const eb = {};
function C_(e, t = !1) {
  let n, r, i = eb;
  function s(u) {
    n = e(u).then(() => {
      if (r) {
        const { value: l } = r;
        r = null, s(l);
      } else
        n = null;
    });
  }
  function o(u) {
    r = { event: u };
  }
  function a(u) {
    n ? o(u) : s(u);
  }
  function c(u) {
    i !== u && requestAnimationFrame(() => {
      const l = i;
      i = eb, a(l);
    }), i = u;
  }
  return t ? c : a;
}
class eu {
  /**
   * Constructor.
   * @param {*} filterSelection An optional selection to interactively filter
   *  this client's data. If provided, a coordinator will re-query and update
   *  the client when the selection updates.
   */
  constructor(t) {
    this._filterBy = t, this._requestUpdate = C_(() => this.requestQuery(), !0), this._coordinator = null;
  }
  /**
   * Return this client's connected coordinator.
   */
  get coordinator() {
    return this._coordinator;
  }
  /**
   * Set this client's connected coordinator.
   */
  set coordinator(t) {
    this._coordinator = t;
  }
  /**
   * Return this client's filter selection.
   */
  get filterBy() {
    return this._filterBy;
  }
  /**
   * Return a boolean indicating if the client query can be indexed. Should
   * return true if changes to the filterBy selection does not change the
   * groupby domain of the client query.
   */
  get filterIndexable() {
    return !0;
  }
  /**
   * Return an array of fields queried by this client.
   * @returns {object[]|null} The fields to retrieve info for.
   */
  fields() {
    return null;
  }
  /**
   * Called by the coordinator to set the field info for this client.
   * @param {*} info The field info result.
   * @returns {this}
   */
  fieldInfo(t) {
    return this;
  }
  /**
   * Return a query specifying the data needed by this client.
   * @param {*} [filter] The filtering criteria to apply in the query.
   * @returns {*} The client query
   */
  query(t) {
    return null;
  }
  /**
   * Called by the coordinator to inform the client that a query is pending.
   * @returns {this}
   */
  queryPending() {
    return this;
  }
  /**
   * Called by the coordinator to return a query result.
   * @param {*} data The query result.
   * @returns {this}
   */
  queryResult(t) {
    return this;
  }
  /**
   * Called by the coordinator to report a query execution error.
   * @param {*} error
   * @returns {this}
   */
  queryError(t) {
    return this;
  }
  /**
   * Request the coordinator to execute a query for this client.
   * If an explicit query is not provided, the client query method will
   * be called, filtered by the current filterBy selection.
   */
  requestQuery(t) {
    var r;
    const n = t || this.query((r = this.filterBy) == null ? void 0 : r.predicate(this));
    return this._coordinator.requestQuery(this, n);
  }
  /**
   * Request that the coordinator perform a throttled update of this client
   * using the default query. Unlike requestQuery, for which every call will
   * result in an executed query, multiple calls to requestUpdate may be
   * consolidated into a single update.
   */
  requestUpdate() {
    this._requestUpdate();
  }
  /**
   * Requests a client update.
   * For example to (re-)render an interface component.
   *
   * @returns {this | Promise<any>}
   */
  update() {
    return this;
  }
}
function bt(e, t, n, r) {
  function i(s) {
    return s instanceof n ? s : new n(function(o) {
      o(s);
    });
  }
  return new (n || (n = Promise))(function(s, o) {
    function a(l) {
      try {
        u(r.next(l));
      } catch (f) {
        o(f);
      }
    }
    function c(l) {
      try {
        u(r.throw(l));
      } catch (f) {
        o(f);
      }
    }
    function u(l) {
      l.done ? s(l.value) : i(l.value).then(a, c);
    }
    u((r = r.apply(e, t || [])).next());
  });
}
function nb(e) {
  var t = typeof Symbol == "function" && Symbol.iterator, n = t && e[t], r = 0;
  if (n) return n.call(e);
  if (e && typeof e.length == "number") return {
    next: function() {
      return e && r >= e.length && (e = void 0), { value: e && e[r++], done: !e };
    }
  };
  throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
function vt(e) {
  return this instanceof vt ? (this.v = e, this) : new vt(e);
}
function ur(e, t, n) {
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  var r = n.apply(e, t || []), i, s = [];
  return i = {}, a("next"), a("throw"), a("return", o), i[Symbol.asyncIterator] = function() {
    return this;
  }, i;
  function o(d) {
    return function(p) {
      return Promise.resolve(p).then(d, f);
    };
  }
  function a(d, p) {
    r[d] && (i[d] = function(y) {
      return new Promise(function(m, g) {
        s.push([d, y, m, g]) > 1 || c(d, y);
      });
    }, p && (i[d] = p(i[d])));
  }
  function c(d, p) {
    try {
      u(r[d](p));
    } catch (y) {
      h(s[0][3], y);
    }
  }
  function u(d) {
    d.value instanceof vt ? Promise.resolve(d.value.v).then(l, f) : h(s[0][2], d);
  }
  function l(d) {
    c("next", d);
  }
  function f(d) {
    c("throw", d);
  }
  function h(d, p) {
    d(p), s.shift(), s.length && c(s[0][0], s[0][1]);
  }
}
function Tl(e) {
  var t, n;
  return t = {}, r("next"), r("throw", function(i) {
    throw i;
  }), r("return"), t[Symbol.iterator] = function() {
    return this;
  }, t;
  function r(i, s) {
    t[i] = e[i] ? function(o) {
      return (n = !n) ? { value: vt(e[i](o)), done: !1 } : s ? s(o) : o;
    } : s;
  }
}
function So(e) {
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  var t = e[Symbol.asyncIterator], n;
  return t ? t.call(e) : (e = typeof nb == "function" ? nb(e) : e[Symbol.iterator](), n = {}, r("next"), r("throw"), r("return"), n[Symbol.asyncIterator] = function() {
    return this;
  }, n);
  function r(s) {
    n[s] = e[s] && function(o) {
      return new Promise(function(a, c) {
        o = e[s](o), i(a, c, o.done, o.value);
      });
    };
  }
  function i(s, o, a, c) {
    Promise.resolve(c).then(function(u) {
      s({ value: u, done: a });
    }, o);
  }
}
const tD = new TextDecoder("utf-8"), y0 = (e) => tD.decode(e), eD = new TextEncoder(), nm = (e) => eD.encode(e), nD = (e) => typeof e == "number", rD = (e) => typeof e == "boolean", Re = (e) => typeof e == "function", Pn = (e) => e != null && Object(e) === e, _c = (e) => Pn(e) && Re(e.then), jh = (e) => Pn(e) && Re(e[Symbol.iterator]), rm = (e) => Pn(e) && Re(e[Symbol.asyncIterator]), m0 = (e) => Pn(e) && Pn(e.schema), P_ = (e) => Pn(e) && "done" in e && "value" in e, U_ = (e) => Pn(e) && Re(e.stat) && nD(e.fd), z_ = (e) => Pn(e) && im(e.body), q_ = (e) => "_getDOMStream" in e && "_getNodeStream" in e, im = (e) => Pn(e) && Re(e.cancel) && Re(e.getReader) && !q_(e), j_ = (e) => Pn(e) && Re(e.read) && Re(e.pipe) && rD(e.readable) && !q_(e), iD = (e) => Pn(e) && Re(e.clear) && Re(e.bytes) && Re(e.position) && Re(e.setPosition) && Re(e.capacity) && Re(e.getBufferIdentifier) && Re(e.createLong), sm = typeof SharedArrayBuffer < "u" ? SharedArrayBuffer : ArrayBuffer;
function sD(e) {
  const t = e[0] ? [e[0]] : [];
  let n, r, i, s;
  for (let o, a, c = 0, u = 0, l = e.length; ++c < l; ) {
    if (o = t[u], a = e[c], !o || !a || o.buffer !== a.buffer || a.byteOffset < o.byteOffset) {
      a && (t[++u] = a);
      continue;
    }
    if ({ byteOffset: n, byteLength: i } = o, { byteOffset: r, byteLength: s } = a, n + i < r || r + s < n) {
      a && (t[++u] = a);
      continue;
    }
    t[u] = new Uint8Array(o.buffer, n, r - n + s);
  }
  return t;
}
function rb(e, t, n = 0, r = t.byteLength) {
  const i = e.byteLength, s = new Uint8Array(e.buffer, e.byteOffset, i), o = new Uint8Array(t.buffer, t.byteOffset, Math.min(r, i));
  return s.set(o, n), e;
}
function mr(e, t) {
  const n = sD(e), r = n.reduce((l, f) => l + f.byteLength, 0);
  let i, s, o, a = 0, c = -1;
  const u = Math.min(t || Number.POSITIVE_INFINITY, r);
  for (const l = n.length; ++c < l; ) {
    if (i = n[c], s = i.subarray(0, Math.min(i.length, u - a)), u <= a + s.length) {
      s.length < i.length ? n[c] = i.subarray(s.length) : s.length === i.length && c++, o ? rb(o, s, a) : o = s;
      break;
    }
    rb(o || (o = new Uint8Array(u)), s, a), a += s.length;
  }
  return [o || new Uint8Array(0), n.slice(c), r - (o ? o.byteLength : 0)];
}
function Yt(e, t) {
  let n = P_(t) ? t.value : t;
  return n instanceof e ? e === Uint8Array ? new e(n.buffer, n.byteOffset, n.byteLength) : n : n ? (typeof n == "string" && (n = nm(n)), n instanceof ArrayBuffer ? new e(n) : n instanceof sm ? new e(n) : iD(n) ? Yt(e, n.bytes()) : ArrayBuffer.isView(n) ? n.byteLength <= 0 ? new e(0) : new e(n.buffer, n.byteOffset, n.byteLength / e.BYTES_PER_ELEMENT) : e.from(n)) : new e(0);
}
const Na = (e) => Yt(Int32Array, e), ib = (e) => Yt(BigInt64Array, e), Dt = (e) => Yt(Uint8Array, e), g0 = (e) => (e.next(), e);
function* oD(e, t) {
  const n = function* (i) {
    yield i;
  }, r = typeof t == "string" || ArrayBuffer.isView(t) || t instanceof ArrayBuffer || t instanceof sm ? n(t) : jh(t) ? t : n(t);
  return yield* g0(function* (i) {
    let s = null;
    do
      s = i.next(yield Yt(e, s));
    while (!s.done);
  }(r[Symbol.iterator]())), new e();
}
const aD = (e) => oD(Uint8Array, e);
function V_(e, t) {
  return ur(this, arguments, function* () {
    if (_c(t))
      return yield vt(yield vt(yield* Tl(So(V_(e, yield vt(t))))));
    const r = function(o) {
      return ur(this, arguments, function* () {
        yield yield vt(yield vt(o));
      });
    }, i = function(o) {
      return ur(this, arguments, function* () {
        yield vt(yield* Tl(So(g0(function* (a) {
          let c = null;
          do
            c = a.next(yield c == null ? void 0 : c.value);
          while (!c.done);
        }(o[Symbol.iterator]())))));
      });
    }, s = typeof t == "string" || ArrayBuffer.isView(t) || t instanceof ArrayBuffer || t instanceof sm ? r(t) : jh(t) ? i(t) : rm(t) ? t : r(t);
    return yield vt(
      // otherwise if AsyncIterable, use it
      yield* Tl(So(g0(function(o) {
        return ur(this, arguments, function* () {
          let a = null;
          do
            a = yield vt(o.next(yield yield vt(Yt(e, a))));
          while (!a.done);
        });
      }(s[Symbol.asyncIterator]()))))
    ), yield vt(new e());
  });
}
const cD = (e) => V_(Uint8Array, e);
function uD(e, t) {
  let n = 0;
  const r = e.length;
  if (r !== t.length)
    return !1;
  if (r > 0)
    do
      if (e[n] !== t[n])
        return !1;
    while (++n < r);
  return !0;
}
const mn = {
  fromIterable(e) {
    return ju(lD(e));
  },
  fromAsyncIterable(e) {
    return ju(fD(e));
  },
  fromDOMStream(e) {
    return ju(hD(e));
  },
  fromNodeStream(e) {
    return ju(pD(e));
  },
  // @ts-ignore
  toDOMStream(e, t) {
    throw new Error('"toDOMStream" not available in this environment');
  },
  // @ts-ignore
  toNodeStream(e, t) {
    throw new Error('"toNodeStream" not available in this environment');
  }
}, ju = (e) => (e.next(), e);
function* lD(e) {
  let t, n = !1, r = [], i, s, o, a = 0;
  function c() {
    return s === "peek" ? mr(r, o)[0] : ([i, r, a] = mr(r, o), i);
  }
  ({ cmd: s, size: o } = (yield null) || { cmd: "read", size: 0 });
  const u = aD(e)[Symbol.iterator]();
  try {
    do
      if ({ done: t, value: i } = Number.isNaN(o - a) ? u.next() : u.next(o - a), !t && i.byteLength > 0 && (r.push(i), a += i.byteLength), t || o <= a)
        do
          ({ cmd: s, size: o } = yield c());
        while (o < a);
    while (!t);
  } catch (l) {
    (n = !0) && typeof u.throw == "function" && u.throw(l);
  } finally {
    n === !1 && typeof u.return == "function" && u.return(null);
  }
  return null;
}
function fD(e) {
  return ur(this, arguments, function* () {
    let n, r = !1, i = [], s, o, a, c = 0;
    function u() {
      return o === "peek" ? mr(i, a)[0] : ([s, i, c] = mr(i, a), s);
    }
    ({ cmd: o, size: a } = (yield yield vt(null)) || { cmd: "read", size: 0 });
    const l = cD(e)[Symbol.asyncIterator]();
    try {
      do
        if ({ done: n, value: s } = Number.isNaN(a - c) ? yield vt(l.next()) : yield vt(l.next(a - c)), !n && s.byteLength > 0 && (i.push(s), c += s.byteLength), n || a <= c)
          do
            ({ cmd: o, size: a } = yield yield vt(u()));
          while (a < c);
      while (!n);
    } catch (f) {
      (r = !0) && typeof l.throw == "function" && (yield vt(l.throw(f)));
    } finally {
      r === !1 && typeof l.return == "function" && (yield vt(l.return(new Uint8Array(0))));
    }
    return yield vt(null);
  });
}
function hD(e) {
  return ur(this, arguments, function* () {
    let n = !1, r = !1, i = [], s, o, a, c = 0;
    function u() {
      return o === "peek" ? mr(i, a)[0] : ([s, i, c] = mr(i, a), s);
    }
    ({ cmd: o, size: a } = (yield yield vt(null)) || { cmd: "read", size: 0 });
    const l = new dD(e);
    try {
      do
        if ({ done: n, value: s } = Number.isNaN(a - c) ? yield vt(l.read()) : yield vt(l.read(a - c)), !n && s.byteLength > 0 && (i.push(Dt(s)), c += s.byteLength), n || a <= c)
          do
            ({ cmd: o, size: a } = yield yield vt(u()));
          while (a < c);
      while (!n);
    } catch (f) {
      (r = !0) && (yield vt(l.cancel(f)));
    } finally {
      r === !1 ? yield vt(l.cancel()) : e.locked && l.releaseLock();
    }
    return yield vt(null);
  });
}
class dD {
  constructor(t) {
    this.source = t, this.reader = null, this.reader = this.source.getReader(), this.reader.closed.catch(() => {
    });
  }
  get closed() {
    return this.reader ? this.reader.closed.catch(() => {
    }) : Promise.resolve();
  }
  releaseLock() {
    this.reader && this.reader.releaseLock(), this.reader = null;
  }
  cancel(t) {
    return bt(this, void 0, void 0, function* () {
      const { reader: n, source: r } = this;
      n && (yield n.cancel(t).catch(() => {
      })), r && r.locked && this.releaseLock();
    });
  }
  read(t) {
    return bt(this, void 0, void 0, function* () {
      if (t === 0)
        return { done: this.reader == null, value: new Uint8Array(0) };
      const n = yield this.reader.read();
      return !n.done && (n.value = Dt(n)), n;
    });
  }
}
const op = (e, t) => {
  const n = (i) => r([t, i]);
  let r;
  return [t, n, new Promise((i) => (r = i) && e.once(t, n))];
};
function pD(e) {
  return ur(this, arguments, function* () {
    const n = [];
    let r = "error", i = !1, s = null, o, a, c = 0, u = [], l;
    function f() {
      return o === "peek" ? mr(u, a)[0] : ([l, u, c] = mr(u, a), l);
    }
    if ({ cmd: o, size: a } = (yield yield vt(null)) || { cmd: "read", size: 0 }, e.isTTY)
      return yield yield vt(new Uint8Array(0)), yield vt(null);
    try {
      n[0] = op(e, "end"), n[1] = op(e, "error");
      do {
        if (n[2] = op(e, "readable"), [r, s] = yield vt(Promise.race(n.map((d) => d[2]))), r === "error")
          break;
        if ((i = r === "end") || (Number.isFinite(a - c) ? (l = Dt(e.read(a - c)), l.byteLength < a - c && (l = Dt(e.read()))) : l = Dt(e.read()), l.byteLength > 0 && (u.push(l), c += l.byteLength)), i || a <= c)
          do
            ({ cmd: o, size: a } = yield yield vt(f()));
          while (a < c);
      } while (!i);
    } finally {
      yield vt(h(n, r === "error" ? s : null));
    }
    return yield vt(null);
    function h(d, p) {
      return l = u = null, new Promise((y, m) => {
        for (const [g, b] of d)
          e.off(g, b);
        try {
          const g = e.destroy;
          g && g.call(e, p), p = void 0;
        } catch (g) {
          p = g || p;
        } finally {
          p != null ? m(p) : y();
        }
      });
    }
  });
}
var he;
(function(e) {
  e[e.V1 = 0] = "V1", e[e.V2 = 1] = "V2", e[e.V3 = 2] = "V3", e[e.V4 = 3] = "V4", e[e.V5 = 4] = "V5";
})(he || (he = {}));
var Je;
(function(e) {
  e[e.Sparse = 0] = "Sparse", e[e.Dense = 1] = "Dense";
})(Je || (Je = {}));
var Oe;
(function(e) {
  e[e.HALF = 0] = "HALF", e[e.SINGLE = 1] = "SINGLE", e[e.DOUBLE = 2] = "DOUBLE";
})(Oe || (Oe = {}));
var An;
(function(e) {
  e[e.DAY = 0] = "DAY", e[e.MILLISECOND = 1] = "MILLISECOND";
})(An || (An = {}));
var ct;
(function(e) {
  e[e.SECOND = 0] = "SECOND", e[e.MILLISECOND = 1] = "MILLISECOND", e[e.MICROSECOND = 2] = "MICROSECOND", e[e.NANOSECOND = 3] = "NANOSECOND";
})(ct || (ct = {}));
var gr;
(function(e) {
  e[e.YEAR_MONTH = 0] = "YEAR_MONTH", e[e.DAY_TIME = 1] = "DAY_TIME", e[e.MONTH_DAY_NANO = 2] = "MONTH_DAY_NANO";
})(gr || (gr = {}));
const ap = 2, ir = 4, qr = 4, qt = 4, bi = new Int32Array(2), sb = new Float32Array(bi.buffer), ob = new Float64Array(bi.buffer), Vu = new Uint16Array(new Uint8Array([1, 0]).buffer)[0] === 1;
var b0;
(function(e) {
  e[e.UTF8_BYTES = 1] = "UTF8_BYTES", e[e.UTF16_STRING = 2] = "UTF16_STRING";
})(b0 || (b0 = {}));
let Bo = class Y_ {
  /**
   * Create a new ByteBuffer with a given array of bytes (`Uint8Array`)
   */
  constructor(t) {
    this.bytes_ = t, this.position_ = 0, this.text_decoder_ = new TextDecoder();
  }
  /**
   * Create and allocate a new ByteBuffer with a given size.
   */
  static allocate(t) {
    return new Y_(new Uint8Array(t));
  }
  clear() {
    this.position_ = 0;
  }
  /**
   * Get the underlying `Uint8Array`.
   */
  bytes() {
    return this.bytes_;
  }
  /**
   * Get the buffer's position.
   */
  position() {
    return this.position_;
  }
  /**
   * Set the buffer's position.
   */
  setPosition(t) {
    this.position_ = t;
  }
  /**
   * Get the buffer's capacity.
   */
  capacity() {
    return this.bytes_.length;
  }
  readInt8(t) {
    return this.readUint8(t) << 24 >> 24;
  }
  readUint8(t) {
    return this.bytes_[t];
  }
  readInt16(t) {
    return this.readUint16(t) << 16 >> 16;
  }
  readUint16(t) {
    return this.bytes_[t] | this.bytes_[t + 1] << 8;
  }
  readInt32(t) {
    return this.bytes_[t] | this.bytes_[t + 1] << 8 | this.bytes_[t + 2] << 16 | this.bytes_[t + 3] << 24;
  }
  readUint32(t) {
    return this.readInt32(t) >>> 0;
  }
  readInt64(t) {
    return BigInt.asIntN(64, BigInt(this.readUint32(t)) + (BigInt(this.readUint32(t + 4)) << BigInt(32)));
  }
  readUint64(t) {
    return BigInt.asUintN(64, BigInt(this.readUint32(t)) + (BigInt(this.readUint32(t + 4)) << BigInt(32)));
  }
  readFloat32(t) {
    return bi[0] = this.readInt32(t), sb[0];
  }
  readFloat64(t) {
    return bi[Vu ? 0 : 1] = this.readInt32(t), bi[Vu ? 1 : 0] = this.readInt32(t + 4), ob[0];
  }
  writeInt8(t, n) {
    this.bytes_[t] = n;
  }
  writeUint8(t, n) {
    this.bytes_[t] = n;
  }
  writeInt16(t, n) {
    this.bytes_[t] = n, this.bytes_[t + 1] = n >> 8;
  }
  writeUint16(t, n) {
    this.bytes_[t] = n, this.bytes_[t + 1] = n >> 8;
  }
  writeInt32(t, n) {
    this.bytes_[t] = n, this.bytes_[t + 1] = n >> 8, this.bytes_[t + 2] = n >> 16, this.bytes_[t + 3] = n >> 24;
  }
  writeUint32(t, n) {
    this.bytes_[t] = n, this.bytes_[t + 1] = n >> 8, this.bytes_[t + 2] = n >> 16, this.bytes_[t + 3] = n >> 24;
  }
  writeInt64(t, n) {
    this.writeInt32(t, Number(BigInt.asIntN(32, n))), this.writeInt32(t + 4, Number(BigInt.asIntN(32, n >> BigInt(32))));
  }
  writeUint64(t, n) {
    this.writeUint32(t, Number(BigInt.asUintN(32, n))), this.writeUint32(t + 4, Number(BigInt.asUintN(32, n >> BigInt(32))));
  }
  writeFloat32(t, n) {
    sb[0] = n, this.writeInt32(t, bi[0]);
  }
  writeFloat64(t, n) {
    ob[0] = n, this.writeInt32(t, bi[Vu ? 0 : 1]), this.writeInt32(t + 4, bi[Vu ? 1 : 0]);
  }
  /**
   * Return the file identifier.   Behavior is undefined for FlatBuffers whose
   * schema does not include a file_identifier (likely points at padding or the
   * start of a the root vtable).
   */
  getBufferIdentifier() {
    if (this.bytes_.length < this.position_ + ir + qr)
      throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");
    let t = "";
    for (let n = 0; n < qr; n++)
      t += String.fromCharCode(this.readInt8(this.position_ + ir + n));
    return t;
  }
  /**
   * Look up a field in the vtable, return an offset into the object, or 0 if the
   * field is not present.
   */
  __offset(t, n) {
    const r = t - this.readInt32(t);
    return n < this.readInt16(r) ? this.readInt16(r + n) : 0;
  }
  /**
   * Initialize any Table-derived type to point to the union at the given offset.
   */
  __union(t, n) {
    return t.bb_pos = n + this.readInt32(n), t.bb = this, t;
  }
  /**
   * Create a JavaScript string from UTF-8 data stored inside the FlatBuffer.
   * This allocates a new string and converts to wide chars upon each access.
   *
   * To avoid the conversion to string, pass Encoding.UTF8_BYTES as the
   * "optionalEncoding" argument. This is useful for avoiding conversion when
   * the data will just be packaged back up in another FlatBuffer later on.
   *
   * @param offset
   * @param opt_encoding Defaults to UTF16_STRING
   */
  __string(t, n) {
    t += this.readInt32(t);
    const r = this.readInt32(t);
    t += ir;
    const i = this.bytes_.subarray(t, t + r);
    return n === b0.UTF8_BYTES ? i : this.text_decoder_.decode(i);
  }
  /**
   * Handle unions that can contain string as its member, if a Table-derived type then initialize it,
   * if a string then return a new one
   *
   * WARNING: strings are immutable in JS so we can't change the string that the user gave us, this
   * makes the behaviour of __union_with_string different compared to __union
   */
  __union_with_string(t, n) {
    return typeof t == "string" ? this.__string(n) : this.__union(t, n);
  }
  /**
   * Retrieve the relative offset stored at "offset"
   */
  __indirect(t) {
    return t + this.readInt32(t);
  }
  /**
   * Get the start of data of a vector whose offset is stored at "offset" in this object.
   */
  __vector(t) {
    return t + this.readInt32(t) + ir;
  }
  /**
   * Get the length of a vector whose offset is stored at "offset" in this object.
   */
  __vector_len(t) {
    return this.readInt32(t + this.readInt32(t));
  }
  __has_identifier(t) {
    if (t.length != qr)
      throw new Error("FlatBuffers: file identifier must be length " + qr);
    for (let n = 0; n < qr; n++)
      if (t.charCodeAt(n) != this.readInt8(this.position() + ir + n))
        return !1;
    return !0;
  }
  /**
   * A helper function for generating list for obj api
   */
  createScalarList(t, n) {
    const r = [];
    for (let i = 0; i < n; ++i) {
      const s = t(i);
      s !== null && r.push(s);
    }
    return r;
  }
  /**
   * A helper function for generating list for obj api
   * @param listAccessor function that accepts an index and return data at that index
   * @param listLength listLength
   * @param res result list
   */
  createObjList(t, n) {
    const r = [];
    for (let i = 0; i < n; ++i) {
      const s = t(i);
      s !== null && r.push(s.unpack());
    }
    return r;
  }
}, W_ = class X_ {
  /**
   * Create a FlatBufferBuilder.
   */
  constructor(t) {
    this.minalign = 1, this.vtable = null, this.vtable_in_use = 0, this.isNested = !1, this.object_start = 0, this.vtables = [], this.vector_num_elems = 0, this.force_defaults = !1, this.string_maps = null, this.text_encoder = new TextEncoder();
    let n;
    t ? n = t : n = 1024, this.bb = Bo.allocate(n), this.space = n;
  }
  clear() {
    this.bb.clear(), this.space = this.bb.capacity(), this.minalign = 1, this.vtable = null, this.vtable_in_use = 0, this.isNested = !1, this.object_start = 0, this.vtables = [], this.vector_num_elems = 0, this.force_defaults = !1, this.string_maps = null;
  }
  /**
   * In order to save space, fields that are set to their default value
   * don't get serialized into the buffer. Forcing defaults provides a
   * way to manually disable this optimization.
   *
   * @param forceDefaults true always serializes default values
   */
  forceDefaults(t) {
    this.force_defaults = t;
  }
  /**
   * Get the ByteBuffer representing the FlatBuffer. Only call this after you've
   * called finish(). The actual data starts at the ByteBuffer's current position,
   * not necessarily at 0.
   */
  dataBuffer() {
    return this.bb;
  }
  /**
   * Get the bytes representing the FlatBuffer. Only call this after you've
   * called finish().
   */
  asUint8Array() {
    return this.bb.bytes().subarray(this.bb.position(), this.bb.position() + this.offset());
  }
  /**
   * Prepare to write an element of `size` after `additional_bytes` have been
   * written, e.g. if you write a string, you need to align such the int length
   * field is aligned to 4 bytes, and the string data follows it directly. If all
   * you need to do is alignment, `additional_bytes` will be 0.
   *
   * @param size This is the of the new element to write
   * @param additional_bytes The padding size
   */
  prep(t, n) {
    t > this.minalign && (this.minalign = t);
    const r = ~(this.bb.capacity() - this.space + n) + 1 & t - 1;
    for (; this.space < r + t + n; ) {
      const i = this.bb.capacity();
      this.bb = X_.growByteBuffer(this.bb), this.space += this.bb.capacity() - i;
    }
    this.pad(r);
  }
  pad(t) {
    for (let n = 0; n < t; n++)
      this.bb.writeInt8(--this.space, 0);
  }
  writeInt8(t) {
    this.bb.writeInt8(this.space -= 1, t);
  }
  writeInt16(t) {
    this.bb.writeInt16(this.space -= 2, t);
  }
  writeInt32(t) {
    this.bb.writeInt32(this.space -= 4, t);
  }
  writeInt64(t) {
    this.bb.writeInt64(this.space -= 8, t);
  }
  writeFloat32(t) {
    this.bb.writeFloat32(this.space -= 4, t);
  }
  writeFloat64(t) {
    this.bb.writeFloat64(this.space -= 8, t);
  }
  /**
   * Add an `int8` to the buffer, properly aligned, and grows the buffer (if necessary).
   * @param value The `int8` to add the buffer.
   */
  addInt8(t) {
    this.prep(1, 0), this.writeInt8(t);
  }
  /**
   * Add an `int16` to the buffer, properly aligned, and grows the buffer (if necessary).
   * @param value The `int16` to add the buffer.
   */
  addInt16(t) {
    this.prep(2, 0), this.writeInt16(t);
  }
  /**
   * Add an `int32` to the buffer, properly aligned, and grows the buffer (if necessary).
   * @param value The `int32` to add the buffer.
   */
  addInt32(t) {
    this.prep(4, 0), this.writeInt32(t);
  }
  /**
   * Add an `int64` to the buffer, properly aligned, and grows the buffer (if necessary).
   * @param value The `int64` to add the buffer.
   */
  addInt64(t) {
    this.prep(8, 0), this.writeInt64(t);
  }
  /**
   * Add a `float32` to the buffer, properly aligned, and grows the buffer (if necessary).
   * @param value The `float32` to add the buffer.
   */
  addFloat32(t) {
    this.prep(4, 0), this.writeFloat32(t);
  }
  /**
   * Add a `float64` to the buffer, properly aligned, and grows the buffer (if necessary).
   * @param value The `float64` to add the buffer.
   */
  addFloat64(t) {
    this.prep(8, 0), this.writeFloat64(t);
  }
  addFieldInt8(t, n, r) {
    (this.force_defaults || n != r) && (this.addInt8(n), this.slot(t));
  }
  addFieldInt16(t, n, r) {
    (this.force_defaults || n != r) && (this.addInt16(n), this.slot(t));
  }
  addFieldInt32(t, n, r) {
    (this.force_defaults || n != r) && (this.addInt32(n), this.slot(t));
  }
  addFieldInt64(t, n, r) {
    (this.force_defaults || n !== r) && (this.addInt64(n), this.slot(t));
  }
  addFieldFloat32(t, n, r) {
    (this.force_defaults || n != r) && (this.addFloat32(n), this.slot(t));
  }
  addFieldFloat64(t, n, r) {
    (this.force_defaults || n != r) && (this.addFloat64(n), this.slot(t));
  }
  addFieldOffset(t, n, r) {
    (this.force_defaults || n != r) && (this.addOffset(n), this.slot(t));
  }
  /**
   * Structs are stored inline, so nothing additional is being added. `d` is always 0.
   */
  addFieldStruct(t, n, r) {
    n != r && (this.nested(n), this.slot(t));
  }
  /**
   * Structures are always stored inline, they need to be created right
   * where they're used.  You'll get this assertion failure if you
   * created it elsewhere.
   */
  nested(t) {
    if (t != this.offset())
      throw new TypeError("FlatBuffers: struct must be serialized inline.");
  }
  /**
   * Should not be creating any other object, string or vector
   * while an object is being constructed
   */
  notNested() {
    if (this.isNested)
      throw new TypeError("FlatBuffers: object serialization must not be nested.");
  }
  /**
   * Set the current vtable at `voffset` to the current location in the buffer.
   */
  slot(t) {
    this.vtable !== null && (this.vtable[t] = this.offset());
  }
  /**
   * @returns Offset relative to the end of the buffer.
   */
  offset() {
    return this.bb.capacity() - this.space;
  }
  /**
   * Doubles the size of the backing ByteBuffer and copies the old data towards
   * the end of the new buffer (since we build the buffer backwards).
   *
   * @param bb The current buffer with the existing data
   * @returns A new byte buffer with the old data copied
   * to it. The data is located at the end of the buffer.
   *
   * uint8Array.set() formally takes {Array<number>|ArrayBufferView}, so to pass
   * it a uint8Array we need to suppress the type check:
   * @suppress {checkTypes}
   */
  static growByteBuffer(t) {
    const n = t.capacity();
    if (n & 3221225472)
      throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");
    const r = n << 1, i = Bo.allocate(r);
    return i.setPosition(r - n), i.bytes().set(t.bytes(), r - n), i;
  }
  /**
   * Adds on offset, relative to where it will be written.
   *
   * @param offset The offset to add.
   */
  addOffset(t) {
    this.prep(ir, 0), this.writeInt32(this.offset() - t + ir);
  }
  /**
   * Start encoding a new object in the buffer.  Users will not usually need to
   * call this directly. The FlatBuffers compiler will generate helper methods
   * that call this method internally.
   */
  startObject(t) {
    this.notNested(), this.vtable == null && (this.vtable = []), this.vtable_in_use = t;
    for (let n = 0; n < t; n++)
      this.vtable[n] = 0;
    this.isNested = !0, this.object_start = this.offset();
  }
  /**
   * Finish off writing the object that is under construction.
   *
   * @returns The offset to the object inside `dataBuffer`
   */
  endObject() {
    if (this.vtable == null || !this.isNested)
      throw new Error("FlatBuffers: endObject called without startObject");
    this.addInt32(0);
    const t = this.offset();
    let n = this.vtable_in_use - 1;
    for (; n >= 0 && this.vtable[n] == 0; n--)
      ;
    const r = n + 1;
    for (; n >= 0; n--)
      this.addInt16(this.vtable[n] != 0 ? t - this.vtable[n] : 0);
    const i = 2;
    this.addInt16(t - this.object_start);
    const s = (r + i) * ap;
    this.addInt16(s);
    let o = 0;
    const a = this.space;
    t: for (n = 0; n < this.vtables.length; n++) {
      const c = this.bb.capacity() - this.vtables[n];
      if (s == this.bb.readInt16(c)) {
        for (let u = ap; u < s; u += ap)
          if (this.bb.readInt16(a + u) != this.bb.readInt16(c + u))
            continue t;
        o = this.vtables[n];
        break;
      }
    }
    return o ? (this.space = this.bb.capacity() - t, this.bb.writeInt32(this.space, o - t)) : (this.vtables.push(this.offset()), this.bb.writeInt32(this.bb.capacity() - t, this.offset() - t)), this.isNested = !1, t;
  }
  /**
   * Finalize a buffer, poiting to the given `root_table`.
   */
  finish(t, n, r) {
    const i = r ? qt : 0;
    if (n) {
      const s = n;
      if (this.prep(this.minalign, ir + qr + i), s.length != qr)
        throw new TypeError("FlatBuffers: file identifier must be length " + qr);
      for (let o = qr - 1; o >= 0; o--)
        this.writeInt8(s.charCodeAt(o));
    }
    this.prep(this.minalign, ir + i), this.addOffset(t), i && this.addInt32(this.bb.capacity() - this.space), this.bb.setPosition(this.space);
  }
  /**
   * Finalize a size prefixed buffer, pointing to the given `root_table`.
   */
  finishSizePrefixed(t, n) {
    this.finish(t, n, !0);
  }
  /**
   * This checks a required field has been set in a given table that has
   * just been constructed.
   */
  requiredField(t, n) {
    const r = this.bb.capacity() - t, i = r - this.bb.readInt32(r);
    if (!(n < this.bb.readInt16(i) && this.bb.readInt16(i + n) != 0))
      throw new TypeError("FlatBuffers: field " + n + " must be set");
  }
  /**
   * Start a new array/vector of objects.  Users usually will not call
   * this directly. The FlatBuffers compiler will create a start/end
   * method for vector types in generated code.
   *
   * @param elem_size The size of each element in the array
   * @param num_elems The number of elements in the array
   * @param alignment The alignment of the array
   */
  startVector(t, n, r) {
    this.notNested(), this.vector_num_elems = n, this.prep(ir, t * n), this.prep(r, t * n);
  }
  /**
   * Finish off the creation of an array and all its elements. The array must be
   * created with `startVector`.
   *
   * @returns The offset at which the newly created array
   * starts.
   */
  endVector() {
    return this.writeInt32(this.vector_num_elems), this.offset();
  }
  /**
   * Encode the string `s` in the buffer using UTF-8. If the string passed has
   * already been seen, we return the offset of the already written string
   *
   * @param s The string to encode
   * @return The offset in the buffer where the encoded string starts
   */
  createSharedString(t) {
    if (!t)
      return 0;
    if (this.string_maps || (this.string_maps = /* @__PURE__ */ new Map()), this.string_maps.has(t))
      return this.string_maps.get(t);
    const n = this.createString(t);
    return this.string_maps.set(t, n), n;
  }
  /**
   * Encode the string `s` in the buffer using UTF-8. If a Uint8Array is passed
   * instead of a string, it is assumed to contain valid UTF-8 encoded data.
   *
   * @param s The string to encode
   * @return The offset in the buffer where the encoded string starts
   */
  createString(t) {
    if (t == null)
      return 0;
    let n;
    return t instanceof Uint8Array ? n = t : n = this.text_encoder.encode(t), this.addInt8(0), this.startVector(1, n.length, 1), this.bb.setPosition(this.space -= n.length), this.bb.bytes().set(n, this.space), this.endVector();
  }
  /**
   * Create a byte vector.
   *
   * @param v The bytes to add
   * @returns The offset in the buffer where the byte vector starts
   */
  createByteVector(t) {
    return t == null ? 0 : (this.startVector(1, t.length, 1), this.bb.setPosition(this.space -= t.length), this.bb.bytes().set(t, this.space), this.endVector());
  }
  /**
   * A helper function to pack an object
   *
   * @returns offset of obj
   */
  createObjectOffset(t) {
    return t === null ? 0 : typeof t == "string" ? this.createString(t) : t.pack(this);
  }
  /**
   * A helper function to pack a list of object
   *
   * @returns list of offsets of each non null object
   */
  createObjectOffsetList(t) {
    const n = [];
    for (let r = 0; r < t.length; ++r) {
      const i = t[r];
      if (i !== null)
        n.push(this.createObjectOffset(i));
      else
        throw new TypeError("FlatBuffers: Argument for createObjectOffsetList cannot contain null.");
    }
    return n;
  }
  createStructOffsetList(t, n) {
    return n(this, t.length), this.createObjectOffsetList(t.slice().reverse()), this.endVector();
  }
};
var Ql;
(function(e) {
  e[e.BUFFER = 0] = "BUFFER";
})(Ql || (Ql = {}));
var tf;
(function(e) {
  e[e.LZ4_FRAME = 0] = "LZ4_FRAME", e[e.ZSTD = 1] = "ZSTD";
})(tf || (tf = {}));
class wi {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsBodyCompression(t, n) {
    return (n || new wi()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsBodyCompression(t, n) {
    return t.setPosition(t.position() + qt), (n || new wi()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  /**
   * Compressor library.
   * For LZ4_FRAME, each compressed buffer must consist of a single frame.
   */
  codec() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt8(this.bb_pos + t) : tf.LZ4_FRAME;
  }
  /**
   * Indicates the way the record batch body was compressed
   */
  method() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? this.bb.readInt8(this.bb_pos + t) : Ql.BUFFER;
  }
  static startBodyCompression(t) {
    t.startObject(2);
  }
  static addCodec(t, n) {
    t.addFieldInt8(0, n, tf.LZ4_FRAME);
  }
  static addMethod(t, n) {
    t.addFieldInt8(1, n, Ql.BUFFER);
  }
  static endBodyCompression(t) {
    return t.endObject();
  }
  static createBodyCompression(t, n, r) {
    return wi.startBodyCompression(t), wi.addCodec(t, n), wi.addMethod(t, r), wi.endBodyCompression(t);
  }
}
class G_ {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  /**
   * The relative offset into the shared memory page where the bytes for this
   * buffer starts
   */
  offset() {
    return this.bb.readInt64(this.bb_pos);
  }
  /**
   * The absolute length (in bytes) of the memory buffer. The memory is found
   * from offset (inclusive) to offset + length (non-inclusive). When building
   * messages using the encapsulated IPC message, padding bytes may be written
   * after a buffer, but such padding bytes do not need to be accounted for in
   * the size here.
   */
  length() {
    return this.bb.readInt64(this.bb_pos + 8);
  }
  static sizeOf() {
    return 16;
  }
  static createBuffer(t, n, r) {
    return t.prep(8, 16), t.writeInt64(BigInt(r ?? 0)), t.writeInt64(BigInt(n ?? 0)), t.offset();
  }
}
let H_ = class {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  /**
   * The number of value slots in the Arrow array at this level of a nested
   * tree
   */
  length() {
    return this.bb.readInt64(this.bb_pos);
  }
  /**
   * The number of observed nulls. Fields with null_count == 0 may choose not
   * to write their physical validity bitmap out as a materialized buffer,
   * instead setting the length of the bitmap buffer to 0.
   */
  nullCount() {
    return this.bb.readInt64(this.bb_pos + 8);
  }
  static sizeOf() {
    return 16;
  }
  static createFieldNode(t, n, r) {
    return t.prep(8, 16), t.writeInt64(BigInt(r ?? 0)), t.writeInt64(BigInt(n ?? 0)), t.offset();
  }
}, Cr = class w0 {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsRecordBatch(t, n) {
    return (n || new w0()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsRecordBatch(t, n) {
    return t.setPosition(t.position() + qt), (n || new w0()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  /**
   * number of records / rows. The arrays in the batch should all have this
   * length
   */
  length() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt64(this.bb_pos + t) : BigInt("0");
  }
  /**
   * Nodes correspond to the pre-ordered flattened logical schema
   */
  nodes(t, n) {
    const r = this.bb.__offset(this.bb_pos, 6);
    return r ? (n || new H_()).__init(this.bb.__vector(this.bb_pos + r) + t * 16, this.bb) : null;
  }
  nodesLength() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  /**
   * Buffers correspond to the pre-ordered flattened buffer tree
   *
   * The number of buffers appended to this list depends on the schema. For
   * example, most primitive arrays will have 2 buffers, 1 for the validity
   * bitmap and 1 for the values. For struct arrays, there will only be a
   * single buffer for the validity (nulls) bitmap
   */
  buffers(t, n) {
    const r = this.bb.__offset(this.bb_pos, 8);
    return r ? (n || new G_()).__init(this.bb.__vector(this.bb_pos + r) + t * 16, this.bb) : null;
  }
  buffersLength() {
    const t = this.bb.__offset(this.bb_pos, 8);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  /**
   * Optional compression of the message body
   */
  compression(t) {
    const n = this.bb.__offset(this.bb_pos, 10);
    return n ? (t || new wi()).__init(this.bb.__indirect(this.bb_pos + n), this.bb) : null;
  }
  static startRecordBatch(t) {
    t.startObject(4);
  }
  static addLength(t, n) {
    t.addFieldInt64(0, n, BigInt("0"));
  }
  static addNodes(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static startNodesVector(t, n) {
    t.startVector(16, n, 8);
  }
  static addBuffers(t, n) {
    t.addFieldOffset(2, n, 0);
  }
  static startBuffersVector(t, n) {
    t.startVector(16, n, 8);
  }
  static addCompression(t, n) {
    t.addFieldOffset(3, n, 0);
  }
  static endRecordBatch(t) {
    return t.endObject();
  }
}, ro = class _0 {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsDictionaryBatch(t, n) {
    return (n || new _0()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDictionaryBatch(t, n) {
    return t.setPosition(t.position() + qt), (n || new _0()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  id() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt64(this.bb_pos + t) : BigInt("0");
  }
  data(t) {
    const n = this.bb.__offset(this.bb_pos, 6);
    return n ? (t || new Cr()).__init(this.bb.__indirect(this.bb_pos + n), this.bb) : null;
  }
  /**
   * If isDelta is true the values in the dictionary are to be appended to a
   * dictionary with the indicated id. If isDelta is false this dictionary
   * should replace the existing dictionary.
   */
  isDelta() {
    const t = this.bb.__offset(this.bb_pos, 8);
    return t ? !!this.bb.readInt8(this.bb_pos + t) : !1;
  }
  static startDictionaryBatch(t) {
    t.startObject(3);
  }
  static addId(t, n) {
    t.addFieldInt64(0, n, BigInt("0"));
  }
  static addData(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static addIsDelta(t, n) {
    t.addFieldInt8(2, +n, 0);
  }
  static endDictionaryBatch(t) {
    return t.endObject();
  }
};
var Co;
(function(e) {
  e[e.Little = 0] = "Little", e[e.Big = 1] = "Big";
})(Co || (Co = {}));
var ef;
(function(e) {
  e[e.DenseArray = 0] = "DenseArray";
})(ef || (ef = {}));
class rn {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsInt(t, n) {
    return (n || new rn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsInt(t, n) {
    return t.setPosition(t.position() + qt), (n || new rn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  bitWidth() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt32(this.bb_pos + t) : 0;
  }
  isSigned() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? !!this.bb.readInt8(this.bb_pos + t) : !1;
  }
  static startInt(t) {
    t.startObject(2);
  }
  static addBitWidth(t, n) {
    t.addFieldInt32(0, n, 0);
  }
  static addIsSigned(t, n) {
    t.addFieldInt8(1, +n, 0);
  }
  static endInt(t) {
    return t.endObject();
  }
  static createInt(t, n, r) {
    return rn.startInt(t), rn.addBitWidth(t, n), rn.addIsSigned(t, r), rn.endInt(t);
  }
}
class jr {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsDictionaryEncoding(t, n) {
    return (n || new jr()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDictionaryEncoding(t, n) {
    return t.setPosition(t.position() + qt), (n || new jr()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  /**
   * The known dictionary id in the application where this data is used. In
   * the file or streaming formats, the dictionary ids are found in the
   * DictionaryBatch messages
   */
  id() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt64(this.bb_pos + t) : BigInt("0");
  }
  /**
   * The dictionary indices are constrained to be non-negative integers. If
   * this field is null, the indices must be signed int32. To maximize
   * cross-language compatibility and performance, implementations are
   * recommended to prefer signed integer types over unsigned integer types
   * and to avoid uint64 indices unless they are required by an application.
   */
  indexType(t) {
    const n = this.bb.__offset(this.bb_pos, 6);
    return n ? (t || new rn()).__init(this.bb.__indirect(this.bb_pos + n), this.bb) : null;
  }
  /**
   * By default, dictionaries are not ordered, or the order does not have
   * semantic meaning. In some statistical, applications, dictionary-encoding
   * is used to represent ordered categorical data, and we provide a way to
   * preserve that metadata here
   */
  isOrdered() {
    const t = this.bb.__offset(this.bb_pos, 8);
    return t ? !!this.bb.readInt8(this.bb_pos + t) : !1;
  }
  dictionaryKind() {
    const t = this.bb.__offset(this.bb_pos, 10);
    return t ? this.bb.readInt16(this.bb_pos + t) : ef.DenseArray;
  }
  static startDictionaryEncoding(t) {
    t.startObject(4);
  }
  static addId(t, n) {
    t.addFieldInt64(0, n, BigInt("0"));
  }
  static addIndexType(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static addIsOrdered(t, n) {
    t.addFieldInt8(2, +n, 0);
  }
  static addDictionaryKind(t, n) {
    t.addFieldInt16(3, n, ef.DenseArray);
  }
  static endDictionaryEncoding(t) {
    return t.endObject();
  }
}
class de {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsKeyValue(t, n) {
    return (n || new de()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsKeyValue(t, n) {
    return t.setPosition(t.position() + qt), (n || new de()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  key(t) {
    const n = this.bb.__offset(this.bb_pos, 4);
    return n ? this.bb.__string(this.bb_pos + n, t) : null;
  }
  value(t) {
    const n = this.bb.__offset(this.bb_pos, 6);
    return n ? this.bb.__string(this.bb_pos + n, t) : null;
  }
  static startKeyValue(t) {
    t.startObject(2);
  }
  static addKey(t, n) {
    t.addFieldOffset(0, n, 0);
  }
  static addValue(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static endKeyValue(t) {
    return t.endObject();
  }
  static createKeyValue(t, n, r) {
    return de.startKeyValue(t), de.addKey(t, n), de.addValue(t, r), de.endKeyValue(t);
  }
}
let ab = class Ya {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsBinary(t, n) {
    return (n || new Ya()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsBinary(t, n) {
    return t.setPosition(t.position() + qt), (n || new Ya()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startBinary(t) {
    t.startObject(0);
  }
  static endBinary(t) {
    return t.endObject();
  }
  static createBinary(t) {
    return Ya.startBinary(t), Ya.endBinary(t);
  }
}, cb = class Wa {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsBool(t, n) {
    return (n || new Wa()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsBool(t, n) {
    return t.setPosition(t.position() + qt), (n || new Wa()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startBool(t) {
    t.startObject(0);
  }
  static endBool(t) {
    return t.endObject();
  }
  static createBool(t) {
    return Wa.startBool(t), Wa.endBool(t);
  }
}, El = class io {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsDate(t, n) {
    return (n || new io()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDate(t, n) {
    return t.setPosition(t.position() + qt), (n || new io()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  unit() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt16(this.bb_pos + t) : An.MILLISECOND;
  }
  static startDate(t) {
    t.startObject(1);
  }
  static addUnit(t, n) {
    t.addFieldInt16(0, n, An.MILLISECOND);
  }
  static endDate(t) {
    return t.endObject();
  }
  static createDate(t, n) {
    return io.startDate(t), io.addUnit(t, n), io.endDate(t);
  }
}, so = class yi {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsDecimal(t, n) {
    return (n || new yi()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDecimal(t, n) {
    return t.setPosition(t.position() + qt), (n || new yi()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  /**
   * Total number of decimal digits
   */
  precision() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt32(this.bb_pos + t) : 0;
  }
  /**
   * Number of digits after the decimal point "."
   */
  scale() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? this.bb.readInt32(this.bb_pos + t) : 0;
  }
  /**
   * Number of bits per value. The only accepted widths are 128 and 256.
   * We use bitWidth for consistency with Int::bitWidth.
   */
  bitWidth() {
    const t = this.bb.__offset(this.bb_pos, 8);
    return t ? this.bb.readInt32(this.bb_pos + t) : 128;
  }
  static startDecimal(t) {
    t.startObject(3);
  }
  static addPrecision(t, n) {
    t.addFieldInt32(0, n, 0);
  }
  static addScale(t, n) {
    t.addFieldInt32(1, n, 0);
  }
  static addBitWidth(t, n) {
    t.addFieldInt32(2, n, 128);
  }
  static endDecimal(t) {
    return t.endObject();
  }
  static createDecimal(t, n, r, i) {
    return yi.startDecimal(t), yi.addPrecision(t, n), yi.addScale(t, r), yi.addBitWidth(t, i), yi.endDecimal(t);
  }
}, Nl = class oo {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsDuration(t, n) {
    return (n || new oo()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDuration(t, n) {
    return t.setPosition(t.position() + qt), (n || new oo()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  unit() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt16(this.bb_pos + t) : ct.MILLISECOND;
  }
  static startDuration(t) {
    t.startObject(1);
  }
  static addUnit(t, n) {
    t.addFieldInt16(0, n, ct.MILLISECOND);
  }
  static endDuration(t) {
    return t.endObject();
  }
  static createDuration(t, n) {
    return oo.startDuration(t), oo.addUnit(t, n), oo.endDuration(t);
  }
}, Dl = class ao {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsFixedSizeBinary(t, n) {
    return (n || new ao()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFixedSizeBinary(t, n) {
    return t.setPosition(t.position() + qt), (n || new ao()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  /**
   * Number of bytes per value
   */
  byteWidth() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt32(this.bb_pos + t) : 0;
  }
  static startFixedSizeBinary(t) {
    t.startObject(1);
  }
  static addByteWidth(t, n) {
    t.addFieldInt32(0, n, 0);
  }
  static endFixedSizeBinary(t) {
    return t.endObject();
  }
  static createFixedSizeBinary(t, n) {
    return ao.startFixedSizeBinary(t), ao.addByteWidth(t, n), ao.endFixedSizeBinary(t);
  }
}, Ol = class co {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsFixedSizeList(t, n) {
    return (n || new co()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFixedSizeList(t, n) {
    return t.setPosition(t.position() + qt), (n || new co()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  /**
   * Number of list items per value
   */
  listSize() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt32(this.bb_pos + t) : 0;
  }
  static startFixedSizeList(t) {
    t.startObject(1);
  }
  static addListSize(t, n) {
    t.addFieldInt32(0, n, 0);
  }
  static endFixedSizeList(t) {
    return t.endObject();
  }
  static createFixedSizeList(t, n) {
    return co.startFixedSizeList(t), co.addListSize(t, n), co.endFixedSizeList(t);
  }
};
class sr {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsFloatingPoint(t, n) {
    return (n || new sr()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFloatingPoint(t, n) {
    return t.setPosition(t.position() + qt), (n || new sr()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  precision() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt16(this.bb_pos + t) : Oe.HALF;
  }
  static startFloatingPoint(t) {
    t.startObject(1);
  }
  static addPrecision(t, n) {
    t.addFieldInt16(0, n, Oe.HALF);
  }
  static endFloatingPoint(t) {
    return t.endObject();
  }
  static createFloatingPoint(t, n) {
    return sr.startFloatingPoint(t), sr.addPrecision(t, n), sr.endFloatingPoint(t);
  }
}
class or {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsInterval(t, n) {
    return (n || new or()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsInterval(t, n) {
    return t.setPosition(t.position() + qt), (n || new or()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  unit() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt16(this.bb_pos + t) : gr.YEAR_MONTH;
  }
  static startInterval(t) {
    t.startObject(1);
  }
  static addUnit(t, n) {
    t.addFieldInt16(0, n, gr.YEAR_MONTH);
  }
  static endInterval(t) {
    return t.endObject();
  }
  static createInterval(t, n) {
    return or.startInterval(t), or.addUnit(t, n), or.endInterval(t);
  }
}
let ub = class Xa {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsLargeBinary(t, n) {
    return (n || new Xa()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsLargeBinary(t, n) {
    return t.setPosition(t.position() + qt), (n || new Xa()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startLargeBinary(t) {
    t.startObject(0);
  }
  static endLargeBinary(t) {
    return t.endObject();
  }
  static createLargeBinary(t) {
    return Xa.startLargeBinary(t), Xa.endLargeBinary(t);
  }
}, lb = class Ga {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsLargeUtf8(t, n) {
    return (n || new Ga()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsLargeUtf8(t, n) {
    return t.setPosition(t.position() + qt), (n || new Ga()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startLargeUtf8(t) {
    t.startObject(0);
  }
  static endLargeUtf8(t) {
    return t.endObject();
  }
  static createLargeUtf8(t) {
    return Ga.startLargeUtf8(t), Ga.endLargeUtf8(t);
  }
}, fb = class Ha {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsList(t, n) {
    return (n || new Ha()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsList(t, n) {
    return t.setPosition(t.position() + qt), (n || new Ha()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startList(t) {
    t.startObject(0);
  }
  static endList(t) {
    return t.endObject();
  }
  static createList(t) {
    return Ha.startList(t), Ha.endList(t);
  }
}, Ll = class uo {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsMap(t, n) {
    return (n || new uo()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsMap(t, n) {
    return t.setPosition(t.position() + qt), (n || new uo()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  /**
   * Set to true if the keys within each value are sorted
   */
  keysSorted() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? !!this.bb.readInt8(this.bb_pos + t) : !1;
  }
  static startMap(t) {
    t.startObject(1);
  }
  static addKeysSorted(t, n) {
    t.addFieldInt8(0, +n, 0);
  }
  static endMap(t) {
    return t.endObject();
  }
  static createMap(t, n) {
    return uo.startMap(t), uo.addKeysSorted(t, n), uo.endMap(t);
  }
}, hb = class Ja {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsNull(t, n) {
    return (n || new Ja()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsNull(t, n) {
    return t.setPosition(t.position() + qt), (n || new Ja()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startNull(t) {
    t.startObject(0);
  }
  static endNull(t) {
    return t.endObject();
  }
  static createNull(t) {
    return Ja.startNull(t), Ja.endNull(t);
  }
};
class us {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsStruct_(t, n) {
    return (n || new us()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsStruct_(t, n) {
    return t.setPosition(t.position() + qt), (n || new us()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startStruct_(t) {
    t.startObject(0);
  }
  static endStruct_(t) {
    return t.endObject();
  }
  static createStruct_(t) {
    return us.startStruct_(t), us.endStruct_(t);
  }
}
class bn {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsTime(t, n) {
    return (n || new bn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsTime(t, n) {
    return t.setPosition(t.position() + qt), (n || new bn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  unit() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt16(this.bb_pos + t) : ct.MILLISECOND;
  }
  bitWidth() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? this.bb.readInt32(this.bb_pos + t) : 32;
  }
  static startTime(t) {
    t.startObject(2);
  }
  static addUnit(t, n) {
    t.addFieldInt16(0, n, ct.MILLISECOND);
  }
  static addBitWidth(t, n) {
    t.addFieldInt32(1, n, 32);
  }
  static endTime(t) {
    return t.endObject();
  }
  static createTime(t, n, r) {
    return bn.startTime(t), bn.addUnit(t, n), bn.addBitWidth(t, r), bn.endTime(t);
  }
}
class wn {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsTimestamp(t, n) {
    return (n || new wn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsTimestamp(t, n) {
    return t.setPosition(t.position() + qt), (n || new wn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  unit() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt16(this.bb_pos + t) : ct.SECOND;
  }
  timezone(t) {
    const n = this.bb.__offset(this.bb_pos, 6);
    return n ? this.bb.__string(this.bb_pos + n, t) : null;
  }
  static startTimestamp(t) {
    t.startObject(2);
  }
  static addUnit(t, n) {
    t.addFieldInt16(0, n, ct.SECOND);
  }
  static addTimezone(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static endTimestamp(t) {
    return t.endObject();
  }
  static createTimestamp(t, n, r) {
    return wn.startTimestamp(t), wn.addUnit(t, n), wn.addTimezone(t, r), wn.endTimestamp(t);
  }
}
class Xe {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsUnion(t, n) {
    return (n || new Xe()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsUnion(t, n) {
    return t.setPosition(t.position() + qt), (n || new Xe()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  mode() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt16(this.bb_pos + t) : Je.Sparse;
  }
  typeIds(t) {
    const n = this.bb.__offset(this.bb_pos, 6);
    return n ? this.bb.readInt32(this.bb.__vector(this.bb_pos + n) + t * 4) : 0;
  }
  typeIdsLength() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  typeIdsArray() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? new Int32Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + t), this.bb.__vector_len(this.bb_pos + t)) : null;
  }
  static startUnion(t) {
    t.startObject(2);
  }
  static addMode(t, n) {
    t.addFieldInt16(0, n, Je.Sparse);
  }
  static addTypeIds(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static createTypeIdsVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let r = n.length - 1; r >= 0; r--)
      t.addInt32(n[r]);
    return t.endVector();
  }
  static startTypeIdsVector(t, n) {
    t.startVector(4, n, 4);
  }
  static endUnion(t) {
    return t.endObject();
  }
  static createUnion(t, n, r) {
    return Xe.startUnion(t), Xe.addMode(t, n), Xe.addTypeIds(t, r), Xe.endUnion(t);
  }
}
let db = class Za {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsUtf8(t, n) {
    return (n || new Za()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsUtf8(t, n) {
    return t.setPosition(t.position() + qt), (n || new Za()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startUtf8(t) {
    t.startObject(0);
  }
  static endUtf8(t) {
    return t.endObject();
  }
  static createUtf8(t) {
    return Za.startUtf8(t), Za.endUtf8(t);
  }
};
var Jt;
(function(e) {
  e[e.NONE = 0] = "NONE", e[e.Null = 1] = "Null", e[e.Int = 2] = "Int", e[e.FloatingPoint = 3] = "FloatingPoint", e[e.Binary = 4] = "Binary", e[e.Utf8 = 5] = "Utf8", e[e.Bool = 6] = "Bool", e[e.Decimal = 7] = "Decimal", e[e.Date = 8] = "Date", e[e.Time = 9] = "Time", e[e.Timestamp = 10] = "Timestamp", e[e.Interval = 11] = "Interval", e[e.List = 12] = "List", e[e.Struct_ = 13] = "Struct_", e[e.Union = 14] = "Union", e[e.FixedSizeBinary = 15] = "FixedSizeBinary", e[e.FixedSizeList = 16] = "FixedSizeList", e[e.Map = 17] = "Map", e[e.Duration = 18] = "Duration", e[e.LargeBinary = 19] = "LargeBinary", e[e.LargeUtf8 = 20] = "LargeUtf8", e[e.LargeList = 21] = "LargeList", e[e.RunEndEncoded = 22] = "RunEndEncoded";
})(Jt || (Jt = {}));
let yn = class Rl {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsField(t, n) {
    return (n || new Rl()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsField(t, n) {
    return t.setPosition(t.position() + qt), (n || new Rl()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  name(t) {
    const n = this.bb.__offset(this.bb_pos, 4);
    return n ? this.bb.__string(this.bb_pos + n, t) : null;
  }
  /**
   * Whether or not this field can contain nulls. Should be true in general.
   */
  nullable() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? !!this.bb.readInt8(this.bb_pos + t) : !1;
  }
  typeType() {
    const t = this.bb.__offset(this.bb_pos, 8);
    return t ? this.bb.readUint8(this.bb_pos + t) : Jt.NONE;
  }
  /**
   * This is the type of the decoded value if the field is dictionary encoded.
   */
  type(t) {
    const n = this.bb.__offset(this.bb_pos, 10);
    return n ? this.bb.__union(t, this.bb_pos + n) : null;
  }
  /**
   * Present only if the field is dictionary encoded.
   */
  dictionary(t) {
    const n = this.bb.__offset(this.bb_pos, 12);
    return n ? (t || new jr()).__init(this.bb.__indirect(this.bb_pos + n), this.bb) : null;
  }
  /**
   * children apply only to nested data types like Struct, List and Union. For
   * primitive types children will have length 0.
   */
  children(t, n) {
    const r = this.bb.__offset(this.bb_pos, 14);
    return r ? (n || new Rl()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + r) + t * 4), this.bb) : null;
  }
  childrenLength() {
    const t = this.bb.__offset(this.bb_pos, 14);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  /**
   * User-defined metadata
   */
  customMetadata(t, n) {
    const r = this.bb.__offset(this.bb_pos, 16);
    return r ? (n || new de()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + r) + t * 4), this.bb) : null;
  }
  customMetadataLength() {
    const t = this.bb.__offset(this.bb_pos, 16);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  static startField(t) {
    t.startObject(7);
  }
  static addName(t, n) {
    t.addFieldOffset(0, n, 0);
  }
  static addNullable(t, n) {
    t.addFieldInt8(1, +n, 0);
  }
  static addTypeType(t, n) {
    t.addFieldInt8(2, n, Jt.NONE);
  }
  static addType(t, n) {
    t.addFieldOffset(3, n, 0);
  }
  static addDictionary(t, n) {
    t.addFieldOffset(4, n, 0);
  }
  static addChildren(t, n) {
    t.addFieldOffset(5, n, 0);
  }
  static createChildrenVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let r = n.length - 1; r >= 0; r--)
      t.addOffset(n[r]);
    return t.endVector();
  }
  static startChildrenVector(t, n) {
    t.startVector(4, n, 4);
  }
  static addCustomMetadata(t, n) {
    t.addFieldOffset(6, n, 0);
  }
  static createCustomMetadataVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let r = n.length - 1; r >= 0; r--)
      t.addOffset(n[r]);
    return t.endVector();
  }
  static startCustomMetadataVector(t, n) {
    t.startVector(4, n, 4);
  }
  static endField(t) {
    return t.endObject();
  }
}, tr = class Fr {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsSchema(t, n) {
    return (n || new Fr()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsSchema(t, n) {
    return t.setPosition(t.position() + qt), (n || new Fr()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  /**
   * endianness of the buffer
   * it is Little Endian by default
   * if endianness doesn't match the underlying system then the vectors need to be converted
   */
  endianness() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt16(this.bb_pos + t) : Co.Little;
  }
  fields(t, n) {
    const r = this.bb.__offset(this.bb_pos, 6);
    return r ? (n || new yn()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + r) + t * 4), this.bb) : null;
  }
  fieldsLength() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  customMetadata(t, n) {
    const r = this.bb.__offset(this.bb_pos, 8);
    return r ? (n || new de()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + r) + t * 4), this.bb) : null;
  }
  customMetadataLength() {
    const t = this.bb.__offset(this.bb_pos, 8);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  /**
   * Features used in the stream/file.
   */
  features(t) {
    const n = this.bb.__offset(this.bb_pos, 10);
    return n ? this.bb.readInt64(this.bb.__vector(this.bb_pos + n) + t * 8) : BigInt(0);
  }
  featuresLength() {
    const t = this.bb.__offset(this.bb_pos, 10);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  static startSchema(t) {
    t.startObject(4);
  }
  static addEndianness(t, n) {
    t.addFieldInt16(0, n, Co.Little);
  }
  static addFields(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static createFieldsVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let r = n.length - 1; r >= 0; r--)
      t.addOffset(n[r]);
    return t.endVector();
  }
  static startFieldsVector(t, n) {
    t.startVector(4, n, 4);
  }
  static addCustomMetadata(t, n) {
    t.addFieldOffset(2, n, 0);
  }
  static createCustomMetadataVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let r = n.length - 1; r >= 0; r--)
      t.addOffset(n[r]);
    return t.endVector();
  }
  static startCustomMetadataVector(t, n) {
    t.startVector(4, n, 4);
  }
  static addFeatures(t, n) {
    t.addFieldOffset(3, n, 0);
  }
  static createFeaturesVector(t, n) {
    t.startVector(8, n.length, 8);
    for (let r = n.length - 1; r >= 0; r--)
      t.addInt64(n[r]);
    return t.endVector();
  }
  static startFeaturesVector(t, n) {
    t.startVector(8, n, 8);
  }
  static endSchema(t) {
    return t.endObject();
  }
  static finishSchemaBuffer(t, n) {
    t.finish(n);
  }
  static finishSizePrefixedSchemaBuffer(t, n) {
    t.finish(n, void 0, !0);
  }
  static createSchema(t, n, r, i, s) {
    return Fr.startSchema(t), Fr.addEndianness(t, n), Fr.addFields(t, r), Fr.addCustomMetadata(t, i), Fr.addFeatures(t, s), Fr.endSchema(t);
  }
};
var Pt;
(function(e) {
  e[e.NONE = 0] = "NONE", e[e.Schema = 1] = "Schema", e[e.DictionaryBatch = 2] = "DictionaryBatch", e[e.RecordBatch = 3] = "RecordBatch", e[e.Tensor = 4] = "Tensor", e[e.SparseTensor = 5] = "SparseTensor";
})(Pt || (Pt = {}));
var L;
(function(e) {
  e[e.NONE = 0] = "NONE", e[e.Null = 1] = "Null", e[e.Int = 2] = "Int", e[e.Float = 3] = "Float", e[e.Binary = 4] = "Binary", e[e.Utf8 = 5] = "Utf8", e[e.Bool = 6] = "Bool", e[e.Decimal = 7] = "Decimal", e[e.Date = 8] = "Date", e[e.Time = 9] = "Time", e[e.Timestamp = 10] = "Timestamp", e[e.Interval = 11] = "Interval", e[e.List = 12] = "List", e[e.Struct = 13] = "Struct", e[e.Union = 14] = "Union", e[e.FixedSizeBinary = 15] = "FixedSizeBinary", e[e.FixedSizeList = 16] = "FixedSizeList", e[e.Map = 17] = "Map", e[e.Duration = 18] = "Duration", e[e.LargeBinary = 19] = "LargeBinary", e[e.LargeUtf8 = 20] = "LargeUtf8", e[e.Dictionary = -1] = "Dictionary", e[e.Int8 = -2] = "Int8", e[e.Int16 = -3] = "Int16", e[e.Int32 = -4] = "Int32", e[e.Int64 = -5] = "Int64", e[e.Uint8 = -6] = "Uint8", e[e.Uint16 = -7] = "Uint16", e[e.Uint32 = -8] = "Uint32", e[e.Uint64 = -9] = "Uint64", e[e.Float16 = -10] = "Float16", e[e.Float32 = -11] = "Float32", e[e.Float64 = -12] = "Float64", e[e.DateDay = -13] = "DateDay", e[e.DateMillisecond = -14] = "DateMillisecond", e[e.TimestampSecond = -15] = "TimestampSecond", e[e.TimestampMillisecond = -16] = "TimestampMillisecond", e[e.TimestampMicrosecond = -17] = "TimestampMicrosecond", e[e.TimestampNanosecond = -18] = "TimestampNanosecond", e[e.TimeSecond = -19] = "TimeSecond", e[e.TimeMillisecond = -20] = "TimeMillisecond", e[e.TimeMicrosecond = -21] = "TimeMicrosecond", e[e.TimeNanosecond = -22] = "TimeNanosecond", e[e.DenseUnion = -23] = "DenseUnion", e[e.SparseUnion = -24] = "SparseUnion", e[e.IntervalDayTime = -25] = "IntervalDayTime", e[e.IntervalYearMonth = -26] = "IntervalYearMonth", e[e.DurationSecond = -27] = "DurationSecond", e[e.DurationMillisecond = -28] = "DurationMillisecond", e[e.DurationMicrosecond = -29] = "DurationMicrosecond", e[e.DurationNanosecond = -30] = "DurationNanosecond";
})(L || (L = {}));
var Pr;
(function(e) {
  e[e.OFFSET = 0] = "OFFSET", e[e.DATA = 1] = "DATA", e[e.VALIDITY = 2] = "VALIDITY", e[e.TYPE = 3] = "TYPE";
})(Pr || (Pr = {}));
const yD = void 0;
function vc(e) {
  if (e === null)
    return "null";
  if (e === yD)
    return "undefined";
  switch (typeof e) {
    case "number":
      return `${e}`;
    case "bigint":
      return `${e}`;
    case "string":
      return `"${e}"`;
  }
  return typeof e[Symbol.toPrimitive] == "function" ? e[Symbol.toPrimitive]("string") : ArrayBuffer.isView(e) ? e instanceof BigInt64Array || e instanceof BigUint64Array ? `[${[...e].map((t) => vc(t))}]` : `[${e}]` : ArrayBuffer.isView(e) ? `[${e}]` : JSON.stringify(e, (t, n) => typeof n == "bigint" ? `${n}` : n);
}
function Kt(e) {
  if (typeof e == "bigint" && (e < Number.MIN_SAFE_INTEGER || e > Number.MAX_SAFE_INTEGER))
    throw new TypeError(`${e} is not safe to convert to a number.`);
  return Number(e);
}
function J_(e, t) {
  return Kt(e / t) + Kt(e % t) / Kt(t);
}
const mD = Symbol.for("isArrowBigNum");
function Xn(e, ...t) {
  return t.length === 0 ? Object.setPrototypeOf(Yt(this.TypedArray, e), this.constructor.prototype) : Object.setPrototypeOf(new this.TypedArray(e, ...t), this.constructor.prototype);
}
Xn.prototype[mD] = !0;
Xn.prototype.toJSON = function() {
  return `"${Sc(this)}"`;
};
Xn.prototype.valueOf = function(e) {
  return Z_(this, e);
};
Xn.prototype.toString = function() {
  return Sc(this);
};
Xn.prototype[Symbol.toPrimitive] = function(e = "default") {
  switch (e) {
    case "number":
      return Z_(this);
    case "string":
      return Sc(this);
    case "default":
      return wD(this);
  }
  return Sc(this);
};
function Mo(...e) {
  return Xn.apply(this, e);
}
function Ao(...e) {
  return Xn.apply(this, e);
}
function xc(...e) {
  return Xn.apply(this, e);
}
Object.setPrototypeOf(Mo.prototype, Object.create(Int32Array.prototype));
Object.setPrototypeOf(Ao.prototype, Object.create(Uint32Array.prototype));
Object.setPrototypeOf(xc.prototype, Object.create(Uint32Array.prototype));
Object.assign(Mo.prototype, Xn.prototype, { constructor: Mo, signed: !0, TypedArray: Int32Array, BigIntArray: BigInt64Array });
Object.assign(Ao.prototype, Xn.prototype, { constructor: Ao, signed: !1, TypedArray: Uint32Array, BigIntArray: BigUint64Array });
Object.assign(xc.prototype, Xn.prototype, { constructor: xc, signed: !0, TypedArray: Uint32Array, BigIntArray: BigUint64Array });
const gD = BigInt(4294967296) * BigInt(4294967296), bD = gD - BigInt(1);
function Z_(e, t) {
  const { buffer: n, byteOffset: r, byteLength: i, signed: s } = e, o = new BigUint64Array(n, r, i / 8), a = s && o.at(-1) & BigInt(1) << BigInt(63);
  let c = BigInt(0), u = 0;
  if (a) {
    for (const l of o)
      c |= (l ^ bD) * (BigInt(1) << BigInt(64 * u++));
    c *= BigInt(-1), c -= BigInt(1);
  } else
    for (const l of o)
      c |= l * (BigInt(1) << BigInt(64 * u++));
  if (typeof t == "number") {
    const l = BigInt(Math.pow(10, t)), f = c / l, h = c % l;
    return Kt(f) + Kt(h) / Kt(l);
  }
  return Kt(c);
}
function Sc(e) {
  if (e.byteLength === 8)
    return `${new e.BigIntArray(e.buffer, e.byteOffset, 1)[0]}`;
  if (!e.signed)
    return cp(e);
  let t = new Uint16Array(e.buffer, e.byteOffset, e.byteLength / 2);
  if (new Int16Array([t.at(-1)])[0] >= 0)
    return cp(e);
  t = t.slice();
  let r = 1;
  for (let s = 0; s < t.length; s++) {
    const o = t[s], a = ~o + r;
    t[s] = a, r &= o === 0 ? 1 : 0;
  }
  return `-${cp(t)}`;
}
function wD(e) {
  return e.byteLength === 8 ? new e.BigIntArray(e.buffer, e.byteOffset, 1)[0] : Sc(e);
}
function cp(e) {
  let t = "";
  const n = new Uint32Array(2);
  let r = new Uint16Array(e.buffer, e.byteOffset, e.byteLength / 2);
  const i = new Uint32Array((r = new Uint16Array(r).reverse()).buffer);
  let s = -1;
  const o = r.length - 1;
  do {
    for (n[0] = r[s = 0]; s < o; )
      r[s++] = n[1] = n[0] / 10, n[0] = (n[0] - n[1] * 10 << 16) + r[s];
    r[s] = n[1] = n[0] / 10, n[0] = n[0] - n[1] * 10, t = `${n[0]}${t}`;
  } while (i[0] || i[1] || i[2] || i[3]);
  return t ?? "0";
}
class om {
  /** @nocollapse */
  static new(t, n) {
    switch (n) {
      case !0:
        return new Mo(t);
      case !1:
        return new Ao(t);
    }
    switch (t.constructor) {
      case Int8Array:
      case Int16Array:
      case Int32Array:
      case BigInt64Array:
        return new Mo(t);
    }
    return t.byteLength === 16 ? new xc(t) : new Ao(t);
  }
  /** @nocollapse */
  static signed(t) {
    return new Mo(t);
  }
  /** @nocollapse */
  static unsigned(t) {
    return new Ao(t);
  }
  /** @nocollapse */
  static decimal(t) {
    return new xc(t);
  }
  constructor(t, n) {
    return om.new(t, n);
  }
}
var K_, Q_, tv, ev, nv, rv, iv, sv, ov, av, cv, uv, lv, fv, hv, dv, pv, yv, mv, gv, bv, wv;
class Q {
  /** @nocollapse */
  static isNull(t) {
    return (t == null ? void 0 : t.typeId) === L.Null;
  }
  /** @nocollapse */
  static isInt(t) {
    return (t == null ? void 0 : t.typeId) === L.Int;
  }
  /** @nocollapse */
  static isFloat(t) {
    return (t == null ? void 0 : t.typeId) === L.Float;
  }
  /** @nocollapse */
  static isBinary(t) {
    return (t == null ? void 0 : t.typeId) === L.Binary;
  }
  /** @nocollapse */
  static isLargeBinary(t) {
    return (t == null ? void 0 : t.typeId) === L.LargeBinary;
  }
  /** @nocollapse */
  static isUtf8(t) {
    return (t == null ? void 0 : t.typeId) === L.Utf8;
  }
  /** @nocollapse */
  static isLargeUtf8(t) {
    return (t == null ? void 0 : t.typeId) === L.LargeUtf8;
  }
  /** @nocollapse */
  static isBool(t) {
    return (t == null ? void 0 : t.typeId) === L.Bool;
  }
  /** @nocollapse */
  static isDecimal(t) {
    return (t == null ? void 0 : t.typeId) === L.Decimal;
  }
  /** @nocollapse */
  static isDate(t) {
    return (t == null ? void 0 : t.typeId) === L.Date;
  }
  /** @nocollapse */
  static isTime(t) {
    return (t == null ? void 0 : t.typeId) === L.Time;
  }
  /** @nocollapse */
  static isTimestamp(t) {
    return (t == null ? void 0 : t.typeId) === L.Timestamp;
  }
  /** @nocollapse */
  static isInterval(t) {
    return (t == null ? void 0 : t.typeId) === L.Interval;
  }
  /** @nocollapse */
  static isDuration(t) {
    return (t == null ? void 0 : t.typeId) === L.Duration;
  }
  /** @nocollapse */
  static isList(t) {
    return (t == null ? void 0 : t.typeId) === L.List;
  }
  /** @nocollapse */
  static isStruct(t) {
    return (t == null ? void 0 : t.typeId) === L.Struct;
  }
  /** @nocollapse */
  static isUnion(t) {
    return (t == null ? void 0 : t.typeId) === L.Union;
  }
  /** @nocollapse */
  static isFixedSizeBinary(t) {
    return (t == null ? void 0 : t.typeId) === L.FixedSizeBinary;
  }
  /** @nocollapse */
  static isFixedSizeList(t) {
    return (t == null ? void 0 : t.typeId) === L.FixedSizeList;
  }
  /** @nocollapse */
  static isMap(t) {
    return (t == null ? void 0 : t.typeId) === L.Map;
  }
  /** @nocollapse */
  static isDictionary(t) {
    return (t == null ? void 0 : t.typeId) === L.Dictionary;
  }
  /** @nocollapse */
  static isDenseUnion(t) {
    return Q.isUnion(t) && t.mode === Je.Dense;
  }
  /** @nocollapse */
  static isSparseUnion(t) {
    return Q.isUnion(t) && t.mode === Je.Sparse;
  }
  constructor(t) {
    this.typeId = t;
  }
}
K_ = Symbol.toStringTag;
Q[K_] = ((e) => (e.children = null, e.ArrayType = Array, e.OffsetArrayType = Int32Array, e[Symbol.toStringTag] = "DataType"))(Q.prototype);
class Oi extends Q {
  constructor() {
    super(L.Null);
  }
  toString() {
    return "Null";
  }
}
Q_ = Symbol.toStringTag;
Oi[Q_] = ((e) => e[Symbol.toStringTag] = "Null")(Oi.prototype);
class As extends Q {
  constructor(t, n) {
    super(L.Int), this.isSigned = t, this.bitWidth = n;
  }
  get ArrayType() {
    switch (this.bitWidth) {
      case 8:
        return this.isSigned ? Int8Array : Uint8Array;
      case 16:
        return this.isSigned ? Int16Array : Uint16Array;
      case 32:
        return this.isSigned ? Int32Array : Uint32Array;
      case 64:
        return this.isSigned ? BigInt64Array : BigUint64Array;
    }
    throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);
  }
  toString() {
    return `${this.isSigned ? "I" : "Ui"}nt${this.bitWidth}`;
  }
}
tv = Symbol.toStringTag;
As[tv] = ((e) => (e.isSigned = null, e.bitWidth = null, e[Symbol.toStringTag] = "Int"))(As.prototype);
class Mc extends As {
  constructor() {
    super(!0, 32);
  }
  get ArrayType() {
    return Int32Array;
  }
}
Object.defineProperty(Mc.prototype, "ArrayType", { value: Int32Array });
class nf extends Q {
  constructor(t) {
    super(L.Float), this.precision = t;
  }
  get ArrayType() {
    switch (this.precision) {
      case Oe.HALF:
        return Uint16Array;
      case Oe.SINGLE:
        return Float32Array;
      case Oe.DOUBLE:
        return Float64Array;
    }
    throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);
  }
  toString() {
    return `Float${this.precision << 5 || 16}`;
  }
}
ev = Symbol.toStringTag;
nf[ev] = ((e) => (e.precision = null, e[Symbol.toStringTag] = "Float"))(nf.prototype);
class rf extends Q {
  constructor() {
    super(L.Binary);
  }
  toString() {
    return "Binary";
  }
}
nv = Symbol.toStringTag;
rf[nv] = ((e) => (e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "Binary"))(rf.prototype);
class sf extends Q {
  constructor() {
    super(L.LargeBinary);
  }
  toString() {
    return "LargeBinary";
  }
}
rv = Symbol.toStringTag;
sf[rv] = ((e) => (e.ArrayType = Uint8Array, e.OffsetArrayType = BigInt64Array, e[Symbol.toStringTag] = "LargeBinary"))(sf.prototype);
class of extends Q {
  constructor() {
    super(L.Utf8);
  }
  toString() {
    return "Utf8";
  }
}
iv = Symbol.toStringTag;
of[iv] = ((e) => (e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "Utf8"))(of.prototype);
class af extends Q {
  constructor() {
    super(L.LargeUtf8);
  }
  toString() {
    return "LargeUtf8";
  }
}
sv = Symbol.toStringTag;
af[sv] = ((e) => (e.ArrayType = Uint8Array, e.OffsetArrayType = BigInt64Array, e[Symbol.toStringTag] = "LargeUtf8"))(af.prototype);
class cf extends Q {
  constructor() {
    super(L.Bool);
  }
  toString() {
    return "Bool";
  }
}
ov = Symbol.toStringTag;
cf[ov] = ((e) => (e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "Bool"))(cf.prototype);
class uf extends Q {
  constructor(t, n, r = 128) {
    super(L.Decimal), this.scale = t, this.precision = n, this.bitWidth = r;
  }
  toString() {
    return `Decimal[${this.precision}e${this.scale > 0 ? "+" : ""}${this.scale}]`;
  }
}
av = Symbol.toStringTag;
uf[av] = ((e) => (e.scale = null, e.precision = null, e.ArrayType = Uint32Array, e[Symbol.toStringTag] = "Decimal"))(uf.prototype);
class lf extends Q {
  constructor(t) {
    super(L.Date), this.unit = t;
  }
  toString() {
    return `Date${(this.unit + 1) * 32}<${An[this.unit]}>`;
  }
  get ArrayType() {
    return this.unit === An.DAY ? Int32Array : BigInt64Array;
  }
}
cv = Symbol.toStringTag;
lf[cv] = ((e) => (e.unit = null, e[Symbol.toStringTag] = "Date"))(lf.prototype);
class ff extends Q {
  constructor(t, n) {
    super(L.Time), this.unit = t, this.bitWidth = n;
  }
  toString() {
    return `Time${this.bitWidth}<${ct[this.unit]}>`;
  }
  get ArrayType() {
    switch (this.bitWidth) {
      case 32:
        return Int32Array;
      case 64:
        return BigInt64Array;
    }
    throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);
  }
}
uv = Symbol.toStringTag;
ff[uv] = ((e) => (e.unit = null, e.bitWidth = null, e[Symbol.toStringTag] = "Time"))(ff.prototype);
class hf extends Q {
  constructor(t, n) {
    super(L.Timestamp), this.unit = t, this.timezone = n;
  }
  toString() {
    return `Timestamp<${ct[this.unit]}${this.timezone ? `, ${this.timezone}` : ""}>`;
  }
}
lv = Symbol.toStringTag;
hf[lv] = ((e) => (e.unit = null, e.timezone = null, e.ArrayType = BigInt64Array, e[Symbol.toStringTag] = "Timestamp"))(hf.prototype);
class df extends Q {
  constructor(t) {
    super(L.Interval), this.unit = t;
  }
  toString() {
    return `Interval<${gr[this.unit]}>`;
  }
}
fv = Symbol.toStringTag;
df[fv] = ((e) => (e.unit = null, e.ArrayType = Int32Array, e[Symbol.toStringTag] = "Interval"))(df.prototype);
class pf extends Q {
  constructor(t) {
    super(L.Duration), this.unit = t;
  }
  toString() {
    return `Duration<${ct[this.unit]}>`;
  }
}
hv = Symbol.toStringTag;
pf[hv] = ((e) => (e.unit = null, e.ArrayType = BigInt64Array, e[Symbol.toStringTag] = "Duration"))(pf.prototype);
class yf extends Q {
  constructor(t) {
    super(L.List), this.children = [t];
  }
  toString() {
    return `List<${this.valueType}>`;
  }
  get valueType() {
    return this.children[0].type;
  }
  get valueField() {
    return this.children[0];
  }
  get ArrayType() {
    return this.valueType.ArrayType;
  }
}
dv = Symbol.toStringTag;
yf[dv] = ((e) => (e.children = null, e[Symbol.toStringTag] = "List"))(yf.prototype);
class Ce extends Q {
  constructor(t) {
    super(L.Struct), this.children = t;
  }
  toString() {
    return `Struct<{${this.children.map((t) => `${t.name}:${t.type}`).join(", ")}}>`;
  }
}
pv = Symbol.toStringTag;
Ce[pv] = ((e) => (e.children = null, e[Symbol.toStringTag] = "Struct"))(Ce.prototype);
class mf extends Q {
  constructor(t, n, r) {
    super(L.Union), this.mode = t, this.children = r, this.typeIds = n = Int32Array.from(n), this.typeIdToChildIndex = n.reduce((i, s, o) => (i[s] = o) && i || i, /* @__PURE__ */ Object.create(null));
  }
  toString() {
    return `${this[Symbol.toStringTag]}<${this.children.map((t) => `${t.type}`).join(" | ")}>`;
  }
}
yv = Symbol.toStringTag;
mf[yv] = ((e) => (e.mode = null, e.typeIds = null, e.children = null, e.typeIdToChildIndex = null, e.ArrayType = Int8Array, e[Symbol.toStringTag] = "Union"))(mf.prototype);
class gf extends Q {
  constructor(t) {
    super(L.FixedSizeBinary), this.byteWidth = t;
  }
  toString() {
    return `FixedSizeBinary[${this.byteWidth}]`;
  }
}
mv = Symbol.toStringTag;
gf[mv] = ((e) => (e.byteWidth = null, e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "FixedSizeBinary"))(gf.prototype);
class bf extends Q {
  constructor(t, n) {
    super(L.FixedSizeList), this.listSize = t, this.children = [n];
  }
  get valueType() {
    return this.children[0].type;
  }
  get valueField() {
    return this.children[0];
  }
  get ArrayType() {
    return this.valueType.ArrayType;
  }
  toString() {
    return `FixedSizeList[${this.listSize}]<${this.valueType}>`;
  }
}
gv = Symbol.toStringTag;
bf[gv] = ((e) => (e.children = null, e.listSize = null, e[Symbol.toStringTag] = "FixedSizeList"))(bf.prototype);
class wf extends Q {
  constructor(t, n = !1) {
    var r, i, s;
    if (super(L.Map), this.children = [t], this.keysSorted = n, t && (t.name = "entries", !((r = t == null ? void 0 : t.type) === null || r === void 0) && r.children)) {
      const o = (i = t == null ? void 0 : t.type) === null || i === void 0 ? void 0 : i.children[0];
      o && (o.name = "key");
      const a = (s = t == null ? void 0 : t.type) === null || s === void 0 ? void 0 : s.children[1];
      a && (a.name = "value");
    }
  }
  get keyType() {
    return this.children[0].type.children[0].type;
  }
  get valueType() {
    return this.children[0].type.children[1].type;
  }
  get childType() {
    return this.children[0].type;
  }
  toString() {
    return `Map<{${this.children[0].type.children.map((t) => `${t.name}:${t.type}`).join(", ")}}>`;
  }
}
bv = Symbol.toStringTag;
wf[bv] = ((e) => (e.children = null, e.keysSorted = null, e[Symbol.toStringTag] = "Map_"))(wf.prototype);
const _D = /* @__PURE__ */ ((e) => () => ++e)(-1);
class Po extends Q {
  constructor(t, n, r, i) {
    super(L.Dictionary), this.indices = n, this.dictionary = t, this.isOrdered = i || !1, this.id = r == null ? _D() : Kt(r);
  }
  get children() {
    return this.dictionary.children;
  }
  get valueType() {
    return this.dictionary;
  }
  get ArrayType() {
    return this.dictionary.ArrayType;
  }
  toString() {
    return `Dictionary<${this.indices}, ${this.dictionary}>`;
  }
}
wv = Symbol.toStringTag;
Po[wv] = ((e) => (e.id = null, e.indices = null, e.isOrdered = null, e.dictionary = null, e[Symbol.toStringTag] = "Dictionary"))(Po.prototype);
function Ur(e) {
  const t = e;
  switch (e.typeId) {
    case L.Decimal:
      return e.bitWidth / 32;
    case L.Interval:
      return 1 + t.unit;
    case L.FixedSizeList:
      return t.listSize;
    case L.FixedSizeBinary:
      return t.byteWidth;
    default:
      return 1;
  }
}
class At {
  visitMany(t, ...n) {
    return t.map((r, i) => this.visit(r, ...n.map((s) => s[i])));
  }
  visit(...t) {
    return this.getVisitFn(t[0], !1).apply(this, t);
  }
  getVisitFn(t, n = !0) {
    return vD(this, t, n);
  }
  getVisitFnByTypeId(t, n = !0) {
    return lo(this, t, n);
  }
  visitNull(t, ...n) {
    return null;
  }
  visitBool(t, ...n) {
    return null;
  }
  visitInt(t, ...n) {
    return null;
  }
  visitFloat(t, ...n) {
    return null;
  }
  visitUtf8(t, ...n) {
    return null;
  }
  visitLargeUtf8(t, ...n) {
    return null;
  }
  visitBinary(t, ...n) {
    return null;
  }
  visitLargeBinary(t, ...n) {
    return null;
  }
  visitFixedSizeBinary(t, ...n) {
    return null;
  }
  visitDate(t, ...n) {
    return null;
  }
  visitTimestamp(t, ...n) {
    return null;
  }
  visitTime(t, ...n) {
    return null;
  }
  visitDecimal(t, ...n) {
    return null;
  }
  visitList(t, ...n) {
    return null;
  }
  visitStruct(t, ...n) {
    return null;
  }
  visitUnion(t, ...n) {
    return null;
  }
  visitDictionary(t, ...n) {
    return null;
  }
  visitInterval(t, ...n) {
    return null;
  }
  visitDuration(t, ...n) {
    return null;
  }
  visitFixedSizeList(t, ...n) {
    return null;
  }
  visitMap(t, ...n) {
    return null;
  }
}
function vD(e, t, n = !0) {
  return typeof t == "number" ? lo(e, t, n) : typeof t == "string" && t in L ? lo(e, L[t], n) : t && t instanceof Q ? lo(e, pb(t), n) : t != null && t.type && t.type instanceof Q ? lo(e, pb(t.type), n) : lo(e, L.NONE, n);
}
function lo(e, t, n = !0) {
  let r = null;
  switch (t) {
    case L.Null:
      r = e.visitNull;
      break;
    case L.Bool:
      r = e.visitBool;
      break;
    case L.Int:
      r = e.visitInt;
      break;
    case L.Int8:
      r = e.visitInt8 || e.visitInt;
      break;
    case L.Int16:
      r = e.visitInt16 || e.visitInt;
      break;
    case L.Int32:
      r = e.visitInt32 || e.visitInt;
      break;
    case L.Int64:
      r = e.visitInt64 || e.visitInt;
      break;
    case L.Uint8:
      r = e.visitUint8 || e.visitInt;
      break;
    case L.Uint16:
      r = e.visitUint16 || e.visitInt;
      break;
    case L.Uint32:
      r = e.visitUint32 || e.visitInt;
      break;
    case L.Uint64:
      r = e.visitUint64 || e.visitInt;
      break;
    case L.Float:
      r = e.visitFloat;
      break;
    case L.Float16:
      r = e.visitFloat16 || e.visitFloat;
      break;
    case L.Float32:
      r = e.visitFloat32 || e.visitFloat;
      break;
    case L.Float64:
      r = e.visitFloat64 || e.visitFloat;
      break;
    case L.Utf8:
      r = e.visitUtf8;
      break;
    case L.LargeUtf8:
      r = e.visitLargeUtf8;
      break;
    case L.Binary:
      r = e.visitBinary;
      break;
    case L.LargeBinary:
      r = e.visitLargeBinary;
      break;
    case L.FixedSizeBinary:
      r = e.visitFixedSizeBinary;
      break;
    case L.Date:
      r = e.visitDate;
      break;
    case L.DateDay:
      r = e.visitDateDay || e.visitDate;
      break;
    case L.DateMillisecond:
      r = e.visitDateMillisecond || e.visitDate;
      break;
    case L.Timestamp:
      r = e.visitTimestamp;
      break;
    case L.TimestampSecond:
      r = e.visitTimestampSecond || e.visitTimestamp;
      break;
    case L.TimestampMillisecond:
      r = e.visitTimestampMillisecond || e.visitTimestamp;
      break;
    case L.TimestampMicrosecond:
      r = e.visitTimestampMicrosecond || e.visitTimestamp;
      break;
    case L.TimestampNanosecond:
      r = e.visitTimestampNanosecond || e.visitTimestamp;
      break;
    case L.Time:
      r = e.visitTime;
      break;
    case L.TimeSecond:
      r = e.visitTimeSecond || e.visitTime;
      break;
    case L.TimeMillisecond:
      r = e.visitTimeMillisecond || e.visitTime;
      break;
    case L.TimeMicrosecond:
      r = e.visitTimeMicrosecond || e.visitTime;
      break;
    case L.TimeNanosecond:
      r = e.visitTimeNanosecond || e.visitTime;
      break;
    case L.Decimal:
      r = e.visitDecimal;
      break;
    case L.List:
      r = e.visitList;
      break;
    case L.Struct:
      r = e.visitStruct;
      break;
    case L.Union:
      r = e.visitUnion;
      break;
    case L.DenseUnion:
      r = e.visitDenseUnion || e.visitUnion;
      break;
    case L.SparseUnion:
      r = e.visitSparseUnion || e.visitUnion;
      break;
    case L.Dictionary:
      r = e.visitDictionary;
      break;
    case L.Interval:
      r = e.visitInterval;
      break;
    case L.IntervalDayTime:
      r = e.visitIntervalDayTime || e.visitInterval;
      break;
    case L.IntervalYearMonth:
      r = e.visitIntervalYearMonth || e.visitInterval;
      break;
    case L.Duration:
      r = e.visitDuration;
      break;
    case L.DurationSecond:
      r = e.visitDurationSecond || e.visitDuration;
      break;
    case L.DurationMillisecond:
      r = e.visitDurationMillisecond || e.visitDuration;
      break;
    case L.DurationMicrosecond:
      r = e.visitDurationMicrosecond || e.visitDuration;
      break;
    case L.DurationNanosecond:
      r = e.visitDurationNanosecond || e.visitDuration;
      break;
    case L.FixedSizeList:
      r = e.visitFixedSizeList;
      break;
    case L.Map:
      r = e.visitMap;
      break;
  }
  if (typeof r == "function")
    return r;
  if (!n)
    return () => null;
  throw new Error(`Unrecognized type '${L[t]}'`);
}
function pb(e) {
  switch (e.typeId) {
    case L.Null:
      return L.Null;
    case L.Int: {
      const { bitWidth: t, isSigned: n } = e;
      switch (t) {
        case 8:
          return n ? L.Int8 : L.Uint8;
        case 16:
          return n ? L.Int16 : L.Uint16;
        case 32:
          return n ? L.Int32 : L.Uint32;
        case 64:
          return n ? L.Int64 : L.Uint64;
      }
      return L.Int;
    }
    case L.Float:
      switch (e.precision) {
        case Oe.HALF:
          return L.Float16;
        case Oe.SINGLE:
          return L.Float32;
        case Oe.DOUBLE:
          return L.Float64;
      }
      return L.Float;
    case L.Binary:
      return L.Binary;
    case L.LargeBinary:
      return L.LargeBinary;
    case L.Utf8:
      return L.Utf8;
    case L.LargeUtf8:
      return L.LargeUtf8;
    case L.Bool:
      return L.Bool;
    case L.Decimal:
      return L.Decimal;
    case L.Time:
      switch (e.unit) {
        case ct.SECOND:
          return L.TimeSecond;
        case ct.MILLISECOND:
          return L.TimeMillisecond;
        case ct.MICROSECOND:
          return L.TimeMicrosecond;
        case ct.NANOSECOND:
          return L.TimeNanosecond;
      }
      return L.Time;
    case L.Timestamp:
      switch (e.unit) {
        case ct.SECOND:
          return L.TimestampSecond;
        case ct.MILLISECOND:
          return L.TimestampMillisecond;
        case ct.MICROSECOND:
          return L.TimestampMicrosecond;
        case ct.NANOSECOND:
          return L.TimestampNanosecond;
      }
      return L.Timestamp;
    case L.Date:
      switch (e.unit) {
        case An.DAY:
          return L.DateDay;
        case An.MILLISECOND:
          return L.DateMillisecond;
      }
      return L.Date;
    case L.Interval:
      switch (e.unit) {
        case gr.DAY_TIME:
          return L.IntervalDayTime;
        case gr.YEAR_MONTH:
          return L.IntervalYearMonth;
      }
      return L.Interval;
    case L.Duration:
      switch (e.unit) {
        case ct.SECOND:
          return L.DurationSecond;
        case ct.MILLISECOND:
          return L.DurationMillisecond;
        case ct.MICROSECOND:
          return L.DurationMicrosecond;
        case ct.NANOSECOND:
          return L.DurationNanosecond;
      }
      return L.Duration;
    case L.Map:
      return L.Map;
    case L.List:
      return L.List;
    case L.Struct:
      return L.Struct;
    case L.Union:
      switch (e.mode) {
        case Je.Dense:
          return L.DenseUnion;
        case Je.Sparse:
          return L.SparseUnion;
      }
      return L.Union;
    case L.FixedSizeBinary:
      return L.FixedSizeBinary;
    case L.FixedSizeList:
      return L.FixedSizeList;
    case L.Dictionary:
      return L.Dictionary;
  }
  throw new Error(`Unrecognized type '${L[e.typeId]}'`);
}
At.prototype.visitInt8 = null;
At.prototype.visitInt16 = null;
At.prototype.visitInt32 = null;
At.prototype.visitInt64 = null;
At.prototype.visitUint8 = null;
At.prototype.visitUint16 = null;
At.prototype.visitUint32 = null;
At.prototype.visitUint64 = null;
At.prototype.visitFloat16 = null;
At.prototype.visitFloat32 = null;
At.prototype.visitFloat64 = null;
At.prototype.visitDateDay = null;
At.prototype.visitDateMillisecond = null;
At.prototype.visitTimestampSecond = null;
At.prototype.visitTimestampMillisecond = null;
At.prototype.visitTimestampMicrosecond = null;
At.prototype.visitTimestampNanosecond = null;
At.prototype.visitTimeSecond = null;
At.prototype.visitTimeMillisecond = null;
At.prototype.visitTimeMicrosecond = null;
At.prototype.visitTimeNanosecond = null;
At.prototype.visitDenseUnion = null;
At.prototype.visitSparseUnion = null;
At.prototype.visitIntervalDayTime = null;
At.prototype.visitIntervalYearMonth = null;
At.prototype.visitDuration = null;
At.prototype.visitDurationSecond = null;
At.prototype.visitDurationMillisecond = null;
At.prototype.visitDurationMicrosecond = null;
At.prototype.visitDurationNanosecond = null;
const _v = new Float64Array(1), Ys = new Uint32Array(_v.buffer);
function vv(e) {
  const t = (e & 31744) >> 10, n = (e & 1023) / 1024, r = Math.pow(-1, (e & 32768) >> 15);
  switch (t) {
    case 31:
      return r * (n ? Number.NaN : 1 / 0);
    case 0:
      return r * (n ? 6103515625e-14 * n : 0);
  }
  return r * Math.pow(2, t - 15) * (1 + n);
}
function xD(e) {
  if (e !== e)
    return 32256;
  _v[0] = e;
  const t = (Ys[1] & 2147483648) >> 16 & 65535;
  let n = Ys[1] & 2146435072, r = 0;
  return n >= 1089470464 ? Ys[0] > 0 ? n = 31744 : (n = (n & 2080374784) >> 16, r = (Ys[1] & 1048575) >> 10) : n <= 1056964608 ? (r = 1048576 + (Ys[1] & 1048575), r = 1048576 + (r << (n >> 20) - 998) >> 21, n = 0) : (n = n - 1056964608 >> 10, r = (Ys[1] & 1048575) + 512 >> 10), t | n | r & 65535;
}
class lt extends At {
}
function mt(e) {
  return (t, n, r) => {
    if (t.setValid(n, r != null))
      return e(t, n, r);
  };
}
const SD = (e, t, n) => {
  e[t] = Math.floor(n / 864e5);
}, xv = (e, t, n, r) => {
  if (n + 1 < t.length) {
    const i = Kt(t[n]), s = Kt(t[n + 1]);
    e.set(r.subarray(0, s - i), i);
  }
}, MD = ({ offset: e, values: t }, n, r) => {
  const i = e + n;
  r ? t[i >> 3] |= 1 << i % 8 : t[i >> 3] &= ~(1 << i % 8);
}, si = ({ values: e }, t, n) => {
  e[t] = n;
}, am = ({ values: e }, t, n) => {
  e[t] = n;
}, Sv = ({ values: e }, t, n) => {
  e[t] = xD(n);
}, AD = (e, t, n) => {
  switch (e.type.precision) {
    case Oe.HALF:
      return Sv(e, t, n);
    case Oe.SINGLE:
    case Oe.DOUBLE:
      return am(e, t, n);
  }
}, Mv = ({ values: e }, t, n) => {
  SD(e, t, n.valueOf());
}, Av = ({ values: e }, t, n) => {
  e[t] = BigInt(n);
}, $D = ({ stride: e, values: t }, n, r) => {
  t.set(r.subarray(0, e), e * n);
}, $v = ({ values: e, valueOffsets: t }, n, r) => xv(e, t, n, r), Iv = ({ values: e, valueOffsets: t }, n, r) => xv(e, t, n, nm(r)), ID = (e, t, n) => {
  e.type.unit === An.DAY ? Mv(e, t, n) : Av(e, t, n);
}, Tv = ({ values: e }, t, n) => {
  e[t] = BigInt(n / 1e3);
}, Ev = ({ values: e }, t, n) => {
  e[t] = BigInt(n);
}, Nv = ({ values: e }, t, n) => {
  e[t] = BigInt(n * 1e3);
}, Dv = ({ values: e }, t, n) => {
  e[t] = BigInt(n * 1e6);
}, TD = (e, t, n) => {
  switch (e.type.unit) {
    case ct.SECOND:
      return Tv(e, t, n);
    case ct.MILLISECOND:
      return Ev(e, t, n);
    case ct.MICROSECOND:
      return Nv(e, t, n);
    case ct.NANOSECOND:
      return Dv(e, t, n);
  }
}, Ov = ({ values: e }, t, n) => {
  e[t] = n;
}, Lv = ({ values: e }, t, n) => {
  e[t] = n;
}, Rv = ({ values: e }, t, n) => {
  e[t] = n;
}, kv = ({ values: e }, t, n) => {
  e[t] = n;
}, ED = (e, t, n) => {
  switch (e.type.unit) {
    case ct.SECOND:
      return Ov(e, t, n);
    case ct.MILLISECOND:
      return Lv(e, t, n);
    case ct.MICROSECOND:
      return Rv(e, t, n);
    case ct.NANOSECOND:
      return kv(e, t, n);
  }
}, ND = ({ values: e, stride: t }, n, r) => {
  e.set(r.subarray(0, t), t * n);
}, DD = (e, t, n) => {
  const r = e.children[0], i = e.valueOffsets, s = $n.getVisitFn(r);
  if (Array.isArray(n))
    for (let o = -1, a = i[t], c = i[t + 1]; a < c; )
      s(r, a++, n[++o]);
  else
    for (let o = -1, a = i[t], c = i[t + 1]; a < c; )
      s(r, a++, n.get(++o));
}, OD = (e, t, n) => {
  const r = e.children[0], { valueOffsets: i } = e, s = $n.getVisitFn(r);
  let { [t]: o, [t + 1]: a } = i;
  const c = n instanceof Map ? n.entries() : Object.entries(n);
  for (const u of c)
    if (s(r, o, u), ++o >= a)
      break;
}, LD = (e, t) => (n, r, i, s) => r && n(r, e, t[s]), RD = (e, t) => (n, r, i, s) => r && n(r, e, t.get(s)), kD = (e, t) => (n, r, i, s) => r && n(r, e, t.get(i.name)), FD = (e, t) => (n, r, i, s) => r && n(r, e, t[i.name]), BD = (e, t, n) => {
  const r = e.type.children.map((s) => $n.getVisitFn(s.type)), i = n instanceof Map ? kD(t, n) : n instanceof le ? RD(t, n) : Array.isArray(n) ? LD(t, n) : FD(t, n);
  e.type.children.forEach((s, o) => i(r[o], e.children[o], s, o));
}, CD = (e, t, n) => {
  e.type.mode === Je.Dense ? Fv(e, t, n) : Bv(e, t, n);
}, Fv = (e, t, n) => {
  const r = e.type.typeIdToChildIndex[e.typeIds[t]], i = e.children[r];
  $n.visit(i, e.valueOffsets[t], n);
}, Bv = (e, t, n) => {
  const r = e.type.typeIdToChildIndex[e.typeIds[t]], i = e.children[r];
  $n.visit(i, t, n);
}, PD = (e, t, n) => {
  var r;
  (r = e.dictionary) === null || r === void 0 || r.set(e.values[t], n);
}, UD = (e, t, n) => {
  e.type.unit === gr.DAY_TIME ? Cv(e, t, n) : Pv(e, t, n);
}, Cv = ({ values: e }, t, n) => {
  e.set(n.subarray(0, 2), 2 * t);
}, Pv = ({ values: e }, t, n) => {
  e[t] = n[0] * 12 + n[1] % 12;
}, Uv = ({ values: e }, t, n) => {
  e[t] = n;
}, zv = ({ values: e }, t, n) => {
  e[t] = n;
}, qv = ({ values: e }, t, n) => {
  e[t] = n;
}, jv = ({ values: e }, t, n) => {
  e[t] = n;
}, zD = (e, t, n) => {
  switch (e.type.unit) {
    case ct.SECOND:
      return Uv(e, t, n);
    case ct.MILLISECOND:
      return zv(e, t, n);
    case ct.MICROSECOND:
      return qv(e, t, n);
    case ct.NANOSECOND:
      return jv(e, t, n);
  }
}, qD = (e, t, n) => {
  const { stride: r } = e, i = e.children[0], s = $n.getVisitFn(i);
  if (Array.isArray(n))
    for (let o = -1, a = t * r; ++o < r; )
      s(i, a + o, n[o]);
  else
    for (let o = -1, a = t * r; ++o < r; )
      s(i, a + o, n.get(o));
};
lt.prototype.visitBool = mt(MD);
lt.prototype.visitInt = mt(si);
lt.prototype.visitInt8 = mt(si);
lt.prototype.visitInt16 = mt(si);
lt.prototype.visitInt32 = mt(si);
lt.prototype.visitInt64 = mt(si);
lt.prototype.visitUint8 = mt(si);
lt.prototype.visitUint16 = mt(si);
lt.prototype.visitUint32 = mt(si);
lt.prototype.visitUint64 = mt(si);
lt.prototype.visitFloat = mt(AD);
lt.prototype.visitFloat16 = mt(Sv);
lt.prototype.visitFloat32 = mt(am);
lt.prototype.visitFloat64 = mt(am);
lt.prototype.visitUtf8 = mt(Iv);
lt.prototype.visitLargeUtf8 = mt(Iv);
lt.prototype.visitBinary = mt($v);
lt.prototype.visitLargeBinary = mt($v);
lt.prototype.visitFixedSizeBinary = mt($D);
lt.prototype.visitDate = mt(ID);
lt.prototype.visitDateDay = mt(Mv);
lt.prototype.visitDateMillisecond = mt(Av);
lt.prototype.visitTimestamp = mt(TD);
lt.prototype.visitTimestampSecond = mt(Tv);
lt.prototype.visitTimestampMillisecond = mt(Ev);
lt.prototype.visitTimestampMicrosecond = mt(Nv);
lt.prototype.visitTimestampNanosecond = mt(Dv);
lt.prototype.visitTime = mt(ED);
lt.prototype.visitTimeSecond = mt(Ov);
lt.prototype.visitTimeMillisecond = mt(Lv);
lt.prototype.visitTimeMicrosecond = mt(Rv);
lt.prototype.visitTimeNanosecond = mt(kv);
lt.prototype.visitDecimal = mt(ND);
lt.prototype.visitList = mt(DD);
lt.prototype.visitStruct = mt(BD);
lt.prototype.visitUnion = mt(CD);
lt.prototype.visitDenseUnion = mt(Fv);
lt.prototype.visitSparseUnion = mt(Bv);
lt.prototype.visitDictionary = mt(PD);
lt.prototype.visitInterval = mt(UD);
lt.prototype.visitIntervalDayTime = mt(Cv);
lt.prototype.visitIntervalYearMonth = mt(Pv);
lt.prototype.visitDuration = mt(zD);
lt.prototype.visitDurationSecond = mt(Uv);
lt.prototype.visitDurationMillisecond = mt(zv);
lt.prototype.visitDurationMicrosecond = mt(qv);
lt.prototype.visitDurationNanosecond = mt(jv);
lt.prototype.visitFixedSizeList = mt(qD);
lt.prototype.visitMap = mt(OD);
const $n = new lt(), On = Symbol.for("parent"), $o = Symbol.for("rowIndex");
class cm {
  constructor(t, n) {
    return this[On] = t, this[$o] = n, new Proxy(this, new VD());
  }
  toArray() {
    return Object.values(this.toJSON());
  }
  toJSON() {
    const t = this[$o], n = this[On], r = n.type.children, i = {};
    for (let s = -1, o = r.length; ++s < o; )
      i[r[s].name] = Ze.visit(n.children[s], t);
    return i;
  }
  toString() {
    return `{${[...this].map(([t, n]) => `${vc(t)}: ${vc(n)}`).join(", ")}}`;
  }
  [Symbol.for("nodejs.util.inspect.custom")]() {
    return this.toString();
  }
  [Symbol.iterator]() {
    return new jD(this[On], this[$o]);
  }
}
class jD {
  constructor(t, n) {
    this.childIndex = 0, this.children = t.children, this.rowIndex = n, this.childFields = t.type.children, this.numChildren = this.childFields.length;
  }
  [Symbol.iterator]() {
    return this;
  }
  next() {
    const t = this.childIndex;
    return t < this.numChildren ? (this.childIndex = t + 1, {
      done: !1,
      value: [
        this.childFields[t].name,
        Ze.visit(this.children[t], this.rowIndex)
      ]
    }) : { done: !0, value: null };
  }
}
Object.defineProperties(cm.prototype, {
  [Symbol.toStringTag]: { enumerable: !1, configurable: !1, value: "Row" },
  [On]: { writable: !0, enumerable: !1, configurable: !1, value: null },
  [$o]: { writable: !0, enumerable: !1, configurable: !1, value: -1 }
});
class VD {
  isExtensible() {
    return !1;
  }
  deleteProperty() {
    return !1;
  }
  preventExtensions() {
    return !0;
  }
  ownKeys(t) {
    return t[On].type.children.map((n) => n.name);
  }
  has(t, n) {
    return t[On].type.children.findIndex((r) => r.name === n) !== -1;
  }
  getOwnPropertyDescriptor(t, n) {
    if (t[On].type.children.findIndex((r) => r.name === n) !== -1)
      return { writable: !0, enumerable: !0, configurable: !0 };
  }
  get(t, n) {
    if (Reflect.has(t, n))
      return t[n];
    const r = t[On].type.children.findIndex((i) => i.name === n);
    if (r !== -1) {
      const i = Ze.visit(t[On].children[r], t[$o]);
      return Reflect.set(t, n, i), i;
    }
  }
  set(t, n, r) {
    const i = t[On].type.children.findIndex((s) => s.name === n);
    return i !== -1 ? ($n.visit(t[On].children[i], t[$o], r), Reflect.set(t, n, r)) : Reflect.has(t, n) || typeof n == "symbol" ? Reflect.set(t, n, r) : !1;
  }
}
class nt extends At {
}
function ft(e) {
  return (t, n) => t.getValid(n) ? e(t, n) : null;
}
const YD = (e, t) => 864e5 * e[t], WD = (e, t) => null, Vv = (e, t, n) => {
  if (n + 1 >= t.length)
    return null;
  const r = Kt(t[n]), i = Kt(t[n + 1]);
  return e.subarray(r, i);
}, XD = ({ offset: e, values: t }, n) => {
  const r = e + n;
  return (t[r >> 3] & 1 << r % 8) !== 0;
}, Yv = ({ values: e }, t) => YD(e, t), Wv = ({ values: e }, t) => Kt(e[t]), Yi = ({ stride: e, values: t }, n) => t[e * n], GD = ({ stride: e, values: t }, n) => vv(t[e * n]), Xv = ({ values: e }, t) => e[t], HD = ({ stride: e, values: t }, n) => t.subarray(e * n, e * (n + 1)), Gv = ({ values: e, valueOffsets: t }, n) => Vv(e, t, n), Hv = ({ values: e, valueOffsets: t }, n) => {
  const r = Vv(e, t, n);
  return r !== null ? y0(r) : null;
}, JD = ({ values: e }, t) => e[t], ZD = ({ type: e, values: t }, n) => e.precision !== Oe.HALF ? t[n] : vv(t[n]), KD = (e, t) => e.type.unit === An.DAY ? Yv(e, t) : Wv(e, t), Jv = ({ values: e }, t) => 1e3 * Kt(e[t]), Zv = ({ values: e }, t) => Kt(e[t]), Kv = ({ values: e }, t) => J_(e[t], BigInt(1e3)), Qv = ({ values: e }, t) => J_(e[t], BigInt(1e6)), QD = (e, t) => {
  switch (e.type.unit) {
    case ct.SECOND:
      return Jv(e, t);
    case ct.MILLISECOND:
      return Zv(e, t);
    case ct.MICROSECOND:
      return Kv(e, t);
    case ct.NANOSECOND:
      return Qv(e, t);
  }
}, tx = ({ values: e }, t) => e[t], ex = ({ values: e }, t) => e[t], nx = ({ values: e }, t) => e[t], rx = ({ values: e }, t) => e[t], tO = (e, t) => {
  switch (e.type.unit) {
    case ct.SECOND:
      return tx(e, t);
    case ct.MILLISECOND:
      return ex(e, t);
    case ct.MICROSECOND:
      return nx(e, t);
    case ct.NANOSECOND:
      return rx(e, t);
  }
}, eO = ({ values: e, stride: t }, n) => om.decimal(e.subarray(t * n, t * (n + 1))), nO = (e, t) => {
  const { valueOffsets: n, stride: r, children: i } = e, { [t * r]: s, [t * r + 1]: o } = n, c = i[0].slice(s, o - s);
  return new le([c]);
}, rO = (e, t) => {
  const { valueOffsets: n, children: r } = e, { [t]: i, [t + 1]: s } = n, o = r[0];
  return new um(o.slice(i, s - i));
}, iO = (e, t) => new cm(e, t), sO = (e, t) => e.type.mode === Je.Dense ? ix(e, t) : sx(e, t), ix = (e, t) => {
  const n = e.type.typeIdToChildIndex[e.typeIds[t]], r = e.children[n];
  return Ze.visit(r, e.valueOffsets[t]);
}, sx = (e, t) => {
  const n = e.type.typeIdToChildIndex[e.typeIds[t]], r = e.children[n];
  return Ze.visit(r, t);
}, oO = (e, t) => {
  var n;
  return (n = e.dictionary) === null || n === void 0 ? void 0 : n.get(e.values[t]);
}, aO = (e, t) => e.type.unit === gr.DAY_TIME ? ox(e, t) : ax(e, t), ox = ({ values: e }, t) => e.subarray(2 * t, 2 * (t + 1)), ax = ({ values: e }, t) => {
  const n = e[t], r = new Int32Array(2);
  return r[0] = Math.trunc(n / 12), r[1] = Math.trunc(n % 12), r;
}, cx = ({ values: e }, t) => e[t], ux = ({ values: e }, t) => e[t], lx = ({ values: e }, t) => e[t], fx = ({ values: e }, t) => e[t], cO = (e, t) => {
  switch (e.type.unit) {
    case ct.SECOND:
      return cx(e, t);
    case ct.MILLISECOND:
      return ux(e, t);
    case ct.MICROSECOND:
      return lx(e, t);
    case ct.NANOSECOND:
      return fx(e, t);
  }
}, uO = (e, t) => {
  const { stride: n, children: r } = e, s = r[0].slice(t * n, n);
  return new le([s]);
};
nt.prototype.visitNull = ft(WD);
nt.prototype.visitBool = ft(XD);
nt.prototype.visitInt = ft(JD);
nt.prototype.visitInt8 = ft(Yi);
nt.prototype.visitInt16 = ft(Yi);
nt.prototype.visitInt32 = ft(Yi);
nt.prototype.visitInt64 = ft(Xv);
nt.prototype.visitUint8 = ft(Yi);
nt.prototype.visitUint16 = ft(Yi);
nt.prototype.visitUint32 = ft(Yi);
nt.prototype.visitUint64 = ft(Xv);
nt.prototype.visitFloat = ft(ZD);
nt.prototype.visitFloat16 = ft(GD);
nt.prototype.visitFloat32 = ft(Yi);
nt.prototype.visitFloat64 = ft(Yi);
nt.prototype.visitUtf8 = ft(Hv);
nt.prototype.visitLargeUtf8 = ft(Hv);
nt.prototype.visitBinary = ft(Gv);
nt.prototype.visitLargeBinary = ft(Gv);
nt.prototype.visitFixedSizeBinary = ft(HD);
nt.prototype.visitDate = ft(KD);
nt.prototype.visitDateDay = ft(Yv);
nt.prototype.visitDateMillisecond = ft(Wv);
nt.prototype.visitTimestamp = ft(QD);
nt.prototype.visitTimestampSecond = ft(Jv);
nt.prototype.visitTimestampMillisecond = ft(Zv);
nt.prototype.visitTimestampMicrosecond = ft(Kv);
nt.prototype.visitTimestampNanosecond = ft(Qv);
nt.prototype.visitTime = ft(tO);
nt.prototype.visitTimeSecond = ft(tx);
nt.prototype.visitTimeMillisecond = ft(ex);
nt.prototype.visitTimeMicrosecond = ft(nx);
nt.prototype.visitTimeNanosecond = ft(rx);
nt.prototype.visitDecimal = ft(eO);
nt.prototype.visitList = ft(nO);
nt.prototype.visitStruct = ft(iO);
nt.prototype.visitUnion = ft(sO);
nt.prototype.visitDenseUnion = ft(ix);
nt.prototype.visitSparseUnion = ft(sx);
nt.prototype.visitDictionary = ft(oO);
nt.prototype.visitInterval = ft(aO);
nt.prototype.visitIntervalDayTime = ft(ox);
nt.prototype.visitIntervalYearMonth = ft(ax);
nt.prototype.visitDuration = ft(cO);
nt.prototype.visitDurationSecond = ft(cx);
nt.prototype.visitDurationMillisecond = ft(ux);
nt.prototype.visitDurationMicrosecond = ft(lx);
nt.prototype.visitDurationNanosecond = ft(fx);
nt.prototype.visitFixedSizeList = ft(uO);
nt.prototype.visitMap = ft(rO);
const Ze = new nt(), fo = Symbol.for("keys"), Io = Symbol.for("vals"), ho = Symbol.for("kKeysAsStrings"), v0 = Symbol.for("_kKeysAsStrings");
class um {
  constructor(t) {
    return this[fo] = new le([t.children[0]]).memoize(), this[Io] = t.children[1], new Proxy(this, new fO());
  }
  /** @ignore */
  get [ho]() {
    return this[v0] || (this[v0] = Array.from(this[fo].toArray(), String));
  }
  [Symbol.iterator]() {
    return new lO(this[fo], this[Io]);
  }
  get size() {
    return this[fo].length;
  }
  toArray() {
    return Object.values(this.toJSON());
  }
  toJSON() {
    const t = this[fo], n = this[Io], r = {};
    for (let i = -1, s = t.length; ++i < s; )
      r[t.get(i)] = Ze.visit(n, i);
    return r;
  }
  toString() {
    return `{${[...this].map(([t, n]) => `${vc(t)}: ${vc(n)}`).join(", ")}}`;
  }
  [Symbol.for("nodejs.util.inspect.custom")]() {
    return this.toString();
  }
}
class lO {
  constructor(t, n) {
    this.keys = t, this.vals = n, this.keyIndex = 0, this.numKeys = t.length;
  }
  [Symbol.iterator]() {
    return this;
  }
  next() {
    const t = this.keyIndex;
    return t === this.numKeys ? { done: !0, value: null } : (this.keyIndex++, {
      done: !1,
      value: [
        this.keys.get(t),
        Ze.visit(this.vals, t)
      ]
    });
  }
}
class fO {
  isExtensible() {
    return !1;
  }
  deleteProperty() {
    return !1;
  }
  preventExtensions() {
    return !0;
  }
  ownKeys(t) {
    return t[ho];
  }
  has(t, n) {
    return t[ho].includes(n);
  }
  getOwnPropertyDescriptor(t, n) {
    if (t[ho].indexOf(n) !== -1)
      return { writable: !0, enumerable: !0, configurable: !0 };
  }
  get(t, n) {
    if (Reflect.has(t, n))
      return t[n];
    const r = t[ho].indexOf(n);
    if (r !== -1) {
      const i = Ze.visit(Reflect.get(t, Io), r);
      return Reflect.set(t, n, i), i;
    }
  }
  set(t, n, r) {
    const i = t[ho].indexOf(n);
    return i !== -1 ? ($n.visit(Reflect.get(t, Io), i, r), Reflect.set(t, n, r)) : Reflect.has(t, n) ? Reflect.set(t, n, r) : !1;
  }
}
Object.defineProperties(um.prototype, {
  [Symbol.toStringTag]: { enumerable: !1, configurable: !1, value: "Row" },
  [fo]: { writable: !0, enumerable: !1, configurable: !1, value: null },
  [Io]: { writable: !0, enumerable: !1, configurable: !1, value: null },
  [v0]: { writable: !0, enumerable: !1, configurable: !1, value: null }
});
let yb;
function hx(e, t, n, r) {
  const { length: i = 0 } = e;
  let s = typeof t != "number" ? 0 : t, o = typeof n != "number" ? i : n;
  return s < 0 && (s = (s % i + i) % i), o < 0 && (o = (o % i + i) % i), o < s && (yb = s, s = o, o = yb), o > i && (o = i), r ? r(e, s, o) : [s, o];
}
const lm = (e, t) => e < 0 ? t + e : e, mb = (e) => e !== e;
function fa(e) {
  if (typeof e !== "object" || e === null)
    return mb(e) ? mb : (n) => n === e;
  if (e instanceof Date) {
    const n = e.valueOf();
    return (r) => r instanceof Date ? r.valueOf() === n : !1;
  }
  return ArrayBuffer.isView(e) ? (n) => n ? uD(e, n) : !1 : e instanceof Map ? dO(e) : Array.isArray(e) ? hO(e) : e instanceof le ? pO(e) : yO(e, !0);
}
function hO(e) {
  const t = [];
  for (let n = -1, r = e.length; ++n < r; )
    t[n] = fa(e[n]);
  return Vh(t);
}
function dO(e) {
  let t = -1;
  const n = [];
  for (const r of e.values())
    n[++t] = fa(r);
  return Vh(n);
}
function pO(e) {
  const t = [];
  for (let n = -1, r = e.length; ++n < r; )
    t[n] = fa(e.get(n));
  return Vh(t);
}
function yO(e, t = !1) {
  const n = Object.keys(e);
  if (!t && n.length === 0)
    return () => !1;
  const r = [];
  for (let i = -1, s = n.length; ++i < s; )
    r[i] = fa(e[n[i]]);
  return Vh(r, n);
}
function Vh(e, t) {
  return (n) => {
    if (!n || typeof n != "object")
      return !1;
    switch (n.constructor) {
      case Array:
        return mO(e, n);
      case Map:
        return gb(e, n, n.keys());
      case um:
      case cm:
      case Object:
      case void 0:
        return gb(e, n, t || Object.keys(n));
    }
    return n instanceof le ? gO(e, n) : !1;
  };
}
function mO(e, t) {
  const n = e.length;
  if (t.length !== n)
    return !1;
  for (let r = -1; ++r < n; )
    if (!e[r](t[r]))
      return !1;
  return !0;
}
function gO(e, t) {
  const n = e.length;
  if (t.length !== n)
    return !1;
  for (let r = -1; ++r < n; )
    if (!e[r](t.get(r)))
      return !1;
  return !0;
}
function gb(e, t, n) {
  const r = n[Symbol.iterator](), i = t instanceof Map ? t.keys() : Object.keys(t)[Symbol.iterator](), s = t instanceof Map ? t.values() : Object.values(t)[Symbol.iterator]();
  let o = 0;
  const a = e.length;
  let c = s.next(), u = r.next(), l = i.next();
  for (; o < a && !u.done && !l.done && !c.done && !(u.value !== l.value || !e[o](c.value)); ++o, u = r.next(), l = i.next(), c = s.next())
    ;
  return o === a && u.done && l.done && c.done ? !0 : (r.return && r.return(), i.return && i.return(), s.return && s.return(), !1);
}
function dx(e, t, n, r) {
  return (n & 1 << r) !== 0;
}
function bO(e, t, n, r) {
  return (n & 1 << r) >> r;
}
function bb(e, t, n) {
  const r = n.byteLength + 7 & -8;
  if (e > 0 || n.byteLength < r) {
    const i = new Uint8Array(r);
    return i.set(e % 8 === 0 ? n.subarray(e >> 3) : (
      // Otherwise iterate each bit from the offset and return a new one
      x0(new fm(n, e, t, null, dx)).subarray(0, r)
    )), i;
  }
  return n;
}
function x0(e) {
  const t = [];
  let n = 0, r = 0, i = 0;
  for (const o of e)
    o && (i |= 1 << r), ++r === 8 && (t[n++] = i, i = r = 0);
  (n === 0 || r > 0) && (t[n++] = i);
  const s = new Uint8Array(t.length + 7 & -8);
  return s.set(t), s;
}
class fm {
  constructor(t, n, r, i, s) {
    this.bytes = t, this.length = r, this.context = i, this.get = s, this.bit = n % 8, this.byteIndex = n >> 3, this.byte = t[this.byteIndex++], this.index = 0;
  }
  next() {
    return this.index < this.length ? (this.bit === 8 && (this.bit = 0, this.byte = this.bytes[this.byteIndex++]), {
      value: this.get(this.context, this.index++, this.byte, this.bit++)
    }) : { done: !0, value: null };
  }
  [Symbol.iterator]() {
    return this;
  }
}
function S0(e, t, n) {
  if (n - t <= 0)
    return 0;
  if (n - t < 8) {
    let s = 0;
    for (const o of new fm(e, t, n - t, e, bO))
      s += o;
    return s;
  }
  const r = n >> 3 << 3, i = t + (t % 8 === 0 ? 0 : 8 - t % 8);
  return (
    // Get the popcnt of bits between the left hand side, and the next highest multiple of 8
    S0(e, t, i) + // Get the popcnt of bits between the right hand side, and the next lowest multiple of 8
    S0(e, r, n) + // Get the popcnt of all bits between the left and right hand sides' multiples of 8
    wO(e, i >> 3, r - i >> 3)
  );
}
function wO(e, t, n) {
  let r = 0, i = Math.trunc(t);
  const s = new DataView(e.buffer, e.byteOffset, e.byteLength), o = n === void 0 ? e.byteLength : i + n;
  for (; o - i >= 4; )
    r += up(s.getUint32(i)), i += 4;
  for (; o - i >= 2; )
    r += up(s.getUint16(i)), i += 2;
  for (; o - i >= 1; )
    r += up(s.getUint8(i)), i += 1;
  return r;
}
function up(e) {
  let t = Math.trunc(e);
  return t = t - (t >>> 1 & 1431655765), t = (t & 858993459) + (t >>> 2 & 858993459), (t + (t >>> 4) & 252645135) * 16843009 >>> 24;
}
const _O = -1;
class jt {
  get typeId() {
    return this.type.typeId;
  }
  get ArrayType() {
    return this.type.ArrayType;
  }
  get buffers() {
    return [this.valueOffsets, this.values, this.nullBitmap, this.typeIds];
  }
  get nullable() {
    if (this._nullCount !== 0) {
      const { type: t } = this;
      return Q.isSparseUnion(t) ? this.children.some((n) => n.nullable) : Q.isDenseUnion(t) ? this.children.some((n) => n.nullable) : this.nullBitmap && this.nullBitmap.byteLength > 0;
    }
    return !0;
  }
  get byteLength() {
    let t = 0;
    const { valueOffsets: n, values: r, nullBitmap: i, typeIds: s } = this;
    return n && (t += n.byteLength), r && (t += r.byteLength), i && (t += i.byteLength), s && (t += s.byteLength), this.children.reduce((o, a) => o + a.byteLength, t);
  }
  get nullCount() {
    if (Q.isUnion(this.type))
      return this.children.reduce((r, i) => r + i.nullCount, 0);
    let t = this._nullCount, n;
    return t <= _O && (n = this.nullBitmap) && (this._nullCount = t = n.length === 0 ? (
      // no null bitmap, so all values are valid
      0
    ) : this.length - S0(n, this.offset, this.offset + this.length)), t;
  }
  constructor(t, n, r, i, s, o = [], a) {
    this.type = t, this.children = o, this.dictionary = a, this.offset = Math.floor(Math.max(n || 0, 0)), this.length = Math.floor(Math.max(r || 0, 0)), this._nullCount = Math.floor(Math.max(i || 0, -1));
    let c;
    s instanceof jt ? (this.stride = s.stride, this.values = s.values, this.typeIds = s.typeIds, this.nullBitmap = s.nullBitmap, this.valueOffsets = s.valueOffsets) : (this.stride = Ur(t), s && ((c = s[0]) && (this.valueOffsets = c), (c = s[1]) && (this.values = c), (c = s[2]) && (this.nullBitmap = c), (c = s[3]) && (this.typeIds = c)));
  }
  getValid(t) {
    const { type: n } = this;
    if (Q.isUnion(n)) {
      const r = n, i = this.children[r.typeIdToChildIndex[this.typeIds[t]]], s = r.mode === Je.Dense ? this.valueOffsets[t] : t;
      return i.getValid(s);
    }
    if (this.nullable && this.nullCount > 0) {
      const r = this.offset + t;
      return (this.nullBitmap[r >> 3] & 1 << r % 8) !== 0;
    }
    return !0;
  }
  setValid(t, n) {
    let r;
    const { type: i } = this;
    if (Q.isUnion(i)) {
      const s = i, o = this.children[s.typeIdToChildIndex[this.typeIds[t]]], a = s.mode === Je.Dense ? this.valueOffsets[t] : t;
      r = o.getValid(a), o.setValid(a, n);
    } else {
      let { nullBitmap: s } = this;
      const { offset: o, length: a } = this, c = o + t, u = 1 << c % 8, l = c >> 3;
      (!s || s.byteLength <= l) && (s = new Uint8Array((o + a + 63 & -64) >> 3).fill(255), this.nullCount > 0 ? (s.set(bb(o, a, this.nullBitmap), 0), Object.assign(this, { nullBitmap: s })) : Object.assign(this, { nullBitmap: s, _nullCount: 0 }));
      const f = s[l];
      r = (f & u) !== 0, s[l] = n ? f | u : f & ~u;
    }
    return r !== !!n && (this._nullCount = this.nullCount + (n ? -1 : 1)), n;
  }
  clone(t = this.type, n = this.offset, r = this.length, i = this._nullCount, s = this, o = this.children) {
    return new jt(t, n, r, i, s, o, this.dictionary);
  }
  slice(t, n) {
    const { stride: r, typeId: i, children: s } = this, o = +(this._nullCount === 0) - 1, a = i === 16 ? r : 1, c = this._sliceBuffers(t, n, r, i);
    return this.clone(
      this.type,
      this.offset + t,
      n,
      o,
      c,
      // Don't slice children if we have value offsets (the variable-width types)
      s.length === 0 || this.valueOffsets ? s : this._sliceChildren(s, a * t, a * n)
    );
  }
  _changeLengthAndBackfillNullBitmap(t) {
    if (this.typeId === L.Null)
      return this.clone(this.type, 0, t, 0);
    const { length: n, nullCount: r } = this, i = new Uint8Array((t + 63 & -64) >> 3).fill(255, 0, n >> 3);
    i[n >> 3] = (1 << n - (n & -8)) - 1, r > 0 && i.set(bb(this.offset, n, this.nullBitmap), 0);
    const s = this.buffers;
    return s[Pr.VALIDITY] = i, this.clone(this.type, 0, t, r + (t - n), s);
  }
  _sliceBuffers(t, n, r, i) {
    let s;
    const { buffers: o } = this;
    return (s = o[Pr.TYPE]) && (o[Pr.TYPE] = s.subarray(t, t + n)), (s = o[Pr.OFFSET]) && (o[Pr.OFFSET] = s.subarray(t, t + n + 1)) || // Otherwise if no offsets, slice the data buffer. Don't slice the data vector for Booleans, since the offset goes by bits not bytes
    (s = o[Pr.DATA]) && (o[Pr.DATA] = i === 6 ? s : s.subarray(r * t, r * (t + n))), o;
  }
  _sliceChildren(t, n, r) {
    return t.map((i) => i.slice(n, r));
  }
}
jt.prototype.children = Object.freeze([]);
class fc extends At {
  visit(t) {
    return this.getVisitFn(t.type).call(this, t);
  }
  visitNull(t) {
    const { ["type"]: n, ["offset"]: r = 0, ["length"]: i = 0 } = t;
    return new jt(n, r, i, i);
  }
  visitBool(t) {
    const { ["type"]: n, ["offset"]: r = 0 } = t, i = Dt(t.nullBitmap), s = Yt(n.ArrayType, t.data), { ["length"]: o = s.length >> 3, ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, o, a, [void 0, s, i]);
  }
  visitInt(t) {
    const { ["type"]: n, ["offset"]: r = 0 } = t, i = Dt(t.nullBitmap), s = Yt(n.ArrayType, t.data), { ["length"]: o = s.length, ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, o, a, [void 0, s, i]);
  }
  visitFloat(t) {
    const { ["type"]: n, ["offset"]: r = 0 } = t, i = Dt(t.nullBitmap), s = Yt(n.ArrayType, t.data), { ["length"]: o = s.length, ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, o, a, [void 0, s, i]);
  }
  visitUtf8(t) {
    const { ["type"]: n, ["offset"]: r = 0 } = t, i = Dt(t.data), s = Dt(t.nullBitmap), o = Na(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, a, c, [o, i, s]);
  }
  visitLargeUtf8(t) {
    const { ["type"]: n, ["offset"]: r = 0 } = t, i = Dt(t.data), s = Dt(t.nullBitmap), o = ib(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, a, c, [o, i, s]);
  }
  visitBinary(t) {
    const { ["type"]: n, ["offset"]: r = 0 } = t, i = Dt(t.data), s = Dt(t.nullBitmap), o = Na(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, a, c, [o, i, s]);
  }
  visitLargeBinary(t) {
    const { ["type"]: n, ["offset"]: r = 0 } = t, i = Dt(t.data), s = Dt(t.nullBitmap), o = ib(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, a, c, [o, i, s]);
  }
  visitFixedSizeBinary(t) {
    const { ["type"]: n, ["offset"]: r = 0 } = t, i = Dt(t.nullBitmap), s = Yt(n.ArrayType, t.data), { ["length"]: o = s.length / Ur(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, o, a, [void 0, s, i]);
  }
  visitDate(t) {
    const { ["type"]: n, ["offset"]: r = 0 } = t, i = Dt(t.nullBitmap), s = Yt(n.ArrayType, t.data), { ["length"]: o = s.length / Ur(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, o, a, [void 0, s, i]);
  }
  visitTimestamp(t) {
    const { ["type"]: n, ["offset"]: r = 0 } = t, i = Dt(t.nullBitmap), s = Yt(n.ArrayType, t.data), { ["length"]: o = s.length / Ur(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, o, a, [void 0, s, i]);
  }
  visitTime(t) {
    const { ["type"]: n, ["offset"]: r = 0 } = t, i = Dt(t.nullBitmap), s = Yt(n.ArrayType, t.data), { ["length"]: o = s.length / Ur(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, o, a, [void 0, s, i]);
  }
  visitDecimal(t) {
    const { ["type"]: n, ["offset"]: r = 0 } = t, i = Dt(t.nullBitmap), s = Yt(n.ArrayType, t.data), { ["length"]: o = s.length / Ur(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, o, a, [void 0, s, i]);
  }
  visitList(t) {
    const { ["type"]: n, ["offset"]: r = 0, ["child"]: i } = t, s = Dt(t.nullBitmap), o = Na(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, a, c, [o, void 0, s], [i]);
  }
  visitStruct(t) {
    const { ["type"]: n, ["offset"]: r = 0, ["children"]: i = [] } = t, s = Dt(t.nullBitmap), { length: o = i.reduce((c, { length: u }) => Math.max(c, u), 0), nullCount: a = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, o, a, [void 0, void 0, s], i);
  }
  visitUnion(t) {
    const { ["type"]: n, ["offset"]: r = 0, ["children"]: i = [] } = t, s = Yt(n.ArrayType, t.typeIds), { ["length"]: o = s.length, ["nullCount"]: a = -1 } = t;
    if (Q.isSparseUnion(n))
      return new jt(n, r, o, a, [void 0, void 0, void 0, s], i);
    const c = Na(t.valueOffsets);
    return new jt(n, r, o, a, [c, void 0, void 0, s], i);
  }
  visitDictionary(t) {
    const { ["type"]: n, ["offset"]: r = 0 } = t, i = Dt(t.nullBitmap), s = Yt(n.indices.ArrayType, t.data), { ["dictionary"]: o = new le([new fc().visit({ type: n.dictionary })]) } = t, { ["length"]: a = s.length, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, a, c, [void 0, s, i], [], o);
  }
  visitInterval(t) {
    const { ["type"]: n, ["offset"]: r = 0 } = t, i = Dt(t.nullBitmap), s = Yt(n.ArrayType, t.data), { ["length"]: o = s.length / Ur(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, o, a, [void 0, s, i]);
  }
  visitDuration(t) {
    const { ["type"]: n, ["offset"]: r = 0 } = t, i = Dt(t.nullBitmap), s = Yt(n.ArrayType, t.data), { ["length"]: o = s.length, ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, o, a, [void 0, s, i]);
  }
  visitFixedSizeList(t) {
    const { ["type"]: n, ["offset"]: r = 0, ["child"]: i = new fc().visit({ type: n.valueType }) } = t, s = Dt(t.nullBitmap), { ["length"]: o = i.length / Ur(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, o, a, [void 0, void 0, s], [i]);
  }
  visitMap(t) {
    const { ["type"]: n, ["offset"]: r = 0, ["child"]: i = new fc().visit({ type: n.childType }) } = t, s = Dt(t.nullBitmap), o = Na(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new jt(n, r, a, c, [o, void 0, s], [i]);
  }
}
const vO = new fc();
function St(e) {
  return vO.visit(e);
}
class wb {
  constructor(t = 0, n) {
    this.numChunks = t, this.getChunkIterator = n, this.chunkIndex = 0, this.chunkIterator = this.getChunkIterator(0);
  }
  next() {
    for (; this.chunkIndex < this.numChunks; ) {
      const t = this.chunkIterator.next();
      if (!t.done)
        return t;
      ++this.chunkIndex < this.numChunks && (this.chunkIterator = this.getChunkIterator(this.chunkIndex));
    }
    return { done: !0, value: null };
  }
  [Symbol.iterator]() {
    return this;
  }
}
function xO(e) {
  return e.some((t) => t.nullable);
}
function px(e) {
  return e.reduce((t, n) => t + n.nullCount, 0);
}
function yx(e) {
  return e.reduce((t, n, r) => (t[r + 1] = t[r] + n.length, t), new Uint32Array(e.length + 1));
}
function mx(e, t, n, r) {
  const i = [];
  for (let s = -1, o = e.length; ++s < o; ) {
    const a = e[s], c = t[s], { length: u } = a;
    if (c >= r)
      break;
    if (n >= c + u)
      continue;
    if (c >= n && c + u <= r) {
      i.push(a);
      continue;
    }
    const l = Math.max(0, n - c), f = Math.min(r - c, u);
    i.push(a.slice(l, f - l));
  }
  return i.length === 0 && i.push(e[0].slice(0, 0)), i;
}
function hm(e, t, n, r) {
  let i = 0, s = 0, o = t.length - 1;
  do {
    if (i >= o - 1)
      return n < t[o] ? r(e, i, n - t[i]) : null;
    s = i + Math.trunc((o - i) * 0.5), n < t[s] ? o = s : i = s;
  } while (i < o);
}
function dm(e, t) {
  return e.getValid(t);
}
function _f(e) {
  function t(n, r, i) {
    return e(n[r], i);
  }
  return function(n) {
    const r = this.data;
    return hm(r, this._offsets, n, t);
  };
}
function gx(e) {
  let t;
  function n(r, i, s) {
    return e(r[i], s, t);
  }
  return function(r, i) {
    const s = this.data;
    t = i;
    const o = hm(s, this._offsets, r, n);
    return t = void 0, o;
  };
}
function bx(e) {
  let t;
  function n(r, i, s) {
    let o = s, a = 0, c = 0;
    for (let u = i - 1, l = r.length; ++u < l; ) {
      const f = r[u];
      if (~(a = e(f, t, o)))
        return c + a;
      o = 0, c += f.length;
    }
    return -1;
  }
  return function(r, i) {
    t = r;
    const s = this.data, o = typeof i != "number" ? n(s, 0, 0) : hm(s, this._offsets, i, n);
    return t = void 0, o;
  };
}
class rt extends At {
}
function SO(e, t) {
  return t === null && e.length > 0 ? 0 : -1;
}
function MO(e, t) {
  const { nullBitmap: n } = e;
  if (!n || e.nullCount <= 0)
    return -1;
  let r = 0;
  for (const i of new fm(n, e.offset + (t || 0), e.length, n, dx)) {
    if (!i)
      return r;
    ++r;
  }
  return -1;
}
function gt(e, t, n) {
  if (t === void 0)
    return -1;
  if (t === null)
    switch (e.typeId) {
      case L.Union:
        break;
      case L.Dictionary:
        break;
      default:
        return MO(e, n);
    }
  const r = Ze.getVisitFn(e), i = fa(t);
  for (let s = (n || 0) - 1, o = e.length; ++s < o; )
    if (i(r(e, s)))
      return s;
  return -1;
}
function wx(e, t, n) {
  const r = Ze.getVisitFn(e), i = fa(t);
  for (let s = (n || 0) - 1, o = e.length; ++s < o; )
    if (i(r(e, s)))
      return s;
  return -1;
}
rt.prototype.visitNull = SO;
rt.prototype.visitBool = gt;
rt.prototype.visitInt = gt;
rt.prototype.visitInt8 = gt;
rt.prototype.visitInt16 = gt;
rt.prototype.visitInt32 = gt;
rt.prototype.visitInt64 = gt;
rt.prototype.visitUint8 = gt;
rt.prototype.visitUint16 = gt;
rt.prototype.visitUint32 = gt;
rt.prototype.visitUint64 = gt;
rt.prototype.visitFloat = gt;
rt.prototype.visitFloat16 = gt;
rt.prototype.visitFloat32 = gt;
rt.prototype.visitFloat64 = gt;
rt.prototype.visitUtf8 = gt;
rt.prototype.visitLargeUtf8 = gt;
rt.prototype.visitBinary = gt;
rt.prototype.visitLargeBinary = gt;
rt.prototype.visitFixedSizeBinary = gt;
rt.prototype.visitDate = gt;
rt.prototype.visitDateDay = gt;
rt.prototype.visitDateMillisecond = gt;
rt.prototype.visitTimestamp = gt;
rt.prototype.visitTimestampSecond = gt;
rt.prototype.visitTimestampMillisecond = gt;
rt.prototype.visitTimestampMicrosecond = gt;
rt.prototype.visitTimestampNanosecond = gt;
rt.prototype.visitTime = gt;
rt.prototype.visitTimeSecond = gt;
rt.prototype.visitTimeMillisecond = gt;
rt.prototype.visitTimeMicrosecond = gt;
rt.prototype.visitTimeNanosecond = gt;
rt.prototype.visitDecimal = gt;
rt.prototype.visitList = gt;
rt.prototype.visitStruct = gt;
rt.prototype.visitUnion = gt;
rt.prototype.visitDenseUnion = wx;
rt.prototype.visitSparseUnion = wx;
rt.prototype.visitDictionary = gt;
rt.prototype.visitInterval = gt;
rt.prototype.visitIntervalDayTime = gt;
rt.prototype.visitIntervalYearMonth = gt;
rt.prototype.visitDuration = gt;
rt.prototype.visitDurationSecond = gt;
rt.prototype.visitDurationMillisecond = gt;
rt.prototype.visitDurationMicrosecond = gt;
rt.prototype.visitDurationNanosecond = gt;
rt.prototype.visitFixedSizeList = gt;
rt.prototype.visitMap = gt;
const vf = new rt();
class st extends At {
}
function ht(e) {
  const { type: t } = e;
  if (e.nullCount === 0 && e.stride === 1 && // Don't defer to native iterator for timestamps since Numbers are expected
  // (DataType.isTimestamp(type)) && type.unit === TimeUnit.MILLISECOND ||
  (Q.isInt(t) && t.bitWidth !== 64 || Q.isTime(t) && t.bitWidth !== 64 || Q.isFloat(t) && t.precision !== Oe.HALF))
    return new wb(e.data.length, (r) => {
      const i = e.data[r];
      return i.values.subarray(0, i.length)[Symbol.iterator]();
    });
  let n = 0;
  return new wb(e.data.length, (r) => {
    const s = e.data[r].length, o = e.slice(n, n + s);
    return n += s, new AO(o);
  });
}
class AO {
  constructor(t) {
    this.vector = t, this.index = 0;
  }
  next() {
    return this.index < this.vector.length ? {
      value: this.vector.get(this.index++)
    } : { done: !0, value: null };
  }
  [Symbol.iterator]() {
    return this;
  }
}
st.prototype.visitNull = ht;
st.prototype.visitBool = ht;
st.prototype.visitInt = ht;
st.prototype.visitInt8 = ht;
st.prototype.visitInt16 = ht;
st.prototype.visitInt32 = ht;
st.prototype.visitInt64 = ht;
st.prototype.visitUint8 = ht;
st.prototype.visitUint16 = ht;
st.prototype.visitUint32 = ht;
st.prototype.visitUint64 = ht;
st.prototype.visitFloat = ht;
st.prototype.visitFloat16 = ht;
st.prototype.visitFloat32 = ht;
st.prototype.visitFloat64 = ht;
st.prototype.visitUtf8 = ht;
st.prototype.visitLargeUtf8 = ht;
st.prototype.visitBinary = ht;
st.prototype.visitLargeBinary = ht;
st.prototype.visitFixedSizeBinary = ht;
st.prototype.visitDate = ht;
st.prototype.visitDateDay = ht;
st.prototype.visitDateMillisecond = ht;
st.prototype.visitTimestamp = ht;
st.prototype.visitTimestampSecond = ht;
st.prototype.visitTimestampMillisecond = ht;
st.prototype.visitTimestampMicrosecond = ht;
st.prototype.visitTimestampNanosecond = ht;
st.prototype.visitTime = ht;
st.prototype.visitTimeSecond = ht;
st.prototype.visitTimeMillisecond = ht;
st.prototype.visitTimeMicrosecond = ht;
st.prototype.visitTimeNanosecond = ht;
st.prototype.visitDecimal = ht;
st.prototype.visitList = ht;
st.prototype.visitStruct = ht;
st.prototype.visitUnion = ht;
st.prototype.visitDenseUnion = ht;
st.prototype.visitSparseUnion = ht;
st.prototype.visitDictionary = ht;
st.prototype.visitInterval = ht;
st.prototype.visitIntervalDayTime = ht;
st.prototype.visitIntervalYearMonth = ht;
st.prototype.visitDuration = ht;
st.prototype.visitDurationSecond = ht;
st.prototype.visitDurationMillisecond = ht;
st.prototype.visitDurationMicrosecond = ht;
st.prototype.visitDurationNanosecond = ht;
st.prototype.visitFixedSizeList = ht;
st.prototype.visitMap = ht;
const pm = new st();
var _x;
const vx = {}, xx = {};
let le = class is {
  constructor(t) {
    var n, r, i;
    const s = t[0] instanceof is ? t.flatMap((a) => a.data) : t;
    if (s.length === 0 || s.some((a) => !(a instanceof jt)))
      throw new TypeError("Vector constructor expects an Array of Data instances.");
    const o = (n = s[0]) === null || n === void 0 ? void 0 : n.type;
    switch (s.length) {
      case 0:
        this._offsets = [0];
        break;
      case 1: {
        const { get: a, set: c, indexOf: u } = vx[o.typeId], l = s[0];
        this.isValid = (f) => dm(l, f), this.get = (f) => a(l, f), this.set = (f, h) => c(l, f, h), this.indexOf = (f) => u(l, f), this._offsets = [0, l.length];
        break;
      }
      default:
        Object.setPrototypeOf(this, xx[o.typeId]), this._offsets = yx(s);
        break;
    }
    this.data = s, this.type = o, this.stride = Ur(o), this.numChildren = (i = (r = o.children) === null || r === void 0 ? void 0 : r.length) !== null && i !== void 0 ? i : 0, this.length = this._offsets.at(-1);
  }
  /**
   * The aggregate size (in bytes) of this Vector's buffers and/or child Vectors.
   */
  get byteLength() {
    return this.data.reduce((t, n) => t + n.byteLength, 0);
  }
  /**
   * Whether this Vector's elements can contain null values.
   */
  get nullable() {
    return xO(this.data);
  }
  /**
   * The number of null elements in this Vector.
   */
  get nullCount() {
    return px(this.data);
  }
  /**
   * The Array or TypedArray constructor used for the JS representation
   *  of the element's values in {@link Vector.prototype.toArray `toArray()`}.
   */
  get ArrayType() {
    return this.type.ArrayType;
  }
  /**
   * The name that should be printed when the Vector is logged in a message.
   */
  get [Symbol.toStringTag]() {
    return `${this.VectorName}<${this.type[Symbol.toStringTag]}>`;
  }
  /**
   * The name of this Vector.
   */
  get VectorName() {
    return `${L[this.type.typeId]}Vector`;
  }
  /**
   * Check whether an element is null.
   * @param index The index at which to read the validity bitmap.
   */
  // @ts-ignore
  isValid(t) {
    return !1;
  }
  /**
   * Get an element value by position.
   * @param index The index of the element to read.
   */
  // @ts-ignore
  get(t) {
    return null;
  }
  /**
   * Get an element value by position.
   * @param index The index of the element to read. A negative index will count back from the last element.
   */
  at(t) {
    return this.get(lm(t, this.length));
  }
  /**
   * Set an element value by position.
   * @param index The index of the element to write.
   * @param value The value to set.
   */
  // @ts-ignore
  set(t, n) {
  }
  /**
   * Retrieve the index of the first occurrence of a value in an Vector.
   * @param element The value to locate in the Vector.
   * @param offset The index at which to begin the search. If offset is omitted, the search starts at index 0.
   */
  // @ts-ignore
  indexOf(t, n) {
    return -1;
  }
  includes(t, n) {
    return this.indexOf(t, n) > -1;
  }
  /**
   * Iterator for the Vector's elements.
   */
  [Symbol.iterator]() {
    return pm.visit(this);
  }
  /**
   * Combines two or more Vectors of the same type.
   * @param others Additional Vectors to add to the end of this Vector.
   */
  concat(...t) {
    return new is(this.data.concat(t.flatMap((n) => n.data).flat(Number.POSITIVE_INFINITY)));
  }
  /**
   * Return a zero-copy sub-section of this Vector.
   * @param start The beginning of the specified portion of the Vector.
   * @param end The end of the specified portion of the Vector. This is exclusive of the element at the index 'end'.
   */
  slice(t, n) {
    return new is(hx(this, t, n, ({ data: r, _offsets: i }, s, o) => mx(r, i, s, o)));
  }
  toJSON() {
    return [...this];
  }
  /**
   * Return a JavaScript Array or TypedArray of the Vector's elements.
   *
   * @note If this Vector contains a single Data chunk and the Vector's type is a
   *  primitive numeric type corresponding to one of the JavaScript TypedArrays, this
   *  method returns a zero-copy slice of the underlying TypedArray values. If there's
   *  more than one chunk, the resulting TypedArray will be a copy of the data from each
   *  chunk's underlying TypedArray values.
   *
   * @returns An Array or TypedArray of the Vector's elements, based on the Vector's DataType.
   */
  toArray() {
    const { type: t, data: n, length: r, stride: i, ArrayType: s } = this;
    switch (t.typeId) {
      case L.Int:
      case L.Float:
      case L.Decimal:
      case L.Time:
      case L.Timestamp:
        switch (n.length) {
          case 0:
            return new s();
          case 1:
            return n[0].values.subarray(0, r * i);
          default:
            return n.reduce((o, { values: a, length: c }) => (o.array.set(a.subarray(0, c * i), o.offset), o.offset += c * i, o), { array: new s(r * i), offset: 0 }).array;
        }
    }
    return [...this];
  }
  /**
   * Returns a string representation of the Vector.
   *
   * @returns A string representation of the Vector.
   */
  toString() {
    return `[${[...this].join(",")}]`;
  }
  /**
   * Returns a child Vector by name, or null if this Vector has no child with the given name.
   * @param name The name of the child to retrieve.
   */
  getChild(t) {
    var n;
    return this.getChildAt((n = this.type.children) === null || n === void 0 ? void 0 : n.findIndex((r) => r.name === t));
  }
  /**
   * Returns a child Vector by index, or null if this Vector has no child at the supplied index.
   * @param index The index of the child to retrieve.
   */
  getChildAt(t) {
    return t > -1 && t < this.numChildren ? new is(this.data.map(({ children: n }) => n[t])) : null;
  }
  get isMemoized() {
    return Q.isDictionary(this.type) ? this.data[0].dictionary.isMemoized : !1;
  }
  /**
   * Adds memoization to the Vector's {@link get} method. For dictionary
   * vectors, this method return a vector that memoizes only the dictionary
   * values.
   *
   * Memoization is very useful when decoding a value is expensive such as
   * Utf8. The memoization creates a cache of the size of the Vector and
   * therefore increases memory usage.
   *
   * @returns A new vector that memoizes calls to {@link get}.
   */
  memoize() {
    if (Q.isDictionary(this.type)) {
      const t = new xf(this.data[0].dictionary), n = this.data.map((r) => {
        const i = r.clone();
        return i.dictionary = t, i;
      });
      return new is(n);
    }
    return new xf(this);
  }
  /**
   * Returns a vector without memoization of the {@link get} method. If this
   * vector is not memoized, this method returns this vector.
   *
   * @returns A new vector without memoization.
   */
  unmemoize() {
    if (Q.isDictionary(this.type) && this.isMemoized) {
      const t = this.data[0].dictionary.unmemoize(), n = this.data.map((r) => {
        const i = r.clone();
        return i.dictionary = t, i;
      });
      return new is(n);
    }
    return this;
  }
};
_x = Symbol.toStringTag;
le[_x] = ((e) => {
  e.type = Q.prototype, e.data = [], e.length = 0, e.stride = 1, e.numChildren = 0, e._offsets = new Uint32Array([0]), e[Symbol.isConcatSpreadable] = !0;
  const t = Object.keys(L).map((n) => L[n]).filter((n) => typeof n == "number" && n !== L.NONE);
  for (const n of t) {
    const r = Ze.getVisitFnByTypeId(n), i = $n.getVisitFnByTypeId(n), s = vf.getVisitFnByTypeId(n);
    vx[n] = { get: r, set: i, indexOf: s }, xx[n] = Object.create(e, {
      isValid: { value: _f(dm) },
      get: { value: _f(Ze.getVisitFnByTypeId(n)) },
      set: { value: gx($n.getVisitFnByTypeId(n)) },
      indexOf: { value: bx(vf.getVisitFnByTypeId(n)) }
    });
  }
  return "Vector";
})(le.prototype);
class xf extends le {
  constructor(t) {
    super(t.data);
    const n = this.get, r = this.set, i = this.slice, s = new Array(this.length);
    Object.defineProperty(this, "get", {
      value(o) {
        const a = s[o];
        if (a !== void 0)
          return a;
        const c = n.call(this, o);
        return s[o] = c, c;
      }
    }), Object.defineProperty(this, "set", {
      value(o, a) {
        r.call(this, o, a), s[o] = a;
      }
    }), Object.defineProperty(this, "slice", {
      value: (o, a) => new xf(i.call(this, o, a))
    }), Object.defineProperty(this, "isMemoized", { value: !0 }), Object.defineProperty(this, "unmemoize", {
      value: () => new le(this.data)
    }), Object.defineProperty(this, "memoize", {
      value: () => this
    });
  }
}
class M0 {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  /**
   * Index to the start of the RecordBlock (note this is past the Message header)
   */
  offset() {
    return this.bb.readInt64(this.bb_pos);
  }
  /**
   * Length of the metadata
   */
  metaDataLength() {
    return this.bb.readInt32(this.bb_pos + 8);
  }
  /**
   * Length of the data (this is aligned so there can be a gap between this and
   * the metadata).
   */
  bodyLength() {
    return this.bb.readInt64(this.bb_pos + 16);
  }
  static sizeOf() {
    return 24;
  }
  static createBlock(t, n, r, i) {
    return t.prep(8, 24), t.writeInt64(BigInt(i ?? 0)), t.pad(4), t.writeInt32(r), t.writeInt64(BigInt(n ?? 0)), t.offset();
  }
}
class nn {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsFooter(t, n) {
    return (n || new nn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFooter(t, n) {
    return t.setPosition(t.position() + qt), (n || new nn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  version() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt16(this.bb_pos + t) : he.V1;
  }
  schema(t) {
    const n = this.bb.__offset(this.bb_pos, 6);
    return n ? (t || new tr()).__init(this.bb.__indirect(this.bb_pos + n), this.bb) : null;
  }
  dictionaries(t, n) {
    const r = this.bb.__offset(this.bb_pos, 8);
    return r ? (n || new M0()).__init(this.bb.__vector(this.bb_pos + r) + t * 24, this.bb) : null;
  }
  dictionariesLength() {
    const t = this.bb.__offset(this.bb_pos, 8);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  recordBatches(t, n) {
    const r = this.bb.__offset(this.bb_pos, 10);
    return r ? (n || new M0()).__init(this.bb.__vector(this.bb_pos + r) + t * 24, this.bb) : null;
  }
  recordBatchesLength() {
    const t = this.bb.__offset(this.bb_pos, 10);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  /**
   * User-defined metadata
   */
  customMetadata(t, n) {
    const r = this.bb.__offset(this.bb_pos, 12);
    return r ? (n || new de()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + r) + t * 4), this.bb) : null;
  }
  customMetadataLength() {
    const t = this.bb.__offset(this.bb_pos, 12);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  static startFooter(t) {
    t.startObject(5);
  }
  static addVersion(t, n) {
    t.addFieldInt16(0, n, he.V1);
  }
  static addSchema(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static addDictionaries(t, n) {
    t.addFieldOffset(2, n, 0);
  }
  static startDictionariesVector(t, n) {
    t.startVector(24, n, 8);
  }
  static addRecordBatches(t, n) {
    t.addFieldOffset(3, n, 0);
  }
  static startRecordBatchesVector(t, n) {
    t.startVector(24, n, 8);
  }
  static addCustomMetadata(t, n) {
    t.addFieldOffset(4, n, 0);
  }
  static createCustomMetadataVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let r = n.length - 1; r >= 0; r--)
      t.addOffset(n[r]);
    return t.endVector();
  }
  static startCustomMetadataVector(t, n) {
    t.startVector(4, n, 4);
  }
  static endFooter(t) {
    return t.endObject();
  }
  static finishFooterBuffer(t, n) {
    t.finish(n);
  }
  static finishSizePrefixedFooterBuffer(t, n) {
    t.finish(n, void 0, !0);
  }
}
class Ut {
  constructor(t = [], n, r, i = he.V5) {
    this.fields = t || [], this.metadata = n || /* @__PURE__ */ new Map(), r || (r = A0(t)), this.dictionaries = r, this.metadataVersion = i;
  }
  get [Symbol.toStringTag]() {
    return "Schema";
  }
  get names() {
    return this.fields.map((t) => t.name);
  }
  toString() {
    return `Schema<{ ${this.fields.map((t, n) => `${n}: ${t}`).join(", ")} }>`;
  }
  /**
   * Construct a new Schema containing only specified fields.
   *
   * @param fieldNames Names of fields to keep.
   * @returns A new Schema of fields matching the specified names.
   */
  select(t) {
    const n = new Set(t), r = this.fields.filter((i) => n.has(i.name));
    return new Ut(r, this.metadata);
  }
  /**
   * Construct a new Schema containing only fields at the specified indices.
   *
   * @param fieldIndices Indices of fields to keep.
   * @returns A new Schema of fields at the specified indices.
   */
  selectAt(t) {
    const n = t.map((r) => this.fields[r]).filter(Boolean);
    return new Ut(n, this.metadata);
  }
  assign(...t) {
    const n = t[0] instanceof Ut ? t[0] : Array.isArray(t[0]) ? new Ut(t[0]) : new Ut(t), r = [...this.fields], i = Yu(Yu(/* @__PURE__ */ new Map(), this.metadata), n.metadata), s = n.fields.filter((a) => {
      const c = r.findIndex((u) => u.name === a.name);
      return ~c ? (r[c] = a.clone({
        metadata: Yu(Yu(/* @__PURE__ */ new Map(), r[c].metadata), a.metadata)
      })) && !1 : !0;
    }), o = A0(s, /* @__PURE__ */ new Map());
    return new Ut([...r, ...s], i, new Map([...this.dictionaries, ...o]));
  }
}
Ut.prototype.fields = null;
Ut.prototype.metadata = null;
Ut.prototype.dictionaries = null;
class Qt {
  /** @nocollapse */
  static new(...t) {
    let [n, r, i, s] = t;
    return t[0] && typeof t[0] == "object" && ({ name: n } = t[0], r === void 0 && (r = t[0].type), i === void 0 && (i = t[0].nullable), s === void 0 && (s = t[0].metadata)), new Qt(`${n}`, r, i, s);
  }
  constructor(t, n, r = !1, i) {
    this.name = t, this.type = n, this.nullable = r, this.metadata = i || /* @__PURE__ */ new Map();
  }
  get typeId() {
    return this.type.typeId;
  }
  get [Symbol.toStringTag]() {
    return "Field";
  }
  toString() {
    return `${this.name}: ${this.type}`;
  }
  clone(...t) {
    let [n, r, i, s] = t;
    return !t[0] || typeof t[0] != "object" ? [n = this.name, r = this.type, i = this.nullable, s = this.metadata] = t : { name: n = this.name, type: r = this.type, nullable: i = this.nullable, metadata: s = this.metadata } = t[0], Qt.new(n, r, i, s);
  }
}
Qt.prototype.type = null;
Qt.prototype.name = null;
Qt.prototype.nullable = null;
Qt.prototype.metadata = null;
function Yu(e, t) {
  return new Map([...e || /* @__PURE__ */ new Map(), ...t || /* @__PURE__ */ new Map()]);
}
function A0(e, t = /* @__PURE__ */ new Map()) {
  for (let n = -1, r = e.length; ++n < r; ) {
    const s = e[n].type;
    if (Q.isDictionary(s)) {
      if (!t.has(s.id))
        t.set(s.id, s.dictionary);
      else if (t.get(s.id) !== s.dictionary)
        throw new Error("Cannot create Schema containing two different dictionaries with the same Id");
    }
    s.children && s.children.length > 0 && A0(s.children, t);
  }
  return t;
}
var $O = W_, IO = Bo;
class ym {
  /** @nocollapse */
  static decode(t) {
    t = new IO(Dt(t));
    const n = nn.getRootAsFooter(t), r = Ut.decode(n.schema(), /* @__PURE__ */ new Map(), n.version());
    return new TO(r, n);
  }
  /** @nocollapse */
  static encode(t) {
    const n = new $O(), r = Ut.encode(n, t.schema);
    nn.startRecordBatchesVector(n, t.numRecordBatches);
    for (const o of [...t.recordBatches()].slice().reverse())
      Uo.encode(n, o);
    const i = n.endVector();
    nn.startDictionariesVector(n, t.numDictionaries);
    for (const o of [...t.dictionaryBatches()].slice().reverse())
      Uo.encode(n, o);
    const s = n.endVector();
    return nn.startFooter(n), nn.addSchema(n, r), nn.addVersion(n, he.V5), nn.addRecordBatches(n, i), nn.addDictionaries(n, s), nn.finishFooterBuffer(n, nn.endFooter(n)), n.asUint8Array();
  }
  get numRecordBatches() {
    return this._recordBatches.length;
  }
  get numDictionaries() {
    return this._dictionaryBatches.length;
  }
  constructor(t, n = he.V5, r, i) {
    this.schema = t, this.version = n, r && (this._recordBatches = r), i && (this._dictionaryBatches = i);
  }
  *recordBatches() {
    for (let t, n = -1, r = this.numRecordBatches; ++n < r; )
      (t = this.getRecordBatch(n)) && (yield t);
  }
  *dictionaryBatches() {
    for (let t, n = -1, r = this.numDictionaries; ++n < r; )
      (t = this.getDictionaryBatch(n)) && (yield t);
  }
  getRecordBatch(t) {
    return t >= 0 && t < this.numRecordBatches && this._recordBatches[t] || null;
  }
  getDictionaryBatch(t) {
    return t >= 0 && t < this.numDictionaries && this._dictionaryBatches[t] || null;
  }
}
class TO extends ym {
  get numRecordBatches() {
    return this._footer.recordBatchesLength();
  }
  get numDictionaries() {
    return this._footer.dictionariesLength();
  }
  constructor(t, n) {
    super(t, n.version()), this._footer = n;
  }
  getRecordBatch(t) {
    if (t >= 0 && t < this.numRecordBatches) {
      const n = this._footer.recordBatches(t);
      if (n)
        return Uo.decode(n);
    }
    return null;
  }
  getDictionaryBatch(t) {
    if (t >= 0 && t < this.numDictionaries) {
      const n = this._footer.dictionaries(t);
      if (n)
        return Uo.decode(n);
    }
    return null;
  }
}
class Uo {
  /** @nocollapse */
  static decode(t) {
    return new Uo(t.metaDataLength(), t.bodyLength(), t.offset());
  }
  /** @nocollapse */
  static encode(t, n) {
    const { metaDataLength: r } = n, i = BigInt(n.offset), s = BigInt(n.bodyLength);
    return M0.createBlock(t, i, r, s);
  }
  constructor(t, n, r) {
    this.metaDataLength = t, this.offset = Kt(r), this.bodyLength = Kt(n);
  }
}
const re = Object.freeze({ done: !0, value: void 0 });
class _b {
  constructor(t) {
    this._json = t;
  }
  get schema() {
    return this._json.schema;
  }
  get batches() {
    return this._json.batches || [];
  }
  get dictionaries() {
    return this._json.dictionaries || [];
  }
}
class Sx {
  tee() {
    return this._getDOMStream().tee();
  }
  pipe(t, n) {
    return this._getNodeStream().pipe(t, n);
  }
  pipeTo(t, n) {
    return this._getDOMStream().pipeTo(t, n);
  }
  pipeThrough(t, n) {
    return this._getDOMStream().pipeThrough(t, n);
  }
  _getDOMStream() {
    return this._DOMStream || (this._DOMStream = this.toDOMStream());
  }
  _getNodeStream() {
    return this._nodeStream || (this._nodeStream = this.toNodeStream());
  }
}
class EO extends Sx {
  constructor() {
    super(), this._values = [], this.resolvers = [], this._closedPromise = new Promise((t) => this._closedPromiseResolve = t);
  }
  get closed() {
    return this._closedPromise;
  }
  cancel(t) {
    return bt(this, void 0, void 0, function* () {
      yield this.return(t);
    });
  }
  write(t) {
    this._ensureOpen() && (this.resolvers.length <= 0 ? this._values.push(t) : this.resolvers.shift().resolve({ done: !1, value: t }));
  }
  abort(t) {
    this._closedPromiseResolve && (this.resolvers.length <= 0 ? this._error = { error: t } : this.resolvers.shift().reject({ done: !0, value: t }));
  }
  close() {
    if (this._closedPromiseResolve) {
      const { resolvers: t } = this;
      for (; t.length > 0; )
        t.shift().resolve(re);
      this._closedPromiseResolve(), this._closedPromiseResolve = void 0;
    }
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  toDOMStream(t) {
    return mn.toDOMStream(this._closedPromiseResolve || this._error ? this : this._values, t);
  }
  toNodeStream(t) {
    return mn.toNodeStream(this._closedPromiseResolve || this._error ? this : this._values, t);
  }
  throw(t) {
    return bt(this, void 0, void 0, function* () {
      return yield this.abort(t), re;
    });
  }
  return(t) {
    return bt(this, void 0, void 0, function* () {
      return yield this.close(), re;
    });
  }
  read(t) {
    return bt(this, void 0, void 0, function* () {
      return (yield this.next(t, "read")).value;
    });
  }
  peek(t) {
    return bt(this, void 0, void 0, function* () {
      return (yield this.next(t, "peek")).value;
    });
  }
  next(...t) {
    return this._values.length > 0 ? Promise.resolve({ done: !1, value: this._values.shift() }) : this._error ? Promise.reject({ done: !0, value: this._error.error }) : this._closedPromiseResolve ? new Promise((n, r) => {
      this.resolvers.push({ resolve: n, reject: r });
    }) : Promise.resolve(re);
  }
  _ensureOpen() {
    if (this._closedPromiseResolve)
      return !0;
    throw new Error("AsyncQueue is closed");
  }
}
class NO extends EO {
  write(t) {
    if ((t = Dt(t)).byteLength > 0)
      return super.write(t);
  }
  toString(t = !1) {
    return t ? y0(this.toUint8Array(!0)) : this.toUint8Array(!1).then(y0);
  }
  toUint8Array(t = !1) {
    return t ? mr(this._values)[0] : bt(this, void 0, void 0, function* () {
      var n, r, i, s;
      const o = [];
      let a = 0;
      try {
        for (var c = !0, u = So(this), l; l = yield u.next(), n = l.done, !n; c = !0) {
          s = l.value, c = !1;
          const f = s;
          o.push(f), a += f.byteLength;
        }
      } catch (f) {
        r = { error: f };
      } finally {
        try {
          !c && !n && (i = u.return) && (yield i.call(u));
        } finally {
          if (r) throw r.error;
        }
      }
      return mr(o, a)[0];
    });
  }
}
class Sf {
  constructor(t) {
    t && (this.source = new DO(mn.fromIterable(t)));
  }
  [Symbol.iterator]() {
    return this;
  }
  next(t) {
    return this.source.next(t);
  }
  throw(t) {
    return this.source.throw(t);
  }
  return(t) {
    return this.source.return(t);
  }
  peek(t) {
    return this.source.peek(t);
  }
  read(t) {
    return this.source.read(t);
  }
}
class zo {
  constructor(t) {
    t instanceof zo ? this.source = t.source : t instanceof NO ? this.source = new ns(mn.fromAsyncIterable(t)) : j_(t) ? this.source = new ns(mn.fromNodeStream(t)) : im(t) ? this.source = new ns(mn.fromDOMStream(t)) : z_(t) ? this.source = new ns(mn.fromDOMStream(t.body)) : jh(t) ? this.source = new ns(mn.fromIterable(t)) : _c(t) ? this.source = new ns(mn.fromAsyncIterable(t)) : rm(t) && (this.source = new ns(mn.fromAsyncIterable(t)));
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  next(t) {
    return this.source.next(t);
  }
  throw(t) {
    return this.source.throw(t);
  }
  return(t) {
    return this.source.return(t);
  }
  get closed() {
    return this.source.closed;
  }
  cancel(t) {
    return this.source.cancel(t);
  }
  peek(t) {
    return this.source.peek(t);
  }
  read(t) {
    return this.source.read(t);
  }
}
class DO {
  constructor(t) {
    this.source = t;
  }
  cancel(t) {
    this.return(t);
  }
  peek(t) {
    return this.next(t, "peek").value;
  }
  read(t) {
    return this.next(t, "read").value;
  }
  next(t, n = "read") {
    return this.source.next({ cmd: n, size: t });
  }
  throw(t) {
    return Object.create(this.source.throw && this.source.throw(t) || re);
  }
  return(t) {
    return Object.create(this.source.return && this.source.return(t) || re);
  }
}
class ns {
  constructor(t) {
    this.source = t, this._closedPromise = new Promise((n) => this._closedPromiseResolve = n);
  }
  cancel(t) {
    return bt(this, void 0, void 0, function* () {
      yield this.return(t);
    });
  }
  get closed() {
    return this._closedPromise;
  }
  read(t) {
    return bt(this, void 0, void 0, function* () {
      return (yield this.next(t, "read")).value;
    });
  }
  peek(t) {
    return bt(this, void 0, void 0, function* () {
      return (yield this.next(t, "peek")).value;
    });
  }
  next(t) {
    return bt(this, arguments, void 0, function* (n, r = "read") {
      return yield this.source.next({ cmd: r, size: n });
    });
  }
  throw(t) {
    return bt(this, void 0, void 0, function* () {
      const n = this.source.throw && (yield this.source.throw(t)) || re;
      return this._closedPromiseResolve && this._closedPromiseResolve(), this._closedPromiseResolve = void 0, Object.create(n);
    });
  }
  return(t) {
    return bt(this, void 0, void 0, function* () {
      const n = this.source.return && (yield this.source.return(t)) || re;
      return this._closedPromiseResolve && this._closedPromiseResolve(), this._closedPromiseResolve = void 0, Object.create(n);
    });
  }
}
class vb extends Sf {
  constructor(t, n) {
    super(), this.position = 0, this.buffer = Dt(t), this.size = n === void 0 ? this.buffer.byteLength : n;
  }
  readInt32(t) {
    const { buffer: n, byteOffset: r } = this.readAt(t, 4);
    return new DataView(n, r).getInt32(0, !0);
  }
  seek(t) {
    return this.position = Math.min(t, this.size), t < this.size;
  }
  read(t) {
    const { buffer: n, size: r, position: i } = this;
    return n && i < r ? (typeof t != "number" && (t = Number.POSITIVE_INFINITY), this.position = Math.min(r, i + Math.min(r - i, t)), n.subarray(i, this.position)) : null;
  }
  readAt(t, n) {
    const r = this.buffer, i = Math.min(this.size, t + n);
    return r ? r.subarray(t, i) : new Uint8Array(n);
  }
  close() {
    this.buffer && (this.buffer = null);
  }
  throw(t) {
    return this.close(), { done: !0, value: t };
  }
  return(t) {
    return this.close(), { done: !0, value: t };
  }
}
class Mf extends zo {
  constructor(t, n) {
    super(), this.position = 0, this._handle = t, typeof n == "number" ? this.size = n : this._pending = bt(this, void 0, void 0, function* () {
      this.size = (yield t.stat()).size, delete this._pending;
    });
  }
  readInt32(t) {
    return bt(this, void 0, void 0, function* () {
      const { buffer: n, byteOffset: r } = yield this.readAt(t, 4);
      return new DataView(n, r).getInt32(0, !0);
    });
  }
  seek(t) {
    return bt(this, void 0, void 0, function* () {
      return this._pending && (yield this._pending), this.position = Math.min(t, this.size), t < this.size;
    });
  }
  read(t) {
    return bt(this, void 0, void 0, function* () {
      this._pending && (yield this._pending);
      const { _handle: n, size: r, position: i } = this;
      if (n && i < r) {
        typeof t != "number" && (t = Number.POSITIVE_INFINITY);
        let s = i, o = 0, a = 0;
        const c = Math.min(r, s + Math.min(r - s, t)), u = new Uint8Array(Math.max(0, (this.position = c) - s));
        for (; (s += a) < c && (o += a) < u.byteLength; )
          ({ bytesRead: a } = yield n.read(u, o, u.byteLength - o, s));
        return u;
      }
      return null;
    });
  }
  readAt(t, n) {
    return bt(this, void 0, void 0, function* () {
      this._pending && (yield this._pending);
      const { _handle: r, size: i } = this;
      if (r && t + n < i) {
        const s = Math.min(i, t + n), o = new Uint8Array(s - t);
        return (yield r.read(o, 0, n, t)).buffer;
      }
      return new Uint8Array(n);
    });
  }
  close() {
    return bt(this, void 0, void 0, function* () {
      const t = this._handle;
      this._handle = null, t && (yield t.close());
    });
  }
  throw(t) {
    return bt(this, void 0, void 0, function* () {
      return yield this.close(), { done: !0, value: t };
    });
  }
  return(t) {
    return bt(this, void 0, void 0, function* () {
      return yield this.close(), { done: !0, value: t };
    });
  }
}
const OO = 65536;
function yo(e) {
  return e < 0 && (e = 4294967295 + e + 1), `0x${e.toString(16)}`;
}
const qo = 8, mm = [
  1,
  10,
  100,
  1e3,
  1e4,
  1e5,
  1e6,
  1e7,
  1e8
];
class Mx {
  constructor(t) {
    this.buffer = t;
  }
  high() {
    return this.buffer[1];
  }
  low() {
    return this.buffer[0];
  }
  _times(t) {
    const n = new Uint32Array([
      this.buffer[1] >>> 16,
      this.buffer[1] & 65535,
      this.buffer[0] >>> 16,
      this.buffer[0] & 65535
    ]), r = new Uint32Array([
      t.buffer[1] >>> 16,
      t.buffer[1] & 65535,
      t.buffer[0] >>> 16,
      t.buffer[0] & 65535
    ]);
    let i = n[3] * r[3];
    this.buffer[0] = i & 65535;
    let s = i >>> 16;
    return i = n[2] * r[3], s += i, i = n[3] * r[2] >>> 0, s += i, this.buffer[0] += s << 16, this.buffer[1] = s >>> 0 < i ? OO : 0, this.buffer[1] += s >>> 16, this.buffer[1] += n[1] * r[3] + n[2] * r[2] + n[3] * r[1], this.buffer[1] += n[0] * r[3] + n[1] * r[2] + n[2] * r[1] + n[3] * r[0] << 16, this;
  }
  _plus(t) {
    const n = this.buffer[0] + t.buffer[0] >>> 0;
    this.buffer[1] += t.buffer[1], n < this.buffer[0] >>> 0 && ++this.buffer[1], this.buffer[0] = n;
  }
  lessThan(t) {
    return this.buffer[1] < t.buffer[1] || this.buffer[1] === t.buffer[1] && this.buffer[0] < t.buffer[0];
  }
  equals(t) {
    return this.buffer[1] === t.buffer[1] && this.buffer[0] == t.buffer[0];
  }
  greaterThan(t) {
    return t.lessThan(this);
  }
  hex() {
    return `${yo(this.buffer[1])} ${yo(this.buffer[0])}`;
  }
}
class Vt extends Mx {
  times(t) {
    return this._times(t), this;
  }
  plus(t) {
    return this._plus(t), this;
  }
  /** @nocollapse */
  static from(t, n = new Uint32Array(2)) {
    return Vt.fromString(typeof t == "string" ? t : t.toString(), n);
  }
  /** @nocollapse */
  static fromNumber(t, n = new Uint32Array(2)) {
    return Vt.fromString(t.toString(), n);
  }
  /** @nocollapse */
  static fromString(t, n = new Uint32Array(2)) {
    const r = t.length, i = new Vt(n);
    for (let s = 0; s < r; ) {
      const o = qo < r - s ? qo : r - s, a = new Vt(new Uint32Array([Number.parseInt(t.slice(s, s + o), 10), 0])), c = new Vt(new Uint32Array([mm[o], 0]));
      i.times(c), i.plus(a), s += o;
    }
    return i;
  }
  /** @nocollapse */
  static convertArray(t) {
    const n = new Uint32Array(t.length * 2);
    for (let r = -1, i = t.length; ++r < i; )
      Vt.from(t[r], new Uint32Array(n.buffer, n.byteOffset + 2 * r * 4, 2));
    return n;
  }
  /** @nocollapse */
  static multiply(t, n) {
    return new Vt(new Uint32Array(t.buffer)).times(n);
  }
  /** @nocollapse */
  static add(t, n) {
    return new Vt(new Uint32Array(t.buffer)).plus(n);
  }
}
class Ye extends Mx {
  negate() {
    return this.buffer[0] = ~this.buffer[0] + 1, this.buffer[1] = ~this.buffer[1], this.buffer[0] == 0 && ++this.buffer[1], this;
  }
  times(t) {
    return this._times(t), this;
  }
  plus(t) {
    return this._plus(t), this;
  }
  lessThan(t) {
    const n = this.buffer[1] << 0, r = t.buffer[1] << 0;
    return n < r || n === r && this.buffer[0] < t.buffer[0];
  }
  /** @nocollapse */
  static from(t, n = new Uint32Array(2)) {
    return Ye.fromString(typeof t == "string" ? t : t.toString(), n);
  }
  /** @nocollapse */
  static fromNumber(t, n = new Uint32Array(2)) {
    return Ye.fromString(t.toString(), n);
  }
  /** @nocollapse */
  static fromString(t, n = new Uint32Array(2)) {
    const r = t.startsWith("-"), i = t.length, s = new Ye(n);
    for (let o = r ? 1 : 0; o < i; ) {
      const a = qo < i - o ? qo : i - o, c = new Ye(new Uint32Array([Number.parseInt(t.slice(o, o + a), 10), 0])), u = new Ye(new Uint32Array([mm[a], 0]));
      s.times(u), s.plus(c), o += a;
    }
    return r ? s.negate() : s;
  }
  /** @nocollapse */
  static convertArray(t) {
    const n = new Uint32Array(t.length * 2);
    for (let r = -1, i = t.length; ++r < i; )
      Ye.from(t[r], new Uint32Array(n.buffer, n.byteOffset + 2 * r * 4, 2));
    return n;
  }
  /** @nocollapse */
  static multiply(t, n) {
    return new Ye(new Uint32Array(t.buffer)).times(n);
  }
  /** @nocollapse */
  static add(t, n) {
    return new Ye(new Uint32Array(t.buffer)).plus(n);
  }
}
class er {
  constructor(t) {
    this.buffer = t;
  }
  high() {
    return new Ye(new Uint32Array(this.buffer.buffer, this.buffer.byteOffset + 8, 2));
  }
  low() {
    return new Ye(new Uint32Array(this.buffer.buffer, this.buffer.byteOffset, 2));
  }
  negate() {
    return this.buffer[0] = ~this.buffer[0] + 1, this.buffer[1] = ~this.buffer[1], this.buffer[2] = ~this.buffer[2], this.buffer[3] = ~this.buffer[3], this.buffer[0] == 0 && ++this.buffer[1], this.buffer[1] == 0 && ++this.buffer[2], this.buffer[2] == 0 && ++this.buffer[3], this;
  }
  times(t) {
    const n = new Vt(new Uint32Array([this.buffer[3], 0])), r = new Vt(new Uint32Array([this.buffer[2], 0])), i = new Vt(new Uint32Array([this.buffer[1], 0])), s = new Vt(new Uint32Array([this.buffer[0], 0])), o = new Vt(new Uint32Array([t.buffer[3], 0])), a = new Vt(new Uint32Array([t.buffer[2], 0])), c = new Vt(new Uint32Array([t.buffer[1], 0])), u = new Vt(new Uint32Array([t.buffer[0], 0]));
    let l = Vt.multiply(s, u);
    this.buffer[0] = l.low();
    const f = new Vt(new Uint32Array([l.high(), 0]));
    return l = Vt.multiply(i, u), f.plus(l), l = Vt.multiply(s, c), f.plus(l), this.buffer[1] = f.low(), this.buffer[3] = f.lessThan(l) ? 1 : 0, this.buffer[2] = f.high(), new Vt(new Uint32Array(this.buffer.buffer, this.buffer.byteOffset + 8, 2)).plus(Vt.multiply(r, u)).plus(Vt.multiply(i, c)).plus(Vt.multiply(s, a)), this.buffer[3] += Vt.multiply(n, u).plus(Vt.multiply(r, c)).plus(Vt.multiply(i, a)).plus(Vt.multiply(s, o)).low(), this;
  }
  plus(t) {
    const n = new Uint32Array(4);
    return n[3] = this.buffer[3] + t.buffer[3] >>> 0, n[2] = this.buffer[2] + t.buffer[2] >>> 0, n[1] = this.buffer[1] + t.buffer[1] >>> 0, n[0] = this.buffer[0] + t.buffer[0] >>> 0, n[0] < this.buffer[0] >>> 0 && ++n[1], n[1] < this.buffer[1] >>> 0 && ++n[2], n[2] < this.buffer[2] >>> 0 && ++n[3], this.buffer[3] = n[3], this.buffer[2] = n[2], this.buffer[1] = n[1], this.buffer[0] = n[0], this;
  }
  hex() {
    return `${yo(this.buffer[3])} ${yo(this.buffer[2])} ${yo(this.buffer[1])} ${yo(this.buffer[0])}`;
  }
  /** @nocollapse */
  static multiply(t, n) {
    return new er(new Uint32Array(t.buffer)).times(n);
  }
  /** @nocollapse */
  static add(t, n) {
    return new er(new Uint32Array(t.buffer)).plus(n);
  }
  /** @nocollapse */
  static from(t, n = new Uint32Array(4)) {
    return er.fromString(typeof t == "string" ? t : t.toString(), n);
  }
  /** @nocollapse */
  static fromNumber(t, n = new Uint32Array(4)) {
    return er.fromString(t.toString(), n);
  }
  /** @nocollapse */
  static fromString(t, n = new Uint32Array(4)) {
    const r = t.startsWith("-"), i = t.length, s = new er(n);
    for (let o = r ? 1 : 0; o < i; ) {
      const a = qo < i - o ? qo : i - o, c = new er(new Uint32Array([Number.parseInt(t.slice(o, o + a), 10), 0, 0, 0])), u = new er(new Uint32Array([mm[a], 0, 0, 0]));
      s.times(u), s.plus(c), o += a;
    }
    return r ? s.negate() : s;
  }
  /** @nocollapse */
  static convertArray(t) {
    const n = new Uint32Array(t.length * 4);
    for (let r = -1, i = t.length; ++r < i; )
      er.from(t[r], new Uint32Array(n.buffer, n.byteOffset + 4 * 4 * r, 4));
    return n;
  }
}
class Ax extends At {
  constructor(t, n, r, i, s = he.V5) {
    super(), this.nodesIndex = -1, this.buffersIndex = -1, this.bytes = t, this.nodes = n, this.buffers = r, this.dictionaries = i, this.metadataVersion = s;
  }
  visit(t) {
    return super.visit(t instanceof Qt ? t.type : t);
  }
  visitNull(t, { length: n } = this.nextFieldNode()) {
    return St({ type: t, length: n });
  }
  visitBool(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return St({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), data: this.readData(t) });
  }
  visitInt(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return St({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), data: this.readData(t) });
  }
  visitFloat(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return St({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), data: this.readData(t) });
  }
  visitUtf8(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return St({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), valueOffsets: this.readOffsets(t), data: this.readData(t) });
  }
  visitLargeUtf8(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return St({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), valueOffsets: this.readOffsets(t), data: this.readData(t) });
  }
  visitBinary(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return St({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), valueOffsets: this.readOffsets(t), data: this.readData(t) });
  }
  visitLargeBinary(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return St({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), valueOffsets: this.readOffsets(t), data: this.readData(t) });
  }
  visitFixedSizeBinary(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return St({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), data: this.readData(t) });
  }
  visitDate(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return St({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), data: this.readData(t) });
  }
  visitTimestamp(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return St({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), data: this.readData(t) });
  }
  visitTime(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return St({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), data: this.readData(t) });
  }
  visitDecimal(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return St({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), data: this.readData(t) });
  }
  visitList(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return St({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), valueOffsets: this.readOffsets(t), child: this.visit(t.children[0]) });
  }
  visitStruct(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return St({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), children: this.visitMany(t.children) });
  }
  visitUnion(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return this.metadataVersion < he.V5 && this.readNullBitmap(t, r), t.mode === Je.Sparse ? this.visitSparseUnion(t, { length: n, nullCount: r }) : this.visitDenseUnion(t, { length: n, nullCount: r });
  }
  visitDenseUnion(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return St({ type: t, length: n, nullCount: r, typeIds: this.readTypeIds(t), valueOffsets: this.readOffsets(t), children: this.visitMany(t.children) });
  }
  visitSparseUnion(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return St({ type: t, length: n, nullCount: r, typeIds: this.readTypeIds(t), children: this.visitMany(t.children) });
  }
  visitDictionary(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return St({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), data: this.readData(t.indices), dictionary: this.readDictionary(t) });
  }
  visitInterval(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return St({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), data: this.readData(t) });
  }
  visitDuration(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return St({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), data: this.readData(t) });
  }
  visitFixedSizeList(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return St({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), child: this.visit(t.children[0]) });
  }
  visitMap(t, { length: n, nullCount: r } = this.nextFieldNode()) {
    return St({ type: t, length: n, nullCount: r, nullBitmap: this.readNullBitmap(t, r), valueOffsets: this.readOffsets(t), child: this.visit(t.children[0]) });
  }
  nextFieldNode() {
    return this.nodes[++this.nodesIndex];
  }
  nextBufferRange() {
    return this.buffers[++this.buffersIndex];
  }
  readNullBitmap(t, n, r = this.nextBufferRange()) {
    return n > 0 && this.readData(t, r) || new Uint8Array(0);
  }
  readOffsets(t, n) {
    return this.readData(t, n);
  }
  readTypeIds(t, n) {
    return this.readData(t, n);
  }
  readData(t, { length: n, offset: r } = this.nextBufferRange()) {
    return this.bytes.subarray(r, r + n);
  }
  readDictionary(t) {
    return this.dictionaries.get(t.id);
  }
}
class LO extends Ax {
  constructor(t, n, r, i, s) {
    super(new Uint8Array(0), n, r, i, s), this.sources = t;
  }
  readNullBitmap(t, n, { offset: r } = this.nextBufferRange()) {
    return n <= 0 ? new Uint8Array(0) : x0(this.sources[r]);
  }
  readOffsets(t, { offset: n } = this.nextBufferRange()) {
    return Yt(Uint8Array, Yt(t.OffsetArrayType, this.sources[n]));
  }
  readTypeIds(t, { offset: n } = this.nextBufferRange()) {
    return Yt(Uint8Array, Yt(t.ArrayType, this.sources[n]));
  }
  readData(t, { offset: n } = this.nextBufferRange()) {
    const { sources: r } = this;
    return Q.isTimestamp(t) || (Q.isInt(t) || Q.isTime(t)) && t.bitWidth === 64 || Q.isDuration(t) || Q.isDate(t) && t.unit === An.MILLISECOND ? Yt(Uint8Array, Ye.convertArray(r[n])) : Q.isDecimal(t) ? Yt(Uint8Array, er.convertArray(r[n])) : Q.isBinary(t) || Q.isLargeBinary(t) || Q.isFixedSizeBinary(t) ? RO(r[n]) : Q.isBool(t) ? x0(r[n]) : Q.isUtf8(t) || Q.isLargeUtf8(t) ? nm(r[n].join("")) : Yt(Uint8Array, Yt(t.ArrayType, r[n].map((i) => +i)));
  }
}
function RO(e) {
  const t = e.join(""), n = new Uint8Array(t.length / 2);
  for (let r = 0; r < t.length; r += 2)
    n[r >> 1] = Number.parseInt(t.slice(r, r + 2), 16);
  return n;
}
class ot extends At {
  compareSchemas(t, n) {
    return t === n || n instanceof t.constructor && this.compareManyFields(t.fields, n.fields);
  }
  compareManyFields(t, n) {
    return t === n || Array.isArray(t) && Array.isArray(n) && t.length === n.length && t.every((r, i) => this.compareFields(r, n[i]));
  }
  compareFields(t, n) {
    return t === n || n instanceof t.constructor && t.name === n.name && t.nullable === n.nullable && this.visit(t.type, n.type);
  }
}
function je(e, t) {
  return t instanceof e.constructor;
}
function Fs(e, t) {
  return e === t || je(e, t);
}
function oi(e, t) {
  return e === t || je(e, t) && e.bitWidth === t.bitWidth && e.isSigned === t.isSigned;
}
function Yh(e, t) {
  return e === t || je(e, t) && e.precision === t.precision;
}
function kO(e, t) {
  return e === t || je(e, t) && e.byteWidth === t.byteWidth;
}
function gm(e, t) {
  return e === t || je(e, t) && e.unit === t.unit;
}
function nu(e, t) {
  return e === t || je(e, t) && e.unit === t.unit && e.timezone === t.timezone;
}
function ru(e, t) {
  return e === t || je(e, t) && e.unit === t.unit && e.bitWidth === t.bitWidth;
}
function FO(e, t) {
  return e === t || je(e, t) && e.children.length === t.children.length && Li.compareManyFields(e.children, t.children);
}
function BO(e, t) {
  return e === t || je(e, t) && e.children.length === t.children.length && Li.compareManyFields(e.children, t.children);
}
function bm(e, t) {
  return e === t || je(e, t) && e.mode === t.mode && e.typeIds.every((n, r) => n === t.typeIds[r]) && Li.compareManyFields(e.children, t.children);
}
function CO(e, t) {
  return e === t || je(e, t) && e.id === t.id && e.isOrdered === t.isOrdered && Li.visit(e.indices, t.indices) && Li.visit(e.dictionary, t.dictionary);
}
function wm(e, t) {
  return e === t || je(e, t) && e.unit === t.unit;
}
function iu(e, t) {
  return e === t || je(e, t) && e.unit === t.unit;
}
function PO(e, t) {
  return e === t || je(e, t) && e.listSize === t.listSize && e.children.length === t.children.length && Li.compareManyFields(e.children, t.children);
}
function UO(e, t) {
  return e === t || je(e, t) && e.keysSorted === t.keysSorted && e.children.length === t.children.length && Li.compareManyFields(e.children, t.children);
}
ot.prototype.visitNull = Fs;
ot.prototype.visitBool = Fs;
ot.prototype.visitInt = oi;
ot.prototype.visitInt8 = oi;
ot.prototype.visitInt16 = oi;
ot.prototype.visitInt32 = oi;
ot.prototype.visitInt64 = oi;
ot.prototype.visitUint8 = oi;
ot.prototype.visitUint16 = oi;
ot.prototype.visitUint32 = oi;
ot.prototype.visitUint64 = oi;
ot.prototype.visitFloat = Yh;
ot.prototype.visitFloat16 = Yh;
ot.prototype.visitFloat32 = Yh;
ot.prototype.visitFloat64 = Yh;
ot.prototype.visitUtf8 = Fs;
ot.prototype.visitLargeUtf8 = Fs;
ot.prototype.visitBinary = Fs;
ot.prototype.visitLargeBinary = Fs;
ot.prototype.visitFixedSizeBinary = kO;
ot.prototype.visitDate = gm;
ot.prototype.visitDateDay = gm;
ot.prototype.visitDateMillisecond = gm;
ot.prototype.visitTimestamp = nu;
ot.prototype.visitTimestampSecond = nu;
ot.prototype.visitTimestampMillisecond = nu;
ot.prototype.visitTimestampMicrosecond = nu;
ot.prototype.visitTimestampNanosecond = nu;
ot.prototype.visitTime = ru;
ot.prototype.visitTimeSecond = ru;
ot.prototype.visitTimeMillisecond = ru;
ot.prototype.visitTimeMicrosecond = ru;
ot.prototype.visitTimeNanosecond = ru;
ot.prototype.visitDecimal = Fs;
ot.prototype.visitList = FO;
ot.prototype.visitStruct = BO;
ot.prototype.visitUnion = bm;
ot.prototype.visitDenseUnion = bm;
ot.prototype.visitSparseUnion = bm;
ot.prototype.visitDictionary = CO;
ot.prototype.visitInterval = wm;
ot.prototype.visitIntervalDayTime = wm;
ot.prototype.visitIntervalYearMonth = wm;
ot.prototype.visitDuration = iu;
ot.prototype.visitDurationSecond = iu;
ot.prototype.visitDurationMillisecond = iu;
ot.prototype.visitDurationMicrosecond = iu;
ot.prototype.visitDurationNanosecond = iu;
ot.prototype.visitFixedSizeList = PO;
ot.prototype.visitMap = UO;
const Li = new ot();
function zO(e, t) {
  return Li.compareSchemas(e, t);
}
function lp(e, t) {
  return qO(e, t.map((n) => n.data.concat()));
}
function qO(e, t) {
  const n = [...e.fields], r = [], i = { numBatches: t.reduce((f, h) => Math.max(f, h.length), 0) };
  let s = 0, o = 0, a = -1;
  const c = t.length;
  let u, l = [];
  for (; i.numBatches-- > 0; ) {
    for (o = Number.POSITIVE_INFINITY, a = -1; ++a < c; )
      l[a] = u = t[a].shift(), o = Math.min(o, u ? u.length : o);
    Number.isFinite(o) && (l = jO(n, o, l, t, i), o > 0 && (r[s++] = St({
      type: new Ce(n),
      length: o,
      nullCount: 0,
      children: l.slice()
    })));
  }
  return [
    e = e.assign(n),
    r.map((f) => new Rn(e, f))
  ];
}
function jO(e, t, n, r, i) {
  var s;
  const o = (t + 63 & -64) >> 3;
  for (let a = -1, c = r.length; ++a < c; ) {
    const u = n[a], l = u == null ? void 0 : u.length;
    if (l >= t)
      l === t ? n[a] = u : (n[a] = u.slice(0, t), i.numBatches = Math.max(i.numBatches, r[a].unshift(u.slice(t, l - t))));
    else {
      const f = e[a];
      e[a] = f.clone({ nullable: !0 }), n[a] = (s = u == null ? void 0 : u._changeLengthAndBackfillNullBitmap(t)) !== null && s !== void 0 ? s : St({
        type: f.type,
        length: t,
        nullCount: t,
        nullBitmap: new Uint8Array(o)
      });
    }
  }
  return n;
}
var $x;
let Ac = class ss {
  constructor(...t) {
    var n, r;
    if (t.length === 0)
      return this.batches = [], this.schema = new Ut([]), this._offsets = [0], this;
    let i, s;
    t[0] instanceof Ut && (i = t.shift()), t.at(-1) instanceof Uint32Array && (s = t.pop());
    const o = (c) => {
      if (c) {
        if (c instanceof Rn)
          return [c];
        if (c instanceof ss)
          return c.batches;
        if (c instanceof jt) {
          if (c.type instanceof Ce)
            return [new Rn(new Ut(c.type.children), c)];
        } else {
          if (Array.isArray(c))
            return c.flatMap((u) => o(u));
          if (typeof c[Symbol.iterator] == "function")
            return [...c].flatMap((u) => o(u));
          if (typeof c == "object") {
            const u = Object.keys(c), l = u.map((d) => new le([c[d]])), f = i ?? new Ut(u.map((d, p) => new Qt(String(d), l[p].type, l[p].nullable))), [, h] = lp(f, l);
            return h.length === 0 ? [new Rn(c)] : h;
          }
        }
      }
      return [];
    }, a = t.flatMap((c) => o(c));
    if (i = (r = i ?? ((n = a[0]) === null || n === void 0 ? void 0 : n.schema)) !== null && r !== void 0 ? r : new Ut([]), !(i instanceof Ut))
      throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");
    for (const c of a) {
      if (!(c instanceof Rn))
        throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");
      if (!zO(i, c.schema))
        throw new TypeError("Table and inner RecordBatch schemas must be equivalent.");
    }
    this.schema = i, this.batches = a, this._offsets = s ?? yx(this.data);
  }
  /**
   * The contiguous {@link RecordBatch `RecordBatch`} chunks of the Table rows.
   */
  get data() {
    return this.batches.map(({ data: t }) => t);
  }
  /**
   * The number of columns in this Table.
   */
  get numCols() {
    return this.schema.fields.length;
  }
  /**
   * The number of rows in this Table.
   */
  get numRows() {
    return this.data.reduce((t, n) => t + n.length, 0);
  }
  /**
   * The number of null rows in this Table.
   */
  get nullCount() {
    return this._nullCount === -1 && (this._nullCount = px(this.data)), this._nullCount;
  }
  /**
   * Check whether an element is null.
   *
   * @param index The index at which to read the validity bitmap.
   */
  // @ts-ignore
  isValid(t) {
    return !1;
  }
  /**
   * Get an element value by position.
   *
   * @param index The index of the element to read.
   */
  // @ts-ignore
  get(t) {
    return null;
  }
  /**
    * Get an element value by position.
    * @param index The index of the element to read. A negative index will count back from the last element.
    */
  // @ts-ignore
  at(t) {
    return this.get(lm(t, this.numRows));
  }
  /**
   * Set an element value by position.
   *
   * @param index The index of the element to write.
   * @param value The value to set.
   */
  // @ts-ignore
  set(t, n) {
  }
  /**
   * Retrieve the index of the first occurrence of a value in an Vector.
   *
   * @param element The value to locate in the Vector.
   * @param offset The index at which to begin the search. If offset is omitted, the search starts at index 0.
   */
  // @ts-ignore
  indexOf(t, n) {
    return -1;
  }
  /**
   * Iterator for rows in this Table.
   */
  [Symbol.iterator]() {
    return this.batches.length > 0 ? pm.visit(new le(this.data)) : new Array(0)[Symbol.iterator]();
  }
  /**
   * Return a JavaScript Array of the Table rows.
   *
   * @returns An Array of Table rows.
   */
  toArray() {
    return [...this];
  }
  /**
   * Returns a string representation of the Table rows.
   *
   * @returns A string representation of the Table rows.
   */
  toString() {
    return `[
  ${this.toArray().join(`,
  `)}
]`;
  }
  /**
   * Combines two or more Tables of the same schema.
   *
   * @param others Additional Tables to add to the end of this Tables.
   */
  concat(...t) {
    const n = this.schema, r = this.data.concat(t.flatMap(({ data: i }) => i));
    return new ss(n, r.map((i) => new Rn(n, i)));
  }
  /**
   * Return a zero-copy sub-section of this Table.
   *
   * @param begin The beginning of the specified portion of the Table.
   * @param end The end of the specified portion of the Table. This is exclusive of the element at the index 'end'.
   */
  slice(t, n) {
    const r = this.schema;
    [t, n] = hx({ length: this.numRows }, t, n);
    const i = mx(this.data, this._offsets, t, n);
    return new ss(r, i.map((s) => new Rn(r, s)));
  }
  /**
   * Returns a child Vector by name, or null if this Vector has no child with the given name.
   *
   * @param name The name of the child to retrieve.
   */
  getChild(t) {
    return this.getChildAt(this.schema.fields.findIndex((n) => n.name === t));
  }
  /**
   * Returns a child Vector by index, or null if this Vector has no child at the supplied index.
   *
   * @param index The index of the child to retrieve.
   */
  getChildAt(t) {
    if (t > -1 && t < this.schema.fields.length) {
      const n = this.data.map((r) => r.children[t]);
      if (n.length === 0) {
        const { type: r } = this.schema.fields[t], i = St({ type: r, length: 0, nullCount: 0 });
        n.push(i._changeLengthAndBackfillNullBitmap(this.numRows));
      }
      return new le(n);
    }
    return null;
  }
  /**
   * Sets a child Vector by name.
   *
   * @param name The name of the child to overwrite.
   * @returns A new Table with the supplied child for the specified name.
   */
  setChild(t, n) {
    var r;
    return this.setChildAt((r = this.schema.fields) === null || r === void 0 ? void 0 : r.findIndex((i) => i.name === t), n);
  }
  setChildAt(t, n) {
    let r = this.schema, i = [...this.batches];
    if (t > -1 && t < this.numCols) {
      n || (n = new le([St({ type: new Oi(), length: this.numRows })]));
      const s = r.fields.slice(), o = s[t].clone({ type: n.type }), a = this.schema.fields.map((c, u) => this.getChildAt(u));
      [s[t], a[t]] = [o, n], [r, i] = lp(r, a);
    }
    return new ss(r, i);
  }
  /**
   * Construct a new Table containing only specified columns.
   *
   * @param columnNames Names of columns to keep.
   * @returns A new Table of columns matching the specified names.
   */
  select(t) {
    const n = this.schema.fields.reduce((r, i, s) => r.set(i.name, s), /* @__PURE__ */ new Map());
    return this.selectAt(t.map((r) => n.get(r)).filter((r) => r > -1));
  }
  /**
   * Construct a new Table containing only columns at the specified indices.
   *
   * @param columnIndices Indices of columns to keep.
   * @returns A new Table of columns at the specified indices.
   */
  selectAt(t) {
    const n = this.schema.selectAt(t), r = this.batches.map((i) => i.selectAt(t));
    return new ss(n, r);
  }
  assign(t) {
    const n = this.schema.fields, [r, i] = t.schema.fields.reduce((a, c, u) => {
      const [l, f] = a, h = n.findIndex((d) => d.name === c.name);
      return ~h ? f[h] = u : l.push(u), a;
    }, [[], []]), s = this.schema.assign(t.schema), o = [
      ...n.map((a, c) => [c, i[c]]).map(([a, c]) => c === void 0 ? this.getChildAt(a) : t.getChildAt(c)),
      ...r.map((a) => t.getChildAt(a))
    ].filter(Boolean);
    return new ss(...lp(s, o));
  }
};
$x = Symbol.toStringTag;
Ac[$x] = ((e) => (e.schema = null, e.batches = [], e._offsets = new Uint32Array([0]), e._nullCount = -1, e[Symbol.isConcatSpreadable] = !0, e.isValid = _f(dm), e.get = _f(Ze.getVisitFn(L.Struct)), e.set = gx($n.getVisitFn(L.Struct)), e.indexOf = bx(vf.getVisitFn(L.Struct)), "Table"))(Ac.prototype);
var Ix;
let Rn = class Ka {
  constructor(...t) {
    switch (t.length) {
      case 2: {
        if ([this.schema] = t, !(this.schema instanceof Ut))
          throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");
        if ([
          ,
          this.data = St({
            nullCount: 0,
            type: new Ce(this.schema.fields),
            children: this.schema.fields.map((n) => St({ type: n.type, nullCount: 0 }))
          })
        ] = t, !(this.data instanceof jt))
          throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");
        [this.schema, this.data] = xb(this.schema, this.data.children);
        break;
      }
      case 1: {
        const [n] = t, { fields: r, children: i, length: s } = Object.keys(n).reduce((c, u, l) => (c.children[l] = n[u], c.length = Math.max(c.length, n[u].length), c.fields[l] = Qt.new({ name: u, type: n[u].type, nullable: !0 }), c), {
          length: 0,
          fields: new Array(),
          children: new Array()
        }), o = new Ut(r), a = St({ type: new Ce(r), length: s, children: i, nullCount: 0 });
        [this.schema, this.data] = xb(o, a.children, s);
        break;
      }
      default:
        throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.");
    }
  }
  get dictionaries() {
    return this._dictionaries || (this._dictionaries = Tx(this.schema.fields, this.data.children));
  }
  /**
   * The number of columns in this RecordBatch.
   */
  get numCols() {
    return this.schema.fields.length;
  }
  /**
   * The number of rows in this RecordBatch.
   */
  get numRows() {
    return this.data.length;
  }
  /**
   * The number of null rows in this RecordBatch.
   */
  get nullCount() {
    return this.data.nullCount;
  }
  /**
   * Check whether an row is null.
   * @param index The index at which to read the validity bitmap.
   */
  isValid(t) {
    return this.data.getValid(t);
  }
  /**
   * Get a row by position.
   * @param index The index of the row to read.
   */
  get(t) {
    return Ze.visit(this.data, t);
  }
  /**
    * Get a row value by position.
    * @param index The index of the row to read. A negative index will count back from the last row.
    */
  at(t) {
    return this.get(lm(t, this.numRows));
  }
  /**
   * Set a row by position.
   * @param index The index of the row to write.
   * @param value The value to set.
   */
  set(t, n) {
    return $n.visit(this.data, t, n);
  }
  /**
   * Retrieve the index of the first occurrence of a row in an RecordBatch.
   * @param element The row to locate in the RecordBatch.
   * @param offset The index at which to begin the search. If offset is omitted, the search starts at index 0.
   */
  indexOf(t, n) {
    return vf.visit(this.data, t, n);
  }
  /**
   * Iterator for rows in this RecordBatch.
   */
  [Symbol.iterator]() {
    return pm.visit(new le([this.data]));
  }
  /**
   * Return a JavaScript Array of the RecordBatch rows.
   * @returns An Array of RecordBatch rows.
   */
  toArray() {
    return [...this];
  }
  /**
   * Combines two or more RecordBatch of the same schema.
   * @param others Additional RecordBatch to add to the end of this RecordBatch.
   */
  concat(...t) {
    return new Ac(this.schema, [this, ...t]);
  }
  /**
   * Return a zero-copy sub-section of this RecordBatch.
   * @param start The beginning of the specified portion of the RecordBatch.
   * @param end The end of the specified portion of the RecordBatch. This is exclusive of the row at the index 'end'.
   */
  slice(t, n) {
    const [r] = new le([this.data]).slice(t, n).data;
    return new Ka(this.schema, r);
  }
  /**
   * Returns a child Vector by name, or null if this Vector has no child with the given name.
   * @param name The name of the child to retrieve.
   */
  getChild(t) {
    var n;
    return this.getChildAt((n = this.schema.fields) === null || n === void 0 ? void 0 : n.findIndex((r) => r.name === t));
  }
  /**
   * Returns a child Vector by index, or null if this Vector has no child at the supplied index.
   * @param index The index of the child to retrieve.
   */
  getChildAt(t) {
    return t > -1 && t < this.schema.fields.length ? new le([this.data.children[t]]) : null;
  }
  /**
   * Sets a child Vector by name.
   * @param name The name of the child to overwrite.
   * @returns A new RecordBatch with the new child for the specified name.
   */
  setChild(t, n) {
    var r;
    return this.setChildAt((r = this.schema.fields) === null || r === void 0 ? void 0 : r.findIndex((i) => i.name === t), n);
  }
  setChildAt(t, n) {
    let r = this.schema, i = this.data;
    if (t > -1 && t < this.numCols) {
      n || (n = new le([St({ type: new Oi(), length: this.numRows })]));
      const s = r.fields.slice(), o = i.children.slice(), a = s[t].clone({ type: n.type });
      [s[t], o[t]] = [a, n.data[0]], r = new Ut(s, new Map(this.schema.metadata)), i = St({ type: new Ce(s), children: o });
    }
    return new Ka(r, i);
  }
  /**
   * Construct a new RecordBatch containing only specified columns.
   *
   * @param columnNames Names of columns to keep.
   * @returns A new RecordBatch of columns matching the specified names.
   */
  select(t) {
    const n = this.schema.select(t), r = new Ce(n.fields), i = [];
    for (const s of t) {
      const o = this.schema.fields.findIndex((a) => a.name === s);
      ~o && (i[o] = this.data.children[o]);
    }
    return new Ka(n, St({ type: r, length: this.numRows, children: i }));
  }
  /**
   * Construct a new RecordBatch containing only columns at the specified indices.
   *
   * @param columnIndices Indices of columns to keep.
   * @returns A new RecordBatch of columns matching at the specified indices.
   */
  selectAt(t) {
    const n = this.schema.selectAt(t), r = t.map((s) => this.data.children[s]).filter(Boolean), i = St({ type: new Ce(n.fields), length: this.numRows, children: r });
    return new Ka(n, i);
  }
};
Ix = Symbol.toStringTag;
Rn[Ix] = ((e) => (e._nullCount = -1, e[Symbol.isConcatSpreadable] = !0, "RecordBatch"))(Rn.prototype);
function xb(e, t, n = t.reduce((r, i) => Math.max(r, i.length), 0)) {
  var r;
  const i = [...e.fields], s = [...t], o = (n + 63 & -64) >> 3;
  for (const [a, c] of e.fields.entries()) {
    const u = t[a];
    (!u || u.length !== n) && (i[a] = c.clone({ nullable: !0 }), s[a] = (r = u == null ? void 0 : u._changeLengthAndBackfillNullBitmap(n)) !== null && r !== void 0 ? r : St({
      type: c.type,
      length: n,
      nullCount: n,
      nullBitmap: new Uint8Array(o)
    }));
  }
  return [
    e.assign(i),
    St({ type: new Ce(i), length: n, children: s })
  ];
}
function Tx(e, t, n = /* @__PURE__ */ new Map()) {
  var r, i;
  if (((r = e == null ? void 0 : e.length) !== null && r !== void 0 ? r : 0) > 0 && (e == null ? void 0 : e.length) === (t == null ? void 0 : t.length))
    for (let s = -1, o = e.length; ++s < o; ) {
      const { type: a } = e[s], c = t[s];
      for (const u of [c, ...((i = c == null ? void 0 : c.dictionary) === null || i === void 0 ? void 0 : i.data) || []])
        Tx(a.children, u == null ? void 0 : u.children, n);
      if (Q.isDictionary(a)) {
        const { id: u } = a;
        if (!n.has(u))
          c != null && c.dictionary && n.set(u, c.dictionary);
        else if (n.get(u) !== c.dictionary)
          throw new Error("Cannot create Schema containing two different dictionaries with the same Id");
      }
    }
  return n;
}
class Ex extends Rn {
  constructor(t) {
    const n = t.fields.map((i) => St({ type: i.type })), r = St({ type: new Ce(t.fields), nullCount: 0, children: n });
    super(t, r);
  }
}
let di = class Qn {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsMessage(t, n) {
    return (n || new Qn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsMessage(t, n) {
    return t.setPosition(t.position() + qt), (n || new Qn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  version() {
    const t = this.bb.__offset(this.bb_pos, 4);
    return t ? this.bb.readInt16(this.bb_pos + t) : he.V1;
  }
  headerType() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? this.bb.readUint8(this.bb_pos + t) : Pt.NONE;
  }
  header(t) {
    const n = this.bb.__offset(this.bb_pos, 8);
    return n ? this.bb.__union(t, this.bb_pos + n) : null;
  }
  bodyLength() {
    const t = this.bb.__offset(this.bb_pos, 10);
    return t ? this.bb.readInt64(this.bb_pos + t) : BigInt("0");
  }
  customMetadata(t, n) {
    const r = this.bb.__offset(this.bb_pos, 12);
    return r ? (n || new de()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + r) + t * 4), this.bb) : null;
  }
  customMetadataLength() {
    const t = this.bb.__offset(this.bb_pos, 12);
    return t ? this.bb.__vector_len(this.bb_pos + t) : 0;
  }
  static startMessage(t) {
    t.startObject(5);
  }
  static addVersion(t, n) {
    t.addFieldInt16(0, n, he.V1);
  }
  static addHeaderType(t, n) {
    t.addFieldInt8(1, n, Pt.NONE);
  }
  static addHeader(t, n) {
    t.addFieldOffset(2, n, 0);
  }
  static addBodyLength(t, n) {
    t.addFieldInt64(3, n, BigInt("0"));
  }
  static addCustomMetadata(t, n) {
    t.addFieldOffset(4, n, 0);
  }
  static createCustomMetadataVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let r = n.length - 1; r >= 0; r--)
      t.addOffset(n[r]);
    return t.endVector();
  }
  static startCustomMetadataVector(t, n) {
    t.startVector(4, n, 4);
  }
  static endMessage(t) {
    return t.endObject();
  }
  static finishMessageBuffer(t, n) {
    t.finish(n);
  }
  static finishSizePrefixedMessageBuffer(t, n) {
    t.finish(n, void 0, !0);
  }
  static createMessage(t, n, r, i, s, o) {
    return Qn.startMessage(t), Qn.addVersion(t, n), Qn.addHeaderType(t, r), Qn.addHeader(t, i), Qn.addBodyLength(t, s), Qn.addCustomMetadata(t, o), Qn.endMessage(t);
  }
};
class VO extends At {
  visit(t, n) {
    return t == null || n == null ? void 0 : super.visit(t, n);
  }
  visitNull(t, n) {
    return hb.startNull(n), hb.endNull(n);
  }
  visitInt(t, n) {
    return rn.startInt(n), rn.addBitWidth(n, t.bitWidth), rn.addIsSigned(n, t.isSigned), rn.endInt(n);
  }
  visitFloat(t, n) {
    return sr.startFloatingPoint(n), sr.addPrecision(n, t.precision), sr.endFloatingPoint(n);
  }
  visitBinary(t, n) {
    return ab.startBinary(n), ab.endBinary(n);
  }
  visitLargeBinary(t, n) {
    return ub.startLargeBinary(n), ub.endLargeBinary(n);
  }
  visitBool(t, n) {
    return cb.startBool(n), cb.endBool(n);
  }
  visitUtf8(t, n) {
    return db.startUtf8(n), db.endUtf8(n);
  }
  visitLargeUtf8(t, n) {
    return lb.startLargeUtf8(n), lb.endLargeUtf8(n);
  }
  visitDecimal(t, n) {
    return so.startDecimal(n), so.addScale(n, t.scale), so.addPrecision(n, t.precision), so.addBitWidth(n, t.bitWidth), so.endDecimal(n);
  }
  visitDate(t, n) {
    return El.startDate(n), El.addUnit(n, t.unit), El.endDate(n);
  }
  visitTime(t, n) {
    return bn.startTime(n), bn.addUnit(n, t.unit), bn.addBitWidth(n, t.bitWidth), bn.endTime(n);
  }
  visitTimestamp(t, n) {
    const r = t.timezone && n.createString(t.timezone) || void 0;
    return wn.startTimestamp(n), wn.addUnit(n, t.unit), r !== void 0 && wn.addTimezone(n, r), wn.endTimestamp(n);
  }
  visitInterval(t, n) {
    return or.startInterval(n), or.addUnit(n, t.unit), or.endInterval(n);
  }
  visitDuration(t, n) {
    return Nl.startDuration(n), Nl.addUnit(n, t.unit), Nl.endDuration(n);
  }
  visitList(t, n) {
    return fb.startList(n), fb.endList(n);
  }
  visitStruct(t, n) {
    return us.startStruct_(n), us.endStruct_(n);
  }
  visitUnion(t, n) {
    Xe.startTypeIdsVector(n, t.typeIds.length);
    const r = Xe.createTypeIdsVector(n, t.typeIds);
    return Xe.startUnion(n), Xe.addMode(n, t.mode), Xe.addTypeIds(n, r), Xe.endUnion(n);
  }
  visitDictionary(t, n) {
    const r = this.visit(t.indices, n);
    return jr.startDictionaryEncoding(n), jr.addId(n, BigInt(t.id)), jr.addIsOrdered(n, t.isOrdered), r !== void 0 && jr.addIndexType(n, r), jr.endDictionaryEncoding(n);
  }
  visitFixedSizeBinary(t, n) {
    return Dl.startFixedSizeBinary(n), Dl.addByteWidth(n, t.byteWidth), Dl.endFixedSizeBinary(n);
  }
  visitFixedSizeList(t, n) {
    return Ol.startFixedSizeList(n), Ol.addListSize(n, t.listSize), Ol.endFixedSizeList(n);
  }
  visitMap(t, n) {
    return Ll.startMap(n), Ll.addKeysSorted(n, t.keysSorted), Ll.endMap(n);
  }
}
const fp = new VO();
function YO(e, t = /* @__PURE__ */ new Map()) {
  return new Ut(XO(e, t), kl(e.metadata), t);
}
function Nx(e) {
  return new Un(e.count, Dx(e.columns), Ox(e.columns));
}
function WO(e) {
  return new ni(Nx(e.data), e.id, e.isDelta);
}
function XO(e, t) {
  return (e.fields || []).filter(Boolean).map((n) => Qt.fromJSON(n, t));
}
function Sb(e, t) {
  return (e.children || []).filter(Boolean).map((n) => Qt.fromJSON(n, t));
}
function Dx(e) {
  return (e || []).reduce((t, n) => [
    ...t,
    new ha(n.count, GO(n.VALIDITY)),
    ...Dx(n.children)
  ], []);
}
function Ox(e, t = []) {
  for (let n = -1, r = (e || []).length; ++n < r; ) {
    const i = e[n];
    i.VALIDITY && t.push(new Yr(t.length, i.VALIDITY.length)), i.TYPE_ID && t.push(new Yr(t.length, i.TYPE_ID.length)), i.OFFSET && t.push(new Yr(t.length, i.OFFSET.length)), i.DATA && t.push(new Yr(t.length, i.DATA.length)), t = Ox(i.children, t);
  }
  return t;
}
function GO(e) {
  return (e || []).reduce((t, n) => t + +(n === 0), 0);
}
function HO(e, t) {
  let n, r, i, s, o, a;
  return !t || !(s = e.dictionary) ? (o = Ab(e, Sb(e, t)), i = new Qt(e.name, o, e.nullable, kl(e.metadata))) : t.has(n = s.id) ? (r = (r = s.indexType) ? Mb(r) : new Mc(), a = new Po(t.get(n), r, n, s.isOrdered), i = new Qt(e.name, a, e.nullable, kl(e.metadata))) : (r = (r = s.indexType) ? Mb(r) : new Mc(), t.set(n, o = Ab(e, Sb(e, t))), a = new Po(o, r, n, s.isOrdered), i = new Qt(e.name, a, e.nullable, kl(e.metadata))), i || null;
}
function kl(e = []) {
  return new Map(e.map(({ key: t, value: n }) => [t, n]));
}
function Mb(e) {
  return new As(e.isSigned, e.bitWidth);
}
function Ab(e, t) {
  const n = e.type.name;
  switch (n) {
    case "NONE":
      return new Oi();
    case "null":
      return new Oi();
    case "binary":
      return new rf();
    case "largebinary":
      return new sf();
    case "utf8":
      return new of();
    case "largeutf8":
      return new af();
    case "bool":
      return new cf();
    case "list":
      return new yf((t || [])[0]);
    case "struct":
      return new Ce(t || []);
    case "struct_":
      return new Ce(t || []);
  }
  switch (n) {
    case "int": {
      const r = e.type;
      return new As(r.isSigned, r.bitWidth);
    }
    case "floatingpoint": {
      const r = e.type;
      return new nf(Oe[r.precision]);
    }
    case "decimal": {
      const r = e.type;
      return new uf(r.scale, r.precision, r.bitWidth);
    }
    case "date": {
      const r = e.type;
      return new lf(An[r.unit]);
    }
    case "time": {
      const r = e.type;
      return new ff(ct[r.unit], r.bitWidth);
    }
    case "timestamp": {
      const r = e.type;
      return new hf(ct[r.unit], r.timezone);
    }
    case "interval": {
      const r = e.type;
      return new df(gr[r.unit]);
    }
    case "duration": {
      const r = e.type;
      return new pf(ct[r.unit]);
    }
    case "union": {
      const r = e.type, [i, ...s] = (r.mode + "").toLowerCase(), o = i.toUpperCase() + s.join("");
      return new mf(Je[o], r.typeIds || [], t || []);
    }
    case "fixedsizebinary": {
      const r = e.type;
      return new gf(r.byteWidth);
    }
    case "fixedsizelist": {
      const r = e.type;
      return new bf(r.listSize, (t || [])[0]);
    }
    case "map": {
      const r = e.type;
      return new wf((t || [])[0], r.keysSorted);
    }
  }
  throw new Error(`Unrecognized type: "${n}"`);
}
var JO = W_, ZO = Bo;
class kn {
  /** @nocollapse */
  static fromJSON(t, n) {
    const r = new kn(0, he.V5, n);
    return r._createHeader = KO(t, n), r;
  }
  /** @nocollapse */
  static decode(t) {
    t = new ZO(Dt(t));
    const n = di.getRootAsMessage(t), r = n.bodyLength(), i = n.version(), s = n.headerType(), o = new kn(r, i, s);
    return o._createHeader = QO(n, s), o;
  }
  /** @nocollapse */
  static encode(t) {
    const n = new JO();
    let r = -1;
    return t.isSchema() ? r = Ut.encode(n, t.header()) : t.isRecordBatch() ? r = Un.encode(n, t.header()) : t.isDictionaryBatch() && (r = ni.encode(n, t.header())), di.startMessage(n), di.addVersion(n, he.V5), di.addHeader(n, r), di.addHeaderType(n, t.headerType), di.addBodyLength(n, BigInt(t.bodyLength)), di.finishMessageBuffer(n, di.endMessage(n)), n.asUint8Array();
  }
  /** @nocollapse */
  static from(t, n = 0) {
    if (t instanceof Ut)
      return new kn(0, he.V5, Pt.Schema, t);
    if (t instanceof Un)
      return new kn(n, he.V5, Pt.RecordBatch, t);
    if (t instanceof ni)
      return new kn(n, he.V5, Pt.DictionaryBatch, t);
    throw new Error(`Unrecognized Message header: ${t}`);
  }
  get type() {
    return this.headerType;
  }
  get version() {
    return this._version;
  }
  get headerType() {
    return this._headerType;
  }
  get bodyLength() {
    return this._bodyLength;
  }
  header() {
    return this._createHeader();
  }
  isSchema() {
    return this.headerType === Pt.Schema;
  }
  isRecordBatch() {
    return this.headerType === Pt.RecordBatch;
  }
  isDictionaryBatch() {
    return this.headerType === Pt.DictionaryBatch;
  }
  constructor(t, n, r, i) {
    this._version = n, this._headerType = r, this.body = new Uint8Array(0), i && (this._createHeader = () => i), this._bodyLength = Kt(t);
  }
}
class Un {
  get nodes() {
    return this._nodes;
  }
  get length() {
    return this._length;
  }
  get buffers() {
    return this._buffers;
  }
  constructor(t, n, r) {
    this._nodes = n, this._buffers = r, this._length = Kt(t);
  }
}
class ni {
  get id() {
    return this._id;
  }
  get data() {
    return this._data;
  }
  get isDelta() {
    return this._isDelta;
  }
  get length() {
    return this.data.length;
  }
  get nodes() {
    return this.data.nodes;
  }
  get buffers() {
    return this.data.buffers;
  }
  constructor(t, n, r = !1) {
    this._data = t, this._isDelta = r, this._id = Kt(n);
  }
}
class Yr {
  constructor(t, n) {
    this.offset = Kt(t), this.length = Kt(n);
  }
}
class ha {
  constructor(t, n) {
    this.length = Kt(t), this.nullCount = Kt(n);
  }
}
function KO(e, t) {
  return () => {
    switch (t) {
      case Pt.Schema:
        return Ut.fromJSON(e);
      case Pt.RecordBatch:
        return Un.fromJSON(e);
      case Pt.DictionaryBatch:
        return ni.fromJSON(e);
    }
    throw new Error(`Unrecognized Message type: { name: ${Pt[t]}, type: ${t} }`);
  };
}
function QO(e, t) {
  return () => {
    switch (t) {
      case Pt.Schema:
        return Ut.decode(e.header(new tr()), /* @__PURE__ */ new Map(), e.version());
      case Pt.RecordBatch:
        return Un.decode(e.header(new Cr()), e.version());
      case Pt.DictionaryBatch:
        return ni.decode(e.header(new ro()), e.version());
    }
    throw new Error(`Unrecognized Message type: { name: ${Pt[t]}, type: ${t} }`);
  };
}
Qt.encode = l9;
Qt.decode = c9;
Qt.fromJSON = HO;
Ut.encode = u9;
Ut.decode = t9;
Ut.fromJSON = YO;
Un.encode = f9;
Un.decode = e9;
Un.fromJSON = Nx;
ni.encode = h9;
ni.decode = n9;
ni.fromJSON = WO;
ha.encode = d9;
ha.decode = i9;
Yr.encode = p9;
Yr.decode = r9;
function t9(e, t = /* @__PURE__ */ new Map(), n = he.V5) {
  const r = a9(e, t);
  return new Ut(r, Fl(e), t, n);
}
function e9(e, t = he.V5) {
  if (e.compression() !== null)
    throw new Error("Record batch compression not implemented");
  return new Un(e.length(), s9(e), o9(e, t));
}
function n9(e, t = he.V5) {
  return new ni(Un.decode(e.data(), t), e.id(), e.isDelta());
}
function r9(e) {
  return new Yr(e.offset(), e.length());
}
function i9(e) {
  return new ha(e.length(), e.nullCount());
}
function s9(e) {
  const t = [];
  for (let n, r = -1, i = -1, s = e.nodesLength(); ++r < s; )
    (n = e.nodes(r)) && (t[++i] = ha.decode(n));
  return t;
}
function o9(e, t) {
  const n = [];
  for (let r, i = -1, s = -1, o = e.buffersLength(); ++i < o; )
    (r = e.buffers(i)) && (t < he.V4 && (r.bb_pos += 8 * (i + 1)), n[++s] = Yr.decode(r));
  return n;
}
function a9(e, t) {
  const n = [];
  for (let r, i = -1, s = -1, o = e.fieldsLength(); ++i < o; )
    (r = e.fields(i)) && (n[++s] = Qt.decode(r, t));
  return n;
}
function $b(e, t) {
  const n = [];
  for (let r, i = -1, s = -1, o = e.childrenLength(); ++i < o; )
    (r = e.children(i)) && (n[++s] = Qt.decode(r, t));
  return n;
}
function c9(e, t) {
  let n, r, i, s, o, a;
  return !t || !(a = e.dictionary()) ? (i = Tb(e, $b(e, t)), r = new Qt(e.name(), i, e.nullable(), Fl(e))) : t.has(n = Kt(a.id())) ? (s = (s = a.indexType()) ? Ib(s) : new Mc(), o = new Po(t.get(n), s, n, a.isOrdered()), r = new Qt(e.name(), o, e.nullable(), Fl(e))) : (s = (s = a.indexType()) ? Ib(s) : new Mc(), t.set(n, i = Tb(e, $b(e, t))), o = new Po(i, s, n, a.isOrdered()), r = new Qt(e.name(), o, e.nullable(), Fl(e))), r || null;
}
function Fl(e) {
  const t = /* @__PURE__ */ new Map();
  if (e)
    for (let n, r, i = -1, s = Math.trunc(e.customMetadataLength()); ++i < s; )
      (n = e.customMetadata(i)) && (r = n.key()) != null && t.set(r, n.value());
  return t;
}
function Ib(e) {
  return new As(e.isSigned(), e.bitWidth());
}
function Tb(e, t) {
  const n = e.typeType();
  switch (n) {
    case Jt.NONE:
      return new Oi();
    case Jt.Null:
      return new Oi();
    case Jt.Binary:
      return new rf();
    case Jt.LargeBinary:
      return new sf();
    case Jt.Utf8:
      return new of();
    case Jt.LargeUtf8:
      return new af();
    case Jt.Bool:
      return new cf();
    case Jt.List:
      return new yf((t || [])[0]);
    case Jt.Struct_:
      return new Ce(t || []);
  }
  switch (n) {
    case Jt.Int: {
      const r = e.type(new rn());
      return new As(r.isSigned(), r.bitWidth());
    }
    case Jt.FloatingPoint: {
      const r = e.type(new sr());
      return new nf(r.precision());
    }
    case Jt.Decimal: {
      const r = e.type(new so());
      return new uf(r.scale(), r.precision(), r.bitWidth());
    }
    case Jt.Date: {
      const r = e.type(new El());
      return new lf(r.unit());
    }
    case Jt.Time: {
      const r = e.type(new bn());
      return new ff(r.unit(), r.bitWidth());
    }
    case Jt.Timestamp: {
      const r = e.type(new wn());
      return new hf(r.unit(), r.timezone());
    }
    case Jt.Interval: {
      const r = e.type(new or());
      return new df(r.unit());
    }
    case Jt.Duration: {
      const r = e.type(new Nl());
      return new pf(r.unit());
    }
    case Jt.Union: {
      const r = e.type(new Xe());
      return new mf(r.mode(), r.typeIdsArray() || [], t || []);
    }
    case Jt.FixedSizeBinary: {
      const r = e.type(new Dl());
      return new gf(r.byteWidth());
    }
    case Jt.FixedSizeList: {
      const r = e.type(new Ol());
      return new bf(r.listSize(), (t || [])[0]);
    }
    case Jt.Map: {
      const r = e.type(new Ll());
      return new wf((t || [])[0], r.keysSorted());
    }
  }
  throw new Error(`Unrecognized type: "${Jt[n]}" (${n})`);
}
function u9(e, t) {
  const n = t.fields.map((s) => Qt.encode(e, s));
  tr.startFieldsVector(e, n.length);
  const r = tr.createFieldsVector(e, n), i = t.metadata && t.metadata.size > 0 ? tr.createCustomMetadataVector(e, [...t.metadata].map(([s, o]) => {
    const a = e.createString(`${s}`), c = e.createString(`${o}`);
    return de.startKeyValue(e), de.addKey(e, a), de.addValue(e, c), de.endKeyValue(e);
  })) : -1;
  return tr.startSchema(e), tr.addFields(e, r), tr.addEndianness(e, y9 ? Co.Little : Co.Big), i !== -1 && tr.addCustomMetadata(e, i), tr.endSchema(e);
}
function l9(e, t) {
  let n = -1, r = -1, i = -1;
  const s = t.type;
  let o = t.typeId;
  Q.isDictionary(s) ? (o = s.dictionary.typeId, i = fp.visit(s, e), r = fp.visit(s.dictionary, e)) : r = fp.visit(s, e);
  const a = (s.children || []).map((l) => Qt.encode(e, l)), c = yn.createChildrenVector(e, a), u = t.metadata && t.metadata.size > 0 ? yn.createCustomMetadataVector(e, [...t.metadata].map(([l, f]) => {
    const h = e.createString(`${l}`), d = e.createString(`${f}`);
    return de.startKeyValue(e), de.addKey(e, h), de.addValue(e, d), de.endKeyValue(e);
  })) : -1;
  return t.name && (n = e.createString(t.name)), yn.startField(e), yn.addType(e, r), yn.addTypeType(e, o), yn.addChildren(e, c), yn.addNullable(e, !!t.nullable), n !== -1 && yn.addName(e, n), i !== -1 && yn.addDictionary(e, i), u !== -1 && yn.addCustomMetadata(e, u), yn.endField(e);
}
function f9(e, t) {
  const n = t.nodes || [], r = t.buffers || [];
  Cr.startNodesVector(e, n.length);
  for (const o of n.slice().reverse())
    ha.encode(e, o);
  const i = e.endVector();
  Cr.startBuffersVector(e, r.length);
  for (const o of r.slice().reverse())
    Yr.encode(e, o);
  const s = e.endVector();
  return Cr.startRecordBatch(e), Cr.addLength(e, BigInt(t.length)), Cr.addNodes(e, i), Cr.addBuffers(e, s), Cr.endRecordBatch(e);
}
function h9(e, t) {
  const n = Un.encode(e, t.data);
  return ro.startDictionaryBatch(e), ro.addId(e, BigInt(t.id)), ro.addIsDelta(e, t.isDelta), ro.addData(e, n), ro.endDictionaryBatch(e);
}
function d9(e, t) {
  return H_.createFieldNode(e, BigInt(t.length), BigInt(t.nullCount));
}
function p9(e, t) {
  return G_.createBuffer(e, BigInt(t.offset), BigInt(t.length));
}
const y9 = (() => {
  const e = new ArrayBuffer(2);
  return new DataView(e).setInt16(
    0,
    256,
    !0
    /* littleEndian */
  ), new Int16Array(e)[0] === 256;
})(), _m = (e) => `Expected ${Pt[e]} Message in stream, but was null or length 0.`, vm = (e) => `Header pointer of flatbuffer-encoded ${Pt[e]} Message is null or length 0.`, Lx = (e, t) => `Expected to read ${e} metadata bytes, but only read ${t}.`, Rx = (e, t) => `Expected to read ${e} bytes for message body, but only read ${t}.`;
class kx {
  constructor(t) {
    this.source = t instanceof Sf ? t : new Sf(t);
  }
  [Symbol.iterator]() {
    return this;
  }
  next() {
    let t;
    return (t = this.readMetadataLength()).done || t.value === -1 && (t = this.readMetadataLength()).done || (t = this.readMetadata(t.value)).done ? re : t;
  }
  throw(t) {
    return this.source.throw(t);
  }
  return(t) {
    return this.source.return(t);
  }
  readMessage(t) {
    let n;
    if ((n = this.next()).done)
      return null;
    if (t != null && n.value.headerType !== t)
      throw new Error(_m(t));
    return n.value;
  }
  readMessageBody(t) {
    if (t <= 0)
      return new Uint8Array(0);
    const n = Dt(this.source.read(t));
    if (n.byteLength < t)
      throw new Error(Rx(t, n.byteLength));
    return (
      /* 1. */
      n.byteOffset % 8 === 0 && /* 2. */
      n.byteOffset + n.byteLength <= n.buffer.byteLength ? n : n.slice()
    );
  }
  readSchema(t = !1) {
    const n = Pt.Schema, r = this.readMessage(n), i = r == null ? void 0 : r.header();
    if (t && !i)
      throw new Error(vm(n));
    return i;
  }
  readMetadataLength() {
    const t = this.source.read(Wh), n = t && new Bo(t), r = (n == null ? void 0 : n.readInt32(0)) || 0;
    return { done: r === 0, value: r };
  }
  readMetadata(t) {
    const n = this.source.read(t);
    if (!n)
      return re;
    if (n.byteLength < t)
      throw new Error(Lx(t, n.byteLength));
    return { done: !1, value: kn.decode(n) };
  }
}
class m9 {
  constructor(t, n) {
    this.source = t instanceof zo ? t : U_(t) ? new Mf(t, n) : new zo(t);
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  next() {
    return bt(this, void 0, void 0, function* () {
      let t;
      return (t = yield this.readMetadataLength()).done || t.value === -1 && (t = yield this.readMetadataLength()).done || (t = yield this.readMetadata(t.value)).done ? re : t;
    });
  }
  throw(t) {
    return bt(this, void 0, void 0, function* () {
      return yield this.source.throw(t);
    });
  }
  return(t) {
    return bt(this, void 0, void 0, function* () {
      return yield this.source.return(t);
    });
  }
  readMessage(t) {
    return bt(this, void 0, void 0, function* () {
      let n;
      if ((n = yield this.next()).done)
        return null;
      if (t != null && n.value.headerType !== t)
        throw new Error(_m(t));
      return n.value;
    });
  }
  readMessageBody(t) {
    return bt(this, void 0, void 0, function* () {
      if (t <= 0)
        return new Uint8Array(0);
      const n = Dt(yield this.source.read(t));
      if (n.byteLength < t)
        throw new Error(Rx(t, n.byteLength));
      return (
        /* 1. */
        n.byteOffset % 8 === 0 && /* 2. */
        n.byteOffset + n.byteLength <= n.buffer.byteLength ? n : n.slice()
      );
    });
  }
  readSchema() {
    return bt(this, arguments, void 0, function* (t = !1) {
      const n = Pt.Schema, r = yield this.readMessage(n), i = r == null ? void 0 : r.header();
      if (t && !i)
        throw new Error(vm(n));
      return i;
    });
  }
  readMetadataLength() {
    return bt(this, void 0, void 0, function* () {
      const t = yield this.source.read(Wh), n = t && new Bo(t), r = (n == null ? void 0 : n.readInt32(0)) || 0;
      return { done: r === 0, value: r };
    });
  }
  readMetadata(t) {
    return bt(this, void 0, void 0, function* () {
      const n = yield this.source.read(t);
      if (!n)
        return re;
      if (n.byteLength < t)
        throw new Error(Lx(t, n.byteLength));
      return { done: !1, value: kn.decode(n) };
    });
  }
}
class g9 extends kx {
  constructor(t) {
    super(new Uint8Array(0)), this._schema = !1, this._body = [], this._batchIndex = 0, this._dictionaryIndex = 0, this._json = t instanceof _b ? t : new _b(t);
  }
  next() {
    const { _json: t } = this;
    if (!this._schema)
      return this._schema = !0, { done: !1, value: kn.fromJSON(t.schema, Pt.Schema) };
    if (this._dictionaryIndex < t.dictionaries.length) {
      const n = t.dictionaries[this._dictionaryIndex++];
      return this._body = n.data.columns, { done: !1, value: kn.fromJSON(n, Pt.DictionaryBatch) };
    }
    if (this._batchIndex < t.batches.length) {
      const n = t.batches[this._batchIndex++];
      return this._body = n.columns, { done: !1, value: kn.fromJSON(n, Pt.RecordBatch) };
    }
    return this._body = [], re;
  }
  readMessageBody(t) {
    return n(this._body);
    function n(r) {
      return (r || []).reduce((i, s) => [
        ...i,
        ...s.VALIDITY && [s.VALIDITY] || [],
        ...s.TYPE_ID && [s.TYPE_ID] || [],
        ...s.OFFSET && [s.OFFSET] || [],
        ...s.DATA && [s.DATA] || [],
        ...n(s.children)
      ], []);
    }
  }
  readMessage(t) {
    let n;
    if ((n = this.next()).done)
      return null;
    if (t != null && n.value.headerType !== t)
      throw new Error(_m(t));
    return n.value;
  }
  readSchema() {
    const t = Pt.Schema, n = this.readMessage(t), r = n == null ? void 0 : n.header();
    if (!n || !r)
      throw new Error(vm(t));
    return r;
  }
}
const Wh = 4, $0 = "ARROW1", Af = new Uint8Array($0.length);
for (let e = 0; e < $0.length; e += 1)
  Af[e] = $0.codePointAt(e);
function xm(e, t = 0) {
  for (let n = -1, r = Af.length; ++n < r; )
    if (Af[n] !== e[t + n])
      return !1;
  return !0;
}
const su = Af.length, Fx = su + Wh, b9 = su * 2 + Wh;
class Zr extends Sx {
  constructor(t) {
    super(), this._impl = t;
  }
  get closed() {
    return this._impl.closed;
  }
  get schema() {
    return this._impl.schema;
  }
  get autoDestroy() {
    return this._impl.autoDestroy;
  }
  get dictionaries() {
    return this._impl.dictionaries;
  }
  get numDictionaries() {
    return this._impl.numDictionaries;
  }
  get numRecordBatches() {
    return this._impl.numRecordBatches;
  }
  get footer() {
    return this._impl.isFile() ? this._impl.footer : null;
  }
  isSync() {
    return this._impl.isSync();
  }
  isAsync() {
    return this._impl.isAsync();
  }
  isFile() {
    return this._impl.isFile();
  }
  isStream() {
    return this._impl.isStream();
  }
  next() {
    return this._impl.next();
  }
  throw(t) {
    return this._impl.throw(t);
  }
  return(t) {
    return this._impl.return(t);
  }
  cancel() {
    return this._impl.cancel();
  }
  reset(t) {
    return this._impl.reset(t), this._DOMStream = void 0, this._nodeStream = void 0, this;
  }
  open(t) {
    const n = this._impl.open(t);
    return _c(n) ? n.then(() => this) : this;
  }
  readRecordBatch(t) {
    return this._impl.isFile() ? this._impl.readRecordBatch(t) : null;
  }
  [Symbol.iterator]() {
    return this._impl[Symbol.iterator]();
  }
  [Symbol.asyncIterator]() {
    return this._impl[Symbol.asyncIterator]();
  }
  toDOMStream() {
    return mn.toDOMStream(this.isSync() ? { [Symbol.iterator]: () => this } : { [Symbol.asyncIterator]: () => this });
  }
  toNodeStream() {
    return mn.toNodeStream(this.isSync() ? { [Symbol.iterator]: () => this } : { [Symbol.asyncIterator]: () => this }, { objectMode: !0 });
  }
  /** @nocollapse */
  // @ts-ignore
  static throughNode(t) {
    throw new Error('"throughNode" not available in this environment');
  }
  /** @nocollapse */
  static throughDOM(t, n) {
    throw new Error('"throughDOM" not available in this environment');
  }
  /** @nocollapse */
  static from(t) {
    return t instanceof Zr ? t : m0(t) ? x9(t) : U_(t) ? A9(t) : _c(t) ? bt(this, void 0, void 0, function* () {
      return yield Zr.from(yield t);
    }) : z_(t) || im(t) || j_(t) || rm(t) ? M9(new zo(t)) : S9(new Sf(t));
  }
  /** @nocollapse */
  static readAll(t) {
    return t instanceof Zr ? t.isSync() ? Eb(t) : Nb(t) : m0(t) || ArrayBuffer.isView(t) || jh(t) || P_(t) ? Eb(t) : Nb(t);
  }
}
class $f extends Zr {
  constructor(t) {
    super(t), this._impl = t;
  }
  readAll() {
    return [...this];
  }
  [Symbol.iterator]() {
    return this._impl[Symbol.iterator]();
  }
  [Symbol.asyncIterator]() {
    return ur(this, arguments, function* () {
      yield vt(yield* Tl(So(this[Symbol.iterator]())));
    });
  }
}
class If extends Zr {
  constructor(t) {
    super(t), this._impl = t;
  }
  readAll() {
    return bt(this, void 0, void 0, function* () {
      var t, n, r, i;
      const s = new Array();
      try {
        for (var o = !0, a = So(this), c; c = yield a.next(), t = c.done, !t; o = !0) {
          i = c.value, o = !1;
          const u = i;
          s.push(u);
        }
      } catch (u) {
        n = { error: u };
      } finally {
        try {
          !o && !t && (r = a.return) && (yield r.call(a));
        } finally {
          if (n) throw n.error;
        }
      }
      return s;
    });
  }
  [Symbol.iterator]() {
    throw new Error("AsyncRecordBatchStreamReader is not Iterable");
  }
  [Symbol.asyncIterator]() {
    return this._impl[Symbol.asyncIterator]();
  }
}
class Bx extends $f {
  constructor(t) {
    super(t), this._impl = t;
  }
}
class w9 extends If {
  constructor(t) {
    super(t), this._impl = t;
  }
}
class Cx {
  get numDictionaries() {
    return this._dictionaryIndex;
  }
  get numRecordBatches() {
    return this._recordBatchIndex;
  }
  constructor(t = /* @__PURE__ */ new Map()) {
    this.closed = !1, this.autoDestroy = !0, this._dictionaryIndex = 0, this._recordBatchIndex = 0, this.dictionaries = t;
  }
  isSync() {
    return !1;
  }
  isAsync() {
    return !1;
  }
  isFile() {
    return !1;
  }
  isStream() {
    return !1;
  }
  reset(t) {
    return this._dictionaryIndex = 0, this._recordBatchIndex = 0, this.schema = t, this.dictionaries = /* @__PURE__ */ new Map(), this;
  }
  _loadRecordBatch(t, n) {
    const r = this._loadVectors(t, n, this.schema.fields), i = St({ type: new Ce(this.schema.fields), length: t.length, children: r });
    return new Rn(this.schema, i);
  }
  _loadDictionaryBatch(t, n) {
    const { id: r, isDelta: i } = t, { dictionaries: s, schema: o } = this, a = s.get(r);
    if (i || !a) {
      const c = o.dictionaries.get(r), u = this._loadVectors(t.data, n, [c]);
      return (a && i ? a.concat(new le(u)) : new le(u)).memoize();
    }
    return a.memoize();
  }
  _loadVectors(t, n, r) {
    return new Ax(n, t.nodes, t.buffers, this.dictionaries, this.schema.metadataVersion).visitMany(r);
  }
}
class Tf extends Cx {
  constructor(t, n) {
    super(n), this._reader = m0(t) ? new g9(this._handle = t) : new kx(this._handle = t);
  }
  isSync() {
    return !0;
  }
  isStream() {
    return !0;
  }
  [Symbol.iterator]() {
    return this;
  }
  cancel() {
    !this.closed && (this.closed = !0) && (this.reset()._reader.return(), this._reader = null, this.dictionaries = null);
  }
  open(t) {
    return this.closed || (this.autoDestroy = Ux(this, t), this.schema || (this.schema = this._reader.readSchema()) || this.cancel()), this;
  }
  throw(t) {
    return !this.closed && this.autoDestroy && (this.closed = !0) ? this.reset()._reader.throw(t) : re;
  }
  return(t) {
    return !this.closed && this.autoDestroy && (this.closed = !0) ? this.reset()._reader.return(t) : re;
  }
  next() {
    if (this.closed)
      return re;
    let t;
    const { _reader: n } = this;
    for (; t = this._readNextMessageAndValidate(); )
      if (t.isSchema())
        this.reset(t.header());
      else if (t.isRecordBatch()) {
        this._recordBatchIndex++;
        const r = t.header(), i = n.readMessageBody(t.bodyLength);
        return { done: !1, value: this._loadRecordBatch(r, i) };
      } else if (t.isDictionaryBatch()) {
        this._dictionaryIndex++;
        const r = t.header(), i = n.readMessageBody(t.bodyLength), s = this._loadDictionaryBatch(r, i);
        this.dictionaries.set(r.id, s);
      }
    return this.schema && this._recordBatchIndex === 0 ? (this._recordBatchIndex++, { done: !1, value: new Ex(this.schema) }) : this.return();
  }
  _readNextMessageAndValidate(t) {
    return this._reader.readMessage(t);
  }
}
class Ef extends Cx {
  constructor(t, n) {
    super(n), this._reader = new m9(this._handle = t);
  }
  isAsync() {
    return !0;
  }
  isStream() {
    return !0;
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  cancel() {
    return bt(this, void 0, void 0, function* () {
      !this.closed && (this.closed = !0) && (yield this.reset()._reader.return(), this._reader = null, this.dictionaries = null);
    });
  }
  open(t) {
    return bt(this, void 0, void 0, function* () {
      return this.closed || (this.autoDestroy = Ux(this, t), this.schema || (this.schema = yield this._reader.readSchema()) || (yield this.cancel())), this;
    });
  }
  throw(t) {
    return bt(this, void 0, void 0, function* () {
      return !this.closed && this.autoDestroy && (this.closed = !0) ? yield this.reset()._reader.throw(t) : re;
    });
  }
  return(t) {
    return bt(this, void 0, void 0, function* () {
      return !this.closed && this.autoDestroy && (this.closed = !0) ? yield this.reset()._reader.return(t) : re;
    });
  }
  next() {
    return bt(this, void 0, void 0, function* () {
      if (this.closed)
        return re;
      let t;
      const { _reader: n } = this;
      for (; t = yield this._readNextMessageAndValidate(); )
        if (t.isSchema())
          yield this.reset(t.header());
        else if (t.isRecordBatch()) {
          this._recordBatchIndex++;
          const r = t.header(), i = yield n.readMessageBody(t.bodyLength);
          return { done: !1, value: this._loadRecordBatch(r, i) };
        } else if (t.isDictionaryBatch()) {
          this._dictionaryIndex++;
          const r = t.header(), i = yield n.readMessageBody(t.bodyLength), s = this._loadDictionaryBatch(r, i);
          this.dictionaries.set(r.id, s);
        }
      return this.schema && this._recordBatchIndex === 0 ? (this._recordBatchIndex++, { done: !1, value: new Ex(this.schema) }) : yield this.return();
    });
  }
  _readNextMessageAndValidate(t) {
    return bt(this, void 0, void 0, function* () {
      return yield this._reader.readMessage(t);
    });
  }
}
class Px extends Tf {
  get footer() {
    return this._footer;
  }
  get numDictionaries() {
    return this._footer ? this._footer.numDictionaries : 0;
  }
  get numRecordBatches() {
    return this._footer ? this._footer.numRecordBatches : 0;
  }
  constructor(t, n) {
    super(t instanceof vb ? t : new vb(t), n);
  }
  isSync() {
    return !0;
  }
  isFile() {
    return !0;
  }
  open(t) {
    if (!this.closed && !this._footer) {
      this.schema = (this._footer = this._readFooter()).schema;
      for (const n of this._footer.dictionaryBatches())
        n && this._readDictionaryBatch(this._dictionaryIndex++);
    }
    return super.open(t);
  }
  readRecordBatch(t) {
    var n;
    if (this.closed)
      return null;
    this._footer || this.open();
    const r = (n = this._footer) === null || n === void 0 ? void 0 : n.getRecordBatch(t);
    if (r && this._handle.seek(r.offset)) {
      const i = this._reader.readMessage(Pt.RecordBatch);
      if (i != null && i.isRecordBatch()) {
        const s = i.header(), o = this._reader.readMessageBody(i.bodyLength);
        return this._loadRecordBatch(s, o);
      }
    }
    return null;
  }
  _readDictionaryBatch(t) {
    var n;
    const r = (n = this._footer) === null || n === void 0 ? void 0 : n.getDictionaryBatch(t);
    if (r && this._handle.seek(r.offset)) {
      const i = this._reader.readMessage(Pt.DictionaryBatch);
      if (i != null && i.isDictionaryBatch()) {
        const s = i.header(), o = this._reader.readMessageBody(i.bodyLength), a = this._loadDictionaryBatch(s, o);
        this.dictionaries.set(s.id, a);
      }
    }
  }
  _readFooter() {
    const { _handle: t } = this, n = t.size - Fx, r = t.readInt32(n), i = t.readAt(n - r, r);
    return ym.decode(i);
  }
  _readNextMessageAndValidate(t) {
    var n;
    if (this._footer || this.open(), this._footer && this._recordBatchIndex < this.numRecordBatches) {
      const r = (n = this._footer) === null || n === void 0 ? void 0 : n.getRecordBatch(this._recordBatchIndex);
      if (r && this._handle.seek(r.offset))
        return this._reader.readMessage(t);
    }
    return null;
  }
}
class _9 extends Ef {
  get footer() {
    return this._footer;
  }
  get numDictionaries() {
    return this._footer ? this._footer.numDictionaries : 0;
  }
  get numRecordBatches() {
    return this._footer ? this._footer.numRecordBatches : 0;
  }
  constructor(t, ...n) {
    const r = typeof n[0] != "number" ? n.shift() : void 0, i = n[0] instanceof Map ? n.shift() : void 0;
    super(t instanceof Mf ? t : new Mf(t, r), i);
  }
  isFile() {
    return !0;
  }
  isAsync() {
    return !0;
  }
  open(t) {
    const n = Object.create(null, {
      open: { get: () => super.open }
    });
    return bt(this, void 0, void 0, function* () {
      if (!this.closed && !this._footer) {
        this.schema = (this._footer = yield this._readFooter()).schema;
        for (const r of this._footer.dictionaryBatches())
          r && (yield this._readDictionaryBatch(this._dictionaryIndex++));
      }
      return yield n.open.call(this, t);
    });
  }
  readRecordBatch(t) {
    return bt(this, void 0, void 0, function* () {
      var n;
      if (this.closed)
        return null;
      this._footer || (yield this.open());
      const r = (n = this._footer) === null || n === void 0 ? void 0 : n.getRecordBatch(t);
      if (r && (yield this._handle.seek(r.offset))) {
        const i = yield this._reader.readMessage(Pt.RecordBatch);
        if (i != null && i.isRecordBatch()) {
          const s = i.header(), o = yield this._reader.readMessageBody(i.bodyLength);
          return this._loadRecordBatch(s, o);
        }
      }
      return null;
    });
  }
  _readDictionaryBatch(t) {
    return bt(this, void 0, void 0, function* () {
      var n;
      const r = (n = this._footer) === null || n === void 0 ? void 0 : n.getDictionaryBatch(t);
      if (r && (yield this._handle.seek(r.offset))) {
        const i = yield this._reader.readMessage(Pt.DictionaryBatch);
        if (i != null && i.isDictionaryBatch()) {
          const s = i.header(), o = yield this._reader.readMessageBody(i.bodyLength), a = this._loadDictionaryBatch(s, o);
          this.dictionaries.set(s.id, a);
        }
      }
    });
  }
  _readFooter() {
    return bt(this, void 0, void 0, function* () {
      const { _handle: t } = this;
      t._pending && (yield t._pending);
      const n = t.size - Fx, r = yield t.readInt32(n), i = yield t.readAt(n - r, r);
      return ym.decode(i);
    });
  }
  _readNextMessageAndValidate(t) {
    return bt(this, void 0, void 0, function* () {
      if (this._footer || (yield this.open()), this._footer && this._recordBatchIndex < this.numRecordBatches) {
        const n = this._footer.getRecordBatch(this._recordBatchIndex);
        if (n && (yield this._handle.seek(n.offset)))
          return yield this._reader.readMessage(t);
      }
      return null;
    });
  }
}
class v9 extends Tf {
  constructor(t, n) {
    super(t, n);
  }
  _loadVectors(t, n, r) {
    return new LO(n, t.nodes, t.buffers, this.dictionaries, this.schema.metadataVersion).visitMany(r);
  }
}
function Ux(e, t) {
  return t && typeof t.autoDestroy == "boolean" ? t.autoDestroy : e.autoDestroy;
}
function* Eb(e) {
  const t = Zr.from(e);
  try {
    if (!t.open({ autoDestroy: !1 }).closed)
      do
        yield t;
      while (!t.reset().open().closed);
  } finally {
    t.cancel();
  }
}
function Nb(e) {
  return ur(this, arguments, function* () {
    const n = yield vt(Zr.from(e));
    try {
      if (!(yield vt(n.open({ autoDestroy: !1 }))).closed)
        do
          yield yield vt(n);
        while (!(yield vt(n.reset().open())).closed);
    } finally {
      yield vt(n.cancel());
    }
  });
}
function x9(e) {
  return new $f(new v9(e));
}
function S9(e) {
  const t = e.peek(su + 7 & -8);
  return t && t.byteLength >= 4 ? xm(t) ? new Bx(new Px(e.read())) : new $f(new Tf(e)) : new $f(new Tf(function* () {
  }()));
}
function M9(e) {
  return bt(this, void 0, void 0, function* () {
    const t = yield e.peek(su + 7 & -8);
    return t && t.byteLength >= 4 ? xm(t) ? new Bx(new Px(yield e.read())) : new If(new Ef(e)) : new If(new Ef(function() {
      return ur(this, arguments, function* () {
      });
    }()));
  });
}
function A9(e) {
  return bt(this, void 0, void 0, function* () {
    const { size: t } = yield e.stat(), n = new Mf(e, t);
    return t >= b9 && xm(yield n.readAt(0, su + 7 & -8)) ? new w9(new _9(n)) : new If(new Ef(n));
  });
}
function Sm(e) {
  const t = Zr.from(e);
  return _c(t) ? t.then((n) => Sm(n)) : t.isAsync() ? t.readAll().then((n) => new Ac(n)) : new Ac(t.readAll());
}
function $9(e = "ws://localhost:3000/") {
  const t = [];
  let n = !1, r = null, i;
  const s = {
    open() {
      n = !0, c();
    },
    close() {
      for (n = !1, r = null, i = null; t.length; )
        t.shift().reject("Socket closed");
    },
    error(u) {
      if (r) {
        const { reject: l } = r;
        r = null, c(), l(u);
      } else
        console.error("WebSocket error: ", u);
    },
    message({ data: u }) {
      if (r) {
        const { query: l, resolve: f, reject: h } = r;
        if (r = null, c(), typeof u == "string") {
          const d = JSON.parse(u);
          d.error ? h(d.error) : f(d);
        } else if (l.type === "exec")
          f();
        else if (l.type === "arrow")
          f(Sm(u.arrayBuffer()));
        else
          throw new Error(`Unexpected socket data: ${u}`);
      } else
        console.log("WebSocket message: ", u);
    }
  };
  function o() {
    i = new WebSocket(e);
    for (const u in s)
      i.addEventListener(u, s[u]);
  }
  function a(u, l, f) {
    i == null && o(), t.push({ query: u, resolve: l, reject: f }), n && !r && c();
  }
  function c() {
    t.length && (r = t.shift(), i.send(JSON.stringify(r.query)));
  }
  return {
    get connected() {
      return n;
    },
    /**
     * Query the DuckDB server.
     * @param {object} query
     * @param {'exec' | 'arrow' | 'json'} [query.type] The query type: 'exec', 'arrow', or 'json'.
     * @param {string} query.sql A SQL query string.
     * @returns the query result
     */
    query(u) {
      return new Promise(
        (l, f) => a(u, l, f)
      );
    }
  };
}
class Ri {
  /**
   * Create a new Ref instance.
   * @param {string|Ref|null} table The table name.
   * @param {string|null} [column] The column name.
   */
  constructor(t, n) {
    t && (this.table = String(t)), n && (this.column = n);
  }
  /**
   * Get the list of referenced columns. Either a single element array
   * if column is non-null, otherwise an empty array.
   */
  get columns() {
    return this.column ? [this.column] : [];
  }
  /**
   * Generate a SQL string for this reference.
   * @returns {string} The SQL string.
   */
  toString() {
    const { table: t, column: n } = this;
    if (n) {
      const r = n.startsWith("*") ? n : `"${n}"`;
      return `${t ? `${Db(t)}.` : ""}${r}`;
    } else
      return t ? Db(t) : "NULL";
  }
}
function Db(e) {
  return e.split(".").map((n) => `"${n}"`).join(".");
}
function I9(e, t) {
  return e instanceof Ri && e.column === t;
}
function Ft(e) {
  return typeof e == "string" ? Xh(e) : e;
}
function Bl(e) {
  return typeof e == "string" ? T9(e) : e;
}
function T9(e) {
  return new Ri(e);
}
function Xh(e, t = null) {
  return arguments.length === 1 && (t = e, e = null), new Ri(e, t);
}
function ou(e) {
  switch (typeof e) {
    case "boolean":
      return e ? "TRUE" : "FALSE";
    case "string":
      return `'${e.replace("'", "''")}'`;
    case "number":
      return Number.isFinite(e) ? String(e) : "NULL";
    default:
      if (e == null)
        return "NULL";
      if (e instanceof Date) {
        const t = +e;
        if (Number.isNaN(t)) return "NULL";
        const n = e.getUTCFullYear(), r = e.getUTCMonth(), i = e.getUTCDate();
        return t === Date.UTC(n, r, i) ? `MAKE_DATE(${n}, ${r + 1}, ${i})` : `EPOCH_MS(${t})`;
      } else return e instanceof RegExp ? `'${e.source}'` : String(e);
  }
}
const jo = (e) => typeof (e == null ? void 0 : e.addEventListener) == "function";
function zx(e) {
  return e instanceof Gh;
}
class Gh {
  /**
   * Create a new SQL expression instance.
   * @param {(string | ParamLike | SQLExpression | import('./ref.js').Ref)[]} parts The parts of the expression.
   * @param {string[]} [columns=[]] The column dependencies
   * @param {object} [props] Additional properties for this expression.
   */
  constructor(t, n, r) {
    this._expr = Array.isArray(t) ? t : [t], this._deps = n || [], this.annotate(r);
    const i = this._expr.filter((s) => jo(s));
    i.length > 0 ? (this._params = Array.from(new Set(i)), this._params.forEach((s) => {
      s.addEventListener("value", () => {
        var o;
        return E9(this, (o = this.map) == null ? void 0 : o.get("value"));
      });
    })) : this.addEventListener = void 0;
  }
  /**
   * A reference to this expression.
   * Provides compatibility with param-like objects.
   */
  get value() {
    return this;
  }
  /**
   * The column dependencies of this expression.
   * @returns {string[]} The columns dependencies.
   */
  get columns() {
    const { _params: t, _deps: n } = this;
    if (t) {
      const r = new Set(t.flatMap((i) => {
        var o;
        const s = (o = i.value) == null ? void 0 : o.columns;
        return Array.isArray(s) ? s : [];
      }));
      if (r.size) {
        const i = new Set(n);
        return r.forEach((s) => i.add(s)), Array.from(i);
      }
    }
    return n;
  }
  /**
   * The first column dependency in this expression, or undefined if none.
   * @returns {string} The first column dependency.
   */
  get column() {
    return this._deps.length ? this._deps[0] : this.columns[0];
  }
  /**
   * Annotate this expression instance with additional properties.
   * @param {object[]} [props] One or more objects with properties to add.
   * @returns This SQL expression.
   */
  annotate(...t) {
    return Object.assign(this, ...t);
  }
  /**
   * Generate a SQL code string corresponding to this expression.
   * @returns {string} A SQL code string.
   */
  toString() {
    return this._expr.map((t) => jo(t) && !zx(t) ? ou(t.value) : t).join("");
  }
  /**
   * Add an event listener callback for the provided event type.
   * @param {string} type The event type to listen for (for example, "value").
   * @param {(a: SQLExpression) => Promise?} callback The callback function to
   *  invoke upon updates. A callback may optionally return a Promise that
   *  upstream listeners may await before proceeding.
   */
  addEventListener(t, n) {
    const r = this.map || (this.map = /* @__PURE__ */ new Map());
    (r.get(t) || (r.set(t, /* @__PURE__ */ new Set()), r.get(t))).add(n);
  }
}
function E9(e, t) {
  if (t != null && t.size)
    return Promise.allSettled(Array.from(t, (n) => n(e)));
}
function qx(e, t) {
  const n = [e[0]], r = /* @__PURE__ */ new Set(), i = t.length;
  for (let s = 0, o = 0; s < i; ) {
    const a = t[s];
    jo(a) ? n[++o] = a : (Array.isArray(a == null ? void 0 : a.columns) && a.columns.forEach((u) => r.add(u)), n[o] += typeof a == "string" ? a : ou(a));
    const c = e[++s];
    jo(n[o]) ? n[++o] = c : n[o] += c;
  }
  return { spans: n, cols: Array.from(r) };
}
function j(e, ...t) {
  const { spans: n, cols: r } = qx(e, t);
  return new Gh(n, r);
}
function N9(e) {
  const t = Ft(e);
  return j`${t} DESC NULLS LAST`.annotate({ label: t == null ? void 0 : t.label, desc: !0 });
}
const Hh = (e) => ({
  value: e,
  toString: () => ou(e)
});
function au(e) {
  var t;
  e(this.op, this), (t = this.children) == null || t.forEach((n) => n.visit(e));
}
function jx(e, t) {
  const n = t.filter((i) => i != null).map(Ft), r = n.map((i, s) => s ? ` ${e} ` : "");
  return n.length === 1 ? r.push("") : n.length > 1 && (r[0] = "(", r.push(")")), j(r, ...n).annotate({ op: e, children: n, visit: au });
}
const ki = (...e) => jx("AND", e.flat()), Mm = (...e) => jx("OR", e.flat()), D9 = (e) => (t) => j`(${e} ${Ft(t)})`.annotate({ op: e, a: t, visit: au }), O9 = D9("NOT"), Vx = (e) => (t) => j`(${Ft(t)} ${e})`.annotate({ op: e, a: t, visit: au }), Am = Vx("IS NULL"), $c = Vx("IS NOT NULL"), Wi = (e) => (t, n) => j`(${Ft(t)} ${e} ${Ft(n)})`.annotate({ op: e, a: t, b: n, visit: au }), L9 = Wi("="), $m = Wi("<>"), Ic = Wi("<"), Yx = Wi(">"), Tc = Wi("<="), R9 = Wi(">="), k9 = Wi("IS DISTINCT FROM"), Im = Wi("IS NOT DISTINCT FROM");
function Wx(e, t, n, r) {
  t = Ft(t);
  const i = e.startsWith("NOT ") ? "NOT " : "";
  return (n ? r ? j`${i}(${n[0]} <= ${t} AND ${t} < ${n[1]})` : j`(${t} ${e} ${n[0]} AND ${n[1]})` : j``).annotate({ op: e, visit: au, field: t, range: n });
}
const In = (e, t, n) => Wx("BETWEEN", e, t, n), F9 = (e, t, n) => Wx("NOT BETWEEN", e, t, n);
function Nf(e, t) {
  return Array.from({ length: e }, () => t);
}
function ai(e, t) {
  return (...n) => {
    const r = n.map(Ft), i = t ? `::${t}` : "";
    return (r.length ? j([`${e}(`, ...Nf(r.length - 1, ", "), `)${i}`], ...r) : j`${e}()${i}`).annotate({ func: e, args: r });
  };
}
const B9 = ai("REGEXP_MATCHES"), C9 = ai("CONTAINS"), P9 = ai("PREFIX"), U9 = ai("SUFFIX");
class xi extends Gh {
  /**
   * Create a new WindowFunction instance.
   * @param {string} op The window operation indicator.
   * @param {*} func The window function expression.
   * @param {*} [type] The SQL data type to cast to.
   * @param {string} [name] The window definition name.
   * @param {*} [group] Grouping (partition by) expressions.
   * @param {*} [order] Sorting (order by) expressions.
   * @param {*} [frame] The window frame definition.
   */
  constructor(t, n, r, i, s = "", o = "", a = "") {
    let c;
    if (i && !(s || o || a))
      c = i ? j`${n} OVER "${i}"` : j`${n} OVER ()`;
    else {
      const h = s && o ? " " : "", d = (s || o) && a ? " " : "";
      c = j`${n} OVER (${i ? `"${i}" ` : ""}${s}${h}${o}${d}${a})`;
    }
    r && (c = j`(${c})::${r}`);
    const { _expr: l, _deps: f } = c;
    super(l, f), this.window = t, this.func = n, this.type = r, this.name = i, this.group = s, this.order = o, this.frame = a;
  }
  get basis() {
    return this.column;
  }
  get label() {
    const { func: t } = this;
    return t.label ?? t.toString();
  }
  /**
   * Return an updated window function over a named window definition.
   * @param {string} name The window definition name.
   * @returns {WindowFunction} A new window function.
   */
  over(t) {
    const { window: n, func: r, type: i, group: s, order: o, frame: a } = this;
    return new xi(n, r, i, t, s, o, a);
  }
  /**
   * Return an updated window function with the given partitioning.
   * @param {*} expr The grouping (partition by) criteria for the window function.
   * @returns {WindowFunction} A new window function.
   */
  partitionby(...t) {
    const n = t.flat().filter((l) => l).map(Ft), r = j(
      ["PARTITION BY ", Nf(n.length - 1, ", "), ""],
      ...n
    ), { window: i, func: s, type: o, name: a, order: c, frame: u } = this;
    return new xi(i, s, o, a, r, c, u);
  }
  /**
   * Return an updated window function with the given ordering.
   * @param {*} expr The sorting (order by) criteria for the window function.
   * @returns {WindowFunction} A new window function.
   */
  orderby(...t) {
    const n = t.flat().filter((l) => l).map(Ft), r = j(
      ["ORDER BY ", Nf(n.length - 1, ", "), ""],
      ...n
    ), { window: i, func: s, type: o, name: a, group: c, frame: u } = this;
    return new xi(i, s, o, a, c, r, u);
  }
  /**
   * Return an updated window function with the given rows frame.
   * @param {(number|null)[] | import('./expression.js').ParamLike} expr The row-based window frame.
   * @returns {WindowFunction} A new window function.
   */
  rows(t) {
    const n = Ob("ROWS", t), { window: r, func: i, type: s, name: o, group: a, order: c } = this;
    return new xi(r, i, s, o, a, c, n);
  }
  /**
   * Return an updated window function with the given range frame.
   * @param {(number|null)[] | import('./expression.js').ParamLike} expr The range-based window frame.
   * @returns {WindowFunction} A new window function.
   */
  range(t) {
    const n = Ob("RANGE", t), { window: r, func: i, type: s, name: o, group: a, order: c } = this;
    return new xi(r, i, s, o, a, c, n);
  }
}
function Ob(e, t) {
  if (jo(t)) {
    const n = j`${t}`;
    return n.toString = () => `${e} ${Lb(t.value)}`, n;
  }
  return `${e} ${Lb(t)}`;
}
function Lb(e) {
  const [t, n] = e, r = t === 0 ? "CURRENT ROW" : Number.isFinite(t) ? `${Math.abs(t)} PRECEDING` : "UNBOUNDED PRECEDING", i = n === 0 ? "CURRENT ROW" : Number.isFinite(n) ? `${Math.abs(n)} FOLLOWING` : "UNBOUNDED FOLLOWING";
  return `BETWEEN ${r} AND ${i}`;
}
function Gn(e, t) {
  return (...n) => {
    const r = ai(e)(...n);
    return new xi(e, r, t);
  };
}
const z9 = Gn("ROW_NUMBER", "INTEGER"), q9 = Gn("RANK", "INTEGER"), j9 = Gn("DENSE_RANK", "INTEGER"), V9 = Gn("PERCENT_RANK"), Y9 = Gn("CUME_DIST"), W9 = Gn("NTILE"), X9 = Gn("LAG"), G9 = Gn("LEAD"), H9 = Gn("FIRST_VALUE"), J9 = Gn("LAST_VALUE"), Z9 = Gn("NTH_VALUE");
function Tt(e, ...t) {
  return j(e, ...t).annotate({ aggregate: !0 });
}
class hc extends Gh {
  /**
   * Create a new AggregateFunction instance.
   * @param {*} op The aggregate operation.
   * @param {*} [args] The aggregate function arguments.
   * @param {*} [type] The SQL data type to cast to.
   * @param {boolean} [isDistinct] Flag indicating if this is a distinct value aggregate.
   * @param {*} [filter] Filtering expression to apply prior to aggregation.
   */
  constructor(t, n, r, i, s) {
    n = (n || []).map(Ft);
    const { strings: o, exprs: a } = K9(t, n, r, i, s), { spans: c, cols: u } = qx(o, a);
    super(c, u), this.aggregate = t, this.args = n, this.type = r, this.isDistinct = i, this.filter = s;
  }
  get basis() {
    return this.column;
  }
  get label() {
    const { aggregate: t, args: n, isDistinct: r } = this, i = r ? "DISTINCT" + (n.length ? " " : "") : "", s = n.length ? `(${i}${n.map(Q9).join(", ")})` : "";
    return `${t.toLowerCase()}${s}`;
  }
  /**
   * Return a new derived aggregate function over distinct values.
   * @returns {AggregateFunction} A new aggregate function.
   */
  distinct() {
    const { aggregate: t, args: n, type: r, filter: i } = this;
    return new hc(t, n, r, !0, i);
  }
  /**
   * Return a new derived aggregate function that filters values.
   * @param {*} filter The filter expresion.
   * @returns {AggregateFunction} A new aggregate function.
   */
  where(t) {
    const { aggregate: n, args: r, type: i, isDistinct: s } = this;
    return new hc(n, r, i, s, t);
  }
  /**
   * Return a new window function over this aggregate.
   * @returns {WindowFunction} A new aggregate function.
   */
  window() {
    const { aggregate: t, args: n, type: r, isDistinct: i } = this, s = new hc(t, n, null, i);
    return new xi(t, s, r);
  }
  /**
   * Return a window function over this aggregate with the given partitioning.
   * @param {*} expr The grouping (partition by) criteria for the window function.
   * @returns {WindowFunction} A new window function.
   */
  partitionby(...t) {
    return this.window().partitionby(...t);
  }
  /**
   * Return a window function over this aggregate with the given ordering.
   * @param {*} expr The sorting (order by) criteria for the window function.
   * @returns {WindowFunction} A new window function.
   */
  orderby(...t) {
    return this.window().orderby(...t);
  }
  /**
   * Return a window function over this aggregate with the given row frame.
   * @param {(number|null)[] | import('./expression.js').ParamLike} frame The row-based window frame.
   * @returns {WindowFunction} A new window function.
   */
  rows(t) {
    return this.window().rows(t);
  }
  /**
   * Return a window function over this aggregate with the given range frame.
   * @param {(number|null)[] | import('./expression.js').ParamLike} frame The range-based window frame.
   * @returns {WindowFunction} A new window function.
   */
  range(t) {
    return this.window().range(t);
  }
}
function K9(e, t, n, r, i) {
  const s = `)${n ? `::${n}` : ""}`;
  let o = [`${e}(${r ? "DISTINCT " : ""}`], a = [];
  return t.length ? (o = o.concat([
    ...Nf(t.length - 1, ", "),
    `${s}${i ? " FILTER (WHERE " : ""}`,
    ...i ? [")"] : []
  ]), a = [...t, ...i ? [i] : []]) : o[0] += "*" + s, { exprs: a, strings: o };
}
function Q9(e) {
  const t = ou(e);
  return t && t.startsWith('"') && t.endsWith('"') ? t.slice(1, -1) : t;
}
function kt(e, t) {
  return (...n) => new hc(e, n, t);
}
const Ni = kt("COUNT", "INTEGER"), Xx = kt("AVG"), tL = kt("MAD"), Vo = kt("MAX"), Yo = kt("MIN"), Bs = kt("SUM", "DOUBLE"), eL = kt("PRODUCT"), nL = kt("MEDIAN"), rL = kt("QUANTILE"), iL = kt("MODE"), sL = kt("VARIANCE"), Gx = kt("STDDEV"), oL = kt("SKEWNESS"), aL = kt("KURTOSIS"), cL = kt("ENTROPY"), uL = kt("VAR_POP"), lL = kt("STDDEV_POP"), fL = kt("CORR"), hL = kt("COVAR_SAMP"), dL = kt("COVAR_POP"), pL = kt("REGR_INTERCEPT"), yL = kt("REGR_SLOPE"), mL = kt("REGR_COUNT"), gL = kt("REGR_SYY"), bL = kt("REGR_SXX"), wL = kt("REGR_AVGX"), _L = kt("FIRST"), vL = kt("LAST"), I0 = kt("ARG_MIN"), T0 = kt("ARG_MAX"), xL = kt("STRING_AGG"), SL = kt("ARRAY_AGG");
function Tm(e, t) {
  const n = Ft(e), r = j`CAST(${n} AS ${t})`;
  return Object.defineProperty(r, "label", {
    enumerable: !0,
    get() {
      return e.label;
    }
  }), Object.defineProperty(r, "aggregate", {
    enumerable: !0,
    get() {
      return e.aggregate || !1;
    }
  }), r;
}
const E0 = (e) => Tm(e, "DOUBLE"), ML = (e) => Tm(e, "INTEGER"), AL = (e) => j`epoch_ms(${Ft(e)})`;
function $L(e, t, n = 1) {
  const r = `INTERVAL ${n} ${t}`, i = Ft(e);
  return j`TIME_BUCKET(${r}, ${i})`.annotate({ label: t });
}
const IL = (e) => {
  const t = Ft(e);
  return j`MAKE_DATE(2012, MONTH(${t}), 1)`.annotate({ label: "month" });
}, TL = (e) => {
  const t = Ft(e);
  return j`MAKE_DATE(2012, MONTH(${t}), DAY(${t}))`.annotate({ label: "date" });
}, EL = (e) => {
  const t = Ft(e);
  return j`MAKE_DATE(2012, 1, DAY(${t}))`.annotate({ label: "date" });
}, Hx = ai("ST_AsGeoJSON"), NL = ai("ST_X"), DL = ai("ST_Y"), Em = ai("ST_CENTROID"), OL = (e) => NL(Em(e)), LL = (e) => DL(Em(e));
class xt {
  static select(...t) {
    return new xt().select(...t);
  }
  static from(...t) {
    return new xt().from(...t);
  }
  static with(...t) {
    return new xt().with(...t);
  }
  static union(...t) {
    return new ls("UNION", t.flat());
  }
  static unionAll(...t) {
    return new ls("UNION ALL", t.flat());
  }
  static intersect(...t) {
    return new ls("INTERSECT", t.flat());
  }
  static except(...t) {
    return new ls("EXCEPT", t.flat());
  }
  static describe(t) {
    const n = t.clone(), { clone: r, toString: i } = n;
    return Object.assign(n, {
      describe: !0,
      clone: () => xt.describe(r.call(n)),
      toString: () => `DESCRIBE ${i.call(n)}`
    });
  }
  constructor() {
    this.query = {
      with: [],
      select: [],
      from: [],
      where: [],
      groupby: [],
      having: [],
      window: [],
      qualify: [],
      orderby: []
    }, this.cteFor = null;
  }
  clone() {
    const t = new xt();
    return t.query = { ...this.query }, t;
  }
  /**
   * Retrieve current WITH common table expressions (CTEs).
   * @returns {any[]}
   */
  /**
  * Add WITH common table expressions (CTEs).
  * @param  {...any} expr Expressions to add.
  * @returns {this}
  */
  with(...t) {
    const { query: n } = this;
    if (t.length === 0)
      return n.with;
    {
      const r = [], i = (s, o) => {
        const a = o.clone();
        a.cteFor = this, r.push({ as: s, query: a });
      };
      return t.flat().forEach((s) => {
        if (s != null) if (s.as && s.query)
          i(s.as, s.query);
        else
          for (const o in s)
            i(o, s[o]);
      }), n.with = n.with.concat(r), this;
    }
  }
  /**
   * Retrieve current SELECT expressions.
   * @returns {any[]}
   */
  /**
  * Add SELECT expressions.
  * @param {...any} expr Expressions to add.
  * @returns {this}
  */
  select(...t) {
    const { query: n } = this;
    if (t.length === 0)
      return n.select;
    {
      const r = [];
      for (const s of t.flat())
        if (s != null) if (typeof s == "string")
          r.push({ as: s, expr: Ft(s) });
        else if (s instanceof Ri)
          r.push({ as: s.column, expr: s });
        else if (Array.isArray(s))
          r.push({ as: s[0], expr: s[1] });
        else
          for (const o in s)
            r.push({ as: Wu(o), expr: Ft(s[o]) });
      const i = new Set(r.map((s) => s.as));
      return n.select = n.select.filter((s) => !i.has(s.as)).concat(r.filter((s) => s.expr)), this;
    }
  }
  $select(...t) {
    return this.query.select = [], this.select(...t);
  }
  distinct(t = !0) {
    return this.query.distinct = !!t, this;
  }
  /**
   * Retrieve current from expressions.
   * @returns {any[]}
   */
  /**
  * Provide table from expressions.
  * @param  {...any} expr
  * @returns {this}
  */
  from(...t) {
    const { query: n } = this;
    if (t.length === 0)
      return n.from;
    {
      const r = [];
      return t.flat().forEach((i) => {
        if (i != null) if (typeof i == "string")
          r.push({ as: i, from: Bl(i) });
        else if (i instanceof Ri)
          r.push({ as: i.table, from: i });
        else if (Cl(i) || zx(i))
          r.push({ from: i });
        else if (Array.isArray(i))
          r.push({ as: Wu(i[0]), from: Bl(i[1]) });
        else
          for (const s in i)
            r.push({ as: Wu(s), from: Bl(i[s]) });
      }), n.from = n.from.concat(r), this;
    }
  }
  $from(...t) {
    return this.query.from = [], this.from(...t);
  }
  /**
   * Retrieve current SAMPLE settings.
   * @returns {any[]}
   */
  /**
  * Set SAMPLE settings.
  * @param {number|object} value The percentage or number of rows to sample.
  * @param {string} [method] The sampling method to use.
  * @returns {this}
  */
  sample(t, n) {
    const { query: r } = this;
    if (arguments.length === 0)
      return r.sample;
    {
      let i = t;
      return typeof t == "number" && (i = t > 0 && t < 1 ? { perc: 100 * t, method: n } : { rows: Math.round(t), method: n }), r.sample = i, this;
    }
  }
  /**
   * Retrieve current WHERE expressions.
   * @returns {any[]}
   */
  /**
  * Add WHERE expressions.
  * @param  {...any} expr Expressions to add.
  * @returns {this}
  */
  where(...t) {
    const { query: n } = this;
    return t.length === 0 ? n.where : (n.where = n.where.concat(
      t.flat().filter((r) => r)
    ), this);
  }
  $where(...t) {
    return this.query.where = [], this.where(...t);
  }
  /**
   * Retrieve current GROUP BY expressions.
   * @returns {any[]}
   */
  /**
  * Add GROUP BY expressions.
  * @param  {...any} expr Expressions to add.
  * @returns {this}
  */
  groupby(...t) {
    const { query: n } = this;
    return t.length === 0 ? n.groupby : (n.groupby = n.groupby.concat(
      t.flat().filter((r) => r).map(Ft)
    ), this);
  }
  $groupby(...t) {
    return this.query.groupby = [], this.groupby(...t);
  }
  /**
   * Retrieve current HAVING expressions.
   * @returns {any[]}
   */
  /**
  * Add HAVING expressions.
  * @param  {...any} expr Expressions to add.
  * @returns {this}
  */
  having(...t) {
    const { query: n } = this;
    return t.length === 0 ? n.having : (n.having = n.having.concat(
      t.flat().filter((r) => r)
    ), this);
  }
  /**
   * Retrieve current WINDOW definitions.
   * @returns {any[]}
   */
  /**
  * Add WINDOW definitions.
  * @param  {...any} expr Expressions to add.
  * @returns {this}
  */
  window(...t) {
    const { query: n } = this;
    if (t.length === 0)
      return n.window;
    {
      const r = [];
      return t.flat().forEach((i) => {
        if (i != null) for (const s in i)
          r.push({ as: Wu(s), expr: i[s] });
      }), n.window = n.window.concat(r), this;
    }
  }
  /**
   * Retrieve current QUALIFY expressions.
   * @returns {any[]}
   */
  /**
  * Add QUALIFY expressions.
  * @param  {...any} expr Expressions to add.
  * @returns {this}
  */
  qualify(...t) {
    const { query: n } = this;
    return t.length === 0 ? n.qualify : (n.qualify = n.qualify.concat(
      t.flat().filter((r) => r)
    ), this);
  }
  /**
   * Retrieve current ORDER BY expressions.
   * @returns {any[]}
   */
  /**
  * Add ORDER BY expressions.
  * @param  {...any} expr Expressions to add.
  * @returns {this}
  */
  orderby(...t) {
    const { query: n } = this;
    return t.length === 0 ? n.orderby : (n.orderby = n.orderby.concat(
      t.flat().filter((r) => r).map(Ft)
    ), this);
  }
  /**
   * Retrieve current LIMIT value.
   * @returns {number|null}
   */
  /**
  * Set the query result LIMIT.
  * @param {number} value The limit value.
  * @returns {this}
  */
  limit(t) {
    const { query: n } = this;
    return arguments.length === 0 ? n.limit : (n.limit = Number.isFinite(t) ? t : void 0, this);
  }
  /**
   * Retrieve current OFFSET value.
   * @returns {number|null}
   */
  /**
  * Set the query result OFFSET.
  * @param {number} value The offset value.
  * @returns {this}
  */
  offset(t) {
    const { query: n } = this;
    return arguments.length === 0 ? n.offset : (n.offset = Number.isFinite(t) ? t : void 0, this);
  }
  get subqueries() {
    const { query: t, cteFor: n } = this, r = ((n == null ? void 0 : n.query) || t).with, i = r == null ? void 0 : r.reduce((o, { as: a, query: c }) => (o[a] = c, o), {}), s = [];
    return t.from.forEach(({ from: o }) => {
      if (Cl(o))
        s.push(o);
      else if (i[o.table]) {
        const a = i[o.table];
        s.push(a);
      }
    }), s;
  }
  toString() {
    const {
      with: t,
      select: n,
      distinct: r,
      from: i,
      sample: s,
      where: o,
      groupby: a,
      having: c,
      window: u,
      qualify: l,
      orderby: f,
      limit: h,
      offset: d
    } = this.query, p = [];
    if (t.length) {
      const m = t.map(({ as: g, query: b }) => `"${g}" AS (${b})`);
      p.push(`WITH ${m.join(", ")}`);
    }
    const y = n.map(
      ({ as: m, expr: g }) => I9(g, m) && !g.table ? `${g}` : `${g} AS "${m}"`
    );
    if (p.push(`SELECT${r ? " DISTINCT" : ""} ${y.join(", ")}`), i.length) {
      const m = i.map(({ as: g, from: b }) => {
        const w = Cl(b) ? `(${b})` : `${b}`;
        return !g || g === b.table ? w : `${w} AS "${g}"`;
      });
      p.push(`FROM ${m.join(", ")}`);
    }
    if (o.length) {
      const m = o.map(String).filter((g) => g).join(" AND ");
      m && p.push(`WHERE ${m}`);
    }
    if (s) {
      const { rows: m, perc: g, method: b, seed: w } = s, _ = m ? `${m} ROWS` : `${g} PERCENT`, x = b ? ` (${b}${w != null ? `, ${w}` : ""})` : "";
      p.push(`USING SAMPLE ${_}${x}`);
    }
    if (a.length && p.push(`GROUP BY ${a.join(", ")}`), c.length) {
      const m = c.map(String).filter((g) => g).join(" AND ");
      m && p.push(`HAVING ${m}`);
    }
    if (u.length) {
      const m = u.map(({ as: g, expr: b }) => `"${g}" AS (${b})`);
      p.push(`WINDOW ${m.join(", ")}`);
    }
    if (l.length) {
      const m = l.map(String).filter((g) => g).join(" AND ");
      m && p.push(`QUALIFY ${m}`);
    }
    return f.length && p.push(`ORDER BY ${f.join(", ")}`), Number.isFinite(h) && p.push(`LIMIT ${h}`), Number.isFinite(d) && p.push(`OFFSET ${d}`), p.join(" ");
  }
}
class ls {
  constructor(t, n) {
    this.op = t, this.queries = n.map((r) => r.clone()), this.query = { orderby: [] }, this.cteFor = null;
  }
  clone() {
    const t = new ls(this.op, this.queries);
    return t.query = { ...this.query }, t;
  }
  orderby(...t) {
    const { query: n } = this;
    return t.length === 0 ? n.orderby : (n.orderby = n.orderby.concat(
      t.flat().filter((r) => r).map(Ft)
    ), this);
  }
  limit(t) {
    const { query: n } = this;
    return arguments.length === 0 ? n.limit : (n.limit = Number.isFinite(t) ? t : void 0, this);
  }
  offset(t) {
    const { query: n } = this;
    return arguments.length === 0 ? n.offset : (n.offset = Number.isFinite(t) ? t : void 0, this);
  }
  get subqueries() {
    const { queries: t, cteFor: n } = this;
    return n && t.forEach((r) => r.cteFor = n), t;
  }
  toString() {
    const { op: t, queries: n, query: { orderby: r, limit: i, offset: s } } = this, o = [n.join(` ${t} `)];
    return r.length && o.push(`ORDER BY ${r.join(", ")}`), Number.isFinite(i) && o.push(`LIMIT ${i}`), Number.isFinite(s) && o.push(`OFFSET ${s}`), o.join(" ");
  }
}
function Cl(e) {
  return e instanceof xt || e instanceof ls;
}
function RL(e) {
  return Cl(e) && e.describe;
}
function Wu(e) {
  return kL(e) ? e.slice(1, -1) : e;
}
function kL(e) {
  return e[0] === '"' && e[e.length - 1] === '"';
}
const Pl = (e) => e;
function Rb() {
  return {
    apply: Pl,
    invert: Pl,
    sqlApply: Ft,
    sqlInvert: Pl
  };
}
function FL({ base: e = null } = {}) {
  if (e == null || e === Math.E)
    return {
      apply: Math.log,
      invert: Math.exp,
      sqlApply: (t) => j`LN(${Ft(t)})`,
      sqlInvert: (t) => j`EXP(${t})`
    };
  if (e === 10)
    return {
      apply: Math.log10,
      invert: (t) => Math.pow(10, t),
      sqlApply: (t) => j`LOG(${Ft(t)})`,
      sqlInvert: (t) => j`POW(10, ${t})`
    };
  {
    const t = +e;
    return {
      apply: (n) => Math.log(n) / Math.log(t),
      invert: (n) => Math.pow(t, n),
      sqlApply: (n) => j`LN(${Ft(n)}) / LN(${t})`,
      sqlInvert: (n) => j`POW(${t}, ${n})`
    };
  }
}
function BL({ constant: e = 1 } = {}) {
  const t = +e;
  return {
    apply: (n) => Math.sign(n) * Math.log1p(Math.abs(n)),
    invert: (n) => Math.sign(n) * Math.exp(Math.abs(n) - t),
    sqlApply: (n) => (n = Ft(n), j`SIGN(${n}) * LN(${t} + ABS(${n}))`),
    sqlInvert: (n) => j`SIGN(${n}) * (EXP(ABS(${n})) - ${t})`
  };
}
function CL() {
  return {
    apply: (e) => Math.sign(e) * Math.sqrt(Math.abs(e)),
    invert: (e) => Math.sign(e) * e * e,
    sqlApply: (e) => (e = Ft(e), j`SIGN(${e}) * SQRT(ABS(${e}))`),
    sqlInvert: (e) => j`SIGN(${e}) * (${e}) ** 2`
  };
}
function PL({ exponent: e = 1 } = {}) {
  const t = +e;
  return {
    apply: (n) => Math.sign(n) * Math.pow(Math.abs(n), t),
    invert: (n) => Math.sign(n) * Math.pow(Math.abs(n), 1 / t),
    sqlApply: (n) => (n = Ft(n), j`SIGN(${n}) * POW(ABS(${n}), ${t})`),
    sqlInvert: (n) => j`SIGN(${n}) * POW(ABS(${n}), 1/${t})`
  };
}
function kb() {
  return {
    apply: (e) => +e,
    invert: (e) => new Date(e),
    sqlApply: (e) => e instanceof Date ? +e : AL(Ft(e)),
    sqlInvert: Pl
  };
}
const UL = {
  identity: Rb,
  linear: Rb,
  log: FL,
  symlog: BL,
  sqrt: CL,
  pow: PL,
  time: kb,
  utc: kb
};
function Jx(e) {
  const t = UL[e.type];
  return t ? { ...e, ...t(e) } : null;
}
function cu(e, t, {
  replace: n = !1,
  temp: r = !0,
  view: i = !1
} = {}) {
  return "CREATE" + (n ? " OR REPLACE " : " ") + (r ? "TEMP " : "") + (i ? "VIEW" : "TABLE") + (n ? " " : " IF NOT EXISTS ") + e + " AS " + t;
}
function Zx(e) {
  return `INSTALL ${e}; LOAD ${e}`;
}
function zL(e, {
  columns: t = Object.keys((e == null ? void 0 : e[0]) || {})
} = {}) {
  let n = [];
  if (Array.isArray(t) ? (n = t, t = n.reduce((i, s) => (i[s] = s, i), {})) : t && (n = Object.keys(t)), !n.length)
    throw new Error("Can not create table from empty column set.");
  const r = [];
  for (const i of e) {
    const s = n.map((o) => `${ou(i[o])} AS "${t[o]}"`);
    r.push(`(SELECT ${s.join(", ")})`);
  }
  return r.join(" UNION ALL ");
}
function Jh(e, t, n, r = {}, i = {}) {
  const { select: s = ["*"], where: o, view: a, temp: c, replace: u, ...l } = r, f = XL({ ...i, ...l }), h = `${e}('${n}'${f ? ", " + f : ""})`, d = o ? ` WHERE ${o}` : "", p = `SELECT ${s.join(", ")} FROM ${h}${d}`;
  return cu(t, p, { view: a, temp: c, replace: u });
}
function qL(e, t, n) {
  return Jh("read_csv", e, t, n, { auto_detect: !0, sample_size: -1 });
}
function jL(e, t, n) {
  return Jh("read_json", e, t, n, { auto_detect: !0, json_format: "auto" });
}
function VL(e, t, n) {
  return Jh("read_parquet", e, t, n);
}
function YL(e, t, n = {}) {
  const { options: r, ...i } = n;
  if (r) {
    const s = Array.isArray(r) ? r.join(", ") : typeof r == "string" ? r : Object.entries(r).map(([o, a]) => `${o}=${a}`).join(", ");
    Object.assign(i, { open_options: s.toUpperCase() });
  }
  return Jh("st_read", e, t, i);
}
function WL(e, t, n = {}) {
  const { select: r = ["*"], ...i } = n, s = zL(t), o = r.length === 1 && r[0] === "*" ? s : `SELECT ${r} FROM ${s}`;
  return cu(e, o, i);
}
function XL(e) {
  return Object.entries(e).map(([t, n]) => `${t}=${N0(n)}`).join(", ");
}
function N0(e) {
  switch (typeof e) {
    case "boolean":
      return String(e);
    case "string":
      return `'${e}'`;
    case "undefined":
    case "object":
      return e == null ? "NULL" : Array.isArray(e) ? "[" + e.map((t) => N0(t)).join(", ") + "]" : "{" + Object.entries(e).map(([t, n]) => `'${t}': ${N0(n)}`).join(", ") + "}";
    default:
      return e;
  }
}
function GL(e) {
  var o;
  if (!e.filterIndexable) return null;
  const t = e.query(), n = D0(t);
  if (typeof n != "string" || !t.select) return null;
  const r = [], i = [], s = {};
  for (const a of t.select()) {
    const { as: c, expr: { aggregate: u, args: l } } = a, f = (o = u == null ? void 0 : u.toUpperCase) == null ? void 0 : o.call(u);
    switch (f) {
      case "COUNT":
      case "SUM":
        r.push({ [c]: Tt`SUM("${c}")::DOUBLE` });
        break;
      case "AVG":
        r.push({ [c]: JL(s, c, l[0]) });
        break;
      case "ARG_MAX":
        r.push({ [c]: ZL(s, c, l) });
        break;
      case "ARG_MIN":
        r.push({ [c]: KL(s, c, l) });
        break;
      case "VARIANCE":
      case "VAR_SAMP":
        s[c] = null, r.push({ [c]: Xu(s, l[0], n) });
        break;
      case "VAR_POP":
        s[c] = null, r.push({ [c]: Xu(s, l[0], n, !1) });
        break;
      case "STDDEV":
      case "STDDEV_SAMP":
        s[c] = null, r.push({ [c]: Tt`SQRT(${Xu(s, l[0], n)})` });
        break;
      case "STDDEV_POP":
        s[c] = null, r.push({ [c]: Tt`SQRT(${Xu(s, l[0], n, !1)})` });
        break;
      case "COVAR_SAMP":
        s[c] = null, r.push({ [c]: Ul(s, l, n) });
        break;
      case "COVAR_POP":
        s[c] = null, r.push({ [c]: Ul(s, l, n, !1) });
        break;
      case "CORR":
        s[c] = null, r.push({ [c]: Fb(s, l, n) });
        break;
      case "REGR_COUNT":
        s[c] = null, r.push({ [c]: Tt`${da(s, l)}::DOUBLE` });
        break;
      case "REGR_AVGX":
        s[c] = null, r.push({ [c]: tS(s, l) });
        break;
      case "REGR_AVGY":
        s[c] = null, r.push({ [c]: eS(s, l) });
        break;
      case "REGR_SYY":
        s[c] = null, r.push({ [c]: L0(s, 0, l, n) });
        break;
      case "REGR_SXX":
        s[c] = null, r.push({ [c]: L0(s, 1, l, n) });
        break;
      case "REGR_SXY":
        s[c] = null, r.push({ [c]: Ul(s, l, n, null) });
        break;
      case "REGR_SLOPE":
        s[c] = null, r.push({ [c]: nS(s, l, n) });
        break;
      case "REGR_INTERCEPT":
        s[c] = null, r.push({ [c]: QL(s, l, n) });
        break;
      case "REGR_R2":
        s[c] = null, r.push({ [c]: Tt`(${Fb(s, l, n)}) ** 2` });
        break;
      case "MAX":
      case "MIN":
      case "BIT_AND":
      case "BIT_OR":
      case "BIT_XOR":
      case "BOOL_AND":
      case "BOOL_OR":
      case "PRODUCT":
        r.push({ [c]: Tt`${f}("${c}")` });
        break;
      default:
        if (!u) i.push(c);
        else return null;
    }
  }
  return r.length ? { from: n, dims: i, aggr: r, aux: s } : null;
}
function zn(e, ...t) {
  const n = t.length ? "_" + t.map(HL).join("_") : "";
  return `__${e}${n}__`;
}
function HL(e) {
  return `${e}`.replaceAll('"', "").replaceAll(" ", "_");
}
function D0(e) {
  const t = e.subqueries;
  if (e.select) {
    const r = e.from();
    if (!r.length) return;
    if (t.length === 0) return r[0].from.table;
  }
  const n = D0(t[0]);
  for (let r = 1; r < t.length; ++r) {
    const i = D0(t[r]);
    if (i !== void 0 && i !== n)
      return NaN;
  }
  return n;
}
function Kx(e, t) {
  const n = zn("count", t);
  return e[n] = Tt`COUNT(${t})`, Tt`SUM(${n})`.annotate({ name: n });
}
function JL(e, t, n) {
  const r = Kx(e, n);
  return Tt`(SUM("${t}" * ${r.name}) / ${r})`;
}
function Ec(e, t) {
  return j`(SELECT AVG(${e}) FROM "${t}")`;
}
function ZL(e, t, [, n]) {
  const r = zn("max", n);
  return e[r] = Tt`MAX(${n})`, Tt`ARG_MAX("${t}", ${r})`;
}
function KL(e, t, [, n]) {
  const r = zn("min", n);
  return e[r] = Tt`MIN(${n})`, Tt`ARG_MIN("${t}", ${r})`;
}
function Xu(e, t, n, r = !0) {
  const i = Kx(e, t), s = zn("rssq", t), o = zn("rsum", t), a = j`${t} - ${Ec(t, n)}`;
  return e[s] = Tt`SUM((${a}) ** 2)`, e[o] = Tt`SUM(${a})`, Tt`(SUM(${s}) - (SUM(${o}) ** 2 / ${i})) / (${i}${r ? " - 1" : ""})`;
}
function Ul(e, t, n, r = !0) {
  const i = da(e, t), s = Qx(e, t, n), o = Nc(e, 1, t, n), a = Nc(e, 0, t, n), c = r === null ? "" : r ? ` / (${i} - 1)` : ` / ${i}`;
  return Tt`(${s} - ${o} * ${a} / ${i})${c}`;
}
function Fb(e, t, n) {
  const r = da(e, t), i = Qx(e, t, n), s = O0(e, 1, t, n), o = O0(e, 0, t, n), a = Nc(e, 1, t, n), c = Nc(e, 0, t, n), u = Tt`(${s} - (${a} ** 2) / ${r})`, l = Tt`(${o} - (${c} ** 2) / ${r})`;
  return Tt`(${i} - ${a} * ${c} / ${r}) / SQRT(${u} * ${l})`;
}
function da(e, [t, n]) {
  const r = zn("count", t, n);
  return e[r] = Tt`REGR_COUNT(${t}, ${n})`, Tt`SUM(${r})`.annotate({ name: r });
}
function Nc(e, t, n, r) {
  const i = n[t], s = n[1 - t], o = zn("rs", i);
  return e[o] = Tt`SUM(${i} - ${Ec(i, r)}) FILTER (${s} IS NOT NULL)`, Tt`SUM(${o})`;
}
function O0(e, t, n, r) {
  const i = n[t], s = n[1 - t], o = zn("rss", i);
  return e[o] = Tt`SUM((${i} - ${Ec(i, r)}) ** 2) FILTER (${s} IS NOT NULL)`, Tt`SUM(${o})`;
}
function Qx(e, t, n) {
  const [r, i] = t, s = zn("sxy", r, i);
  return e[s] = Tt`SUM((${i} - ${Ec(i, n)}) * (${r} - ${Ec(r, n)}))`, Tt`SUM(${s})`;
}
function tS(e, t) {
  const [n, r] = t, i = da(e, t), s = zn("avg", r, n);
  return e[s] = Tt`REGR_AVGX(${n}, ${r})`, Tt`(SUM(${s} * ${i.name}) / ${i})`;
}
function eS(e, t) {
  const [n, r] = t, i = da(e, t), s = zn("avg", n, r);
  return e[s] = Tt`REGR_AVGY(${n}, ${r})`, Tt`(SUM(${s} * ${i.name}) / ${i})`;
}
function L0(e, t, n, r) {
  const i = da(e, n), s = Nc(e, t, n, r), o = O0(e, t, n, r);
  return Tt`(${o} - (${s} ** 2 / ${i}))`;
}
function nS(e, t, n) {
  const r = Ul(e, t, n, null), i = L0(e, 1, t, n);
  return Tt`(${r}) / ${i}`;
}
function QL(e, t, n) {
  const r = tS(e, t), i = eS(e, t), s = nS(e, t, n);
  return Tt`${i} - (${s}) * ${r}`;
}
function tR(e) {
  let t = 2166136261;
  for (let n = 0, r = e.length; n < r; ++n) {
    const i = e.charCodeAt(n), s = i & 65280;
    s && (t = Bb(t ^ s >> 8)), t = Bb(t ^ i & 255);
  }
  return eR(t);
}
function Bb(e) {
  return e + (e << 1) + (e << 4) + (e << 7) + (e << 8) + (e << 24);
}
function eR(e) {
  return e += e << 13, e ^= e >>> 7, e += e << 3, e ^= e >>> 17, e += e << 5, e & 4294967295;
}
const nR = { skip: !0, result: null };
class rR {
  /**
   * Create a new data cube index table manager.
   * @param {import('./Coordinator.js').Coordinator} coordinator A Mosaic coordinator.
   * @param {object} [options] Indexer options.
   * @param {boolean} [options.enabled=true] Flag to enable/disable indexer.
   * @param {boolean} [options.temp=true] Flag to indicate if generated data
   *  cube index tables should be temporary tables.
   */
  constructor(t, {
    enabled: n = !0,
    temp: r = !0
  } = {}) {
    this.indexes = /* @__PURE__ */ new Map(), this.active = null, this.temp = r, this.mc = t, this._enabled = n;
  }
  /**
   * Set the enabled state of this indexer. If false, any cached state is
   * cleared and subsequent index calls will return null until re-enabled.
   * @param {boolean} state The enabled state.
   */
  enabled(t) {
    if (t === void 0)
      return this._enabled;
    this._enabled !== t && (t || this.clear(), this._enabled = t);
  }
  /**
   * Clear the cache of data cube index table entries for the current active
   * selection clause. This method will also cancel any queued data cube table
   * creation queries that have not yet been submitted to the database. This
   * method does _not_ drop any existing data cube tables.
   */
  clear() {
    this.mc.cancel(Array.from(this.indexes.values(), (t) => t == null ? void 0 : t.result)), this.indexes.clear(), this.active = null;
  }
  /**
   * Return data cube index table information for the active state of a
   * client-selection pair, or null if the client is not indexable. This
   * method has multiple possible side effects, including data cube table
   * generation and updating internal caches.
   * @param {import('./MosaicClient.js').MosaicClient} client A Mosaic client.
   * @param {import('./Selection.js').Selection} selection A Mosaic selection
   *  to filter the client by.
   * @param {import('./util/selection-types.js').SelectionClause} activeClause
   *  A representative active selection clause for which to (possibly) generate
   *  data cube index tables.
   * @returns {DataCubeInfo | Skip | null} Data cube index table
   *  information and query generator, or null if the client is not indexable.
   */
  index(t, n, r) {
    var f;
    if (!this._enabled) return null;
    const { indexes: i, mc: s, temp: o } = this, { source: a } = r;
    if (!a || this.active && (this.active.source !== a && this.clear(), ((f = this.active) == null ? void 0 : f.source) === null))
      return null;
    let { active: c } = this;
    if (!c && (this.active = c = iR(r), c.source === null))
      return null;
    if (i.has(t))
      return i.get(t);
    const u = GL(t);
    let l;
    if (!u)
      l = null;
    else if (n.skip(t, r))
      l = nR;
    else {
      const h = n.remove(a).predicate(t);
      l = aR(t.query(h), c, u), l.result = s.exec(cu(l.table, l.create, { temp: o })), l.result.catch((d) => s.logger().error(d));
    }
    return i.set(t, l), l;
  }
}
function iR(e) {
  const { source: t, meta: n } = e, r = e.predicate, i = r == null ? void 0 : r.columns;
  let s, o;
  if (!n || !i)
    return { source: null, columns: o, predicate: s };
  const { type: a, scales: c, bin: u, pixelSize: l = 1 } = n;
  if (a === "point")
    s = (f) => f, o = Object.fromEntries(
      i.map((f) => [`${f}`, Ft(f)])
    );
  else if (a === "interval" && c) {
    const f = c.map((h) => oR(h, l, u));
    f.some((h) => !h) || (f.length === 1 ? (s = (h) => h ? In("active0", h.range.map(f[0])) : [], o = { active0: f[0](r.field) }) : (s = (h) => h ? ki(h.children.map(
      ({ range: d }, p) => In(`active${p}`, d.map(f[p]))
    )) : [], o = Object.fromEntries(
      // @ts-ignore
      r.children.map((h, d) => [`active${d}`, f[d](h.field)])
    )));
  }
  return { source: o ? t : null, columns: o, predicate: s };
}
const sR = { ceil: "CEIL", round: "ROUND" };
function oR(e, t, n) {
  const { type: r, domain: i, range: s, apply: o, sqlApply: a } = Jx(e);
  if (!o) return;
  const c = sR[`${n}`.toLowerCase()] || "FLOOR", u = o(Math.min(...i)), l = o(Math.max(...i)), f = r === "identity" ? 1 : Math.abs(s[1] - s[0]) / (l - u), h = f / t === 1 ? "" : `${f / t}::DOUBLE * `, d = u === 0 ? "" : ` - ${u}::DOUBLE`;
  return (p) => j`${c}(${h}(${a(p)}${d}))::INTEGER`;
}
function aR(e, t, n) {
  const { dims: r, aggr: i, aux: s } = n, { columns: o } = t, a = e.select({ ...o, ...s }).groupby(Object.keys(o)), [c] = a.subqueries;
  if (c) {
    const p = Object.values(o).flatMap((y) => y.columns);
    cR(c, p);
  }
  const u = a.orderby();
  a.query.orderby = [];
  const l = a.toString(), h = `cube_index_${(tR(l) >>> 0).toString(16)}`, d = xt.select(r, i).from(h).groupby(r).orderby(u);
  return new uR({ table: h, create: l, active: t, select: d });
}
function cR(e, t) {
  const n = /* @__PURE__ */ new Set(), r = (i) => {
    n.has(i) || (n.add(i), i.select && i.from().length && i.select(t), i.subqueries.forEach(r));
  };
  r(e);
}
class uR {
  /**
   * Create a new DataCubeInfo instance.
   * @param {object} options
   */
  constructor({ table: t, create: n, active: r, select: i } = {}) {
    this.table = t, this.create = n, this.result = null, this.active = r, this.select = i, this.skip = !1;
  }
  /**
   * Generate a data cube index table query for the given predicate.
   * @param {import('@uwdata/mosaic-sql').SQLExpression} predicate The current
   *  active clause predicate.
   * @returns {Query} A data cube index table query.
   */
  query(t) {
    return this.select.clone().where(this.active.predicate(t));
  }
}
class Nm extends Promise {
  /**
   * Create a new query result Promise.
   */
  constructor() {
    let t, n;
    super((r, i) => {
      t = r, n = i;
    }), this._resolve = t, this._reject = n;
  }
  /**
   * Resolve the result Promise with the provided value.
   * @param {*} value The result value.
   * @returns {this}
   */
  fulfill(t) {
    return this._resolve(t), this;
  }
  /**
   * Rejects the result Promise with the provided error.
   * @param {*} error The error value.
   * @returns {this}
   */
  reject(t) {
    return this._reject(t), this;
  }
}
Nm.prototype.constructor = Promise;
function lR(e) {
  return (typeof requestAnimationFrame < "u" ? requestAnimationFrame : typeof setImmediate < "u" ? setImmediate : setTimeout)(e);
}
function fR(e, t, n) {
  let r = [], i = 0;
  function s() {
    const o = hR(r, t);
    r = [], i = 0;
    for (const a of o)
      pR(a, e, n), gR(a, t);
  }
  return {
    add(o, a) {
      o.request.type === "arrow" ? (i = i || lR(() => s()), r.push({ entry: o, priority: a, index: r.length })) : e(o, a);
    }
  };
}
function hR(e, t) {
  const n = [], r = /* @__PURE__ */ new Map();
  for (const i of e) {
    const { entry: { request: s } } = i, o = dR(s.query, t);
    if (!r.has(o)) {
      const a = [];
      n.push(a), r.set(o, a);
    }
    r.get(o).push(i);
  }
  return n;
}
function dR(e, t) {
  const n = `${e}`;
  if (e instanceof xt && !t.get(n)) {
    if (
      // @ts-ignore
      e.orderby().length || e.where().length || // @ts-ignore
      e.qualify().length || e.having().length
    )
      return n;
    const r = e.clone().$select("*"), i = e.groupby();
    if (i.length) {
      const s = {};
      e.select().forEach(({ as: o, expr: a }) => s[o] = a), r.$groupby(i.map((o) => o instanceof Ri && s[o.column] || o));
    }
    return `${r}`;
  } else
    return n;
}
function pR(e, t, n) {
  if (yR(e))
    t({
      request: {
        type: "arrow",
        cache: !1,
        record: !1,
        query: e.query = mR(e, n)
      },
      result: e.result = new Nm()
    });
  else
    for (const { entry: r, priority: i } of e)
      t(r, i);
}
function yR(e) {
  if (e.length > 1) {
    const t = `${e[0].entry.request.query}`;
    for (let n = 1; n < e.length; ++n)
      if (t !== `${e[n].entry.request.query}`)
        return !0;
  }
  return !1;
}
function mR(e, t) {
  const n = e.maps = [], r = /* @__PURE__ */ new Map();
  for (const o of e) {
    const { query: a } = o.entry.request, c = [];
    n.push(c);
    for (const { as: u, expr: l } of a.select()) {
      const f = `${l}`;
      r.has(f) || r.set(f, [`col${r.size}`, l]);
      const [h] = r.get(f);
      c.push([h, u]);
    }
    t(`${a}`);
  }
  const i = e[0].entry.request.query.clone(), s = i.groupby();
  if (s.length) {
    const o = {};
    e.maps[0].forEach(([a, c]) => o[c] = a), i.$groupby(s.map((a) => a instanceof Ri && o[a.column] || a));
  }
  return i.$select(Array.from(r.values()));
}
async function gR(e, t) {
  const { maps: n, query: r, result: i } = e;
  if (!n) return;
  let s;
  try {
    s = await i;
  } catch (a) {
    for (const { entry: c } of e)
      c.result.reject(a);
    return;
  }
  const o = RL(r);
  e.forEach(({ entry: a }, c) => {
    const { request: u, result: l } = a, f = n[c], h = o && f ? wR(s, f) : f ? bR(s, f) : s;
    u.cache && t.set(String(u.query), h), l.fulfill(h);
  });
}
function bR(e, t) {
  const n = {};
  for (const [r, i] of t)
    n[i] = e.getChild(r);
  return new e.constructor(n);
}
function wR(e, t) {
  const n = new Map(t), r = [];
  for (const i of e)
    n.has(i.column_name) && r.push({ ...i, column_name: n.get(i.column_name) });
  return r;
}
const _R = typeof requestIdleCallback < "u" ? requestIdleCallback : setTimeout, vR = () => ({
  get: () => {
  },
  set: (e, t) => t,
  clear: () => {
  }
});
function xR({
  max: e = 1e3,
  // max entries
  ttl: t = 3 * 60 * 60 * 1e3
  // time-to-live, default 3 hours
} = {}) {
  let n = /* @__PURE__ */ new Map();
  function r() {
    const i = performance.now() - t;
    let s = null, o = 1 / 0;
    for (const [a, c] of n) {
      const { last: u } = c;
      u < o && (s = a, o = u), i > u && n.delete(a);
    }
    s && n.delete(s);
  }
  return {
    get(i) {
      const s = n.get(i);
      if (s)
        return s.last = performance.now(), s.value;
    },
    set(i, s) {
      return n.set(i, { last: performance.now(), value: s }), n.size > e && _R(r), s;
    },
    clear() {
      n = /* @__PURE__ */ new Map();
    }
  };
}
function SR(e) {
  const t = Array.from(
    { length: e },
    () => ({ head: null, tail: null })
  );
  return {
    /**
     * Indicate if the queue is empty.
     * @returns [boolean] true if empty, false otherwise.
     */
    isEmpty() {
      return t.every((n) => !n.head);
    },
    /**
     * Insert an item into the queue with a given priority rank.
     * @param {*} item The item to add.
     * @param {number} rank The integer priority rank.
     *  Priority ranks are integers starting at zero.
     *  Lower ranks indicate higher priority.
     */
    insert(n, r) {
      const i = t[r];
      if (!i)
        throw new Error(`Invalid queue priority rank: ${r}`);
      const s = { item: n, next: null };
      i.head === null ? i.head = i.tail = s : i.tail = i.tail.next = s;
    },
    /**
     * Remove a set of items from the queue, regardless of priority rank.
     * If a provided item is not in the queue it will be ignored.
     * @param {(item: *) => boolean} test A predicate function to test
     * 	if an item should be removed (true to drop, false to keep).
     */
    remove(n) {
      for (const r of t) {
        let { head: i, tail: s } = r;
        for (let o = null, a = i; a; o = a, a = a.next)
          n(a.item) && (a === i ? i = a.next : o.next = a.next, a === s && (s = o || i));
        r.head = i, r.tail = s;
      }
    },
    /**
     * Remove and return the next highest priority item.
     * @returns {*} The next item in the queue,
     *  or undefined if this queue is empty.
     */
    next() {
      for (const n of t) {
        const { head: r } = n;
        if (r !== null)
          return n.head = r.next, n.tail === r && (n.tail = null), r.item;
      }
    }
  };
}
const _i = { High: 0, Normal: 1, Low: 2 };
class MR {
  constructor() {
    this.queue = SR(3), this.db = null, this.clientCache = null, this._logger = null, this._logQueries = !1, this.recorders = [], this.pending = null, this._consolidate = null;
  }
  next() {
    if (this.pending || this.queue.isEmpty()) return;
    const { request: t, result: n } = this.queue.next();
    this.pending = this.submit(t, n), this.pending.finally(() => {
      this.pending = null, this.next();
    });
  }
  enqueue(t, n = _i.Normal) {
    this.queue.insert(t, n), this.next();
  }
  recordQuery(t) {
    this.recorders.length && t && this.recorders.forEach((n) => n.add(t));
  }
  async submit(t, n) {
    try {
      const { query: r, type: i, cache: s = !1, record: o = !0, options: a } = t, c = r ? `${r}` : null;
      if (o && this.recordQuery(c), s) {
        const f = this.clientCache.get(c);
        if (f) {
          this._logger.debug("Cache"), n.fulfill(f);
          return;
        }
      }
      const u = performance.now();
      this._logQueries && this._logger.debug("Query", { type: i, sql: c, ...a });
      const l = await this.db.query({ type: i, sql: c, ...a });
      s && this.clientCache.set(c, l), this._logger.debug(`Request: ${(performance.now() - u).toFixed(1)}`), n.fulfill(l);
    } catch (r) {
      n.reject(r);
    }
  }
  cache(t) {
    return t !== void 0 ? this.clientCache = t === !0 ? xR() : t || vR() : this.clientCache;
  }
  logger(t) {
    return t ? this._logger = t : this._logger;
  }
  logQueries(t) {
    return t !== void 0 ? this._logQueries = !!t : this._logQueries;
  }
  connector(t) {
    return t ? this.db = t : this.db;
  }
  consolidate(t) {
    t && !this._consolidate ? this._consolidate = fR(this.enqueue.bind(this), this.clientCache, this.recordQuery.bind(this)) : !t && this._consolidate && (this._consolidate = null);
  }
  request(t, n = _i.Normal) {
    const r = new Nm(), i = { request: t, result: r };
    return this._consolidate ? this._consolidate.add(i, n) : this.enqueue(i, n), r;
  }
  cancel(t) {
    const n = new Set(t);
    n.size && this.queue.remove(({ result: r }) => n.has(r));
  }
  clear() {
    this.queue.remove(({ result: t }) => (t.reject("Cleared"), !0));
  }
  record() {
    let t = [];
    const n = {
      add(r) {
        t.push(r);
      },
      reset() {
        t = [];
      },
      snapshot() {
        return t.slice();
      },
      stop() {
        return this.recorders = this.recorders.filter((r) => r !== n), t;
      }
    };
    return this.recorders.push(n), n;
  }
}
function rS(e) {
  switch (e) {
    case "BIGINT":
    case "HUGEINT":
    case "INTEGER":
    case "SMALLINT":
    case "TINYINT":
    case "UBIGINT":
    case "UINTEGER":
    case "USMALLINT":
    case "UTINYINT":
    case "DOUBLE":
    case "FLOAT":
    case "REAL":
      return "number";
    case "DATE":
    case "TIMESTAMP":
    case "TIMESTAMPTZ":
    case "TIMESTAMP WITH TIME ZONE":
    case "TIME":
    case "TIMESTAMP_NS":
      return "date";
    case "BOOLEAN":
      return "boolean";
    case "VARCHAR":
    case "UUID":
    case "JSON":
      return "string";
    case "ARRAY":
    case "LIST":
      return "array";
    case "BLOB":
    case "STRUCT":
    case "MAP":
    case "GEOMETRY":
      return "object";
    default:
      if (e.startsWith("DECIMAL"))
        return "number";
      if (e.startsWith("STRUCT") || e.startsWith("MAP"))
        return "object";
      if (e.endsWith("]"))
        return "array";
      throw new Error(`Unsupported type: ${e}`);
  }
}
function AR(e) {
  return typeof (e == null ? void 0 : e.getChild) == "function";
}
function $R(e) {
  if (Q.isTimestamp(e))
    return (t) => t == null ? t : new Date(t);
  if (Q.isInt(e) && e.bitWidth >= 64)
    return (t) => t == null ? t : Number(t);
  if (Q.isDecimal(e)) {
    const t = 1 / Math.pow(10, e.scale);
    return (n) => n == null ? n : iS(n, t);
  }
  return (t) => t;
}
function IR(e) {
  const { type: t } = e;
  if (Q.isTimestamp(t)) {
    const n = e.length, r = new Array(n);
    for (let i = 0; i < n; ++i) {
      const s = e.get(i);
      r[i] = s == null ? null : new Date(s);
    }
    return r;
  }
  if (Q.isInt(t) && t.bitWidth >= 64) {
    const n = e.length, r = e.nullCount ? new Array(n) : new Float64Array(n);
    for (let i = 0; i < n; ++i) {
      const s = e.get(i);
      r[i] = s == null ? null : Number(s);
    }
    return r;
  }
  if (Q.isDecimal(t)) {
    const n = 1 / Math.pow(10, t.scale), r = e.length, i = e.nullCount ? new Array(r) : new Float64Array(r);
    for (let s = 0; s < r; ++s) {
      const o = e.get(s);
      i[s] = o == null ? null : iS(o, n);
    }
    return i;
  }
  return e.nullCount ? Array.from(e) : e.toArray();
}
const Cb = Array.from(
  { length: 8 },
  (e, t) => Math.pow(2, t * 32)
);
function iS(e, t) {
  const n = e.length;
  let r = 0;
  if (e.signed && (e[n - 1] | 0) < 0) {
    for (let i = 0; i < n; ++i)
      r += ~e[i] * Cb[i];
    r = -(r + 1);
  } else
    for (let i = 0; i < n; ++i)
      r += e[i] * Cb[i];
  return r * t;
}
const TR = "count", ER = "nulls", NR = "max", DR = "min", OR = "distinct", LR = {
  [TR]: Ni,
  [OR]: (e) => Ni(e).distinct(),
  [NR]: Vo,
  [DR]: Yo,
  [ER]: (e) => Ni().where(Am(e))
};
function RR(e, t, n) {
  return xt.from(e).select(Array.from(n, (r) => [r, LR[r](t)]));
}
async function kR(e, t) {
  return t.length === 1 && `${t[0].column}` == "*" ? BR(e, t[0].table) : (await Promise.all(t.map((n) => FR(e, n)))).filter((n) => n);
}
async function FR(e, { table: t, column: n, stats: r }) {
  const i = xt.from({ source: t }).select({ column: n }).groupby(n.aggregate ? j`ALL` : []), [s] = Array.from(await e.query(xt.describe(i))), o = {
    table: t,
    column: `${n}`,
    sqlType: s.column_type,
    type: rS(s.column_type),
    nullable: s.null === "YES"
  };
  if (!(r != null && r.length || r != null && r.size)) return o;
  const a = await e.query(
    RR(t, n, r),
    { persist: !0 }
  );
  for (let c = 0; c < a.numCols; ++c) {
    const { name: u } = a.schema.fields[c], l = a.getChildAt(c), f = $R(l.type);
    o[u] = f(l.get(0));
  }
  return o;
}
async function BR(e, t) {
  const n = await e.query(`DESCRIBE ${Bl(t)}`);
  return Array.from(n).map((r) => ({
    table: t,
    column: r.column_name,
    sqlType: r.column_type,
    type: rS(r.column_type),
    nullable: r.null === "YES"
  }));
}
function CR() {
  return {
    debug() {
    },
    info() {
    },
    log() {
    },
    warn() {
    },
    error() {
    }
  };
}
let Gu;
function Wr(e) {
  return e ? Gu = e : Gu == null && (Gu = new PR()), Gu;
}
class PR {
  constructor(t = $9(), {
    logger: n = console,
    manager: r = new MR(),
    cache: i = !0,
    consolidate: s = !0,
    indexes: o = {}
  } = {}) {
    this.manager = r, this.manager.cache(i), this.manager.consolidate(s), this.dataCubeIndexer = new rR(this, o), this.logger(n), this.databaseConnector(t), this.clear();
  }
  /**
   * Clear the coordinator state.
   * @param {object} [options] Options object.
   * @param {boolean} [options.clients=true] If true, disconnect all clients.
   * @param {boolean} [options.cache=true] If true, clear the query cache.
   */
  clear({ clients: t = !0, cache: n = !0 } = {}) {
    var r, i;
    this.manager.clear(), t && ((r = this.filterGroups) == null || r.forEach((s) => s.disconnect()), this.filterGroups = /* @__PURE__ */ new Map(), (i = this.clients) == null || i.forEach((s) => this.disconnect(s)), this.clients = /* @__PURE__ */ new Set()), n && this.manager.cache().clear();
  }
  /**
   * Get or set the database connector.
   * @param {*} [db] The database connector to use.
   * @returns The current database connector.
   */
  databaseConnector(t) {
    return this.manager.connector(t);
  }
  /**
   * Get or set the logger.
   * @param {*} logger  The logger to use.
   * @returns The current logger
   */
  logger(t) {
    return arguments.length && (this._logger = t || CR(), this.manager.logger(this._logger)), this._logger;
  }
  // -- Query Management ----
  /**
   * Cancel previosuly submitted query requests. These queries will be
   * canceled if they are queued but have not yet been submitted.
   * @param {import('./util/query-result.js').QueryResult[]} requests An array
   *  of query result objects, such as those returned by the `query` method.
   */
  cancel(t) {
    this.manager.cancel(t);
  }
  /**
   * Issue a query for which no result (return value) is needed.
   * @param {import('@uwdata/mosaic-sql').Query | string} query The query.
   * @param {object} [options] An options object.
   * @param {number} [options.priority] The query priority, defaults to
   *  `Priority.Normal`.
   * @returns {import('./util/query-result.js').QueryResult} A query result
   *  promise.
   */
  exec(t, { priority: n = _i.Normal } = {}) {
    return t = Array.isArray(t) ? t.join(`;
`) : t, this.manager.request({ type: "exec", query: t }, n);
  }
  /**
   * Issue a query to the backing database. The submitted query may be
   * consolidate with other queries and its results may be cached.
   * @param {import('@uwdata/mosaic-sql').Query | string} query The query.
   * @param {object} [options] An options object.
   * @param {'arrow' | 'json'} [options.type] The query result format type.
   * @param {boolean} [options.cache=true] If true, cache the query result.
   * @param {number} [options.priority] The query priority, defaults to
   *  `Priority.Normal`.
   * @returns {import('./util/query-result.js').QueryResult} A query result
   *  promise.
   */
  query(t, {
    type: n = "arrow",
    cache: r = !0,
    priority: i = _i.Normal,
    ...s
  } = {}) {
    return this.manager.request({ type: n, query: t, cache: r, options: s }, i);
  }
  /**
   * Issue a query to prefetch data for later use. The query result is cached
   * for efficient future access.
   * @param {import('@uwdata/mosaic-sql').Query | string} query The query.
   * @param {object} [options] An options object.
   * @param {'arrow' | 'json'} [options.type] The query result format type.
   * @returns {import('./util/query-result.js').QueryResult} A query result
   *  promise.
   */
  prefetch(t, n = {}) {
    return this.query(t, { ...n, cache: !0, priority: _i.Low });
  }
  createBundle(t, n, r = _i.Low) {
    const i = { name: t, queries: n };
    return this.manager.request({ type: "create-bundle", options: i }, r);
  }
  loadBundle(t, n = _i.High) {
    const r = { name: t };
    return this.manager.request({ type: "load-bundle", options: r }, n);
  }
  // -- Client Management ----
  /**
   * Update client data by submitting the given query and returning the
   * data (or error) to the client.
   * @param {import('./MosaicClient.js').MosaicClient} client A Mosaic client.
   * @param {import('@uwdata/mosaic-sql').Query | string} query The data query.
   * @param {number} [priority] The query priority.
   * @returns {Promise} A Promise that resolves upon completion of the update.
   */
  updateClient(t, n, r = _i.Normal) {
    return t.queryPending(), this.query(n, { priority: r }).then(
      (i) => t.queryResult(i).update(),
      (i) => {
        this._logger.error(i), t.queryError(i);
      }
    ).catch((i) => this._logger.error(i));
  }
  /**
   * Issue a query request for a client. If the query is null or undefined,
   * the client is simply updated. Otherwise `updateClient` is called. As a
   * side effect, this method clears the current data cube indexer state.
   * @param {import('./MosaicClient.js').MosaicClient} client The client
   *  to update.
   * @param {import('@uwdata/mosaic-sql').Query | string | null} [query]
   *  The query to issue.
   */
  requestQuery(t, n) {
    return this.dataCubeIndexer.clear(), n ? this.updateClient(t, n) : t.update();
  }
  /**
   * Connect a client to the coordinator.
   * @param {import('./MosaicClient.js').MosaicClient} client The Mosaic
   *  client to connect.
   */
  async connect(t) {
    const { clients: n } = this;
    if (n.has(t))
      throw new Error("Client already connected.");
    n.add(t), t.coordinator = this;
    const r = t.fields();
    r != null && r.length && t.fieldInfo(await kR(this, r)), UR(this, t.filterBy, t), t.requestQuery();
  }
  /**
   * Disconnect a client from the coordinator.
   * @param {import('./MosaicClient.js').MosaicClient} client The Mosaic
   *  client to disconnect.
   */
  disconnect(t) {
    const { clients: n, filterGroups: r } = this;
    if (!n.has(t)) return;
    n.delete(t), t.coordinator = null;
    const i = r.get(t.filterBy);
    i && i.clients.delete(t);
  }
}
function UR(e, t, n) {
  if (!t) return;
  let r = e.filterGroups.get(t);
  if (!r) {
    const i = (o) => zR(e, t, o), s = () => qR(e, t);
    t.addEventListener("activate", i), t.addEventListener("value", s), r = {
      selection: t,
      clients: /* @__PURE__ */ new Set(),
      disconnect() {
        t.removeEventListener("activate", i), t.removeEventListener("value", s);
      }
    }, e.filterGroups.set(t, r);
  }
  r.clients.add(n);
}
function zR(e, t, n) {
  const { dataCubeIndexer: r, filterGroups: i } = e, { clients: s } = i.get(t);
  for (const o of s)
    r.index(o, t, n);
}
function qR(e, t) {
  const { dataCubeIndexer: n, filterGroups: r } = e, { clients: i } = r.get(t), { active: s } = t;
  return Promise.allSettled(Array.from(i, (o) => {
    const a = n.index(o, t, s), c = a ? null : t.predicate(o);
    if (a != null && a.skip || !a && !c) return;
    const u = (a == null ? void 0 : a.query(s.predicate)) ?? o.query(c);
    return e.updateClient(o, u);
  }));
}
class jR {
  /**
   * Create a new asynchronous dispatcher instance.
   */
  constructor() {
    this._callbacks = /* @__PURE__ */ new Map();
  }
  /**
   * Add an event listener callback for the provided event type.
   * @param {string} type The event type.
   * @param {(value: *) => void | Promise} callback The event handler
   *  callback function to add. If the callback has already been
   *  added for the event type, this method has no effect.
   */
  addEventListener(t, n) {
    this._callbacks.has(t) || this._callbacks.set(t, {
      callbacks: /* @__PURE__ */ new Set(),
      pending: null,
      queue: new VR()
    }), this._callbacks.get(t).callbacks.add(n);
  }
  /**
   * Remove an event listener callback for the provided event type.
   * @param {string} type The event type.
   * @param {(value: *) => void | Promise} callback The event handler
   *  callback function to remove.
   */
  removeEventListener(t, n) {
    const r = this._callbacks.get(t);
    r && r.callbacks.delete(n);
  }
  /**
   * Lifecycle method that returns the event value to emit.
   * This default implementation simply returns the input value as-is.
   * Subclasses may override this method to implement custom transformations
   * prior to emitting an event value to all listeners.
   * @param {string} type The event type.
   * @param {*} value The event value.
   * @returns The (possibly transformed) event value to emit.
   */
  willEmit(t, n) {
    return n;
  }
  /**
   * Lifecycle method that returns a filter function for updating the
   * queue of unemitted event values prior to enqueueing a new value.
   * This default implementation simply returns null, indicating that
   * any other unemitted event values should be dropped (that is, all
   * queued events are filtered).
   * @param {string} type The event type.
   * @param {*} value The new event value that will be enqueued.
   * @returns {(value: *) => boolean|null} A dispatch queue filter
   *  function, or null if all unemitted event values should be filtered.
   */
  emitQueueFilter(t, n) {
    return null;
  }
  /**
   * Cancel all unemitted event values for the given event type.
   * @param {string} type The event type.
   */
  cancel(t) {
    const n = this._callbacks.get(t);
    n == null || n.queue.clear();
  }
  /**
   * Returns a promise that resolves when any pending updates complete for
   * the event of the given type currently being processed. The Promise will
   * resolve immediately if the queue for the given event type is empty.
   * @param {string} type The event type to wait for.
   * @returns {Promise} A pending event promise.
   */
  async pending(t) {
    var n;
    await ((n = this._callbacks.get(t)) == null ? void 0 : n.pending);
  }
  /**
   * Emit an event value to listeners for the given event type.
   * If a previous emit has not yet resolved, the event value
   * will be queued to be emitted later.
   * The actual event value given to listeners will be the result
   * of passing the input value through the emitValue() method.
   * @param {string} type The event type.
   * @param {*} value The event value.
   */
  emit(t, n) {
    const r = this._callbacks.get(t) || {};
    if (r.pending)
      r.queue.enqueue(n, this.emitQueueFilter(t, n));
    else {
      const i = this.willEmit(t, n), { callbacks: s, queue: o } = r;
      if (s != null && s.size) {
        const a = Array.from(s, (c) => c(i));
        r.pending = Promise.allSettled(a).then(() => {
          r.pending = null, o.isEmpty() || this.emit(t, o.dequeue());
        });
      }
    }
  }
}
class VR {
  /**
   * Create a new dispatch queue instance.
   */
  constructor() {
    this.clear();
  }
  /**
   * Clear the queue state of all event values.
   */
  clear() {
    this.next = null;
  }
  /**
   * Indicate if the queue is empty.
   * @returns {boolean} True if queue is empty, false otherwise.
   */
  isEmpty() {
    return !this.next;
  }
  /**
   * Add a new value to the queue, and optionally filter the
   * current queue content in response.
   * @param {*} value The value to add.
   * @param {(value: *) => boolean} [filter] An optional filter
   *  function to apply to existing queue content. If unspecified
   *  or falsy, all previously queued values are removed. Otherwise,
   *  the provided function is applied to all queue entries. The
   *  entry is retained if the filter function returns a truthy value,
   *  otherwise the entry is removed.
   */
  enqueue(t, n) {
    const r = { value: t };
    if (n && this.next) {
      let i = this;
      for (; i.next; )
        n(i.next.value) ? i = i.next : i.next = i.next.next;
      i.next = r;
    } else
      this.next = r;
  }
  /**
   * Remove and return the next queued event value.
   * @returns {*} The next event value in the queue.
   */
  dequeue() {
    const { next: t } = this;
    return this.next = t == null ? void 0 : t.next, t == null ? void 0 : t.value;
  }
}
function sS(e, t) {
  return e === t ? !1 : e instanceof Date && t instanceof Date ? +e != +t : Array.isArray(e) && Array.isArray(t) ? YR(e, t) : !0;
}
function YR(e, t) {
  if (e.length !== t.length) return !0;
  for (let n = 0; n < e.length; ++n)
    if (e[n] !== t[n]) return !0;
  return !1;
}
function Di(e) {
  return e instanceof ms;
}
class ms extends jR {
  /**
   * Create a new Param instance.
   * @param {*} value The initial value of the Param.
   */
  constructor(t) {
    super(), this._value = t;
  }
  /**
   * Create a new Param instance with the given initial value.
   * @param {*} value The initial value of the Param.
   * @returns {Param} The new Param instance.
   */
  static value(t) {
    return new ms(t);
  }
  /**
   * Create a new Param instance over an array of initial values,
   * which may contain nested Params.
   * @param {*} values The initial values of the Param.
   * @returns {Param} The new Param instance.
   */
  static array(t) {
    if (t.some((n) => Di(n))) {
      const n = new ms(), r = () => {
        n.update(t.map((i) => Di(i) ? i.value : i));
      };
      return r(), t.forEach((i) => Di(i) ? i.addEventListener("value", r) : 0), n;
    }
    return new ms(t);
  }
  /**
   * The current value of the Param.
   */
  get value() {
    return this._value;
  }
  /**
   * Update the Param value
   * @param {*} value The new value of the Param.
   * @param {object} [options] The update options.
   * @param {boolean} [options.force] A boolean flag indicating if the Param
   *  should emit a 'value' event even if the internal value is unchanged.
   * @returns {this} This Param instance.
   */
  update(t, { force: n } = {}) {
    return sS(this._value, t) || n ? this.emit("value", t) : this.cancel("value"), this;
  }
  /**
   * Upon value-typed updates, sets the current value to the input value
   * immediately prior to the event value being emitted to listeners.
   * @param {string} type The event type.
   * @param {*} value The input event value.
   * @returns {*} The input event value.
   */
  willEmit(t, n) {
    return t === "value" && (this._value = n), n;
  }
}
function hr(e) {
  return e instanceof Df;
}
let Df = class po extends ms {
  /**
   * Create a new Selection instance with an
   * intersect (conjunction) resolution strategy.
   * @param {object} [options] The selection options.
   * @param {boolean} [options.cross=false] Boolean flag indicating
   *  cross-filtered resolution. If true, selection clauses will not
   *  be applied to the clients they are associated with.
   * @param {boolean} [options.empty=false] Boolean flag indicating if a lack
   *  of clauses should correspond to an empty selection with no records. This
   *  setting determines the default selection state.
   * @returns {Selection} The new Selection instance.
   */
  static intersect({ cross: t = !1, empty: n = !1 } = {}) {
    return new po(new Da({ cross: t, empty: n }));
  }
  /**
   * Create a new Selection instance with a
   * union (disjunction) resolution strategy.
   * @param {object} [options] The selection options.
   * @param {boolean} [options.cross=false] Boolean flag indicating
   *  cross-filtered resolution. If true, selection clauses will not
   *  be applied to the clients they are associated with.
   * @param {boolean} [options.empty=false] Boolean flag indicating if a lack
   *  of clauses should correspond to an empty selection with no records. This
   *  setting determines the default selection state.
   * @returns {Selection} The new Selection instance.
   */
  static union({ cross: t = !1, empty: n = !1 } = {}) {
    return new po(new Da({ cross: t, empty: n, union: !0 }));
  }
  /**
   * Create a new Selection instance with a singular resolution strategy
   * that keeps only the most recent selection clause.
   * @param {object} [options] The selection options.
   * @param {boolean} [options.cross=false] Boolean flag indicating
   *  cross-filtered resolution. If true, selection clauses will not
   *  be applied to the clients they are associated with.
   * @param {boolean} [options.empty=false] Boolean flag indicating if a lack
   *  of clauses should correspond to an empty selection with no records. This
   *  setting determines the default selection state.
   * @returns {Selection} The new Selection instance.
   */
  static single({ cross: t = !1, empty: n = !1 } = {}) {
    return new po(new Da({ cross: t, empty: n, single: !0 }));
  }
  /**
   * Create a new Selection instance with a
   * cross-filtered intersect resolution strategy.
   * @param {object} [options] The selection options.
   * @param {boolean} [options.empty=false] Boolean flag indicating if a lack
   *  of clauses should correspond to an empty selection with no records. This
   *  setting determines the default selection state.
   * @returns {Selection} The new Selection instance.
   */
  static crossfilter({ empty: t = !1 } = {}) {
    return new po(new Da({ cross: !0, empty: t }));
  }
  /**
   * Create a new Selection instance.
   * @param {SelectionResolver} resolver The selection resolution
   *  strategy to apply.
   */
  constructor(t = new Da()) {
    super([]), this._resolved = this._value, this._resolver = t;
  }
  /**
   * Create a cloned copy of this Selection instance.
   * @returns {Selection} A clone of this selection.
   */
  clone() {
    const t = new po(this._resolver);
    return t._value = t._resolved = this._value, t;
  }
  /**
   * Create a clone of this Selection with clauses corresponding
   * to the provided source removed.
   * @param {*} source The clause source to remove.
   * @returns {Selection} A cloned and updated Selection.
   */
  remove(t) {
    const n = this.clone();
    return n._value = n._resolved = n._resolver.resolve(this._resolved, { source: t }), n._value.active = { source: t }, n;
  }
  /**
   * The selection clause resolver.
   */
  get resolver() {
    return this._resolver;
  }
  /**
   * Indicate if this selection has a single resolution strategy.
   */
  get single() {
    return this._resolver.single;
  }
  /**
   * The current array of selection clauses.
   */
  get clauses() {
    return super.value;
  }
  /**
   * The current active (most recently updated) selection clause.
   */
  get active() {
    return this.clauses.active;
  }
  /**
   * The value corresponding to the current active selection clause.
   * This method ensures compatibility where a normal Param is expected.
   */
  get value() {
    var t;
    return (t = this.active) == null ? void 0 : t.value;
  }
  /**
   * The value corresponding to a given source. Returns undefined if
   * this selection does not include a clause from this source.
   * @param {*} source The clause source to look up the value for.
   */
  valueFor(t) {
    var n;
    return (n = this.clauses.find((r) => r.source === t)) == null ? void 0 : n.value;
  }
  /**
   * Emit an activate event with the given selection clause.
   * @param {*} clause The clause repesenting the potential activation.
   */
  activate(t) {
    this.emit("activate", t);
  }
  /**
   * Update the selection with a new selection clause.
   * @param {*} clause The selection clause to add.
   * @returns {this} This Selection instance.
   */
  update(t) {
    return this._resolved = this._resolver.resolve(this._resolved, t, !0), this._resolved.active = t, super.update(this._resolved);
  }
  /**
   * Upon value-typed updates, sets the current clause list to the
   * input value and returns the active clause value.
   * @param {string} type The event type.
   * @param {*} value The input event value.
   * @returns {*} For value-typed events, returns the active clause
   *  values. Otherwise returns the input event value as-is.
   */
  willEmit(t, n) {
    return t === "value" ? (this._value = n, this.value) : n;
  }
  /**
   * Upon value-typed updates, returns a dispatch queue filter function.
   * The return value depends on the selection resolution strategy.
   * @param {string} type The event type.
   * @param {*} value The new event value that will be enqueued.
   * @returns {(value: *) => boolean|null} For value-typed events,
   *  returns a dispatch queue filter function. Otherwise returns null.
   */
  emitQueueFilter(t, n) {
    return t === "value" ? this._resolver.queueFilter(n) : null;
  }
  /**
   * Indicates if a selection clause should not be applied to a given client.
   * The return value depends on the selection resolution strategy.
   * @param {*} client The selection clause.
   * @param {*} clause The client to test.
   * @returns True if the client should be skipped, false otherwise.
   */
  skip(t, n) {
    return this._resolver.skip(t, n);
  }
  /**
   * Return a selection query predicate for the given client.
   * @param {*} client The client whose data may be filtered.
   * @param {boolean} [noSkip=false] Disable skipping of active
   *  cross-filtered sources. If set true, the source of the active
   *  clause in a cross-filtered selection will not be skipped.
   * @returns {*} The query predicate for filtering client data,
   *  based on the current state of this selection.
   */
  predicate(t, n = !1) {
    const { clauses: r } = this, i = n ? null : r.active;
    return this._resolver.predicate(r, i, t);
  }
};
class Da {
  /**
   * Create a new selection resolved instance.
   * @param {object} [options] The resolution strategy options.
   * @param {boolean} [options.union=false] Boolean flag to indicate a union strategy.
   *  If false, an intersection strategy is used.
   * @param {boolean} [options.cross=false] Boolean flag to indicate cross-filtering.
   * @param {boolean} [options.single=false] Boolean flag to indicate single clauses only.
   * @param {boolean} [options.empty=false] Boolean flag indicating if a lack
   *  of clauses should correspond to an empty selection with no records. This
   *  setting determines the default selection state.
   */
  constructor({ union: t, cross: n, single: r, empty: i } = {}) {
    this.union = !!t, this.cross = !!n, this.single = !!r, this.empty = !!i;
  }
  /**
   * Resolve a list of selection clauses according to the resolution strategy.
   * @param {*[]} clauseList An array of selection clauses.
   * @param {*} clause A new selection clause to add.
   * @returns {*[]} An updated array of selection clauses.
   */
  resolve(t, n, r = !1) {
    const { source: i, predicate: s } = n, o = t.filter((c) => i !== c.source), a = this.single ? [] : o;
    return this.single && r && o.forEach((c) => {
      var u, l;
      return (l = (u = c.source) == null ? void 0 : u.reset) == null ? void 0 : l.call(u);
    }), s && a.push(n), a;
  }
  /**
   * Indicates if a selection clause should not be applied to a given client.
   * The return value depends on the resolution strategy.
   * @param {*} client The selection clause.
   * @param {*} clause The client to test.
   * @returns True if the client should be skipped, false otherwise.
   */
  skip(t, n) {
    var r;
    return this.cross && ((r = n == null ? void 0 : n.clients) == null ? void 0 : r.has(t));
  }
  /**
   * Return a selection query predicate for the given client.
   * @param {*[]} clauseList An array of selection clauses.
   * @param {*} active The current active selection clause.
   * @param {*} client The client whose data may be filtered.
   * @returns {*} The query predicate for filtering client data,
   *  based on the current state of this selection.
   */
  predicate(t, n, r) {
    const { empty: i, union: s } = this;
    if (i && !t.length)
      return ["FALSE"];
    if (this.skip(r, n)) return;
    const o = t.filter((a) => !this.skip(r, a)).map((a) => a.predicate);
    return s && o.length > 1 ? Mm(o) : o;
  }
  /**
   * Returns a filter function for queued selection updates.
   * @param {*} value The new event value that will be enqueued.
   * @returns {(value: *) => boolean|null} A dispatch queue filter
   *  function, or null if all unemitted event values should be filtered.
   */
  queueFilter(t) {
    var n;
    if (this.cross) {
      const r = (n = t.active) == null ? void 0 : n.source;
      return (i) => {
        var s;
        return ((s = i.active) == null ? void 0 : s.source) !== r;
      };
    }
    return null;
  }
}
function oS(e, t, {
  source: n,
  clients: r = n ? /* @__PURE__ */ new Set([n]) : void 0
}) {
  const i = t !== void 0 ? Im(e, Hh(t)) : null;
  return {
    meta: { type: "point" },
    source: n,
    clients: r,
    value: t,
    predicate: i
  };
}
function Dm(e, t, {
  source: n,
  clients: r = n ? /* @__PURE__ */ new Set([n]) : void 0
}) {
  let i = null;
  if (t) {
    const s = t.map((o) => {
      const a = o.map((c, u) => Im(e[u], Hh(c)));
      return a.length > 1 ? ki(a) : a[0];
    });
    i = s.length > 1 ? Mm(s) : s[0];
  }
  return {
    meta: { type: "point" },
    source: n,
    clients: r,
    value: t,
    predicate: i
  };
}
function Om(e, t, {
  source: n,
  clients: r = n ? /* @__PURE__ */ new Set([n]) : void 0,
  bin: i,
  scale: s,
  pixelSize: o = 1
}) {
  const a = t != null ? In(e, t) : null;
  return { meta: { type: "interval", scales: s && [s], bin: i, pixelSize: o }, source: n, clients: r, value: t, predicate: a };
}
function WR(e, t, {
  source: n,
  clients: r = n ? /* @__PURE__ */ new Set([n]) : void 0,
  bin: i,
  scales: s = [],
  pixelSize: o = 1
}) {
  const a = t != null ? ki(e.map((u, l) => In(u, t[l]))) : null;
  return { meta: { type: "interval", scales: s, bin: i, pixelSize: o }, source: n, clients: r, value: t, predicate: a };
}
const XR = { contains: C9, prefix: P9, suffix: U9, regexp: B9 };
function GR(e, t, {
  source: n,
  clients: r = void 0,
  method: i = "contains"
}) {
  let s = XR[i];
  const o = t ? s(e, Hh(t)) : null;
  return { meta: { type: "match", method: i }, source: n, clients: r, value: t, predicate: o };
}
function HR() {
  const e = /* @__PURE__ */ new Set();
  let t, n = new Promise((r) => t = r);
  return {
    /**
     * Mark an item as pending.
     * @param {*} item An item to synchronize on.
     */
    pending(r) {
      e.add(r);
    },
    /**
     * Mark a pending item as ready, indicating it is
     * ready for a synchronized update.
     * @param {*} item An item to synchronize on.
     * @returns {boolean} True if the synchronizer is ready to
     *  resolve, false otherwise.
     */
    ready(r) {
      return e.delete(r), e.size === 0;
    },
    /**
     * Resolve the current synchronization cycle, causing the synchronize
     * promise to resolve and thereby trigger downstream updates.
     */
    resolve() {
      n = new Promise((r) => {
        t(), t = r;
      });
    },
    /**
     * The promise for the current synchronization cycle.
     * @return {Promise} The synchronization promise.
     */
    get promise() {
      return n;
    }
  };
}
function $s(e) {
  return AR(e) ? JR(e) : ZR(e);
}
function JR(e) {
  const { numRows: t, numCols: n, schema: { fields: r } } = e, i = {};
  for (let s = 0; s < n; ++s) {
    const o = r[s].name;
    i[o] ? console.warn(`Redundant column name "${o}". Skipping...`) : i[o] = IR(e.getChildAt(s));
  }
  return { numRows: t, columns: i };
}
function ZR(e) {
  const t = e.length;
  if (typeof e[0] == "object") {
    const n = t ? Object.keys(e[0]) : [], r = {};
    return n.length > 0 && n.forEach((i) => {
      r[i] = e.map((s) => s[i]);
    }), { numRows: t, columns: r };
  } else
    return { numRows: t, values: e };
}
const uu = Symbol("Fixed"), qn = Symbol("Transient"), aS = Symbol("Transform");
function zt(e, t) {
  return e == null || t == null ? NaN : e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN;
}
function Is(e, t) {
  return e == null || t == null ? NaN : t < e ? -1 : t > e ? 1 : t >= e ? 0 : NaN;
}
function lu(e) {
  let t, n, r;
  e.length !== 2 ? (t = zt, n = (a, c) => zt(e(a), c), r = (a, c) => e(a) - c) : (t = e === zt || e === Is ? e : KR, n = e, r = e);
  function i(a, c, u = 0, l = a.length) {
    if (u < l) {
      if (t(c, c) !== 0) return l;
      do {
        const f = u + l >>> 1;
        n(a[f], c) < 0 ? u = f + 1 : l = f;
      } while (u < l);
    }
    return u;
  }
  function s(a, c, u = 0, l = a.length) {
    if (u < l) {
      if (t(c, c) !== 0) return l;
      do {
        const f = u + l >>> 1;
        n(a[f], c) <= 0 ? u = f + 1 : l = f;
      } while (u < l);
    }
    return u;
  }
  function o(a, c, u = 0, l = a.length) {
    const f = i(a, c, u, l - 1);
    return f > u && r(a[f - 1], c) > -r(a[f], c) ? f - 1 : f;
  }
  return { left: i, center: o, right: s };
}
function KR() {
  return 0;
}
function cS(e) {
  return e === null ? NaN : +e;
}
function* QR(e, t) {
  if (t === void 0)
    for (let n of e)
      n != null && (n = +n) >= n && (yield n);
  else {
    let n = -1;
    for (let r of e)
      (r = t(r, ++n, e)) != null && (r = +r) >= r && (yield r);
  }
}
const tk = lu(zt), Zh = tk.right;
lu(cS).center;
const uS = lS(fS), ek = lS(nk);
function lS(e) {
  return function(t, n, r = n) {
    if (!((n = +n) >= 0)) throw new RangeError("invalid rx");
    if (!((r = +r) >= 0)) throw new RangeError("invalid ry");
    let { data: i, width: s, height: o } = t;
    if (!((s = Math.floor(s)) >= 0)) throw new RangeError("invalid width");
    if (!((o = Math.floor(o !== void 0 ? o : i.length / s)) >= 0)) throw new RangeError("invalid height");
    if (!s || !o || !n && !r) return t;
    const a = n && e(n), c = r && e(r), u = i.slice();
    return a && c ? (Ws(a, u, i, s, o), Ws(a, i, u, s, o), Ws(a, u, i, s, o), Xs(c, i, u, s, o), Xs(c, u, i, s, o), Xs(c, i, u, s, o)) : a ? (Ws(a, i, u, s, o), Ws(a, u, i, s, o), Ws(a, i, u, s, o)) : c && (Xs(c, i, u, s, o), Xs(c, u, i, s, o), Xs(c, i, u, s, o)), t;
  };
}
function Ws(e, t, n, r, i) {
  for (let s = 0, o = r * i; s < o; )
    e(t, n, s, s += r, 1);
}
function Xs(e, t, n, r, i) {
  for (let s = 0, o = r * i; s < r; ++s)
    e(t, n, s, s + o, r);
}
function nk(e) {
  const t = fS(e);
  return (n, r, i, s, o) => {
    i <<= 2, s <<= 2, o <<= 2, t(n, r, i + 0, s + 0, o), t(n, r, i + 1, s + 1, o), t(n, r, i + 2, s + 2, o), t(n, r, i + 3, s + 3, o);
  };
}
function fS(e) {
  const t = Math.floor(e);
  if (t === e) return rk(e);
  const n = e - t, r = 2 * e + 1;
  return (i, s, o, a, c) => {
    if (!((a -= c) >= o)) return;
    let u = t * s[o];
    const l = c * t, f = l + c;
    for (let h = o, d = o + l; h < d; h += c)
      u += s[Math.min(a, h)];
    for (let h = o, d = a; h <= d; h += c)
      u += s[Math.min(a, h + l)], i[h] = (u + n * (s[Math.max(o, h - f)] + s[Math.min(a, h + f)])) / r, u -= s[Math.max(o, h - l)];
  };
}
function rk(e) {
  const t = 2 * e + 1;
  return (n, r, i, s, o) => {
    if (!((s -= o) >= i)) return;
    let a = e * r[i];
    const c = o * e;
    for (let u = i, l = i + c; u < l; u += o)
      a += r[Math.min(s, u)];
    for (let u = i, l = s; u <= l; u += o)
      a += r[Math.min(s, u + c)], n[u] = a / t, a -= r[Math.max(i, u - c)];
  };
}
function Kh(e, t) {
  let n = 0;
  if (t === void 0)
    for (let r of e)
      r != null && (r = +r) >= r && ++n;
  else {
    let r = -1;
    for (let i of e)
      (i = t(i, ++r, e)) != null && (i = +i) >= i && ++n;
  }
  return n;
}
function ik(e) {
  return e.length | 0;
}
function sk(e) {
  return !(e > 0);
}
function ok(e) {
  return typeof e != "object" || "length" in e ? e : Array.from(e);
}
function ak(e) {
  return (t) => e(...t);
}
function ck(...e) {
  const t = typeof e[e.length - 1] == "function" && ak(e.pop());
  e = e.map(ok);
  const n = e.map(ik), r = e.length - 1, i = new Array(r + 1).fill(0), s = [];
  if (r < 0 || n.some(sk)) return s;
  for (; ; ) {
    s.push(i.map((a, c) => e[c][a]));
    let o = r;
    for (; ++i[o] === n[o]; ) {
      if (o === 0) return t ? s.map(t) : s;
      i[o--] = 0;
    }
  }
}
function uk(e, t) {
  var n = 0, r = 0;
  return Float64Array.from(e, t === void 0 ? (i) => n += +i || 0 : (i) => n += +t(i, r++, e) || 0);
}
function Lm(e, t) {
  let n = 0, r, i = 0, s = 0;
  if (t === void 0)
    for (let o of e)
      o != null && (o = +o) >= o && (r = o - i, i += r / ++n, s += r * (o - i));
  else {
    let o = -1;
    for (let a of e)
      (a = t(a, ++o, e)) != null && (a = +a) >= a && (r = a - i, i += r / ++n, s += r * (a - i));
  }
  if (n > 1) return s / (n - 1);
}
function fu(e, t) {
  const n = Lm(e, t);
  return n && Math.sqrt(n);
}
function pe(e, t) {
  let n, r;
  if (t === void 0)
    for (const i of e)
      i != null && (n === void 0 ? i >= i && (n = r = i) : (n > i && (n = i), r < i && (r = i)));
  else {
    let i = -1;
    for (let s of e)
      (s = t(s, ++i, e)) != null && (n === void 0 ? s >= s && (n = r = s) : (n > s && (n = s), r < s && (r = s)));
  }
  return [n, r];
}
class dr {
  constructor() {
    this._partials = new Float64Array(32), this._n = 0;
  }
  add(t) {
    const n = this._partials;
    let r = 0;
    for (let i = 0; i < this._n && i < 32; i++) {
      const s = n[i], o = t + s, a = Math.abs(t) < Math.abs(s) ? t - (o - s) : s - (o - t);
      a && (n[r++] = a), t = o;
    }
    return n[r] = t, this._n = r + 1, this;
  }
  valueOf() {
    const t = this._partials;
    let n = this._n, r, i, s, o = 0;
    if (n > 0) {
      for (o = t[--n]; n > 0 && (r = o, i = t[--n], o = r + i, s = i - (o - r), !s); )
        ;
      n > 0 && (s < 0 && t[n - 1] < 0 || s > 0 && t[n - 1] > 0) && (i = s * 2, r = o + i, i == r - o && (o = r));
    }
    return o;
  }
}
class Ts extends Map {
  constructor(t, n = pS) {
    if (super(), Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: n } }), t != null) for (const [r, i] of t) this.set(r, i);
  }
  get(t) {
    return super.get(R0(this, t));
  }
  has(t) {
    return super.has(R0(this, t));
  }
  set(t, n) {
    return super.set(hS(this, t), n);
  }
  delete(t) {
    return super.delete(dS(this, t));
  }
}
class pa extends Set {
  constructor(t, n = pS) {
    if (super(), Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: n } }), t != null) for (const r of t) this.add(r);
  }
  has(t) {
    return super.has(R0(this, t));
  }
  add(t) {
    return super.add(hS(this, t));
  }
  delete(t) {
    return super.delete(dS(this, t));
  }
}
function R0({ _intern: e, _key: t }, n) {
  const r = t(n);
  return e.has(r) ? e.get(r) : n;
}
function hS({ _intern: e, _key: t }, n) {
  const r = t(n);
  return e.has(r) ? e.get(r) : (e.set(r, n), n);
}
function dS({ _intern: e, _key: t }, n) {
  const r = t(n);
  return e.has(r) && (n = e.get(r), e.delete(r)), n;
}
function pS(e) {
  return e !== null && typeof e == "object" ? e.valueOf() : e;
}
function k0(e) {
  return e;
}
function ci(e, ...t) {
  return Rm(e, k0, k0, t);
}
function To(e, t, ...n) {
  return Rm(e, k0, t, n);
}
function lk(e, t, ...n) {
  return Rm(e, Array.from, t, n);
}
function Rm(e, t, n, r) {
  return function i(s, o) {
    if (o >= r.length) return n(s);
    const a = new Ts(), c = r[o++];
    let u = -1;
    for (const l of s) {
      const f = c(l, ++u, s), h = a.get(f);
      h ? h.push(l) : a.set(f, [l]);
    }
    for (const [l, f] of a)
      a.set(l, i(f, o));
    return t(a);
  }(e, 0);
}
function fk(e, t) {
  return Array.from(t, (n) => e[n]);
}
function Of(e, ...t) {
  if (typeof e[Symbol.iterator] != "function") throw new TypeError("values is not iterable");
  e = Array.from(e);
  let [n] = t;
  if (n && n.length !== 2 || t.length > 1) {
    const r = Uint32Array.from(e, (i, s) => s);
    return t.length > 1 ? (t = t.map((i) => e.map(i)), r.sort((i, s) => {
      for (const o of t) {
        const a = Dc(o[i], o[s]);
        if (a) return a;
      }
    })) : (n = e.map(n), r.sort((i, s) => Dc(n[i], n[s]))), fk(e, r);
  }
  return e.sort(km(n));
}
function km(e = zt) {
  if (e === zt) return Dc;
  if (typeof e != "function") throw new TypeError("compare is not a function");
  return (t, n) => {
    const r = e(t, n);
    return r || r === 0 ? r : (e(n, n) === 0) - (e(t, t) === 0);
  };
}
function Dc(e, t) {
  return (e == null || !(e >= e)) - (t == null || !(t >= t)) || (e < t ? -1 : e > t ? 1 : 0);
}
function Fm(e, t, n) {
  return (t.length !== 2 ? Of(To(e, t, n), ([r, i], [s, o]) => zt(i, o) || zt(r, s)) : Of(ci(e, n), ([r, i], [s, o]) => t(i, o) || zt(r, s))).map(([r]) => r);
}
const hk = Math.sqrt(50), dk = Math.sqrt(10), pk = Math.sqrt(2);
function Lf(e, t, n) {
  const r = (t - e) / Math.max(0, n), i = Math.floor(Math.log10(r)), s = r / Math.pow(10, i), o = s >= hk ? 10 : s >= dk ? 5 : s >= pk ? 2 : 1;
  let a, c, u;
  return i < 0 ? (u = Math.pow(10, -i) / o, a = Math.round(e * u), c = Math.round(t * u), a / u < e && ++a, c / u > t && --c, u = -u) : (u = Math.pow(10, i) * o, a = Math.round(e / u), c = Math.round(t / u), a * u < e && ++a, c * u > t && --c), c < a && 0.5 <= n && n < 2 ? Lf(e, t, n * 2) : [a, c, u];
}
function Fi(e, t, n) {
  if (t = +t, e = +e, n = +n, !(n > 0)) return [];
  if (e === t) return [e];
  const r = t < e, [i, s, o] = r ? Lf(t, e, n) : Lf(e, t, n);
  if (!(s >= i)) return [];
  const a = s - i + 1, c = new Array(a);
  if (r)
    if (o < 0) for (let u = 0; u < a; ++u) c[u] = (s - u) / -o;
    else for (let u = 0; u < a; ++u) c[u] = (s - u) * o;
  else if (o < 0) for (let u = 0; u < a; ++u) c[u] = (i + u) / -o;
  else for (let u = 0; u < a; ++u) c[u] = (i + u) * o;
  return c;
}
function Oc(e, t, n) {
  return t = +t, e = +e, n = +n, Lf(e, t, n)[2];
}
function F0(e, t, n) {
  t = +t, e = +e, n = +n;
  const r = t < e, i = r ? Oc(t, e, n) : Oc(e, t, n);
  return (r ? -1 : 1) * (i < 0 ? 1 / -i : i);
}
function yS(e, t, n) {
  let r;
  for (; ; ) {
    const i = Oc(e, t, n);
    if (i === r || i === 0 || !isFinite(i))
      return [e, t];
    i > 0 ? (e = Math.floor(e / i) * i, t = Math.ceil(t / i) * i) : i < 0 && (e = Math.ceil(e * i) / i, t = Math.floor(t * i) / i), r = i;
  }
}
function Bm(e) {
  return Math.max(1, Math.ceil(Math.log(Kh(e)) / Math.LN2) + 1);
}
function ce(e, t) {
  let n;
  if (t === void 0)
    for (const r of e)
      r != null && (n < r || n === void 0 && r >= r) && (n = r);
  else {
    let r = -1;
    for (let i of e)
      (i = t(i, ++r, e)) != null && (n < i || n === void 0 && i >= i) && (n = i);
  }
  return n;
}
function yk(e, t) {
  let n, r = -1, i = -1;
  if (t === void 0)
    for (const s of e)
      ++i, s != null && (n < s || n === void 0 && s >= s) && (n = s, r = i);
  else
    for (let s of e)
      (s = t(s, ++i, e)) != null && (n < s || n === void 0 && s >= s) && (n = s, r = i);
  return r;
}
function ve(e, t) {
  let n;
  if (t === void 0)
    for (const r of e)
      r != null && (n > r || n === void 0 && r >= r) && (n = r);
  else {
    let r = -1;
    for (let i of e)
      (i = t(i, ++r, e)) != null && (n > i || n === void 0 && i >= i) && (n = i);
  }
  return n;
}
function mk(e, t) {
  let n, r = -1, i = -1;
  if (t === void 0)
    for (const s of e)
      ++i, s != null && (n > s || n === void 0 && s >= s) && (n = s, r = i);
  else
    for (let s of e)
      (s = t(s, ++i, e)) != null && (n > s || n === void 0 && s >= s) && (n = s, r = i);
  return r;
}
function mS(e, t, n = 0, r = 1 / 0, i) {
  if (t = Math.floor(t), n = Math.floor(Math.max(0, n)), r = Math.floor(Math.min(e.length - 1, r)), !(n <= t && t <= r)) return e;
  for (i = i === void 0 ? Dc : km(i); r > n; ) {
    if (r - n > 600) {
      const c = r - n + 1, u = t - n + 1, l = Math.log(c), f = 0.5 * Math.exp(2 * l / 3), h = 0.5 * Math.sqrt(l * f * (c - f) / c) * (u - c / 2 < 0 ? -1 : 1), d = Math.max(n, Math.floor(t - u * f / c + h)), p = Math.min(r, Math.floor(t + (c - u) * f / c + h));
      mS(e, t, d, p, i);
    }
    const s = e[t];
    let o = n, a = r;
    for (Oa(e, n, t), i(e[r], s) > 0 && Oa(e, n, r); o < a; ) {
      for (Oa(e, o, a), ++o, --a; i(e[o], s) < 0; ) ++o;
      for (; i(e[a], s) > 0; ) --a;
    }
    i(e[n], s) === 0 ? Oa(e, n, a) : (++a, Oa(e, a, r)), a <= t && (n = a + 1), t <= a && (r = a - 1);
  }
  return e;
}
function Oa(e, t, n) {
  const r = e[t];
  e[t] = e[n], e[n] = r;
}
function Cm(e, t = zt) {
  let n, r = !1;
  if (t.length === 1) {
    let i;
    for (const s of e) {
      const o = t(s);
      (r ? zt(o, i) > 0 : zt(o, o) === 0) && (n = s, i = o, r = !0);
    }
  } else
    for (const i of e)
      (r ? t(i, n) > 0 : t(i, i) === 0) && (n = i, r = !0);
  return n;
}
function Bi(e, t, n) {
  if (e = Float64Array.from(QR(e, n)), !(!(r = e.length) || isNaN(t = +t))) {
    if (t <= 0 || r < 2) return ve(e);
    if (t >= 1) return ce(e);
    var r, i = (r - 1) * t, s = Math.floor(i), o = ce(mS(e, s).subarray(0, s + 1)), a = ve(e.subarray(s + 1));
    return o + (a - o) * (i - s);
  }
}
function gk(e, t, n = cS) {
  if (!(!(r = e.length) || isNaN(t = +t))) {
    if (t <= 0 || r < 2) return +n(e[0], 0, e);
    if (t >= 1) return +n(e[r - 1], r - 1, e);
    var r, i = (r - 1) * t, s = Math.floor(i), o = +n(e[s], s, e), a = +n(e[s + 1], s + 1, e);
    return o + (a - o) * (i - s);
  }
}
function bk(e, t, n) {
  const r = Kh(e), i = Bi(e, 0.75) - Bi(e, 0.25);
  return r && i ? Math.ceil((n - t) / (2 * i * Math.pow(r, -1 / 3))) : 1;
}
function gS(e, t, n) {
  const r = Kh(e), i = fu(e);
  return r && i ? Math.ceil((n - t) * Math.cbrt(r) / (3.49 * i)) : 1;
}
function Qh(e, t) {
  let n = 0, r = 0;
  if (t === void 0)
    for (let i of e)
      i != null && (i = +i) >= i && (++n, r += i);
  else {
    let i = -1;
    for (let s of e)
      (s = t(s, ++i, e)) != null && (s = +s) >= s && (++n, r += s);
  }
  if (n) return r / n;
}
function Lc(e, t) {
  return Bi(e, 0.5, t);
}
function* wk(e) {
  for (const t of e)
    yield* t;
}
function bS(e) {
  return Array.from(wk(e));
}
function wS(e, t) {
  const n = new Ts();
  if (t === void 0)
    for (let s of e)
      s != null && s >= s && n.set(s, (n.get(s) || 0) + 1);
  else {
    let s = -1;
    for (let o of e)
      (o = t(o, ++s, e)) != null && o >= o && n.set(o, (n.get(o) || 0) + 1);
  }
  let r, i = 0;
  for (const [s, o] of n)
    o > i && (i = o, r = s);
  return r;
}
function _k(e, t = vk) {
  const n = [];
  let r, i = !1;
  for (const s of e)
    i && n.push(t(r, s)), r = s, i = !0;
  return n;
}
function vk(e, t) {
  return [e, t];
}
function sn(e, t, n) {
  e = +e, t = +t, n = (i = arguments.length) < 2 ? (t = e, e = 0, 1) : i < 3 ? 1 : +n;
  for (var r = -1, i = Math.max(0, Math.ceil((t - e) / n)) | 0, s = new Array(i); ++r < i; )
    s[r] = e + r * n;
  return s;
}
function _S(e, t = zt) {
  if (typeof e[Symbol.iterator] != "function") throw new TypeError("values is not iterable");
  let n = Array.from(e);
  const r = new Float64Array(n.length);
  t.length !== 2 && (n = n.map(t), t = zt);
  const i = (a, c) => t(n[a], n[c]);
  let s, o;
  return e = Uint32Array.from(n, (a, c) => c), e.sort(t === zt ? (a, c) => Dc(n[a], n[c]) : km(i)), e.forEach((a, c) => {
    const u = i(a, s === void 0 ? a : s);
    u >= 0 ? ((s === void 0 || u > 0) && (s = a, o = c), r[a] = o) : r[a] = NaN;
  }), r;
}
function xk(e, t = zt) {
  let n, r = !1;
  if (t.length === 1) {
    let i;
    for (const s of e) {
      const o = t(s);
      (r ? zt(o, i) < 0 : zt(o, o) === 0) && (n = s, i = o, r = !0);
    }
  } else
    for (const i of e)
      (r ? t(i, n) < 0 : t(i, i) === 0) && (n = i, r = !0);
  return n;
}
function br(e, t) {
  let n = 0;
  if (t === void 0)
    for (let r of e)
      (r = +r) && (n += r);
  else {
    let r = -1;
    for (let i of e)
      (i = +t(i, ++r, e)) && (n += i);
  }
  return n;
}
function Rf(e) {
  if (typeof e[Symbol.iterator] != "function") throw new TypeError("values is not iterable");
  return Array.from(e).reverse();
}
function Sk(e) {
  return e;
}
var hp = 1, dp = 2, B0 = 3, Hu = 4, Pb = 1e-6;
function Mk(e) {
  return "translate(" + e + ",0)";
}
function Ak(e) {
  return "translate(0," + e + ")";
}
function $k(e) {
  return (t) => +e(t);
}
function Ik(e, t) {
  return t = Math.max(0, e.bandwidth() - t * 2) / 2, e.round() && (t = Math.round(t)), (n) => +e(n) + t;
}
function Tk() {
  return !this.__axis;
}
function Ek(e, t) {
  var n = [], r = null, i = null, s = 6, o = 6, a = 3, c = typeof window < "u" && window.devicePixelRatio > 1 ? 0 : 0.5, u = e === hp || e === Hu ? -1 : 1, l = e === Hu || e === dp ? "x" : "y", f = e === hp || e === B0 ? Mk : Ak;
  function h(d) {
    var p = r ?? (t.ticks ? t.ticks.apply(t, n) : t.domain()), y = i ?? (t.tickFormat ? t.tickFormat.apply(t, n) : Sk), m = Math.max(s, 0) + a, g = t.range(), b = +g[0] + c, w = +g[g.length - 1] + c, _ = (t.bandwidth ? Ik : $k)(t.copy(), c), x = d.selection ? d.selection() : d, v = x.selectAll(".domain").data([null]), M = x.selectAll(".tick").data(p, t).order(), E = M.exit(), $ = M.enter().append("g").attr("class", "tick"), N = M.select("line"), A = M.select("text");
    v = v.merge(v.enter().insert("path", ".tick").attr("class", "domain").attr("stroke", "currentColor")), M = M.merge($), N = N.merge($.append("line").attr("stroke", "currentColor").attr(l + "2", u * s)), A = A.merge($.append("text").attr("fill", "currentColor").attr(l, u * m).attr("dy", e === hp ? "0em" : e === B0 ? "0.71em" : "0.32em")), d !== x && (v = v.transition(d), M = M.transition(d), N = N.transition(d), A = A.transition(d), E = E.transition(d).attr("opacity", Pb).attr("transform", function(D) {
      return isFinite(D = _(D)) ? f(D + c) : this.getAttribute("transform");
    }), $.attr("opacity", Pb).attr("transform", function(D) {
      var k = this.parentNode.__axis;
      return f((k && isFinite(k = k(D)) ? k : _(D)) + c);
    })), E.remove(), v.attr("d", e === Hu || e === dp ? o ? "M" + u * o + "," + b + "H" + c + "V" + w + "H" + u * o : "M" + c + "," + b + "V" + w : o ? "M" + b + "," + u * o + "V" + c + "H" + w + "V" + u * o : "M" + b + "," + c + "H" + w), M.attr("opacity", 1).attr("transform", function(D) {
      return f(_(D) + c);
    }), N.attr(l + "2", u * s), A.attr(l, u * m).text(y), x.filter(Tk).attr("fill", "none").attr("font-size", 10).attr("font-family", "sans-serif").attr("text-anchor", e === dp ? "start" : e === Hu ? "end" : "middle"), x.each(function() {
      this.__axis = _;
    });
  }
  return h.scale = function(d) {
    return arguments.length ? (t = d, h) : t;
  }, h.ticks = function() {
    return n = Array.from(arguments), h;
  }, h.tickArguments = function(d) {
    return arguments.length ? (n = d == null ? [] : Array.from(d), h) : n.slice();
  }, h.tickValues = function(d) {
    return arguments.length ? (r = d == null ? null : Array.from(d), h) : r && r.slice();
  }, h.tickFormat = function(d) {
    return arguments.length ? (i = d, h) : i;
  }, h.tickSize = function(d) {
    return arguments.length ? (s = o = +d, h) : s;
  }, h.tickSizeInner = function(d) {
    return arguments.length ? (s = +d, h) : s;
  }, h.tickSizeOuter = function(d) {
    return arguments.length ? (o = +d, h) : o;
  }, h.tickPadding = function(d) {
    return arguments.length ? (a = +d, h) : a;
  }, h.offset = function(d) {
    return arguments.length ? (c = +d, h) : c;
  }, h;
}
function Nk(e) {
  return Ek(B0, e);
}
var Dk = { value: () => {
} };
function td() {
  for (var e = 0, t = arguments.length, n = {}, r; e < t; ++e) {
    if (!(r = arguments[e] + "") || r in n || /[\s.]/.test(r)) throw new Error("illegal type: " + r);
    n[r] = [];
  }
  return new zl(n);
}
function zl(e) {
  this._ = e;
}
function Ok(e, t) {
  return e.trim().split(/^|\s+/).map(function(n) {
    var r = "", i = n.indexOf(".");
    if (i >= 0 && (r = n.slice(i + 1), n = n.slice(0, i)), n && !t.hasOwnProperty(n)) throw new Error("unknown type: " + n);
    return { type: n, name: r };
  });
}
zl.prototype = td.prototype = {
  constructor: zl,
  on: function(e, t) {
    var n = this._, r = Ok(e + "", n), i, s = -1, o = r.length;
    if (arguments.length < 2) {
      for (; ++s < o; ) if ((i = (e = r[s]).type) && (i = Lk(n[i], e.name))) return i;
      return;
    }
    if (t != null && typeof t != "function") throw new Error("invalid callback: " + t);
    for (; ++s < o; )
      if (i = (e = r[s]).type) n[i] = Ub(n[i], e.name, t);
      else if (t == null) for (i in n) n[i] = Ub(n[i], e.name, null);
    return this;
  },
  copy: function() {
    var e = {}, t = this._;
    for (var n in t) e[n] = t[n].slice();
    return new zl(e);
  },
  call: function(e, t) {
    if ((i = arguments.length - 2) > 0) for (var n = new Array(i), r = 0, i, s; r < i; ++r) n[r] = arguments[r + 2];
    if (!this._.hasOwnProperty(e)) throw new Error("unknown type: " + e);
    for (s = this._[e], r = 0, i = s.length; r < i; ++r) s[r].value.apply(t, n);
  },
  apply: function(e, t, n) {
    if (!this._.hasOwnProperty(e)) throw new Error("unknown type: " + e);
    for (var r = this._[e], i = 0, s = r.length; i < s; ++i) r[i].value.apply(t, n);
  }
};
function Lk(e, t) {
  for (var n = 0, r = e.length, i; n < r; ++n)
    if ((i = e[n]).name === t)
      return i.value;
}
function Ub(e, t, n) {
  for (var r = 0, i = e.length; r < i; ++r)
    if (e[r].name === t) {
      e[r] = Dk, e = e.slice(0, r).concat(e.slice(r + 1));
      break;
    }
  return n != null && e.push({ name: t, value: n }), e;
}
var C0 = "http://www.w3.org/1999/xhtml";
const Es = {
  svg: "http://www.w3.org/2000/svg",
  xhtml: C0,
  xlink: "http://www.w3.org/1999/xlink",
  xml: "http://www.w3.org/XML/1998/namespace",
  xmlns: "http://www.w3.org/2000/xmlns/"
};
function ed(e) {
  var t = e += "", n = t.indexOf(":");
  return n >= 0 && (t = e.slice(0, n)) !== "xmlns" && (e = e.slice(n + 1)), Es.hasOwnProperty(t) ? { space: Es[t], local: e } : e;
}
function Rk(e) {
  return function() {
    var t = this.ownerDocument, n = this.namespaceURI;
    return n === C0 && t.documentElement.namespaceURI === C0 ? t.createElement(e) : t.createElementNS(n, e);
  };
}
function kk(e) {
  return function() {
    return this.ownerDocument.createElementNS(e.space, e.local);
  };
}
function nd(e) {
  var t = ed(e);
  return (t.local ? kk : Rk)(t);
}
function Fk() {
}
function Pm(e) {
  return e == null ? Fk : function() {
    return this.querySelector(e);
  };
}
function Bk(e) {
  typeof e != "function" && (e = Pm(e));
  for (var t = this._groups, n = t.length, r = new Array(n), i = 0; i < n; ++i)
    for (var s = t[i], o = s.length, a = r[i] = new Array(o), c, u, l = 0; l < o; ++l)
      (c = s[l]) && (u = e.call(c, c.__data__, l, s)) && ("__data__" in c && (u.__data__ = c.__data__), a[l] = u);
  return new cn(r, this._parents);
}
function Ck(e) {
  return e == null ? [] : Array.isArray(e) ? e : Array.from(e);
}
function Pk() {
  return [];
}
function vS(e) {
  return e == null ? Pk : function() {
    return this.querySelectorAll(e);
  };
}
function Uk(e) {
  return function() {
    return Ck(e.apply(this, arguments));
  };
}
function zk(e) {
  typeof e == "function" ? e = Uk(e) : e = vS(e);
  for (var t = this._groups, n = t.length, r = [], i = [], s = 0; s < n; ++s)
    for (var o = t[s], a = o.length, c, u = 0; u < a; ++u)
      (c = o[u]) && (r.push(e.call(c, c.__data__, u, o)), i.push(c));
  return new cn(r, i);
}
function xS(e) {
  return function() {
    return this.matches(e);
  };
}
function SS(e) {
  return function(t) {
    return t.matches(e);
  };
}
var qk = Array.prototype.find;
function jk(e) {
  return function() {
    return qk.call(this.children, e);
  };
}
function Vk() {
  return this.firstElementChild;
}
function Yk(e) {
  return this.select(e == null ? Vk : jk(typeof e == "function" ? e : SS(e)));
}
var Wk = Array.prototype.filter;
function Xk() {
  return Array.from(this.children);
}
function Gk(e) {
  return function() {
    return Wk.call(this.children, e);
  };
}
function Hk(e) {
  return this.selectAll(e == null ? Xk : Gk(typeof e == "function" ? e : SS(e)));
}
function Jk(e) {
  typeof e != "function" && (e = xS(e));
  for (var t = this._groups, n = t.length, r = new Array(n), i = 0; i < n; ++i)
    for (var s = t[i], o = s.length, a = r[i] = [], c, u = 0; u < o; ++u)
      (c = s[u]) && e.call(c, c.__data__, u, s) && a.push(c);
  return new cn(r, this._parents);
}
function MS(e) {
  return new Array(e.length);
}
function Zk() {
  return new cn(this._enter || this._groups.map(MS), this._parents);
}
function kf(e, t) {
  this.ownerDocument = e.ownerDocument, this.namespaceURI = e.namespaceURI, this._next = null, this._parent = e, this.__data__ = t;
}
kf.prototype = {
  constructor: kf,
  appendChild: function(e) {
    return this._parent.insertBefore(e, this._next);
  },
  insertBefore: function(e, t) {
    return this._parent.insertBefore(e, t);
  },
  querySelector: function(e) {
    return this._parent.querySelector(e);
  },
  querySelectorAll: function(e) {
    return this._parent.querySelectorAll(e);
  }
};
function Kk(e) {
  return function() {
    return e;
  };
}
function Qk(e, t, n, r, i, s) {
  for (var o = 0, a, c = t.length, u = s.length; o < u; ++o)
    (a = t[o]) ? (a.__data__ = s[o], r[o] = a) : n[o] = new kf(e, s[o]);
  for (; o < c; ++o)
    (a = t[o]) && (i[o] = a);
}
function tF(e, t, n, r, i, s, o) {
  var a, c, u = /* @__PURE__ */ new Map(), l = t.length, f = s.length, h = new Array(l), d;
  for (a = 0; a < l; ++a)
    (c = t[a]) && (h[a] = d = o.call(c, c.__data__, a, t) + "", u.has(d) ? i[a] = c : u.set(d, c));
  for (a = 0; a < f; ++a)
    d = o.call(e, s[a], a, s) + "", (c = u.get(d)) ? (r[a] = c, c.__data__ = s[a], u.delete(d)) : n[a] = new kf(e, s[a]);
  for (a = 0; a < l; ++a)
    (c = t[a]) && u.get(h[a]) === c && (i[a] = c);
}
function eF(e) {
  return e.__data__;
}
function nF(e, t) {
  if (!arguments.length) return Array.from(this, eF);
  var n = t ? tF : Qk, r = this._parents, i = this._groups;
  typeof e != "function" && (e = Kk(e));
  for (var s = i.length, o = new Array(s), a = new Array(s), c = new Array(s), u = 0; u < s; ++u) {
    var l = r[u], f = i[u], h = f.length, d = rF(e.call(l, l && l.__data__, u, r)), p = d.length, y = a[u] = new Array(p), m = o[u] = new Array(p), g = c[u] = new Array(h);
    n(l, f, y, m, g, d, t);
    for (var b = 0, w = 0, _, x; b < p; ++b)
      if (_ = y[b]) {
        for (b >= w && (w = b + 1); !(x = m[w]) && ++w < p; ) ;
        _._next = x || null;
      }
  }
  return o = new cn(o, r), o._enter = a, o._exit = c, o;
}
function rF(e) {
  return typeof e == "object" && "length" in e ? e : Array.from(e);
}
function iF() {
  return new cn(this._exit || this._groups.map(MS), this._parents);
}
function sF(e, t, n) {
  var r = this.enter(), i = this, s = this.exit();
  return typeof e == "function" ? (r = e(r), r && (r = r.selection())) : r = r.append(e + ""), t != null && (i = t(i), i && (i = i.selection())), n == null ? s.remove() : n(s), r && i ? r.merge(i).order() : i;
}
function oF(e) {
  for (var t = e.selection ? e.selection() : e, n = this._groups, r = t._groups, i = n.length, s = r.length, o = Math.min(i, s), a = new Array(i), c = 0; c < o; ++c)
    for (var u = n[c], l = r[c], f = u.length, h = a[c] = new Array(f), d, p = 0; p < f; ++p)
      (d = u[p] || l[p]) && (h[p] = d);
  for (; c < i; ++c)
    a[c] = n[c];
  return new cn(a, this._parents);
}
function aF() {
  for (var e = this._groups, t = -1, n = e.length; ++t < n; )
    for (var r = e[t], i = r.length - 1, s = r[i], o; --i >= 0; )
      (o = r[i]) && (s && o.compareDocumentPosition(s) ^ 4 && s.parentNode.insertBefore(o, s), s = o);
  return this;
}
function cF(e) {
  e || (e = uF);
  function t(f, h) {
    return f && h ? e(f.__data__, h.__data__) : !f - !h;
  }
  for (var n = this._groups, r = n.length, i = new Array(r), s = 0; s < r; ++s) {
    for (var o = n[s], a = o.length, c = i[s] = new Array(a), u, l = 0; l < a; ++l)
      (u = o[l]) && (c[l] = u);
    c.sort(t);
  }
  return new cn(i, this._parents).order();
}
function uF(e, t) {
  return e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN;
}
function lF() {
  var e = arguments[0];
  return arguments[0] = this, e.apply(null, arguments), this;
}
function fF() {
  return Array.from(this);
}
function hF() {
  for (var e = this._groups, t = 0, n = e.length; t < n; ++t)
    for (var r = e[t], i = 0, s = r.length; i < s; ++i) {
      var o = r[i];
      if (o) return o;
    }
  return null;
}
function dF() {
  let e = 0;
  for (const t of this) ++e;
  return e;
}
function pF() {
  return !this.node();
}
function yF(e) {
  for (var t = this._groups, n = 0, r = t.length; n < r; ++n)
    for (var i = t[n], s = 0, o = i.length, a; s < o; ++s)
      (a = i[s]) && e.call(a, a.__data__, s, i);
  return this;
}
function mF(e) {
  return function() {
    this.removeAttribute(e);
  };
}
function gF(e) {
  return function() {
    this.removeAttributeNS(e.space, e.local);
  };
}
function bF(e, t) {
  return function() {
    this.setAttribute(e, t);
  };
}
function wF(e, t) {
  return function() {
    this.setAttributeNS(e.space, e.local, t);
  };
}
function _F(e, t) {
  return function() {
    var n = t.apply(this, arguments);
    n == null ? this.removeAttribute(e) : this.setAttribute(e, n);
  };
}
function vF(e, t) {
  return function() {
    var n = t.apply(this, arguments);
    n == null ? this.removeAttributeNS(e.space, e.local) : this.setAttributeNS(e.space, e.local, n);
  };
}
function xF(e, t) {
  var n = ed(e);
  if (arguments.length < 2) {
    var r = this.node();
    return n.local ? r.getAttributeNS(n.space, n.local) : r.getAttribute(n);
  }
  return this.each((t == null ? n.local ? gF : mF : typeof t == "function" ? n.local ? vF : _F : n.local ? wF : bF)(n, t));
}
function AS(e) {
  return e.ownerDocument && e.ownerDocument.defaultView || e.document && e || e.defaultView;
}
function SF(e) {
  return function() {
    this.style.removeProperty(e);
  };
}
function MF(e, t, n) {
  return function() {
    this.style.setProperty(e, t, n);
  };
}
function AF(e, t, n) {
  return function() {
    var r = t.apply(this, arguments);
    r == null ? this.style.removeProperty(e) : this.style.setProperty(e, r, n);
  };
}
function $F(e, t, n) {
  return arguments.length > 1 ? this.each((t == null ? SF : typeof t == "function" ? AF : MF)(e, t, n ?? "")) : Wo(this.node(), e);
}
function Wo(e, t) {
  return e.style.getPropertyValue(t) || AS(e).getComputedStyle(e, null).getPropertyValue(t);
}
function IF(e) {
  return function() {
    delete this[e];
  };
}
function TF(e, t) {
  return function() {
    this[e] = t;
  };
}
function EF(e, t) {
  return function() {
    var n = t.apply(this, arguments);
    n == null ? delete this[e] : this[e] = n;
  };
}
function NF(e, t) {
  return arguments.length > 1 ? this.each((t == null ? IF : typeof t == "function" ? EF : TF)(e, t)) : this.node()[e];
}
function $S(e) {
  return e.trim().split(/^|\s+/);
}
function Um(e) {
  return e.classList || new IS(e);
}
function IS(e) {
  this._node = e, this._names = $S(e.getAttribute("class") || "");
}
IS.prototype = {
  add: function(e) {
    var t = this._names.indexOf(e);
    t < 0 && (this._names.push(e), this._node.setAttribute("class", this._names.join(" ")));
  },
  remove: function(e) {
    var t = this._names.indexOf(e);
    t >= 0 && (this._names.splice(t, 1), this._node.setAttribute("class", this._names.join(" ")));
  },
  contains: function(e) {
    return this._names.indexOf(e) >= 0;
  }
};
function TS(e, t) {
  for (var n = Um(e), r = -1, i = t.length; ++r < i; ) n.add(t[r]);
}
function ES(e, t) {
  for (var n = Um(e), r = -1, i = t.length; ++r < i; ) n.remove(t[r]);
}
function DF(e) {
  return function() {
    TS(this, e);
  };
}
function OF(e) {
  return function() {
    ES(this, e);
  };
}
function LF(e, t) {
  return function() {
    (t.apply(this, arguments) ? TS : ES)(this, e);
  };
}
function RF(e, t) {
  var n = $S(e + "");
  if (arguments.length < 2) {
    for (var r = Um(this.node()), i = -1, s = n.length; ++i < s; ) if (!r.contains(n[i])) return !1;
    return !0;
  }
  return this.each((typeof t == "function" ? LF : t ? DF : OF)(n, t));
}
function kF() {
  this.textContent = "";
}
function FF(e) {
  return function() {
    this.textContent = e;
  };
}
function BF(e) {
  return function() {
    var t = e.apply(this, arguments);
    this.textContent = t ?? "";
  };
}
function CF(e) {
  return arguments.length ? this.each(e == null ? kF : (typeof e == "function" ? BF : FF)(e)) : this.node().textContent;
}
function PF() {
  this.innerHTML = "";
}
function UF(e) {
  return function() {
    this.innerHTML = e;
  };
}
function zF(e) {
  return function() {
    var t = e.apply(this, arguments);
    this.innerHTML = t ?? "";
  };
}
function qF(e) {
  return arguments.length ? this.each(e == null ? PF : (typeof e == "function" ? zF : UF)(e)) : this.node().innerHTML;
}
function jF() {
  this.nextSibling && this.parentNode.appendChild(this);
}
function VF() {
  return this.each(jF);
}
function YF() {
  this.previousSibling && this.parentNode.insertBefore(this, this.parentNode.firstChild);
}
function WF() {
  return this.each(YF);
}
function XF(e) {
  var t = typeof e == "function" ? e : nd(e);
  return this.select(function() {
    return this.appendChild(t.apply(this, arguments));
  });
}
function GF() {
  return null;
}
function HF(e, t) {
  var n = typeof e == "function" ? e : nd(e), r = t == null ? GF : typeof t == "function" ? t : Pm(t);
  return this.select(function() {
    return this.insertBefore(n.apply(this, arguments), r.apply(this, arguments) || null);
  });
}
function JF() {
  var e = this.parentNode;
  e && e.removeChild(this);
}
function ZF() {
  return this.each(JF);
}
function KF() {
  var e = this.cloneNode(!1), t = this.parentNode;
  return t ? t.insertBefore(e, this.nextSibling) : e;
}
function QF() {
  var e = this.cloneNode(!0), t = this.parentNode;
  return t ? t.insertBefore(e, this.nextSibling) : e;
}
function tB(e) {
  return this.select(e ? QF : KF);
}
function eB(e) {
  return arguments.length ? this.property("__data__", e) : this.node().__data__;
}
function nB(e) {
  return function(t) {
    e.call(this, t, this.__data__);
  };
}
function rB(e) {
  return e.trim().split(/^|\s+/).map(function(t) {
    var n = "", r = t.indexOf(".");
    return r >= 0 && (n = t.slice(r + 1), t = t.slice(0, r)), { type: t, name: n };
  });
}
function iB(e) {
  return function() {
    var t = this.__on;
    if (t) {
      for (var n = 0, r = -1, i = t.length, s; n < i; ++n)
        s = t[n], (!e.type || s.type === e.type) && s.name === e.name ? this.removeEventListener(s.type, s.listener, s.options) : t[++r] = s;
      ++r ? t.length = r : delete this.__on;
    }
  };
}
function sB(e, t, n) {
  return function() {
    var r = this.__on, i, s = nB(t);
    if (r) {
      for (var o = 0, a = r.length; o < a; ++o)
        if ((i = r[o]).type === e.type && i.name === e.name) {
          this.removeEventListener(i.type, i.listener, i.options), this.addEventListener(i.type, i.listener = s, i.options = n), i.value = t;
          return;
        }
    }
    this.addEventListener(e.type, s, n), i = { type: e.type, name: e.name, value: t, listener: s, options: n }, r ? r.push(i) : this.__on = [i];
  };
}
function oB(e, t, n) {
  var r = rB(e + ""), i, s = r.length, o;
  if (arguments.length < 2) {
    var a = this.node().__on;
    if (a) {
      for (var c = 0, u = a.length, l; c < u; ++c)
        for (i = 0, l = a[c]; i < s; ++i)
          if ((o = r[i]).type === l.type && o.name === l.name)
            return l.value;
    }
    return;
  }
  for (a = t ? sB : iB, i = 0; i < s; ++i) this.each(a(r[i], t, n));
  return this;
}
function NS(e, t, n) {
  var r = AS(e), i = r.CustomEvent;
  typeof i == "function" ? i = new i(t, n) : (i = r.document.createEvent("Event"), n ? (i.initEvent(t, n.bubbles, n.cancelable), i.detail = n.detail) : i.initEvent(t, !1, !1)), e.dispatchEvent(i);
}
function aB(e, t) {
  return function() {
    return NS(this, e, t);
  };
}
function cB(e, t) {
  return function() {
    return NS(this, e, t.apply(this, arguments));
  };
}
function uB(e, t) {
  return this.each((typeof t == "function" ? cB : aB)(e, t));
}
function* lB() {
  for (var e = this._groups, t = 0, n = e.length; t < n; ++t)
    for (var r = e[t], i = 0, s = r.length, o; i < s; ++i)
      (o = r[i]) && (yield o);
}
var DS = [null];
function cn(e, t) {
  this._groups = e, this._parents = t;
}
function hu() {
  return new cn([[document.documentElement]], DS);
}
function fB() {
  return this;
}
cn.prototype = hu.prototype = {
  constructor: cn,
  select: Bk,
  selectAll: zk,
  selectChild: Yk,
  selectChildren: Hk,
  filter: Jk,
  data: nF,
  enter: Zk,
  exit: iF,
  join: sF,
  merge: oF,
  selection: fB,
  order: aF,
  sort: cF,
  call: lF,
  nodes: fF,
  node: hF,
  size: dF,
  empty: pF,
  each: yF,
  attr: xF,
  style: $F,
  property: NF,
  classed: RF,
  text: CF,
  html: qF,
  raise: VF,
  lower: WF,
  append: XF,
  insert: HF,
  remove: ZF,
  clone: tB,
  datum: eB,
  on: oB,
  dispatch: uB,
  [Symbol.iterator]: lB
};
function Wt(e) {
  return typeof e == "string" ? new cn([[document.querySelector(e)]], [document.documentElement]) : new cn([[e]], DS);
}
function hB(e) {
  let t;
  for (; t = e.sourceEvent; ) e = t;
  return e;
}
function Ln(e, t) {
  if (e = hB(e), t === void 0 && (t = e.currentTarget), t) {
    var n = t.ownerSVGElement || t;
    if (n.createSVGPoint) {
      var r = n.createSVGPoint();
      return r.x = e.clientX, r.y = e.clientY, r = r.matrixTransform(t.getScreenCTM().inverse()), [r.x, r.y];
    }
    if (t.getBoundingClientRect) {
      var i = t.getBoundingClientRect();
      return [e.clientX - i.left - t.clientLeft, e.clientY - i.top - t.clientTop];
    }
  }
  return [e.pageX, e.pageY];
}
const P0 = { capture: !0, passive: !1 };
function U0(e) {
  e.preventDefault(), e.stopImmediatePropagation();
}
function OS(e) {
  var t = e.document.documentElement, n = Wt(e).on("dragstart.drag", U0, P0);
  "onselectstart" in t ? n.on("selectstart.drag", U0, P0) : (t.__noselect = t.style.MozUserSelect, t.style.MozUserSelect = "none");
}
function LS(e, t) {
  var n = e.document.documentElement, r = Wt(e).on("dragstart.drag", null);
  t && (r.on("click.drag", U0, P0), setTimeout(function() {
    r.on("click.drag", null);
  }, 0)), "onselectstart" in n ? r.on("selectstart.drag", null) : (n.style.MozUserSelect = n.__noselect, delete n.__noselect);
}
function ya(e, t, n) {
  e.prototype = t.prototype = n, n.constructor = e;
}
function du(e, t) {
  var n = Object.create(e.prototype);
  for (var r in t) n[r] = t[r];
  return n;
}
function Xi() {
}
var Ns = 0.7, Xo = 1 / Ns, Eo = "\\s*([+-]?\\d+)\\s*", Rc = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", pr = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", dB = /^#([0-9a-f]{3,8})$/, pB = new RegExp(`^rgb\\(${Eo},${Eo},${Eo}\\)$`), yB = new RegExp(`^rgb\\(${pr},${pr},${pr}\\)$`), mB = new RegExp(`^rgba\\(${Eo},${Eo},${Eo},${Rc}\\)$`), gB = new RegExp(`^rgba\\(${pr},${pr},${pr},${Rc}\\)$`), bB = new RegExp(`^hsl\\(${Rc},${pr},${pr}\\)$`), wB = new RegExp(`^hsla\\(${Rc},${pr},${pr},${Rc}\\)$`), zb = {
  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
};
ya(Xi, Ci, {
  copy(e) {
    return Object.assign(new this.constructor(), this, e);
  },
  displayable() {
    return this.rgb().displayable();
  },
  hex: qb,
  // Deprecated! Use color.formatHex.
  formatHex: qb,
  formatHex8: _B,
  formatHsl: vB,
  formatRgb: jb,
  toString: jb
});
function qb() {
  return this.rgb().formatHex();
}
function _B() {
  return this.rgb().formatHex8();
}
function vB() {
  return RS(this).formatHsl();
}
function jb() {
  return this.rgb().formatRgb();
}
function Ci(e) {
  var t, n;
  return e = (e + "").trim().toLowerCase(), (t = dB.exec(e)) ? (n = t[1].length, t = parseInt(t[1], 16), n === 6 ? Vb(t) : n === 3 ? new _e(t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | t & 240, (t & 15) << 4 | t & 15, 1) : n === 8 ? Ju(t >> 24 & 255, t >> 16 & 255, t >> 8 & 255, (t & 255) / 255) : n === 4 ? Ju(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 = pB.exec(e)) ? new _e(t[1], t[2], t[3], 1) : (t = yB.exec(e)) ? new _e(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, 1) : (t = mB.exec(e)) ? Ju(t[1], t[2], t[3], t[4]) : (t = gB.exec(e)) ? Ju(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, t[4]) : (t = bB.exec(e)) ? Xb(t[1], t[2] / 100, t[3] / 100, 1) : (t = wB.exec(e)) ? Xb(t[1], t[2] / 100, t[3] / 100, t[4]) : zb.hasOwnProperty(e) ? Vb(zb[e]) : e === "transparent" ? new _e(NaN, NaN, NaN, 0) : null;
}
function Vb(e) {
  return new _e(e >> 16 & 255, e >> 8 & 255, e & 255, 1);
}
function Ju(e, t, n, r) {
  return r <= 0 && (e = t = n = NaN), new _e(e, t, n, r);
}
function zm(e) {
  return e instanceof Xi || (e = Ci(e)), e ? (e = e.rgb(), new _e(e.r, e.g, e.b, e.opacity)) : new _e();
}
function un(e, t, n, r) {
  return arguments.length === 1 ? zm(e) : new _e(e, t, n, r ?? 1);
}
function _e(e, t, n, r) {
  this.r = +e, this.g = +t, this.b = +n, this.opacity = +r;
}
ya(_e, un, du(Xi, {
  brighter(e) {
    return e = e == null ? Xo : Math.pow(Xo, e), new _e(this.r * e, this.g * e, this.b * e, this.opacity);
  },
  darker(e) {
    return e = e == null ? Ns : Math.pow(Ns, e), new _e(this.r * e, this.g * e, this.b * e, this.opacity);
  },
  rgb() {
    return this;
  },
  clamp() {
    return new _e(gs(this.r), gs(this.g), gs(this.b), Ff(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: Yb,
  // Deprecated! Use color.formatHex.
  formatHex: Yb,
  formatHex8: xB,
  formatRgb: Wb,
  toString: Wb
}));
function Yb() {
  return `#${fs(this.r)}${fs(this.g)}${fs(this.b)}`;
}
function xB() {
  return `#${fs(this.r)}${fs(this.g)}${fs(this.b)}${fs((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`;
}
function Wb() {
  const e = Ff(this.opacity);
  return `${e === 1 ? "rgb(" : "rgba("}${gs(this.r)}, ${gs(this.g)}, ${gs(this.b)}${e === 1 ? ")" : `, ${e})`}`;
}
function Ff(e) {
  return isNaN(e) ? 1 : Math.max(0, Math.min(1, e));
}
function gs(e) {
  return Math.max(0, Math.min(255, Math.round(e) || 0));
}
function fs(e) {
  return e = gs(e), (e < 16 ? "0" : "") + e.toString(16);
}
function Xb(e, t, n, r) {
  return r <= 0 ? e = t = n = NaN : n <= 0 || n >= 1 ? e = t = NaN : t <= 0 && (e = NaN), new Fn(e, t, n, r);
}
function RS(e) {
  if (e instanceof Fn) return new Fn(e.h, e.s, e.l, e.opacity);
  if (e instanceof Xi || (e = Ci(e)), !e) return new Fn();
  if (e instanceof Fn) return e;
  e = e.rgb();
  var t = e.r / 255, n = e.g / 255, r = e.b / 255, i = Math.min(t, n, r), s = Math.max(t, n, r), o = NaN, a = s - i, c = (s + i) / 2;
  return a ? (t === s ? o = (n - r) / a + (n < r) * 6 : n === s ? o = (r - t) / a + 2 : o = (t - n) / a + 4, a /= c < 0.5 ? s + i : 2 - s - i, o *= 60) : a = c > 0 && c < 1 ? 0 : o, new Fn(o, a, c, e.opacity);
}
function z0(e, t, n, r) {
  return arguments.length === 1 ? RS(e) : new Fn(e, t, n, r ?? 1);
}
function Fn(e, t, n, r) {
  this.h = +e, this.s = +t, this.l = +n, this.opacity = +r;
}
ya(Fn, z0, du(Xi, {
  brighter(e) {
    return e = e == null ? Xo : Math.pow(Xo, e), new Fn(this.h, this.s, this.l * e, this.opacity);
  },
  darker(e) {
    return e = e == null ? Ns : Math.pow(Ns, e), new Fn(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, r = n + (n < 0.5 ? n : 1 - n) * t, i = 2 * n - r;
    return new _e(
      pp(e >= 240 ? e - 240 : e + 120, i, r),
      pp(e, i, r),
      pp(e < 120 ? e + 240 : e - 120, i, r),
      this.opacity
    );
  },
  clamp() {
    return new Fn(Gb(this.h), Zu(this.s), Zu(this.l), Ff(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 = Ff(this.opacity);
    return `${e === 1 ? "hsl(" : "hsla("}${Gb(this.h)}, ${Zu(this.s) * 100}%, ${Zu(this.l) * 100}%${e === 1 ? ")" : `, ${e})`}`;
  }
}));
function Gb(e) {
  return e = (e || 0) % 360, e < 0 ? e + 360 : e;
}
function Zu(e) {
  return Math.max(0, Math.min(1, e || 0));
}
function pp(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 kS = Math.PI / 180, FS = 180 / Math.PI, Bf = 18, BS = 0.96422, CS = 1, PS = 0.82521, US = 4 / 29, No = 6 / 29, zS = 3 * No * No, SB = No * No * No;
function qS(e) {
  if (e instanceof yr) return new yr(e.l, e.a, e.b, e.opacity);
  if (e instanceof Xr) return jS(e);
  e instanceof _e || (e = zm(e));
  var t = bp(e.r), n = bp(e.g), r = bp(e.b), i = yp((0.2225045 * t + 0.7168786 * n + 0.0606169 * r) / CS), s, o;
  return t === n && n === r ? s = o = i : (s = yp((0.4360747 * t + 0.3850649 * n + 0.1430804 * r) / BS), o = yp((0.0139322 * t + 0.0971045 * n + 0.7141733 * r) / PS)), new yr(116 * i - 16, 500 * (s - i), 200 * (i - o), e.opacity);
}
function q0(e, t, n, r) {
  return arguments.length === 1 ? qS(e) : new yr(e, t, n, r ?? 1);
}
function yr(e, t, n, r) {
  this.l = +e, this.a = +t, this.b = +n, this.opacity = +r;
}
ya(yr, q0, du(Xi, {
  brighter(e) {
    return new yr(this.l + Bf * (e ?? 1), this.a, this.b, this.opacity);
  },
  darker(e) {
    return new yr(this.l - Bf * (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 = BS * mp(t), e = CS * mp(e), n = PS * mp(n), new _e(
      gp(3.1338561 * t - 1.6168667 * e - 0.4906146 * n),
      gp(-0.9787684 * t + 1.9161415 * e + 0.033454 * n),
      gp(0.0719453 * t - 0.2289914 * e + 1.4052427 * n),
      this.opacity
    );
  }
}));
function yp(e) {
  return e > SB ? Math.pow(e, 1 / 3) : e / zS + US;
}
function mp(e) {
  return e > No ? e * e * e : zS * (e - US);
}
function gp(e) {
  return 255 * (e <= 31308e-7 ? 12.92 * e : 1.055 * Math.pow(e, 1 / 2.4) - 0.055);
}
function bp(e) {
  return (e /= 255) <= 0.04045 ? e / 12.92 : Math.pow((e + 0.055) / 1.055, 2.4);
}
function MB(e) {
  if (e instanceof Xr) return new Xr(e.h, e.c, e.l, e.opacity);
  if (e instanceof yr || (e = qS(e)), e.a === 0 && e.b === 0) return new Xr(NaN, 0 < e.l && e.l < 100 ? 0 : NaN, e.l, e.opacity);
  var t = Math.atan2(e.b, e.a) * FS;
  return new Xr(t < 0 ? t + 360 : t, Math.sqrt(e.a * e.a + e.b * e.b), e.l, e.opacity);
}
function j0(e, t, n, r) {
  return arguments.length === 1 ? MB(e) : new Xr(e, t, n, r ?? 1);
}
function Xr(e, t, n, r) {
  this.h = +e, this.c = +t, this.l = +n, this.opacity = +r;
}
function jS(e) {
  if (isNaN(e.h)) return new yr(e.l, 0, 0, e.opacity);
  var t = e.h * kS;
  return new yr(e.l, Math.cos(t) * e.c, Math.sin(t) * e.c, e.opacity);
}
ya(Xr, j0, du(Xi, {
  brighter(e) {
    return new Xr(this.h, this.c, this.l + Bf * (e ?? 1), this.opacity);
  },
  darker(e) {
    return new Xr(this.h, this.c, this.l - Bf * (e ?? 1), this.opacity);
  },
  rgb() {
    return jS(this).rgb();
  }
}));
var VS = -0.14861, qm = 1.78277, jm = -0.29227, rd = -0.90649, kc = 1.97294, Hb = kc * rd, Jb = kc * qm, Zb = qm * jm - rd * VS;
function AB(e) {
  if (e instanceof bs) return new bs(e.h, e.s, e.l, e.opacity);
  e instanceof _e || (e = zm(e));
  var t = e.r / 255, n = e.g / 255, r = e.b / 255, i = (Zb * r + Hb * t - Jb * n) / (Zb + Hb - Jb), s = r - i, o = (kc * (n - i) - jm * s) / rd, a = Math.sqrt(o * o + s * s) / (kc * i * (1 - i)), c = a ? Math.atan2(o, s) * FS - 120 : NaN;
  return new bs(c < 0 ? c + 360 : c, a, i, e.opacity);
}
function wr(e, t, n, r) {
  return arguments.length === 1 ? AB(e) : new bs(e, t, n, r ?? 1);
}
function bs(e, t, n, r) {
  this.h = +e, this.s = +t, this.l = +n, this.opacity = +r;
}
ya(bs, wr, du(Xi, {
  brighter(e) {
    return e = e == null ? Xo : Math.pow(Xo, e), new bs(this.h, this.s, this.l * e, this.opacity);
  },
  darker(e) {
    return e = e == null ? Ns : Math.pow(Ns, e), new bs(this.h, this.s, this.l * e, this.opacity);
  },
  rgb() {
    var e = isNaN(this.h) ? 0 : (this.h + 120) * kS, t = +this.l, n = isNaN(this.s) ? 0 : this.s * t * (1 - t), r = Math.cos(e), i = Math.sin(e);
    return new _e(
      255 * (t + n * (VS * r + qm * i)),
      255 * (t + n * (jm * r + rd * i)),
      255 * (t + n * (kc * r)),
      this.opacity
    );
  }
}));
function $B(e, t, n, r, i) {
  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) * r + o * i) / 6;
}
function IB(e) {
  var t = e.length - 1;
  return function(n) {
    var r = n <= 0 ? n = 0 : n >= 1 ? (n = 1, t - 1) : Math.floor(n * t), i = e[r], s = e[r + 1], o = r > 0 ? e[r - 1] : 2 * i - s, a = r < t - 1 ? e[r + 2] : 2 * s - i;
    return $B((n - r / t) * t, o, i, s, a);
  };
}
const id = (e) => () => e;
function YS(e, t) {
  return function(n) {
    return e + n * t;
  };
}
function TB(e, t, n) {
  return e = Math.pow(e, n), t = Math.pow(t, n) - e, n = 1 / n, function(r) {
    return Math.pow(e + r * t, n);
  };
}
function Vm(e, t) {
  var n = t - e;
  return n ? YS(e, n > 180 || n < -180 ? n - 360 * Math.round(n / 360) : n) : id(isNaN(e) ? t : e);
}
function EB(e) {
  return (e = +e) == 1 ? De : function(t, n) {
    return n - t ? TB(t, n, e) : id(isNaN(t) ? n : t);
  };
}
function De(e, t) {
  var n = t - e;
  return n ? YS(e, n) : id(isNaN(e) ? t : e);
}
const Ds = function e(t) {
  var n = EB(t);
  function r(i, s) {
    var o = n((i = un(i)).r, (s = un(s)).r), a = n(i.g, s.g), c = n(i.b, s.b), u = De(i.opacity, s.opacity);
    return function(l) {
      return i.r = o(l), i.g = a(l), i.b = c(l), i.opacity = u(l), i + "";
    };
  }
  return r.gamma = e, r;
}(1);
function NB(e) {
  return function(t) {
    var n = t.length, r = new Array(n), i = new Array(n), s = new Array(n), o, a;
    for (o = 0; o < n; ++o)
      a = un(t[o]), r[o] = a.r || 0, i[o] = a.g || 0, s[o] = a.b || 0;
    return r = e(r), i = e(i), s = e(s), a.opacity = 1, function(c) {
      return a.r = r(c), a.g = i(c), a.b = s(c), a + "";
    };
  };
}
var DB = NB(IB);
function OB(e, t) {
  t || (t = []);
  var n = e ? Math.min(t.length, e.length) : 0, r = t.slice(), i;
  return function(s) {
    for (i = 0; i < n; ++i) r[i] = e[i] * (1 - s) + t[i] * s;
    return r;
  };
}
function LB(e) {
  return ArrayBuffer.isView(e) && !(e instanceof DataView);
}
function RB(e, t) {
  var n = t ? t.length : 0, r = e ? Math.min(n, e.length) : 0, i = new Array(r), s = new Array(n), o;
  for (o = 0; o < r; ++o) i[o] = ma(e[o], t[o]);
  for (; o < n; ++o) s[o] = t[o];
  return function(a) {
    for (o = 0; o < r; ++o) s[o] = i[o](a);
    return s;
  };
}
function kB(e, t) {
  var n = /* @__PURE__ */ new Date();
  return e = +e, t = +t, function(r) {
    return n.setTime(e * (1 - r) + t * r), n;
  };
}
function Ee(e, t) {
  return e = +e, t = +t, function(n) {
    return e * (1 - n) + t * n;
  };
}
function FB(e, t) {
  var n = {}, r = {}, i;
  (e === null || typeof e != "object") && (e = {}), (t === null || typeof t != "object") && (t = {});
  for (i in t)
    i in e ? n[i] = ma(e[i], t[i]) : r[i] = t[i];
  return function(s) {
    for (i in n) r[i] = n[i](s);
    return r;
  };
}
var V0 = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, wp = new RegExp(V0.source, "g");
function BB(e) {
  return function() {
    return e;
  };
}
function CB(e) {
  return function(t) {
    return e(t) + "";
  };
}
function WS(e, t) {
  var n = V0.lastIndex = wp.lastIndex = 0, r, i, s, o = -1, a = [], c = [];
  for (e = e + "", t = t + ""; (r = V0.exec(e)) && (i = wp.exec(t)); )
    (s = i.index) > n && (s = t.slice(n, s), a[o] ? a[o] += s : a[++o] = s), (r = r[0]) === (i = i[0]) ? a[o] ? a[o] += i : a[++o] = i : (a[++o] = null, c.push({ i: o, x: Ee(r, i) })), n = wp.lastIndex;
  return n < t.length && (s = t.slice(n), a[o] ? a[o] += s : a[++o] = s), a.length < 2 ? c[0] ? CB(c[0].x) : BB(t) : (t = c.length, function(u) {
    for (var l = 0, f; l < t; ++l) a[(f = c[l]).i] = f.x(u);
    return a.join("");
  });
}
function ma(e, t) {
  var n = typeof t, r;
  return t == null || n === "boolean" ? id(t) : (n === "number" ? Ee : n === "string" ? (r = Ci(t)) ? (t = r, Ds) : WS : t instanceof Ci ? Ds : t instanceof Date ? kB : LB(t) ? OB : Array.isArray(t) ? RB : typeof t.valueOf != "function" && typeof t.toString != "function" || isNaN(t) ? FB : Ee)(e, t);
}
function Ym(e, t) {
  return e = +e, t = +t, function(n) {
    return Math.round(e * (1 - n) + t * n);
  };
}
var Kb = 180 / Math.PI, Y0 = {
  translateX: 0,
  translateY: 0,
  rotate: 0,
  skewX: 0,
  scaleX: 1,
  scaleY: 1
};
function XS(e, t, n, r, i, s) {
  var o, a, c;
  return (o = Math.sqrt(e * e + t * t)) && (e /= o, t /= o), (c = e * n + t * r) && (n -= e * c, r -= t * c), (a = Math.sqrt(n * n + r * r)) && (n /= a, r /= a, c /= a), e * r < t * n && (e = -e, t = -t, c = -c, o = -o), {
    translateX: i,
    translateY: s,
    rotate: Math.atan2(t, e) * Kb,
    skewX: Math.atan(c) * Kb,
    scaleX: o,
    scaleY: a
  };
}
var Ku;
function PB(e) {
  const t = new (typeof DOMMatrix == "function" ? DOMMatrix : WebKitCSSMatrix)(e + "");
  return t.isIdentity ? Y0 : XS(t.a, t.b, t.c, t.d, t.e, t.f);
}
function UB(e) {
  return e == null || (Ku || (Ku = document.createElementNS("http://www.w3.org/2000/svg", "g")), Ku.setAttribute("transform", e), !(e = Ku.transform.baseVal.consolidate())) ? Y0 : (e = e.matrix, XS(e.a, e.b, e.c, e.d, e.e, e.f));
}
function GS(e, t, n, r) {
  function i(u) {
    return u.length ? u.pop() + " " : "";
  }
  function s(u, l, f, h, d, p) {
    if (u !== f || l !== h) {
      var y = d.push("translate(", null, t, null, n);
      p.push({ i: y - 4, x: Ee(u, f) }, { i: y - 2, x: Ee(l, h) });
    } else (f || h) && d.push("translate(" + f + t + h + n);
  }
  function o(u, l, f, h) {
    u !== l ? (u - l > 180 ? l += 360 : l - u > 180 && (u += 360), h.push({ i: f.push(i(f) + "rotate(", null, r) - 2, x: Ee(u, l) })) : l && f.push(i(f) + "rotate(" + l + r);
  }
  function a(u, l, f, h) {
    u !== l ? h.push({ i: f.push(i(f) + "skewX(", null, r) - 2, x: Ee(u, l) }) : l && f.push(i(f) + "skewX(" + l + r);
  }
  function c(u, l, f, h, d, p) {
    if (u !== f || l !== h) {
      var y = d.push(i(d) + "scale(", null, ",", null, ")");
      p.push({ i: y - 4, x: Ee(u, f) }, { i: y - 2, x: Ee(l, h) });
    } else (f !== 1 || h !== 1) && d.push(i(d) + "scale(" + f + "," + h + ")");
  }
  return function(u, l) {
    var f = [], h = [];
    return u = e(u), l = e(l), s(u.translateX, u.translateY, l.translateX, l.translateY, f, h), o(u.rotate, l.rotate, f, h), a(u.skewX, l.skewX, f, h), c(u.scaleX, u.scaleY, l.scaleX, l.scaleY, f, h), u = l = null, function(d) {
      for (var p = -1, y = h.length, m; ++p < y; ) f[(m = h[p]).i] = m.x(d);
      return f.join("");
    };
  };
}
var zB = GS(PB, "px, ", "px)", "deg)"), qB = GS(UB, ", ", ")", ")"), jB = 1e-12;
function Qb(e) {
  return ((e = Math.exp(e)) + 1 / e) / 2;
}
function VB(e) {
  return ((e = Math.exp(e)) - 1 / e) / 2;
}
function YB(e) {
  return ((e = Math.exp(2 * e)) - 1) / (e + 1);
}
const WB = function e(t, n, r) {
  function i(s, o) {
    var a = s[0], c = s[1], u = s[2], l = o[0], f = o[1], h = o[2], d = l - a, p = f - c, y = d * d + p * p, m, g;
    if (y < jB)
      g = Math.log(h / u) / t, m = function(M) {
        return [
          a + M * d,
          c + M * p,
          u * Math.exp(t * M * g)
        ];
      };
    else {
      var b = Math.sqrt(y), w = (h * h - u * u + r * y) / (2 * u * n * b), _ = (h * h - u * u - r * y) / (2 * h * n * b), x = Math.log(Math.sqrt(w * w + 1) - w), v = Math.log(Math.sqrt(_ * _ + 1) - _);
      g = (v - x) / t, m = function(M) {
        var E = M * g, $ = Qb(x), N = u / (n * b) * ($ * YB(t * E + x) - VB(x));
        return [
          a + N * d,
          c + N * p,
          u * $ / Qb(t * E + x)
        ];
      };
    }
    return m.duration = g * 1e3 * t / Math.SQRT2, m;
  }
  return i.rho = function(s) {
    var o = Math.max(1e-3, +s), a = o * o, c = a * a;
    return e(o, a, c);
  }, i;
}(Math.SQRT2, 2, 4);
function XB(e) {
  return function(t, n) {
    var r = e((t = z0(t)).h, (n = z0(n)).h), i = De(t.s, n.s), s = De(t.l, n.l), o = De(t.opacity, n.opacity);
    return function(a) {
      return t.h = r(a), t.s = i(a), t.l = s(a), t.opacity = o(a), t + "";
    };
  };
}
const GB = XB(Vm);
function HB(e, t) {
  var n = De((e = q0(e)).l, (t = q0(t)).l), r = De(e.a, t.a), i = De(e.b, t.b), s = De(e.opacity, t.opacity);
  return function(o) {
    return e.l = n(o), e.a = r(o), e.b = i(o), e.opacity = s(o), e + "";
  };
}
function JB(e) {
  return function(t, n) {
    var r = e((t = j0(t)).h, (n = j0(n)).h), i = De(t.c, n.c), s = De(t.l, n.l), o = De(t.opacity, n.opacity);
    return function(a) {
      return t.h = r(a), t.c = i(a), t.l = s(a), t.opacity = o(a), t + "";
    };
  };
}
const ZB = JB(Vm);
function HS(e) {
  return function t(n) {
    n = +n;
    function r(i, s) {
      var o = e((i = wr(i)).h, (s = wr(s)).h), a = De(i.s, s.s), c = De(i.l, s.l), u = De(i.opacity, s.opacity);
      return function(l) {
        return i.h = o(l), i.s = a(l), i.l = c(Math.pow(l, n)), i.opacity = u(l), i + "";
      };
    }
    return r.gamma = t, r;
  }(1);
}
HS(Vm);
var Wm = HS(De);
function sd(e, t) {
  t === void 0 && (t = e, e = ma);
  for (var n = 0, r = t.length - 1, i = t[0], s = new Array(r < 0 ? 0 : r); n < r; ) s[n] = e(i, i = t[++n]);
  return function(o) {
    var a = Math.max(0, Math.min(r - 1, Math.floor(o *= r)));
    return s[a](o - a);
  };
}
function jn(e, t) {
  for (var n = new Array(t), r = 0; r < t; ++r) n[r] = e(r / (t - 1));
  return n;
}
var Go = 0, Qa = 0, La = 0, JS = 1e3, Cf, tc, Pf = 0, Os = 0, od = 0, Fc = typeof performance == "object" && performance.now ? performance : Date, ZS = typeof window == "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(e) {
  setTimeout(e, 17);
};
function Xm() {
  return Os || (ZS(KB), Os = Fc.now() + od);
}
function KB() {
  Os = 0;
}
function Uf() {
  this._call = this._time = this._next = null;
}
Uf.prototype = KS.prototype = {
  constructor: Uf,
  restart: function(e, t, n) {
    if (typeof e != "function") throw new TypeError("callback is not a function");
    n = (n == null ? Xm() : +n) + (t == null ? 0 : +t), !this._next && tc !== this && (tc ? tc._next = this : Cf = this, tc = this), this._call = e, this._time = n, W0();
  },
  stop: function() {
    this._call && (this._call = null, this._time = 1 / 0, W0());
  }
};
function KS(e, t, n) {
  var r = new Uf();
  return r.restart(e, t, n), r;
}
function QB() {
  Xm(), ++Go;
  for (var e = Cf, t; e; )
    (t = Os - e._time) >= 0 && e._call.call(void 0, t), e = e._next;
  --Go;
}
function tw() {
  Os = (Pf = Fc.now()) + od, Go = Qa = 0;
  try {
    QB();
  } finally {
    Go = 0, eC(), Os = 0;
  }
}
function tC() {
  var e = Fc.now(), t = e - Pf;
  t > JS && (od -= t, Pf = e);
}
function eC() {
  for (var e, t = Cf, n, r = 1 / 0; t; )
    t._call ? (r > t._time && (r = t._time), e = t, t = t._next) : (n = t._next, t._next = null, t = e ? e._next = n : Cf = n);
  tc = e, W0(r);
}
function W0(e) {
  if (!Go) {
    Qa && (Qa = clearTimeout(Qa));
    var t = e - Os;
    t > 24 ? (e < 1 / 0 && (Qa = setTimeout(tw, e - Fc.now() - od)), La && (La = clearInterval(La))) : (La || (Pf = Fc.now(), La = setInterval(tC, JS)), Go = 1, ZS(tw));
  }
}
function ew(e, t, n) {
  var r = new Uf();
  return t = t == null ? 0 : +t, r.restart((i) => {
    r.stop(), e(i + t);
  }, t, n), r;
}
var nC = td("start", "end", "cancel", "interrupt"), rC = [], QS = 0, nw = 1, X0 = 2, ql = 3, rw = 4, G0 = 5, jl = 6;
function ad(e, t, n, r, i, s) {
  var o = e.__transition;
  if (!o) e.__transition = {};
  else if (n in o) return;
  iC(e, n, {
    name: t,
    index: r,
    // For context during callback.
    group: i,
    // For context during callback.
    on: nC,
    tween: rC,
    time: s.time,
    delay: s.delay,
    duration: s.duration,
    ease: s.ease,
    timer: null,
    state: QS
  });
}
function Gm(e, t) {
  var n = Hn(e, t);
  if (n.state > QS) throw new Error("too late; already scheduled");
  return n;
}
function xr(e, t) {
  var n = Hn(e, t);
  if (n.state > ql) throw new Error("too late; already running");
  return n;
}
function Hn(e, t) {
  var n = e.__transition;
  if (!n || !(n = n[t])) throw new Error("transition not found");
  return n;
}
function iC(e, t, n) {
  var r = e.__transition, i;
  r[t] = n, n.timer = KS(s, 0, n.time);
  function s(u) {
    n.state = nw, n.timer.restart(o, n.delay, n.time), n.delay <= u && o(u - n.delay);
  }
  function o(u) {
    var l, f, h, d;
    if (n.state !== nw) return c();
    for (l in r)
      if (d = r[l], d.name === n.name) {
        if (d.state === ql) return ew(o);
        d.state === rw ? (d.state = jl, d.timer.stop(), d.on.call("interrupt", e, e.__data__, d.index, d.group), delete r[l]) : +l < t && (d.state = jl, d.timer.stop(), d.on.call("cancel", e, e.__data__, d.index, d.group), delete r[l]);
      }
    if (ew(function() {
      n.state === ql && (n.state = rw, n.timer.restart(a, n.delay, n.time), a(u));
    }), n.state = X0, n.on.call("start", e, e.__data__, n.index, n.group), n.state === X0) {
      for (n.state = ql, i = new Array(h = n.tween.length), l = 0, f = -1; l < h; ++l)
        (d = n.tween[l].value.call(e, e.__data__, n.index, n.group)) && (i[++f] = d);
      i.length = f + 1;
    }
  }
  function a(u) {
    for (var l = u < n.duration ? n.ease.call(null, u / n.duration) : (n.timer.restart(c), n.state = G0, 1), f = -1, h = i.length; ++f < h; )
      i[f].call(e, l);
    n.state === G0 && (n.on.call("end", e, e.__data__, n.index, n.group), c());
  }
  function c() {
    n.state = jl, n.timer.stop(), delete r[t];
    for (var u in r) return;
    delete e.__transition;
  }
}
function Do(e, t) {
  var n = e.__transition, r, i, s = !0, o;
  if (n) {
    t = t == null ? null : t + "";
    for (o in n) {
      if ((r = n[o]).name !== t) {
        s = !1;
        continue;
      }
      i = r.state > X0 && r.state < G0, r.state = jl, r.timer.stop(), r.on.call(i ? "interrupt" : "cancel", e, e.__data__, r.index, r.group), delete n[o];
    }
    s && delete e.__transition;
  }
}
function sC(e) {
  return this.each(function() {
    Do(this, e);
  });
}
function oC(e, t) {
  var n, r;
  return function() {
    var i = xr(this, e), s = i.tween;
    if (s !== n) {
      r = n = s;
      for (var o = 0, a = r.length; o < a; ++o)
        if (r[o].name === t) {
          r = r.slice(), r.splice(o, 1);
          break;
        }
    }
    i.tween = r;
  };
}
function aC(e, t, n) {
  var r, i;
  if (typeof n != "function") throw new Error();
  return function() {
    var s = xr(this, e), o = s.tween;
    if (o !== r) {
      i = (r = o).slice();
      for (var a = { name: t, value: n }, c = 0, u = i.length; c < u; ++c)
        if (i[c].name === t) {
          i[c] = a;
          break;
        }
      c === u && i.push(a);
    }
    s.tween = i;
  };
}
function cC(e, t) {
  var n = this._id;
  if (e += "", arguments.length < 2) {
    for (var r = Hn(this.node(), n).tween, i = 0, s = r.length, o; i < s; ++i)
      if ((o = r[i]).name === e)
        return o.value;
    return null;
  }
  return this.each((t == null ? oC : aC)(n, e, t));
}
function Hm(e, t, n) {
  var r = e._id;
  return e.each(function() {
    var i = xr(this, r);
    (i.value || (i.value = {}))[t] = n.apply(this, arguments);
  }), function(i) {
    return Hn(i, r).value[t];
  };
}
function t3(e, t) {
  var n;
  return (typeof t == "number" ? Ee : t instanceof Ci ? Ds : (n = Ci(t)) ? (t = n, Ds) : WS)(e, t);
}
function uC(e) {
  return function() {
    this.removeAttribute(e);
  };
}
function lC(e) {
  return function() {
    this.removeAttributeNS(e.space, e.local);
  };
}
function fC(e, t, n) {
  var r, i = n + "", s;
  return function() {
    var o = this.getAttribute(e);
    return o === i ? null : o === r ? s : s = t(r = o, n);
  };
}
function hC(e, t, n) {
  var r, i = n + "", s;
  return function() {
    var o = this.getAttributeNS(e.space, e.local);
    return o === i ? null : o === r ? s : s = t(r = o, n);
  };
}
function dC(e, t, n) {
  var r, i, s;
  return function() {
    var o, a = n(this), c;
    return a == null ? void this.removeAttribute(e) : (o = this.getAttribute(e), c = a + "", o === c ? null : o === r && c === i ? s : (i = c, s = t(r = o, a)));
  };
}
function pC(e, t, n) {
  var r, i, s;
  return function() {
    var o, a = n(this), c;
    return a == null ? void this.removeAttributeNS(e.space, e.local) : (o = this.getAttributeNS(e.space, e.local), c = a + "", o === c ? null : o === r && c === i ? s : (i = c, s = t(r = o, a)));
  };
}
function yC(e, t) {
  var n = ed(e), r = n === "transform" ? qB : t3;
  return this.attrTween(e, typeof t == "function" ? (n.local ? pC : dC)(n, r, Hm(this, "attr." + e, t)) : t == null ? (n.local ? lC : uC)(n) : (n.local ? hC : fC)(n, r, t));
}
function mC(e, t) {
  return function(n) {
    this.setAttribute(e, t.call(this, n));
  };
}
function gC(e, t) {
  return function(n) {
    this.setAttributeNS(e.space, e.local, t.call(this, n));
  };
}
function bC(e, t) {
  var n, r;
  function i() {
    var s = t.apply(this, arguments);
    return s !== r && (n = (r = s) && gC(e, s)), n;
  }
  return i._value = t, i;
}
function wC(e, t) {
  var n, r;
  function i() {
    var s = t.apply(this, arguments);
    return s !== r && (n = (r = s) && mC(e, s)), n;
  }
  return i._value = t, i;
}
function _C(e, t) {
  var n = "attr." + e;
  if (arguments.length < 2) return (n = this.tween(n)) && n._value;
  if (t == null) return this.tween(n, null);
  if (typeof t != "function") throw new Error();
  var r = ed(e);
  return this.tween(n, (r.local ? bC : wC)(r, t));
}
function vC(e, t) {
  return function() {
    Gm(this, e).delay = +t.apply(this, arguments);
  };
}
function xC(e, t) {
  return t = +t, function() {
    Gm(this, e).delay = t;
  };
}
function SC(e) {
  var t = this._id;
  return arguments.length ? this.each((typeof e == "function" ? vC : xC)(t, e)) : Hn(this.node(), t).delay;
}
function MC(e, t) {
  return function() {
    xr(this, e).duration = +t.apply(this, arguments);
  };
}
function AC(e, t) {
  return t = +t, function() {
    xr(this, e).duration = t;
  };
}
function $C(e) {
  var t = this._id;
  return arguments.length ? this.each((typeof e == "function" ? MC : AC)(t, e)) : Hn(this.node(), t).duration;
}
function IC(e, t) {
  if (typeof t != "function") throw new Error();
  return function() {
    xr(this, e).ease = t;
  };
}
function TC(e) {
  var t = this._id;
  return arguments.length ? this.each(IC(t, e)) : Hn(this.node(), t).ease;
}
function EC(e, t) {
  return function() {
    var n = t.apply(this, arguments);
    if (typeof n != "function") throw new Error();
    xr(this, e).ease = n;
  };
}
function NC(e) {
  if (typeof e != "function") throw new Error();
  return this.each(EC(this._id, e));
}
function DC(e) {
  typeof e != "function" && (e = xS(e));
  for (var t = this._groups, n = t.length, r = new Array(n), i = 0; i < n; ++i)
    for (var s = t[i], o = s.length, a = r[i] = [], c, u = 0; u < o; ++u)
      (c = s[u]) && e.call(c, c.__data__, u, s) && a.push(c);
  return new ri(r, this._parents, this._name, this._id);
}
function OC(e) {
  if (e._id !== this._id) throw new Error();
  for (var t = this._groups, n = e._groups, r = t.length, i = n.length, s = Math.min(r, i), o = new Array(r), a = 0; a < s; ++a)
    for (var c = t[a], u = n[a], l = c.length, f = o[a] = new Array(l), h, d = 0; d < l; ++d)
      (h = c[d] || u[d]) && (f[d] = h);
  for (; a < r; ++a)
    o[a] = t[a];
  return new ri(o, this._parents, this._name, this._id);
}
function LC(e) {
  return (e + "").trim().split(/^|\s+/).every(function(t) {
    var n = t.indexOf(".");
    return n >= 0 && (t = t.slice(0, n)), !t || t === "start";
  });
}
function RC(e, t, n) {
  var r, i, s = LC(t) ? Gm : xr;
  return function() {
    var o = s(this, e), a = o.on;
    a !== r && (i = (r = a).copy()).on(t, n), o.on = i;
  };
}
function kC(e, t) {
  var n = this._id;
  return arguments.length < 2 ? Hn(this.node(), n).on.on(e) : this.each(RC(n, e, t));
}
function FC(e) {
  return function() {
    var t = this.parentNode;
    for (var n in this.__transition) if (+n !== e) return;
    t && t.removeChild(this);
  };
}
function BC() {
  return this.on("end.remove", FC(this._id));
}
function CC(e) {
  var t = this._name, n = this._id;
  typeof e != "function" && (e = Pm(e));
  for (var r = this._groups, i = r.length, s = new Array(i), o = 0; o < i; ++o)
    for (var a = r[o], c = a.length, u = s[o] = new Array(c), l, f, h = 0; h < c; ++h)
      (l = a[h]) && (f = e.call(l, l.__data__, h, a)) && ("__data__" in l && (f.__data__ = l.__data__), u[h] = f, ad(u[h], t, n, h, u, Hn(l, n)));
  return new ri(s, this._parents, t, n);
}
function PC(e) {
  var t = this._name, n = this._id;
  typeof e != "function" && (e = vS(e));
  for (var r = this._groups, i = r.length, s = [], o = [], a = 0; a < i; ++a)
    for (var c = r[a], u = c.length, l, f = 0; f < u; ++f)
      if (l = c[f]) {
        for (var h = e.call(l, l.__data__, f, c), d, p = Hn(l, n), y = 0, m = h.length; y < m; ++y)
          (d = h[y]) && ad(d, t, n, y, h, p);
        s.push(h), o.push(l);
      }
  return new ri(s, o, t, n);
}
var UC = hu.prototype.constructor;
function zC() {
  return new UC(this._groups, this._parents);
}
function qC(e, t) {
  var n, r, i;
  return function() {
    var s = Wo(this, e), o = (this.style.removeProperty(e), Wo(this, e));
    return s === o ? null : s === n && o === r ? i : i = t(n = s, r = o);
  };
}
function e3(e) {
  return function() {
    this.style.removeProperty(e);
  };
}
function jC(e, t, n) {
  var r, i = n + "", s;
  return function() {
    var o = Wo(this, e);
    return o === i ? null : o === r ? s : s = t(r = o, n);
  };
}
function VC(e, t, n) {
  var r, i, s;
  return function() {
    var o = Wo(this, e), a = n(this), c = a + "";
    return a == null && (c = a = (this.style.removeProperty(e), Wo(this, e))), o === c ? null : o === r && c === i ? s : (i = c, s = t(r = o, a));
  };
}
function YC(e, t) {
  var n, r, i, s = "style." + t, o = "end." + s, a;
  return function() {
    var c = xr(this, e), u = c.on, l = c.value[s] == null ? a || (a = e3(t)) : void 0;
    (u !== n || i !== l) && (r = (n = u).copy()).on(o, i = l), c.on = r;
  };
}
function WC(e, t, n) {
  var r = (e += "") == "transform" ? zB : t3;
  return t == null ? this.styleTween(e, qC(e, r)).on("end.style." + e, e3(e)) : typeof t == "function" ? this.styleTween(e, VC(e, r, Hm(this, "style." + e, t))).each(YC(this._id, e)) : this.styleTween(e, jC(e, r, t), n).on("end.style." + e, null);
}
function XC(e, t, n) {
  return function(r) {
    this.style.setProperty(e, t.call(this, r), n);
  };
}
function GC(e, t, n) {
  var r, i;
  function s() {
    var o = t.apply(this, arguments);
    return o !== i && (r = (i = o) && XC(e, o, n)), r;
  }
  return s._value = t, s;
}
function HC(e, t, n) {
  var r = "style." + (e += "");
  if (arguments.length < 2) return (r = this.tween(r)) && r._value;
  if (t == null) return this.tween(r, null);
  if (typeof t != "function") throw new Error();
  return this.tween(r, GC(e, t, n ?? ""));
}
function JC(e) {
  return function() {
    this.textContent = e;
  };
}
function ZC(e) {
  return function() {
    var t = e(this);
    this.textContent = t ?? "";
  };
}
function KC(e) {
  return this.tween("text", typeof e == "function" ? ZC(Hm(this, "text", e)) : JC(e == null ? "" : e + ""));
}
function QC(e) {
  return function(t) {
    this.textContent = e.call(this, t);
  };
}
function tP(e) {
  var t, n;
  function r() {
    var i = e.apply(this, arguments);
    return i !== n && (t = (n = i) && QC(i)), t;
  }
  return r._value = e, r;
}
function eP(e) {
  var t = "text";
  if (arguments.length < 1) return (t = this.tween(t)) && t._value;
  if (e == null) return this.tween(t, null);
  if (typeof e != "function") throw new Error();
  return this.tween(t, tP(e));
}
function nP() {
  for (var e = this._name, t = this._id, n = n3(), r = this._groups, i = r.length, s = 0; s < i; ++s)
    for (var o = r[s], a = o.length, c, u = 0; u < a; ++u)
      if (c = o[u]) {
        var l = Hn(c, t);
        ad(c, e, n, u, o, {
          time: l.time + l.delay + l.duration,
          delay: 0,
          duration: l.duration,
          ease: l.ease
        });
      }
  return new ri(r, this._parents, e, n);
}
function rP() {
  var e, t, n = this, r = n._id, i = n.size();
  return new Promise(function(s, o) {
    var a = { value: o }, c = { value: function() {
      --i === 0 && s();
    } };
    n.each(function() {
      var u = xr(this, r), l = u.on;
      l !== e && (t = (e = l).copy(), t._.cancel.push(a), t._.interrupt.push(a), t._.end.push(c)), u.on = t;
    }), i === 0 && s();
  });
}
var iP = 0;
function ri(e, t, n, r) {
  this._groups = e, this._parents = t, this._name = n, this._id = r;
}
function n3() {
  return ++iP;
}
var Nr = hu.prototype;
ri.prototype = {
  constructor: ri,
  select: CC,
  selectAll: PC,
  selectChild: Nr.selectChild,
  selectChildren: Nr.selectChildren,
  filter: DC,
  merge: OC,
  selection: zC,
  transition: nP,
  call: Nr.call,
  nodes: Nr.nodes,
  node: Nr.node,
  size: Nr.size,
  empty: Nr.empty,
  each: Nr.each,
  on: kC,
  attr: yC,
  attrTween: _C,
  style: WC,
  styleTween: HC,
  text: KC,
  textTween: eP,
  remove: BC,
  tween: cC,
  delay: SC,
  duration: $C,
  ease: TC,
  easeVarying: NC,
  end: rP,
  [Symbol.iterator]: Nr[Symbol.iterator]
};
function sP(e) {
  return ((e *= 2) <= 1 ? e * e * e : (e -= 2) * e * e + 2) / 2;
}
var oP = {
  time: null,
  // Set on use.
  delay: 0,
  duration: 250,
  ease: sP
};
function aP(e, t) {
  for (var n; !(n = e.__transition) || !(n = n[t]); )
    if (!(e = e.parentNode))
      throw new Error(`transition ${t} not found`);
  return n;
}
function cP(e) {
  var t, n;
  e instanceof ri ? (t = e._id, e = e._name) : (t = n3(), (n = oP).time = Xm(), e = e == null ? null : e + "");
  for (var r = this._groups, i = r.length, s = 0; s < i; ++s)
    for (var o = r[s], a = o.length, c, u = 0; u < a; ++u)
      (c = o[u]) && ad(c, e, t, u, o, n || aP(c, t));
  return new ri(r, this._parents, e, t);
}
hu.prototype.interrupt = sC;
hu.prototype.transition = cP;
const _p = (e) => () => e;
function uP(e, {
  sourceEvent: t,
  target: n,
  selection: r,
  mode: i,
  dispatch: s
}) {
  Object.defineProperties(this, {
    type: { value: e, enumerable: !0, configurable: !0 },
    sourceEvent: { value: t, enumerable: !0, configurable: !0 },
    target: { value: n, enumerable: !0, configurable: !0 },
    selection: { value: r, enumerable: !0, configurable: !0 },
    mode: { value: i, enumerable: !0, configurable: !0 },
    _: { value: s }
  });
}
function lP(e) {
  e.stopImmediatePropagation();
}
function vp(e) {
  e.preventDefault(), e.stopImmediatePropagation();
}
var iw = { name: "drag" }, xp = { name: "space" }, Gs = { name: "handle" }, Hs = { name: "center" };
const { abs: sw, max: $e, min: Ie } = Math;
function ow(e) {
  return [+e[0], +e[1]];
}
function H0(e) {
  return [ow(e[0]), ow(e[1])];
}
var Vl = {
  name: "x",
  handles: ["w", "e"].map(Bc),
  input: function(e, t) {
    return e == null ? null : [[+e[0], t[0][1]], [+e[1], t[1][1]]];
  },
  output: function(e) {
    return e && [e[0][0], e[1][0]];
  }
}, Yl = {
  name: "y",
  handles: ["n", "s"].map(Bc),
  input: function(e, t) {
    return e == null ? null : [[t[0][0], +e[0]], [t[1][0], +e[1]]];
  },
  output: function(e) {
    return e && [e[0][1], e[1][1]];
  }
}, fP = {
  name: "xy",
  handles: ["n", "w", "e", "s", "nw", "ne", "sw", "se"].map(Bc),
  input: function(e) {
    return e == null ? null : H0(e);
  },
  output: function(e) {
    return e;
  }
}, Dr = {
  overlay: "crosshair",
  selection: "move",
  n: "ns-resize",
  e: "ew-resize",
  s: "ns-resize",
  w: "ew-resize",
  nw: "nwse-resize",
  ne: "nesw-resize",
  se: "nwse-resize",
  sw: "nesw-resize"
}, aw = {
  e: "w",
  w: "e",
  nw: "ne",
  ne: "nw",
  se: "sw",
  sw: "se"
}, cw = {
  n: "s",
  s: "n",
  nw: "sw",
  ne: "se",
  se: "ne",
  sw: "nw"
}, hP = {
  overlay: 1,
  selection: 1,
  n: null,
  e: 1,
  s: null,
  w: -1,
  nw: -1,
  ne: 1,
  se: 1,
  sw: -1
}, dP = {
  overlay: 1,
  selection: 1,
  n: -1,
  e: null,
  s: 1,
  w: null,
  nw: -1,
  ne: -1,
  se: 1,
  sw: 1
};
function Bc(e) {
  return { type: e };
}
function pP(e) {
  return !e.ctrlKey && !e.button;
}
function yP() {
  var e = this.ownerSVGElement || this;
  return e.hasAttribute("viewBox") ? (e = e.viewBox.baseVal, [[e.x, e.y], [e.x + e.width, e.y + e.height]]) : [[0, 0], [e.width.baseVal.value, e.height.baseVal.value]];
}
function mP() {
  return navigator.maxTouchPoints || "ontouchstart" in this;
}
function Sp(e) {
  for (; !e.__brush; ) if (!(e = e.parentNode)) return;
  return e.__brush;
}
function gP(e) {
  return e[0][0] === e[1][0] || e[0][1] === e[1][1];
}
function bP() {
  return Jm(Vl);
}
function wP() {
  return Jm(Yl);
}
function _P() {
  return Jm(fP);
}
function Jm(e) {
  var t = yP, n = pP, r = mP, i = !0, s = td("start", "brush", "end"), o = 6, a;
  function c(m) {
    var g = m.property("__brush", y).selectAll(".overlay").data([Bc("overlay")]);
    g.enter().append("rect").attr("class", "overlay").attr("pointer-events", "all").attr("cursor", Dr.overlay).merge(g).each(function() {
      var w = Sp(this).extent;
      Wt(this).attr("x", w[0][0]).attr("y", w[0][1]).attr("width", w[1][0] - w[0][0]).attr("height", w[1][1] - w[0][1]);
    }), m.selectAll(".selection").data([Bc("selection")]).enter().append("rect").attr("class", "selection").attr("cursor", Dr.selection).attr("fill", "#777").attr("fill-opacity", 0.3).attr("stroke", "#fff").attr("shape-rendering", "crispEdges");
    var b = m.selectAll(".handle").data(e.handles, function(w) {
      return w.type;
    });
    b.exit().remove(), b.enter().append("rect").attr("class", function(w) {
      return "handle handle--" + w.type;
    }).attr("cursor", function(w) {
      return Dr[w.type];
    }), m.each(u).attr("fill", "none").attr("pointer-events", "all").on("mousedown.brush", h).filter(r).on("touchstart.brush", h).on("touchmove.brush", d).on("touchend.brush touchcancel.brush", p).style("touch-action", "none").style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
  }
  c.move = function(m, g, b) {
    m.tween ? m.on("start.brush", function(w) {
      l(this, arguments).beforestart().start(w);
    }).on("interrupt.brush end.brush", function(w) {
      l(this, arguments).end(w);
    }).tween("brush", function() {
      var w = this, _ = w.__brush, x = l(w, arguments), v = _.selection, M = e.input(typeof g == "function" ? g.apply(this, arguments) : g, _.extent), E = ma(v, M);
      function $(N) {
        _.selection = N === 1 && M === null ? null : E(N), u.call(w), x.brush();
      }
      return v !== null && M !== null ? $ : $(1);
    }) : m.each(function() {
      var w = this, _ = arguments, x = w.__brush, v = e.input(typeof g == "function" ? g.apply(w, _) : g, x.extent), M = l(w, _).beforestart();
      Do(w), x.selection = v === null ? null : v, u.call(w), M.start(b).brush(b).end(b);
    });
  }, c.clear = function(m, g) {
    c.move(m, null, g);
  };
  function u() {
    var m = Wt(this), g = Sp(this).selection;
    g ? (m.selectAll(".selection").style("display", null).attr("x", g[0][0]).attr("y", g[0][1]).attr("width", g[1][0] - g[0][0]).attr("height", g[1][1] - g[0][1]), m.selectAll(".handle").style("display", null).attr("x", function(b) {
      return b.type[b.type.length - 1] === "e" ? g[1][0] - o / 2 : g[0][0] - o / 2;
    }).attr("y", function(b) {
      return b.type[0] === "s" ? g[1][1] - o / 2 : g[0][1] - o / 2;
    }).attr("width", function(b) {
      return b.type === "n" || b.type === "s" ? g[1][0] - g[0][0] + o : o;
    }).attr("height", function(b) {
      return b.type === "e" || b.type === "w" ? g[1][1] - g[0][1] + o : o;
    })) : m.selectAll(".selection,.handle").style("display", "none").attr("x", null).attr("y", null).attr("width", null).attr("height", null);
  }
  function l(m, g, b) {
    var w = m.__brush.emitter;
    return w && (!b || !w.clean) ? w : new f(m, g, b);
  }
  function f(m, g, b) {
    this.that = m, this.args = g, this.state = m.__brush, this.active = 0, this.clean = b;
  }
  f.prototype = {
    beforestart: function() {
      return ++this.active === 1 && (this.state.emitter = this, this.starting = !0), this;
    },
    start: function(m, g) {
      return this.starting ? (this.starting = !1, this.emit("start", m, g)) : this.emit("brush", m), this;
    },
    brush: function(m, g) {
      return this.emit("brush", m, g), this;
    },
    end: function(m, g) {
      return --this.active === 0 && (delete this.state.emitter, this.emit("end", m, g)), this;
    },
    emit: function(m, g, b) {
      var w = Wt(this.that).datum();
      s.call(
        m,
        this.that,
        new uP(m, {
          sourceEvent: g,
          target: c,
          selection: e.output(this.state.selection),
          mode: b,
          dispatch: s
        }),
        w
      );
    }
  };
  function h(m) {
    if (a && !m.touches || !n.apply(this, arguments)) return;
    var g = this, b = m.target.__data__.type, w = (i && m.metaKey ? b = "overlay" : b) === "selection" ? iw : i && m.altKey ? Hs : Gs, _ = e === Yl ? null : hP[b], x = e === Vl ? null : dP[b], v = Sp(g), M = v.extent, E = v.selection, $ = M[0][0], N, A, D = M[0][1], k, S, I = M[1][0], T, R, B = M[1][1], C, F, P = 0, U = 0, Y, G = _ && x && i && m.shiftKey, K, H, V = Array.from(m.touches || [m], (J) => {
      const Ct = J.identifier;
      return J = Ln(J, g), J.point0 = J.slice(), J.identifier = Ct, J;
    });
    Do(g);
    var W = l(g, arguments, !0).beforestart();
    if (b === "overlay") {
      E && (Y = !0);
      const J = [V[0], V[1] || V[0]];
      v.selection = E = [[
        N = e === Yl ? $ : Ie(J[0][0], J[1][0]),
        k = e === Vl ? D : Ie(J[0][1], J[1][1])
      ], [
        T = e === Yl ? I : $e(J[0][0], J[1][0]),
        C = e === Vl ? B : $e(J[0][1], J[1][1])
      ]], V.length > 1 && wt(m);
    } else
      N = E[0][0], k = E[0][1], T = E[1][0], C = E[1][1];
    A = N, S = k, R = T, F = C;
    var q = Wt(g).attr("pointer-events", "none"), X = q.selectAll(".overlay").attr("cursor", Dr[b]);
    if (m.touches)
      W.moved = z, W.ended = tt;
    else {
      var Z = Wt(m.view).on("mousemove.brush", z, !0).on("mouseup.brush", tt, !0);
      i && Z.on("keydown.brush", It, !0).on("keyup.brush", Et, !0), OS(m.view);
    }
    u.call(g), W.start(m, w.name);
    function z(J) {
      for (const Ct of J.changedTouches || [J])
        for (const en of V)
          en.identifier === Ct.identifier && (en.cur = Ln(Ct, g));
      if (G && !K && !H && V.length === 1) {
        const Ct = V[0];
        sw(Ct.cur[0] - Ct[0]) > sw(Ct.cur[1] - Ct[1]) ? H = !0 : K = !0;
      }
      for (const Ct of V)
        Ct.cur && (Ct[0] = Ct.cur[0], Ct[1] = Ct.cur[1]);
      Y = !0, vp(J), wt(J);
    }
    function wt(J) {
      const Ct = V[0], en = Ct.point0;
      var Zn;
      switch (P = Ct[0] - en[0], U = Ct[1] - en[1], w) {
        case xp:
        case iw: {
          _ && (P = $e($ - N, Ie(I - T, P)), A = N + P, R = T + P), x && (U = $e(D - k, Ie(B - C, U)), S = k + U, F = C + U);
          break;
        }
        case Gs: {
          V[1] ? (_ && (A = $e($, Ie(I, V[0][0])), R = $e($, Ie(I, V[1][0])), _ = 1), x && (S = $e(D, Ie(B, V[0][1])), F = $e(D, Ie(B, V[1][1])), x = 1)) : (_ < 0 ? (P = $e($ - N, Ie(I - N, P)), A = N + P, R = T) : _ > 0 && (P = $e($ - T, Ie(I - T, P)), A = N, R = T + P), x < 0 ? (U = $e(D - k, Ie(B - k, U)), S = k + U, F = C) : x > 0 && (U = $e(D - C, Ie(B - C, U)), S = k, F = C + U));
          break;
        }
        case Hs: {
          _ && (A = $e($, Ie(I, N - P * _)), R = $e($, Ie(I, T + P * _))), x && (S = $e(D, Ie(B, k - U * x)), F = $e(D, Ie(B, C + U * x)));
          break;
        }
      }
      R < A && (_ *= -1, Zn = N, N = T, T = Zn, Zn = A, A = R, R = Zn, b in aw && X.attr("cursor", Dr[b = aw[b]])), F < S && (x *= -1, Zn = k, k = C, C = Zn, Zn = S, S = F, F = Zn, b in cw && X.attr("cursor", Dr[b = cw[b]])), v.selection && (E = v.selection), K && (A = E[0][0], R = E[1][0]), H && (S = E[0][1], F = E[1][1]), (E[0][0] !== A || E[0][1] !== S || E[1][0] !== R || E[1][1] !== F) && (v.selection = [[A, S], [R, F]], u.call(g), W.brush(J, w.name));
    }
    function tt(J) {
      if (lP(J), J.touches) {
        if (J.touches.length) return;
        a && clearTimeout(a), a = setTimeout(function() {
          a = null;
        }, 500);
      } else
        LS(J.view, Y), Z.on("keydown.brush keyup.brush mousemove.brush mouseup.brush", null);
      q.attr("pointer-events", "all"), X.attr("cursor", Dr.overlay), v.selection && (E = v.selection), gP(E) && (v.selection = null, u.call(g)), W.end(J, w.name);
    }
    function It(J) {
      switch (J.keyCode) {
        case 16: {
          G = _ && x;
          break;
        }
        case 18: {
          w === Gs && (_ && (T = R - P * _, N = A + P * _), x && (C = F - U * x, k = S + U * x), w = Hs, wt(J));
          break;
        }
        case 32: {
          (w === Gs || w === Hs) && (_ < 0 ? T = R - P : _ > 0 && (N = A - P), x < 0 ? C = F - U : x > 0 && (k = S - U), w = xp, X.attr("cursor", Dr.selection), wt(J));
          break;
        }
        default:
          return;
      }
      vp(J);
    }
    function Et(J) {
      switch (J.keyCode) {
        case 16: {
          G && (K = H = G = !1, wt(J));
          break;
        }
        case 18: {
          w === Hs && (_ < 0 ? T = R : _ > 0 && (N = A), x < 0 ? C = F : x > 0 && (k = S), w = Gs, wt(J));
          break;
        }
        case 32: {
          w === xp && (J.altKey ? (_ && (T = R - P * _, N = A + P * _), x && (C = F - U * x, k = S + U * x), w = Hs) : (_ < 0 ? T = R : _ > 0 && (N = A), x < 0 ? C = F : x > 0 && (k = S), w = Gs), X.attr("cursor", Dr[b]), wt(J));
          break;
        }
        default:
          return;
      }
      vp(J);
    }
  }
  function d(m) {
    l(this, arguments).moved(m);
  }
  function p(m) {
    l(this, arguments).ended(m);
  }
  function y() {
    var m = this.__brush || { selection: null };
    return m.extent = H0(t.apply(this, arguments)), m.dim = e, m;
  }
  return c.extent = function(m) {
    return arguments.length ? (t = typeof m == "function" ? m : _p(H0(m)), c) : t;
  }, c.filter = function(m) {
    return arguments.length ? (n = typeof m == "function" ? m : _p(!!m), c) : n;
  }, c.touchable = function(m) {
    return arguments.length ? (r = typeof m == "function" ? m : _p(!!m), c) : r;
  }, c.handleSize = function(m) {
    return arguments.length ? (o = +m, c) : o;
  }, c.keyModifiers = function(m) {
    return arguments.length ? (i = !!m, c) : i;
  }, c.on = function() {
    var m = s.on.apply(s, arguments);
    return m === s ? c : m;
  }, c;
}
const J0 = Math.PI, Z0 = 2 * J0, os = 1e-6, vP = Z0 - os;
function r3(e) {
  this._ += e[0];
  for (let t = 1, n = e.length; t < n; ++t)
    this._ += arguments[t] + e[t];
}
function xP(e) {
  let t = Math.floor(e);
  if (!(t >= 0)) throw new Error(`invalid digits: ${e}`);
  if (t > 15) return r3;
  const n = 10 ** t;
  return function(r) {
    this._ += r[0];
    for (let i = 1, s = r.length; i < s; ++i)
      this._ += Math.round(arguments[i] * n) / n + r[i];
  };
}
let i3 = class {
  constructor(t) {
    this._x0 = this._y0 = // start of current subpath
    this._x1 = this._y1 = null, this._ = "", this._append = t == null ? r3 : xP(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, r, i) {
    this._append`Q${+t},${+n},${this._x1 = +r},${this._y1 = +i}`;
  }
  bezierCurveTo(t, n, r, i, s, o) {
    this._append`C${+t},${+n},${+r},${+i},${this._x1 = +s},${this._y1 = +o}`;
  }
  arcTo(t, n, r, i, s) {
    if (t = +t, n = +n, r = +r, i = +i, s = +s, s < 0) throw new Error(`negative radius: ${s}`);
    let o = this._x1, a = this._y1, c = r - t, u = i - n, l = o - t, f = a - n, h = l * l + f * f;
    if (this._x1 === null)
      this._append`M${this._x1 = t},${this._y1 = n}`;
    else if (h > os) if (!(Math.abs(f * c - u * l) > os) || !s)
      this._append`L${this._x1 = t},${this._y1 = n}`;
    else {
      let d = r - o, p = i - a, y = c * c + u * u, m = d * d + p * p, g = Math.sqrt(y), b = Math.sqrt(h), w = s * Math.tan((J0 - Math.acos((y + h - m) / (2 * g * b))) / 2), _ = w / b, x = w / g;
      Math.abs(_ - 1) > os && this._append`L${t + _ * l},${n + _ * f}`, this._append`A${s},${s},0,0,${+(f * d > l * p)},${this._x1 = t + x * c},${this._y1 = n + x * u}`;
    }
  }
  arc(t, n, r, i, s, o) {
    if (t = +t, n = +n, r = +r, o = !!o, r < 0) throw new Error(`negative radius: ${r}`);
    let a = r * Math.cos(i), c = r * Math.sin(i), u = t + a, l = n + c, f = 1 ^ o, h = o ? i - s : s - i;
    this._x1 === null ? this._append`M${u},${l}` : (Math.abs(this._x1 - u) > os || Math.abs(this._y1 - l) > os) && this._append`L${u},${l}`, r && (h < 0 && (h = h % Z0 + Z0), h > vP ? this._append`A${r},${r},0,1,${f},${t - a},${n - c}A${r},${r},0,1,${f},${this._x1 = u},${this._y1 = l}` : h > os && this._append`A${r},${r},0,${+(h >= J0)},${f},${this._x1 = t + r * Math.cos(s)},${this._y1 = n + r * Math.sin(s)}`);
  }
  rect(t, n, r, i) {
    this._append`M${this._x0 = this._x1 = +t},${this._y0 = this._y1 = +n}h${r = +r}v${+i}h${-r}Z`;
  }
  toString() {
    return this._;
  }
};
function Gr(e = 3) {
  return new i3(+e);
}
var SP = Array.prototype, s3 = SP.slice;
function MP(e, t) {
  return e - t;
}
function AP(e) {
  for (var t = 0, n = e.length, r = e[n - 1][1] * e[0][0] - e[n - 1][0] * e[0][1]; ++t < n; ) r += e[t - 1][1] * e[t][0] - e[t - 1][0] * e[t][1];
  return r;
}
const vi = (e) => () => e;
function $P(e, t) {
  for (var n = -1, r = t.length, i; ++n < r; ) if (i = IP(e, t[n])) return i;
  return 0;
}
function IP(e, t) {
  for (var n = t[0], r = t[1], i = -1, s = 0, o = e.length, a = o - 1; s < o; a = s++) {
    var c = e[s], u = c[0], l = c[1], f = e[a], h = f[0], d = f[1];
    if (TP(c, f, t)) return 0;
    l > r != d > r && n < (h - u) * (r - l) / (d - l) + u && (i = -i);
  }
  return i;
}
function TP(e, t, n) {
  var r;
  return EP(e, t, n) && NP(e[r = +(e[0] === t[0])], n[r], t[r]);
}
function EP(e, t, n) {
  return (t[0] - e[0]) * (n[1] - e[1]) === (n[0] - e[0]) * (t[1] - e[1]);
}
function NP(e, t, n) {
  return e <= t && t <= n || n <= t && t <= e;
}
function DP() {
}
var Or = [
  [],
  [[[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 zf() {
  var e = 1, t = 1, n = Bm, r = c;
  function i(u) {
    var l = n(u);
    if (Array.isArray(l))
      l = l.slice().sort(MP);
    else {
      const f = pe(u, OP);
      for (l = Fi(...yS(f[0], f[1], l), l); l[l.length - 1] >= f[1]; ) l.pop();
      for (; l[1] < f[0]; ) l.shift();
    }
    return l.map((f) => s(u, f));
  }
  function s(u, l) {
    const f = l == null ? NaN : +l;
    if (isNaN(f)) throw new Error(`invalid value: ${l}`);
    var h = [], d = [];
    return o(u, f, function(p) {
      r(p, u, f), AP(p) > 0 ? h.push([p]) : d.push(p);
    }), d.forEach(function(p) {
      for (var y = 0, m = h.length, g; y < m; ++y)
        if ($P((g = h[y])[0], p) !== -1) {
          g.push(p);
          return;
        }
    }), {
      type: "MultiPolygon",
      value: l,
      coordinates: h
    };
  }
  function o(u, l, f) {
    var h = new Array(), d = new Array(), p, y, m, g, b, w;
    for (p = y = -1, g = rs(u[0], l), Or[g << 1].forEach(_); ++p < e - 1; )
      m = g, g = rs(u[p + 1], l), Or[m | g << 1].forEach(_);
    for (Or[g << 0].forEach(_); ++y < t - 1; ) {
      for (p = -1, g = rs(u[y * e + e], l), b = rs(u[y * e], l), Or[g << 1 | b << 2].forEach(_); ++p < e - 1; )
        m = g, g = rs(u[y * e + e + p + 1], l), w = b, b = rs(u[y * e + p + 1], l), Or[m | g << 1 | b << 2 | w << 3].forEach(_);
      Or[g | b << 3].forEach(_);
    }
    for (p = -1, b = u[y * e] >= l, Or[b << 2].forEach(_); ++p < e - 1; )
      w = b, b = rs(u[y * e + p + 1], l), Or[b << 2 | w << 3].forEach(_);
    Or[b << 3].forEach(_);
    function _(x) {
      var v = [x[0][0] + p, x[0][1] + y], M = [x[1][0] + p, x[1][1] + y], E = a(v), $ = a(M), N, A;
      (N = d[E]) ? (A = h[$]) ? (delete d[N.end], delete h[A.start], N === A ? (N.ring.push(M), f(N.ring)) : h[N.start] = d[A.end] = { start: N.start, end: A.end, ring: N.ring.concat(A.ring) }) : (delete d[N.end], N.ring.push(M), d[N.end = $] = N) : (N = h[$]) ? (A = d[E]) ? (delete h[N.start], delete d[A.end], N === A ? (N.ring.push(M), f(N.ring)) : h[A.start] = d[N.end] = { start: A.start, end: N.end, ring: A.ring.concat(N.ring) }) : (delete h[N.start], N.ring.unshift(v), h[N.start = E] = N) : h[E] = d[$] = { start: E, end: $, ring: [v, M] };
    }
  }
  function a(u) {
    return u[0] * 2 + u[1] * (e + 1) * 4;
  }
  function c(u, l, f) {
    u.forEach(function(h) {
      var d = h[0], p = h[1], y = d | 0, m = p | 0, g = Mp(l[m * e + y]);
      d > 0 && d < e && y === d && (h[0] = uw(d, Mp(l[m * e + y - 1]), g, f)), p > 0 && p < t && m === p && (h[1] = uw(p, Mp(l[(m - 1) * e + y]), g, f));
    });
  }
  return i.contour = s, i.size = function(u) {
    if (!arguments.length) return [e, t];
    var l = Math.floor(u[0]), f = Math.floor(u[1]);
    if (!(l >= 0 && f >= 0)) throw new Error("invalid size");
    return e = l, t = f, i;
  }, i.thresholds = function(u) {
    return arguments.length ? (n = typeof u == "function" ? u : Array.isArray(u) ? vi(s3.call(u)) : vi(u), i) : n;
  }, i.smooth = function(u) {
    return arguments.length ? (r = u ? c : DP, i) : r === c;
  }, i;
}
function OP(e) {
  return isFinite(e) ? e : NaN;
}
function rs(e, t) {
  return e == null ? !1 : +e >= t;
}
function Mp(e) {
  return e == null || isNaN(e = +e) ? -1 / 0 : e;
}
function uw(e, t, n, r) {
  const i = r - t, s = n - t, o = isFinite(i) || isFinite(s) ? i / s : Math.sign(i) / Math.sign(s);
  return isNaN(o) ? e : e + o - 0.5;
}
function LP(e) {
  return e[0];
}
function RP(e) {
  return e[1];
}
function kP() {
  return 1;
}
function FP() {
  var e = LP, t = RP, n = kP, r = 960, i = 500, s = 20, o = 2, a = s * 3, c = r + a * 2 >> o, u = i + a * 2 >> o, l = vi(20);
  function f(b) {
    var w = new Float32Array(c * u), _ = Math.pow(2, -o), x = -1;
    for (const k of b) {
      var v = (e(k, ++x, b) + a) * _, M = (t(k, x, b) + a) * _, E = +n(k, x, b);
      if (E && v >= 0 && v < c && M >= 0 && M < u) {
        var $ = Math.floor(v), N = Math.floor(M), A = v - $ - 0.5, D = M - N - 0.5;
        w[$ + N * c] += (1 - A) * (1 - D) * E, w[$ + 1 + N * c] += A * (1 - D) * E, w[$ + 1 + (N + 1) * c] += A * D * E, w[$ + (N + 1) * c] += (1 - A) * D * E;
      }
    }
    return uS({ data: w, width: c, height: u }, s * _), w;
  }
  function h(b) {
    var w = f(b), _ = l(w), x = Math.pow(2, 2 * o);
    return Array.isArray(_) || (_ = Fi(Number.MIN_VALUE, ce(w) / x, _)), zf().size([c, u]).thresholds(_.map((v) => v * x))(w).map((v, M) => (v.value = +_[M], d(v)));
  }
  h.contours = function(b) {
    var w = f(b), _ = zf().size([c, u]), x = Math.pow(2, 2 * o), v = (M) => {
      M = +M;
      var E = d(_.contour(w, M * x));
      return E.value = M, E;
    };
    return Object.defineProperty(v, "max", { get: () => ce(w) / x }), v;
  };
  function d(b) {
    return b.coordinates.forEach(p), b;
  }
  function p(b) {
    b.forEach(y);
  }
  function y(b) {
    b.forEach(m);
  }
  function m(b) {
    b[0] = b[0] * Math.pow(2, o) - a, b[1] = b[1] * Math.pow(2, o) - a;
  }
  function g() {
    return a = s * 3, c = r + a * 2 >> o, u = i + a * 2 >> o, h;
  }
  return h.x = function(b) {
    return arguments.length ? (e = typeof b == "function" ? b : vi(+b), h) : e;
  }, h.y = function(b) {
    return arguments.length ? (t = typeof b == "function" ? b : vi(+b), h) : t;
  }, h.weight = function(b) {
    return arguments.length ? (n = typeof b == "function" ? b : vi(+b), h) : n;
  }, h.size = function(b) {
    if (!arguments.length) return [r, i];
    var w = +b[0], _ = +b[1];
    if (!(w >= 0 && _ >= 0)) throw new Error("invalid size");
    return r = w, i = _, g();
  }, h.cellSize = function(b) {
    if (!arguments.length) return 1 << o;
    if (!((b = +b) >= 1)) throw new Error("invalid cell size");
    return o = Math.floor(Math.log(b) / Math.LN2), g();
  }, h.thresholds = function(b) {
    return arguments.length ? (l = typeof b == "function" ? b : Array.isArray(b) ? vi(s3.call(b)) : vi(b), h) : l;
  }, h.bandwidth = function(b) {
    if (!arguments.length) return Math.sqrt(s * (s + 1));
    if (!((b = +b) >= 0)) throw new Error("invalid bandwidth");
    return s = (Math.sqrt(4 * b * b + 1) - 1) / 2, g();
  }, h;
}
const Kr = 11102230246251565e-32, Te = 134217729, BP = (3 + 8 * Kr) * Kr;
function Ap(e, t, n, r, i) {
  let s, o, a, c, u = t[0], l = r[0], f = 0, h = 0;
  l > u == l > -u ? (s = u, u = t[++f]) : (s = l, l = r[++h]);
  let d = 0;
  if (f < e && h < n)
    for (l > u == l > -u ? (o = u + s, a = s - (o - u), u = t[++f]) : (o = l + s, a = s - (o - l), l = r[++h]), s = o, a !== 0 && (i[d++] = a); f < e && h < n; )
      l > u == l > -u ? (o = s + u, c = o - s, a = s - (o - c) + (u - c), u = t[++f]) : (o = s + l, c = o - s, a = s - (o - c) + (l - c), l = r[++h]), s = o, a !== 0 && (i[d++] = a);
  for (; f < e; )
    o = s + u, c = o - s, a = s - (o - c) + (u - c), u = t[++f], s = o, a !== 0 && (i[d++] = a);
  for (; h < n; )
    o = s + l, c = o - s, a = s - (o - c) + (l - c), l = r[++h], s = o, a !== 0 && (i[d++] = a);
  return (s !== 0 || d === 0) && (i[d++] = s), d;
}
function CP(e, t) {
  let n = t[0];
  for (let r = 1; r < e; r++) n += t[r];
  return n;
}
function pu(e) {
  return new Float64Array(e);
}
const PP = (3 + 16 * Kr) * Kr, UP = (2 + 12 * Kr) * Kr, zP = (9 + 64 * Kr) * Kr * Kr, Js = pu(4), lw = pu(8), fw = pu(12), hw = pu(16), Le = pu(4);
function qP(e, t, n, r, i, s, o) {
  let a, c, u, l, f, h, d, p, y, m, g, b, w, _, x, v, M, E;
  const $ = e - i, N = n - i, A = t - s, D = r - s;
  _ = $ * D, h = Te * $, d = h - (h - $), p = $ - d, h = Te * D, y = h - (h - D), m = D - y, x = p * m - (_ - d * y - p * y - d * m), v = A * N, h = Te * A, d = h - (h - A), p = A - d, h = Te * N, y = h - (h - N), m = N - y, M = p * m - (v - d * y - p * y - d * m), g = x - M, f = x - g, Js[0] = x - (g + f) + (f - M), b = _ + g, f = b - _, w = _ - (b - f) + (g - f), g = w - v, f = w - g, Js[1] = w - (g + f) + (f - v), E = b + g, f = E - b, Js[2] = b - (E - f) + (g - f), Js[3] = E;
  let k = CP(4, Js), S = UP * o;
  if (k >= S || -k >= S || (f = e - $, a = e - ($ + f) + (f - i), f = n - N, u = n - (N + f) + (f - i), f = t - A, c = t - (A + f) + (f - s), f = r - D, l = r - (D + f) + (f - s), a === 0 && c === 0 && u === 0 && l === 0) || (S = zP * o + BP * Math.abs(k), k += $ * l + D * a - (A * u + N * c), k >= S || -k >= S)) return k;
  _ = a * D, h = Te * a, d = h - (h - a), p = a - d, h = Te * D, y = h - (h - D), m = D - y, x = p * m - (_ - d * y - p * y - d * m), v = c * N, h = Te * c, d = h - (h - c), p = c - d, h = Te * N, y = h - (h - N), m = N - y, M = p * m - (v - d * y - p * y - d * m), g = x - M, f = x - g, Le[0] = x - (g + f) + (f - M), b = _ + g, f = b - _, w = _ - (b - f) + (g - f), g = w - v, f = w - g, Le[1] = w - (g + f) + (f - v), E = b + g, f = E - b, Le[2] = b - (E - f) + (g - f), Le[3] = E;
  const I = Ap(4, Js, 4, Le, lw);
  _ = $ * l, h = Te * $, d = h - (h - $), p = $ - d, h = Te * l, y = h - (h - l), m = l - y, x = p * m - (_ - d * y - p * y - d * m), v = A * u, h = Te * A, d = h - (h - A), p = A - d, h = Te * u, y = h - (h - u), m = u - y, M = p * m - (v - d * y - p * y - d * m), g = x - M, f = x - g, Le[0] = x - (g + f) + (f - M), b = _ + g, f = b - _, w = _ - (b - f) + (g - f), g = w - v, f = w - g, Le[1] = w - (g + f) + (f - v), E = b + g, f = E - b, Le[2] = b - (E - f) + (g - f), Le[3] = E;
  const T = Ap(I, lw, 4, Le, fw);
  _ = a * l, h = Te * a, d = h - (h - a), p = a - d, h = Te * l, y = h - (h - l), m = l - y, x = p * m - (_ - d * y - p * y - d * m), v = c * u, h = Te * c, d = h - (h - c), p = c - d, h = Te * u, y = h - (h - u), m = u - y, M = p * m - (v - d * y - p * y - d * m), g = x - M, f = x - g, Le[0] = x - (g + f) + (f - M), b = _ + g, f = b - _, w = _ - (b - f) + (g - f), g = w - v, f = w - g, Le[1] = w - (g + f) + (f - v), E = b + g, f = E - b, Le[2] = b - (E - f) + (g - f), Le[3] = E;
  const R = Ap(T, fw, 4, Le, hw);
  return hw[R - 1];
}
function Qu(e, t, n, r, i, s) {
  const o = (t - s) * (n - i), a = (e - i) * (r - s), c = o - a, u = Math.abs(o + a);
  return Math.abs(c) >= PP * u ? c : -qP(e, t, n, r, i, s, u);
}
const dw = Math.pow(2, -52), tl = new Uint32Array(512);
class qf {
  static from(t, n = XP, r = GP) {
    const i = t.length, s = new Float64Array(i * 2);
    for (let o = 0; o < i; o++) {
      const a = t[o];
      s[2 * o] = n(a), s[2 * o + 1] = r(a);
    }
    return new qf(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 r = Math.max(2 * n - 5, 0);
    this._triangles = new Uint32Array(r * 3), this._halfedges = new Int32Array(r * 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: r, _hullTri: i, _hullHash: s } = this, o = t.length >> 1;
    let a = 1 / 0, c = 1 / 0, u = -1 / 0, l = -1 / 0;
    for (let $ = 0; $ < o; $++) {
      const N = t[2 * $], A = t[2 * $ + 1];
      N < a && (a = N), A < c && (c = A), N > u && (u = N), A > l && (l = A), this._ids[$] = $;
    }
    const f = (a + u) / 2, h = (c + l) / 2;
    let d, p, y;
    for (let $ = 0, N = 1 / 0; $ < o; $++) {
      const A = $p(f, h, t[2 * $], t[2 * $ + 1]);
      A < N && (d = $, N = A);
    }
    const m = t[2 * d], g = t[2 * d + 1];
    for (let $ = 0, N = 1 / 0; $ < o; $++) {
      if ($ === d) continue;
      const A = $p(m, g, t[2 * $], t[2 * $ + 1]);
      A < N && A > 0 && (p = $, N = A);
    }
    let b = t[2 * p], w = t[2 * p + 1], _ = 1 / 0;
    for (let $ = 0; $ < o; $++) {
      if ($ === d || $ === p) continue;
      const N = YP(m, g, b, w, t[2 * $], t[2 * $ + 1]);
      N < _ && (y = $, _ = N);
    }
    let x = t[2 * y], v = t[2 * y + 1];
    if (_ === 1 / 0) {
      for (let A = 0; A < o; A++)
        this._dists[A] = t[2 * A] - t[0] || t[2 * A + 1] - t[1];
      mo(this._ids, this._dists, 0, o - 1);
      const $ = new Uint32Array(o);
      let N = 0;
      for (let A = 0, D = -1 / 0; A < o; A++) {
        const k = this._ids[A], S = this._dists[k];
        S > D && ($[N++] = k, D = S);
      }
      this.hull = $.subarray(0, N), this.triangles = new Uint32Array(0), this.halfedges = new Uint32Array(0);
      return;
    }
    if (Qu(m, g, b, w, x, v) < 0) {
      const $ = p, N = b, A = w;
      p = y, b = x, w = v, y = $, x = N, v = A;
    }
    const M = WP(m, g, b, w, x, v);
    this._cx = M.x, this._cy = M.y;
    for (let $ = 0; $ < o; $++)
      this._dists[$] = $p(t[2 * $], t[2 * $ + 1], M.x, M.y);
    mo(this._ids, this._dists, 0, o - 1), this._hullStart = d;
    let E = 3;
    r[d] = n[y] = p, r[p] = n[d] = y, r[y] = n[p] = d, i[d] = 0, i[p] = 1, i[y] = 2, s.fill(-1), s[this._hashKey(m, g)] = d, s[this._hashKey(b, w)] = p, s[this._hashKey(x, v)] = y, this.trianglesLen = 0, this._addTriangle(d, p, y, -1, -1, -1);
    for (let $ = 0, N, A; $ < this._ids.length; $++) {
      const D = this._ids[$], k = t[2 * D], S = t[2 * D + 1];
      if ($ > 0 && Math.abs(k - N) <= dw && Math.abs(S - A) <= dw || (N = k, A = S, D === d || D === p || D === y)) continue;
      let I = 0;
      for (let F = 0, P = this._hashKey(k, S); F < this._hashSize && (I = s[(P + F) % this._hashSize], !(I !== -1 && I !== r[I])); F++)
        ;
      I = n[I];
      let T = I, R;
      for (; R = r[T], Qu(k, S, t[2 * T], t[2 * T + 1], t[2 * R], t[2 * R + 1]) >= 0; )
        if (T = R, T === I) {
          T = -1;
          break;
        }
      if (T === -1) continue;
      let B = this._addTriangle(T, D, r[T], -1, -1, i[T]);
      i[D] = this._legalize(B + 2), i[T] = B, E++;
      let C = r[T];
      for (; R = r[C], Qu(k, S, t[2 * C], t[2 * C + 1], t[2 * R], t[2 * R + 1]) < 0; )
        B = this._addTriangle(C, D, R, i[D], -1, i[C]), i[D] = this._legalize(B + 2), r[C] = C, E--, C = R;
      if (T === I)
        for (; R = n[T], Qu(k, S, t[2 * R], t[2 * R + 1], t[2 * T], t[2 * T + 1]) < 0; )
          B = this._addTriangle(R, D, T, -1, i[T], i[R]), this._legalize(B + 2), i[R] = B, r[T] = T, E--, T = R;
      this._hullStart = n[D] = T, r[T] = n[C] = D, r[D] = C, s[this._hashKey(k, S)] = D, s[this._hashKey(t[2 * T], t[2 * T + 1])] = T;
    }
    this.hull = new Uint32Array(E);
    for (let $ = 0, N = this._hullStart; $ < E; $++)
      this.hull[$] = N, N = r[N];
    this.triangles = this._triangles.subarray(0, this.trianglesLen), this.halfedges = this._halfedges.subarray(0, this.trianglesLen);
  }
  _hashKey(t, n) {
    return Math.floor(jP(t - this._cx, n - this._cy) * this._hashSize) % this._hashSize;
  }
  _legalize(t) {
    const { _triangles: n, _halfedges: r, coords: i } = this;
    let s = 0, o = 0;
    for (; ; ) {
      const a = r[t], c = t - t % 3;
      if (o = c + (t + 2) % 3, a === -1) {
        if (s === 0) break;
        t = tl[--s];
        continue;
      }
      const u = a - a % 3, l = c + (t + 1) % 3, f = u + (a + 2) % 3, h = n[o], d = n[t], p = n[l], y = n[f];
      if (VP(
        i[2 * h],
        i[2 * h + 1],
        i[2 * d],
        i[2 * d + 1],
        i[2 * p],
        i[2 * p + 1],
        i[2 * y],
        i[2 * y + 1]
      )) {
        n[t] = y, n[a] = h;
        const g = r[f];
        if (g === -1) {
          let w = this._hullStart;
          do {
            if (this._hullTri[w] === f) {
              this._hullTri[w] = t;
              break;
            }
            w = this._hullPrev[w];
          } while (w !== this._hullStart);
        }
        this._link(t, g), this._link(a, r[o]), this._link(o, f);
        const b = u + (a + 1) % 3;
        s < tl.length && (tl[s++] = b);
      } else {
        if (s === 0) break;
        t = tl[--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, r, i, s, o) {
    const a = this.trianglesLen;
    return this._triangles[a] = t, this._triangles[a + 1] = n, this._triangles[a + 2] = r, this._link(a, i), this._link(a + 1, s), this._link(a + 2, o), this.trianglesLen += 3, a;
  }
}
function jP(e, t) {
  const n = e / (Math.abs(e) + Math.abs(t));
  return (t > 0 ? 3 - n : 1 + n) / 4;
}
function $p(e, t, n, r) {
  const i = e - n, s = t - r;
  return i * i + s * s;
}
function VP(e, t, n, r, i, s, o, a) {
  const c = e - o, u = t - a, l = n - o, f = r - a, h = i - o, d = s - a, p = c * c + u * u, y = l * l + f * f, m = h * h + d * d;
  return c * (f * m - y * d) - u * (l * m - y * h) + p * (l * d - f * h) < 0;
}
function YP(e, t, n, r, i, s) {
  const o = n - e, a = r - t, c = i - e, u = s - t, l = o * o + a * a, f = c * c + u * u, h = 0.5 / (o * u - a * c), d = (u * l - a * f) * h, p = (o * f - c * l) * h;
  return d * d + p * p;
}
function WP(e, t, n, r, i, s) {
  const o = n - e, a = r - t, c = i - e, u = s - t, l = o * o + a * a, f = c * c + u * u, h = 0.5 / (o * u - a * c), d = e + (u * l - a * f) * h, p = t + (o * f - c * l) * h;
  return { x: d, y: p };
}
function mo(e, t, n, r) {
  if (r - n <= 20)
    for (let i = n + 1; i <= r; i++) {
      const s = e[i], o = t[s];
      let a = i - 1;
      for (; a >= n && t[e[a]] > o; ) e[a + 1] = e[a--];
      e[a + 1] = s;
    }
  else {
    const i = n + r >> 1;
    let s = n + 1, o = r;
    Ra(e, i, s), t[e[n]] > t[e[r]] && Ra(e, n, r), t[e[s]] > t[e[r]] && Ra(e, s, r), t[e[n]] > t[e[s]] && Ra(e, n, s);
    const a = e[s], c = t[a];
    for (; ; ) {
      do
        s++;
      while (t[e[s]] < c);
      do
        o--;
      while (t[e[o]] > c);
      if (o < s) break;
      Ra(e, s, o);
    }
    e[n + 1] = e[o], e[o] = a, r - s + 1 >= o - n ? (mo(e, t, s, r), mo(e, t, n, o - 1)) : (mo(e, t, n, o - 1), mo(e, t, s, r));
  }
}
function Ra(e, t, n) {
  const r = e[t];
  e[t] = e[n], e[n] = r;
}
function XP(e) {
  return e[0];
}
function GP(e) {
  return e[1];
}
const pw = 1e-6;
class hs {
  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, r) {
    t = +t, n = +n, r = +r;
    const i = t + r, s = n;
    if (r < 0) throw new Error("negative radius");
    this._x1 === null ? this._ += `M${i},${s}` : (Math.abs(this._x1 - i) > pw || Math.abs(this._y1 - s) > pw) && (this._ += "L" + i + "," + s), r && (this._ += `A${r},${r},0,1,1,${t - r},${n}A${r},${r},0,1,1,${this._x1 = i},${this._y1 = s}`);
  }
  rect(t, n, r, i) {
    this._ += `M${this._x0 = this._x1 = +t},${this._y0 = this._y1 = +n}h${+r}v${+i}h${-r}Z`;
  }
  value() {
    return this._ || null;
  }
}
class K0 {
  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 HP = class {
  constructor(t, [n, r, i, s] = [0, 0, 960, 500]) {
    if (!((i = +i) >= (n = +n)) || !((s = +s) >= (r = +r))) 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 = i, this.xmin = n, this.ymax = s, this.ymin = r, this._init();
  }
  update() {
    return this.delaunay.update(), this._init(), this;
  }
  _init() {
    const { delaunay: { points: t, hull: n, triangles: r }, vectors: i } = this;
    let s, o;
    const a = this.circumcenters = this._circumcenters.subarray(0, r.length / 3 * 2);
    for (let y = 0, m = 0, g = r.length, b, w; y < g; y += 3, m += 2) {
      const _ = r[y] * 2, x = r[y + 1] * 2, v = r[y + 2] * 2, M = t[_], E = t[_ + 1], $ = t[x], N = t[x + 1], A = t[v], D = t[v + 1], k = $ - M, S = N - E, I = A - M, T = D - E, R = (k * T - S * I) * 2;
      if (Math.abs(R) < 1e-9) {
        if (s === void 0) {
          s = o = 0;
          for (const C of n) s += t[C * 2], o += t[C * 2 + 1];
          s /= n.length, o /= n.length;
        }
        const B = 1e9 * Math.sign((s - M) * T - (o - E) * I);
        b = (M + A) / 2 - B * T, w = (E + D) / 2 + B * I;
      } else {
        const B = 1 / R, C = k * k + S * S, F = I * I + T * T;
        b = M + (T * C - S * F) * B, w = E + (k * F - I * C) * B;
      }
      a[m] = b, a[m + 1] = w;
    }
    let c = n[n.length - 1], u, l = c * 4, f, h = t[2 * c], d, p = t[2 * c + 1];
    i.fill(0);
    for (let y = 0; y < n.length; ++y)
      c = n[y], u = l, f = h, d = p, l = c * 4, h = t[2 * c], p = t[2 * c + 1], i[u + 2] = i[l] = d - p, i[u + 3] = i[l + 1] = h - f;
  }
  render(t) {
    const n = t == null ? t = new hs() : void 0, { delaunay: { halfedges: r, inedges: i, hull: s }, circumcenters: o, vectors: a } = this;
    if (s.length <= 1) return null;
    for (let l = 0, f = r.length; l < f; ++l) {
      const h = r[l];
      if (h < l) continue;
      const d = Math.floor(l / 3) * 2, p = Math.floor(h / 3) * 2, y = o[d], m = o[d + 1], g = o[p], b = o[p + 1];
      this._renderSegment(y, m, g, b, t);
    }
    let c, u = s[s.length - 1];
    for (let l = 0; l < s.length; ++l) {
      c = u, u = s[l];
      const f = Math.floor(i[u] / 3) * 2, h = o[f], d = o[f + 1], p = c * 4, y = this._project(h, d, a[p + 2], a[p + 3]);
      y && this._renderSegment(h, d, y[0], y[1], t);
    }
    return n && n.value();
  }
  renderBounds(t) {
    const n = t == null ? t = new hs() : void 0;
    return t.rect(this.xmin, this.ymin, this.xmax - this.xmin, this.ymax - this.ymin), n && n.value();
  }
  renderCell(t, n) {
    const r = n == null ? n = new hs() : void 0, i = this._clip(t);
    if (i === null || !i.length) return;
    n.moveTo(i[0], i[1]);
    let s = i.length;
    for (; i[0] === i[s - 2] && i[1] === i[s - 1] && s > 1; ) s -= 2;
    for (let o = 2; o < s; o += 2)
      (i[o] !== i[o - 2] || i[o + 1] !== i[o - 1]) && n.lineTo(i[o], i[o + 1]);
    return n.closePath(), r && r.value();
  }
  *cellPolygons() {
    const { delaunay: { points: t } } = this;
    for (let n = 0, r = t.length / 2; n < r; ++n) {
      const i = this.cellPolygon(n);
      i && (i.index = n, yield i);
    }
  }
  cellPolygon(t) {
    const n = new K0();
    return this.renderCell(t, n), n.value();
  }
  _renderSegment(t, n, r, i, s) {
    let o;
    const a = this._regioncode(t, n), c = this._regioncode(r, i);
    a === 0 && c === 0 ? (s.moveTo(t, n), s.lineTo(r, i)) : (o = this._clipSegment(t, n, r, i, a, c)) && (s.moveTo(o[0], o[1]), s.lineTo(o[2], o[3]));
  }
  contains(t, n, r) {
    return n = +n, n !== n || (r = +r, r !== r) ? !1 : this.delaunay._step(t, n, r) === t;
  }
  *neighbors(t) {
    const n = this._clip(t);
    if (n) for (const r of this.delaunay.neighbors(t)) {
      const i = this._clip(r);
      if (i) {
        t: for (let s = 0, o = n.length; s < o; s += 2)
          for (let a = 0, c = i.length; a < c; a += 2)
            if (n[s] === i[a] && n[s + 1] === i[a + 1] && n[(s + 2) % o] === i[(a + c - 2) % c] && n[(s + 3) % o] === i[(a + c - 1) % c]) {
              yield r;
              break t;
            }
      }
    }
  }
  _cell(t) {
    const { circumcenters: n, delaunay: { inedges: r, halfedges: i, triangles: s } } = this, o = r[t];
    if (o === -1) return null;
    const a = [];
    let c = o;
    do {
      const u = Math.floor(c / 3);
      if (a.push(n[u * 2], n[u * 2 + 1]), c = c % 3 === 2 ? c - 2 : c + 1, s[c] !== t) break;
      c = i[c];
    } while (c !== o && c !== -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: r } = this, i = t * 4;
    return this._simplify(r[i] || r[i + 1] ? this._clipInfinite(t, n, r[i], r[i + 1], r[i + 2], r[i + 3]) : this._clipFinite(t, n));
  }
  _clipFinite(t, n) {
    const r = n.length;
    let i = null, s, o, a = n[r - 2], c = n[r - 1], u, l = this._regioncode(a, c), f, h = 0;
    for (let d = 0; d < r; d += 2)
      if (s = a, o = c, a = n[d], c = n[d + 1], u = l, l = this._regioncode(a, c), u === 0 && l === 0)
        f = h, h = 0, i ? i.push(a, c) : i = [a, c];
      else {
        let p, y, m, g, b;
        if (u === 0) {
          if ((p = this._clipSegment(s, o, a, c, u, l)) === null) continue;
          [y, m, g, b] = p;
        } else {
          if ((p = this._clipSegment(a, c, s, o, l, u)) === null) continue;
          [g, b, y, m] = p, f = h, h = this._edgecode(y, m), f && h && this._edge(t, f, h, i, i.length), i ? i.push(y, m) : i = [y, m];
        }
        f = h, h = this._edgecode(g, b), f && h && this._edge(t, f, h, i, i.length), i ? i.push(g, b) : i = [g, b];
      }
    if (i)
      f = h, h = this._edgecode(i[0], i[1]), f && h && this._edge(t, f, h, i, i.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 i;
  }
  _clipSegment(t, n, r, i, s, o) {
    const a = s < o;
    for (a && ([t, n, r, i, s, o] = [r, i, t, n, o, s]); ; ) {
      if (s === 0 && o === 0) return a ? [r, i, t, n] : [t, n, r, i];
      if (s & o) return null;
      let c, u, l = s || o;
      l & 8 ? (c = t + (r - t) * (this.ymax - n) / (i - n), u = this.ymax) : l & 4 ? (c = t + (r - t) * (this.ymin - n) / (i - n), u = this.ymin) : l & 2 ? (u = n + (i - n) * (this.xmax - t) / (r - t), c = this.xmax) : (u = n + (i - n) * (this.xmin - t) / (r - t), c = this.xmin), s ? (t = c, n = u, s = this._regioncode(t, n)) : (r = c, i = u, o = this._regioncode(r, i));
    }
  }
  _clipInfinite(t, n, r, i, s, o) {
    let a = Array.from(n), c;
    if ((c = this._project(a[0], a[1], r, i)) && a.unshift(c[0], c[1]), (c = this._project(a[a.length - 2], a[a.length - 1], s, o)) && a.push(c[0], c[1]), a = this._clipFinite(t, a))
      for (let u = 0, l = a.length, f, h = this._edgecode(a[l - 2], a[l - 1]); u < l; u += 2)
        f = h, h = this._edgecode(a[u], a[u + 1]), f && h && (u = this._edge(t, f, h, a, u), l = 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, r, i, s) {
    for (; n !== r; ) {
      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;
      }
      (i[s] !== o || i[s + 1] !== a) && this.contains(t, o, a) && (i.splice(s, 0, o, a), s += 2);
    }
    return s;
  }
  _project(t, n, r, i) {
    let s = 1 / 0, o, a, c;
    if (i < 0) {
      if (n <= this.ymin) return null;
      (o = (this.ymin - n) / i) < s && (c = this.ymin, a = t + (s = o) * r);
    } else if (i > 0) {
      if (n >= this.ymax) return null;
      (o = (this.ymax - n) / i) < s && (c = this.ymax, a = t + (s = o) * r);
    }
    if (r > 0) {
      if (t >= this.xmax) return null;
      (o = (this.xmax - t) / r) < s && (a = this.xmax, c = n + (s = o) * i);
    } else if (r < 0) {
      if (t <= this.xmin) return null;
      (o = (this.xmin - t) / r) < s && (a = this.xmin, c = n + (s = o) * i);
    }
    return [a, c];
  }
  _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 r = (n + 2) % t.length, i = (n + 4) % t.length;
        (t[n] === t[r] && t[r] === t[i] || t[n + 1] === t[r + 1] && t[r + 1] === t[i + 1]) && (t.splice(r, 2), n -= 2);
      }
      t.length || (t = null);
    }
    return t;
  }
};
const JP = 2 * Math.PI, Zs = Math.pow;
function ZP(e) {
  return e[0];
}
function KP(e) {
  return e[1];
}
function QP(e) {
  const { triangles: t, coords: n } = e;
  for (let r = 0; r < t.length; r += 3) {
    const i = 2 * t[r], s = 2 * t[r + 1], o = 2 * t[r + 2];
    if ((n[o] - n[i]) * (n[s + 1] - n[i + 1]) - (n[s] - n[i]) * (n[o + 1] - n[i + 1]) > 1e-10) return !1;
  }
  return !0;
}
function tU(e, t, n) {
  return [e + Math.sin(e + t) * n, t + Math.cos(e - t) * n];
}
class Gi {
  static from(t, n = ZP, r = KP, i) {
    return new Gi("length" in t ? eU(t, n, r, i) : Float64Array.from(nU(t, n, r, i)));
  }
  constructor(t) {
    this._delaunator = new qf(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 && QP(t)) {
      this.collinear = Int32Array.from({ length: n.length / 2 }, (h, d) => d).sort((h, d) => n[2 * h] - n[2 * d] || n[2 * h + 1] - n[2 * d + 1]);
      const c = this.collinear[0], u = this.collinear[this.collinear.length - 1], l = [n[2 * c], n[2 * c + 1], n[2 * u], n[2 * u + 1]], f = 1e-8 * Math.hypot(l[3] - l[1], l[2] - l[0]);
      for (let h = 0, d = n.length / 2; h < d; ++h) {
        const p = tU(n[2 * h], n[2 * h + 1], f);
        n[2 * h] = p[0], n[2 * h + 1] = p[1];
      }
      this._delaunator = new qf(n);
    } else
      delete this.collinear;
    const r = this.halfedges = this._delaunator.halfedges, i = this.hull = this._delaunator.hull, s = this.triangles = this._delaunator.triangles, o = this.inedges.fill(-1), a = this._hullIndex.fill(-1);
    for (let c = 0, u = r.length; c < u; ++c) {
      const l = s[c % 3 === 2 ? c - 2 : c + 1];
      (r[c] === -1 || o[l] === -1) && (o[l] = c);
    }
    for (let c = 0, u = i.length; c < u; ++c)
      a[i[c]] = c;
    i.length <= 2 && i.length > 0 && (this.triangles = new Int32Array(3).fill(-1), this.halfedges = new Int32Array(3).fill(-1), this.triangles[0] = i[0], o[i[0]] = 1, i.length === 2 && (o[i[1]] = 0, this.triangles[1] = i[1], this.triangles[2] = i[1]));
  }
  voronoi(t) {
    return new HP(this, t);
  }
  *neighbors(t) {
    const { inedges: n, hull: r, _hullIndex: i, 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 c = n[t];
    if (c === -1) return;
    let u = c, l = -1;
    do {
      if (yield l = o[u], u = u % 3 === 2 ? u - 2 : u + 1, o[u] !== t) return;
      if (u = s[u], u === -1) {
        const f = r[(i[t] + 1) % r.length];
        f !== l && (yield f);
        return;
      }
    } while (u !== c);
  }
  find(t, n, r = 0) {
    if (t = +t, t !== t || (n = +n, n !== n)) return -1;
    const i = r;
    let s;
    for (; (s = this._step(r, t, n)) >= 0 && s !== r && s !== i; ) r = s;
    return s;
  }
  _step(t, n, r) {
    const { inedges: i, hull: s, _hullIndex: o, halfedges: a, triangles: c, points: u } = this;
    if (i[t] === -1 || !u.length) return (t + 1) % (u.length >> 1);
    let l = t, f = Zs(n - u[t * 2], 2) + Zs(r - u[t * 2 + 1], 2);
    const h = i[t];
    let d = h;
    do {
      let p = c[d];
      const y = Zs(n - u[p * 2], 2) + Zs(r - u[p * 2 + 1], 2);
      if (y < f && (f = y, l = p), d = d % 3 === 2 ? d - 2 : d + 1, c[d] !== t) break;
      if (d = a[d], d === -1) {
        if (d = s[(o[t] + 1) % s.length], d !== p && Zs(n - u[d * 2], 2) + Zs(r - u[d * 2 + 1], 2) < f)
          return d;
        break;
      }
    } while (d !== h);
    return l;
  }
  render(t) {
    const n = t == null ? t = new hs() : void 0, { points: r, halfedges: i, triangles: s } = this;
    for (let o = 0, a = i.length; o < a; ++o) {
      const c = i[o];
      if (c < o) continue;
      const u = s[o] * 2, l = s[c] * 2;
      t.moveTo(r[u], r[u + 1]), t.lineTo(r[l], r[l + 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 r = t == null ? t = new hs() : void 0, { points: i } = this;
    for (let s = 0, o = i.length; s < o; s += 2) {
      const a = i[s], c = i[s + 1];
      t.moveTo(a + n, c), t.arc(a, c, n, 0, JP);
    }
    return r && r.value();
  }
  renderHull(t) {
    const n = t == null ? t = new hs() : void 0, { hull: r, points: i } = this, s = r[0] * 2, o = r.length;
    t.moveTo(i[s], i[s + 1]);
    for (let a = 1; a < o; ++a) {
      const c = 2 * r[a];
      t.lineTo(i[c], i[c + 1]);
    }
    return t.closePath(), n && n.value();
  }
  hullPolygon() {
    const t = new K0();
    return this.renderHull(t), t.value();
  }
  renderTriangle(t, n) {
    const r = n == null ? n = new hs() : void 0, { points: i, triangles: s } = this, o = s[t *= 3] * 2, a = s[t + 1] * 2, c = s[t + 2] * 2;
    return n.moveTo(i[o], i[o + 1]), n.lineTo(i[a], i[a + 1]), n.lineTo(i[c], i[c + 1]), n.closePath(), r && r.value();
  }
  *trianglePolygons() {
    const { triangles: t } = this;
    for (let n = 0, r = t.length / 3; n < r; ++n)
      yield this.trianglePolygon(n);
  }
  trianglePolygon(t) {
    const n = new K0();
    return this.renderTriangle(t, n), n.value();
  }
}
function eU(e, t, n, r) {
  const i = e.length, s = new Float64Array(i * 2);
  for (let o = 0; o < i; ++o) {
    const a = e[o];
    s[o * 2] = t.call(r, a, o, e), s[o * 2 + 1] = n.call(r, a, o, e);
  }
  return s;
}
function* nU(e, t, n, r) {
  let i = 0;
  for (const s of e)
    yield t.call(r, s, i, e), yield n.call(r, s, i, e), ++i;
}
function rU(e) {
  return Math.abs(e = Math.round(e)) >= 1e21 ? e.toLocaleString("en").replace(/,/g, "") : e.toString(10);
}
function jf(e, t) {
  if ((n = (e = t ? e.toExponential(t - 1) : e.toExponential()).indexOf("e")) < 0) return null;
  var n, r = e.slice(0, n);
  return [
    r.length > 1 ? r[0] + r.slice(2) : r,
    +e.slice(n + 1)
  ];
}
function Ho(e) {
  return e = jf(Math.abs(e)), e ? e[1] : NaN;
}
function iU(e, t) {
  return function(n, r) {
    for (var i = n.length, s = [], o = 0, a = e[0], c = 0; i > 0 && a > 0 && (c + a + 1 > r && (a = Math.max(1, r - c)), s.push(n.substring(i -= a, i + a)), !((c += a + 1) > r)); )
      a = e[o = (o + 1) % e.length];
    return s.reverse().join(t);
  };
}
function sU(e) {
  return function(t) {
    return t.replace(/[0-9]/g, function(n) {
      return e[+n];
    });
  };
}
var oU = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
function Cc(e) {
  if (!(t = oU.exec(e))) throw new Error("invalid format: " + e);
  var t;
  return new Zm({
    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]
  });
}
Cc.prototype = Zm.prototype;
function Zm(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 + "";
}
Zm.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 aU(e) {
  t: for (var t = e.length, n = 1, r = -1, i; n < t; ++n)
    switch (e[n]) {
      case ".":
        r = i = n;
        break;
      case "0":
        r === 0 && (r = n), i = n;
        break;
      default:
        if (!+e[n]) break t;
        r > 0 && (r = 0);
        break;
    }
  return r > 0 ? e.slice(0, r) + e.slice(i + 1) : e;
}
var o3;
function cU(e, t) {
  var n = jf(e, t);
  if (!n) return e + "";
  var r = n[0], i = n[1], s = i - (o3 = Math.max(-8, Math.min(8, Math.floor(i / 3))) * 3) + 1, o = r.length;
  return s === o ? r : s > o ? r + new Array(s - o + 1).join("0") : s > 0 ? r.slice(0, s) + "." + r.slice(s) : "0." + new Array(1 - s).join("0") + jf(e, Math.max(0, t + s - 1))[0];
}
function yw(e, t) {
  var n = jf(e, t);
  if (!n) return e + "";
  var r = n[0], i = n[1];
  return i < 0 ? "0." + new Array(-i).join("0") + r : r.length > i + 1 ? r.slice(0, i + 1) + "." + r.slice(i + 1) : r + new Array(i - r.length + 2).join("0");
}
const mw = {
  "%": (e, t) => (e * 100).toFixed(t),
  b: (e) => Math.round(e).toString(2),
  c: (e) => e + "",
  d: rU,
  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) => yw(e * 100, t),
  r: yw,
  s: cU,
  X: (e) => Math.round(e).toString(16).toUpperCase(),
  x: (e) => Math.round(e).toString(16)
};
function gw(e) {
  return e;
}
var bw = Array.prototype.map, ww = ["y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"];
function uU(e) {
  var t = e.grouping === void 0 || e.thousands === void 0 ? gw : iU(bw.call(e.grouping, Number), e.thousands + ""), n = e.currency === void 0 ? "" : e.currency[0] + "", r = e.currency === void 0 ? "" : e.currency[1] + "", i = e.decimal === void 0 ? "." : e.decimal + "", s = e.numerals === void 0 ? gw : sU(bw.call(e.numerals, String)), o = e.percent === void 0 ? "%" : e.percent + "", a = e.minus === void 0 ? "−" : e.minus + "", c = e.nan === void 0 ? "NaN" : e.nan + "";
  function u(f) {
    f = Cc(f);
    var h = f.fill, d = f.align, p = f.sign, y = f.symbol, m = f.zero, g = f.width, b = f.comma, w = f.precision, _ = f.trim, x = f.type;
    x === "n" ? (b = !0, x = "g") : mw[x] || (w === void 0 && (w = 12), _ = !0, x = "g"), (m || h === "0" && d === "=") && (m = !0, h = "0", d = "=");
    var v = y === "$" ? n : y === "#" && /[boxX]/.test(x) ? "0" + x.toLowerCase() : "", M = y === "$" ? r : /[%p]/.test(x) ? o : "", E = mw[x], $ = /[defgprs%]/.test(x);
    w = w === void 0 ? 6 : /[gprs]/.test(x) ? Math.max(1, Math.min(21, w)) : Math.max(0, Math.min(20, w));
    function N(A) {
      var D = v, k = M, S, I, T;
      if (x === "c")
        k = E(A) + k, A = "";
      else {
        A = +A;
        var R = A < 0 || 1 / A < 0;
        if (A = isNaN(A) ? c : E(Math.abs(A), w), _ && (A = aU(A)), R && +A == 0 && p !== "+" && (R = !1), D = (R ? p === "(" ? p : a : p === "-" || p === "(" ? "" : p) + D, k = (x === "s" ? ww[8 + o3 / 3] : "") + k + (R && p === "(" ? ")" : ""), $) {
          for (S = -1, I = A.length; ++S < I; )
            if (T = A.charCodeAt(S), 48 > T || T > 57) {
              k = (T === 46 ? i + A.slice(S + 1) : A.slice(S)) + k, A = A.slice(0, S);
              break;
            }
        }
      }
      b && !m && (A = t(A, 1 / 0));
      var B = D.length + A.length + k.length, C = B < g ? new Array(g - B + 1).join(h) : "";
      switch (b && m && (A = t(C + A, C.length ? g - k.length : 1 / 0), C = ""), d) {
        case "<":
          A = D + A + k + C;
          break;
        case "=":
          A = D + C + A + k;
          break;
        case "^":
          A = C.slice(0, B = C.length >> 1) + D + A + k + C.slice(B);
          break;
        default:
          A = C + D + A + k;
          break;
      }
      return s(A);
    }
    return N.toString = function() {
      return f + "";
    }, N;
  }
  function l(f, h) {
    var d = u((f = Cc(f), f.type = "f", f)), p = Math.max(-8, Math.min(8, Math.floor(Ho(h) / 3))) * 3, y = Math.pow(10, -p), m = ww[8 + p / 3];
    return function(g) {
      return d(y * g) + m;
    };
  }
  return {
    format: u,
    formatPrefix: l
  };
}
var el, ga, a3;
lU({
  thousands: ",",
  grouping: [3],
  currency: ["$", ""]
});
function lU(e) {
  return el = uU(e), ga = el.format, a3 = el.formatPrefix, el;
}
function fU(e) {
  return Math.max(0, -Ho(Math.abs(e)));
}
function hU(e, t) {
  return Math.max(0, Math.max(-8, Math.min(8, Math.floor(Ho(t) / 3))) * 3 - Ho(Math.abs(e)));
}
function dU(e, t) {
  return e = Math.abs(e), t = Math.abs(t) - e, Math.max(0, Ho(t) - Ho(e)) + 1;
}
var ut = 1e-6, Vf = 1e-12, Mt = Math.PI, ae = Mt / 2, _w = Mt / 4, ln = Mt * 2, Me = 180 / Mt, Lt = Mt / 180, Bt = Math.abs, ba = Math.atan, Vn = Math.atan2, pt = Math.cos, nl = Math.ceil, c3 = Math.exp, Q0 = Math.hypot, Yf = Math.log, Ip = Math.pow, et = Math.sin, vn = Math.sign || function(e) {
  return e > 0 ? 1 : e < 0 ? -1 : 0;
}, Ue = Math.sqrt, Km = Math.tan;
function u3(e) {
  return e > 1 ? 0 : e < -1 ? Mt : Math.acos(e);
}
function Ke(e) {
  return e > 1 ? ae : e < -1 ? -ae : Math.asin(e);
}
function on() {
}
function Wf(e, t) {
  e && xw.hasOwnProperty(e.type) && xw[e.type](e, t);
}
var vw = {
  Feature: function(e, t) {
    Wf(e.geometry, t);
  },
  FeatureCollection: function(e, t) {
    for (var n = e.features, r = -1, i = n.length; ++r < i; ) Wf(n[r].geometry, t);
  }
}, xw = {
  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, r = -1, i = n.length; ++r < i; ) e = n[r], t.point(e[0], e[1], e[2]);
  },
  LineString: function(e, t) {
    ty(e.coordinates, t, 0);
  },
  MultiLineString: function(e, t) {
    for (var n = e.coordinates, r = -1, i = n.length; ++r < i; ) ty(n[r], t, 0);
  },
  Polygon: function(e, t) {
    Sw(e.coordinates, t);
  },
  MultiPolygon: function(e, t) {
    for (var n = e.coordinates, r = -1, i = n.length; ++r < i; ) Sw(n[r], t);
  },
  GeometryCollection: function(e, t) {
    for (var n = e.geometries, r = -1, i = n.length; ++r < i; ) Wf(n[r], t);
  }
};
function ty(e, t, n) {
  var r = -1, i = e.length - n, s;
  for (t.lineStart(); ++r < i; ) s = e[r], t.point(s[0], s[1], s[2]);
  t.lineEnd();
}
function Sw(e, t) {
  var n = -1, r = e.length;
  for (t.polygonStart(); ++n < r; ) ty(e[n], t, 1);
  t.polygonEnd();
}
function Si(e, t) {
  e && vw.hasOwnProperty(e.type) ? vw[e.type](e, t) : Wf(e, t);
}
function ey(e) {
  return [Vn(e[1], e[0]), Ke(e[2])];
}
function Jo(e) {
  var t = e[0], n = e[1], r = pt(n);
  return [r * pt(t), r * et(t), et(n)];
}
function rl(e, t) {
  return e[0] * t[0] + e[1] * t[1] + e[2] * t[2];
}
function Xf(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 Tp(e, t) {
  e[0] += t[0], e[1] += t[1], e[2] += t[2];
}
function il(e, t) {
  return [e[0] * t, e[1] * t, e[2] * t];
}
function ny(e) {
  var t = Ue(e[0] * e[0] + e[1] * e[1] + e[2] * e[2]);
  e[0] /= t, e[1] /= t, e[2] /= t;
}
var ec, Gf, Hf, Jf, Zf, Kf, Qf, th, ry, iy, sy, l3, f3, ke, Fe, Be, Bn = {
  sphere: on,
  point: Qm,
  lineStart: Mw,
  lineEnd: Aw,
  polygonStart: function() {
    Bn.lineStart = mU, Bn.lineEnd = gU;
  },
  polygonEnd: function() {
    Bn.lineStart = Mw, Bn.lineEnd = Aw;
  }
};
function Qm(e, t) {
  e *= Lt, t *= Lt;
  var n = pt(t);
  yu(n * pt(e), n * et(e), et(t));
}
function yu(e, t, n) {
  ++ec, Hf += (e - Hf) / ec, Jf += (t - Jf) / ec, Zf += (n - Zf) / ec;
}
function Mw() {
  Bn.point = pU;
}
function pU(e, t) {
  e *= Lt, t *= Lt;
  var n = pt(t);
  ke = n * pt(e), Fe = n * et(e), Be = et(t), Bn.point = yU, yu(ke, Fe, Be);
}
function yU(e, t) {
  e *= Lt, t *= Lt;
  var n = pt(t), r = n * pt(e), i = n * et(e), s = et(t), o = Vn(Ue((o = Fe * s - Be * i) * o + (o = Be * r - ke * s) * o + (o = ke * i - Fe * r) * o), ke * r + Fe * i + Be * s);
  Gf += o, Kf += o * (ke + (ke = r)), Qf += o * (Fe + (Fe = i)), th += o * (Be + (Be = s)), yu(ke, Fe, Be);
}
function Aw() {
  Bn.point = Qm;
}
function mU() {
  Bn.point = bU;
}
function gU() {
  h3(l3, f3), Bn.point = Qm;
}
function bU(e, t) {
  l3 = e, f3 = t, e *= Lt, t *= Lt, Bn.point = h3;
  var n = pt(t);
  ke = n * pt(e), Fe = n * et(e), Be = et(t), yu(ke, Fe, Be);
}
function h3(e, t) {
  e *= Lt, t *= Lt;
  var n = pt(t), r = n * pt(e), i = n * et(e), s = et(t), o = Fe * s - Be * i, a = Be * r - ke * s, c = ke * i - Fe * r, u = Q0(o, a, c), l = Ke(u), f = u && -l / u;
  ry.add(f * o), iy.add(f * a), sy.add(f * c), Gf += l, Kf += l * (ke + (ke = r)), Qf += l * (Fe + (Fe = i)), th += l * (Be + (Be = s)), yu(ke, Fe, Be);
}
function wU(e) {
  ec = Gf = Hf = Jf = Zf = Kf = Qf = th = 0, ry = new dr(), iy = new dr(), sy = new dr(), Si(e, Bn);
  var t = +ry, n = +iy, r = +sy, i = Q0(t, n, r);
  return i < Vf && (t = Kf, n = Qf, r = th, Gf < ut && (t = Hf, n = Jf, r = Zf), i = Q0(t, n, r), i < Vf) ? [NaN, NaN] : [Vn(n, t) * Me, Ke(r / i) * Me];
}
function oy(e, t) {
  function n(r, i) {
    return r = e(r, i), t(r[0], r[1]);
  }
  return e.invert && t.invert && (n.invert = function(r, i) {
    return r = t.invert(r, i), r && e.invert(r[0], r[1]);
  }), n;
}
function ay(e, t) {
  return Bt(e) > Mt && (e -= Math.round(e / ln) * ln), [e, t];
}
ay.invert = ay;
function d3(e, t, n) {
  return (e %= ln) ? t || n ? oy(Iw(e), Tw(t, n)) : Iw(e) : t || n ? Tw(t, n) : ay;
}
function $w(e) {
  return function(t, n) {
    return t += e, Bt(t) > Mt && (t -= Math.round(t / ln) * ln), [t, n];
  };
}
function Iw(e) {
  var t = $w(e);
  return t.invert = $w(-e), t;
}
function Tw(e, t) {
  var n = pt(e), r = et(e), i = pt(t), s = et(t);
  function o(a, c) {
    var u = pt(c), l = pt(a) * u, f = et(a) * u, h = et(c), d = h * n + l * r;
    return [
      Vn(f * i - d * s, l * n - h * r),
      Ke(d * i + f * s)
    ];
  }
  return o.invert = function(a, c) {
    var u = pt(c), l = pt(a) * u, f = et(a) * u, h = et(c), d = h * i - f * s;
    return [
      Vn(f * i + h * s, l * n + d * r),
      Ke(d * n - l * r)
    ];
  }, o;
}
function _U(e) {
  e = d3(e[0] * Lt, e[1] * Lt, e.length > 2 ? e[2] * Lt : 0);
  function t(n) {
    return n = e(n[0] * Lt, n[1] * Lt), n[0] *= Me, n[1] *= Me, n;
  }
  return t.invert = function(n) {
    return n = e.invert(n[0] * Lt, n[1] * Lt), n[0] *= Me, n[1] *= Me, n;
  }, t;
}
function vU(e, t, n, r, i, s) {
  if (n) {
    var o = pt(t), a = et(t), c = r * n;
    i == null ? (i = t + r * ln, s = t - c / 2) : (i = Ew(o, i), s = Ew(o, s), (r > 0 ? i < s : i > s) && (i += r * ln));
    for (var u, l = i; r > 0 ? l > s : l < s; l -= c)
      u = ey([o, -a * pt(l), -a * et(l)]), e.point(u[0], u[1]);
  }
}
function Ew(e, t) {
  t = Jo(t), t[0] -= e, ny(t);
  var n = u3(-t[1]);
  return ((-t[2] < 0 ? -n : n) + ln - ut) % ln;
}
function p3() {
  var e = [], t;
  return {
    point: function(n, r, i) {
      t.push([n, r, i]);
    },
    lineStart: function() {
      e.push(t = []);
    },
    lineEnd: on,
    rejoin: function() {
      e.length > 1 && e.push(e.pop().concat(e.shift()));
    },
    result: function() {
      var n = e;
      return e = [], t = null, n;
    }
  };
}
function Wl(e, t) {
  return Bt(e[0] - t[0]) < ut && Bt(e[1] - t[1]) < ut;
}
function sl(e, t, n, r) {
  this.x = e, this.z = t, this.o = n, this.e = r, this.v = !1, this.n = this.p = null;
}
function y3(e, t, n, r, i) {
  var s = [], o = [], a, c;
  if (e.forEach(function(p) {
    if (!((y = p.length - 1) <= 0)) {
      var y, m = p[0], g = p[y], b;
      if (Wl(m, g)) {
        if (!m[2] && !g[2]) {
          for (i.lineStart(), a = 0; a < y; ++a) i.point((m = p[a])[0], m[1]);
          i.lineEnd();
          return;
        }
        g[0] += 2 * ut;
      }
      s.push(b = new sl(m, p, null, !0)), o.push(b.o = new sl(m, null, b, !1)), s.push(b = new sl(g, p, null, !1)), o.push(b.o = new sl(g, null, b, !0));
    }
  }), !!s.length) {
    for (o.sort(t), Nw(s), Nw(o), a = 0, c = o.length; a < c; ++a)
      o[a].e = n = !n;
    for (var u = s[0], l, f; ; ) {
      for (var h = u, d = !0; h.v; ) if ((h = h.n) === u) return;
      l = h.z, i.lineStart();
      do {
        if (h.v = h.o.v = !0, h.e) {
          if (d)
            for (a = 0, c = l.length; a < c; ++a) i.point((f = l[a])[0], f[1]);
          else
            r(h.x, h.n.x, 1, i);
          h = h.n;
        } else {
          if (d)
            for (l = h.p.z, a = l.length - 1; a >= 0; --a) i.point((f = l[a])[0], f[1]);
          else
            r(h.x, h.p.x, -1, i);
          h = h.p;
        }
        h = h.o, l = h.z, d = !d;
      } while (!h.v);
      i.lineEnd();
    }
  }
}
function Nw(e) {
  if (t = e.length) {
    for (var t, n = 0, r = e[0], i; ++n < t; )
      r.n = i = e[n], i.p = r, r = i;
    r.n = i = e[0], i.p = r;
  }
}
function Ep(e) {
  return Bt(e[0]) <= Mt ? e[0] : vn(e[0]) * ((Bt(e[0]) + Mt) % ln - Mt);
}
function xU(e, t) {
  var n = Ep(t), r = t[1], i = et(r), s = [et(n), -pt(n), 0], o = 0, a = 0, c = new dr();
  i === 1 ? r = ae + ut : i === -1 && (r = -ae - ut);
  for (var u = 0, l = e.length; u < l; ++u)
    if (h = (f = e[u]).length)
      for (var f, h, d = f[h - 1], p = Ep(d), y = d[1] / 2 + _w, m = et(y), g = pt(y), b = 0; b < h; ++b, p = _, m = v, g = M, d = w) {
        var w = f[b], _ = Ep(w), x = w[1] / 2 + _w, v = et(x), M = pt(x), E = _ - p, $ = E >= 0 ? 1 : -1, N = $ * E, A = N > Mt, D = m * v;
        if (c.add(Vn(D * $ * et(N), g * M + D * pt(N))), o += A ? E + $ * ln : E, A ^ p >= n ^ _ >= n) {
          var k = Xf(Jo(d), Jo(w));
          ny(k);
          var S = Xf(s, k);
          ny(S);
          var I = (A ^ E >= 0 ? -1 : 1) * Ke(S[2]);
          (r > I || r === I && (k[0] || k[1])) && (a += A ^ E >= 0 ? 1 : -1);
        }
      }
  return (o < -ut || o < ut && c < -Vf) ^ a & 1;
}
function m3(e, t, n, r) {
  return function(i) {
    var s = t(i), o = p3(), a = t(o), c = !1, u, l, f, h = {
      point: d,
      lineStart: y,
      lineEnd: m,
      polygonStart: function() {
        h.point = g, h.lineStart = b, h.lineEnd = w, l = [], u = [];
      },
      polygonEnd: function() {
        h.point = d, h.lineStart = y, h.lineEnd = m, l = bS(l);
        var _ = xU(u, r);
        l.length ? (c || (i.polygonStart(), c = !0), y3(l, MU, _, n, i)) : _ && (c || (i.polygonStart(), c = !0), i.lineStart(), n(null, null, 1, i), i.lineEnd()), c && (i.polygonEnd(), c = !1), l = u = null;
      },
      sphere: function() {
        i.polygonStart(), i.lineStart(), n(null, null, 1, i), i.lineEnd(), i.polygonEnd();
      }
    };
    function d(_, x) {
      e(_, x) && i.point(_, x);
    }
    function p(_, x) {
      s.point(_, x);
    }
    function y() {
      h.point = p, s.lineStart();
    }
    function m() {
      h.point = d, s.lineEnd();
    }
    function g(_, x) {
      f.push([_, x]), a.point(_, x);
    }
    function b() {
      a.lineStart(), f = [];
    }
    function w() {
      g(f[0][0], f[0][1]), a.lineEnd();
      var _ = a.clean(), x = o.result(), v, M = x.length, E, $, N;
      if (f.pop(), u.push(f), f = null, !!M) {
        if (_ & 1) {
          if ($ = x[0], (E = $.length - 1) > 0) {
            for (c || (i.polygonStart(), c = !0), i.lineStart(), v = 0; v < E; ++v) i.point((N = $[v])[0], N[1]);
            i.lineEnd();
          }
          return;
        }
        M > 1 && _ & 2 && x.push(x.pop().concat(x.shift())), l.push(x.filter(SU));
      }
    }
    return h;
  };
}
function SU(e) {
  return e.length > 1;
}
function MU(e, t) {
  return ((e = e.x)[0] < 0 ? e[1] - ae - ut : ae - e[1]) - ((t = t.x)[0] < 0 ? t[1] - ae - ut : ae - t[1]);
}
const Dw = m3(
  function() {
    return !0;
  },
  AU,
  IU,
  [-Mt, -ae]
);
function AU(e) {
  var t = NaN, n = NaN, r = NaN, i;
  return {
    lineStart: function() {
      e.lineStart(), i = 1;
    },
    point: function(s, o) {
      var a = s > 0 ? Mt : -Mt, c = Bt(s - t);
      Bt(c - Mt) < ut ? (e.point(t, n = (n + o) / 2 > 0 ? ae : -ae), e.point(r, n), e.lineEnd(), e.lineStart(), e.point(a, n), e.point(s, n), i = 0) : r !== a && c >= Mt && (Bt(t - r) < ut && (t -= r * ut), Bt(s - a) < ut && (s -= a * ut), n = $U(t, n, s, o), e.point(r, n), e.lineEnd(), e.lineStart(), e.point(a, n), i = 0), e.point(t = s, n = o), r = a;
    },
    lineEnd: function() {
      e.lineEnd(), t = n = NaN;
    },
    clean: function() {
      return 2 - i;
    }
  };
}
function $U(e, t, n, r) {
  var i, s, o = et(e - n);
  return Bt(o) > ut ? ba((et(t) * (s = pt(r)) * et(n) - et(r) * (i = pt(t)) * et(e)) / (i * s * o)) : (t + r) / 2;
}
function IU(e, t, n, r) {
  var i;
  if (e == null)
    i = n * ae, r.point(-Mt, i), r.point(0, i), r.point(Mt, i), r.point(Mt, 0), r.point(Mt, -i), r.point(0, -i), r.point(-Mt, -i), r.point(-Mt, 0), r.point(-Mt, i);
  else if (Bt(e[0] - t[0]) > ut) {
    var s = e[0] < t[0] ? Mt : -Mt;
    i = n * s / 2, r.point(-s, i), r.point(0, i), r.point(s, i);
  } else
    r.point(t[0], t[1]);
}
function TU(e) {
  var t = pt(e), n = 6 * Lt, r = t > 0, i = Bt(t) > ut;
  function s(l, f, h, d) {
    vU(d, e, n, h, l, f);
  }
  function o(l, f) {
    return pt(l) * pt(f) > t;
  }
  function a(l) {
    var f, h, d, p, y;
    return {
      lineStart: function() {
        p = d = !1, y = 1;
      },
      point: function(m, g) {
        var b = [m, g], w, _ = o(m, g), x = r ? _ ? 0 : u(m, g) : _ ? u(m + (m < 0 ? Mt : -Mt), g) : 0;
        if (!f && (p = d = _) && l.lineStart(), _ !== d && (w = c(f, b), (!w || Wl(f, w) || Wl(b, w)) && (b[2] = 1)), _ !== d)
          y = 0, _ ? (l.lineStart(), w = c(b, f), l.point(w[0], w[1])) : (w = c(f, b), l.point(w[0], w[1], 2), l.lineEnd()), f = w;
        else if (i && f && r ^ _) {
          var v;
          !(x & h) && (v = c(b, f, !0)) && (y = 0, r ? (l.lineStart(), l.point(v[0][0], v[0][1]), l.point(v[1][0], v[1][1]), l.lineEnd()) : (l.point(v[1][0], v[1][1]), l.lineEnd(), l.lineStart(), l.point(v[0][0], v[0][1], 3)));
        }
        _ && (!f || !Wl(f, b)) && l.point(b[0], b[1]), f = b, d = _, h = x;
      },
      lineEnd: function() {
        d && l.lineEnd(), f = null;
      },
      // Rejoin first and last segments if there were intersections and the first
      // and last points were visible.
      clean: function() {
        return y | (p && d) << 1;
      }
    };
  }
  function c(l, f, h) {
    var d = Jo(l), p = Jo(f), y = [1, 0, 0], m = Xf(d, p), g = rl(m, m), b = m[0], w = g - b * b;
    if (!w) return !h && l;
    var _ = t * g / w, x = -t * b / w, v = Xf(y, m), M = il(y, _), E = il(m, x);
    Tp(M, E);
    var $ = v, N = rl(M, $), A = rl($, $), D = N * N - A * (rl(M, M) - 1);
    if (!(D < 0)) {
      var k = Ue(D), S = il($, (-N - k) / A);
      if (Tp(S, M), S = ey(S), !h) return S;
      var I = l[0], T = f[0], R = l[1], B = f[1], C;
      T < I && (C = I, I = T, T = C);
      var F = T - I, P = Bt(F - Mt) < ut, U = P || F < ut;
      if (!P && B < R && (C = R, R = B, B = C), U ? P ? R + B > 0 ^ S[1] < (Bt(S[0] - I) < ut ? R : B) : R <= S[1] && S[1] <= B : F > Mt ^ (I <= S[0] && S[0] <= T)) {
        var Y = il($, (-N + k) / A);
        return Tp(Y, M), [S, ey(Y)];
      }
    }
  }
  function u(l, f) {
    var h = r ? e : Mt - e, d = 0;
    return l < -h ? d |= 1 : l > h && (d |= 2), f < -h ? d |= 4 : f > h && (d |= 8), d;
  }
  return m3(o, a, s, r ? [0, -e] : [-Mt, e - Mt]);
}
function EU(e, t, n, r, i, s) {
  var o = e[0], a = e[1], c = t[0], u = t[1], l = 0, f = 1, h = c - o, d = u - a, p;
  if (p = n - o, !(!h && p > 0)) {
    if (p /= h, h < 0) {
      if (p < l) return;
      p < f && (f = p);
    } else if (h > 0) {
      if (p > f) return;
      p > l && (l = p);
    }
    if (p = i - o, !(!h && p < 0)) {
      if (p /= h, h < 0) {
        if (p > f) return;
        p > l && (l = p);
      } else if (h > 0) {
        if (p < l) return;
        p < f && (f = p);
      }
      if (p = r - a, !(!d && p > 0)) {
        if (p /= d, d < 0) {
          if (p < l) return;
          p < f && (f = p);
        } else if (d > 0) {
          if (p > f) return;
          p > l && (l = p);
        }
        if (p = s - a, !(!d && p < 0)) {
          if (p /= d, d < 0) {
            if (p > f) return;
            p > l && (l = p);
          } else if (d > 0) {
            if (p < l) return;
            p < f && (f = p);
          }
          return l > 0 && (e[0] = o + l * h, e[1] = a + l * d), f < 1 && (t[0] = o + f * h, t[1] = a + f * d), !0;
        }
      }
    }
  }
}
var nc = 1e9, ol = -nc;
function g3(e, t, n, r) {
  function i(u, l) {
    return e <= u && u <= n && t <= l && l <= r;
  }
  function s(u, l, f, h) {
    var d = 0, p = 0;
    if (u == null || (d = o(u, f)) !== (p = o(l, f)) || c(u, l) < 0 ^ f > 0)
      do
        h.point(d === 0 || d === 3 ? e : n, d > 1 ? r : t);
      while ((d = (d + f + 4) % 4) !== p);
    else
      h.point(l[0], l[1]);
  }
  function o(u, l) {
    return Bt(u[0] - e) < ut ? l > 0 ? 0 : 3 : Bt(u[0] - n) < ut ? l > 0 ? 2 : 1 : Bt(u[1] - t) < ut ? l > 0 ? 1 : 0 : l > 0 ? 3 : 2;
  }
  function a(u, l) {
    return c(u.x, l.x);
  }
  function c(u, l) {
    var f = o(u, 1), h = o(l, 1);
    return f !== h ? f - h : f === 0 ? l[1] - u[1] : f === 1 ? u[0] - l[0] : f === 2 ? u[1] - l[1] : l[0] - u[0];
  }
  return function(u) {
    var l = u, f = p3(), h, d, p, y, m, g, b, w, _, x, v, M = {
      point: E,
      lineStart: D,
      lineEnd: k,
      polygonStart: N,
      polygonEnd: A
    };
    function E(I, T) {
      i(I, T) && l.point(I, T);
    }
    function $() {
      for (var I = 0, T = 0, R = d.length; T < R; ++T)
        for (var B = d[T], C = 1, F = B.length, P = B[0], U, Y, G = P[0], K = P[1]; C < F; ++C)
          U = G, Y = K, P = B[C], G = P[0], K = P[1], Y <= r ? K > r && (G - U) * (r - Y) > (K - Y) * (e - U) && ++I : K <= r && (G - U) * (r - Y) < (K - Y) * (e - U) && --I;
      return I;
    }
    function N() {
      l = f, h = [], d = [], v = !0;
    }
    function A() {
      var I = $(), T = v && I, R = (h = bS(h)).length;
      (T || R) && (u.polygonStart(), T && (u.lineStart(), s(null, null, 1, u), u.lineEnd()), R && y3(h, a, I, s, u), u.polygonEnd()), l = u, h = d = p = null;
    }
    function D() {
      M.point = S, d && d.push(p = []), x = !0, _ = !1, b = w = NaN;
    }
    function k() {
      h && (S(y, m), g && _ && f.rejoin(), h.push(f.result())), M.point = E, _ && l.lineEnd();
    }
    function S(I, T) {
      var R = i(I, T);
      if (d && p.push([I, T]), x)
        y = I, m = T, g = R, x = !1, R && (l.lineStart(), l.point(I, T));
      else if (R && _) l.point(I, T);
      else {
        var B = [b = Math.max(ol, Math.min(nc, b)), w = Math.max(ol, Math.min(nc, w))], C = [I = Math.max(ol, Math.min(nc, I)), T = Math.max(ol, Math.min(nc, T))];
        EU(B, C, e, t, n, r) ? (_ || (l.lineStart(), l.point(B[0], B[1])), l.point(C[0], C[1]), R || l.lineEnd(), v = !1) : R && (l.lineStart(), l.point(I, T), v = !1);
      }
      b = I, w = T, _ = R;
    }
    return M;
  };
}
function Ow(e, t, n) {
  var r = sn(e, t - ut, n).concat(t);
  return function(i) {
    return r.map(function(s) {
      return [i, s];
    });
  };
}
function Lw(e, t, n) {
  var r = sn(e, t - ut, n).concat(t);
  return function(i) {
    return r.map(function(s) {
      return [s, i];
    });
  };
}
function NU() {
  var e, t, n, r, i, s, o, a, c = 10, u = c, l = 90, f = 360, h, d, p, y, m = 2.5;
  function g() {
    return { type: "MultiLineString", coordinates: b() };
  }
  function b() {
    return sn(nl(r / l) * l, n, l).map(p).concat(sn(nl(a / f) * f, o, f).map(y)).concat(sn(nl(t / c) * c, e, c).filter(function(w) {
      return Bt(w % l) > ut;
    }).map(h)).concat(sn(nl(s / u) * u, i, u).filter(function(w) {
      return Bt(w % f) > ut;
    }).map(d));
  }
  return g.lines = function() {
    return b().map(function(w) {
      return { type: "LineString", coordinates: w };
    });
  }, g.outline = function() {
    return {
      type: "Polygon",
      coordinates: [
        p(r).concat(
          y(o).slice(1),
          p(n).reverse().slice(1),
          y(a).reverse().slice(1)
        )
      ]
    };
  }, g.extent = function(w) {
    return arguments.length ? g.extentMajor(w).extentMinor(w) : g.extentMinor();
  }, g.extentMajor = function(w) {
    return arguments.length ? (r = +w[0][0], n = +w[1][0], a = +w[0][1], o = +w[1][1], r > n && (w = r, r = n, n = w), a > o && (w = a, a = o, o = w), g.precision(m)) : [[r, a], [n, o]];
  }, g.extentMinor = function(w) {
    return arguments.length ? (t = +w[0][0], e = +w[1][0], s = +w[0][1], i = +w[1][1], t > e && (w = t, t = e, e = w), s > i && (w = s, s = i, i = w), g.precision(m)) : [[t, s], [e, i]];
  }, g.step = function(w) {
    return arguments.length ? g.stepMajor(w).stepMinor(w) : g.stepMinor();
  }, g.stepMajor = function(w) {
    return arguments.length ? (l = +w[0], f = +w[1], g) : [l, f];
  }, g.stepMinor = function(w) {
    return arguments.length ? (c = +w[0], u = +w[1], g) : [c, u];
  }, g.precision = function(w) {
    return arguments.length ? (m = +w, h = Ow(s, i, 90), d = Lw(t, e, m), p = Ow(a, o, 90), y = Lw(r, n, m), g) : m;
  }, g.extentMajor([[-180, -90 + ut], [180, 90 - ut]]).extentMinor([[-180, -80 - ut], [180, 80 + ut]]);
}
function DU() {
  return NU()();
}
const cy = (e) => e;
var Np = new dr(), uy = new dr(), b3, w3, ly, fy, Vr = {
  point: on,
  lineStart: on,
  lineEnd: on,
  polygonStart: function() {
    Vr.lineStart = OU, Vr.lineEnd = RU;
  },
  polygonEnd: function() {
    Vr.lineStart = Vr.lineEnd = Vr.point = on, Np.add(Bt(uy)), uy = new dr();
  },
  result: function() {
    var e = Np / 2;
    return Np = new dr(), e;
  }
};
function OU() {
  Vr.point = LU;
}
function LU(e, t) {
  Vr.point = _3, b3 = ly = e, w3 = fy = t;
}
function _3(e, t) {
  uy.add(fy * e - ly * t), ly = e, fy = t;
}
function RU() {
  _3(b3, w3);
}
var Zo = 1 / 0, eh = Zo, Pc = -Zo, nh = Pc, rh = {
  point: kU,
  lineStart: on,
  lineEnd: on,
  polygonStart: on,
  polygonEnd: on,
  result: function() {
    var e = [[Zo, eh], [Pc, nh]];
    return Pc = nh = -(eh = Zo = 1 / 0), e;
  }
};
function kU(e, t) {
  e < Zo && (Zo = e), e > Pc && (Pc = e), t < eh && (eh = t), t > nh && (nh = t);
}
var hy = 0, dy = 0, rc = 0, ih = 0, sh = 0, go = 0, py = 0, yy = 0, ic = 0, v3, x3, ar, cr, _n = {
  point: Ls,
  lineStart: Rw,
  lineEnd: kw,
  polygonStart: function() {
    _n.lineStart = CU, _n.lineEnd = PU;
  },
  polygonEnd: function() {
    _n.point = Ls, _n.lineStart = Rw, _n.lineEnd = kw;
  },
  result: function() {
    var e = ic ? [py / ic, yy / ic] : go ? [ih / go, sh / go] : rc ? [hy / rc, dy / rc] : [NaN, NaN];
    return hy = dy = rc = ih = sh = go = py = yy = ic = 0, e;
  }
};
function Ls(e, t) {
  hy += e, dy += t, ++rc;
}
function Rw() {
  _n.point = FU;
}
function FU(e, t) {
  _n.point = BU, Ls(ar = e, cr = t);
}
function BU(e, t) {
  var n = e - ar, r = t - cr, i = Ue(n * n + r * r);
  ih += i * (ar + e) / 2, sh += i * (cr + t) / 2, go += i, Ls(ar = e, cr = t);
}
function kw() {
  _n.point = Ls;
}
function CU() {
  _n.point = UU;
}
function PU() {
  S3(v3, x3);
}
function UU(e, t) {
  _n.point = S3, Ls(v3 = ar = e, x3 = cr = t);
}
function S3(e, t) {
  var n = e - ar, r = t - cr, i = Ue(n * n + r * r);
  ih += i * (ar + e) / 2, sh += i * (cr + t) / 2, go += i, i = cr * e - ar * t, py += i * (ar + e), yy += i * (cr + t), ic += i * 3, Ls(ar = e, cr = t);
}
function M3(e) {
  this._context = e;
}
M3.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, ln);
        break;
      }
    }
  },
  result: on
};
var my = new dr(), Dp, A3, $3, sc, oc, Uc = {
  point: on,
  lineStart: function() {
    Uc.point = zU;
  },
  lineEnd: function() {
    Dp && I3(A3, $3), Uc.point = on;
  },
  polygonStart: function() {
    Dp = !0;
  },
  polygonEnd: function() {
    Dp = null;
  },
  result: function() {
    var e = +my;
    return my = new dr(), e;
  }
};
function zU(e, t) {
  Uc.point = I3, A3 = sc = e, $3 = oc = t;
}
function I3(e, t) {
  sc -= e, oc -= t, my.add(Ue(sc * sc + oc * oc)), sc = e, oc = t;
}
let Fw, oh, Bw, Cw;
class Pw {
  constructor(t) {
    this._append = t == null ? T3 : qU(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 !== Bw || this._append !== oh) {
          const r = this._radius, i = this._;
          this._ = "", this._append`m0,${r}a${r},${r} 0 1,1 0,${-2 * r}a${r},${r} 0 1,1 0,${2 * r}z`, Bw = r, oh = this._append, Cw = this._, this._ = i;
        }
        this._ += Cw;
        break;
      }
    }
  }
  result() {
    const t = this._;
    return this._ = "", t.length ? t : null;
  }
}
function T3(e) {
  let t = 1;
  this._ += e[0];
  for (const n = e.length; t < n; ++t)
    this._ += arguments[t] + e[t];
}
function qU(e) {
  const t = Math.floor(e);
  if (!(t >= 0)) throw new RangeError(`invalid digits: ${e}`);
  if (t > 15) return T3;
  if (t !== Fw) {
    const n = 10 ** t;
    Fw = t, oh = function(i) {
      let s = 1;
      this._ += i[0];
      for (const o = i.length; s < o; ++s)
        this._ += Math.round(arguments[s] * n) / n + i[s];
    };
  }
  return oh;
}
function Hi(e, t) {
  let n = 3, r = 4.5, i, s;
  function o(a) {
    return a && (typeof r == "function" && s.pointRadius(+r.apply(this, arguments)), Si(a, i(s))), s.result();
  }
  return o.area = function(a) {
    return Si(a, i(Vr)), Vr.result();
  }, o.measure = function(a) {
    return Si(a, i(Uc)), Uc.result();
  }, o.bounds = function(a) {
    return Si(a, i(rh)), rh.result();
  }, o.centroid = function(a) {
    return Si(a, i(_n)), _n.result();
  }, o.projection = function(a) {
    return arguments.length ? (i = a == null ? (e = null, cy) : (e = a).stream, o) : e;
  }, o.context = function(a) {
    return arguments.length ? (s = a == null ? (t = null, new Pw(n)) : new M3(t = a), typeof r != "function" && s.pointRadius(r), o) : t;
  }, o.pointRadius = function(a) {
    return arguments.length ? (r = typeof a == "function" ? a : (s.pointRadius(+a), +a), o) : r;
  }, o.digits = function(a) {
    if (!arguments.length) return n;
    if (a == null) n = null;
    else {
      const c = Math.floor(a);
      if (!(c >= 0)) throw new RangeError(`invalid digits: ${a}`);
      n = c;
    }
    return t === null && (s = new Pw(n)), o;
  }, o.projection(e).digits(n).context(t);
}
function ah(e) {
  return {
    stream: cd(e)
  };
}
function cd(e) {
  return function(t) {
    var n = new gy();
    for (var r in e) n[r] = e[r];
    return n.stream = t, n;
  };
}
function gy() {
}
gy.prototype = {
  constructor: gy,
  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 tg(e, t, n) {
  var r = e.clipExtent && e.clipExtent();
  return e.scale(150).translate([0, 0]), r != null && e.clipExtent(null), Si(n, e.stream(rh)), t(rh.result()), r != null && e.clipExtent(r), e;
}
function eg(e, t, n) {
  return tg(e, function(r) {
    var i = t[1][0] - t[0][0], s = t[1][1] - t[0][1], o = Math.min(i / (r[1][0] - r[0][0]), s / (r[1][1] - r[0][1])), a = +t[0][0] + (i - o * (r[1][0] + r[0][0])) / 2, c = +t[0][1] + (s - o * (r[1][1] + r[0][1])) / 2;
    e.scale(150 * o).translate([a, c]);
  }, n);
}
function E3(e, t, n) {
  return eg(e, [[0, 0], t], n);
}
function N3(e, t, n) {
  return tg(e, function(r) {
    var i = +t, s = i / (r[1][0] - r[0][0]), o = (i - s * (r[1][0] + r[0][0])) / 2, a = -s * r[0][1];
    e.scale(150 * s).translate([o, a]);
  }, n);
}
function D3(e, t, n) {
  return tg(e, function(r) {
    var i = +t, s = i / (r[1][1] - r[0][1]), o = -s * r[0][0], a = (i - s * (r[1][1] + r[0][1])) / 2;
    e.scale(150 * s).translate([o, a]);
  }, n);
}
var Uw = 16, jU = pt(30 * Lt);
function zw(e, t) {
  return +t ? YU(e, t) : VU(e);
}
function VU(e) {
  return cd({
    point: function(t, n) {
      t = e(t, n), this.stream.point(t[0], t[1]);
    }
  });
}
function YU(e, t) {
  function n(r, i, s, o, a, c, u, l, f, h, d, p, y, m) {
    var g = u - r, b = l - i, w = g * g + b * b;
    if (w > 4 * t && y--) {
      var _ = o + h, x = a + d, v = c + p, M = Ue(_ * _ + x * x + v * v), E = Ke(v /= M), $ = Bt(Bt(v) - 1) < ut || Bt(s - f) < ut ? (s + f) / 2 : Vn(x, _), N = e($, E), A = N[0], D = N[1], k = A - r, S = D - i, I = b * k - g * S;
      (I * I / w > t || Bt((g * k + b * S) / w - 0.5) > 0.3 || o * h + a * d + c * p < jU) && (n(r, i, s, o, a, c, A, D, $, _ /= M, x /= M, v, y, m), m.point(A, D), n(A, D, $, _, x, v, u, l, f, h, d, p, y, m));
    }
  }
  return function(r) {
    var i, s, o, a, c, u, l, f, h, d, p, y, m = {
      point: g,
      lineStart: b,
      lineEnd: _,
      polygonStart: function() {
        r.polygonStart(), m.lineStart = x;
      },
      polygonEnd: function() {
        r.polygonEnd(), m.lineStart = b;
      }
    };
    function g(E, $) {
      E = e(E, $), r.point(E[0], E[1]);
    }
    function b() {
      f = NaN, m.point = w, r.lineStart();
    }
    function w(E, $) {
      var N = Jo([E, $]), A = e(E, $);
      n(f, h, l, d, p, y, f = A[0], h = A[1], l = E, d = N[0], p = N[1], y = N[2], Uw, r), r.point(f, h);
    }
    function _() {
      m.point = g, r.lineEnd();
    }
    function x() {
      b(), m.point = v, m.lineEnd = M;
    }
    function v(E, $) {
      w(i = E, $), s = f, o = h, a = d, c = p, u = y, m.point = w;
    }
    function M() {
      n(f, h, l, d, p, y, s, o, i, a, c, u, Uw, r), m.lineEnd = _, _();
    }
    return m;
  };
}
var WU = cd({
  point: function(e, t) {
    this.stream.point(e * Lt, t * Lt);
  }
});
function XU(e) {
  return cd({
    point: function(t, n) {
      var r = e(t, n);
      return this.stream.point(r[0], r[1]);
    }
  });
}
function GU(e, t, n, r, i) {
  function s(o, a) {
    return o *= r, a *= i, [t + e * o, n - e * a];
  }
  return s.invert = function(o, a) {
    return [(o - t) / e * r, (n - a) / e * i];
  }, s;
}
function qw(e, t, n, r, i, s) {
  if (!s) return GU(e, t, n, r, i);
  var o = pt(s), a = et(s), c = o * e, u = a * e, l = o / e, f = a / e, h = (a * n - o * t) / e, d = (a * t + o * n) / e;
  function p(y, m) {
    return y *= r, m *= i, [c * y - u * m + t, n - u * y - c * m];
  }
  return p.invert = function(y, m) {
    return [r * (l * y - f * m + h), i * (d - f * y - l * m)];
  }, p;
}
function Ji(e) {
  return O3(function() {
    return e;
  })();
}
function O3(e) {
  var t, n = 150, r = 480, i = 250, s = 0, o = 0, a = 0, c = 0, u = 0, l, f = 0, h = 1, d = 1, p = null, y = Dw, m = null, g, b, w, _ = cy, x = 0.5, v, M, E, $, N;
  function A(I) {
    return E(I[0] * Lt, I[1] * Lt);
  }
  function D(I) {
    return I = E.invert(I[0], I[1]), I && [I[0] * Me, I[1] * Me];
  }
  A.stream = function(I) {
    return $ && N === I ? $ : $ = WU(XU(l)(y(v(_(N = I)))));
  }, A.preclip = function(I) {
    return arguments.length ? (y = I, p = void 0, S()) : y;
  }, A.postclip = function(I) {
    return arguments.length ? (_ = I, m = g = b = w = null, S()) : _;
  }, A.clipAngle = function(I) {
    return arguments.length ? (y = +I ? TU(p = I * Lt) : (p = null, Dw), S()) : p * Me;
  }, A.clipExtent = function(I) {
    return arguments.length ? (_ = I == null ? (m = g = b = w = null, cy) : g3(m = +I[0][0], g = +I[0][1], b = +I[1][0], w = +I[1][1]), S()) : m == null ? null : [[m, g], [b, w]];
  }, A.scale = function(I) {
    return arguments.length ? (n = +I, k()) : n;
  }, A.translate = function(I) {
    return arguments.length ? (r = +I[0], i = +I[1], k()) : [r, i];
  }, A.center = function(I) {
    return arguments.length ? (s = I[0] % 360 * Lt, o = I[1] % 360 * Lt, k()) : [s * Me, o * Me];
  }, A.rotate = function(I) {
    return arguments.length ? (a = I[0] % 360 * Lt, c = I[1] % 360 * Lt, u = I.length > 2 ? I[2] % 360 * Lt : 0, k()) : [a * Me, c * Me, u * Me];
  }, A.angle = function(I) {
    return arguments.length ? (f = I % 360 * Lt, k()) : f * Me;
  }, A.reflectX = function(I) {
    return arguments.length ? (h = I ? -1 : 1, k()) : h < 0;
  }, A.reflectY = function(I) {
    return arguments.length ? (d = I ? -1 : 1, k()) : d < 0;
  }, A.precision = function(I) {
    return arguments.length ? (v = zw(M, x = I * I), S()) : Ue(x);
  }, A.fitExtent = function(I, T) {
    return eg(A, I, T);
  }, A.fitSize = function(I, T) {
    return E3(A, I, T);
  }, A.fitWidth = function(I, T) {
    return N3(A, I, T);
  }, A.fitHeight = function(I, T) {
    return D3(A, I, T);
  };
  function k() {
    var I = qw(n, 0, 0, h, d, f).apply(null, t(s, o)), T = qw(n, r - I[0], i - I[1], h, d, f);
    return l = d3(a, c, u), M = oy(t, T), E = oy(l, M), v = zw(M, x), S();
  }
  function S() {
    return $ = N = null, A;
  }
  return function() {
    return t = e.apply(this, arguments), A.invert = t.invert && D, k();
  };
}
function ng(e) {
  var t = 0, n = Mt / 3, r = O3(e), i = r(t, n);
  return i.parallels = function(s) {
    return arguments.length ? r(t = s[0] * Lt, n = s[1] * Lt) : [t * Me, n * Me];
  }, i;
}
function HU(e) {
  var t = pt(e);
  function n(r, i) {
    return [r * t, et(i) / t];
  }
  return n.invert = function(r, i) {
    return [r / t, Ke(i * t)];
  }, n;
}
function JU(e, t) {
  var n = et(e), r = (n + et(t)) / 2;
  if (Bt(r) < ut) return HU(e);
  var i = 1 + n * (2 * r - n), s = Ue(i) / r;
  function o(a, c) {
    var u = Ue(i - 2 * r * et(c)) / r;
    return [u * et(a *= r), s - u * pt(a)];
  }
  return o.invert = function(a, c) {
    var u = s - c, l = Vn(a, Bt(u)) * vn(u);
    return u * r < 0 && (l -= Mt * vn(a) * vn(u)), [l / r, Ke((i - (a * a + u * u) * r * r) / (2 * r))];
  }, o;
}
function ch() {
  return ng(JU).scale(155.424).center([0, 33.6442]);
}
function L3() {
  return ch().parallels([29.5, 45.5]).scale(1070).translate([480, 250]).rotate([96, 0]).center([-0.6, 38.7]);
}
function ZU(e) {
  var t = e.length;
  return {
    point: function(n, r) {
      for (var i = -1; ++i < t; ) e[i].point(n, r);
    },
    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 KU() {
  var e, t, n = L3(), r, i = ch().rotate([154, 0]).center([-2, 58.5]).parallels([55, 65]), s, o = ch().rotate([157, 0]).center([-3, 19.9]).parallels([8, 18]), a, c, u = { point: function(h, d) {
    c = [h, d];
  } };
  function l(h) {
    var d = h[0], p = h[1];
    return c = null, r.point(d, p), c || (s.point(d, p), c) || (a.point(d, p), c);
  }
  l.invert = function(h) {
    var d = n.scale(), p = n.translate(), y = (h[0] - p[0]) / d, m = (h[1] - p[1]) / d;
    return (m >= 0.12 && m < 0.234 && y >= -0.425 && y < -0.214 ? i : m >= 0.166 && m < 0.234 && y >= -0.214 && y < -0.115 ? o : n).invert(h);
  }, l.stream = function(h) {
    return e && t === h ? e : e = ZU([n.stream(t = h), i.stream(h), o.stream(h)]);
  }, l.precision = function(h) {
    return arguments.length ? (n.precision(h), i.precision(h), o.precision(h), f()) : n.precision();
  }, l.scale = function(h) {
    return arguments.length ? (n.scale(h), i.scale(h * 0.35), o.scale(h), l.translate(n.translate())) : n.scale();
  }, l.translate = function(h) {
    if (!arguments.length) return n.translate();
    var d = n.scale(), p = +h[0], y = +h[1];
    return r = n.translate(h).clipExtent([[p - 0.455 * d, y - 0.238 * d], [p + 0.455 * d, y + 0.238 * d]]).stream(u), s = i.translate([p - 0.307 * d, y + 0.201 * d]).clipExtent([[p - 0.425 * d + ut, y + 0.12 * d + ut], [p - 0.214 * d - ut, y + 0.234 * d - ut]]).stream(u), a = o.translate([p - 0.205 * d, y + 0.212 * d]).clipExtent([[p - 0.214 * d + ut, y + 0.166 * d + ut], [p - 0.115 * d - ut, y + 0.234 * d - ut]]).stream(u), f();
  }, l.fitExtent = function(h, d) {
    return eg(l, h, d);
  }, l.fitSize = function(h, d) {
    return E3(l, h, d);
  }, l.fitWidth = function(h, d) {
    return N3(l, h, d);
  }, l.fitHeight = function(h, d) {
    return D3(l, h, d);
  };
  function f() {
    return e = t = null, l;
  }
  return l.scale(1070);
}
function R3(e) {
  return function(t, n) {
    var r = pt(t), i = pt(n), s = e(r * i);
    return s === 1 / 0 ? [2, 0] : [
      s * i * et(t),
      s * et(n)
    ];
  };
}
function mu(e) {
  return function(t, n) {
    var r = Ue(t * t + n * n), i = e(r), s = et(i), o = pt(i);
    return [
      Vn(t * s, r * o),
      Ke(r && n * s / r)
    ];
  };
}
var k3 = R3(function(e) {
  return Ue(2 / (1 + e));
});
k3.invert = mu(function(e) {
  return 2 * Ke(e / 2);
});
function QU() {
  return Ji(k3).scale(124.75).clipAngle(180 - 1e-3);
}
var F3 = R3(function(e) {
  return (e = u3(e)) && e / et(e);
});
F3.invert = mu(function(e) {
  return e;
});
function tz() {
  return Ji(F3).scale(79.4188).clipAngle(180 - 1e-3);
}
function ud(e, t) {
  return [e, Yf(Km((ae + t) / 2))];
}
ud.invert = function(e, t) {
  return [e, 2 * ba(c3(t)) - ae];
};
function ez() {
  return B3(ud).scale(961 / ln);
}
function B3(e) {
  var t = Ji(e), n = t.center, r = t.scale, i = t.translate, s = t.clipExtent, o = null, a, c, u;
  t.scale = function(f) {
    return arguments.length ? (r(f), l()) : r();
  }, t.translate = function(f) {
    return arguments.length ? (i(f), l()) : i();
  }, t.center = function(f) {
    return arguments.length ? (n(f), l()) : n();
  }, t.clipExtent = function(f) {
    return arguments.length ? (f == null ? o = a = c = u = null : (o = +f[0][0], a = +f[0][1], c = +f[1][0], u = +f[1][1]), l()) : o == null ? null : [[o, a], [c, u]];
  };
  function l() {
    var f = Mt * r(), h = t(_U(t.rotate()).invert([0, 0]));
    return s(o == null ? [[h[0] - f, h[1] - f], [h[0] + f, h[1] + f]] : e === ud ? [[Math.max(h[0] - f, o), a], [Math.min(h[0] + f, c), u]] : [[o, Math.max(h[1] - f, a)], [c, Math.min(h[1] + f, u)]]);
  }
  return l();
}
function al(e) {
  return Km((ae + e) / 2);
}
function nz(e, t) {
  var n = pt(e), r = e === t ? et(e) : Yf(n / pt(t)) / Yf(al(t) / al(e)), i = n * Ip(al(e), r) / r;
  if (!r) return ud;
  function s(o, a) {
    i > 0 ? a < -ae + ut && (a = -ae + ut) : a > ae - ut && (a = ae - ut);
    var c = i / Ip(al(a), r);
    return [c * et(r * o), i - c * pt(r * o)];
  }
  return s.invert = function(o, a) {
    var c = i - a, u = vn(r) * Ue(o * o + c * c), l = Vn(o, Bt(c)) * vn(c);
    return c * r < 0 && (l -= Mt * vn(o) * vn(c)), [l / r, 2 * ba(Ip(i / u, 1 / r)) - ae];
  }, s;
}
function rz() {
  return ng(nz).scale(109.5).parallels([30, 30]);
}
function uh(e, t) {
  return [e, t];
}
uh.invert = uh;
function iz() {
  return Ji(uh).scale(152.63);
}
function sz(e, t) {
  var n = pt(e), r = e === t ? et(e) : (n - pt(t)) / (t - e), i = n / r + e;
  if (Bt(r) < ut) return uh;
  function s(o, a) {
    var c = i - a, u = r * o;
    return [c * et(u), i - c * pt(u)];
  }
  return s.invert = function(o, a) {
    var c = i - a, u = Vn(o, Bt(c)) * vn(c);
    return c * r < 0 && (u -= Mt * vn(o) * vn(c)), [u / r, i - vn(r) * Ue(o * o + c * c)];
  }, s;
}
function oz() {
  return ng(sz).scale(131.154).center([0, 13.9389]);
}
var dc = 1.340264, pc = -0.081106, yc = 893e-6, mc = 3796e-6, lh = Ue(3) / 2, az = 12;
function C3(e, t) {
  var n = Ke(lh * et(t)), r = n * n, i = r * r * r;
  return [
    e * pt(n) / (lh * (dc + 3 * pc * r + i * (7 * yc + 9 * mc * r))),
    n * (dc + pc * r + i * (yc + mc * r))
  ];
}
C3.invert = function(e, t) {
  for (var n = t, r = n * n, i = r * r * r, s = 0, o, a, c; s < az && (a = n * (dc + pc * r + i * (yc + mc * r)) - t, c = dc + 3 * pc * r + i * (7 * yc + 9 * mc * r), n -= o = a / c, r = n * n, i = r * r * r, !(Bt(o) < Vf)); ++s)
    ;
  return [
    lh * e * (dc + 3 * pc * r + i * (7 * yc + 9 * mc * r)) / pt(n),
    Ke(et(n) / lh)
  ];
};
function cz() {
  return Ji(C3).scale(177.158);
}
function P3(e, t) {
  var n = pt(t), r = pt(e) * n;
  return [n * et(e) / r, et(t) / r];
}
P3.invert = mu(ba);
function uz() {
  return Ji(P3).scale(144.049).clipAngle(60);
}
function U3(e, t) {
  return [pt(t) * et(e), et(t)];
}
U3.invert = mu(Ke);
function lz() {
  return Ji(U3).scale(249.5).clipAngle(90 + ut);
}
function z3(e, t) {
  var n = pt(t), r = 1 + pt(e) * n;
  return [n * et(e) / r, et(t) / r];
}
z3.invert = mu(function(e) {
  return 2 * ba(e);
});
function fz() {
  return Ji(z3).scale(250).clipAngle(142);
}
function q3(e, t) {
  return [Yf(Km((ae + t) / 2)), -e];
}
q3.invert = function(e, t) {
  return [-t, 2 * ba(c3(e)) - ae];
};
function hz() {
  var e = B3(q3), t = e.center, n = e.rotate;
  return e.center = function(r) {
    return arguments.length ? t([-r[1], r[0]]) : (r = t(), [r[1], -r[0]]);
  }, e.rotate = function(r) {
    return arguments.length ? n([r[0], r[1], r.length > 2 ? r[2] + 90 : 90]) : (r = n(), [r[0], r[1], r[2] - 90]);
  }, n([0, 0, 90]).scale(159.155);
}
function dz(e, t) {
  return e.parent === t.parent ? 1 : 2;
}
function pz(e) {
  return e.reduce(yz, 0) / e.length;
}
function yz(e, t) {
  return e + t.x;
}
function mz(e) {
  return 1 + e.reduce(gz, 0);
}
function gz(e, t) {
  return Math.max(e, t.y);
}
function bz(e) {
  for (var t; t = e.children; ) e = t[0];
  return e;
}
function wz(e) {
  for (var t; t = e.children; ) e = t[t.length - 1];
  return e;
}
function j3() {
  var e = dz, t = 1, n = 1, r = !1;
  function i(s) {
    var o, a = 0;
    s.eachAfter(function(h) {
      var d = h.children;
      d ? (h.x = pz(d), h.y = mz(d)) : (h.x = o ? a += e(h, o) : 0, h.y = 0, o = h);
    });
    var c = bz(s), u = wz(s), l = c.x - e(c, u) / 2, f = u.x + e(u, c) / 2;
    return s.eachAfter(r ? function(h) {
      h.x = (h.x - s.x) * t, h.y = (s.y - h.y) * n;
    } : function(h) {
      h.x = (h.x - l) / (f - l) * t, h.y = (1 - (s.y ? h.y / s.y : 1)) * n;
    });
  }
  return i.separation = function(s) {
    return arguments.length ? (e = s, i) : e;
  }, i.size = function(s) {
    return arguments.length ? (r = !1, t = +s[0], n = +s[1], i) : r ? null : [t, n];
  }, i.nodeSize = function(s) {
    return arguments.length ? (r = !0, t = +s[0], n = +s[1], i) : r ? [t, n] : null;
  }, i;
}
function _z(e) {
  var t = 0, n = e.children, r = n && n.length;
  if (!r) t = 1;
  else for (; --r >= 0; ) t += n[r].value;
  e.value = t;
}
function vz() {
  return this.eachAfter(_z);
}
function xz(e, t) {
  let n = -1;
  for (const r of this)
    e.call(t, r, ++n, this);
  return this;
}
function Sz(e, t) {
  for (var n = this, r = [n], i, s, o = -1; n = r.pop(); )
    if (e.call(t, n, ++o, this), i = n.children)
      for (s = i.length - 1; s >= 0; --s)
        r.push(i[s]);
  return this;
}
function Mz(e, t) {
  for (var n = this, r = [n], i = [], s, o, a, c = -1; n = r.pop(); )
    if (i.push(n), s = n.children)
      for (o = 0, a = s.length; o < a; ++o)
        r.push(s[o]);
  for (; n = i.pop(); )
    e.call(t, n, ++c, this);
  return this;
}
function Az(e, t) {
  let n = -1;
  for (const r of this)
    if (e.call(t, r, ++n, this))
      return r;
}
function $z(e) {
  return this.eachAfter(function(t) {
    for (var n = +e(t.data) || 0, r = t.children, i = r && r.length; --i >= 0; ) n += r[i].value;
    t.value = n;
  });
}
function Iz(e) {
  return this.eachBefore(function(t) {
    t.children && t.children.sort(e);
  });
}
function Tz(e) {
  for (var t = this, n = Ez(t, e), r = [t]; t !== n; )
    t = t.parent, r.push(t);
  for (var i = r.length; e !== n; )
    r.splice(i, 0, e), e = e.parent;
  return r;
}
function Ez(e, t) {
  if (e === t) return e;
  var n = e.ancestors(), r = t.ancestors(), i = null;
  for (e = n.pop(), t = r.pop(); e === t; )
    i = e, e = n.pop(), t = r.pop();
  return i;
}
function Nz() {
  for (var e = this, t = [e]; e = e.parent; )
    t.push(e);
  return t;
}
function Dz() {
  return Array.from(this);
}
function Oz() {
  var e = [];
  return this.eachBefore(function(t) {
    t.children || e.push(t);
  }), e;
}
function Lz() {
  var e = this, t = [];
  return e.each(function(n) {
    n !== e && t.push({ source: n.parent, target: n });
  }), t;
}
function* Rz() {
  var e = this, t, n = [e], r, i, s;
  do
    for (t = n.reverse(), n = []; e = t.pop(); )
      if (yield e, r = e.children)
        for (i = 0, s = r.length; i < s; ++i)
          n.push(r[i]);
  while (n.length);
}
function V3(e, t) {
  e instanceof Map ? (e = [void 0, e], t === void 0 && (t = Bz)) : t === void 0 && (t = Fz);
  for (var n = new Ko(e), r, i = [n], s, o, a, c; r = i.pop(); )
    if ((o = t(r.data)) && (c = (o = Array.from(o)).length))
      for (r.children = o, a = c - 1; a >= 0; --a)
        i.push(s = o[a] = new Ko(o[a])), s.parent = r, s.depth = r.depth + 1;
  return n.eachBefore(Y3);
}
function kz() {
  return V3(this).eachBefore(Cz);
}
function Fz(e) {
  return e.children;
}
function Bz(e) {
  return Array.isArray(e) ? e[1] : null;
}
function Cz(e) {
  e.data.value !== void 0 && (e.value = e.data.value), e.data = e.data.data;
}
function Y3(e) {
  var t = 0;
  do
    e.height = t;
  while ((e = e.parent) && e.height < ++t);
}
function Ko(e) {
  this.data = e, this.depth = this.height = 0, this.parent = null;
}
Ko.prototype = V3.prototype = {
  constructor: Ko,
  count: vz,
  each: xz,
  eachAfter: Mz,
  eachBefore: Sz,
  find: Az,
  sum: $z,
  sort: Iz,
  path: Tz,
  ancestors: Nz,
  descendants: Dz,
  leaves: Oz,
  links: Lz,
  copy: kz,
  [Symbol.iterator]: Rz
};
function Op(e) {
  return e == null ? null : Pz(e);
}
function Pz(e) {
  if (typeof e != "function") throw new Error();
  return e;
}
var Uz = { depth: -1 }, jw = {}, Lp = {};
function zz(e) {
  return e.id;
}
function qz(e) {
  return e.parentId;
}
function W3() {
  var e = zz, t = qz, n;
  function r(i) {
    var s = Array.from(i), o = e, a = t, c, u, l, f, h, d, p, y, m = /* @__PURE__ */ new Map();
    if (n != null) {
      const g = s.map((_, x) => jz(n(_, x, i))), b = g.map(Vw), w = new Set(g).add("");
      for (const _ of b)
        w.has(_) || (w.add(_), g.push(_), b.push(Vw(_)), s.push(Lp));
      o = (_, x) => g[x], a = (_, x) => b[x];
    }
    for (l = 0, c = s.length; l < c; ++l)
      u = s[l], d = s[l] = new Ko(u), (p = o(u, l, i)) != null && (p += "") && (y = d.id = p, m.set(y, m.has(y) ? jw : d)), (p = a(u, l, i)) != null && (p += "") && (d.parent = p);
    for (l = 0; l < c; ++l)
      if (d = s[l], p = d.parent) {
        if (h = m.get(p), !h) throw new Error("missing: " + p);
        if (h === jw) throw new Error("ambiguous: " + p);
        h.children ? h.children.push(d) : h.children = [d], d.parent = h;
      } else {
        if (f) throw new Error("multiple roots");
        f = d;
      }
    if (!f) throw new Error("no root");
    if (n != null) {
      for (; f.data === Lp && f.children.length === 1; )
        f = f.children[0], --c;
      for (let g = s.length - 1; g >= 0 && (d = s[g], d.data === Lp); --g)
        d.data = null;
    }
    if (f.parent = Uz, f.eachBefore(function(g) {
      g.depth = g.parent.depth + 1, --c;
    }).eachBefore(Y3), f.parent = null, c > 0) throw new Error("cycle");
    return f;
  }
  return r.id = function(i) {
    return arguments.length ? (e = Op(i), r) : e;
  }, r.parentId = function(i) {
    return arguments.length ? (t = Op(i), r) : t;
  }, r.path = function(i) {
    return arguments.length ? (n = Op(i), r) : n;
  }, r;
}
function jz(e) {
  e = `${e}`;
  let t = e.length;
  return by(e, t - 1) && !by(e, t - 2) && (e = e.slice(0, -1)), e[0] === "/" ? e : `/${e}`;
}
function Vw(e) {
  let t = e.length;
  if (t < 2) return "";
  for (; --t > 1 && !by(e, t); ) ;
  return e.slice(0, t);
}
function by(e, t) {
  if (e[t] === "/") {
    let n = 0;
    for (; t > 0 && e[--t] === "\\"; ) ++n;
    if (!(n & 1)) return !0;
  }
  return !1;
}
function Vz(e, t) {
  return e.parent === t.parent ? 1 : 2;
}
function Rp(e) {
  var t = e.children;
  return t ? t[0] : e.t;
}
function kp(e) {
  var t = e.children;
  return t ? t[t.length - 1] : e.t;
}
function Yz(e, t, n) {
  var r = n / (t.i - e.i);
  t.c -= r, t.s += n, e.c += r, t.z += n, t.m += n;
}
function Wz(e) {
  for (var t = 0, n = 0, r = e.children, i = r.length, s; --i >= 0; )
    s = r[i], s.z += t, s.m += t, t += s.s + (n += s.c);
}
function Xz(e, t, n) {
  return e.a.parent === t.parent ? e.a : n;
}
function Xl(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;
}
Xl.prototype = Object.create(Ko.prototype);
function Gz(e) {
  for (var t = new Xl(e, 0), n, r = [t], i, s, o, a; n = r.pop(); )
    if (s = n._.children)
      for (n.children = new Array(a = s.length), o = a - 1; o >= 0; --o)
        r.push(i = n.children[o] = new Xl(s[o], o)), i.parent = n;
  return (t.parent = new Xl(null, 0)).children = [t], t;
}
function fh() {
  var e = Vz, t = 1, n = 1, r = null;
  function i(u) {
    var l = Gz(u);
    if (l.eachAfter(s), l.parent.m = -l.z, l.eachBefore(o), r) u.eachBefore(c);
    else {
      var f = u, h = u, d = u;
      u.eachBefore(function(b) {
        b.x < f.x && (f = b), b.x > h.x && (h = b), b.depth > d.depth && (d = b);
      });
      var p = f === h ? 1 : e(f, h) / 2, y = p - f.x, m = t / (h.x + p + y), g = n / (d.depth || 1);
      u.eachBefore(function(b) {
        b.x = (b.x + y) * m, b.y = b.depth * g;
      });
    }
    return u;
  }
  function s(u) {
    var l = u.children, f = u.parent.children, h = u.i ? f[u.i - 1] : null;
    if (l) {
      Wz(u);
      var d = (l[0].z + l[l.length - 1].z) / 2;
      h ? (u.z = h.z + e(u._, h._), u.m = u.z - d) : u.z = d;
    } else h && (u.z = h.z + e(u._, h._));
    u.parent.A = a(u, h, u.parent.A || f[0]);
  }
  function o(u) {
    u._.x = u.z + u.parent.m, u.m += u.parent.m;
  }
  function a(u, l, f) {
    if (l) {
      for (var h = u, d = u, p = l, y = h.parent.children[0], m = h.m, g = d.m, b = p.m, w = y.m, _; p = kp(p), h = Rp(h), p && h; )
        y = Rp(y), d = kp(d), d.a = u, _ = p.z + b - h.z - m + e(p._, h._), _ > 0 && (Yz(Xz(p, u, f), u, _), m += _, g += _), b += p.m, m += h.m, w += y.m, g += d.m;
      p && !kp(d) && (d.t = p, d.m += b - g), h && !Rp(y) && (y.t = h, y.m += m - w, f = u);
    }
    return f;
  }
  function c(u) {
    u.x *= t, u.y = u.depth * n;
  }
  return i.separation = function(u) {
    return arguments.length ? (e = u, i) : e;
  }, i.size = function(u) {
    return arguments.length ? (r = !1, t = +u[0], n = +u[1], i) : r ? null : [t, n];
  }, i.nodeSize = function(u) {
    return arguments.length ? (r = !0, t = +u[0], n = +u[1], i) : r ? [t, n] : null;
  }, i;
}
const Hz = 1664525, Jz = 1013904223, Yw = 1 / 4294967296;
function rg(e = Math.random()) {
  let t = (0 <= e && e < 1 ? e / Yw : Math.abs(e)) | 0;
  return () => (t = Hz * t + Jz | 0, Yw * (t >>> 0));
}
function Sr(e, t) {
  switch (arguments.length) {
    case 0:
      break;
    case 1:
      this.range(e);
      break;
    default:
      this.range(t).domain(e);
      break;
  }
  return this;
}
function ld(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 ig() {
  var e = new Ts(), t = [], n = [], r = wy;
  function i(s) {
    let o = e.get(s);
    if (o === void 0) {
      if (r !== wy) return r;
      e.set(s, o = t.push(s) - 1);
    }
    return n[o % n.length];
  }
  return i.domain = function(s) {
    if (!arguments.length) return t.slice();
    t = [], e = new Ts();
    for (const o of s)
      e.has(o) || e.set(o, t.push(o) - 1);
    return i;
  }, i.range = function(s) {
    return arguments.length ? (n = Array.from(s), i) : n.slice();
  }, i.unknown = function(s) {
    return arguments.length ? (r = s, i) : r;
  }, i.copy = function() {
    return ig(t, n).unknown(r);
  }, Sr.apply(i, arguments), i;
}
function fd() {
  var e = ig().unknown(void 0), t = e.domain, n = e.range, r = 0, i = 1, s, o, a = !1, c = 0, u = 0, l = 0.5;
  delete e.unknown;
  function f() {
    var h = t().length, d = i < r, p = d ? i : r, y = d ? r : i;
    s = (y - p) / Math.max(1, h - c + u * 2), a && (s = Math.floor(s)), p += (y - p - s * (h - c)) * l, o = s * (1 - c), a && (p = Math.round(p), o = Math.round(o));
    var m = sn(h).map(function(g) {
      return p + s * g;
    });
    return n(d ? m.reverse() : m);
  }
  return e.domain = function(h) {
    return arguments.length ? (t(h), f()) : t();
  }, e.range = function(h) {
    return arguments.length ? ([r, i] = h, r = +r, i = +i, f()) : [r, i];
  }, e.rangeRound = function(h) {
    return [r, i] = h, r = +r, i = +i, a = !0, f();
  }, e.bandwidth = function() {
    return o;
  }, e.step = function() {
    return s;
  }, e.round = function(h) {
    return arguments.length ? (a = !!h, f()) : a;
  }, e.padding = function(h) {
    return arguments.length ? (c = Math.min(1, u = +h), f()) : c;
  }, e.paddingInner = function(h) {
    return arguments.length ? (c = Math.min(1, h), f()) : c;
  }, e.paddingOuter = function(h) {
    return arguments.length ? (u = +h, f()) : u;
  }, e.align = function(h) {
    return arguments.length ? (l = Math.max(0, Math.min(1, h)), f()) : l;
  }, e.copy = function() {
    return fd(t(), [r, i]).round(a).paddingInner(c).paddingOuter(u).align(l);
  }, Sr.apply(f(), arguments);
}
function X3(e) {
  var t = e.copy;
  return e.padding = e.paddingOuter, delete e.paddingInner, delete e.paddingOuter, e.copy = function() {
    return X3(t());
  }, e;
}
function Zz() {
  return X3(fd.apply(null, arguments).paddingInner(1));
}
function Kz(e) {
  return function() {
    return e;
  };
}
function _y(e) {
  return +e;
}
var Ww = [0, 1];
function xn(e) {
  return e;
}
function vy(e, t) {
  return (t -= e = +e) ? function(n) {
    return (n - e) / t;
  } : Kz(isNaN(t) ? NaN : 0.5);
}
function Qz(e, t) {
  var n;
  return e > t && (n = e, e = t, t = n), function(r) {
    return Math.max(e, Math.min(t, r));
  };
}
function tq(e, t, n) {
  var r = e[0], i = e[1], s = t[0], o = t[1];
  return i < r ? (r = vy(i, r), s = n(o, s)) : (r = vy(r, i), s = n(s, o)), function(a) {
    return s(r(a));
  };
}
function eq(e, t, n) {
  var r = Math.min(e.length, t.length) - 1, i = new Array(r), s = new Array(r), o = -1;
  for (e[r] < e[0] && (e = e.slice().reverse(), t = t.slice().reverse()); ++o < r; )
    i[o] = vy(e[o], e[o + 1]), s[o] = n(t[o], t[o + 1]);
  return function(a) {
    var c = Zh(e, a, 1, r) - 1;
    return s[c](i[c](a));
  };
}
function gu(e, t) {
  return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown());
}
function hd() {
  var e = Ww, t = Ww, n = ma, r, i, s, o = xn, a, c, u;
  function l() {
    var h = Math.min(e.length, t.length);
    return o !== xn && (o = Qz(e[0], e[h - 1])), a = h > 2 ? eq : tq, c = u = null, f;
  }
  function f(h) {
    return h == null || isNaN(h = +h) ? s : (c || (c = a(e.map(r), t, n)))(r(o(h)));
  }
  return f.invert = function(h) {
    return o(i((u || (u = a(t, e.map(r), Ee)))(h)));
  }, f.domain = function(h) {
    return arguments.length ? (e = Array.from(h, _y), l()) : e.slice();
  }, f.range = function(h) {
    return arguments.length ? (t = Array.from(h), l()) : t.slice();
  }, f.rangeRound = function(h) {
    return t = Array.from(h), n = Ym, l();
  }, f.clamp = function(h) {
    return arguments.length ? (o = h ? !0 : xn, l()) : o !== xn;
  }, f.interpolate = function(h) {
    return arguments.length ? (n = h, l()) : n;
  }, f.unknown = function(h) {
    return arguments.length ? (s = h, f) : s;
  }, function(h, d) {
    return r = h, i = d, l();
  };
}
function G3() {
  return hd()(xn, xn);
}
function nq(e, t, n, r) {
  var i = F0(e, t, n), s;
  switch (r = Cc(r ?? ",f"), r.type) {
    case "s": {
      var o = Math.max(Math.abs(e), Math.abs(t));
      return r.precision == null && !isNaN(s = hU(i, o)) && (r.precision = s), a3(r, o);
    }
    case "":
    case "e":
    case "g":
    case "p":
    case "r": {
      r.precision == null && !isNaN(s = dU(i, Math.max(Math.abs(e), Math.abs(t)))) && (r.precision = s - (r.type === "e"));
      break;
    }
    case "f":
    case "%": {
      r.precision == null && !isNaN(s = fU(i)) && (r.precision = s - (r.type === "%") * 2);
      break;
    }
  }
  return ga(r);
}
function bu(e) {
  var t = e.domain;
  return e.ticks = function(n) {
    var r = t();
    return Fi(r[0], r[r.length - 1], n ?? 10);
  }, e.tickFormat = function(n, r) {
    var i = t();
    return nq(i[0], i[i.length - 1], n ?? 10, r);
  }, e.nice = function(n) {
    n == null && (n = 10);
    var r = t(), i = 0, s = r.length - 1, o = r[i], a = r[s], c, u, l = 10;
    for (a < o && (u = o, o = a, a = u, u = i, i = s, s = u); l-- > 0; ) {
      if (u = Oc(o, a, n), u === c)
        return r[i] = o, r[s] = a, t(r);
      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;
      c = u;
    }
    return e;
  }, e;
}
function dd() {
  var e = G3();
  return e.copy = function() {
    return gu(e, dd());
  }, Sr.apply(e, arguments), bu(e);
}
function H3(e) {
  var t;
  function n(r) {
    return r == null || isNaN(r = +r) ? t : r;
  }
  return n.invert = n, n.domain = n.range = function(r) {
    return arguments.length ? (e = Array.from(r, _y), n) : e.slice();
  }, n.unknown = function(r) {
    return arguments.length ? (t = r, n) : t;
  }, n.copy = function() {
    return H3(e).unknown(t);
  }, e = arguments.length ? Array.from(e, _y) : [0, 1], bu(n);
}
function J3(e, t) {
  e = e.slice();
  var n = 0, r = e.length - 1, i = e[n], s = e[r], o;
  return s < i && (o = n, n = r, r = o, o = i, i = s, s = o), e[n] = t.floor(i), e[r] = t.ceil(s), e;
}
function Xw(e) {
  return Math.log(e);
}
function Gw(e) {
  return Math.exp(e);
}
function rq(e) {
  return -Math.log(-e);
}
function iq(e) {
  return -Math.exp(-e);
}
function sq(e) {
  return isFinite(e) ? +("1e" + e) : e < 0 ? 0 : e;
}
function oq(e) {
  return e === 10 ? sq : e === Math.E ? Math.exp : (t) => Math.pow(e, t);
}
function aq(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 Hw(e) {
  return (t, n) => -e(-t, n);
}
function Z3(e) {
  const t = e(Xw, Gw), n = t.domain;
  let r = 10, i, s;
  function o() {
    return i = aq(r), s = oq(r), n()[0] < 0 ? (i = Hw(i), s = Hw(s), e(rq, iq)) : e(Xw, Gw), t;
  }
  return t.base = function(a) {
    return arguments.length ? (r = +a, o()) : r;
  }, t.domain = function(a) {
    return arguments.length ? (n(a), o()) : n();
  }, t.ticks = (a) => {
    const c = n();
    let u = c[0], l = c[c.length - 1];
    const f = l < u;
    f && ([u, l] = [l, u]);
    let h = i(u), d = i(l), p, y;
    const m = a == null ? 10 : +a;
    let g = [];
    if (!(r % 1) && d - h < m) {
      if (h = Math.floor(h), d = Math.ceil(d), u > 0) {
        for (; h <= d; ++h)
          for (p = 1; p < r; ++p)
            if (y = h < 0 ? p / s(-h) : p * s(h), !(y < u)) {
              if (y > l) break;
              g.push(y);
            }
      } else for (; h <= d; ++h)
        for (p = r - 1; p >= 1; --p)
          if (y = h > 0 ? p / s(-h) : p * s(h), !(y < u)) {
            if (y > l) break;
            g.push(y);
          }
      g.length * 2 < m && (g = Fi(u, l, m));
    } else
      g = Fi(h, d, Math.min(d - h, m)).map(s);
    return f ? g.reverse() : g;
  }, t.tickFormat = (a, c) => {
    if (a == null && (a = 10), c == null && (c = r === 10 ? "s" : ","), typeof c != "function" && (!(r % 1) && (c = Cc(c)).precision == null && (c.trim = !0), c = ga(c)), a === 1 / 0) return c;
    const u = Math.max(1, r * a / t.ticks().length);
    return (l) => {
      let f = l / s(Math.round(i(l)));
      return f * r < r - 0.5 && (f *= r), f <= u ? c(l) : "";
    };
  }, t.nice = () => n(J3(n(), {
    floor: (a) => s(Math.floor(i(a))),
    ceil: (a) => s(Math.ceil(i(a)))
  })), t;
}
function K3() {
  const e = Z3(hd()).domain([1, 10]);
  return e.copy = () => gu(e, K3()).base(e.base()), Sr.apply(e, arguments), e;
}
function Jw(e) {
  return function(t) {
    return Math.sign(t) * Math.log1p(Math.abs(t / e));
  };
}
function Zw(e) {
  return function(t) {
    return Math.sign(t) * Math.expm1(Math.abs(t)) * e;
  };
}
function Q3(e) {
  var t = 1, n = e(Jw(t), Zw(t));
  return n.constant = function(r) {
    return arguments.length ? e(Jw(t = +r), Zw(t)) : t;
  }, bu(n);
}
function t6() {
  var e = Q3(hd());
  return e.copy = function() {
    return gu(e, t6()).constant(e.constant());
  }, Sr.apply(e, arguments);
}
function Kw(e) {
  return function(t) {
    return t < 0 ? -Math.pow(-t, e) : Math.pow(t, e);
  };
}
function cq(e) {
  return e < 0 ? -Math.sqrt(-e) : Math.sqrt(e);
}
function uq(e) {
  return e < 0 ? -e * e : e * e;
}
function e6(e) {
  var t = e(xn, xn), n = 1;
  function r() {
    return n === 1 ? e(xn, xn) : n === 0.5 ? e(cq, uq) : e(Kw(n), Kw(1 / n));
  }
  return t.exponent = function(i) {
    return arguments.length ? (n = +i, r()) : n;
  }, bu(t);
}
function n6() {
  var e = e6(hd());
  return e.copy = function() {
    return gu(e, n6()).exponent(e.exponent());
  }, Sr.apply(e, arguments), e;
}
function r6() {
  var e = [], t = [], n = [], r;
  function i() {
    var o = 0, a = Math.max(1, t.length);
    for (n = new Array(a - 1); ++o < a; ) n[o - 1] = gk(e, o / a);
    return s;
  }
  function s(o) {
    return o == null || isNaN(o = +o) ? r : t[Zh(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(zt), i();
  }, s.range = function(o) {
    return arguments.length ? (t = Array.from(o), i()) : t.slice();
  }, s.unknown = function(o) {
    return arguments.length ? (r = o, s) : r;
  }, s.quantiles = function() {
    return n.slice();
  }, s.copy = function() {
    return r6().domain(e).range(t).unknown(r);
  }, Sr.apply(s, arguments);
}
function i6() {
  var e = [0.5], t = [0, 1], n, r = 1;
  function i(s) {
    return s != null && s <= s ? t[Zh(e, s, 0, r)] : n;
  }
  return i.domain = function(s) {
    return arguments.length ? (e = Array.from(s), r = Math.min(e.length, t.length - 1), i) : e.slice();
  }, i.range = function(s) {
    return arguments.length ? (t = Array.from(s), r = Math.min(e.length, t.length - 1), i) : t.slice();
  }, i.invertExtent = function(s) {
    var o = t.indexOf(s);
    return [e[o - 1], e[o]];
  }, i.unknown = function(s) {
    return arguments.length ? (n = s, i) : n;
  }, i.copy = function() {
    return i6().domain(e).range(t).unknown(n);
  }, Sr.apply(i, arguments);
}
const Fp = /* @__PURE__ */ new Date(), Bp = /* @__PURE__ */ new Date();
function ye(e, t, n, r) {
  function i(s) {
    return e(s = arguments.length === 0 ? /* @__PURE__ */ new Date() : /* @__PURE__ */ new Date(+s)), s;
  }
  return i.floor = (s) => (e(s = /* @__PURE__ */ new Date(+s)), s), i.ceil = (s) => (e(s = new Date(s - 1)), t(s, 1), e(s), s), i.round = (s) => {
    const o = i(s), a = i.ceil(s);
    return s - o < a - s ? o : a;
  }, i.offset = (s, o) => (t(s = /* @__PURE__ */ new Date(+s), o == null ? 1 : Math.floor(o)), s), i.range = (s, o, a) => {
    const c = [];
    if (s = i.ceil(s), a = a == null ? 1 : Math.floor(a), !(s < o) || !(a > 0)) return c;
    let u;
    do
      c.push(u = /* @__PURE__ */ new Date(+s)), t(s, a), e(s);
    while (u < s && s < o);
    return c;
  }, i.filter = (s) => ye((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 && (i.count = (s, o) => (Fp.setTime(+s), Bp.setTime(+o), e(Fp), e(Bp), Math.floor(n(Fp, Bp))), i.every = (s) => (s = Math.floor(s), !isFinite(s) || !(s > 0) ? null : s > 1 ? i.filter(r ? (o) => r(o) % s === 0 : (o) => i.count(0, o) % s === 0) : i)), i;
}
const hh = ye(() => {
}, (e, t) => {
  e.setTime(+e + t);
}, (e, t) => t - e);
hh.every = (e) => (e = Math.floor(e), !isFinite(e) || !(e > 0) ? null : e > 1 ? ye((t) => {
  t.setTime(Math.floor(t / e) * e);
}, (t, n) => {
  t.setTime(+t + n * e);
}, (t, n) => (n - t) / e) : hh);
hh.range;
const Hr = 1e3, Sn = Hr * 60, Jr = Sn * 60, ii = Jr * 24, sg = ii * 7, Qw = ii * 30, Cp = ii * 365, Cn = ye((e) => {
  e.setTime(e - e.getMilliseconds());
}, (e, t) => {
  e.setTime(+e + t * Hr);
}, (e, t) => (t - e) / Hr, (e) => e.getUTCSeconds());
Cn.range;
const wu = ye((e) => {
  e.setTime(e - e.getMilliseconds() - e.getSeconds() * Hr);
}, (e, t) => {
  e.setTime(+e + t * Sn);
}, (e, t) => (t - e) / Sn, (e) => e.getMinutes());
wu.range;
const _u = ye((e) => {
  e.setUTCSeconds(0, 0);
}, (e, t) => {
  e.setTime(+e + t * Sn);
}, (e, t) => (t - e) / Sn, (e) => e.getUTCMinutes());
_u.range;
const vu = ye((e) => {
  e.setTime(e - e.getMilliseconds() - e.getSeconds() * Hr - e.getMinutes() * Sn);
}, (e, t) => {
  e.setTime(+e + t * Jr);
}, (e, t) => (t - e) / Jr, (e) => e.getHours());
vu.range;
const xu = ye((e) => {
  e.setUTCMinutes(0, 0, 0);
}, (e, t) => {
  e.setTime(+e + t * Jr);
}, (e, t) => (t - e) / Jr, (e) => e.getUTCHours());
xu.range;
const Cs = ye(
  (e) => e.setHours(0, 0, 0, 0),
  (e, t) => e.setDate(e.getDate() + t),
  (e, t) => (t - e - (t.getTimezoneOffset() - e.getTimezoneOffset()) * Sn) / ii,
  (e) => e.getDate() - 1
);
Cs.range;
const pd = ye((e) => {
  e.setUTCHours(0, 0, 0, 0);
}, (e, t) => {
  e.setUTCDate(e.getUTCDate() + t);
}, (e, t) => (t - e) / ii, (e) => e.getUTCDate() - 1);
pd.range;
const yd = ye((e) => {
  e.setUTCHours(0, 0, 0, 0);
}, (e, t) => {
  e.setUTCDate(e.getUTCDate() + t);
}, (e, t) => (t - e) / ii, (e) => Math.floor(e / ii));
yd.range;
function Ps(e) {
  return ye((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()) * Sn) / sg);
}
const Qo = Ps(0), zc = Ps(1), s6 = Ps(2), o6 = Ps(3), Rs = Ps(4), a6 = Ps(5), c6 = Ps(6);
Qo.range;
zc.range;
s6.range;
o6.range;
Rs.range;
a6.range;
c6.range;
function Us(e) {
  return ye((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) / sg);
}
const ta = Us(0), qc = Us(1), u6 = Us(2), l6 = Us(3), ks = Us(4), f6 = Us(5), h6 = Us(6);
ta.range;
qc.range;
u6.range;
l6.range;
ks.range;
f6.range;
h6.range;
const Su = ye((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());
Su.range;
const Mu = ye((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());
Mu.range;
const Yn = ye((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());
Yn.every = (e) => !isFinite(e = Math.floor(e)) || !(e > 0) ? null : ye((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);
});
Yn.range;
const Wn = ye((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());
Wn.every = (e) => !isFinite(e = Math.floor(e)) || !(e > 0) ? null : ye((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);
});
Wn.range;
function d6(e, t, n, r, i, s) {
  const o = [
    [Cn, 1, Hr],
    [Cn, 5, 5 * Hr],
    [Cn, 15, 15 * Hr],
    [Cn, 30, 30 * Hr],
    [s, 1, Sn],
    [s, 5, 5 * Sn],
    [s, 15, 15 * Sn],
    [s, 30, 30 * Sn],
    [i, 1, Jr],
    [i, 3, 3 * Jr],
    [i, 6, 6 * Jr],
    [i, 12, 12 * Jr],
    [r, 1, ii],
    [r, 2, 2 * ii],
    [n, 1, sg],
    [t, 1, Qw],
    [t, 3, 3 * Qw],
    [e, 1, Cp]
  ];
  function a(u, l, f) {
    const h = l < u;
    h && ([u, l] = [l, u]);
    const d = f && typeof f.range == "function" ? f : c(u, l, f), p = d ? d.range(u, +l + 1) : [];
    return h ? p.reverse() : p;
  }
  function c(u, l, f) {
    const h = Math.abs(l - u) / f, d = lu(([, , m]) => m).right(o, h);
    if (d === o.length) return e.every(F0(u / Cp, l / Cp, f));
    if (d === 0) return hh.every(Math.max(F0(u, l, f), 1));
    const [p, y] = o[h / o[d - 1][2] < o[d][2] / h ? d - 1 : d];
    return p.every(y);
  }
  return [a, c];
}
const [lq, p6] = d6(Wn, Mu, ta, yd, xu, _u), [fq, hq] = d6(Yn, Su, Qo, Cs, vu, wu);
function Pp(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 Up(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 ka(e, t, n) {
  return { y: e, m: t, d: n, H: 0, M: 0, S: 0, L: 0 };
}
function dq(e) {
  var t = e.dateTime, n = e.date, r = e.time, i = e.periods, s = e.days, o = e.shortDays, a = e.months, c = e.shortMonths, u = Fa(i), l = Ba(i), f = Fa(s), h = Ba(s), d = Fa(o), p = Ba(o), y = Fa(a), m = Ba(a), g = Fa(c), b = Ba(c), w = {
    a: R,
    A: B,
    b: C,
    B: F,
    c: null,
    d: s2,
    e: s2,
    f: Fq,
    g: Wq,
    G: Gq,
    H: Lq,
    I: Rq,
    j: kq,
    L: y6,
    m: Bq,
    M: Cq,
    p: P,
    q: U,
    Q: c2,
    s: u2,
    S: Pq,
    u: Uq,
    U: zq,
    V: qq,
    w: jq,
    W: Vq,
    x: null,
    X: null,
    y: Yq,
    Y: Xq,
    Z: Hq,
    "%": a2
  }, _ = {
    a: Y,
    A: G,
    b: K,
    B: H,
    c: null,
    d: o2,
    e: o2,
    f: Qq,
    g: uj,
    G: fj,
    H: Jq,
    I: Zq,
    j: Kq,
    L: g6,
    m: tj,
    M: ej,
    p: V,
    q: W,
    Q: c2,
    s: u2,
    S: nj,
    u: rj,
    U: ij,
    V: sj,
    w: oj,
    W: aj,
    x: null,
    X: null,
    y: cj,
    Y: lj,
    Z: hj,
    "%": a2
  }, x = {
    a: N,
    A,
    b: D,
    B: k,
    c: S,
    d: r2,
    e: r2,
    f: Eq,
    g: n2,
    G: e2,
    H: i2,
    I: i2,
    j: Aq,
    L: Tq,
    m: Mq,
    M: $q,
    p: $,
    q: Sq,
    Q: Dq,
    s: Oq,
    S: Iq,
    u: bq,
    U: wq,
    V: _q,
    w: gq,
    W: vq,
    x: I,
    X: T,
    y: n2,
    Y: e2,
    Z: xq,
    "%": Nq
  };
  w.x = v(n, w), w.X = v(r, w), w.c = v(t, w), _.x = v(n, _), _.X = v(r, _), _.c = v(t, _);
  function v(q, X) {
    return function(Z) {
      var z = [], wt = -1, tt = 0, It = q.length, Et, J, Ct;
      for (Z instanceof Date || (Z = /* @__PURE__ */ new Date(+Z)); ++wt < It; )
        q.charCodeAt(wt) === 37 && (z.push(q.slice(tt, wt)), (J = t2[Et = q.charAt(++wt)]) != null ? Et = q.charAt(++wt) : J = Et === "e" ? " " : "0", (Ct = X[Et]) && (Et = Ct(Z, J)), z.push(Et), tt = wt + 1);
      return z.push(q.slice(tt, wt)), z.join("");
    };
  }
  function M(q, X) {
    return function(Z) {
      var z = ka(1900, void 0, 1), wt = E(z, q, Z += "", 0), tt, It;
      if (wt != Z.length) return null;
      if ("Q" in z) return new Date(z.Q);
      if ("s" in z) return new Date(z.s * 1e3 + ("L" in z ? z.L : 0));
      if (X && !("Z" in z) && (z.Z = 0), "p" in z && (z.H = z.H % 12 + z.p * 12), z.m === void 0 && (z.m = "q" in z ? z.q : 0), "V" in z) {
        if (z.V < 1 || z.V > 53) return null;
        "w" in z || (z.w = 1), "Z" in z ? (tt = Up(ka(z.y, 0, 1)), It = tt.getUTCDay(), tt = It > 4 || It === 0 ? qc.ceil(tt) : qc(tt), tt = pd.offset(tt, (z.V - 1) * 7), z.y = tt.getUTCFullYear(), z.m = tt.getUTCMonth(), z.d = tt.getUTCDate() + (z.w + 6) % 7) : (tt = Pp(ka(z.y, 0, 1)), It = tt.getDay(), tt = It > 4 || It === 0 ? zc.ceil(tt) : zc(tt), tt = Cs.offset(tt, (z.V - 1) * 7), z.y = tt.getFullYear(), z.m = tt.getMonth(), z.d = tt.getDate() + (z.w + 6) % 7);
      } else ("W" in z || "U" in z) && ("w" in z || (z.w = "u" in z ? z.u % 7 : "W" in z ? 1 : 0), It = "Z" in z ? Up(ka(z.y, 0, 1)).getUTCDay() : Pp(ka(z.y, 0, 1)).getDay(), z.m = 0, z.d = "W" in z ? (z.w + 6) % 7 + z.W * 7 - (It + 5) % 7 : z.w + z.U * 7 - (It + 6) % 7);
      return "Z" in z ? (z.H += z.Z / 100 | 0, z.M += z.Z % 100, Up(z)) : Pp(z);
    };
  }
  function E(q, X, Z, z) {
    for (var wt = 0, tt = X.length, It = Z.length, Et, J; wt < tt; ) {
      if (z >= It) return -1;
      if (Et = X.charCodeAt(wt++), Et === 37) {
        if (Et = X.charAt(wt++), J = x[Et in t2 ? X.charAt(wt++) : Et], !J || (z = J(q, Z, z)) < 0) return -1;
      } else if (Et != Z.charCodeAt(z++))
        return -1;
    }
    return z;
  }
  function $(q, X, Z) {
    var z = u.exec(X.slice(Z));
    return z ? (q.p = l.get(z[0].toLowerCase()), Z + z[0].length) : -1;
  }
  function N(q, X, Z) {
    var z = d.exec(X.slice(Z));
    return z ? (q.w = p.get(z[0].toLowerCase()), Z + z[0].length) : -1;
  }
  function A(q, X, Z) {
    var z = f.exec(X.slice(Z));
    return z ? (q.w = h.get(z[0].toLowerCase()), Z + z[0].length) : -1;
  }
  function D(q, X, Z) {
    var z = g.exec(X.slice(Z));
    return z ? (q.m = b.get(z[0].toLowerCase()), Z + z[0].length) : -1;
  }
  function k(q, X, Z) {
    var z = y.exec(X.slice(Z));
    return z ? (q.m = m.get(z[0].toLowerCase()), Z + z[0].length) : -1;
  }
  function S(q, X, Z) {
    return E(q, t, X, Z);
  }
  function I(q, X, Z) {
    return E(q, n, X, Z);
  }
  function T(q, X, Z) {
    return E(q, r, X, Z);
  }
  function R(q) {
    return o[q.getDay()];
  }
  function B(q) {
    return s[q.getDay()];
  }
  function C(q) {
    return c[q.getMonth()];
  }
  function F(q) {
    return a[q.getMonth()];
  }
  function P(q) {
    return i[+(q.getHours() >= 12)];
  }
  function U(q) {
    return 1 + ~~(q.getMonth() / 3);
  }
  function Y(q) {
    return o[q.getUTCDay()];
  }
  function G(q) {
    return s[q.getUTCDay()];
  }
  function K(q) {
    return c[q.getUTCMonth()];
  }
  function H(q) {
    return a[q.getUTCMonth()];
  }
  function V(q) {
    return i[+(q.getUTCHours() >= 12)];
  }
  function W(q) {
    return 1 + ~~(q.getUTCMonth() / 3);
  }
  return {
    format: function(q) {
      var X = v(q += "", w);
      return X.toString = function() {
        return q;
      }, X;
    },
    parse: function(q) {
      var X = M(q += "", !1);
      return X.toString = function() {
        return q;
      }, X;
    },
    utcFormat: function(q) {
      var X = v(q += "", _);
      return X.toString = function() {
        return q;
      }, X;
    },
    utcParse: function(q) {
      var X = M(q += "", !0);
      return X.toString = function() {
        return q;
      }, X;
    }
  };
}
var t2 = { "-": "", _: " ", 0: "0" }, xe = /^\s*\d+/, pq = /^%/, yq = /[\\^$*+?|[\]().{}]/g;
function Rt(e, t, n) {
  var r = e < 0 ? "-" : "", i = (r ? -e : e) + "", s = i.length;
  return r + (s < n ? new Array(n - s + 1).join(t) + i : i);
}
function mq(e) {
  return e.replace(yq, "\\$&");
}
function Fa(e) {
  return new RegExp("^(?:" + e.map(mq).join("|") + ")", "i");
}
function Ba(e) {
  return new Map(e.map((t, n) => [t.toLowerCase(), n]));
}
function gq(e, t, n) {
  var r = xe.exec(t.slice(n, n + 1));
  return r ? (e.w = +r[0], n + r[0].length) : -1;
}
function bq(e, t, n) {
  var r = xe.exec(t.slice(n, n + 1));
  return r ? (e.u = +r[0], n + r[0].length) : -1;
}
function wq(e, t, n) {
  var r = xe.exec(t.slice(n, n + 2));
  return r ? (e.U = +r[0], n + r[0].length) : -1;
}
function _q(e, t, n) {
  var r = xe.exec(t.slice(n, n + 2));
  return r ? (e.V = +r[0], n + r[0].length) : -1;
}
function vq(e, t, n) {
  var r = xe.exec(t.slice(n, n + 2));
  return r ? (e.W = +r[0], n + r[0].length) : -1;
}
function e2(e, t, n) {
  var r = xe.exec(t.slice(n, n + 4));
  return r ? (e.y = +r[0], n + r[0].length) : -1;
}
function n2(e, t, n) {
  var r = xe.exec(t.slice(n, n + 2));
  return r ? (e.y = +r[0] + (+r[0] > 68 ? 1900 : 2e3), n + r[0].length) : -1;
}
function xq(e, t, n) {
  var r = /^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n, n + 6));
  return r ? (e.Z = r[1] ? 0 : -(r[2] + (r[3] || "00")), n + r[0].length) : -1;
}
function Sq(e, t, n) {
  var r = xe.exec(t.slice(n, n + 1));
  return r ? (e.q = r[0] * 3 - 3, n + r[0].length) : -1;
}
function Mq(e, t, n) {
  var r = xe.exec(t.slice(n, n + 2));
  return r ? (e.m = r[0] - 1, n + r[0].length) : -1;
}
function r2(e, t, n) {
  var r = xe.exec(t.slice(n, n + 2));
  return r ? (e.d = +r[0], n + r[0].length) : -1;
}
function Aq(e, t, n) {
  var r = xe.exec(t.slice(n, n + 3));
  return r ? (e.m = 0, e.d = +r[0], n + r[0].length) : -1;
}
function i2(e, t, n) {
  var r = xe.exec(t.slice(n, n + 2));
  return r ? (e.H = +r[0], n + r[0].length) : -1;
}
function $q(e, t, n) {
  var r = xe.exec(t.slice(n, n + 2));
  return r ? (e.M = +r[0], n + r[0].length) : -1;
}
function Iq(e, t, n) {
  var r = xe.exec(t.slice(n, n + 2));
  return r ? (e.S = +r[0], n + r[0].length) : -1;
}
function Tq(e, t, n) {
  var r = xe.exec(t.slice(n, n + 3));
  return r ? (e.L = +r[0], n + r[0].length) : -1;
}
function Eq(e, t, n) {
  var r = xe.exec(t.slice(n, n + 6));
  return r ? (e.L = Math.floor(r[0] / 1e3), n + r[0].length) : -1;
}
function Nq(e, t, n) {
  var r = pq.exec(t.slice(n, n + 1));
  return r ? n + r[0].length : -1;
}
function Dq(e, t, n) {
  var r = xe.exec(t.slice(n));
  return r ? (e.Q = +r[0], n + r[0].length) : -1;
}
function Oq(e, t, n) {
  var r = xe.exec(t.slice(n));
  return r ? (e.s = +r[0], n + r[0].length) : -1;
}
function s2(e, t) {
  return Rt(e.getDate(), t, 2);
}
function Lq(e, t) {
  return Rt(e.getHours(), t, 2);
}
function Rq(e, t) {
  return Rt(e.getHours() % 12 || 12, t, 2);
}
function kq(e, t) {
  return Rt(1 + Cs.count(Yn(e), e), t, 3);
}
function y6(e, t) {
  return Rt(e.getMilliseconds(), t, 3);
}
function Fq(e, t) {
  return y6(e, t) + "000";
}
function Bq(e, t) {
  return Rt(e.getMonth() + 1, t, 2);
}
function Cq(e, t) {
  return Rt(e.getMinutes(), t, 2);
}
function Pq(e, t) {
  return Rt(e.getSeconds(), t, 2);
}
function Uq(e) {
  var t = e.getDay();
  return t === 0 ? 7 : t;
}
function zq(e, t) {
  return Rt(Qo.count(Yn(e) - 1, e), t, 2);
}
function m6(e) {
  var t = e.getDay();
  return t >= 4 || t === 0 ? Rs(e) : Rs.ceil(e);
}
function qq(e, t) {
  return e = m6(e), Rt(Rs.count(Yn(e), e) + (Yn(e).getDay() === 4), t, 2);
}
function jq(e) {
  return e.getDay();
}
function Vq(e, t) {
  return Rt(zc.count(Yn(e) - 1, e), t, 2);
}
function Yq(e, t) {
  return Rt(e.getFullYear() % 100, t, 2);
}
function Wq(e, t) {
  return e = m6(e), Rt(e.getFullYear() % 100, t, 2);
}
function Xq(e, t) {
  return Rt(e.getFullYear() % 1e4, t, 4);
}
function Gq(e, t) {
  var n = e.getDay();
  return e = n >= 4 || n === 0 ? Rs(e) : Rs.ceil(e), Rt(e.getFullYear() % 1e4, t, 4);
}
function Hq(e) {
  var t = e.getTimezoneOffset();
  return (t > 0 ? "-" : (t *= -1, "+")) + Rt(t / 60 | 0, "0", 2) + Rt(t % 60, "0", 2);
}
function o2(e, t) {
  return Rt(e.getUTCDate(), t, 2);
}
function Jq(e, t) {
  return Rt(e.getUTCHours(), t, 2);
}
function Zq(e, t) {
  return Rt(e.getUTCHours() % 12 || 12, t, 2);
}
function Kq(e, t) {
  return Rt(1 + pd.count(Wn(e), e), t, 3);
}
function g6(e, t) {
  return Rt(e.getUTCMilliseconds(), t, 3);
}
function Qq(e, t) {
  return g6(e, t) + "000";
}
function tj(e, t) {
  return Rt(e.getUTCMonth() + 1, t, 2);
}
function ej(e, t) {
  return Rt(e.getUTCMinutes(), t, 2);
}
function nj(e, t) {
  return Rt(e.getUTCSeconds(), t, 2);
}
function rj(e) {
  var t = e.getUTCDay();
  return t === 0 ? 7 : t;
}
function ij(e, t) {
  return Rt(ta.count(Wn(e) - 1, e), t, 2);
}
function b6(e) {
  var t = e.getUTCDay();
  return t >= 4 || t === 0 ? ks(e) : ks.ceil(e);
}
function sj(e, t) {
  return e = b6(e), Rt(ks.count(Wn(e), e) + (Wn(e).getUTCDay() === 4), t, 2);
}
function oj(e) {
  return e.getUTCDay();
}
function aj(e, t) {
  return Rt(qc.count(Wn(e) - 1, e), t, 2);
}
function cj(e, t) {
  return Rt(e.getUTCFullYear() % 100, t, 2);
}
function uj(e, t) {
  return e = b6(e), Rt(e.getUTCFullYear() % 100, t, 2);
}
function lj(e, t) {
  return Rt(e.getUTCFullYear() % 1e4, t, 4);
}
function fj(e, t) {
  var n = e.getUTCDay();
  return e = n >= 4 || n === 0 ? ks(e) : ks.ceil(e), Rt(e.getUTCFullYear() % 1e4, t, 4);
}
function hj() {
  return "+0000";
}
function a2() {
  return "%";
}
function c2(e) {
  return +e;
}
function u2(e) {
  return Math.floor(+e / 1e3);
}
var Ks, og, Au;
dj({
  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 dj(e) {
  return Ks = dq(e), og = Ks.format, Ks.parse, Au = Ks.utcFormat, Ks.utcParse, Ks;
}
function pj(e) {
  return new Date(e);
}
function yj(e) {
  return e instanceof Date ? +e : +/* @__PURE__ */ new Date(+e);
}
function ag(e, t, n, r, i, s, o, a, c, u) {
  var l = G3(), f = l.invert, h = l.domain, d = u(".%L"), p = u(":%S"), y = u("%I:%M"), m = u("%I %p"), g = u("%a %d"), b = u("%b %d"), w = u("%B"), _ = u("%Y");
  function x(v) {
    return (c(v) < v ? d : a(v) < v ? p : o(v) < v ? y : s(v) < v ? m : r(v) < v ? i(v) < v ? g : b : n(v) < v ? w : _)(v);
  }
  return l.invert = function(v) {
    return new Date(f(v));
  }, l.domain = function(v) {
    return arguments.length ? h(Array.from(v, yj)) : h().map(pj);
  }, l.ticks = function(v) {
    var M = h();
    return e(M[0], M[M.length - 1], v ?? 10);
  }, l.tickFormat = function(v, M) {
    return M == null ? x : u(M);
  }, l.nice = function(v) {
    var M = h();
    return (!v || typeof v.range != "function") && (v = t(M[0], M[M.length - 1], v ?? 10)), v ? h(J3(M, v)) : l;
  }, l.copy = function() {
    return gu(l, ag(e, t, n, r, i, s, o, a, c, u));
  }, l;
}
function mj() {
  return Sr.apply(ag(fq, hq, Yn, Su, Qo, Cs, vu, wu, Cn, og).domain([new Date(2e3, 0, 1), new Date(2e3, 0, 2)]), arguments);
}
function gj() {
  return Sr.apply(ag(lq, p6, Wn, Mu, ta, pd, xu, _u, Cn, Au).domain([Date.UTC(2e3, 0, 1), Date.UTC(2e3, 0, 2)]), arguments);
}
function md(e, t) {
  return t.domain(e.domain()).interpolator(e.interpolator()).clamp(e.clamp()).unknown(e.unknown());
}
function gd() {
  var e = 0, t = 0.5, n = 1, r = 1, i, s, o, a, c, u = xn, l, f = !1, h;
  function d(y) {
    return isNaN(y = +y) ? h : (y = 0.5 + ((y = +l(y)) - s) * (r * y < r * s ? a : c), u(f ? Math.max(0, Math.min(1, y)) : y));
  }
  d.domain = function(y) {
    return arguments.length ? ([e, t, n] = y, i = l(e = +e), s = l(t = +t), o = l(n = +n), a = i === s ? 0 : 0.5 / (s - i), c = s === o ? 0 : 0.5 / (o - s), r = s < i ? -1 : 1, d) : [e, t, n];
  }, d.clamp = function(y) {
    return arguments.length ? (f = !!y, d) : f;
  }, d.interpolator = function(y) {
    return arguments.length ? (u = y, d) : u;
  };
  function p(y) {
    return function(m) {
      var g, b, w;
      return arguments.length ? ([g, b, w] = m, u = sd(y, [g, b, w]), d) : [u(0), u(0.5), u(1)];
    };
  }
  return d.range = p(ma), d.rangeRound = p(Ym), d.unknown = function(y) {
    return arguments.length ? (h = y, d) : h;
  }, function(y) {
    return l = y, i = y(e), s = y(t), o = y(n), a = i === s ? 0 : 0.5 / (s - i), c = s === o ? 0 : 0.5 / (o - s), r = s < i ? -1 : 1, d;
  };
}
function w6() {
  var e = bu(gd()(xn));
  return e.copy = function() {
    return md(e, w6());
  }, ld.apply(e, arguments);
}
function _6() {
  var e = Z3(gd()).domain([0.1, 1, 10]);
  return e.copy = function() {
    return md(e, _6()).base(e.base());
  }, ld.apply(e, arguments);
}
function v6() {
  var e = Q3(gd());
  return e.copy = function() {
    return md(e, v6()).constant(e.constant());
  }, ld.apply(e, arguments);
}
function x6() {
  var e = e6(gd());
  return e.copy = function() {
    return md(e, x6()).exponent(e.exponent());
  }, ld.apply(e, arguments);
}
function _t(e) {
  for (var t = e.length / 6 | 0, n = new Array(t), r = 0; r < t; ) n[r] = "#" + e.slice(r * 6, ++r * 6);
  return n;
}
const bj = _t("1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf"), wj = _t("7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666"), _j = _t("1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666"), vj = _t("4269d0efb118ff725c6cc5b03ca951ff8ab7a463f297bbf59c6b4e9498a0"), xj = _t("a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928"), Sj = _t("fbb4aeb3cde3ccebc5decbe4fed9a6ffffcce5d8bdfddaecf2f2f2"), Mj = _t("b3e2cdfdcdaccbd5e8f4cae4e6f5c9fff2aef1e2cccccccc"), Aj = _t("e41a1c377eb84daf4a984ea3ff7f00ffff33a65628f781bf999999"), $j = _t("66c2a5fc8d628da0cbe78ac3a6d854ffd92fe5c494b3b3b3"), Ij = _t("8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f"), Tj = _t("4e79a7f28e2ce1575976b7b259a14fedc949af7aa1ff9da79c755fbab0ab"), Xt = (e) => DB(e[e.length - 1]);
var S6 = new Array(3).concat(
  "d8b365f5f5f55ab4ac",
  "a6611adfc27d80cdc1018571",
  "a6611adfc27df5f5f580cdc1018571",
  "8c510ad8b365f6e8c3c7eae55ab4ac01665e",
  "8c510ad8b365f6e8c3f5f5f5c7eae55ab4ac01665e",
  "8c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e",
  "8c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e",
  "5430058c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e003c30",
  "5430058c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e003c30"
).map(_t);
const M6 = Xt(S6);
var A6 = new Array(3).concat(
  "af8dc3f7f7f77fbf7b",
  "7b3294c2a5cfa6dba0008837",
  "7b3294c2a5cff7f7f7a6dba0008837",
  "762a83af8dc3e7d4e8d9f0d37fbf7b1b7837",
  "762a83af8dc3e7d4e8f7f7f7d9f0d37fbf7b1b7837",
  "762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b7837",
  "762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b7837",
  "40004b762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b783700441b",
  "40004b762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b783700441b"
).map(_t);
const $6 = Xt(A6);
var I6 = new Array(3).concat(
  "e9a3c9f7f7f7a1d76a",
  "d01c8bf1b6dab8e1864dac26",
  "d01c8bf1b6daf7f7f7b8e1864dac26",
  "c51b7de9a3c9fde0efe6f5d0a1d76a4d9221",
  "c51b7de9a3c9fde0eff7f7f7e6f5d0a1d76a4d9221",
  "c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221",
  "c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221",
  "8e0152c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221276419",
  "8e0152c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221276419"
).map(_t);
const T6 = Xt(I6);
var E6 = new Array(3).concat(
  "998ec3f7f7f7f1a340",
  "5e3c99b2abd2fdb863e66101",
  "5e3c99b2abd2f7f7f7fdb863e66101",
  "542788998ec3d8daebfee0b6f1a340b35806",
  "542788998ec3d8daebf7f7f7fee0b6f1a340b35806",
  "5427888073acb2abd2d8daebfee0b6fdb863e08214b35806",
  "5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b35806",
  "2d004b5427888073acb2abd2d8daebfee0b6fdb863e08214b358067f3b08",
  "2d004b5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b358067f3b08"
).map(_t);
const N6 = Xt(E6);
var xy = new Array(3).concat(
  "ef8a62f7f7f767a9cf",
  "ca0020f4a58292c5de0571b0",
  "ca0020f4a582f7f7f792c5de0571b0",
  "b2182bef8a62fddbc7d1e5f067a9cf2166ac",
  "b2182bef8a62fddbc7f7f7f7d1e5f067a9cf2166ac",
  "b2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac",
  "b2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac",
  "67001fb2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac053061",
  "67001fb2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac053061"
).map(_t);
const dh = Xt(xy);
var D6 = new Array(3).concat(
  "ef8a62ffffff999999",
  "ca0020f4a582bababa404040",
  "ca0020f4a582ffffffbababa404040",
  "b2182bef8a62fddbc7e0e0e09999994d4d4d",
  "b2182bef8a62fddbc7ffffffe0e0e09999994d4d4d",
  "b2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d",
  "b2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d",
  "67001fb2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d1a1a1a",
  "67001fb2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d1a1a1a"
).map(_t);
const O6 = Xt(D6);
var Sy = new Array(3).concat(
  "fc8d59ffffbf91bfdb",
  "d7191cfdae61abd9e92c7bb6",
  "d7191cfdae61ffffbfabd9e92c7bb6",
  "d73027fc8d59fee090e0f3f891bfdb4575b4",
  "d73027fc8d59fee090ffffbfe0f3f891bfdb4575b4",
  "d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4",
  "d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4",
  "a50026d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4313695",
  "a50026d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4313695"
).map(_t);
const ph = Xt(Sy);
var L6 = new Array(3).concat(
  "fc8d59ffffbf91cf60",
  "d7191cfdae61a6d96a1a9641",
  "d7191cfdae61ffffbfa6d96a1a9641",
  "d73027fc8d59fee08bd9ef8b91cf601a9850",
  "d73027fc8d59fee08bffffbfd9ef8b91cf601a9850",
  "d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850",
  "d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850",
  "a50026d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850006837",
  "a50026d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850006837"
).map(_t);
const R6 = Xt(L6);
var k6 = new Array(3).concat(
  "fc8d59ffffbf99d594",
  "d7191cfdae61abdda42b83ba",
  "d7191cfdae61ffffbfabdda42b83ba",
  "d53e4ffc8d59fee08be6f59899d5943288bd",
  "d53e4ffc8d59fee08bffffbfe6f59899d5943288bd",
  "d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd",
  "d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd",
  "9e0142d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd5e4fa2",
  "9e0142d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd5e4fa2"
).map(_t);
const F6 = Xt(k6);
var B6 = new Array(3).concat(
  "e5f5f999d8c92ca25f",
  "edf8fbb2e2e266c2a4238b45",
  "edf8fbb2e2e266c2a42ca25f006d2c",
  "edf8fbccece699d8c966c2a42ca25f006d2c",
  "edf8fbccece699d8c966c2a441ae76238b45005824",
  "f7fcfde5f5f9ccece699d8c966c2a441ae76238b45005824",
  "f7fcfde5f5f9ccece699d8c966c2a441ae76238b45006d2c00441b"
).map(_t);
const C6 = Xt(B6);
var P6 = new Array(3).concat(
  "e0ecf49ebcda8856a7",
  "edf8fbb3cde38c96c688419d",
  "edf8fbb3cde38c96c68856a7810f7c",
  "edf8fbbfd3e69ebcda8c96c68856a7810f7c",
  "edf8fbbfd3e69ebcda8c96c68c6bb188419d6e016b",
  "f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d6e016b",
  "f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d810f7c4d004b"
).map(_t);
const U6 = Xt(P6);
var z6 = new Array(3).concat(
  "e0f3dba8ddb543a2ca",
  "f0f9e8bae4bc7bccc42b8cbe",
  "f0f9e8bae4bc7bccc443a2ca0868ac",
  "f0f9e8ccebc5a8ddb57bccc443a2ca0868ac",
  "f0f9e8ccebc5a8ddb57bccc44eb3d32b8cbe08589e",
  "f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe08589e",
  "f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe0868ac084081"
).map(_t);
const q6 = Xt(z6);
var j6 = new Array(3).concat(
  "fee8c8fdbb84e34a33",
  "fef0d9fdcc8afc8d59d7301f",
  "fef0d9fdcc8afc8d59e34a33b30000",
  "fef0d9fdd49efdbb84fc8d59e34a33b30000",
  "fef0d9fdd49efdbb84fc8d59ef6548d7301f990000",
  "fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301f990000",
  "fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301fb300007f0000"
).map(_t);
const V6 = Xt(j6);
var Y6 = new Array(3).concat(
  "ece2f0a6bddb1c9099",
  "f6eff7bdc9e167a9cf02818a",
  "f6eff7bdc9e167a9cf1c9099016c59",
  "f6eff7d0d1e6a6bddb67a9cf1c9099016c59",
  "f6eff7d0d1e6a6bddb67a9cf3690c002818a016450",
  "fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016450",
  "fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016c59014636"
).map(_t);
const W6 = Xt(Y6);
var X6 = new Array(3).concat(
  "ece7f2a6bddb2b8cbe",
  "f1eef6bdc9e174a9cf0570b0",
  "f1eef6bdc9e174a9cf2b8cbe045a8d",
  "f1eef6d0d1e6a6bddb74a9cf2b8cbe045a8d",
  "f1eef6d0d1e6a6bddb74a9cf3690c00570b0034e7b",
  "fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0034e7b",
  "fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0045a8d023858"
).map(_t);
const G6 = Xt(X6);
var H6 = new Array(3).concat(
  "e7e1efc994c7dd1c77",
  "f1eef6d7b5d8df65b0ce1256",
  "f1eef6d7b5d8df65b0dd1c77980043",
  "f1eef6d4b9dac994c7df65b0dd1c77980043",
  "f1eef6d4b9dac994c7df65b0e7298ace125691003f",
  "f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125691003f",
  "f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125698004367001f"
).map(_t);
const J6 = Xt(H6);
var Z6 = new Array(3).concat(
  "fde0ddfa9fb5c51b8a",
  "feebe2fbb4b9f768a1ae017e",
  "feebe2fbb4b9f768a1c51b8a7a0177",
  "feebe2fcc5c0fa9fb5f768a1c51b8a7a0177",
  "feebe2fcc5c0fa9fb5f768a1dd3497ae017e7a0177",
  "fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a0177",
  "fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a017749006a"
).map(_t);
const K6 = Xt(Z6);
var Q6 = new Array(3).concat(
  "edf8b17fcdbb2c7fb8",
  "ffffcca1dab441b6c4225ea8",
  "ffffcca1dab441b6c42c7fb8253494",
  "ffffccc7e9b47fcdbb41b6c42c7fb8253494",
  "ffffccc7e9b47fcdbb41b6c41d91c0225ea80c2c84",
  "ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea80c2c84",
  "ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea8253494081d58"
).map(_t);
const tM = Xt(Q6);
var eM = new Array(3).concat(
  "f7fcb9addd8e31a354",
  "ffffccc2e69978c679238443",
  "ffffccc2e69978c67931a354006837",
  "ffffccd9f0a3addd8e78c67931a354006837",
  "ffffccd9f0a3addd8e78c67941ab5d238443005a32",
  "ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443005a32",
  "ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443006837004529"
).map(_t);
const nM = Xt(eM);
var rM = new Array(3).concat(
  "fff7bcfec44fd95f0e",
  "ffffd4fed98efe9929cc4c02",
  "ffffd4fed98efe9929d95f0e993404",
  "ffffd4fee391fec44ffe9929d95f0e993404",
  "ffffd4fee391fec44ffe9929ec7014cc4c028c2d04",
  "ffffe5fff7bcfee391fec44ffe9929ec7014cc4c028c2d04",
  "ffffe5fff7bcfee391fec44ffe9929ec7014cc4c02993404662506"
).map(_t);
const iM = Xt(rM);
var sM = new Array(3).concat(
  "ffeda0feb24cf03b20",
  "ffffb2fecc5cfd8d3ce31a1c",
  "ffffb2fecc5cfd8d3cf03b20bd0026",
  "ffffb2fed976feb24cfd8d3cf03b20bd0026",
  "ffffb2fed976feb24cfd8d3cfc4e2ae31a1cb10026",
  "ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cb10026",
  "ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cbd0026800026"
).map(_t);
const oM = Xt(sM);
var aM = new Array(3).concat(
  "deebf79ecae13182bd",
  "eff3ffbdd7e76baed62171b5",
  "eff3ffbdd7e76baed63182bd08519c",
  "eff3ffc6dbef9ecae16baed63182bd08519c",
  "eff3ffc6dbef9ecae16baed64292c62171b5084594",
  "f7fbffdeebf7c6dbef9ecae16baed64292c62171b5084594",
  "f7fbffdeebf7c6dbef9ecae16baed64292c62171b508519c08306b"
).map(_t);
const cM = Xt(aM);
var uM = new Array(3).concat(
  "e5f5e0a1d99b31a354",
  "edf8e9bae4b374c476238b45",
  "edf8e9bae4b374c47631a354006d2c",
  "edf8e9c7e9c0a1d99b74c47631a354006d2c",
  "edf8e9c7e9c0a1d99b74c47641ab5d238b45005a32",
  "f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45005a32",
  "f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45006d2c00441b"
).map(_t);
const lM = Xt(uM);
var fM = new Array(3).concat(
  "f0f0f0bdbdbd636363",
  "f7f7f7cccccc969696525252",
  "f7f7f7cccccc969696636363252525",
  "f7f7f7d9d9d9bdbdbd969696636363252525",
  "f7f7f7d9d9d9bdbdbd969696737373525252252525",
  "fffffff0f0f0d9d9d9bdbdbd969696737373525252252525",
  "fffffff0f0f0d9d9d9bdbdbd969696737373525252252525000000"
).map(_t);
const hM = Xt(fM);
var dM = new Array(3).concat(
  "efedf5bcbddc756bb1",
  "f2f0f7cbc9e29e9ac86a51a3",
  "f2f0f7cbc9e29e9ac8756bb154278f",
  "f2f0f7dadaebbcbddc9e9ac8756bb154278f",
  "f2f0f7dadaebbcbddc9e9ac8807dba6a51a34a1486",
  "fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a34a1486",
  "fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a354278f3f007d"
).map(_t);
const pM = Xt(dM);
var yM = new Array(3).concat(
  "fee0d2fc9272de2d26",
  "fee5d9fcae91fb6a4acb181d",
  "fee5d9fcae91fb6a4ade2d26a50f15",
  "fee5d9fcbba1fc9272fb6a4ade2d26a50f15",
  "fee5d9fcbba1fc9272fb6a4aef3b2ccb181d99000d",
  "fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181d99000d",
  "fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181da50f1567000d"
).map(_t);
const mM = Xt(yM);
var gM = new Array(3).concat(
  "fee6cefdae6be6550d",
  "feeddefdbe85fd8d3cd94701",
  "feeddefdbe85fd8d3ce6550da63603",
  "feeddefdd0a2fdae6bfd8d3ce6550da63603",
  "feeddefdd0a2fdae6bfd8d3cf16913d948018c2d04",
  "fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d948018c2d04",
  "fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d94801a636037f2704"
).map(_t);
const bM = Xt(gM);
function wM(e) {
  return e = Math.max(0, Math.min(1, e)), "rgb(" + Math.max(0, Math.min(255, Math.round(-4.54 - e * (35.34 - e * (2381.73 - e * (6402.7 - e * (7024.72 - e * 2710.57))))))) + ", " + Math.max(0, Math.min(255, Math.round(32.49 + e * (170.73 + e * (52.82 - e * (131.46 - e * (176.58 - e * 67.37))))))) + ", " + Math.max(0, Math.min(255, Math.round(81.24 + e * (442.36 - e * (2482.43 - e * (6167.24 - e * (6614.94 - e * 2475.67))))))) + ")";
}
const _M = Wm(wr(300, 0.5, 0), wr(-240, 0.5, 1));
var vM = Wm(wr(-100, 0.75, 0.35), wr(80, 1.5, 0.8)), xM = Wm(wr(260, 0.75, 0.35), wr(80, 1.5, 0.8)), cl = wr();
function SM(e) {
  (e < 0 || e > 1) && (e -= Math.floor(e));
  var t = Math.abs(e - 0.5);
  return cl.h = 360 * e - 100, cl.s = 1.5 - 1.5 * t, cl.l = 0.8 - 0.9 * t, cl + "";
}
var ul = un(), Ej = Math.PI / 3, Nj = Math.PI * 2 / 3;
function MM(e) {
  var t;
  return e = (0.5 - e) * Math.PI, ul.r = 255 * (t = Math.sin(e)) * t, ul.g = 255 * (t = Math.sin(e + Ej)) * t, ul.b = 255 * (t = Math.sin(e + Nj)) * t, ul + "";
}
function AM(e) {
  return e = Math.max(0, Math.min(1, e)), "rgb(" + Math.max(0, Math.min(255, Math.round(34.61 + e * (1172.33 - e * (10793.56 - e * (33300.12 - e * (38394.49 - e * 14825.05))))))) + ", " + Math.max(0, Math.min(255, Math.round(23.31 + e * (557.33 + e * (1225.33 - e * (3574.96 - e * (1073.77 + e * 707.56))))))) + ", " + Math.max(0, Math.min(255, Math.round(27.2 + e * (3211.1 - e * (15327.97 - e * (27814 - e * (22569.18 - e * 6838.66))))))) + ")";
}
function bd(e) {
  var t = e.length;
  return function(n) {
    return e[Math.max(0, Math.min(t - 1, Math.floor(n * t)))];
  };
}
const $M = bd(_t("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725"));
var IM = bd(_t("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf")), TM = bd(_t("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4")), EM = bd(_t("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921"));
function we(e) {
  return function() {
    return e;
  };
}
const NM = Math.cos, cg = Math.min, yh = Math.sin, me = Math.sqrt, l2 = 1e-12, mh = Math.PI, wd = 2 * mh;
function DM(e) {
  let t = 3;
  return e.digits = function(n) {
    if (!arguments.length) return t;
    if (n == null)
      t = null;
    else {
      const r = Math.floor(n);
      if (!(r >= 0)) throw new RangeError(`invalid digits: ${n}`);
      t = r;
    }
    return e;
  }, () => new i3(t);
}
function OM(e) {
  return typeof e == "object" && "length" in e ? e : Array.from(e);
}
function LM(e) {
  this._context = e;
}
LM.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 $u(e) {
  return new LM(e);
}
function RM(e) {
  return e[0];
}
function kM(e) {
  return e[1];
}
function FM(e, t) {
  var n = we(!0), r = null, i = $u, s = null, o = DM(a);
  e = typeof e == "function" ? e : e === void 0 ? RM : we(e), t = typeof t == "function" ? t : t === void 0 ? kM : we(t);
  function a(c) {
    var u, l = (c = OM(c)).length, f, h = !1, d;
    for (r == null && (s = i(d = o())), u = 0; u <= l; ++u)
      !(u < l && n(f = c[u], u, c)) === h && ((h = !h) ? s.lineStart() : s.lineEnd()), h && s.point(+e(f, u, c), +t(f, u, c));
    if (d) return s = null, d + "" || null;
  }
  return a.x = function(c) {
    return arguments.length ? (e = typeof c == "function" ? c : we(+c), a) : e;
  }, a.y = function(c) {
    return arguments.length ? (t = typeof c == "function" ? c : we(+c), a) : t;
  }, a.defined = function(c) {
    return arguments.length ? (n = typeof c == "function" ? c : we(!!c), a) : n;
  }, a.curve = function(c) {
    return arguments.length ? (i = c, r != null && (s = i(r)), a) : i;
  }, a.context = function(c) {
    return arguments.length ? (c == null ? r = s = null : s = i(r = c), a) : r;
  }, a;
}
function ug(e, t, n) {
  var r = null, i = we(!0), s = null, o = $u, a = null, c = DM(u);
  e = typeof e == "function" ? e : e === void 0 ? RM : we(+e), t = typeof t == "function" ? t : we(t === void 0 ? 0 : +t), n = typeof n == "function" ? n : n === void 0 ? kM : we(+n);
  function u(f) {
    var h, d, p, y = (f = OM(f)).length, m, g = !1, b, w = new Array(y), _ = new Array(y);
    for (s == null && (a = o(b = c())), h = 0; h <= y; ++h) {
      if (!(h < y && i(m = f[h], h, f)) === g)
        if (g = !g)
          d = h, a.areaStart(), a.lineStart();
        else {
          for (a.lineEnd(), a.lineStart(), p = h - 1; p >= d; --p)
            a.point(w[p], _[p]);
          a.lineEnd(), a.areaEnd();
        }
      g && (w[h] = +e(m, h, f), _[h] = +t(m, h, f), a.point(r ? +r(m, h, f) : w[h], n ? +n(m, h, f) : _[h]));
    }
    if (b) return a = null, b + "" || null;
  }
  function l() {
    return FM().defined(i).curve(o).context(s);
  }
  return u.x = function(f) {
    return arguments.length ? (e = typeof f == "function" ? f : we(+f), r = null, u) : e;
  }, u.x0 = function(f) {
    return arguments.length ? (e = typeof f == "function" ? f : we(+f), u) : e;
  }, u.x1 = function(f) {
    return arguments.length ? (r = f == null ? null : typeof f == "function" ? f : we(+f), u) : r;
  }, u.y = function(f) {
    return arguments.length ? (t = typeof f == "function" ? f : we(+f), n = null, u) : t;
  }, u.y0 = function(f) {
    return arguments.length ? (t = typeof f == "function" ? f : we(+f), u) : t;
  }, u.y1 = function(f) {
    return arguments.length ? (n = f == null ? null : typeof f == "function" ? f : we(+f), u) : n;
  }, u.lineX0 = u.lineY0 = function() {
    return l().x(e).y(t);
  }, u.lineY1 = function() {
    return l().x(e).y(n);
  }, u.lineX1 = function() {
    return l().x(r).y(t);
  }, u.defined = function(f) {
    return arguments.length ? (i = typeof f == "function" ? f : we(!!f), u) : i;
  }, 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;
}
class BM {
  constructor(t, n) {
    this._context = t, this._x = n;
  }
  areaStart() {
    this._line = 0;
  }
  areaEnd() {
    this._line = NaN;
  }
  lineStart() {
    this._point = 0;
  }
  lineEnd() {
    (this._line || this._line !== 0 && this._point === 1) && this._context.closePath(), this._line = 1 - this._line;
  }
  point(t, n) {
    switch (t = +t, n = +n, this._point) {
      case 0: {
        this._point = 1, this._line ? this._context.lineTo(t, n) : this._context.moveTo(t, n);
        break;
      }
      case 1:
        this._point = 2;
      default: {
        this._x ? this._context.bezierCurveTo(this._x0 = (this._x0 + t) / 2, this._y0, this._x0, n, t, n) : this._context.bezierCurveTo(this._x0, this._y0 = (this._y0 + n) / 2, t, this._y0, t, n);
        break;
      }
    }
    this._x0 = t, this._y0 = n;
  }
}
function Dj(e) {
  return new BM(e, !0);
}
function Oj(e) {
  return new BM(e, !1);
}
const Lj = me(3), CM = {
  draw(e, t) {
    const n = me(t + cg(t / 28, 0.75)) * 0.59436, r = n / 2, i = r * Lj;
    e.moveTo(0, n), e.lineTo(0, -n), e.moveTo(-i, -r), e.lineTo(i, r), e.moveTo(-i, r), e.lineTo(i, -r);
  }
}, jc = {
  draw(e, t) {
    const n = me(t / mh);
    e.moveTo(n, 0), e.arc(0, 0, n, 0, wd);
  }
}, PM = {
  draw(e, t) {
    const n = me(t / 5) / 2;
    e.moveTo(-3 * n, -n), e.lineTo(-n, -n), e.lineTo(-n, -3 * n), e.lineTo(n, -3 * n), e.lineTo(n, -n), e.lineTo(3 * n, -n), e.lineTo(3 * n, n), e.lineTo(n, n), e.lineTo(n, 3 * n), e.lineTo(-n, 3 * n), e.lineTo(-n, n), e.lineTo(-3 * n, n), e.closePath();
  }
}, UM = me(1 / 3), Rj = UM * 2, zM = {
  draw(e, t) {
    const n = me(t / Rj), r = n * UM;
    e.moveTo(0, -n), e.lineTo(r, 0), e.lineTo(0, n), e.lineTo(-r, 0), e.closePath();
  }
}, qM = {
  draw(e, t) {
    const n = me(t) * 0.62625;
    e.moveTo(0, -n), e.lineTo(n, 0), e.lineTo(0, n), e.lineTo(-n, 0), e.closePath();
  }
}, jM = {
  draw(e, t) {
    const n = me(t - cg(t / 7, 2)) * 0.87559;
    e.moveTo(-n, 0), e.lineTo(n, 0), e.moveTo(0, n), e.lineTo(0, -n);
  }
}, VM = {
  draw(e, t) {
    const n = me(t), r = -n / 2;
    e.rect(r, r, n, n);
  }
}, YM = {
  draw(e, t) {
    const n = me(t) * 0.4431;
    e.moveTo(n, n), e.lineTo(n, -n), e.lineTo(-n, -n), e.lineTo(-n, n), e.closePath();
  }
}, kj = 0.8908130915292852, WM = yh(mh / 10) / yh(7 * mh / 10), Fj = yh(wd / 10) * WM, Bj = -NM(wd / 10) * WM, XM = {
  draw(e, t) {
    const n = me(t * kj), r = Fj * n, i = Bj * n;
    e.moveTo(0, -n), e.lineTo(r, i);
    for (let s = 1; s < 5; ++s) {
      const o = wd * s / 5, a = NM(o), c = yh(o);
      e.lineTo(c * n, -a * n), e.lineTo(a * r - c * i, c * r + a * i);
    }
    e.closePath();
  }
}, zp = me(3), GM = {
  draw(e, t) {
    const n = -me(t / (zp * 3));
    e.moveTo(0, n * 2), e.lineTo(-zp * n, -n), e.lineTo(zp * n, -n), e.closePath();
  }
}, Cj = me(3), HM = {
  draw(e, t) {
    const n = me(t) * 0.6824, r = n / 2, i = n * Cj / 2;
    e.moveTo(0, -n), e.lineTo(i, r), e.lineTo(-i, r), e.closePath();
  }
}, dn = -0.5, pn = me(3) / 2, My = 1 / me(12), Pj = (My / 2 + 1) * 3, JM = {
  draw(e, t) {
    const n = me(t / Pj), r = n / 2, i = n * My, s = r, o = n * My + n, a = -s, c = o;
    e.moveTo(r, i), e.lineTo(s, o), e.lineTo(a, c), e.lineTo(dn * r - pn * i, pn * r + dn * i), e.lineTo(dn * s - pn * o, pn * s + dn * o), e.lineTo(dn * a - pn * c, pn * a + dn * c), e.lineTo(dn * r + pn * i, dn * i - pn * r), e.lineTo(dn * s + pn * o, dn * o - pn * s), e.lineTo(dn * a + pn * c, dn * c - pn * a), e.closePath();
  }
}, ZM = {
  draw(e, t) {
    const n = me(t - cg(t / 6, 1.7)) * 0.6189;
    e.moveTo(-n, -n), e.lineTo(n, n), e.moveTo(-n, n), e.lineTo(n, -n);
  }
}, Uj = [
  jc,
  PM,
  zM,
  VM,
  XM,
  GM,
  JM
], zj = [
  jc,
  jM,
  ZM,
  HM,
  CM,
  YM,
  qM
];
function Pi() {
}
function gh(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 _d(e) {
  this._context = e;
}
_d.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:
        gh(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:
        gh(this, e, t);
        break;
    }
    this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t;
  }
};
function qj(e) {
  return new _d(e);
}
function KM(e) {
  this._context = e;
}
KM.prototype = {
  areaStart: Pi,
  areaEnd: Pi,
  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:
        gh(this, e, t);
        break;
    }
    this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t;
  }
};
function jj(e) {
  return new KM(e);
}
function QM(e) {
  this._context = e;
}
QM.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, r = (this._y0 + 4 * this._y1 + t) / 6;
        this._line ? this._context.lineTo(n, r) : this._context.moveTo(n, r);
        break;
      case 3:
        this._point = 4;
      default:
        gh(this, e, t);
        break;
    }
    this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t;
  }
};
function Vj(e) {
  return new QM(e);
}
function tA(e, t) {
  this._basis = new _d(e), this._beta = t;
}
tA.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 r = e[0], i = t[0], s = e[n] - r, o = t[n] - i, a = -1, c; ++a <= n; )
        c = a / n, this._basis.point(
          this._beta * e[a] + (1 - this._beta) * (r + c * s),
          this._beta * t[a] + (1 - this._beta) * (i + c * o)
        );
    this._x = this._y = null, this._basis.lineEnd();
  },
  point: function(e, t) {
    this._x.push(+e), this._y.push(+t);
  }
};
const Yj = function e(t) {
  function n(r) {
    return t === 1 ? new _d(r) : new tA(r, t);
  }
  return n.beta = function(r) {
    return e(+r);
  }, n;
}(0.85);
function bh(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 lg(e, t) {
  this._context = e, this._k = (1 - t) / 6;
}
lg.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:
        bh(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:
        bh(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 Wj = function e(t) {
  function n(r) {
    return new lg(r, t);
  }
  return n.tension = function(r) {
    return e(+r);
  }, n;
}(0);
function fg(e, t) {
  this._context = e, this._k = (1 - t) / 6;
}
fg.prototype = {
  areaStart: Pi,
  areaEnd: Pi,
  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:
        bh(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 Xj = function e(t) {
  function n(r) {
    return new fg(r, t);
  }
  return n.tension = function(r) {
    return e(+r);
  }, n;
}(0);
function hg(e, t) {
  this._context = e, this._k = (1 - t) / 6;
}
hg.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:
        bh(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 Gj = function e(t) {
  function n(r) {
    return new hg(r, t);
  }
  return n.tension = function(r) {
    return e(+r);
  }, n;
}(0);
function dg(e, t, n) {
  var r = e._x1, i = e._y1, s = e._x2, o = e._y2;
  if (e._l01_a > l2) {
    var a = 2 * e._l01_2a + 3 * e._l01_a * e._l12_a + e._l12_2a, c = 3 * e._l01_a * (e._l01_a + e._l12_a);
    r = (r * a - e._x0 * e._l12_2a + e._x2 * e._l01_2a) / c, i = (i * a - e._y0 * e._l12_2a + e._y2 * e._l01_2a) / c;
  }
  if (e._l23_a > l2) {
    var u = 2 * e._l23_2a + 3 * e._l23_a * e._l12_a + e._l12_2a, l = 3 * e._l23_a * (e._l23_a + e._l12_a);
    s = (s * u + e._x1 * e._l23_2a - t * e._l12_2a) / l, o = (o * u + e._y1 * e._l23_2a - n * e._l12_2a) / l;
  }
  e._context.bezierCurveTo(r, i, s, o, e._x2, e._y2);
}
function eA(e, t) {
  this._context = e, this._alpha = t;
}
eA.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, r = this._y2 - t;
      this._l23_a = Math.sqrt(this._l23_2a = Math.pow(n * n + r * r, 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:
        dg(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(r) {
    return t ? new eA(r, t) : new lg(r, 0);
  }
  return n.alpha = function(r) {
    return e(+r);
  }, n;
}(0.5);
function nA(e, t) {
  this._context = e, this._alpha = t;
}
nA.prototype = {
  areaStart: Pi,
  areaEnd: Pi,
  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, r = this._y2 - t;
      this._l23_a = Math.sqrt(this._l23_2a = Math.pow(n * n + r * r, 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:
        dg(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 Jj = function e(t) {
  function n(r) {
    return t ? new nA(r, t) : new fg(r, 0);
  }
  return n.alpha = function(r) {
    return e(+r);
  }, n;
}(0.5);
function rA(e, t) {
  this._context = e, this._alpha = t;
}
rA.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, r = this._y2 - t;
      this._l23_a = Math.sqrt(this._l23_2a = Math.pow(n * n + r * r, 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:
        dg(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 Zj = function e(t) {
  function n(r) {
    return t ? new rA(r, t) : new hg(r, 0);
  }
  return n.alpha = function(r) {
    return e(+r);
  }, n;
}(0.5);
function iA(e) {
  this._context = e;
}
iA.prototype = {
  areaStart: Pi,
  areaEnd: Pi,
  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 Kj(e) {
  return new iA(e);
}
function f2(e) {
  return e < 0 ? -1 : 1;
}
function h2(e, t, n) {
  var r = e._x1 - e._x0, i = t - e._x1, s = (e._y1 - e._y0) / (r || i < 0 && -0), o = (n - e._y1) / (i || r < 0 && -0), a = (s * i + o * r) / (r + i);
  return (f2(s) + f2(o)) * Math.min(Math.abs(s), Math.abs(o), 0.5 * Math.abs(a)) || 0;
}
function d2(e, t) {
  var n = e._x1 - e._x0;
  return n ? (3 * (e._y1 - e._y0) / n - t) / 2 : t;
}
function qp(e, t, n) {
  var r = e._x0, i = e._y0, s = e._x1, o = e._y1, a = (s - r) / 3;
  e._context.bezierCurveTo(r + a, i + a * t, s - a, o - a * n, s, o);
}
function wh(e) {
  this._context = e;
}
wh.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:
        qp(this, this._t0, d2(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, qp(this, d2(this, n = h2(this, e, t)), n);
          break;
        default:
          qp(this, this._t0, n = h2(this, e, t));
          break;
      }
      this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t, this._t0 = n;
    }
  }
};
function sA(e) {
  this._context = new oA(e);
}
(sA.prototype = Object.create(wh.prototype)).point = function(e, t) {
  wh.prototype.point.call(this, t, e);
};
function oA(e) {
  this._context = e;
}
oA.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, r, i, s) {
    this._context.bezierCurveTo(t, e, r, n, s, i);
  }
};
function Qj(e) {
  return new wh(e);
}
function tV(e) {
  return new sA(e);
}
function aA(e) {
  this._context = e;
}
aA.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 r = p2(e), i = p2(t), s = 0, o = 1; o < n; ++s, ++o)
          this._context.bezierCurveTo(r[0][s], i[0][s], r[1][s], i[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 p2(e) {
  var t, n = e.length - 1, r, i = new Array(n), s = new Array(n), o = new Array(n);
  for (i[0] = 0, s[0] = 2, o[0] = e[0] + 2 * e[1], t = 1; t < n - 1; ++t) i[t] = 1, s[t] = 4, o[t] = 4 * e[t] + 2 * e[t + 1];
  for (i[n - 1] = 2, s[n - 1] = 7, o[n - 1] = 8 * e[n - 1] + e[n], t = 1; t < n; ++t) r = i[t] / s[t - 1], s[t] -= r, o[t] -= r * o[t - 1];
  for (i[n - 1] = o[n - 1] / s[n - 1], t = n - 2; t >= 0; --t) i[t] = (o[t] - i[t + 1]) / s[t];
  for (s[n - 1] = (e[n] + i[n - 1]) / 2, t = 0; t < n - 1; ++t) s[t] = 2 * e[t + 1] - i[t + 1];
  return [i, s];
}
function eV(e) {
  return new aA(e);
}
function vd(e, t) {
  this._context = e, this._t = t;
}
vd.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 nV(e) {
  return new vd(e, 0.5);
}
function rV(e) {
  return new vd(e, 0);
}
function iV(e) {
  return new vd(e, 1);
}
const ll = (e) => () => e;
function sV(e, {
  sourceEvent: t,
  target: n,
  transform: r,
  dispatch: i
}) {
  Object.defineProperties(this, {
    type: { value: e, enumerable: !0, configurable: !0 },
    sourceEvent: { value: t, enumerable: !0, configurable: !0 },
    target: { value: n, enumerable: !0, configurable: !0 },
    transform: { value: r, enumerable: !0, configurable: !0 },
    _: { value: i }
  });
}
function lr(e, t, n) {
  this.k = e, this.x = t, this.y = n;
}
lr.prototype = {
  constructor: lr,
  scale: function(e) {
    return e === 1 ? this : new lr(this.k * e, this.x, this.y);
  },
  translate: function(e, t) {
    return e === 0 & t === 0 ? this : new lr(this.k, this.x + this.k * e, this.y + this.k * t);
  },
  apply: function(e) {
    return [e[0] * this.k + this.x, e[1] * this.k + this.y];
  },
  applyX: function(e) {
    return e * this.k + this.x;
  },
  applyY: function(e) {
    return e * this.k + this.y;
  },
  invert: function(e) {
    return [(e[0] - this.x) / this.k, (e[1] - this.y) / this.k];
  },
  invertX: function(e) {
    return (e - this.x) / this.k;
  },
  invertY: function(e) {
    return (e - this.y) / this.k;
  },
  rescaleX: function(e) {
    return e.copy().domain(e.range().map(this.invertX, this).map(e.invert, e));
  },
  rescaleY: function(e) {
    return e.copy().domain(e.range().map(this.invertY, this).map(e.invert, e));
  },
  toString: function() {
    return "translate(" + this.x + "," + this.y + ") scale(" + this.k + ")";
  }
};
var cA = new lr(1, 0, 0);
lr.prototype;
function jp(e) {
  e.stopImmediatePropagation();
}
function Ca(e) {
  e.preventDefault(), e.stopImmediatePropagation();
}
function oV(e) {
  return (!e.ctrlKey || e.type === "wheel") && !e.button;
}
function aV() {
  var e = this;
  return e instanceof SVGElement ? (e = e.ownerSVGElement || e, e.hasAttribute("viewBox") ? (e = e.viewBox.baseVal, [[e.x, e.y], [e.x + e.width, e.y + e.height]]) : [[0, 0], [e.width.baseVal.value, e.height.baseVal.value]]) : [[0, 0], [e.clientWidth, e.clientHeight]];
}
function y2() {
  return this.__zoom || cA;
}
function cV(e) {
  return -e.deltaY * (e.deltaMode === 1 ? 0.05 : e.deltaMode ? 1 : 2e-3) * (e.ctrlKey ? 10 : 1);
}
function uV() {
  return navigator.maxTouchPoints || "ontouchstart" in this;
}
function lV(e, t, n) {
  var r = e.invertX(t[0][0]) - n[0][0], i = e.invertX(t[1][0]) - n[1][0], s = e.invertY(t[0][1]) - n[0][1], o = e.invertY(t[1][1]) - n[1][1];
  return e.translate(
    i > r ? (r + i) / 2 : Math.min(0, r) || Math.max(0, i),
    o > s ? (s + o) / 2 : Math.min(0, s) || Math.max(0, o)
  );
}
function fV() {
  var e = oV, t = aV, n = lV, r = cV, i = uV, s = [0, 1 / 0], o = [[-1 / 0, -1 / 0], [1 / 0, 1 / 0]], a = 250, c = WB, u = td("start", "zoom", "end"), l, f, h, d = 500, p = 150, y = 0, m = 10;
  function g(S) {
    S.property("__zoom", y2).on("wheel.zoom", E, { passive: !1 }).on("mousedown.zoom", $).on("dblclick.zoom", N).filter(i).on("touchstart.zoom", A).on("touchmove.zoom", D).on("touchend.zoom touchcancel.zoom", k).style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
  }
  g.transform = function(S, I, T, R) {
    var B = S.selection ? S.selection() : S;
    B.property("__zoom", y2), S !== B ? x(S, I, T, R) : B.interrupt().each(function() {
      v(this, arguments).event(R).start().zoom(null, typeof I == "function" ? I.apply(this, arguments) : I).end();
    });
  }, g.scaleBy = function(S, I, T, R) {
    g.scaleTo(S, function() {
      var B = this.__zoom.k, C = typeof I == "function" ? I.apply(this, arguments) : I;
      return B * C;
    }, T, R);
  }, g.scaleTo = function(S, I, T, R) {
    g.transform(S, function() {
      var B = t.apply(this, arguments), C = this.__zoom, F = T == null ? _(B) : typeof T == "function" ? T.apply(this, arguments) : T, P = C.invert(F), U = typeof I == "function" ? I.apply(this, arguments) : I;
      return n(w(b(C, U), F, P), B, o);
    }, T, R);
  }, g.translateBy = function(S, I, T, R) {
    g.transform(S, function() {
      return n(this.__zoom.translate(
        typeof I == "function" ? I.apply(this, arguments) : I,
        typeof T == "function" ? T.apply(this, arguments) : T
      ), t.apply(this, arguments), o);
    }, null, R);
  }, g.translateTo = function(S, I, T, R, B) {
    g.transform(S, function() {
      var C = t.apply(this, arguments), F = this.__zoom, P = R == null ? _(C) : typeof R == "function" ? R.apply(this, arguments) : R;
      return n(cA.translate(P[0], P[1]).scale(F.k).translate(
        typeof I == "function" ? -I.apply(this, arguments) : -I,
        typeof T == "function" ? -T.apply(this, arguments) : -T
      ), C, o);
    }, R, B);
  };
  function b(S, I) {
    return I = Math.max(s[0], Math.min(s[1], I)), I === S.k ? S : new lr(I, S.x, S.y);
  }
  function w(S, I, T) {
    var R = I[0] - T[0] * S.k, B = I[1] - T[1] * S.k;
    return R === S.x && B === S.y ? S : new lr(S.k, R, B);
  }
  function _(S) {
    return [(+S[0][0] + +S[1][0]) / 2, (+S[0][1] + +S[1][1]) / 2];
  }
  function x(S, I, T, R) {
    S.on("start.zoom", function() {
      v(this, arguments).event(R).start();
    }).on("interrupt.zoom end.zoom", function() {
      v(this, arguments).event(R).end();
    }).tween("zoom", function() {
      var B = this, C = arguments, F = v(B, C).event(R), P = t.apply(B, C), U = T == null ? _(P) : typeof T == "function" ? T.apply(B, C) : T, Y = Math.max(P[1][0] - P[0][0], P[1][1] - P[0][1]), G = B.__zoom, K = typeof I == "function" ? I.apply(B, C) : I, H = c(G.invert(U).concat(Y / G.k), K.invert(U).concat(Y / K.k));
      return function(V) {
        if (V === 1) V = K;
        else {
          var W = H(V), q = Y / W[2];
          V = new lr(q, U[0] - W[0] * q, U[1] - W[1] * q);
        }
        F.zoom(null, V);
      };
    });
  }
  function v(S, I, T) {
    return !T && S.__zooming || new M(S, I);
  }
  function M(S, I) {
    this.that = S, this.args = I, this.active = 0, this.sourceEvent = null, this.extent = t.apply(S, I), this.taps = 0;
  }
  M.prototype = {
    event: function(S) {
      return S && (this.sourceEvent = S), this;
    },
    start: function() {
      return ++this.active === 1 && (this.that.__zooming = this, this.emit("start")), this;
    },
    zoom: function(S, I) {
      return this.mouse && S !== "mouse" && (this.mouse[1] = I.invert(this.mouse[0])), this.touch0 && S !== "touch" && (this.touch0[1] = I.invert(this.touch0[0])), this.touch1 && S !== "touch" && (this.touch1[1] = I.invert(this.touch1[0])), this.that.__zoom = I, this.emit("zoom"), this;
    },
    end: function() {
      return --this.active === 0 && (delete this.that.__zooming, this.emit("end")), this;
    },
    emit: function(S) {
      var I = Wt(this.that).datum();
      u.call(
        S,
        this.that,
        new sV(S, {
          sourceEvent: this.sourceEvent,
          target: g,
          type: S,
          transform: this.that.__zoom,
          dispatch: u
        }),
        I
      );
    }
  };
  function E(S, ...I) {
    if (!e.apply(this, arguments)) return;
    var T = v(this, I).event(S), R = this.__zoom, B = Math.max(s[0], Math.min(s[1], R.k * Math.pow(2, r.apply(this, arguments)))), C = Ln(S);
    if (T.wheel)
      (T.mouse[0][0] !== C[0] || T.mouse[0][1] !== C[1]) && (T.mouse[1] = R.invert(T.mouse[0] = C)), clearTimeout(T.wheel);
    else {
      if (R.k === B) return;
      T.mouse = [C, R.invert(C)], Do(this), T.start();
    }
    Ca(S), T.wheel = setTimeout(F, p), T.zoom("mouse", n(w(b(R, B), T.mouse[0], T.mouse[1]), T.extent, o));
    function F() {
      T.wheel = null, T.end();
    }
  }
  function $(S, ...I) {
    if (h || !e.apply(this, arguments)) return;
    var T = S.currentTarget, R = v(this, I, !0).event(S), B = Wt(S.view).on("mousemove.zoom", U, !0).on("mouseup.zoom", Y, !0), C = Ln(S, T), F = S.clientX, P = S.clientY;
    OS(S.view), jp(S), R.mouse = [C, this.__zoom.invert(C)], Do(this), R.start();
    function U(G) {
      if (Ca(G), !R.moved) {
        var K = G.clientX - F, H = G.clientY - P;
        R.moved = K * K + H * H > y;
      }
      R.event(G).zoom("mouse", n(w(R.that.__zoom, R.mouse[0] = Ln(G, T), R.mouse[1]), R.extent, o));
    }
    function Y(G) {
      B.on("mousemove.zoom mouseup.zoom", null), LS(G.view, R.moved), Ca(G), R.event(G).end();
    }
  }
  function N(S, ...I) {
    if (e.apply(this, arguments)) {
      var T = this.__zoom, R = Ln(S.changedTouches ? S.changedTouches[0] : S, this), B = T.invert(R), C = T.k * (S.shiftKey ? 0.5 : 2), F = n(w(b(T, C), R, B), t.apply(this, I), o);
      Ca(S), a > 0 ? Wt(this).transition().duration(a).call(x, F, R, S) : Wt(this).call(g.transform, F, R, S);
    }
  }
  function A(S, ...I) {
    if (e.apply(this, arguments)) {
      var T = S.touches, R = T.length, B = v(this, I, S.changedTouches.length === R).event(S), C, F, P, U;
      for (jp(S), F = 0; F < R; ++F)
        P = T[F], U = Ln(P, this), U = [U, this.__zoom.invert(U), P.identifier], B.touch0 ? !B.touch1 && B.touch0[2] !== U[2] && (B.touch1 = U, B.taps = 0) : (B.touch0 = U, C = !0, B.taps = 1 + !!l);
      l && (l = clearTimeout(l)), C && (B.taps < 2 && (f = U[0], l = setTimeout(function() {
        l = null;
      }, d)), Do(this), B.start());
    }
  }
  function D(S, ...I) {
    if (this.__zooming) {
      var T = v(this, I).event(S), R = S.changedTouches, B = R.length, C, F, P, U;
      for (Ca(S), C = 0; C < B; ++C)
        F = R[C], P = Ln(F, this), T.touch0 && T.touch0[2] === F.identifier ? T.touch0[0] = P : T.touch1 && T.touch1[2] === F.identifier && (T.touch1[0] = P);
      if (F = T.that.__zoom, T.touch1) {
        var Y = T.touch0[0], G = T.touch0[1], K = T.touch1[0], H = T.touch1[1], V = (V = K[0] - Y[0]) * V + (V = K[1] - Y[1]) * V, W = (W = H[0] - G[0]) * W + (W = H[1] - G[1]) * W;
        F = b(F, Math.sqrt(V / W)), P = [(Y[0] + K[0]) / 2, (Y[1] + K[1]) / 2], U = [(G[0] + H[0]) / 2, (G[1] + H[1]) / 2];
      } else if (T.touch0) P = T.touch0[0], U = T.touch0[1];
      else return;
      T.zoom("touch", n(w(F, P, U), T.extent, o));
    }
  }
  function k(S, ...I) {
    if (this.__zooming) {
      var T = v(this, I).event(S), R = S.changedTouches, B = R.length, C, F;
      for (jp(S), h && clearTimeout(h), h = setTimeout(function() {
        h = null;
      }, d), C = 0; C < B; ++C)
        F = R[C], T.touch0 && T.touch0[2] === F.identifier ? delete T.touch0 : T.touch1 && T.touch1[2] === F.identifier && delete T.touch1;
      if (T.touch1 && !T.touch0 && (T.touch0 = T.touch1, delete T.touch1), T.touch0) T.touch0[1] = this.__zoom.invert(T.touch0[0]);
      else if (T.end(), T.taps === 2 && (F = Ln(F, this), Math.hypot(f[0] - F[0], f[1] - F[1]) < m)) {
        var P = Wt(this).on("dblclick.zoom");
        P && P.apply(this, arguments);
      }
    }
  }
  return g.wheelDelta = function(S) {
    return arguments.length ? (r = typeof S == "function" ? S : ll(+S), g) : r;
  }, g.filter = function(S) {
    return arguments.length ? (e = typeof S == "function" ? S : ll(!!S), g) : e;
  }, g.touchable = function(S) {
    return arguments.length ? (i = typeof S == "function" ? S : ll(!!S), g) : i;
  }, g.extent = function(S) {
    return arguments.length ? (t = typeof S == "function" ? S : ll([[+S[0][0], +S[0][1]], [+S[1][0], +S[1][1]]]), g) : t;
  }, g.scaleExtent = function(S) {
    return arguments.length ? (s[0] = +S[0], s[1] = +S[1], g) : [s[0], s[1]];
  }, g.translateExtent = function(S) {
    return arguments.length ? (o[0][0] = +S[0][0], o[1][0] = +S[1][0], o[0][1] = +S[0][1], o[1][1] = +S[1][1], g) : [[o[0][0], o[0][1]], [o[1][0], o[1][1]]];
  }, g.constrain = function(S) {
    return arguments.length ? (n = S, g) : n;
  }, g.duration = function(S) {
    return arguments.length ? (a = +S, g) : a;
  }, g.interpolate = function(S) {
    return arguments.length ? (c = S, g) : c;
  }, g.on = function() {
    var S = u.on.apply(u, arguments);
    return S === u ? g : S;
  }, g.clickDistance = function(S) {
    return arguments.length ? (y = (S = +S) * S, g) : Math.sqrt(y);
  }, g.tapDistance = function(S) {
    return arguments.length ? (m = +S, g) : m;
  }, g;
}
function Pe(e) {
  return e != null && !Number.isNaN(e);
}
function Tn(e, t) {
  return +Pe(t) - +Pe(e) || zt(e, t);
}
function _h(e, t) {
  return +Pe(t) - +Pe(e) || Is(e, t);
}
function pg(e) {
  return e != null && `${e}` != "";
}
function vh(e) {
  return isFinite(e) ? e : NaN;
}
function Qr(e) {
  return e > 0 && isFinite(e) ? e : NaN;
}
function xd(e) {
  return e < 0 && isFinite(e) ? e : NaN;
}
function uA(e, t) {
  if (e instanceof Date || (e = /* @__PURE__ */ new Date(+e)), isNaN(e)) return typeof t == "function" ? t(e) : t;
  const n = e.getUTCHours(), r = e.getUTCMinutes(), i = e.getUTCSeconds(), s = e.getUTCMilliseconds();
  return `${hV(e.getUTCFullYear())}-${zr(e.getUTCMonth() + 1, 2)}-${zr(e.getUTCDate(), 2)}${n || r || i || s ? `T${zr(n, 2)}:${zr(r, 2)}${i || s ? `:${zr(i, 2)}${s ? `.${zr(s, 3)}` : ""}` : ""}Z` : ""}`;
}
function hV(e) {
  return e < 0 ? `-${zr(-e, 6)}` : e > 9999 ? `+${zr(e, 6)}` : zr(e, 4);
}
function zr(e, t) {
  return `${e}`.padStart(t, "0");
}
const dV = /^(?:[-+]\d{2})?\d{4}(?:-\d{2}(?:-\d{2})?)?(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d{3})?)?(?:Z|[-+]\d{2}:?\d{2})?)?$/;
function lA(e, t) {
  return dV.test(e += "") ? new Date(e) : typeof t == "function" ? t(e) : t;
}
function ea(e) {
  if (e == null) return;
  const t = e[0], n = e[e.length - 1];
  return Is(t, n);
}
const bo = 1e3, Ii = bo * 60, Ti = Ii * 60, _r = Ti * 24, nr = _r * 7, ws = _r * 30, mi = _r * 365, Vp = [
  ["millisecond", 1],
  ["2 milliseconds", 2],
  ["5 milliseconds", 5],
  ["10 milliseconds", 10],
  ["20 milliseconds", 20],
  ["50 milliseconds", 50],
  ["100 milliseconds", 100],
  ["200 milliseconds", 200],
  ["500 milliseconds", 500],
  ["second", bo],
  ["5 seconds", 5 * bo],
  ["15 seconds", 15 * bo],
  ["30 seconds", 30 * bo],
  ["minute", Ii],
  ["5 minutes", 5 * Ii],
  ["15 minutes", 15 * Ii],
  ["30 minutes", 30 * Ii],
  ["hour", Ti],
  ["3 hours", 3 * Ti],
  ["6 hours", 6 * Ti],
  ["12 hours", 12 * Ti],
  ["day", _r],
  ["2 days", 2 * _r],
  ["week", nr],
  ["2 weeks", 2 * nr],
  // https://github.com/d3/d3-time/issues/46
  ["month", ws],
  ["3 months", 3 * ws],
  ["6 months", 6 * ws],
  // https://github.com/d3/d3-time/issues/46
  ["year", mi],
  ["2 years", 2 * mi],
  ["5 years", 5 * mi],
  ["10 years", 10 * mi],
  ["20 years", 20 * mi],
  ["50 years", 50 * mi],
  ["100 years", 100 * mi]
  // TODO generalize to longer time scales
], yg = /* @__PURE__ */ new Map([
  ["second", bo],
  ["minute", Ii],
  ["hour", Ti],
  ["day", _r],
  ["monday", nr],
  ["tuesday", nr],
  ["wednesday", nr],
  ["thursday", nr],
  ["friday", nr],
  ["saturday", nr],
  ["sunday", nr],
  ["week", nr],
  ["month", ws],
  ["year", mi]
]), fA = /* @__PURE__ */ new Map([
  ["second", Cn],
  ["minute", wu],
  ["hour", vu],
  ["day", Cs],
  // https://github.com/d3/d3-time/issues/62
  ["monday", zc],
  ["tuesday", s6],
  ["wednesday", o6],
  ["thursday", Rs],
  ["friday", a6],
  ["saturday", c6],
  ["sunday", Qo],
  ["week", Qo],
  ["month", Su],
  ["year", Yn]
]), mg = /* @__PURE__ */ new Map([
  ["second", Cn],
  ["minute", _u],
  ["hour", xu],
  ["day", yd],
  ["monday", qc],
  ["tuesday", u6],
  ["wednesday", l6],
  ["thursday", ks],
  ["friday", f6],
  ["saturday", h6],
  ["sunday", ta],
  ["week", ta],
  ["month", Mu],
  ["year", Wn]
]), Iu = Symbol("intervalDuration"), Sd = Symbol("intervalType");
for (const [e, t] of fA)
  t[Iu] = yg.get(e), t[Sd] = "time";
for (const [e, t] of mg)
  t[Iu] = yg.get(e), t[Sd] = "utc";
const ac = [
  ["year", Wn, "utc"],
  ["month", Mu, "utc"],
  ["day", yd, "utc", 6 * ws],
  ["hour", xu, "utc", 3 * _r],
  ["minute", _u, "utc", 6 * Ti],
  ["second", Cn, "utc", 30 * Ii]
], Gl = [
  ["year", Yn, "time"],
  ["month", Su, "time"],
  ["day", Cs, "time", 6 * ws],
  ["hour", vu, "time", 3 * _r],
  ["minute", wu, "time", 6 * Ti],
  ["second", Cn, "time", 30 * Ii]
], pV = [
  ac[0],
  Gl[0],
  ac[1],
  Gl[1],
  ac[2],
  Gl[2],
  // Below day, local time typically has an hourly offset from UTC and hence the
  // two are aligned and indistinguishable; therefore, we only consider UTC, and
  // we don’t consider these if the domain only has a single value.
  ...ac.slice(3)
];
function gg(e) {
  let t = `${e}`.toLowerCase();
  t.endsWith("s") && (t = t.slice(0, -1));
  let n = 1;
  const r = /^(?:(\d+)\s+)/.exec(t);
  switch (r && (t = t.slice(r[0].length), n = +r[1]), t) {
    case "quarter":
      t = "month", n *= 3;
      break;
    case "half":
      t = "month", n *= 6;
      break;
  }
  let i = mg.get(t);
  if (!i) throw new Error(`unknown interval: ${e}`);
  if (n > 1 && !i.every) throw new Error(`non-periodic interval: ${t}`);
  return [t, n];
}
function bg(e) {
  return hA(gg(e), "time");
}
function Md(e) {
  return hA(gg(e), "utc");
}
function hA([e, t], n) {
  let r = (n === "time" ? fA : mg).get(e);
  return t > 1 && (r = r.every(t), r[Iu] = yg.get(e) * t, r[Sd] = n), r;
}
function m2(e, t) {
  if (!(t > 1)) return;
  const n = e[Iu];
  if (!Vp.some(([, i]) => i === n) || n % _r === 0 && _r < n && n < ws) return;
  const [r] = Vp[lu(([, i]) => Math.log(i)).center(Vp, Math.log(n * t))];
  return (e[Sd] === "time" ? bg : Md)(r);
}
function g2(e, t, n) {
  const r = t === "time" ? og : Au;
  if (n == null)
    return r(
      e === "year" ? "%Y" : e === "month" ? "%Y-%m" : e === "day" ? "%Y-%m-%d" : e === "hour" || e === "minute" ? "%Y-%m-%dT%H:%M" : e === "second" ? "%Y-%m-%dT%H:%M:%S" : "%Y-%m-%dT%H:%M:%S.%L"
    );
  const i = yV(n);
  switch (e) {
    case "millisecond":
      return Qs(r(".%L"), r(":%M:%S"), i);
    case "second":
      return Qs(r(":%S"), r("%-I:%M"), i);
    case "minute":
      return Qs(r("%-I:%M"), r("%p"), i);
    case "hour":
      return Qs(r("%-I %p"), r("%b %-d"), i);
    case "day":
      return Qs(r("%-d"), r("%b"), i);
    case "month":
      return Qs(r("%b"), r("%Y"), i);
    case "year":
      return r("%Y");
  }
  throw new Error("unable to format time ticks");
}
function yV(e) {
  return e === "left" || e === "right" ? (t, n) => `
${t}
${n}` : e === "top" ? (t, n) => `${n}
${t}` : (t, n) => `${t}
${n}`;
}
function mV(e) {
  return e === "time" ? Gl : e === "utc" ? ac : pV;
}
function gV(e, t, n) {
  const r = ce(_k(t, (i, s) => Math.abs(s - i)));
  if (r < 1e3) return g2("millisecond", "utc", n);
  for (const [i, s, o, a] of mV(e)) {
    if (r > a || i === "hour" && !r) break;
    if (t.every((c) => s.floor(c) >= c)) return g2(i, o, n);
  }
}
function Qs(e, t, n) {
  return (r, i, s) => {
    const o = e(r, i), a = t(r, i), c = i - ea(s);
    return i !== c && s[c] !== void 0 && a === t(s[c], c) ? o : n(o, a);
  };
}
const na = Object.getPrototypeOf(Uint8Array), bV = Object.prototype.toString, dA = Symbol("reindex");
function $t(e, t, n) {
  const r = typeof t;
  return r === "string" ? b2(e, pA(t), n) : r === "function" ? b2(e, t, n) : r === "number" || t instanceof Date || r === "boolean" ? Zt(e, fn(t), n) : typeof (t == null ? void 0 : t.transform) == "function" ? w2(t.transform(e), n) : wV(w2(t, n), e == null ? void 0 : e[dA]);
}
function wV(e, t) {
  return e != null && t ? Id(e, t) : e;
}
function b2(e, t, n) {
  return Zt(e, (n == null ? void 0 : n.prototype) instanceof na ? _V(t) : t, n);
}
function w2(e, t) {
  return t === void 0 ? Qe(e) : e instanceof t ? e : t.prototype instanceof na && !(e instanceof na) ? t.from(e, vg) : t.from(e);
}
function _V(e) {
  return (t, n) => vg(e(t, n));
}
const gc = [null], pA = (e) => (t) => t[e], Ve = { transform: ui }, yt = { transform: (e) => e }, wg = () => 1, vV = () => !0, Ne = (e) => e == null ? e : `${e}`, Nt = (e) => e == null ? e : +e, Ad = (e) => e ? e[0] : void 0, Vc = (e) => e ? e[1] : void 0, xV = (e) => e ? e[2] : void 0, fn = (e) => () => e;
function _g(e) {
  const t = +`${e}`.slice(1) / 100;
  return (n, r) => Bi(n, t, r);
}
function He(e) {
  return e instanceof na ? e : Zt(e, vg, Float64Array);
}
function vg(e) {
  return e == null ? NaN : Number(e);
}
function SV(e) {
  return Zt(e, yA);
}
function yA(e) {
  return e instanceof Date && !isNaN(e) ? e : typeof e == "string" ? lA(e) : e == null || isNaN(e = +e) ? void 0 : new Date(e);
}
function ze(e, t) {
  return e === void 0 && (e = t), e === null ? [void 0, "none"] : Tu(e) ? [void 0, e] : [e, void 0];
}
function fe(e, t) {
  return e === void 0 && (e = t), e === null || typeof e == "number" ? [void 0, e] : [e, void 0];
}
function mA(e, t, n) {
  if (e != null) return hn(e, t, n);
}
function hn(e, t, n) {
  const r = `${e}`.toLowerCase();
  if (!n.includes(r)) throw new Error(`invalid ${t}: ${e}`);
  return r;
}
function Qe(e) {
  return e == null || e instanceof Array || e instanceof na ? e : Array.from(e);
}
function Zt(e, t, n = Array) {
  return e == null ? e : e instanceof n ? e.map(t) : n.from(e, t);
}
function Yc(e, t = Array) {
  return e instanceof t ? e.slice() : t.from(e);
}
function gA({ x: e, x1: t, x2: n }) {
  return e !== void 0 || t !== void 0 || n !== void 0;
}
function bA({ y: e, y1: t, y2: n }) {
  return e !== void 0 || t !== void 0 || n !== void 0;
}
function $d(e) {
  return gA(e) || bA(e) || e.interval !== void 0;
}
function Nn(e) {
  return (e == null ? void 0 : e.toString) === bV;
}
function _s(e) {
  return Nn(e) && (e.type !== void 0 || e.domain !== void 0);
}
function rr(e) {
  return Nn(e) && typeof e.transform != "function";
}
function Ui(e) {
  return rr(e) && e.value === void 0 && e.channel === void 0;
}
function wA(e, t, n, r = yt) {
  return t === void 0 && n === void 0 ? (t = 0, n = e === void 0 ? r : e) : t === void 0 ? t = e === void 0 ? 0 : e : n === void 0 && (n = e === void 0 ? 0 : e), [t, n];
}
function Jn(e, t) {
  return e === void 0 && t === void 0 ? [Ad, Vc] : [e, t];
}
function Zi({ z: e, fill: t, stroke: n } = {}) {
  return e === void 0 && ([e] = ze(t)), e === void 0 && ([e] = ze(n)), e;
}
function ui(e) {
  const t = e.length, n = new Uint32Array(t);
  for (let r = 0; r < t; ++r) n[r] = r;
  return n;
}
function Id(e, t) {
  return Zt(t, (n) => e[n], e.constructor);
}
function xg(e) {
  return e.length === 1 ? (t, n) => e(Id(n, t)) : e;
}
function vs(e, t, n) {
  return e.subarray ? e.subarray(t, n) : e.slice(t, n);
}
function ds(e) {
  return e !== null && typeof e == "object" ? e.valueOf() : e;
}
function _A(e, t) {
  if (t[e] !== void 0) return t[e];
  switch (e) {
    case "x1":
    case "x2":
      e = "x";
      break;
    case "y1":
    case "y2":
      e = "y";
      break;
  }
  return t[e];
}
function an(e) {
  let t;
  return [
    {
      transform: () => t,
      label: Mr(e)
    },
    (n) => t = n
  ];
}
function We(e) {
  return e == null ? [e] : an(e);
}
function Mr(e, t) {
  return typeof e == "string" ? e : e && e.label !== void 0 ? e.label : t;
}
function xh(e, t) {
  return {
    transform(n) {
      const r = e.transform(n), i = t.transform(n);
      return qe(r) || qe(i) ? Zt(r, (s, o) => new Date((+r[o] + +i[o]) / 2)) : Zt(r, (s, o) => (+r[o] + +i[o]) / 2, Float64Array);
    },
    label: e.label
  };
}
function Sh(e, t) {
  const n = vA(t == null ? void 0 : t.interval, t == null ? void 0 : t.type);
  return n ? Zt(e, n) : e;
}
function vA(e, t) {
  const n = Td(e, t);
  return n && ((r) => Pe(r) ? n.floor(r) : r);
}
function Td(e, t) {
  if (e != null) {
    if (typeof e == "number") return xA(e);
    if (typeof e == "string") return (t === "time" ? bg : Md)(e);
    if (typeof e.floor != "function") throw new Error("invalid interval; missing floor method");
    if (typeof e.offset != "function") throw new Error("invalid interval; missing offset method");
    return e;
  }
}
function xA(e) {
  e = +e, 0 < e && e < 1 && Number.isInteger(1 / e) && (e = -1 / e);
  const t = Math.abs(e);
  return e < 0 ? {
    floor: (n) => Math.floor(n * t) / t,
    offset: (n, r = 1) => (n * t + Math.floor(r)) / t,
    range: (n, r) => sn(Math.ceil(n * t), r * t).map((i) => i / t)
  } : {
    floor: (n) => Math.floor(n / t) * t,
    offset: (n, r = 1) => n + t * Math.floor(r),
    range: (n, r) => sn(Math.ceil(n / t), r / t).map((i) => i * t)
  };
}
function wa(e, t) {
  if (e = Td(e, t), e && typeof e.range != "function") throw new Error("invalid interval: missing range method");
  return e;
}
function MV(e, t) {
  if (e = wa(e, t), e && typeof e.ceil != "function") throw new Error("invalid interval: missing ceil method");
  return e;
}
function AV(e) {
  return wo(e) && typeof (e == null ? void 0 : e.floor) == "function" && e.floor() instanceof Date;
}
function wo(e) {
  return typeof (e == null ? void 0 : e.range) == "function";
}
function _a(e) {
  return e === void 0 || rr(e) ? e : { value: e };
}
function $V(e) {
  return e == null ? null : {
    transform: (t) => $t(t, e, Float64Array),
    label: Mr(e)
  };
}
function IV(e) {
  if (!li(e)) return !1;
  for (const t of e)
    if (t != null)
      return typeof t == "object" && "0" in t && "1" in t;
}
function li(e) {
  return e && typeof e[Symbol.iterator] == "function";
}
function SA(e) {
  for (const t of e)
    if (t != null)
      return typeof t != "object" || t instanceof Date;
}
function se(e) {
  for (const t of e) {
    if (t == null) continue;
    const n = typeof t;
    return n === "string" || n === "boolean";
  }
}
function qe(e) {
  for (const t of e)
    if (t != null)
      return t instanceof Date;
}
function TV(e) {
  for (const t of e)
    if (t != null)
      return typeof t == "string" && isNaN(t) && lA(t);
}
function EV(e) {
  for (const t of e)
    if (t != null) {
      if (typeof t != "string") return !1;
      if (t.trim())
        return !isNaN(t);
    }
}
function _o(e) {
  for (const t of e)
    if (t != null)
      return typeof t == "number";
}
function Yp(e, t) {
  let n;
  for (const r of e)
    if (r != null) {
      if (!t(r)) return !1;
      n = !0;
    }
  return n;
}
const NV = new Set("none,currentcolor,transparent,aliceblue,antiquewhite,aqua,aquamarine,azure,beige,bisque,black,blanchedalmond,blue,blueviolet,brown,burlywood,cadetblue,chartreuse,chocolate,coral,cornflowerblue,cornsilk,crimson,cyan,darkblue,darkcyan,darkgoldenrod,darkgray,darkgreen,darkgrey,darkkhaki,darkmagenta,darkolivegreen,darkorange,darkorchid,darkred,darksalmon,darkseagreen,darkslateblue,darkslategray,darkslategrey,darkturquoise,darkviolet,deeppink,deepskyblue,dimgray,dimgrey,dodgerblue,firebrick,floralwhite,forestgreen,fuchsia,gainsboro,ghostwhite,gold,goldenrod,gray,green,greenyellow,grey,honeydew,hotpink,indianred,indigo,ivory,khaki,lavender,lavenderblush,lawngreen,lemonchiffon,lightblue,lightcoral,lightcyan,lightgoldenrodyellow,lightgray,lightgreen,lightgrey,lightpink,lightsalmon,lightseagreen,lightskyblue,lightslategray,lightslategrey,lightsteelblue,lightyellow,lime,limegreen,linen,magenta,maroon,mediumaquamarine,mediumblue,mediumorchid,mediumpurple,mediumseagreen,mediumslateblue,mediumspringgreen,mediumturquoise,mediumvioletred,midnightblue,mintcream,mistyrose,moccasin,navajowhite,navy,oldlace,olive,olivedrab,orange,orangered,orchid,palegoldenrod,palegreen,paleturquoise,palevioletred,papayawhip,peachpuff,peru,pink,plum,powderblue,purple,rebeccapurple,red,rosybrown,royalblue,saddlebrown,salmon,sandybrown,seagreen,seashell,sienna,silver,skyblue,slateblue,slategray,slategrey,snow,springgreen,steelblue,tan,teal,thistle,tomato,turquoise,violet,wheat,white,whitesmoke,yellow".split(","));
function Tu(e) {
  return typeof e != "string" ? !1 : (e = e.toLowerCase().trim(), /^#[0-9a-f]{3,8}$/.test(e) || // hex rgb, rgba, rrggbb, rrggbbaa
  /^(?:url|var|rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color|color-mix)\(.*\)$/.test(e) || // <funciri>, CSS variable, color, etc.
  NV.has(e));
}
function DV(e) {
  return typeof e == "number" && (0 <= e && e <= 1 || isNaN(e));
}
function ee(e) {
  return e == null || ra(e);
}
function ra(e) {
  return /^\s*none\s*$/i.test(e);
}
function OV(e) {
  return /^\s*round\s*$/i.test(e);
}
function Ay(e, t) {
  return mA(e, t, [
    "middle",
    "top-left",
    "top",
    "top-right",
    "right",
    "bottom-right",
    "bottom",
    "bottom-left",
    "left"
  ]);
}
function Eu(e = "middle") {
  return Ay(e, "frameAnchor");
}
function LV(e = {}, ...t) {
  let n = e;
  for (const r of t)
    for (const i in r)
      if (n[i] === void 0) {
        const s = r[i];
        n === e ? n = { ...n, [i]: s } : n[i] = s;
      }
  return n;
}
function RV(e) {
  console.warn("named iterables are deprecated; please use an object instead");
  const t = /* @__PURE__ */ new Set();
  return Object.fromEntries(
    Array.from(e, (n) => {
      const { name: r } = n;
      if (r == null) throw new Error("missing name");
      const i = `${r}`;
      if (i === "__proto__") throw new Error(`illegal name: ${i}`);
      if (t.has(i)) throw new Error(`duplicate name: ${i}`);
      return t.add(i), [r, n];
    })
  );
}
function Sg(e) {
  return li(e) ? RV(e) : e;
}
function MA(e) {
  return e === !0 ? e = "frame" : e === !1 ? e = null : e != null && (e = hn(e, "clip", ["frame", "sphere"])), e;
}
const fr = Symbol("position"), fi = Symbol("color"), Nu = Symbol("radius"), Du = Symbol("length"), Ou = Symbol("opacity"), Ed = Symbol("symbol"), AA = Symbol("projection"), ie = /* @__PURE__ */ new Map([
  ["x", fr],
  ["y", fr],
  ["fx", fr],
  ["fy", fr],
  ["r", Nu],
  ["color", fi],
  ["opacity", Ou],
  ["symbol", Ed],
  ["length", Du],
  ["projection", AA]
]);
function kV(e) {
  return e === fr || e === AA;
}
function FV(e) {
  return e === fr || e === Nu || e === Du || e === Ou;
}
const $A = Math.sqrt(3), IA = 2 / $A, BV = {
  draw(e, t) {
    const n = Math.sqrt(t / Math.PI), r = n * IA, i = r / 2;
    e.moveTo(0, r), e.lineTo(n, i), e.lineTo(n, -i), e.lineTo(0, -r), e.lineTo(-n, -i), e.lineTo(-n, i), e.closePath();
  }
}, Mg = /* @__PURE__ */ new Map([
  ["asterisk", CM],
  ["circle", jc],
  ["cross", PM],
  ["diamond", zM],
  ["diamond2", qM],
  ["hexagon", BV],
  ["plus", jM],
  ["square", VM],
  ["square2", YM],
  ["star", XM],
  ["times", ZM],
  ["triangle", GM],
  ["triangle2", HM],
  ["wye", JM]
]);
function Ag(e) {
  return e && typeof e.draw == "function";
}
function CV(e) {
  return Ag(e) ? !0 : typeof e != "string" ? !1 : Mg.has(e.toLowerCase());
}
function $g(e) {
  if (e == null || Ag(e)) return e;
  const t = Mg.get(`${e}`.toLowerCase());
  if (t) return t;
  throw new Error(`invalid symbol: ${e}`);
}
function PV(e) {
  if (e == null || Ag(e)) return [void 0, e];
  if (typeof e == "string") {
    const t = Mg.get(`${e}`.toLowerCase());
    if (t) return [void 0, t];
  }
  return [e, void 0];
}
function Ar({ filter: e, sort: t, reverse: n, transform: r, initializer: i, ...s } = {}, o) {
  if (r === void 0 && (e != null && (r = Ig(e)), t != null && !Ui(t) && (r = Wp(r, Eg(t))), n && (r = Wp(r, Tg))), o != null && i != null) throw new Error("transforms cannot be applied after initializers");
  return {
    ...s,
    ...(t === null || Ui(t)) && { sort: t },
    transform: Wp(r, o)
  };
}
function tn({ filter: e, sort: t, reverse: n, initializer: r, ...i } = {}, s) {
  return r === void 0 && (e != null && (r = Ig(e)), t != null && !Ui(t) && (r = Xp(r, Eg(t))), n && (r = Xp(r, Tg))), {
    ...i,
    ...(t === null || Ui(t)) && { sort: t },
    initializer: Xp(r, s)
  };
}
function Wp(e, t) {
  return e == null ? t === null ? void 0 : t : t == null ? e === null ? void 0 : e : function(n, r, i) {
    return { data: n, facets: r } = e.call(this, n, r, i), t.call(this, Qe(n), r, i);
  };
}
function Xp(e, t) {
  return e == null ? t === null ? void 0 : t : t == null ? e === null ? void 0 : e : function(n, r, i, ...s) {
    let o, a, c, u, l, f;
    return { data: a = n, facets: c = r, channels: o } = e.call(this, n, r, i, ...s), { data: l = a, facets: f = c, channels: u } = t.call(this, a, c, { ...i, ...o }, ...s), { data: l, facets: f, channels: { ...o, ...u } };
  };
}
function Nd(e, t) {
  return (e.initializer != null ? tn : Ar)(e, t);
}
function UV(e, t) {
  return Nd(t, Ig(e));
}
function Ig(e) {
  return (t, n) => {
    const r = $t(t, e);
    return { data: t, facets: n.map((i) => i.filter((s) => r[s])) };
  };
}
function zV({ sort: e, ...t } = {}) {
  return {
    ...Nd(t, Tg),
    sort: Ui(e) ? e : null
  };
}
function Tg(e, t) {
  return { data: e, facets: t.map((n) => n.slice().reverse()) };
}
function qV({ seed: e, sort: t, ...n } = {}) {
  return {
    ...Nd(n, EA(e == null ? Math.random : rg(e))),
    sort: Ui(t) ? t : null
  };
}
function TA(e, { sort: t, ...n } = {}) {
  return {
    ...(rr(e) && e.channel !== void 0 ? tn : Nd)(n, Eg(e)),
    sort: Ui(t) ? t : null
  };
}
function Eg(e) {
  return (typeof e == "function" && e.length !== 1 ? jV : EA)(e);
}
function jV(e) {
  return (t, n) => {
    const r = (i, s) => e(t[i], t[s]);
    return { data: t, facets: n.map((i) => i.slice().sort(r)) };
  };
}
function EA(e) {
  let t, n;
  ({ channel: t, value: e, order: n } = { ..._a(e) });
  const r = t == null ? void 0 : t.startsWith("-");
  if (r && (t = t.slice(1)), n === void 0 && (n = r ? _h : Tn), typeof n != "function")
    switch (`${n}`.toLowerCase()) {
      case "ascending":
        n = Tn;
        break;
      case "descending":
        n = _h;
        break;
      default:
        throw new Error(`invalid order: ${n}`);
    }
  return (i, s, o) => {
    let a;
    if (t === void 0)
      a = $t(i, e);
    else {
      if (o === void 0) throw new Error("channel sort requires an initializer");
      if (a = o[t], !a) return {};
      a = a.value;
    }
    const c = (u, l) => n(a[u], a[l]);
    return { data: i, facets: s.map((u) => u.slice().sort(c)) };
  };
}
function Ng(e, t) {
  return Dd(null, null, e, t);
}
function Wc(e = { y: "count" }, t = {}) {
  const { x: n = yt } = t;
  if (n == null) throw new Error("missing channel: x");
  return Dd(n, null, e, t);
}
function Xc(e = { x: "count" }, t = {}) {
  const { y: n = yt } = t;
  if (n == null) throw new Error("missing channel: y");
  return Dd(null, n, e, t);
}
function Dg(e = { fill: "count" }, t = {}) {
  let { x: n, y: r } = t;
  if ([n, r] = Jn(n, r), n == null) throw new Error("missing channel: x");
  if (r == null) throw new Error("missing channel: y");
  return Dd(n, r, e, t);
}
function Dd(e, t, {
  data: n = kg,
  filter: r,
  sort: i,
  reverse: s,
  ...o
  // output channel definitions
} = {}, a = {}) {
  o = DA(o, a), n = RA(n, yt), i = i == null ? void 0 : OA("sort", i, a), r = r == null ? void 0 : LA("filter", r, a);
  const [c, u] = We(e), [l, f] = We(t), {
    z: h,
    fill: d,
    stroke: p,
    x1: y,
    x2: m,
    // consumed if x is an output
    y1: g,
    y2: b,
    // consumed if y is an output
    ...w
  } = a, [_, x] = We(h), [v] = ze(d), [M] = ze(p), [E, $] = We(v), [N, A] = We(M);
  return {
    ..."z" in a && { z: _ || h },
    ..."fill" in a && { fill: E || d },
    ..."stroke" in a && { stroke: N || p },
    ...Ar(w, (D, k, S) => {
      const I = Sh($t(D, e), S == null ? void 0 : S.x), T = Sh($t(D, t), S == null ? void 0 : S.y), R = $t(D, h), B = $t(D, v), C = $t(D, M), F = Rg(o, { z: R, fill: B, stroke: C }), P = [], U = [], Y = I && u([]), G = T && f([]), K = R && x([]), H = B && $([]), V = C && A([]);
      let W = 0;
      for (const q of o) q.initialize(D);
      i && i.initialize(D), r && r.initialize(D);
      for (const q of k) {
        const X = [];
        for (const Z of o) Z.scope("facet", q);
        i && i.scope("facet", q), r && r.scope("facet", q);
        for (const [Z, z] of Oo(q, F))
          for (const [wt, tt] of Oo(z, T))
            for (const [It, Et] of Oo(tt, I)) {
              const J = { data: D };
              if (I && (J.x = It), T && (J.y = wt), F && (J.z = Z), !(r && !r.reduce(Et, J))) {
                X.push(W++), U.push(n.reduceIndex(Et, D, J)), I && Y.push(It), T && G.push(wt), R && K.push(F === R ? Z : R[Et[0]]), B && H.push(F === B ? Z : B[Et[0]]), C && V.push(F === C ? Z : C[Et[0]]);
                for (const Ct of o) Ct.reduce(Et, J);
                i && i.reduce(Et, J);
              }
            }
        P.push(X);
      }
      return kA(P, i, s), { data: U, facets: P };
    }),
    ...!Ei(o, "x") && (c ? { x: c } : { x1: y, x2: m }),
    ...!Ei(o, "y") && (l ? { y: l } : { y1: g, y2: b }),
    ...Object.fromEntries(o.map(({ name: D, output: k }) => [D, k]))
  };
}
function Ei(e, ...t) {
  for (const { name: n } of e)
    if (t.includes(n))
      return !0;
  return !1;
}
function NA(e, t, n = Og) {
  const r = Object.entries(e);
  return t.title != null && e.title === void 0 && r.push(["title", HV]), t.href != null && e.href === void 0 && r.push(["href", Fg]), r.filter(([, i]) => i !== void 0).map(([i, s]) => s === null ? VV(i) : n(i, s, t));
}
function Og(e, t, n, r = Lg) {
  let i;
  Nn(t) && "reduce" in t && (i = t.scale, t = t.reduce);
  const s = r(e, t, n), [o, a] = an(s.label);
  let c;
  return {
    name: e,
    output: i === void 0 ? o : { value: o, scale: i },
    initialize(u) {
      s.initialize(u), c = a([]);
    },
    scope(u, l) {
      s.scope(u, l);
    },
    reduce(u, l) {
      c.push(s.reduce(u, l));
    }
  };
}
function VV(e) {
  return { name: e, initialize() {
  }, scope() {
  }, reduce() {
  } };
}
function Lg(e, t, n, r = Od) {
  const i = _A(e, n), s = r(t, i);
  let o, a;
  return {
    label: Mr(s === Mh ? null : i, s.label),
    initialize(c) {
      o = i === void 0 ? c : $t(c, i), s.scope === "data" && (a = s.reduceIndex(ui(c), o));
    },
    scope(c, u) {
      s.scope === c && (a = s.reduceIndex(u, o));
    },
    reduce(c, u) {
      return s.scope == null ? s.reduceIndex(c, o, u) : s.reduceIndex(c, o, a, u);
    }
  };
}
function Oo(e, t) {
  return t ? ci(e, (n) => t[n]) : [[, e]];
}
function Od(e, t, n = YV) {
  if (e == null) return n(e);
  if (typeof e.reduceIndex == "function") return e;
  if (typeof e.reduce == "function" && Nn(e)) return XV(e);
  if (typeof e == "function") return GV(e);
  if (/^p\d{2}$/i.test(e)) return Br(_g(e));
  switch (`${e}`.toLowerCase()) {
    case "first":
      return Fg;
    case "last":
      return JV;
    case "identity":
      return kg;
    case "count":
      return Mh;
    case "distinct":
      return ZV;
    case "sum":
      return t == null ? Mh : KV;
    case "proportion":
      return v2(t, "data");
    case "proportion-facet":
      return v2(t, "facet");
    case "deviation":
      return Br(fu);
    case "min":
      return Br(ve);
    case "min-index":
      return Br(mk);
    case "max":
      return Br(ce);
    case "max-index":
      return Br(yk);
    case "mean":
      return _2(Qh);
    case "median":
      return _2(Lc);
    case "variance":
      return Br(Lm);
    case "mode":
      return Br(wS);
  }
  return n(e);
}
function YV(e) {
  throw new Error(`invalid reduce: ${e}`);
}
function DA(e, t) {
  return NA(e, t, OA);
}
function OA(e, t, n) {
  return Og(e, t, n, LA);
}
function LA(e, t, n) {
  return Lg(e, t, n, RA);
}
function RA(e, t) {
  return Od(e, t, WV);
}
function WV(e) {
  switch (`${e}`.toLowerCase()) {
    case "x":
      return QV;
    case "y":
      return tY;
    case "z":
      return FA;
  }
  throw new Error(`invalid group reduce: ${e}`);
}
function Rg(e, t) {
  for (const n in t) {
    const r = t[n];
    if (r !== void 0 && !e.some((i) => i.name === n))
      return r;
  }
}
function kA(e, t, n) {
  if (t) {
    const r = t.output.transform(), i = (s, o) => Tn(r[s], r[o]);
    e.forEach((s) => s.sort(i));
  }
  n && e.forEach((r) => r.reverse());
}
function XV(e) {
  return console.warn("deprecated reduce interface; implement reduceIndex instead."), { ...e, reduceIndex: e.reduce.bind(e) };
}
function GV(e) {
  return {
    reduceIndex(t, n, r) {
      return e(Id(n, t), r);
    }
  };
}
function Br(e) {
  return {
    reduceIndex(t, n) {
      return e(t, (r) => n[r]);
    }
  };
}
function _2(e) {
  return {
    reduceIndex(t, n) {
      const r = e(t, (i) => n[i]);
      return qe(n) ? new Date(r) : r;
    }
  };
}
const kg = {
  reduceIndex(e, t) {
    return Id(t, e);
  }
}, Fg = {
  reduceIndex(e, t) {
    return t[e[0]];
  }
}, HV = {
  reduceIndex(e, t) {
    const r = Of(
      To(
        e,
        (s) => s.length,
        (s) => t[s]
      ),
      Vc
    ), i = r.slice(-5).reverse();
    if (i.length < r.length) {
      const s = r.slice(0, -4);
      i[4] = [`… ${s.length.toLocaleString("en-US")} more`, br(s, Vc)];
    }
    return i.map(([s, o]) => `${s} (${o.toLocaleString("en-US")})`).join(`
`);
  }
}, JV = {
  reduceIndex(e, t) {
    return t[e[e.length - 1]];
  }
}, Mh = {
  label: "Frequency",
  reduceIndex(e) {
    return e.length;
  }
}, ZV = {
  label: "Distinct",
  reduceIndex(e, t) {
    const n = new pa();
    for (const r of e) n.add(t[r]);
    return n.size;
  }
}, KV = Br(br);
function v2(e, t) {
  return e == null ? { scope: t, label: "Frequency", reduceIndex: (n, r, i = 1) => n.length / i } : { scope: t, reduceIndex: (n, r, i = 1) => br(n, (s) => r[s]) / i };
}
const QV = {
  reduceIndex(e, t, { x: n }) {
    return n;
  }
}, tY = {
  reduceIndex(e, t, { y: n }) {
    return n;
  }
}, FA = {
  reduceIndex(e, t, { z: n }) {
    return n;
  }
};
function eY(e) {
  if (typeof e != "function") throw new Error(`invalid test function: ${e}`);
  return {
    reduceIndex(t, n, { data: r }) {
      return n[t.find((i) => e(r[i], i, r))];
    }
  };
}
function Gc(e, { scale: t, type: n, value: r, filter: i, hint: s, label: o = Mr(r) }, a) {
  return s === void 0 && typeof (r == null ? void 0 : r.transform) == "function" && (s = r.hint), CA(a, {
    scale: t,
    type: n,
    value: $t(e, r),
    label: o,
    filter: i,
    hint: s
  });
}
function BA(e, t) {
  return Object.fromEntries(
    Object.entries(e).map(([n, r]) => [n, Gc(t, r, n)])
  );
}
function Bg(e, t) {
  const n = Object.fromEntries(
    Object.entries(e).map(([r, { scale: i, value: s }]) => {
      const o = i == null ? null : t[i];
      return [r, o == null ? s : Zt(s, o)];
    })
  );
  return n.channels = e, n;
}
function CA(e, t) {
  const { scale: n, value: r } = t;
  if (n === !0 || n === "auto")
    switch (e) {
      case "fill":
      case "stroke":
      case "color":
        t.scale = n !== !0 && Yp(r, Tu) ? null : "color";
        break;
      case "fillOpacity":
      case "strokeOpacity":
      case "opacity":
        t.scale = n !== !0 && Yp(r, DV) ? null : "opacity";
        break;
      case "symbol":
        n !== !0 && Yp(r, CV) ? (t.scale = null, t.value = Zt(r, $g)) : t.scale = "symbol";
        break;
      default:
        t.scale = ie.has(e) ? e : null;
        break;
    }
  else if (n === !1)
    t.scale = null;
  else if (n != null && !ie.has(n))
    throw new Error(`unknown scale: ${n}`);
  return t;
}
function nY(e, t, n, r, i) {
  const { order: s, reverse: o, reduce: a = !0, limit: c } = i;
  for (const u in i) {
    if (!ie.has(u)) continue;
    let { value: l, order: f = s, reverse: h = o, reduce: d = a, limit: p = c } = _a(i[u]);
    const y = l == null ? void 0 : l.startsWith("-");
    if (y && (l = l.slice(1)), f = f === void 0 ? y !== (l === "width" || l === "height") ? UA : PA : sY(f), d == null || d === !1) continue;
    const m = u === "fx" || u === "fy" ? iY(t, r[u]) : rY(n, u);
    if (!m) throw new Error(`missing channel for scale: ${u}`);
    const g = m.value, [b = 0, w = 1 / 0] = li(p) ? p : p < 0 ? [p] : [0, p];
    if (l == null)
      m.domain = () => {
        let _ = Array.from(new pa(g));
        return h && (_ = _.reverse()), (b !== 0 || w !== 1 / 0) && (_ = _.slice(b, w)), _;
      };
    else {
      const _ = l === "data" ? e : l === "height" ? x2(n, "y1", "y2") : l === "width" ? x2(n, "x1", "x2") : $y(n, l, l === "y" ? "y2" : l === "x" ? "x2" : void 0), x = Od(d === !0 ? "max" : d, _);
      m.domain = () => {
        let v = lk(
          ui(g),
          (M) => x.reduceIndex(M, _),
          (M) => g[M]
        );
        return f && v.sort(f), h && v.reverse(), (b !== 0 || w !== 1 / 0) && (v = v.slice(b, w)), v.map(Ad);
      };
    }
  }
}
function rY(e, t) {
  for (const n in e) {
    const r = e[n];
    if (r.scale === t) return r;
  }
}
function iY(e, t) {
  const n = e.original;
  if (n === e) return t;
  const r = t.value, i = t.value = [];
  for (let s = 0; s < n.length; ++s) {
    const o = r[n[s][0]];
    for (const a of e[s]) i[a] = o;
  }
  return t;
}
function x2(e, t, n) {
  const r = $y(e, t), i = $y(e, n);
  return Zt(i, (s, o) => Math.abs(s - r[o]), Float64Array);
}
function $y(e, t, n) {
  let r = e[t];
  if (!r && n !== void 0 && (r = e[n]), r) return r.value;
  throw new Error(`missing channel: ${t}`);
}
function sY(e) {
  if (e == null || typeof e == "function") return e;
  switch (`${e}`.toLowerCase()) {
    case "ascending":
      return PA;
    case "descending":
      return UA;
  }
  throw new Error(`invalid order: ${e}`);
}
function PA([e, t], [n, r]) {
  return Tn(t, r) || Tn(e, n);
}
function UA([e, t], [n, r]) {
  return _h(t, r) || Tn(e, n);
}
function Iy(e, t) {
  let n = e[t];
  if (n) {
    for (; n.source; ) n = n.source;
    return n.source === null ? null : n;
  }
}
const zA = /* @__PURE__ */ new Map([
  ["accent", wj],
  ["category10", bj],
  ["dark2", _j],
  ["observable10", vj],
  ["paired", xj],
  ["pastel1", Sj],
  ["pastel2", Mj],
  ["set1", Aj],
  ["set2", $j],
  ["set3", Ij],
  ["tableau10", Tj]
]);
function oY(e) {
  return e != null && zA.has(`${e}`.toLowerCase());
}
const S2 = new Map([
  ...zA,
  // diverging
  ["brbg", Lr(S6, M6)],
  ["prgn", Lr(A6, $6)],
  ["piyg", Lr(I6, T6)],
  ["puor", Lr(E6, N6)],
  ["rdbu", Lr(xy, dh)],
  ["rdgy", Lr(D6, O6)],
  ["rdylbu", Lr(Sy, ph)],
  ["rdylgn", Lr(L6, R6)],
  ["spectral", Lr(k6, F6)],
  // reversed diverging (for temperature data)
  ["burd", M2(xy, dh)],
  ["buylrd", M2(Sy, ph)],
  // sequential (single-hue)
  ["blues", be(aM, cM)],
  ["greens", be(uM, lM)],
  ["greys", be(fM, hM)],
  ["oranges", be(gM, bM)],
  ["purples", be(dM, pM)],
  ["reds", be(yM, mM)],
  // sequential (multi-hue)
  ["turbo", Rr(AM)],
  ["viridis", Rr($M)],
  ["magma", Rr(IM)],
  ["inferno", Rr(TM)],
  ["plasma", Rr(EM)],
  ["cividis", Rr(wM)],
  ["cubehelix", Rr(_M)],
  ["warm", Rr(vM)],
  ["cool", Rr(xM)],
  ["bugn", be(B6, C6)],
  ["bupu", be(P6, U6)],
  ["gnbu", be(z6, q6)],
  ["orrd", be(j6, V6)],
  ["pubu", be(X6, G6)],
  ["pubugn", be(Y6, W6)],
  ["purd", be(H6, J6)],
  ["rdpu", be(Z6, K6)],
  ["ylgn", be(eM, nM)],
  ["ylgnbu", be(Q6, tM)],
  ["ylorbr", be(rM, iM)],
  ["ylorrd", be(sM, oM)],
  // cyclical
  ["rainbow", A2(SM)],
  ["sinebow", A2(MM)]
]);
function be(e, t) {
  return ({ length: n }) => n === 1 ? [e[3][1]] : n === 2 ? [e[3][1], e[3][2]] : (n = Math.max(3, Math.floor(n)), n > 9 ? jn(t, n) : e[n]);
}
function Lr(e, t) {
  return ({ length: n }) => n === 2 ? [e[3][0], e[3][2]] : (n = Math.max(3, Math.floor(n)), n > 11 ? jn(t, n) : e[n]);
}
function M2(e, t) {
  return ({ length: n }) => n === 2 ? [e[3][2], e[3][0]] : (n = Math.max(3, Math.floor(n)), n > 11 ? jn((r) => t(1 - r), n) : e[n].slice().reverse());
}
function Rr(e) {
  return ({ length: t }) => jn(e, Math.max(2, Math.floor(t)));
}
function A2(e) {
  return ({ length: t }) => jn(e, Math.floor(t) + 1).slice(0, -1);
}
function qA(e) {
  const t = `${e}`.toLowerCase();
  if (!S2.has(t)) throw new Error(`unknown ordinal scheme: ${t}`);
  return S2.get(t);
}
function Ld(e, t) {
  const n = qA(e), r = typeof n == "function" ? n({ length: t }) : n;
  return r.length !== t ? r.slice(0, t) : r;
}
function aY(e, t = "greys") {
  const n = /* @__PURE__ */ new Set(), [r, i] = Ld(t, 2);
  for (const s of e)
    if (s != null)
      if (s === !0) n.add(i);
      else if (s === !1) n.add(r);
      else return;
  return [...n];
}
const $2 = /* @__PURE__ */ new Map([
  // diverging
  ["brbg", M6],
  ["prgn", $6],
  ["piyg", T6],
  ["puor", N6],
  ["rdbu", dh],
  ["rdgy", O6],
  ["rdylbu", ph],
  ["rdylgn", R6],
  ["spectral", F6],
  // reversed diverging (for temperature data)
  ["burd", (e) => dh(1 - e)],
  ["buylrd", (e) => ph(1 - e)],
  // sequential (single-hue)
  ["blues", cM],
  ["greens", lM],
  ["greys", hM],
  ["purples", pM],
  ["reds", mM],
  ["oranges", bM],
  // sequential (multi-hue)
  ["turbo", AM],
  ["viridis", $M],
  ["magma", IM],
  ["inferno", TM],
  ["plasma", EM],
  ["cividis", wM],
  ["cubehelix", _M],
  ["warm", vM],
  ["cool", xM],
  ["bugn", C6],
  ["bupu", U6],
  ["gnbu", q6],
  ["orrd", V6],
  ["pubugn", W6],
  ["pubu", G6],
  ["purd", J6],
  ["rdpu", K6],
  ["ylgnbu", tM],
  ["ylgn", nM],
  ["ylorbr", iM],
  ["ylorrd", oM],
  // cyclical
  ["rainbow", SM],
  ["sinebow", MM]
]);
function Cg(e) {
  const t = `${e}`.toLowerCase();
  if (!$2.has(t)) throw new Error(`unknown quantitative scheme: ${t}`);
  return $2.get(t);
}
const cY = /* @__PURE__ */ new Set([
  "brbg",
  "prgn",
  "piyg",
  "puor",
  "rdbu",
  "rdgy",
  "rdylbu",
  "rdylgn",
  "spectral",
  "burd",
  "buylrd"
]);
function uY(e) {
  return e != null && cY.has(`${e}`.toLowerCase());
}
const jA = (e) => (t) => e(1 - t), Gp = [0, 1], I2 = /* @__PURE__ */ new Map([
  // numbers
  ["number", Ee],
  // color spaces
  ["rgb", Ds],
  ["hsl", GB],
  ["hcl", ZB],
  ["lab", HB]
]);
function VA(e) {
  const t = `${e}`.toLowerCase();
  if (!I2.has(t)) throw new Error(`unknown interpolator: ${t}`);
  return I2.get(t);
}
function Lu(e, t, n, {
  type: r,
  nice: i,
  clamp: s,
  zero: o,
  domain: a = WA(e, n),
  unknown: c,
  round: u,
  scheme: l,
  interval: f,
  range: h = ie.get(e) === Nu ? _Y(n, a) : ie.get(e) === Du ? vY(n, a) : ie.get(e) === Ou ? Gp : void 0,
  interpolate: d = ie.get(e) === fi ? l == null && h !== void 0 ? Ds : Cg(l !== void 0 ? l : r === "cyclical" ? "rainbow" : "turbo") : u ? Ym : Ee,
  reverse: p
}) {
  if (f = wa(f, r), (r === "cyclical" || r === "sequential") && (r = "linear"), typeof d != "function" && (d = VA(d)), p = !!p, h !== void 0) {
    const y = (a = Qe(a)).length, m = (h = Qe(h)).length;
    if (y !== m) {
      if (d.length === 1) throw new Error("invalid piecewise interpolator");
      d = sd(d, h), h = void 0;
    }
  }
  if (d.length === 1 ? (p && (d = jA(d), p = !1), h === void 0 && (h = Float64Array.from(a, (y, m) => m / (a.length - 1)), h.length === 2 && (h = Gp)), t.interpolate((h === Gp ? fn : Ug)(d))) : t.interpolate(d), o) {
    const [y, m] = pe(a);
    (y > 0 || m < 0) && (a = Yc(a), (ea(a) || 1) === Math.sign(y) ? a[0] = 0 : a[a.length - 1] = 0);
  }
  return p && (a = Rf(a)), t.domain(a).unknown(c), i && (t.nice(lY(i, r)), a = t.domain()), h !== void 0 && t.range(h), s && t.clamp(s), { type: r, domain: a, range: h, scale: t, interpolate: d, interval: f };
}
function lY(e, t) {
  return e === !0 ? void 0 : typeof e == "number" ? e : MV(e, t);
}
function fY(e, t, n) {
  return Lu(e, dd(), t, n);
}
function hY(e, t, n) {
  return YA(e, t, { ...n, exponent: 0.5 });
}
function YA(e, t, { exponent: n = 1, ...r }) {
  return Lu(e, n6().exponent(n), t, { ...r, type: "pow" });
}
function dY(e, t, { base: n = 10, domain: r = xY(t), ...i }) {
  return Lu(e, K3().base(n), t, { ...i, domain: r });
}
function pY(e, t, { constant: n = 1, ...r }) {
  return Lu(e, t6().constant(n), t, r);
}
function yY(e, t, {
  range: n,
  quantiles: r = n === void 0 ? 5 : (n = [...n]).length,
  // deprecated; use n instead
  n: i = r,
  scheme: s = "rdylbu",
  domain: o = SY(t),
  unknown: a,
  interpolate: c,
  reverse: u
}) {
  return n === void 0 && (n = c !== void 0 ? jn(c, i) : ie.get(e) === fi ? Ld(s, i) : void 0), o.length > 0 && (o = r6(o, n === void 0 ? { length: i } : n).quantiles()), Pg(e, t, { domain: o, range: n, reverse: u, unknown: a });
}
function mY(e, t, {
  range: n,
  n: r = n === void 0 ? 5 : (n = [...n]).length,
  scheme: i = "rdylbu",
  domain: s = WA(e, t),
  unknown: o,
  interpolate: a,
  reverse: c
}) {
  const [u, l] = pe(s);
  let f;
  return n === void 0 ? (f = Fi(u, l, r), f[0] <= u && f.splice(0, 1), f[f.length - 1] >= l && f.pop(), r = f.length + 1, n = a !== void 0 ? jn(a, r) : ie.get(e) === fi ? Ld(i, r) : void 0) : (f = jn(Ee(u, l), r + 1).slice(1, -1), u instanceof Date && (f = f.map((h) => new Date(h)))), ea(Qe(s)) < 0 && f.reverse(), Pg(e, t, { domain: f, range: n, reverse: c, unknown: o });
}
function Pg(e, t, {
  domain: n = [0],
  // explicit thresholds in ascending order
  unknown: r,
  scheme: i = "rdylbu",
  interpolate: s,
  range: o = s !== void 0 ? jn(s, n.length + 1) : ie.get(e) === fi ? Ld(i, n.length + 1) : void 0,
  reverse: a
}) {
  n = Qe(n);
  const c = ea(n);
  if (!isNaN(c) && !gY(n, c)) throw new Error(`the ${e} scale has a non-monotonic domain`);
  return a && (o = Rf(o)), {
    type: "threshold",
    scale: i6(c < 0 ? Rf(n) : n, o === void 0 ? [] : o).unknown(r),
    domain: n,
    range: o
  };
}
function gY(e, t) {
  for (let n = 1, r = e.length, i = e[0]; n < r; ++n) {
    const s = Is(i, i = e[n]);
    if (s !== 0 && s !== t) return !1;
  }
  return !0;
}
function bY(e) {
  return { type: "identity", scale: FV(ie.get(e)) ? H3() : (t) => t };
}
function Hc(e, t = vh) {
  return e.length ? [
    ve(e, ({ value: n }) => n === void 0 ? n : ve(n, t)),
    ce(e, ({ value: n }) => n === void 0 ? n : ce(n, t))
  ] : [0, 1];
}
function WA(e, t) {
  const n = ie.get(e);
  return (n === Nu || n === Ou || n === Du ? wY : Hc)(t);
}
function wY(e) {
  return [0, e.length ? ce(e, ({ value: t }) => t === void 0 ? t : ce(t, vh)) : 1];
}
function _Y(e, t) {
  const n = e.find(({ radius: o }) => o !== void 0);
  if (n !== void 0) return [0, n.radius];
  const r = Bi(e, 0.5, ({ value: o }) => o === void 0 ? NaN : Bi(o, 0.25, Qr)), i = t.map((o) => 3 * Math.sqrt(o / r)), s = 30 / ce(i);
  return s < 1 ? i.map((o) => o * s) : i;
}
function vY(e, t) {
  const n = Lc(e, ({ value: s }) => s === void 0 ? NaN : Lc(s, Math.abs)), r = t.map((s) => 12 * s / n), i = 60 / ce(r);
  return i < 1 ? r.map((s) => s * i) : r;
}
function xY(e) {
  for (const { value: t } of e)
    if (t !== void 0)
      for (let n of t) {
        if (n > 0) return Hc(e, Qr);
        if (n < 0) return Hc(e, xd);
      }
  return [1, 10];
}
function SY(e) {
  const t = [];
  for (const { value: n } of e)
    if (n !== void 0)
      for (const r of n) t.push(r);
  return t;
}
function Ug(e) {
  return (t, n) => (r) => e(t + r * (n - t));
}
let Ty = 0, Ey;
function MY() {
  const e = Ty;
  return Ty = 0, Ey = void 0, e;
}
function ti(e) {
  e !== Ey && (Ey = e, console.warn(e), ++Ty);
}
function Rd(e, t, n, r, {
  type: i,
  nice: s,
  clamp: o,
  domain: a = Hc(r),
  unknown: c,
  pivot: u = 0,
  scheme: l,
  range: f,
  symmetric: h = !0,
  interpolate: d = ie.get(e) === fi ? l == null && f !== void 0 ? Ds : Cg(l !== void 0 ? l : "rdbu") : Ee,
  reverse: p
}) {
  u = +u, a = Qe(a);
  let [y, m] = a;
  if (a.length > 2 && ti(`Warning: the diverging ${e} scale domain contains extra elements.`), Is(y, m) < 0 && ([y, m] = [m, y], p = !p), y = Math.min(y, u), m = Math.max(m, u), typeof d != "function" && (d = VA(d)), f !== void 0 && (d = d.length === 1 ? Ug(d)(...f) : sd(d, f)), p && (d = jA(d)), h) {
    const g = n.apply(u), b = g - n.apply(y), w = n.apply(m) - g;
    b < w ? y = n.invert(g - w) : b > w && (m = n.invert(g + b));
  }
  return t.domain([y, u, m]).unknown(c).interpolator(d), o && t.clamp(o), s && t.nice(s), { type: i, domain: [y, m], pivot: u, interpolate: d, scale: t };
}
function AY(e, t, n) {
  return Rd(e, w6(), EY, t, n);
}
function $Y(e, t, n) {
  return XA(e, t, { ...n, exponent: 0.5 });
}
function XA(e, t, { exponent: n = 1, ...r }) {
  return Rd(e, x6().exponent(n = +n), OY(n), t, {
    ...r,
    type: "diverging-pow"
  });
}
function IY(e, t, { base: n = 10, pivot: r = 1, domain: i = Hc(t, r < 0 ? xd : Qr), ...s }) {
  return Rd(e, _6().base(n = +n), NY, t, {
    domain: i,
    pivot: r,
    ...s
  });
}
function TY(e, t, { constant: n = 1, ...r }) {
  return Rd(
    e,
    v6().constant(n = +n),
    LY(n),
    t,
    r
  );
}
const EY = {
  apply(e) {
    return e;
  },
  invert(e) {
    return e;
  }
}, NY = {
  apply: Math.log,
  invert: Math.exp
}, DY = {
  apply(e) {
    return Math.sign(e) * Math.sqrt(Math.abs(e));
  },
  invert(e) {
    return Math.sign(e) * (e * e);
  }
};
function OY(e) {
  return e === 0.5 ? DY : {
    apply(t) {
      return Math.sign(t) * Math.pow(Math.abs(t), e);
    },
    invert(t) {
      return Math.sign(t) * Math.pow(Math.abs(t), 1 / e);
    }
  };
}
function LY(e) {
  return {
    apply(t) {
      return Math.sign(t) * Math.log1p(Math.abs(t / e));
    },
    invert(t) {
      return Math.sign(t) * Math.expm1(Math.abs(t)) * e;
    }
  };
}
function GA(e, t, n, r) {
  return Lu(e, t, n, r);
}
function RY(e, t, n) {
  return GA(e, mj(), t, n);
}
function kY(e, t, n) {
  return GA(e, gj(), t, n);
}
const Ru = Symbol("ordinal");
function HA(e, t, n, { type: r, interval: i, domain: s, range: o, reverse: a, hint: c }) {
  return i = wa(i, r), s === void 0 && (s = ZA(n, i, e)), (r === "categorical" || r === Ru) && (r = "ordinal"), a && (s = Rf(s)), s = t.domain(s).domain(), o !== void 0 && (typeof o == "function" && (o = o(s)), t.range(o)), { type: r, domain: s, range: o, scale: t, hint: c, interval: i };
}
function FY(e, t, { type: n, interval: r, domain: i, range: s, scheme: o, unknown: a, ...c }) {
  r = wa(r, n), i === void 0 && (i = ZA(t, r, e));
  let u;
  if (ie.get(e) === Ed)
    u = PY(t), s = s === void 0 ? UY(u) : Zt(s, $g);
  else if (ie.get(e) === fi && (s === void 0 && (n === "ordinal" || n === Ru) && (s = aY(i, o), s !== void 0 && (o = void 0)), o === void 0 && s === void 0 && (o = n === "ordinal" ? "turbo" : "observable10"), o !== void 0))
    if (s !== void 0) {
      const l = Cg(o), f = s[0], h = s[1] - s[0];
      s = ({ length: d }) => jn((p) => l(f + h * p), d);
    } else
      s = qA(o);
  if (a === wy)
    throw new Error(`implicit unknown on ${e} scale is not supported`);
  return HA(e, ig().unknown(a), t, { ...c, type: n, domain: i, range: s, hint: u });
}
function BY(e, t, { align: n = 0.5, padding: r = 0.5, ...i }) {
  return JA(Zz().align(n).padding(r), t, i, e);
}
function CY(e, t, {
  align: n = 0.5,
  padding: r = 0.1,
  paddingInner: i = r,
  paddingOuter: s = e === "fx" || e === "fy" ? 0 : r,
  ...o
}) {
  return JA(
    fd().align(n).paddingInner(i).paddingOuter(s),
    t,
    o,
    e
  );
}
function JA(e, t, n, r) {
  let { round: i } = n;
  return i !== void 0 && e.round(i = !!i), e = HA(r, e, t, n), e.round = i, e;
}
function ZA(e, t, n) {
  const r = new pa();
  for (const { value: i, domain: s } of e) {
    if (s !== void 0) return s();
    if (i !== void 0)
      for (const o of i) r.add(o);
  }
  if (t !== void 0) {
    const [i, s] = pe(r).map(t.floor, t);
    return t.range(i, t.offset(s));
  }
  if (r.size > 1e4 && ie.get(n) === fr)
    throw new Error(`implicit ordinal domain of ${n} scale has more than 10,000 values`);
  return Of(r, Tn);
}
function T2(e, t) {
  let n;
  for (const { hint: r } of e) {
    const i = r == null ? void 0 : r[t];
    if (i !== void 0) {
      if (n === void 0) n = i;
      else if (n !== i) return;
    }
  }
  return n;
}
function PY(e) {
  return {
    fill: T2(e, "fill"),
    stroke: T2(e, "stroke")
  };
}
function UY(e) {
  return ee(e.fill) ? zj : Uj;
}
function Ny(e, {
  label: t,
  inset: n = 0,
  insetTop: r = n,
  insetRight: i = n,
  insetBottom: s = n,
  insetLeft: o = n,
  round: a,
  nice: c,
  clamp: u,
  zero: l,
  align: f,
  padding: h,
  projection: d,
  facet: { label: p = t } = {},
  ...y
} = {}) {
  const m = {};
  for (const [g, b] of e) {
    const w = y[g], _ = n$(g, b, {
      round: ie.get(g) === fr ? a : void 0,
      // only for position
      nice: c,
      clamp: u,
      zero: l,
      align: f,
      padding: h,
      projection: d,
      ...w
    });
    if (_) {
      let {
        label: x = g === "fx" || g === "fy" ? p : t,
        percent: v,
        transform: M,
        inset: E,
        insetTop: $ = E !== void 0 ? E : g === "y" ? r : 0,
        // not fy
        insetRight: N = E !== void 0 ? E : g === "x" ? i : 0,
        // not fx
        insetBottom: A = E !== void 0 ? E : g === "y" ? s : 0,
        // not fy
        insetLeft: D = E !== void 0 ? E : g === "x" ? o : 0
        // not fx
      } = w || {};
      if (M == null) M = void 0;
      else if (typeof M != "function") throw new Error("invalid scale transform; not a function");
      _.percent = !!v, _.label = x === void 0 ? qY(b, _) : x, _.transform = M, g === "x" || g === "fx" ? (_.insetLeft = +D, _.insetRight = +N) : (g === "y" || g === "fy") && (_.insetTop = +$, _.insetBottom = +A), m[g] = _;
    }
  }
  return m;
}
function E2(e) {
  const t = {}, n = { scales: t };
  for (const [r, i] of Object.entries(e)) {
    const { scale: s, type: o, interval: a, label: c } = i;
    t[r] = i$(i), n[r] = s, s.type = o, a != null && (s.interval = a), c != null && (s.label = c);
  }
  return n;
}
function zY(e, t) {
  const { x: n, y: r, fx: i, fy: s } = e, o = i || s ? zg(t) : t;
  i && N2(i, o), s && D2(s, o);
  const a = i || s ? QA(e, t) : t;
  n && N2(n, a), r && D2(r, a);
}
function qY(e = [], t) {
  let n;
  for (const { label: r } of e)
    if (r !== void 0) {
      if (n === void 0) n = r;
      else if (n !== r) return;
    }
  if (n !== void 0)
    return !zs(t) && t.percent && (n = `${n} (%)`), { inferred: !0, toString: () => n };
}
function KA(e) {
  return Math.sign(ea(e.domain())) * Math.sign(ea(e.range()));
}
function zg(e) {
  const {
    marginTop: t,
    marginRight: n,
    marginBottom: r,
    marginLeft: i,
    width: s,
    height: o,
    facet: {
      marginTop: a,
      marginRight: c,
      marginBottom: u,
      marginLeft: l
    }
  } = e;
  return {
    marginTop: Math.max(t, a),
    marginRight: Math.max(n, c),
    marginBottom: Math.max(r, u),
    marginLeft: Math.max(i, l),
    width: s,
    height: o
  };
}
function QA({ fx: e, fy: t }, n) {
  const { marginTop: r, marginRight: i, marginBottom: s, marginLeft: o, width: a, height: c } = zg(n);
  return {
    marginTop: r,
    marginRight: i,
    marginBottom: s,
    marginLeft: o,
    width: e ? e.scale.bandwidth() + o + i : a,
    height: t ? t.scale.bandwidth() + r + s : c,
    facet: { width: a, height: c }
  };
}
function N2(e, t) {
  if (e.range === void 0) {
    const { insetLeft: n, insetRight: r } = e, { width: i, marginLeft: s = 0, marginRight: o = 0 } = t, a = s + n, c = i - o - r;
    e.range = [a, Math.max(a, c)], zs(e) || (e.range = e$(e)), e.scale.range(e.range);
  }
  t$(e);
}
function D2(e, t) {
  if (e.range === void 0) {
    const { insetTop: n, insetBottom: r } = e, { height: i, marginTop: s = 0, marginBottom: o = 0 } = t, a = s + n, c = i - o - r;
    e.range = [Math.max(a, c), a], zs(e) ? e.range.reverse() : e.range = e$(e), e.scale.range(e.range);
  }
  t$(e);
}
function t$(e) {
  e.round === void 0 && YY(e) && jY(e) <= 30 && e.scale.round(!0);
}
function jY({ scale: e }) {
  const t = e.domain().length, [n, r] = e.range(), i = e.paddingInner ? e.paddingInner() : 1, s = e.paddingOuter ? e.paddingOuter() : e.padding(), o = t - i, a = Math.abs(r - n) / Math.max(1, o + s * 2);
  return (a - Math.floor(a)) * o;
}
function e$(e) {
  const t = e.scale.domain().length + r$(e);
  if (!(t > 2)) return e.range;
  const [n, r] = e.range;
  return Array.from({ length: t }, (i, s) => n + s / (t - 1) * (r - n));
}
function Dy(e, t, n) {
  return n$(e, n === void 0 ? void 0 : [{ hint: n }], { ...t });
}
function n$(e, t = [], n = {}) {
  const r = VY(e, t, n);
  if (n.type === void 0 && n.domain === void 0 && n.range === void 0 && n.interval == null && e !== "fx" && e !== "fy" && zs({ type: r })) {
    const i = t.map(({ value: s }) => s).filter((s) => s !== void 0);
    i.some(qe) ? ti(
      `Warning: some data associated with the ${e} scale are dates. Dates are typically associated with a "utc" or "time" scale rather than a "${to(
        r
      )}" scale. If you are using a bar mark, you probably want a rect mark with the interval option instead; if you are using a group transform, you probably want a bin transform instead. If you want to treat this data as ordinal, you can specify the interval of the ${e} scale (e.g., d3.utcDay), or you can suppress this warning by setting the type of the ${e} scale to "${to(
        r
      )}".`
    ) : i.some(TV) ? ti(
      `Warning: some data associated with the ${e} scale are strings that appear to be dates (e.g., YYYY-MM-DD). If these strings represent dates, you should parse them to Date objects. Dates are typically associated with a "utc" or "time" scale rather than a "${to(
        r
      )}" scale. If you are using a bar mark, you probably want a rect mark with the interval option instead; if you are using a group transform, you probably want a bin transform instead. If you want to treat this data as ordinal, you can suppress this warning by setting the type of the ${e} scale to "${to(
        r
      )}".`
    ) : i.some(EV) && ti(
      `Warning: some data associated with the ${e} scale are strings that appear to be numbers. If these strings represent numbers, you should parse or coerce them to numbers. Numbers are typically associated with a "linear" scale rather than a "${to(
        r
      )}" scale. If you want to treat this data as ordinal, you can specify the interval of the ${e} scale (e.g., 1 for integers), or you can suppress this warning by setting the type of the ${e} scale to "${to(
        r
      )}".`
    );
  }
  switch (n.type = r, r) {
    case "diverging":
    case "diverging-sqrt":
    case "diverging-pow":
    case "diverging-log":
    case "diverging-symlog":
    case "cyclical":
    case "sequential":
    case "linear":
    case "sqrt":
    case "threshold":
    case "quantile":
    case "pow":
    case "log":
    case "symlog":
      n = fl(t, n, He);
      break;
    case "identity":
      switch (ie.get(e)) {
        case fr:
          n = fl(t, n, He);
          break;
        case Ed:
          n = fl(t, n, WY);
          break;
      }
      break;
    case "utc":
    case "time":
      n = fl(t, n, SV);
      break;
  }
  switch (r) {
    case "diverging":
      return AY(e, t, n);
    case "diverging-sqrt":
      return $Y(e, t, n);
    case "diverging-pow":
      return XA(e, t, n);
    case "diverging-log":
      return IY(e, t, n);
    case "diverging-symlog":
      return TY(e, t, n);
    case "categorical":
    case "ordinal":
    case Ru:
      return FY(e, t, n);
    case "cyclical":
    case "sequential":
    case "linear":
      return fY(e, t, n);
    case "sqrt":
      return hY(e, t, n);
    case "threshold":
      return Pg(e, t, n);
    case "quantile":
      return yY(e, t, n);
    case "quantize":
      return mY(e, t, n);
    case "pow":
      return YA(e, t, n);
    case "log":
      return dY(e, t, n);
    case "symlog":
      return pY(e, t, n);
    case "utc":
      return kY(e, t, n);
    case "time":
      return RY(e, t, n);
    case "point":
      return BY(e, t, n);
    case "band":
      return CY(e, t, n);
    case "identity":
      return bY(e);
    case void 0:
      return;
    default:
      throw new Error(`unknown scale type: ${r}`);
  }
}
function to(e) {
  return typeof e == "symbol" ? e.description : e;
}
function O2(e) {
  return typeof e == "string" ? `${e}`.toLowerCase() : e;
}
const L2 = { toString: () => "projection" };
function VY(e, t, { type: n, domain: r, range: i, scheme: s, pivot: o, projection: a }) {
  if (n = O2(n), e === "fx" || e === "fy") return "band";
  (e === "x" || e === "y") && a != null && (n = L2);
  for (const u of t) {
    const l = O2(u.type);
    if (l !== void 0) {
      if (n === void 0) n = l;
      else if (n !== l) throw new Error(`scale incompatible with channel: ${n} !== ${l}`);
    }
  }
  if (n === L2) return;
  if (n !== void 0) return n;
  if (r === void 0 && !t.some(({ value: u }) => u !== void 0)) return;
  const c = ie.get(e);
  if (c === Nu) return "sqrt";
  if (c === Ou || c === Du) return "linear";
  if (c === Ed) return "ordinal";
  if ((r || i || []).length > 2) return Hp(c);
  if (r !== void 0) {
    if (se(r)) return Hp(c);
    if (qe(r)) return "utc";
  } else {
    const u = t.map(({ value: l }) => l).filter((l) => l !== void 0);
    if (u.some(se)) return Hp(c);
    if (u.some(qe)) return "utc";
  }
  if (c === fi) {
    if (o != null || uY(s)) return "diverging";
    if (oY(s)) return "categorical";
  }
  return "linear";
}
function Hp(e) {
  switch (e) {
    case fr:
      return "point";
    case fi:
      return Ru;
    default:
      return "ordinal";
  }
}
function zs({ type: e }) {
  return e === "ordinal" || e === "point" || e === "band" || e === Ru;
}
function r$({ type: e }) {
  return e === "threshold";
}
function YY({ type: e }) {
  return e === "point" || e === "band";
}
function Mn(e) {
  if (e === void 0) return !0;
  const t = e.domain(), n = e(t[0]);
  for (let r = 1, i = t.length; r < i; ++r)
    if (e(t[r]) - n)
      return !1;
  return !0;
}
function fl(e, { domain: t, ...n }, r) {
  var i;
  for (const s of e)
    s.value !== void 0 && (t === void 0 && (t = (i = s.value) == null ? void 0 : i.domain), s.value = r(s.value));
  return {
    domain: t === void 0 ? t : r(t),
    ...n
  };
}
function WY(e) {
  return Zt(e, $g);
}
function Jc(e = {}) {
  let t;
  for (const n in e)
    if (ie.has(n) && _s(e[n])) {
      if (t !== void 0) throw new Error("ambiguous scale definition; multiple scales found");
      t = i$(Dy(n, e[n]));
    }
  if (t === void 0) throw new Error("invalid scale definition; no scale found");
  return t;
}
function XY(e) {
  return (t) => {
    if (!ie.has(t = `${t}`)) throw new Error(`unknown scale: ${t}`);
    return e[t];
  };
}
function i$({ scale: e, type: t, domain: n, range: r, interpolate: i, interval: s, transform: o, percent: a, pivot: c }) {
  if (t === "identity") return { type: "identity", apply: (l) => l, invert: (l) => l };
  const u = e.unknown ? e.unknown() : void 0;
  return {
    type: t,
    domain: Yc(n),
    // defensive copy
    ...r !== void 0 && { range: Yc(r) },
    // defensive copy
    ...o !== void 0 && { transform: o },
    ...a && { percent: a },
    // only exposed if truthy
    ...u !== void 0 && { unknown: u },
    ...s !== void 0 && { interval: s },
    // quantitative
    ...i !== void 0 && { interpolate: i },
    ...e.clamp && { clamp: e.clamp() },
    // diverging (always asymmetric; we never want to apply the symmetric transform twice)
    ...c !== void 0 && { pivot: c, symmetric: !1 },
    // log, diverging-log
    ...e.base && { base: e.base() },
    // pow, diverging-pow
    ...e.exponent && { exponent: e.exponent() },
    // symlog, diverging-symlog
    ...e.constant && { constant: e.constant() },
    // band, point
    ...e.align && { align: e.align(), round: e.round() },
    ...e.padding && (e.paddingInner ? { paddingInner: e.paddingInner(), paddingOuter: e.paddingOuter() } : { padding: e.padding() }),
    ...e.bandwidth && { bandwidth: e.bandwidth(), step: e.step() },
    // utilities
    apply: (l) => e(l),
    ...e.invert && { invert: (l) => e.invert(l) }
  };
}
function GY(e, t) {
  const { fx: n, fy: r } = Ny(e, t), i = n == null ? void 0 : n.scale.domain(), s = r == null ? void 0 : r.scale.domain();
  return i && s ? ck(i, s).map(([o, a], c) => ({ x: o, y: a, i: c })) : i ? i.map((o, a) => ({ x: o, i: a })) : s ? s.map((o, a) => ({ y: o, i: a })) : void 0;
}
function HY(e, { x: t, y: n }) {
  return t && (t = Oy(t)), n && (n = Oy(n)), e.filter(
    t && n ? (r) => t.has(r.x) && n.has(r.y) : t ? (r) => t.has(r.x) : (r) => n.has(r.y)
  ).sort(
    t && n ? (r, i) => t.get(r.x) - t.get(i.x) || n.get(r.y) - n.get(i.y) : t ? (r, i) => t.get(r.x) - t.get(i.x) : (r, i) => n.get(r.y) - n.get(i.y)
  );
}
function qg(e, { fx: t, fy: n }) {
  const r = ui(e), i = t == null ? void 0 : t.value, s = n == null ? void 0 : n.value;
  return t && n ? To(
    r,
    (o) => (o.fx = i[o[0]], o.fy = s[o[0]], o),
    (o) => i[o],
    (o) => s[o]
  ) : t ? To(
    r,
    (o) => (o.fx = i[o[0]], o),
    (o) => i[o]
  ) : To(
    r,
    (o) => (o.fy = s[o[0]], o),
    (o) => s[o]
  );
}
function JY(e, t, { marginTop: n, marginLeft: r }) {
  return e && t ? ({ x: i, y: s }) => `translate(${e(i) - r},${t(s) - n})` : e ? ({ x: i }) => `translate(${e(i) - r},0)` : ({ y: i }) => `translate(0,${t(i) - n})`;
}
function ZY(e) {
  const t = [], n = new Uint32Array(br(e, (r) => r.length));
  for (const r of e) {
    let i = 0;
    for (const s of e)
      r !== s && (n.set(s, i), i += s.length);
    t.push(n.slice(0, i));
  }
  return t;
}
const KY = /* @__PURE__ */ new Map([
  ["top", Jp],
  ["right", Qp],
  ["bottom", Zp],
  ["left", Kp],
  ["top-left", hl(Jp, Kp)],
  ["top-right", hl(Jp, Qp)],
  ["bottom-left", hl(Zp, Kp)],
  ["bottom-right", hl(Zp, Qp)],
  ["top-empty", eW],
  ["right-empty", iW],
  ["bottom-empty", nW],
  ["left-empty", rW],
  ["empty", sW]
]);
function QY(e) {
  if (e == null) return null;
  const t = KY.get(`${e}`.toLowerCase());
  if (t) return t;
  throw new Error(`invalid facet anchor: ${e}`);
}
const R2 = /* @__PURE__ */ new WeakMap();
function Oy(e) {
  let t = R2.get(e);
  return t || R2.set(e, t = new Ts(Zt(e, (n, r) => [n, r]))), t;
}
function Ki(e, t) {
  return Oy(e).get(t);
}
function tW(e, t, n) {
  return t = ds(t), n = ds(n), e.find((r) => Object.is(ds(r.x), t) && Object.is(ds(r.y), n));
}
function kd(e, t, n) {
  var r;
  return (r = tW(e, t, n)) == null ? void 0 : r.empty;
}
function Jp(e, { y: t }, { y: n }) {
  return t ? Ki(t, n) === 0 : !0;
}
function Zp(e, { y: t }, { y: n }) {
  return t ? Ki(t, n) === t.length - 1 : !0;
}
function Kp(e, { x: t }, { x: n }) {
  return t ? Ki(t, n) === 0 : !0;
}
function Qp(e, { x: t }, { x: n }) {
  return t ? Ki(t, n) === t.length - 1 : !0;
}
function eW(e, { y: t }, { x: n, y: r, empty: i }) {
  if (i) return !1;
  if (!t) return;
  const s = Ki(t, r);
  if (s > 0) return kd(e, n, t[s - 1]);
}
function nW(e, { y: t }, { x: n, y: r, empty: i }) {
  if (i) return !1;
  if (!t) return;
  const s = Ki(t, r);
  if (s < t.length - 1) return kd(e, n, t[s + 1]);
}
function rW(e, { x: t }, { x: n, y: r, empty: i }) {
  if (i) return !1;
  if (!t) return;
  const s = Ki(t, n);
  if (s > 0) return kd(e, t[s - 1], r);
}
function iW(e, { x: t }, { x: n, y: r, empty: i }) {
  if (i) return !1;
  if (!t) return;
  const s = Ki(t, n);
  if (s < t.length - 1) return kd(e, t[s + 1], r);
}
function sW(e, t, { empty: n }) {
  return n;
}
function hl(e, t) {
  return function() {
    return e.apply(null, arguments) && t.apply(null, arguments);
  };
}
function t0(e, { channels: { fx: t, fy: n }, groups: r }) {
  return t && n ? e.map(({ x: i, y: s }) => {
    var o;
    return ((o = r.get(i)) == null ? void 0 : o.get(s)) ?? [];
  }) : t ? e.map(({ x: i }) => r.get(i) ?? []) : e.map(({ y: i }) => r.get(i) ?? []);
}
const s$ = Math.PI, kr = 2 * s$, k2 = 0.618;
function oW({
  projection: e,
  inset: t = 0,
  insetTop: n = t,
  insetRight: r = t,
  insetBottom: i = t,
  insetLeft: s = t
} = {}, o) {
  if (e == null) return;
  if (typeof e.stream == "function") return e;
  let a, c, u = "frame";
  if (Nn(e)) {
    let x;
    if ({
      type: e,
      domain: c,
      inset: x,
      insetTop: n = x !== void 0 ? x : n,
      insetRight: r = x !== void 0 ? x : r,
      insetBottom: i = x !== void 0 ? x : i,
      insetLeft: s = x !== void 0 ? x : s,
      clip: u = u,
      ...a
    } = e, e == null) return;
  }
  typeof e != "function" && ({ type: e } = o$(e));
  const { width: l, height: f, marginLeft: h, marginRight: d, marginTop: p, marginBottom: y } = o, m = l - h - d - s - r, g = f - p - y - n - i;
  if (e = e == null ? void 0 : e({ width: m, height: g, clip: u, ...a }), e == null) return;
  u = aW(u, h, p, l - d, f - y);
  let b = h + s, w = p + n, _;
  if (c != null) {
    const [[x, v], [M, E]] = Hi(e).bounds(c), $ = Math.min(m / (M - x), g / (E - v));
    $ > 0 ? (b -= ($ * (x + M) - m) / 2, w -= ($ * (v + E) - g) / 2, _ = ah({
      point(N, A) {
        this.stream.point(N * $ + b, A * $ + w);
      }
    })) : ti("Warning: the projection could not be fit to the specified domain; using the default scale.");
  }
  return _ ?? (_ = b === 0 && w === 0 ? a$() : ah({
    point(x, v) {
      this.stream.point(x + b, v + w);
    }
  })), { stream: (x) => e.stream(_.stream(u(x))) };
}
function o$(e) {
  switch (`${e}`.toLowerCase()) {
    case "albers-usa":
      return Dn(KU, 0.7463, 0.4673);
    case "albers":
      return dl(L3, 0.7463, 0.4673);
    case "azimuthal-equal-area":
      return Dn(QU, 4, 4);
    case "azimuthal-equidistant":
      return Dn(tz, kr, kr);
    case "conic-conformal":
      return dl(rz, kr, kr);
    case "conic-equal-area":
      return dl(ch, 6.1702, 2.9781);
    case "conic-equidistant":
      return dl(oz, 7.312, 3.6282);
    case "equal-earth":
      return Dn(cz, 5.4133, 2.6347);
    case "equirectangular":
      return Dn(iz, kr, s$);
    case "gnomonic":
      return Dn(uz, 3.4641, 3.4641);
    case "identity":
      return { type: a$ };
    case "reflect-y":
      return { type: cW };
    case "mercator":
      return Dn(ez, kr, kr);
    case "orthographic":
      return Dn(lz, 2, 2);
    case "stereographic":
      return Dn(fz, 2, 2);
    case "transverse-mercator":
      return Dn(hz, kr, kr);
    default:
      throw new Error(`unknown projection type: ${e}`);
  }
}
function aW(e, t, n, r, i) {
  if (e === !1 || e == null || typeof e == "number") return (s) => s;
  switch (e === !0 && (e = "frame"), `${e}`.toLowerCase()) {
    case "frame":
      return g3(t, n, r, i);
    default:
      throw new Error(`unknown projection clip type: ${e}`);
  }
}
function Dn(e, t, n) {
  return {
    type: ({ width: r, height: i, rotate: s, precision: o = 0.15, clip: a }) => {
      var u, l, f;
      const c = e();
      return o != null && ((u = c.precision) == null || u.call(c, o)), s != null && ((l = c.rotate) == null || l.call(c, s)), typeof a == "number" && ((f = c.clipAngle) == null || f.call(c, a)), c.scale(Math.min(r / t, i / n)), c.translate([r / 2, i / 2]), c;
    },
    aspectRatio: n / t
  };
}
function dl(e, t, n) {
  const { type: r, aspectRatio: i } = Dn(e, t, n);
  return {
    type: (s) => {
      const { parallels: o, domain: a, width: c, height: u } = s, l = r(s);
      return o != null && (l.parallels(o), a === void 0 && l.fitSize([c, u], { type: "Sphere" })), l;
    },
    aspectRatio: i
  };
}
const a$ = fn({ stream: (e) => e }), cW = fn(
  ah({
    point(e, t) {
      this.stream.point(e, -t);
    }
  })
);
function c$(e, t, n, r) {
  const i = n[e], s = n[t], o = i.length, a = n[e] = new Float64Array(o).fill(NaN), c = n[t] = new Float64Array(o).fill(NaN);
  let u;
  const l = r.stream({
    point(f, h) {
      a[u] = f, c[u] = h;
    }
  });
  for (u = 0; u < o; ++u)
    l.point(i[u], s[u]);
}
function uW({ projection: e } = {}) {
  return e == null ? !1 : typeof e.stream == "function" ? !0 : (Nn(e) && (e = e.type), e != null);
}
function lW(e) {
  if (typeof (e == null ? void 0 : e.stream) == "function") return k2;
  if (Nn(e) && (e = e.type), e != null) {
    if (typeof e != "function") {
      const { aspectRatio: t } = o$(e);
      if (t) return t;
    }
    return k2;
  }
}
function Fd(e, t, { projection: n }) {
  const { x: r, y: i } = e;
  let s = {};
  return r && (s.x = r), i && (s.y = i), s = Bg(s, t), n && (r == null ? void 0 : r.scale) === "x" && (i == null ? void 0 : i.scale) === "y" && c$("x", "y", s, n), r && (s.x = He(s.x)), i && (s.y = He(s.y)), s;
}
function fW(e) {
  const t = [], n = [], r = { scale: "x", value: t }, i = { scale: "y", value: n }, s = {
    point(o, a) {
      t.push(o), n.push(a);
    },
    lineStart() {
    },
    lineEnd() {
    },
    polygonStart() {
    },
    polygonEnd() {
    },
    sphere() {
    }
  };
  for (const o of e.value) Si(o, s);
  return [r, i];
}
function Bd(e = {}) {
  const { document: t = typeof window < "u" ? window.document : void 0, clip: n } = e;
  return { document: t, clip: MA(n) };
}
function Ot(e, { document: t }) {
  return Wt(nd(e).call(t.documentElement));
}
function jg(e) {
  let t, n;
  return (...r) => (((n == null ? void 0 : n.length) !== r.length || n.some((i, s) => i !== r[s])) && (n = r, t = e(...r)), t);
}
const hW = jg((e) => new Intl.NumberFormat(e)), dW = jg((e, t) => new Intl.DateTimeFormat(e, { timeZone: "UTC", ...t && { month: t } })), pW = jg((e, t) => new Intl.DateTimeFormat(e, { timeZone: "UTC", ...t && { weekday: t } }));
function u$(e = "en-US") {
  const t = hW(e);
  return (n) => n != null && !isNaN(n) ? t.format(n) : void 0;
}
function yW(e = "en-US", t = "short") {
  const n = dW(e, t);
  return (r) => r != null && !isNaN(r = +new Date(Date.UTC(2e3, +r))) ? n.format(r) : void 0;
}
function mW(e = "en-US", t = "short") {
  const n = pW(e, t);
  return (r) => r != null && !isNaN(r = +new Date(Date.UTC(2001, 0, +r))) ? n.format(r) : void 0;
}
function l$(e) {
  return uA(e, "Invalid Date");
}
function gW(e = "en-US") {
  const t = u$(e);
  return (n) => (n instanceof Date ? l$ : typeof n == "number" ? t : Ne)(n);
}
const ia = gW(), Ae = (typeof window < "u" ? window.devicePixelRatio > 1 : typeof it > "u") ? 0 : 0.5;
let bW = 0;
function Ly() {
  return `plot-clip-${++bW}`;
}
function f$(e, {
  title: t,
  href: n,
  ariaLabel: r,
  ariaDescription: i,
  ariaHidden: s,
  target: o,
  fill: a,
  fillOpacity: c,
  stroke: u,
  strokeWidth: l,
  strokeOpacity: f,
  strokeLinejoin: h,
  strokeLinecap: d,
  strokeMiterlimit: p,
  strokeDasharray: y,
  strokeDashoffset: m,
  opacity: g,
  mixBlendMode: b,
  imageFilter: w,
  paintOrder: _,
  pointerEvents: x,
  shapeRendering: v,
  channels: M
}, {
  ariaLabel: E,
  fill: $ = "currentColor",
  fillOpacity: N,
  stroke: A = "none",
  strokeOpacity: D,
  strokeWidth: k,
  strokeLinecap: S,
  strokeLinejoin: I,
  strokeMiterlimit: T,
  paintOrder: R
}) {
  $ === null && (a = null, c = null), A === null && (u = null, f = null), ee($) ? !ee(A) && (!ee(a) || M != null && M.fill) && (A = "none") : ee(A) && (!ee(u) || M != null && M.stroke) && ($ = "none");
  const [B, C] = ze(a, $), [F, P] = fe(c, N), [U, Y] = ze(u, A), [G, K] = fe(f, D), [H, V] = fe(g);
  ra(Y) || (l === void 0 && (l = k), d === void 0 && (d = S), h === void 0 && (h = I), p === void 0 && !OV(h) && (p = T), !ra(C) && _ === void 0 && (_ = R));
  const [W, q] = fe(l);
  return $ !== null && (e.fill = oe(C, "currentColor"), e.fillOpacity = Pa(P, 1)), A !== null && (e.stroke = oe(Y, "none"), e.strokeWidth = Pa(q, 1), e.strokeOpacity = Pa(K, 1), e.strokeLinejoin = oe(h, "miter"), e.strokeLinecap = oe(d, "butt"), e.strokeMiterlimit = Pa(p, 4), e.strokeDasharray = oe(y, "none"), e.strokeDashoffset = oe(m, "0")), e.target = Ne(o), e.ariaLabel = Ne(E), e.ariaDescription = Ne(i), e.ariaHidden = Ne(s), e.opacity = Pa(V, 1), e.mixBlendMode = oe(b, "normal"), e.imageFilter = oe(w, "none"), e.paintOrder = oe(_, "normal"), e.pointerEvents = oe(x, "auto"), e.shapeRendering = oe(v, "auto"), {
    title: { value: t, optional: !0, filter: null },
    href: { value: n, optional: !0, filter: null },
    ariaLabel: { value: r, optional: !0, filter: null },
    fill: { value: B, scale: "auto", optional: !0 },
    fillOpacity: { value: F, scale: "auto", optional: !0 },
    stroke: { value: U, scale: "auto", optional: !0 },
    strokeOpacity: { value: G, scale: "auto", optional: !0 },
    strokeWidth: { value: W, optional: !0 },
    opacity: { value: H, scale: "auto", optional: !0 }
  };
}
function wW(e, t) {
  t && e.filter((n) => pg(t[n])).append("title").call(vW, t);
}
function _W(e, t) {
  t && e.filter(([n]) => pg(t[n])).append("title").call(xW, t);
}
function vW(e, t) {
  t && e.text((n) => ia(t[n]));
}
function xW(e, t) {
  t && e.text(([n]) => ia(t[n]));
}
function ge(e, { target: t, tip: n }, {
  ariaLabel: r,
  title: i,
  fill: s,
  fillOpacity: o,
  stroke: a,
  strokeOpacity: c,
  strokeWidth: u,
  opacity: l,
  href: f
}) {
  r && at(e, "aria-label", (h) => r[h]), s && at(e, "fill", (h) => s[h]), o && at(e, "fill-opacity", (h) => o[h]), a && at(e, "stroke", (h) => a[h]), c && at(e, "stroke-opacity", (h) => c[h]), u && at(e, "stroke-width", (h) => u[h]), l && at(e, "opacity", (h) => l[h]), f && d$(e, (h) => f[h], t), n || wW(e, i);
}
function Ah(e, { target: t, tip: n }, {
  ariaLabel: r,
  title: i,
  fill: s,
  fillOpacity: o,
  stroke: a,
  strokeOpacity: c,
  strokeWidth: u,
  opacity: l,
  href: f
}) {
  r && at(e, "aria-label", ([h]) => r[h]), s && at(e, "fill", ([h]) => s[h]), o && at(e, "fill-opacity", ([h]) => o[h]), a && at(e, "stroke", ([h]) => a[h]), c && at(e, "stroke-opacity", ([h]) => c[h]), u && at(e, "stroke-width", ([h]) => u[h]), l && at(e, "opacity", ([h]) => l[h]), f && d$(e, ([h]) => f[h], t), n || _W(e, i);
}
function SW({
  ariaLabel: e,
  title: t,
  fill: n,
  fillOpacity: r,
  stroke: i,
  strokeOpacity: s,
  strokeWidth: o,
  opacity: a,
  href: c
}, { tip: u }) {
  return [e, u ? void 0 : t, n, r, i, s, o, a, c].filter((l) => l !== void 0);
}
function Vg(e, t, n) {
  const r = ci(e, (i) => t[i]);
  return n === void 0 && r.size > 1 + e.length >> 1 && ti(
    "Warning: the implicit z channel has high cardinality. This may occur when the fill or stroke channel is associated with quantitative data rather than ordinal or categorical data. You can suppress this warning by setting the z option explicitly; if this data represents a single series, set z to null."
  ), r.values();
}
function* h$(e, t, n, r) {
  const { z: i } = n, { z: s } = r, o = SW(r, n), a = [...t, ...o];
  for (const c of s ? Vg(e, s, i) : [e]) {
    let u, l;
    t: for (const f of c) {
      for (const h of a)
        if (!Pe(h[f])) {
          l && l.push(-1);
          continue t;
        }
      if (u === void 0) {
        l && (yield l), u = o.map((h) => ds(h[f])), l = [f];
        continue;
      }
      l.push(f);
      for (let h = 0; h < o.length; ++h)
        if (ds(o[h][f]) !== u[h]) {
          yield l, u = o.map((p) => ds(p[f])), l = [f];
          continue t;
        }
    }
    l && (yield l);
  }
}
function MW(e, t, n, r) {
  let i;
  const { clip: s = r.clip } = t;
  switch (s) {
    case "frame": {
      const { width: o, height: a, marginLeft: c, marginRight: u, marginTop: l, marginBottom: f } = n, h = Ly();
      i = `url(#${h})`, e = Ot("svg:g", r).call(
        (d) => d.append("svg:clipPath").attr("id", h).append("rect").attr("x", c).attr("y", l).attr("width", o - u - c).attr("height", a - l - f)
      ).each(function() {
        this.appendChild(e.node()), e.node = () => this;
      });
      break;
    }
    case "sphere": {
      const { projection: o } = r;
      if (!o) throw new Error('the "sphere" clip option requires a projection');
      const a = Ly();
      i = `url(#${a})`, e.append("clipPath").attr("id", a).append("path").attr("d", Hi(o)({ type: "Sphere" }));
      break;
    }
  }
  at(e, "aria-label", t.ariaLabel), at(e, "aria-description", t.ariaDescription), at(e, "aria-hidden", t.ariaHidden), at(e, "clip-path", i);
}
function ne(e, t, n, r) {
  MW(e, t, n, r), at(e, "fill", t.fill), at(e, "fill-opacity", t.fillOpacity), at(e, "stroke", t.stroke), at(e, "stroke-width", t.strokeWidth), at(e, "stroke-opacity", t.strokeOpacity), at(e, "stroke-linejoin", t.strokeLinejoin), at(e, "stroke-linecap", t.strokeLinecap), at(e, "stroke-miterlimit", t.strokeMiterlimit), at(e, "stroke-dasharray", t.strokeDasharray), at(e, "stroke-dashoffset", t.strokeDashoffset), at(e, "shape-rendering", t.shapeRendering), at(e, "filter", t.imageFilter), at(e, "paint-order", t.paintOrder);
  const { pointerEvents: i = r.pointerSticky === !1 ? "none" : void 0 } = t;
  at(e, "pointer-events", i);
}
function te(e, t) {
  AW(e, "mix-blend-mode", t.mixBlendMode), at(e, "opacity", t.opacity);
}
function d$(e, t, n) {
  e.each(function(r) {
    const i = t(r);
    if (i != null) {
      const s = this.ownerDocument.createElementNS(Es.svg, "a");
      s.setAttribute("fill", "inherit"), s.setAttributeNS(Es.xlink, "href", i), n != null && s.setAttribute("target", n), this.parentNode.insertBefore(s, this).appendChild(this);
    }
  });
}
function at(e, t, n) {
  n != null && e.attr(t, n);
}
function AW(e, t, n) {
  n != null && e.style(t, n);
}
function Gt(e, t, { x: n, y: r }, i = Ae, s = Ae) {
  i += t.dx, s += t.dy, n != null && n.bandwidth && (i += n.bandwidth() / 2), r != null && r.bandwidth && (s += r.bandwidth() / 2), (i || s) && e.attr("transform", `translate(${i},${s})`);
}
function oe(e, t) {
  if ((e = Ne(e)) !== t) return e;
}
function Pa(e, t) {
  if ((e = Nt(e)) !== t) return e;
}
const $W = /^-?([_a-z]|[\240-\377]|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])([_a-z0-9-]|[\240-\377]|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])*$/i;
function Yg(e) {
  if (e === void 0) return "plot-d6a7b5";
  if (e = `${e}`, !$W.test(e)) throw new Error(`invalid class name: ${e}`);
  return e;
}
function Wg(e, t) {
  if (typeof t == "string")
    e.property("style", t);
  else if (t != null)
    for (const n of e)
      Object.assign(n.style, t);
}
function $r({ frameAnchor: e }, { width: t, height: n, marginTop: r, marginRight: i, marginBottom: s, marginLeft: o }) {
  return [
    /left$/.test(e) ? o : /right$/.test(e) ? t - i : (o + t - i) / 2,
    /^top/.test(e) ? r : /^bottom/.test(e) ? n - s : (r + n - s) / 2
  ];
}
let Ht = class {
  constructor(t, n = {}, r = {}, i) {
    const {
      facet: s = "auto",
      facetAnchor: o,
      fx: a,
      fy: c,
      sort: u,
      dx: l = 0,
      dy: f = 0,
      margin: h = 0,
      marginTop: d = h,
      marginRight: p = h,
      marginBottom: y = h,
      marginLeft: m = h,
      clip: g = i == null ? void 0 : i.clip,
      channels: b,
      tip: w,
      render: _
    } = r;
    if (this.data = t, this.sort = Ui(u) ? u : null, this.initializer = tn(r).initializer, this.transform = this.initializer ? r.transform : Ar(r).transform, s === null || s === !1 ? this.facet = null : (this.facet = hn(s === !0 ? "include" : s, "facet", ["auto", "include", "exclude", "super"]), this.fx = t === gc && typeof a == "string" ? [a] : a, this.fy = t === gc && typeof c == "string" ? [c] : c), this.facetAnchor = QY(o), n = Sg(n), b !== void 0 && (n = { ...IW(b), ...n }), i !== void 0 && (n = { ...f$(this, r, i), ...n }), this.channels = Object.fromEntries(
      Object.entries(n).map(([x, v]) => {
        if (rr(v.value)) {
          const { value: M, label: E = v.label, scale: $ = v.scale } = v.value;
          v = { ...v, label: E, scale: $, value: M };
        }
        if (t === gc && typeof v.value == "string") {
          const { value: M } = v;
          v = { ...v, value: [M] };
        }
        return [x, v];
      }).filter(([x, { value: v, optional: M }]) => {
        if (v != null) return !0;
        if (M) return !1;
        throw new Error(`missing channel value: ${x}`);
      })
    ), this.dx = +l, this.dy = +f, this.marginTop = +d, this.marginRight = +p, this.marginBottom = +y, this.marginLeft = +m, this.clip = MA(g), this.tip = TW(w), this.facet === "super") {
      if (a || c) throw new Error("super-faceting cannot use fx or fy");
      for (const x in this.channels) {
        const { scale: v } = n[x];
        if (!(v !== "x" && v !== "y"))
          throw new Error("super-faceting cannot use x or y");
      }
    }
    _ != null && (this.render = $h(_, this.render));
  }
  initialize(t, n, r) {
    let i = Qe(this.data);
    t === void 0 && i != null && (t = [ui(i)]);
    const s = t;
    this.transform != null && ({ facets: t, data: i } = this.transform(i, t, r), i = Qe(i)), t !== void 0 && (t.original = s);
    const o = BA(this.channels, i);
    return this.sort != null && nY(i, t, o, n, this.sort), { data: i, facets: t, channels: o };
  }
  filter(t, n, r) {
    for (const i in n) {
      const { filter: s = Pe } = n[i];
      if (s !== null) {
        const o = r[i];
        t = t.filter((a) => s(o[a]));
      }
    }
    return t;
  }
  // If there is a projection, and there are paired x and y channels associated
  // with the x and y scale respectively (and not already in screen coordinates
  // as with an initializer), then apply the projection, replacing the x and y
  // values. Note that the x and y scales themselves don’t exist if there is a
  // projection, but whether the channels are associated with scales still
  // determines whether the projection should apply; think of the projection as
  // a combination xy-scale.
  project(t, n, r) {
    for (const i in t)
      if (t[i].scale === "x" && /^x|x$/.test(i)) {
        const s = i.replace(/^x|x$/, "y");
        s in t && t[s].scale === "y" && c$(i, s, n, r.projection);
      }
  }
  scale(t, n, r) {
    const i = Bg(t, n);
    return r.projection && this.project(t, i, r), i;
  }
};
function En(...e) {
  return e.plot = Ht.prototype.plot, e;
}
function $h(e, t) {
  if (e == null) return t === null ? void 0 : t;
  if (t == null) return e === null ? void 0 : e;
  if (typeof e != "function") throw new TypeError(`invalid render transform: ${e}`);
  if (typeof t != "function") throw new TypeError(`invalid render transform: ${t}`);
  return function(n, r, i, s, o, a) {
    return e.call(this, n, r, i, s, o, (c, u, l, f, h) => t.call(this, c, u, l, f, h, a));
  };
}
function IW(e) {
  return Object.fromEntries(
    Object.entries(Sg(e)).map(([t, n]) => (n = typeof n == "string" ? { value: n, label: t } : _a(n), n.filter === void 0 && n.scale == null && (n = { ...n, filter: null }), [t, n]))
  );
}
function TW(e) {
  return e === !0 ? "xy" : e === !1 || e == null ? null : typeof e == "string" ? hn(e, "tip", ["x", "y", "xy"]) : e;
}
function qs(e, t) {
  return (e == null ? void 0 : e.tip) === !0 ? { ...e, tip: t } : Nn(e == null ? void 0 : e.tip) && e.tip.pointer === void 0 ? { ...e, tip: { ...e.tip, pointer: t } } : e;
}
function EW(e, t, n = {}) {
  let r = 0.5 - Ae, i = 0.5 + Ae, s = 0.5 + Ae, o = 0.5 - Ae;
  for (const { marginTop: y, marginRight: m, marginBottom: g, marginLeft: b } of t)
    y > r && (r = y), m > i && (i = m), g > s && (s = g), b > o && (o = b);
  let {
    margin: a,
    marginTop: c = a !== void 0 ? a : r,
    marginRight: u = a !== void 0 ? a : i,
    marginBottom: l = a !== void 0 ? a : s,
    marginLeft: f = a !== void 0 ? a : o
  } = n;
  c = +c, u = +u, l = +l, f = +f;
  let {
    width: h = 640,
    height: d = NW(e, n, {
      width: h,
      marginTopDefault: r,
      marginRightDefault: i,
      marginBottomDefault: s,
      marginLeftDefault: o
    }) + Math.max(0, c - r + l - s)
  } = n;
  h = +h, d = +d;
  const p = {
    width: h,
    height: d,
    marginTop: c,
    marginRight: u,
    marginBottom: l,
    marginLeft: f
  };
  if (e.fx || e.fy) {
    let {
      margin: y,
      marginTop: m = y !== void 0 ? y : c,
      marginRight: g = y !== void 0 ? y : u,
      marginBottom: b = y !== void 0 ? y : l,
      marginLeft: w = y !== void 0 ? y : f
    } = n.facet ?? {};
    m = +m, g = +g, b = +b, w = +w, p.facet = {
      marginTop: m,
      marginRight: g,
      marginBottom: b,
      marginLeft: w
    };
  }
  return p;
}
function NW({ x: e, y: t, fy: n, fx: r }, { projection: i, aspectRatio: s }, { width: o, marginTopDefault: a, marginRightDefault: c, marginBottomDefault: u, marginLeftDefault: l }) {
  const f = n ? n.scale.domain().length : 1, h = lW(i);
  if (h) {
    const p = r ? r.scale.domain().length : 1, y = (1.1 * f - 0.1) / (1.1 * p - 0.1) * h, m = Math.max(0.1, Math.min(10, y));
    return Math.round((o - l - c) * m + a + u);
  }
  const d = t ? zs(t) ? t.scale.domain().length : Math.max(7, 17 / f) : 1;
  if (s != null) {
    if (s = +s, !(isFinite(s) && s > 0)) throw new Error(`invalid aspectRatio: ${s}`);
    const p = F2("y", t) / (F2("x", e) * s), y = r ? r.scale.bandwidth() : 1, m = n ? n.scale.bandwidth() : 1, g = y * (o - l - c) - e.insetLeft - e.insetRight;
    return (p * g + t.insetTop + t.insetBottom) / m + a + u;
  }
  return !!(t || n) * Math.max(1, Math.min(60, d * f)) * 20 + !!r * 30 + 60;
}
function F2(e, t) {
  if (!t) throw new Error(`aspectRatio requires ${e} scale`);
  const { type: n, domain: r } = t;
  let i;
  switch (n) {
    case "linear":
    case "utc":
    case "time":
      i = Number;
      break;
    case "pow": {
      const a = t.scale.exponent();
      i = (c) => Math.pow(c, a);
      break;
    }
    case "log":
      i = Math.log;
      break;
    case "point":
    case "band":
      return r.length;
    default:
      throw new Error(`unsupported ${e} scale for aspectRatio: ${n}`);
  }
  const [s, o] = pe(r);
  return Math.abs(i(o) - i(s));
}
const B2 = /* @__PURE__ */ new WeakMap();
function Xg(e, t, { x: n, y: r, px: i, py: s, maxRadius: o = 40, channels: a, render: c, ...u } = {}) {
  return o = +o, i != null && (n ?? (n = null), a = { ...a, px: { value: i, scale: "x" } }), s != null && (r ?? (r = null), a = { ...a, py: { value: s, scale: "y" } }), {
    x: n,
    y: r,
    channels: a,
    ...u,
    // Unlike other composed transforms, the render transform must be the
    // outermost render function because it will re-render dynamically in
    // response to pointer events.
    render: $h(function(l, f, h, d, p, y) {
      p = { ...p, pointerSticky: !1 };
      const m = p.ownerSVGElement, { data: g } = p.getMarkState(this);
      let b = B2.get(m);
      b || B2.set(m, b = { sticky: !1, roots: [], renders: [] });
      let w = b.renders.push(Y) - 1;
      const { x: _, y: x, fx: v, fy: M } = f;
      let E = v ? v(l.fx) - d.marginLeft : 0, $ = M ? M(l.fy) - d.marginTop : 0;
      _ != null && _.bandwidth && (E += _.bandwidth() / 2), x != null && x.bandwidth && ($ += x.bandwidth() / 2);
      const N = l.fi != null;
      let A;
      if (N) {
        let V = b.facetStates;
        V || (b.facetStates = V = /* @__PURE__ */ new Map()), A = V.get(this), A || V.set(this, A = /* @__PURE__ */ new Map());
      }
      const [D, k] = $r(this, d), { px: S, py: I } = h, T = S ? (V) => S[V] : p$(h, D), R = I ? (V) => I[V] : y$(h, k);
      let B, C, F, P;
      function U(V, W) {
        if (N)
          if (P && (P = cancelAnimationFrame(P)), V == null) A.delete(l.fi);
          else {
            A.set(l.fi, W), P = requestAnimationFrame(() => {
              P = null;
              for (const [q, X] of A)
                if (X < W || X === W && q < l.fi) {
                  V = null;
                  break;
                }
              Y(V);
            });
            return;
          }
        Y(V);
      }
      function Y(V) {
        if (B === V && F === b.sticky) return;
        B = V, F = p.pointerSticky = b.sticky;
        const W = B == null ? [] : [B];
        N && (W.fx = l.fx, W.fy = l.fy, W.fi = l.fi);
        const q = y(W, f, h, d, p);
        if (C) {
          if (N) {
            const X = C.parentNode, Z = C.getAttribute("transform"), z = q.getAttribute("transform");
            Z ? q.setAttribute("transform", Z) : q.removeAttribute("transform"), z ? X.setAttribute("transform", z) : X.removeAttribute("transform"), q.removeAttribute("aria-label"), q.removeAttribute("aria-description"), q.removeAttribute("aria-hidden");
          }
          C.replaceWith(q);
        }
        return b.roots[w] = C = q, B == null && (A == null ? void 0 : A.size) > 1 || p.dispatchValue(B == null ? null : g[B]), q;
      }
      function G(V) {
        if (b.sticky || V.pointerType === "mouse" && V.buttons === 1) return;
        let [W, q] = Ln(V);
        W -= E, q -= $;
        const X = W < d.marginLeft || W > d.width - d.marginRight ? 1 : e, Z = q < d.marginTop || q > d.height - d.marginBottom ? 1 : t;
        let z = null, wt = o * o;
        for (const tt of l) {
          const It = X * (T(tt) - W), Et = Z * (R(tt) - q), J = It * It + Et * Et;
          J <= wt && (z = tt, wt = J);
        }
        if (z != null && (e !== 1 || t !== 1)) {
          const tt = T(z) - W, It = R(z) - q;
          wt = tt * tt + It * It;
        }
        U(z, wt);
      }
      function K(V) {
        V.pointerType === "mouse" && B != null && (b.sticky && b.roots.some((W) => W == null ? void 0 : W.contains(V.target)) || (b.sticky ? (b.sticky = !1, b.renders.forEach((W) => W(null))) : (b.sticky = !0, Y(B)), V.stopImmediatePropagation()));
      }
      function H(V) {
        V.pointerType === "mouse" && (b.sticky || U(null));
      }
      return m.addEventListener("pointerenter", G), m.addEventListener("pointermove", G), m.addEventListener("pointerdown", K), m.addEventListener("pointerleave", H), Y(null);
    }, c)
  };
}
function Cd(e) {
  return Xg(1, 1, e);
}
function Pd(e) {
  return Xg(1, 0.01, e);
}
function Zc(e) {
  return Xg(0.01, 1, e);
}
function p$({ x1: e, x2: t, x: n = e }, r) {
  return e && t ? (i) => (e[i] + t[i]) / 2 : n ? (i) => n[i] : () => r;
}
function y$({ y1: e, y2: t, y: n = e }, r) {
  return e && t ? (i) => (e[i] + t[i]) / 2 : n ? (i) => n[i] : () => r;
}
function m$(e) {
  return zs(e) && e.interval === void 0 ? void 0 : "tabular-nums";
}
function DW(e, t) {
  let {
    label: n = e.label,
    tickSize: r = 6,
    width: i = 240,
    height: s = 44 + r,
    marginTop: o = 18,
    marginRight: a = 0,
    marginBottom: c = 16 + r,
    marginLeft: u = 0,
    style: l,
    ticks: f = (i - u - a) / 64,
    tickFormat: h,
    fontVariant: d = m$(e),
    round: p = !0,
    opacity: y,
    className: m
  } = t;
  const g = Bd(t);
  m = Yg(m), y = fe(y)[1], h === null && (h = () => null);
  const b = Ot("svg", g).attr("class", `${m}-ramp`).attr("font-family", "system-ui, sans-serif").attr("font-size", 10).attr("width", i).attr("height", s).attr("viewBox", `0 0 ${i} ${s}`).call(
    (D) => (
      // Warning: if you edit this, change defaultClassName.
      D.append("style").text(
        `:where(.${m}-ramp) {
  display: block;
  height: auto;
  height: intrinsic;
  max-width: 100%;
  overflow: visible;
}
:where(.${m}-ramp text) {
  white-space: pre;
}`
      )
    )
  ).call(Wg, l);
  let w = (D) => D.selectAll(".tick line").attr("y1", o + c - s), _;
  const x = p ? (D, k) => D.rangeRound(k) : (D, k) => D.range(k), { type: v, domain: M, range: E, interpolate: $, scale: N, pivot: A } = e;
  if ($) {
    const D = E === void 0 ? $ : sd($.length === 1 ? Ug($) : $, E);
    _ = x(
      N.copy(),
      jn(
        Ee(u, i - a),
        Math.min(M.length + (A !== void 0), E === void 0 ? 1 / 0 : E.length)
      )
    );
    const k = 256, S = g.document.createElement("canvas");
    S.width = k, S.height = 1;
    const I = S.getContext("2d");
    for (let T = 0, R = k - 1; T < k; ++T)
      I.fillStyle = D(T / R), I.fillRect(T, 0, 1, 1);
    b.append("image").attr("opacity", y).attr("x", u).attr("y", o).attr("width", i - u - a).attr("height", s - o - c).attr("preserveAspectRatio", "none").attr("xlink:href", S.toDataURL());
  } else if (v === "threshold") {
    const D = M, k = h === void 0 ? (S) => S : typeof h == "string" ? ga(h) : h;
    _ = x(dd().domain([-1, E.length - 1]), [u, i - a]), b.append("g").attr("fill-opacity", y).selectAll().data(E).enter().append("rect").attr("x", (S, I) => _(I - 1)).attr("y", o).attr("width", (S, I) => _(I) - _(I - 1)).attr("height", s - o - c).attr("fill", (S) => S), f = Zt(D, (S, I) => I), h = (S) => k(D[S], S);
  } else
    _ = x(fd().domain(M), [u, i - a]), b.append("g").attr("fill-opacity", y).selectAll().data(M).enter().append("rect").attr("x", _).attr("y", o).attr("width", Math.max(0, _.bandwidth() - 1)).attr("height", s - o - c).attr("fill", N), w = () => {
    };
  return b.append("g").attr("transform", `translate(0,${s - c})`).call(
    Nk(_).ticks(Array.isArray(f) ? null : f, typeof h == "string" ? h : void 0).tickFormat(typeof h == "function" ? h : void 0).tickSize(r).tickValues(Array.isArray(f) ? f : null)
  ).attr("font-size", null).attr("font-family", null).attr("font-variant", oe(d, "normal")).call(w).call((D) => D.select(".domain").remove()), n !== void 0 && b.append("text").attr("x", u).attr("y", o - 6).attr("fill", "currentColor").attr("font-weight", "bold").text(n), b.node();
}
const Ih = Math.PI / 180;
function va(e, { marker: t, markerStart: n = t, markerMid: r = t, markerEnd: i = t } = {}) {
  e.markerStart = e0(n), e.markerMid = e0(r), e.markerEnd = e0(i);
}
function e0(e) {
  if (e == null || e === !1) return null;
  if (e === !0) return P2;
  if (typeof e == "function") return e;
  switch (`${e}`.toLowerCase()) {
    case "none":
      return null;
    case "arrow":
      return C2("auto");
    case "arrow-reverse":
      return C2("auto-start-reverse");
    case "dot":
      return OW;
    case "circle":
    case "circle-fill":
      return P2;
    case "circle-stroke":
      return LW;
    case "tick":
      return n0("auto");
    case "tick-x":
      return n0(90);
    case "tick-y":
      return n0(0);
  }
  throw new Error(`invalid marker: ${e}`);
}
function C2(e) {
  return (t, n) => Ot("svg:marker", n).attr("viewBox", "-5 -5 10 10").attr("markerWidth", 6.67).attr("markerHeight", 6.67).attr("orient", e).attr("fill", "none").attr("stroke", t).attr("stroke-width", 1.5).attr("stroke-linecap", "round").attr("stroke-linejoin", "round").call((r) => r.append("path").attr("d", "M-1.5,-3l3,3l-3,3")).node();
}
function OW(e, t) {
  return Ot("svg:marker", t).attr("viewBox", "-5 -5 10 10").attr("markerWidth", 6.67).attr("markerHeight", 6.67).attr("fill", e).attr("stroke", "none").call((n) => n.append("circle").attr("r", 2.5)).node();
}
function P2(e, t) {
  return Ot("svg:marker", t).attr("viewBox", "-5 -5 10 10").attr("markerWidth", 6.67).attr("markerHeight", 6.67).attr("fill", e).attr("stroke", "var(--plot-background)").attr("stroke-width", 1.5).call((n) => n.append("circle").attr("r", 3)).node();
}
function LW(e, t) {
  return Ot("svg:marker", t).attr("viewBox", "-5 -5 10 10").attr("markerWidth", 6.67).attr("markerHeight", 6.67).attr("fill", "var(--plot-background)").attr("stroke", e).attr("stroke-width", 1.5).call((n) => n.append("circle").attr("r", 3)).node();
}
function n0(e) {
  return (t, n) => Ot("svg:marker", n).attr("viewBox", "-3 -3 6 6").attr("markerWidth", 6).attr("markerHeight", 6).attr("orient", e).attr("stroke", t).call((r) => r.append("path").attr("d", "M0,-3v6")).node();
}
let RW = 0;
function ku(e, t, { stroke: n }, r) {
  return g$(e, t, n && ((i) => n[i]), r);
}
function kW(e, t, { stroke: n }, r) {
  return g$(e, t, n && (([i]) => n[i]), r);
}
function g$(e, { markerStart: t, markerMid: n, markerEnd: r, stroke: i }, s = () => i, o) {
  const a = /* @__PURE__ */ new Map();
  function c(u) {
    return function(l) {
      const f = s(l);
      let h = a.get(u);
      h || a.set(u, h = /* @__PURE__ */ new Map());
      let d = h.get(f);
      if (!d) {
        const p = this.parentNode.insertBefore(u(f, o), this), y = `plot-marker-${++RW}`;
        p.setAttribute("id", y), h.set(f, d = `url(#${y})`);
      }
      return d;
    };
  }
  t && e.attr("marker-start", c(t)), n && e.attr("marker-mid", c(n)), r && e.attr("marker-end", c(r));
}
function Fu({ inset: e, insetLeft: t, insetRight: n, ...r } = {}) {
  return [t, n] = b$(e, t, n), { inset: e, insetLeft: t, insetRight: n, ...r };
}
function Bu({ inset: e, insetTop: t, insetBottom: n, ...r } = {}) {
  return [t, n] = b$(e, t, n), { inset: e, insetTop: t, insetBottom: n, ...r };
}
function b$(e, t, n) {
  return e === void 0 && t === void 0 && n === void 0 ? Ae ? [1, 0] : [0.5, 0.5] : [t, n];
}
function w$(e, { interval: t }) {
  return e = { ..._a(e) }, e.interval = Td(e.interval === void 0 ? t : e.interval), e;
}
function Ud(e, t, n, r) {
  const { [e]: i, [`${e}1`]: s, [`${e}2`]: o } = n, { value: a, interval: c } = w$(i, n);
  if (a == null || c == null && !r) return n;
  const u = Mr(i);
  if (c == null) {
    let d;
    const p = { transform: (y) => d || (d = $t(y, a)), label: u };
    return {
      ...n,
      [e]: void 0,
      [`${e}1`]: s === void 0 ? p : s,
      [`${e}2`]: o === void 0 && !(s === o && r) ? p : o
    };
  }
  let l, f;
  function h(d) {
    return f !== void 0 && d === l ? f : f = Zt($t(l = d, a), (p) => c.floor(p));
  }
  return t({
    ...n,
    [e]: void 0,
    [`${e}1`]: s === void 0 ? { transform: h, label: u } : s,
    [`${e}2`]: o === void 0 ? { transform: (d) => h(d).map((p) => c.offset(p)), label: u } : o
  });
}
function _$(e, t, n) {
  const { [e]: r } = n, { value: i, interval: s } = w$(r, n);
  return i == null || s == null ? n : t({
    ...n,
    [e]: {
      label: Mr(r),
      transform: (o) => {
        const a = Zt($t(o, i), (u) => s.floor(u)), c = a.map((u) => s.offset(u));
        return a.map(
          qe(a) ? (u, l) => u == null || isNaN(u = +u) || (l = c[l], l == null) || isNaN(l = +l) ? void 0 : new Date((u + l) / 2) : (u, l) => u == null || (l = c[l], l == null) ? NaN : (+u + +l) / 2
        );
      }
    }
  });
}
function v$(e = {}) {
  return Ud("x", Fu, e, !0);
}
function x$(e = {}) {
  return Ud("y", Bu, e, !0);
}
function S$(e = {}) {
  return Ud("x", Fu, e);
}
function M$(e = {}) {
  return Ud("y", Bu, e);
}
function A$(e = {}) {
  return _$("x", Fu, e);
}
function $$(e = {}) {
  return _$("y", Bu, e);
}
const I$ = {
  ariaLabel: "rule",
  fill: null,
  stroke: "currentColor"
};
class T$ extends Ht {
  constructor(t, n = {}) {
    const { x: r, y1: i, y2: s, inset: o = 0, insetTop: a = o, insetBottom: c = o } = n;
    super(
      t,
      {
        x: { value: r, scale: "x", optional: !0 },
        y1: { value: i, scale: "y", optional: !0 },
        y2: { value: s, scale: "y", optional: !0 }
      },
      qs(n, "x"),
      I$
    ), this.insetTop = Nt(a), this.insetBottom = Nt(c), va(this, n);
  }
  render(t, n, r, i, s) {
    const { x: o, y: a } = n, { x: c, y1: u, y2: l } = r, { width: f, height: h, marginTop: d, marginRight: p, marginLeft: y, marginBottom: m } = i, { insetTop: g, insetBottom: b } = this;
    return Ot("svg:g", s).call(ne, this, i, s).call(Gt, this, { x: c && o }, Ae, 0).call(
      (w) => w.selectAll().data(t).enter().append("line").call(te, this).attr("x1", c ? (_) => c[_] : (y + f - p) / 2).attr("x2", c ? (_) => c[_] : (y + f - p) / 2).attr("y1", u && !Mn(a) ? (_) => u[_] + g : d + g).attr(
        "y2",
        l && !Mn(a) ? a.bandwidth ? (_) => l[_] + a.bandwidth() - b : (_) => l[_] - b : h - m - b
      ).call(ge, this, r).call(ku, this, r, s)
    ).node();
  }
}
class E$ extends Ht {
  constructor(t, n = {}) {
    const { x1: r, x2: i, y: s, inset: o = 0, insetRight: a = o, insetLeft: c = o } = n;
    super(
      t,
      {
        y: { value: s, scale: "y", optional: !0 },
        x1: { value: r, scale: "x", optional: !0 },
        x2: { value: i, scale: "x", optional: !0 }
      },
      qs(n, "y"),
      I$
    ), this.insetRight = Nt(a), this.insetLeft = Nt(c), va(this, n);
  }
  render(t, n, r, i, s) {
    const { x: o, y: a } = n, { y: c, x1: u, x2: l } = r, { width: f, height: h, marginTop: d, marginRight: p, marginLeft: y, marginBottom: m } = i, { insetLeft: g, insetRight: b } = this;
    return Ot("svg:g", s).call(ne, this, i, s).call(Gt, this, { y: c && a }, 0, Ae).call(
      (w) => w.selectAll().data(t).enter().append("line").call(te, this).attr("x1", u && !Mn(o) ? (_) => u[_] + g : y + g).attr(
        "x2",
        l && !Mn(o) ? o.bandwidth ? (_) => l[_] + o.bandwidth() - b : (_) => l[_] - b : f - p - b
      ).attr("y1", c ? (_) => c[_] : (d + h - m) / 2).attr("y2", c ? (_) => c[_] : (d + h - m) / 2).call(ge, this, r).call(ku, this, r, s)
    ).node();
  }
}
function zi(e, t) {
  let { x: n = yt, y: r, y1: i, y2: s, ...o } = M$(t);
  return [i, s] = N$(r, i, s), new T$(e, { ...o, x: n, y1: i, y2: s });
}
function qi(e, t) {
  let { y: n = yt, x: r, x1: i, x2: s, ...o } = S$(t);
  return [i, s] = N$(r, i, s), new E$(e, { ...o, y: n, x1: i, x2: s });
}
function N$(e, t, n) {
  if (e == null) {
    if (t === void 0) {
      if (n !== void 0) return [0, n];
    } else if (n === void 0) return [0, t];
  } else {
    if (t === void 0)
      return n === void 0 ? [0, e] : [e, n];
    if (n === void 0)
      return [e, t];
  }
  return [t, n];
}
function zd(e, ...t) {
  let n = t.length;
  for (let r = 0, i = !0; r < n; ++r)
    typeof t[r] != "function" && (i && (e = e.slice(), i = !1), e.splice(r, 2, e[r] + t[r] + e[r + 1]), t.splice(r, 1), --r, --n);
  return (r) => {
    let i = e[0];
    for (let s = 0; s < n; ++s)
      i += t[s](r) + e[s + 1];
    return i;
  };
}
const FW = {
  ariaLabel: "text",
  strokeLinejoin: "round",
  strokeWidth: 3,
  paintOrder: "stroke"
}, D$ = "­";
class qd extends Ht {
  constructor(t, n = {}) {
    const {
      x: r,
      y: i,
      text: s = li(t) && SA(t) ? yt : Ve,
      frameAnchor: o,
      textAnchor: a = /right$/i.test(o) ? "end" : /left$/i.test(o) ? "start" : "middle",
      lineAnchor: c = /^top/i.test(o) ? "top" : /^bottom/i.test(o) ? "bottom" : "middle",
      lineHeight: u = 1,
      lineWidth: l = 1 / 0,
      textOverflow: f,
      monospace: h,
      fontFamily: d = h ? "ui-monospace, monospace" : void 0,
      fontSize: p,
      fontStyle: y,
      fontVariant: m,
      fontWeight: g,
      rotate: b
    } = n, [w, _] = fe(b, 0), [x, v] = UW(p);
    if (super(
      t,
      {
        x: { value: r, scale: "x", optional: !0 },
        y: { value: i, scale: "y", optional: !0 },
        fontSize: { value: x, optional: !0 },
        rotate: { value: $V(w), optional: !0 },
        text: { value: s, filter: pg, optional: !0 }
      },
      n,
      FW
    ), this.rotate = _, this.textAnchor = oe(a, "middle"), this.lineAnchor = hn(c, "lineAnchor", ["top", "middle", "bottom"]), this.lineHeight = +u, this.lineWidth = +l, this.textOverflow = O$(f), this.monospace = !!h, this.fontFamily = Ne(d), this.fontSize = v, this.fontStyle = Ne(y), this.fontVariant = Ne(m), this.fontWeight = Ne(g), this.frameAnchor = Eu(o), !(this.lineWidth >= 0)) throw new Error(`invalid lineWidth: ${l}`);
    this.splitLines = F$(this), this.clipLine = B$(this);
  }
  render(t, n, r, i, s) {
    const { x: o, y: a } = n, { x: c, y: u, rotate: l, text: f, title: h, fontSize: d } = r, { rotate: p } = this, [y, m] = $r(this, i);
    return Ot("svg:g", s).call(ne, this, i, s).call(k$, this, f, i).call(Gt, this, { x: c && o, y: u && a }).call(
      (g) => g.selectAll().data(t).enter().append("text").call(te, this).call(BW, this, f, h).attr(
        "transform",
        zd`translate(${c ? (b) => c[b] : y},${u ? (b) => u[b] : m})${l ? (b) => ` rotate(${l[b]})` : p ? ` rotate(${p})` : ""}`
      ).call(at, "font-size", d && ((b) => d[b])).call(ge, this, r)
    ).node();
  }
}
function O$(e) {
  return e == null ? null : hn(e, "textOverflow", [
    "clip",
    // shorthand for clip-end
    "ellipsis",
    // … ellipsis-end
    "clip-start",
    "clip-end",
    "ellipsis-start",
    "ellipsis-middle",
    "ellipsis-end"
  ]).replace(/^(clip|ellipsis)$/, "$1-end");
}
function BW(e, t, n, r) {
  if (!n) return;
  const { lineAnchor: i, lineHeight: s, textOverflow: o, splitLines: a, clipLine: c } = t;
  e.each(function(u) {
    const l = a(ia(n[u]) ?? "").map(c), f = l.length, h = i === "top" ? 0.71 : i === "bottom" ? 1 - f : (164 - f * 100) / 200;
    if (f > 1) {
      let d = 0;
      for (let p = 0; p < f; ++p) {
        if (++d, !l[p]) continue;
        const y = this.ownerDocument.createElementNS(Es.svg, "tspan");
        y.setAttribute("x", 0), p === d - 1 ? y.setAttribute("y", `${(h + p) * s}em`) : y.setAttribute("dy", `${d * s}em`), y.textContent = l[p], this.appendChild(y), d = 0;
      }
    } else
      h && this.setAttribute("y", `${h * s}em`), this.textContent = l[0];
    if (o && !r && l[0] !== n[u]) {
      const d = this.ownerDocument.createElementNS(Es.svg, "title");
      d.textContent = n[u], this.appendChild(d);
    }
  });
}
function sa(e, { x: t, y: n, ...r } = {}) {
  return r.frameAnchor === void 0 && ([t, n] = Jn(t, n)), new qd(e, { ...r, x: t, y: n });
}
function L$(e, { x: t = yt, ...n } = {}) {
  return new qd(e, $$({ ...n, x: t }));
}
function R$(e, { y: t = yt, ...n } = {}) {
  return new qd(e, A$({ ...n, y: t }));
}
function k$(e, t, n) {
  at(e, "text-anchor", t.textAnchor), at(e, "font-family", t.fontFamily), at(e, "font-size", t.fontSize), at(e, "font-style", t.fontStyle), at(e, "font-variant", t.fontVariant === void 0 ? CW(n) : t.fontVariant), at(e, "font-weight", t.fontWeight);
}
function CW(e) {
  return e && (_o(e) || qe(e)) ? "tabular-nums" : void 0;
}
const PW = /* @__PURE__ */ new Set([
  // global keywords
  "inherit",
  "initial",
  "revert",
  "unset",
  // absolute keywords
  "xx-small",
  "x-small",
  "small",
  "medium",
  "large",
  "x-large",
  "xx-large",
  "xxx-large",
  // relative keywords
  "larger",
  "smaller"
]);
function UW(e) {
  return e == null || typeof e == "number" ? [void 0, e] : typeof e != "string" ? [e, void 0] : (e = e.trim().toLowerCase(), PW.has(e) || /^[+-]?\d*\.?\d+(e[+-]?\d+)?(\w*|%)$/.test(e) ? [void 0, e] : [e, void 0]);
}
function zW(e, t, n) {
  const r = [];
  let i, s = 0;
  for (const [o, a, c] of qW(e)) {
    if (i === void 0 && (i = o), s > i && n(e, i, a) > t && (r.push(e.slice(i, s) + (e[s - 1] === D$ ? "-" : "")), i = o), c) {
      r.push(e.slice(i, a)), i = void 0;
      continue;
    }
    s = a;
  }
  return r;
}
function* qW(e) {
  let t = 0, n = 0;
  const r = e.length;
  for (; n < r; ) {
    let i = 1;
    switch (e[n]) {
      case D$:
      case "-":
        ++n, yield [t, n, !1], t = n;
        break;
      case " ":
        for (yield [t, n, !1]; e[++n] === " "; ) ;
        t = n;
        break;
      case "\r":
        e[n + 1] === `
` && ++i;
      case `
`:
        yield [t, n, !0], n += i, t = n;
        break;
      default:
        ++n;
        break;
    }
  }
  yield [t, n, !0];
}
const U2 = {
  a: 56,
  b: 63,
  c: 57,
  d: 63,
  e: 58,
  f: 37,
  g: 62,
  h: 60,
  i: 26,
  j: 26,
  k: 55,
  l: 26,
  m: 88,
  n: 60,
  o: 60,
  p: 62,
  q: 62,
  r: 39,
  s: 54,
  t: 38,
  u: 60,
  v: 55,
  w: 79,
  x: 54,
  y: 55,
  z: 55,
  A: 69,
  B: 67,
  C: 73,
  D: 74,
  E: 61,
  F: 58,
  G: 76,
  H: 75,
  I: 28,
  J: 55,
  K: 67,
  L: 58,
  M: 89,
  N: 75,
  O: 78,
  P: 65,
  Q: 78,
  R: 67,
  S: 65,
  T: 65,
  U: 75,
  V: 69,
  W: 98,
  X: 69,
  Y: 67,
  Z: 67,
  0: 64,
  1: 48,
  2: 62,
  3: 64,
  4: 66,
  5: 63,
  6: 65,
  7: 58,
  8: 65,
  9: 65,
  " ": 29,
  "!": 32,
  '"': 49,
  "'": 31,
  "(": 39,
  ")": 39,
  ",": 31,
  "-": 48,
  ".": 31,
  "/": 32,
  ":": 31,
  ";": 31,
  "?": 52,
  "‘": 31,
  "’": 31,
  "“": 47,
  "”": 47,
  "…": 82
};
function Gg(e, t = 0, n = e.length) {
  let r = 0;
  for (let i = t; i < n; i = xa(e, i))
    r += U2[e[i]] ?? (P$(e, i) ? 120 : U2.e);
  return r;
}
function Hg(e, t = 0, n = e.length) {
  let r = 0;
  for (let i = t; i < n; i = xa(e, i))
    r += P$(e, i) ? 126 : 63;
  return r;
}
function F$({ monospace: e, lineWidth: t, textOverflow: n }) {
  if (n != null || t == 1 / 0) return (s) => s.split(/\r\n?|\n/g);
  const r = e ? Hg : Gg, i = t * 100;
  return (s) => zW(s, i, r);
}
function B$({ monospace: e, lineWidth: t, textOverflow: n }) {
  if (n == null || t == 1 / 0) return (s) => s;
  const r = e ? Hg : Gg, i = t * 100;
  switch (n) {
    case "clip-start":
      return (s) => q2(s, i, r, "");
    case "clip-end":
      return (s) => z2(s, i, r, "");
    case "ellipsis-start":
      return (s) => q2(s, i, r, Lo);
    case "ellipsis-middle":
      return (s) => jW(s, i, r, Lo);
    case "ellipsis-end":
      return (s) => z2(s, i, r, Lo);
  }
}
const Lo = "…";
function oa(e, t, n, r) {
  const i = [];
  let s = 0;
  for (let o = 0, a = 0, c = e.length; o < c; o = a) {
    a = xa(e, o);
    const u = n(e, o, a);
    if (s + u > t) {
      for (s += r; s > t && o > 0; ) a = o, o = i.pop(), s -= n(e, o, a);
      return [o, t - s];
    }
    s += u, i.push(o);
  }
  return [-1, 0];
}
function z2(e, t, n, r) {
  e = e.trim();
  const i = n(r), [s] = oa(e, t, n, i);
  return s < 0 ? e : e.slice(0, s).trimEnd() + r;
}
function jW(e, t, n, r) {
  e = e.trim();
  const i = n(e);
  if (i <= t) return e;
  const s = n(r) / 2, [o, a] = oa(e, t / 2, n, s), [c] = oa(e, i - t / 2 - a + s, n, -s);
  return c < 0 ? r : e.slice(0, o).trimEnd() + r + e.slice(xa(e, c)).trimStart();
}
function q2(e, t, n, r) {
  e = e.trim();
  const i = n(e);
  if (i <= t) return e;
  const s = n(r), [o] = oa(e, i - t + s, n, -s);
  return o < 0 ? r : r + e.slice(xa(e, o)).trimStart();
}
const Ry = /[\p{Combining_Mark}\p{Emoji_Modifier}]+/uy, j2 = new RegExp("\\p{Extended_Pictographic}", "uy");
function xa(e, t) {
  return t += VW(e, t) ? 2 : 1, WW(e, t) && (t = Ry.lastIndex), YW(e, t) ? xa(e, t + 1) : t;
}
function C$(e, t) {
  return e.charCodeAt(t) < 128;
}
function VW(e, t) {
  const n = e.charCodeAt(t);
  if (n >= 55296 && n < 56320) {
    const r = e.charCodeAt(t + 1);
    return r >= 56320 && r < 57344;
  }
  return !1;
}
function YW(e, t) {
  return e.charCodeAt(t) === 8205;
}
function WW(e, t) {
  return C$(e, t) ? !1 : (Ry.lastIndex = t, Ry.test(e));
}
function P$(e, t) {
  return C$(e, t) ? !1 : (j2.lastIndex = t, j2.test(e));
}
const U$ = {
  ariaLabel: "vector",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1.5,
  strokeLinejoin: "round",
  strokeLinecap: "round"
}, z$ = 3.5, XW = z$ * 5, q$ = {
  draw(e, t, n) {
    const r = t * n / XW;
    e.moveTo(0, 0), e.lineTo(0, -t), e.moveTo(-r, r - t), e.lineTo(0, -t), e.lineTo(r, r - t);
  }
}, j$ = {
  draw(e, t, n) {
    e.moveTo(-n, 0), e.lineTo(0, -t), e.lineTo(n, 0);
  }
}, GW = /* @__PURE__ */ new Map([
  ["arrow", q$],
  ["spike", j$]
]);
function HW(e) {
  return e && typeof e.draw == "function";
}
function JW(e) {
  if (HW(e)) return e;
  const t = GW.get(`${e}`.toLowerCase());
  if (t) return t;
  throw new Error(`invalid shape: ${e}`);
}
class jd extends Ht {
  constructor(t, n = {}) {
    const { x: r, y: i, r: s = z$, length: o, rotate: a, shape: c = q$, anchor: u = "middle", frameAnchor: l } = n, [f, h] = fe(o, 12), [d, p] = fe(a, 0);
    super(
      t,
      {
        x: { value: r, scale: "x", optional: !0 },
        y: { value: i, scale: "y", optional: !0 },
        length: { value: f, scale: "length", optional: !0 },
        rotate: { value: d, optional: !0 }
      },
      n,
      U$
    ), this.r = +s, this.length = h, this.rotate = p, this.shape = JW(c), this.anchor = hn(u, "anchor", ["start", "middle", "end"]), this.frameAnchor = Eu(l);
  }
  render(t, n, r, i, s) {
    const { x: o, y: a } = n, { x: c, y: u, length: l, rotate: f } = r, { length: h, rotate: d, anchor: p, shape: y, r: m } = this, [g, b] = $r(this, i);
    return Ot("svg:g", s).call(ne, this, i, s).call(Gt, this, { x: c && o, y: u && a }).call(
      (w) => w.selectAll().data(t).enter().append("path").call(te, this).attr(
        "transform",
        zd`translate(${c ? (_) => c[_] : g},${u ? (_) => u[_] : b})${f ? (_) => ` rotate(${f[_]})` : d ? ` rotate(${d})` : ""}${p === "start" ? "" : p === "end" ? l ? (_) => ` translate(0,${l[_]})` : ` translate(0,${h})` : l ? (_) => ` translate(0,${l[_] / 2})` : ` translate(0,${h / 2})`}`
      ).attr(
        "d",
        l ? (_) => {
          const x = Gr();
          return y.draw(x, l[_], m), x;
        } : (() => {
          const _ = Gr();
          return y.draw(_, h, m), _;
        })()
      ).call(ge, this, r)
    ).node();
  }
}
function V$(e, t = {}) {
  let { x: n, y: r, ...i } = t;
  return t.frameAnchor === void 0 && ([n, r] = Jn(n, r)), new jd(e, { ...i, x: n, y: r });
}
function Y$(e, t = {}) {
  const { x: n = yt, ...r } = t;
  return new jd(e, { ...r, x: n });
}
function W$(e, t = {}) {
  const { y: n = yt, ...r } = t;
  return new jd(e, { ...r, y: n });
}
function ZW(e, t = {}) {
  const {
    shape: n = j$,
    stroke: r = U$.stroke,
    strokeWidth: i = 1,
    fill: s = r,
    fillOpacity: o = 0.3,
    anchor: a = "start",
    ...c
  } = t;
  return V$(e, { ...c, shape: n, stroke: r, strokeWidth: i, fill: s, fillOpacity: o, anchor: a });
}
function Qi(e, t) {
  return arguments.length < 2 && !li(e) && (t = e, e = null), t === void 0 && (t = {}), [e, t];
}
function Vd({ anchor: e } = {}, t) {
  return e === void 0 ? t[0] : hn(e, "anchor", t);
}
function X$(e) {
  return Vd(e, ["left", "right"]);
}
function G$(e) {
  return Vd(e, ["right", "left"]);
}
function H$(e) {
  return Vd(e, ["bottom", "top"]);
}
function J$(e) {
  return Vd(e, ["top", "bottom"]);
}
function Jg() {
  const [e, t] = Qi(...arguments);
  return Q$("y", X$(t), e, t);
}
function Z$() {
  const [e, t] = Qi(...arguments);
  return Q$("fy", G$(t), e, t);
}
function Zg() {
  const [e, t] = Qi(...arguments);
  return t8("x", H$(t), e, t);
}
function K$() {
  const [e, t] = Qi(...arguments);
  return t8("fx", J$(t), e, t);
}
function Q$(e, t, n, {
  color: r = "currentColor",
  opacity: i = 1,
  stroke: s = r,
  strokeOpacity: o = i,
  strokeWidth: a = 1,
  fill: c = r,
  fillOpacity: u = i,
  textAnchor: l,
  textStroke: f,
  textStrokeOpacity: h,
  textStrokeWidth: d,
  tickSize: p = e === "y" ? 6 : 0,
  tickPadding: y,
  tickRotate: m,
  x: g,
  margin: b,
  marginTop: w = b === void 0 ? 20 : b,
  marginRight: _ = b === void 0 ? t === "right" ? 40 : 0 : b,
  marginBottom: x = b === void 0 ? 20 : b,
  marginLeft: v = b === void 0 ? t === "left" ? 40 : 0 : b,
  label: M,
  labelAnchor: E,
  labelArrow: $,
  labelOffset: N,
  ...A
}) {
  return p = Nt(p), y = Nt(y), m = Nt(m), E !== void 0 && (E = hn(E, "labelAnchor", ["center", "top", "bottom"])), $ = h8($), En(
    p && !ee(s) ? KW(e, t, n, {
      stroke: s,
      strokeOpacity: o,
      strokeWidth: a,
      tickSize: p,
      tickPadding: y,
      tickRotate: m,
      x: g,
      ...A
    }) : null,
    ee(c) ? null : tX(e, t, n, {
      fill: c,
      fillOpacity: u,
      stroke: f,
      strokeOpacity: h,
      strokeWidth: d,
      textAnchor: l,
      tickSize: p,
      tickPadding: y,
      tickRotate: m,
      x: g,
      marginTop: w,
      marginRight: _,
      marginBottom: x,
      marginLeft: v,
      ...A
    }),
    !ee(c) && M !== null ? sa(
      [],
      c8({ fill: c, fillOpacity: u, ...A }, function(D, k, S, I, T) {
        const R = I[e], { marginTop: B, marginRight: C, marginBottom: F, marginLeft: P } = e === "y" && T.inset || T, U = E ?? (R.bandwidth ? "center" : "top"), Y = N ?? (t === "right" ? C : P) - 3;
        return U === "center" ? (this.textAnchor = void 0, this.lineAnchor = t === "right" ? "bottom" : "top", this.frameAnchor = t, this.rotate = -90) : (this.textAnchor = t === "right" ? "end" : "start", this.lineAnchor = U, this.frameAnchor = `${U}-${t}`, this.rotate = 0), this.dy = U === "top" ? 3 - B : U === "bottom" ? F - 3 : 0, this.dx = t === "right" ? Y : -Y, this.ariaLabel = `${e}-axis label`, {
          facets: [[0]],
          channels: { text: { value: [f8(e, R, { anchor: t, label: M, labelAnchor: U, labelArrow: $ })] } }
        };
      })
    ) : null
  );
}
function t8(e, t, n, {
  color: r = "currentColor",
  opacity: i = 1,
  stroke: s = r,
  strokeOpacity: o = i,
  strokeWidth: a = 1,
  fill: c = r,
  fillOpacity: u = i,
  textAnchor: l,
  textStroke: f,
  textStrokeOpacity: h,
  textStrokeWidth: d,
  tickSize: p = e === "x" ? 6 : 0,
  tickPadding: y,
  tickRotate: m,
  y: g,
  margin: b,
  marginTop: w = b === void 0 ? t === "top" ? 30 : 0 : b,
  marginRight: _ = b === void 0 ? 20 : b,
  marginBottom: x = b === void 0 ? t === "bottom" ? 30 : 0 : b,
  marginLeft: v = b === void 0 ? 20 : b,
  label: M,
  labelAnchor: E,
  labelArrow: $,
  labelOffset: N,
  ...A
}) {
  return p = Nt(p), y = Nt(y), m = Nt(m), E !== void 0 && (E = hn(E, "labelAnchor", ["center", "left", "right"])), $ = h8($), En(
    p && !ee(s) ? QW(e, t, n, {
      stroke: s,
      strokeOpacity: o,
      strokeWidth: a,
      tickSize: p,
      tickPadding: y,
      tickRotate: m,
      y: g,
      ...A
    }) : null,
    ee(c) ? null : eX(e, t, n, {
      fill: c,
      fillOpacity: u,
      stroke: f,
      strokeOpacity: h,
      strokeWidth: d,
      textAnchor: l,
      tickSize: p,
      tickPadding: y,
      tickRotate: m,
      y: g,
      marginTop: w,
      marginRight: _,
      marginBottom: x,
      marginLeft: v,
      ...A
    }),
    !ee(c) && M !== null ? sa(
      [],
      c8({ fill: c, fillOpacity: u, ...A }, function(D, k, S, I, T) {
        const R = I[e], { marginTop: B, marginRight: C, marginBottom: F, marginLeft: P } = e === "x" && T.inset || T, U = E ?? (R.bandwidth ? "center" : "right"), Y = N ?? (t === "top" ? B : F) - 3;
        return U === "center" ? (this.frameAnchor = t, this.textAnchor = void 0) : (this.frameAnchor = `${t}-${U}`, this.textAnchor = U === "right" ? "end" : "start"), this.lineAnchor = t, this.dy = t === "top" ? -Y : Y, this.dx = U === "right" ? C - 3 : U === "left" ? 3 - P : 0, this.ariaLabel = `${e}-axis label`, {
          facets: [[0]],
          channels: { text: { value: [f8(e, R, { anchor: t, label: M, labelAnchor: U, labelArrow: $ })] } }
        };
      })
    ) : null
  );
}
function KW(e, t, n, {
  strokeWidth: r = 1,
  strokeLinecap: i = null,
  strokeLinejoin: s = null,
  facetAnchor: o = t + (e === "y" ? "-empty" : ""),
  frameAnchor: a = t,
  tickSize: c,
  inset: u = 0,
  insetLeft: l = u,
  insetRight: f = u,
  dx: h = 0,
  y: d = e === "y" ? void 0 : null,
  ...p
}) {
  return Sa(
    W$,
    e,
    n,
    {
      ariaLabel: `${e}-axis tick`,
      ariaHidden: !0
    },
    {
      strokeWidth: r,
      strokeLinecap: i,
      strokeLinejoin: s,
      facetAnchor: o,
      frameAnchor: a,
      y: d,
      ...p,
      dx: t === "left" ? +h - Ae + +l : +h + Ae - f,
      anchor: "start",
      length: c,
      shape: t === "left" ? sX : oX
    }
  );
}
function QW(e, t, n, {
  strokeWidth: r = 1,
  strokeLinecap: i = null,
  strokeLinejoin: s = null,
  facetAnchor: o = t + (e === "x" ? "-empty" : ""),
  frameAnchor: a = t,
  tickSize: c,
  inset: u = 0,
  insetTop: l = u,
  insetBottom: f = u,
  dy: h = 0,
  x: d = e === "x" ? void 0 : null,
  ...p
}) {
  return Sa(
    Y$,
    e,
    n,
    {
      ariaLabel: `${e}-axis tick`,
      ariaHidden: !0
    },
    {
      strokeWidth: r,
      strokeLinejoin: s,
      strokeLinecap: i,
      facetAnchor: o,
      frameAnchor: a,
      x: d,
      ...p,
      dy: t === "bottom" ? +h - Ae - f : +h + Ae + +l,
      anchor: "start",
      length: c,
      shape: t === "bottom" ? rX : iX
    }
  );
}
function tX(e, t, n, {
  facetAnchor: r = t + (e === "y" ? "-empty" : ""),
  frameAnchor: i = t,
  tickSize: s,
  tickRotate: o = 0,
  tickPadding: a = Math.max(3, 9 - s) + (Math.abs(o) > 60 ? 4 * Math.cos(o * Ih) : 0),
  text: c,
  textAnchor: u = Math.abs(o) > 60 ? "middle" : t === "left" ? "end" : "start",
  lineAnchor: l = o > 60 ? "top" : o < -60 ? "bottom" : "middle",
  fontVariant: f,
  inset: h = 0,
  insetLeft: d = h,
  insetRight: p = h,
  dx: y = 0,
  y: m = e === "y" ? void 0 : null,
  ...g
}) {
  return Sa(
    R$,
    e,
    n,
    { ariaLabel: `${e}-axis tick label` },
    {
      facetAnchor: r,
      frameAnchor: i,
      text: c,
      textAnchor: u,
      lineAnchor: l,
      fontVariant: f,
      rotate: o,
      y: m,
      ...g,
      dx: t === "left" ? +y - s - a + +d : +y + +s + +a - p
    },
    function(b, w, _, x, v) {
      f === void 0 && (this.fontVariant = l8(b)), c === void 0 && (v.text = u8(b, w, _, x, t));
    }
  );
}
function eX(e, t, n, {
  facetAnchor: r = t + (e === "x" ? "-empty" : ""),
  frameAnchor: i = t,
  tickSize: s,
  tickRotate: o = 0,
  tickPadding: a = Math.max(3, 9 - s) + (Math.abs(o) >= 10 ? 4 * Math.cos(o * Ih) : 0),
  text: c,
  textAnchor: u = Math.abs(o) >= 10 ? o < 0 ^ t === "bottom" ? "start" : "end" : "middle",
  lineAnchor: l = Math.abs(o) >= 10 ? "middle" : t === "bottom" ? "top" : "bottom",
  fontVariant: f,
  inset: h = 0,
  insetTop: d = h,
  insetBottom: p = h,
  dy: y = 0,
  x: m = e === "x" ? void 0 : null,
  ...g
}) {
  return Sa(
    L$,
    e,
    n,
    { ariaLabel: `${e}-axis tick label` },
    {
      facetAnchor: r,
      frameAnchor: i,
      text: c === void 0 ? null : c,
      textAnchor: u,
      lineAnchor: l,
      fontVariant: f,
      rotate: o,
      x: m,
      ...g,
      dy: t === "bottom" ? +y + +s + +a - p : +y - s - a + +d
    },
    function(b, w, _, x, v) {
      f === void 0 && (this.fontVariant = l8(b)), c === void 0 && (v.text = u8(b, w, _, x, t));
    }
  );
}
function e8() {
  const [e, t] = Qi(...arguments);
  return s8("y", X$(t), e, t);
}
function n8() {
  const [e, t] = Qi(...arguments);
  return s8("fy", G$(t), e, t);
}
function r8() {
  const [e, t] = Qi(...arguments);
  return o8("x", H$(t), e, t);
}
function i8() {
  const [e, t] = Qi(...arguments);
  return o8("fx", J$(t), e, t);
}
function s8(e, t, n, {
  y: r = e === "y" ? void 0 : null,
  x: i = null,
  x1: s = t === "left" ? i : null,
  x2: o = t === "right" ? i : null,
  ...a
}) {
  return Sa(qi, e, n, { ariaLabel: `${e}-grid`, ariaHidden: !0 }, { y: r, x1: s, x2: o, ...a8(a) });
}
function o8(e, t, n, {
  x: r = e === "x" ? void 0 : null,
  y: i = null,
  y1: s = t === "top" ? i : null,
  y2: o = t === "bottom" ? i : null,
  ...a
}) {
  return Sa(zi, e, n, { ariaLabel: `${e}-grid`, ariaHidden: !0 }, { x: r, y1: s, y2: o, ...a8(a) });
}
function a8({
  color: e = "currentColor",
  opacity: t = 0.1,
  stroke: n = e,
  strokeOpacity: r = t,
  strokeWidth: i = 1,
  ...s
}) {
  return { stroke: n, strokeOpacity: r, strokeWidth: i, ...s };
}
function c8({
  fill: e,
  fillOpacity: t,
  fontFamily: n,
  fontSize: r,
  fontStyle: i,
  fontVariant: s,
  fontWeight: o,
  monospace: a,
  pointerEvents: c,
  shapeRendering: u,
  clip: l = !1
}, f) {
  return [, e] = ze(e), [, t] = fe(t), {
    facet: "super",
    x: null,
    y: null,
    fill: e,
    fillOpacity: t,
    fontFamily: n,
    fontSize: r,
    fontStyle: i,
    fontVariant: s,
    fontWeight: o,
    monospace: a,
    pointerEvents: c,
    shapeRendering: u,
    clip: l,
    initializer: f
  };
}
function Sa(e, t, n, r, i, s) {
  let o;
  function a(l, f, h, d, p, y) {
    const m = l == null && (t === "fx" || t === "fy"), { [t]: g } = d;
    if (!g) throw new Error(`missing scale: ${t}`);
    const b = g.domain();
    let { interval: w, ticks: _, tickFormat: x, tickSpacing: v = t === "x" ? 80 : 35 } = i;
    if (typeof _ == "string" && d8(g) && (w = _, _ = void 0), _ === void 0 && (_ = wa(w, g.type) ?? nX(g, v)), l == null) {
      if (li(_))
        l = Qe(_);
      else if (wo(_))
        l = r0(_, ...pe(b));
      else if (g.interval) {
        let E = g.interval;
        if (g.ticks) {
          const [$, N] = pe(b), A = (N - $) / E[Iu];
          E = m2(E, A / _) ?? E, l = r0(E, $, N);
        } else {
          l = b;
          const $ = l.length;
          E = m2(E, $ / _) ?? E, E !== g.interval && (l = r0(E, ...pe(l)));
        }
        if (E === g.interval) {
          const $ = Math.round(l.length / _);
          $ > 1 && (l = l.filter((N, A) => A % $ === 0));
        }
      } else g.ticks ? l = g.ticks(_) : l = b;
      if (!g.ticks && l.length && l !== b) {
        const E = new pa(b);
        l = l.filter(($) => E.has($)), l.length || ti(`Warning: the ${t}-axis ticks appear to not align with the scale domain, resulting in no ticks. Try different ticks?`);
      }
      t === "y" || t === "x" ? f = [ui(l)] : o[t] = { scale: t, value: yt };
    }
    s == null || s.call(this, g, l, _, x, o);
    const M = Object.fromEntries(
      Object.entries(o).map(([E, $]) => [E, { ...$, value: $t(l, $.value) }])
    );
    return m && (f = y.filterFacets(l, M)), { data: l, facets: f, channels: M };
  }
  const c = tn(i).initializer, u = e(n, tn({ ...i, initializer: a }, c));
  return n == null ? (o = u.channels, u.channels = {}) : o = {}, r !== void 0 && Object.assign(u, r), u.clip === void 0 && (u.clip = !1), u;
}
function nX(e, t) {
  const [n, r] = pe(e.range());
  return (r - n) / t;
}
function u8(e, t, n, r, i) {
  return { value: Kg(e, t, n, r, i) };
}
function Kg(e, t, n, r, i) {
  return typeof r == "function" && !(e.type === "log" && e.tickFormat) ? r : r === void 0 && t && qe(t) ? gV(e.type, t, i) ?? ia : e.tickFormat ? e.tickFormat(typeof n == "number" ? n : null, r) : r === void 0 ? ia : typeof r == "string" ? (qe(e.domain()) ? Au : ga)(r) : fn(r);
}
function r0(e, t, n) {
  return e.range(t, e.offset(e.floor(n)));
}
const rX = {
  draw(e, t) {
    e.moveTo(0, 0), e.lineTo(0, t);
  }
}, iX = {
  draw(e, t) {
    e.moveTo(0, 0), e.lineTo(0, -t);
  }
}, sX = {
  draw(e, t) {
    e.moveTo(0, 0), e.lineTo(-t, 0);
  }
}, oX = {
  draw(e, t) {
    e.moveTo(0, 0), e.lineTo(t, 0);
  }
};
function l8(e) {
  return e.bandwidth && !e.interval ? void 0 : "tabular-nums";
}
function f8(e, t, { anchor: n, label: r = t.label, labelAnchor: i, labelArrow: s } = {}) {
  if (!(r == null || r.inferred && d8(t) && /^(date|time|year)$/i.test(r))) {
    if (r = String(r), s === "auto" && (s = (!t.bandwidth || t.interval) && !/[↑↓→←]/.test(r)), !s) return r;
    if (s === !0) {
      const o = KA(t);
      o && (s = /x$/.test(e) || i === "center" ? /x$/.test(e) === o < 0 ? "left" : "right" : o < 0 ? "up" : "down");
    }
    switch (s) {
      case "left":
        return `← ${r}`;
      case "right":
        return `${r} →`;
      case "up":
        return n === "right" ? `${r} ↑` : `↑ ${r}`;
      case "down":
        return n === "right" ? `${r} ↓` : `↓ ${r}`;
    }
    return r;
  }
}
function h8(e = "auto") {
  return ee(e) ? !1 : typeof e == "boolean" ? e : hn(e, "labelArrow", ["auto", "up", "right", "down", "left"]);
}
function d8(e) {
  return qe(e.domain());
}
function V2(e, t) {
  if (t == null) return t;
  const n = e(t);
  if (!n) throw new Error(`scale not found: ${t}`);
  return n;
}
function aX(e, { opacity: t, ...n } = {}) {
  if (!zs(e) && !r$(e))
    throw new Error(`swatches legend requires ordinal or threshold color scale (not ${e.type})`);
  return p8(
    e,
    n,
    (r, i, s, o) => r.append("svg").attr("width", s).attr("height", o).attr("fill", i.scale).attr("fill-opacity", fe(t)[1]).append("rect").attr("width", "100%").attr("height", "100%")
  );
}
function cX(e, {
  fill: t = ((u) => (u = e.hint) == null ? void 0 : u.fill)() !== void 0 ? e.hint.fill : "none",
  fillOpacity: n = 1,
  stroke: r = ((l) => (l = e.hint) == null ? void 0 : l.stroke)() !== void 0 ? e.hint.stroke : ee(t) ? "currentColor" : "none",
  strokeOpacity: i = 1,
  strokeWidth: s = 1.5,
  r: o = 4.5,
  ...a
} = {}, c) {
  const [f, h] = ze(t), [d, p] = ze(r), y = V2(c, f), m = V2(c, d), g = o * o * Math.PI;
  return n = fe(n)[1], i = fe(i)[1], s = fe(s)[1], p8(
    e,
    a,
    (b, w, _, x) => b.append("svg").attr("viewBox", "-8 -8 16 16").attr("width", _).attr("height", x).attr("fill", f === "color" ? (v) => y.scale(v) : h).attr("fill-opacity", n).attr("stroke", d === "color" ? (v) => m.scale(v) : p).attr("stroke-opacity", i).attr("stroke-width", s).append("path").attr("d", (v) => {
      const M = Gr();
      return e.scale(v).draw(M, g), M;
    })
  );
}
function p8(e, t = {}, n) {
  let {
    columns: r,
    tickFormat: i,
    fontVariant: s = m$(e),
    // TODO label,
    swatchSize: o = 15,
    swatchWidth: a = o,
    swatchHeight: c = o,
    marginLeft: u = 0,
    className: l,
    style: f,
    width: h
  } = t;
  const d = Bd(t);
  l = Yg(l), i = Kg(e.scale, e.domain, void 0, i);
  const p = Ot("div", d).attr(
    "class",
    `${l}-swatches ${l}-swatches-${r != null ? "columns" : "wrap"}`
  );
  let y;
  return r != null ? (y = `:where(.${l}-swatches-columns .${l}-swatch) {
  display: flex;
  align-items: center;
  break-inside: avoid;
  padding-bottom: 1px;
}
:where(.${l}-swatches-columns .${l}-swatch::before) {
  flex-shrink: 0;
}
:where(.${l}-swatches-columns .${l}-swatch-label) {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}`, p.style("columns", r).selectAll().data(e.domain).enter().append("div").attr("class", `${l}-swatch`).call(n, e, a, c).call(
    (m) => m.append("div").attr("class", `${l}-swatch-label`).attr("title", i).text(i)
  )) : (y = `:where(.${l}-swatches-wrap) {
  display: flex;
  align-items: center;
  min-height: 33px;
  flex-wrap: wrap;
}
:where(.${l}-swatches-wrap .${l}-swatch) {
  display: inline-flex;
  align-items: center;
  margin-right: 1em;
}`, p.selectAll().data(e.domain).enter().append("span").attr("class", `${l}-swatch`).call(n, e, a, c).append(function() {
    return this.ownerDocument.createTextNode(i.apply(this, arguments));
  })), p.call(
    (m) => m.insert("style", "*").text(
      `:where(.${l}-swatches) {
  font-family: system-ui, sans-serif;
  font-size: 10px;
  margin-bottom: 0.5em;
}
:where(.${l}-swatch > svg) {
  margin-right: 0.5em;
  overflow: visible;
}
${y}`
    )
  ).style("margin-left", u ? `${+u}px` : null).style("width", h === void 0 ? null : `${+h}px`).style("font-variant", oe(s, "normal")).call(Wg, f).node();
}
const Th = /* @__PURE__ */ new Map([
  ["symbol", cX],
  ["color", y8],
  ["opacity", fX]
]);
function uX(e = {}) {
  for (const [t, n] of Th) {
    const r = e[t];
    if (_s(r)) {
      const i = Bd(e);
      let s;
      if (t === "symbol") {
        const { fill: o, stroke: a = o === void 0 && _s(e.color) ? "color" : void 0 } = e;
        s = { fill: o, stroke: a };
      }
      return n(
        Dy(t, r, s),
        Qg(i, r, e),
        (o) => _s(e[o]) ? Dy(o, e[o]) : null
      );
    }
  }
  throw new Error("unknown legend type; no scale found");
}
function lX(e, t, n = {}) {
  return (r, i) => {
    if (!Th.has(r)) throw new Error(`unknown legend type: ${r}`);
    if (r in e)
      return Th.get(r)(e[r], Qg(t, n[r], i), (s) => e[s]);
  };
}
function Qg({ className: e, ...t }, { label: n, ticks: r, tickFormat: i } = {}, s) {
  return LV(s, { className: e, ...t }, { label: n, ticks: r, tickFormat: i });
}
function y8(e, { legend: t = !0, ...n }) {
  if (t === !0 && (t = e.type === "ordinal" ? "swatches" : "ramp"), e.domain !== void 0)
    switch (`${t}`.toLowerCase()) {
      case "swatches":
        return aX(e, n);
      case "ramp":
        return DW(e, n);
      default:
        throw new Error(`unknown legend type: ${t}`);
    }
}
function fX({ type: e, interpolate: t, ...n }, { legend: r = !0, color: i = un(0, 0, 0), ...s }) {
  if (!t) throw new Error(`${e} opacity scales are not supported`);
  if (r === !0 && (r = "ramp"), `${r}`.toLowerCase() !== "ramp") throw new Error(`${r} opacity legends are not supported`);
  return y8({ type: e, ...n, interpolate: hX(i) }, { legend: r, ...s });
}
function hX(e) {
  const { r: t, g: n, b: r } = un(e) || un(0, 0, 0);
  return (i) => `rgba(${t},${n},${r},${i})`;
}
function dX(e, t, n) {
  const r = [];
  for (const [i, s] of Th) {
    const o = n[i];
    if (o != null && o.legend && i in e) {
      const a = s(e[i], Qg(t, e[i], o), (c) => e[c]);
      a != null && r.push(a);
    }
  }
  return r;
}
const pX = {
  ariaLabel: "frame",
  fill: "none",
  stroke: "currentColor",
  clip: !1
}, yX = {
  ariaLabel: "frame",
  fill: null,
  stroke: "currentColor",
  strokeLinecap: "square",
  clip: !1
};
class m8 extends Ht {
  constructor(t = {}) {
    const {
      anchor: n = null,
      inset: r = 0,
      insetTop: i = r,
      insetRight: s = r,
      insetBottom: o = r,
      insetLeft: a = r,
      rx: c,
      ry: u
    } = t;
    super(gc, void 0, t, n == null ? pX : yX), this.anchor = mA(n, "anchor", ["top", "right", "bottom", "left"]), this.insetTop = Nt(i), this.insetRight = Nt(s), this.insetBottom = Nt(o), this.insetLeft = Nt(a), this.rx = Nt(c), this.ry = Nt(u);
  }
  render(t, n, r, i, s) {
    const { marginTop: o, marginRight: a, marginBottom: c, marginLeft: u, width: l, height: f } = i, { anchor: h, insetTop: d, insetRight: p, insetBottom: y, insetLeft: m, rx: g, ry: b } = this, w = u + m, _ = l - a - p, x = o + d, v = f - c - y;
    return Ot(h ? "svg:line" : "svg:rect", s).datum(0).call(ne, this, i, s).call(te, this).call(ge, this, r).call(Gt, this, {}).call(
      h === "left" ? (M) => M.attr("x1", w).attr("x2", w).attr("y1", x).attr("y2", v) : h === "right" ? (M) => M.attr("x1", _).attr("x2", _).attr("y1", x).attr("y2", v) : h === "top" ? (M) => M.attr("x1", w).attr("x2", _).attr("y1", x).attr("y2", x) : h === "bottom" ? (M) => M.attr("x1", w).attr("x2", _).attr("y1", v).attr("y2", v) : (M) => M.attr("x", w).attr("y", x).attr("width", _ - w).attr("height", v - x).attr("rx", g).attr("ry", b)
    ).node();
  }
}
function t1(e) {
  return new m8(e);
}
const i0 = {
  ariaLabel: "tip",
  fill: "var(--plot-background)",
  stroke: "currentColor"
}, mX = /* @__PURE__ */ new Set(["geometry", "href", "src", "ariaLabel", "scales"]);
class g8 extends Ht {
  constructor(t, n = {}) {
    n.tip && (n = { ...n, tip: !1 }), n.title === void 0 && li(t) && SA(t) && (n = { ...n, title: yt });
    const {
      x: r,
      y: i,
      x1: s,
      x2: o,
      y1: a,
      y2: c,
      anchor: u,
      preferredAnchor: l = "bottom",
      monospace: f,
      fontFamily: h = f ? "ui-monospace, monospace" : void 0,
      fontSize: d,
      fontStyle: p,
      fontVariant: y,
      fontWeight: m,
      lineHeight: g = 1,
      lineWidth: b = 20,
      frameAnchor: w,
      format: _,
      textAnchor: x = "start",
      textOverflow: v,
      textPadding: M = 8,
      title: E,
      pointerSize: $ = 12,
      pathFilter: N = "drop-shadow(0 3px 4px rgba(0,0,0,0.2))"
    } = n;
    super(
      t,
      {
        x: { value: s != null && o != null ? null : r, scale: "x", optional: !0 },
        // ignore midpoint
        y: { value: a != null && c != null ? null : i, scale: "y", optional: !0 },
        // ignore midpoint
        x1: { value: s, scale: "x", optional: o == null },
        y1: { value: a, scale: "y", optional: c == null },
        x2: { value: o, scale: "x", optional: s == null },
        y2: { value: c, scale: "y", optional: a == null },
        title: { value: E, optional: !0 }
        // filter: defined
      },
      n,
      i0
    ), this.anchor = Ay(u, "anchor"), this.preferredAnchor = Ay(l, "preferredAnchor"), this.frameAnchor = Eu(w), this.textAnchor = oe(x, "middle"), this.textPadding = +M, this.pointerSize = +$, this.pathFilter = Ne(N), this.lineHeight = +g, this.lineWidth = +b, this.textOverflow = O$(v), this.monospace = !!f, this.fontFamily = Ne(h), this.fontSize = Nt(d), this.fontStyle = Ne(p), this.fontVariant = Ne(y), this.fontWeight = Ne(m);
    for (const A in i0) A in this.channels && (this[A] = i0[A]);
    this.splitLines = F$(this), this.clipLine = B$(this), this.format = typeof _ == "string" || typeof _ == "function" ? { title: _ } : { ..._ };
  }
  render(t, n, r, i, s) {
    const o = this, { x: a, y: c, fx: u, fy: l } = n, { ownerSVGElement: f, document: h } = s, { anchor: d, monospace: p, lineHeight: y, lineWidth: m } = this, { textPadding: g, pointerSize: b, pathFilter: w } = this, { marginTop: _, marginLeft: x } = i, { x1: v, y1: M, x2: E, y2: $, x: N = v ?? E, y: A = M ?? $ } = r, D = u ? u(t.fx) - x : 0, k = l ? l(t.fy) - _ : 0, [S, I] = $r(this, i), T = p$(r, S), R = y$(r, I), B = p ? Hg : Gg, C = B(Lo);
    let F, P;
    "title" in r ? (F = Y2.call(this, { title: r.channels.title }, n), P = _X) : (F = Y2.call(this, r.channels, n), P = vX);
    const U = Ot("svg:g", s).call(ne, this, i, s).call(k$, this).call(Gt, this, { x: N && a, y: A && c }).call(
      (K) => K.selectAll().data(t).enter().append("g").attr("transform", (H) => `translate(${Math.round(T(H))},${Math.round(R(H))})`).call(te, this).call((H) => H.append("path").attr("filter", w)).call(
        (H) => H.append("text").each(function(V) {
          const W = Wt(this);
          this.setAttribute("fill", "currentColor"), this.setAttribute("fill-opacity", 1), this.setAttribute("stroke", "none");
          const q = P.call(o, V, t, F, n, r);
          if (typeof q == "string")
            for (const X of o.splitLines(q))
              Y(W, { value: o.clipLine(X) });
          else {
            const X = /* @__PURE__ */ new Set();
            for (const Z of q) {
              const { label: z = "" } = Z;
              z && X.has(z) || (X.add(z), Y(W, Z));
            }
          }
        })
      )
    );
    function Y(K, { label: H, value: V, color: W, opacity: q }) {
      H ?? (H = ""), V ?? (V = "");
      const X = W != null || q != null;
      let Z, z = m * 100;
      const [wt] = oa(H, z, B, C);
      if (wt >= 0)
        H = H.slice(0, wt).trimEnd() + Lo, Z = V.trim(), V = "";
      else {
        (H || !V && !X) && (V = " " + V);
        const [It] = oa(V, z - B(H), B, C);
        It >= 0 && (Z = V.trim(), V = V.slice(0, It).trimEnd() + Lo);
      }
      const tt = K.append("tspan").attr("x", 0).attr("dy", `${y}em`).text("​");
      H && tt.append("tspan").attr("font-weight", "bold").text(H), V && tt.append(() => h.createTextNode(V)), X && tt.append("tspan").text(" ■").attr("fill", W).attr("fill-opacity", q).style("user-select", "none"), Z && tt.append("title").text(Z);
    }
    function G() {
      const { width: K, height: H } = i.facet ?? i;
      U.selectChildren().each(function(V) {
        let { x: W, width: q, height: X } = this.getBBox();
        q = Math.round(q), X = Math.round(X);
        let Z = d;
        if (Z === void 0) {
          const tt = T(V) + D, It = R(V) + k, Et = tt + q + b + g * 2 < K, J = tt - q - b - g * 2 > 0, Ct = It + X + b + g * 2 < H, en = It - X - b - g * 2 > 0;
          Z = Et && J ? Ct && en ? o.preferredAnchor : en ? "bottom" : "top" : Ct && en ? Et ? "left" : "right" : (Et || J) && (Ct || en) ? `${en ? "bottom" : "top"}-${Et ? "left" : "right"}` : o.preferredAnchor;
        }
        const z = this.firstChild, wt = this.lastChild;
        if (z.setAttribute("d", wX(Z, b, g, q, X)), W) for (const tt of wt.childNodes) tt.setAttribute("x", -W);
        wt.setAttribute("y", `${+gX(Z, wt.childNodes.length, y).toFixed(6)}em`), wt.setAttribute("transform", `translate(${bX(Z, b, g, q, X)})`);
      }), U.attr("visibility", null);
    }
    return t.length && (U.attr("visibility", "hidden"), f.isConnected ? Promise.resolve().then(G) : typeof requestAnimationFrame < "u" && requestAnimationFrame(G)), U.node();
  }
}
function b8(e, { x: t, y: n, ...r } = {}) {
  return r.frameAnchor === void 0 && ([t, n] = Jn(t, n)), new g8(e, { ...r, x: t, y: n });
}
function gX(e, t, n) {
  return /^top(?:-|$)/.test(e) ? 0.94 - n : -0.29 - t * n;
}
function bX(e, t, n, r, i) {
  switch (e) {
    case "middle":
      return [-r / 2, i / 2];
    case "top-left":
      return [n, t + n];
    case "top":
      return [-r / 2, t / 2 + n];
    case "top-right":
      return [-r - n, t + n];
    case "right":
      return [-t / 2 - r - n, i / 2];
    case "bottom-left":
      return [n, -t - n];
    case "bottom":
      return [-r / 2, -t / 2 - n];
    case "bottom-right":
      return [-r - n, -t - n];
    case "left":
      return [n + t / 2, i / 2];
  }
}
function wX(e, t, n, r, i) {
  const s = r + n * 2, o = i + n * 2;
  switch (e) {
    case "middle":
      return `M${-s / 2},${-o / 2}h${s}v${o}h${-s}z`;
    case "top-left":
      return `M0,0l${t},${t}h${s - t}v${o}h${-s}z`;
    case "top":
      return `M0,0l${t / 2},${t / 2}h${(s - t) / 2}v${o}h${-s}v${-o}h${(s - t) / 2}z`;
    case "top-right":
      return `M0,0l${-t},${t}h${t - s}v${o}h${s}z`;
    case "right":
      return `M0,0l${-t / 2},${-t / 2}v${t / 2 - o / 2}h${-s}v${o}h${s}v${t / 2 - o / 2}z`;
    case "bottom-left":
      return `M0,0l${t},${-t}h${s - t}v${-o}h${-s}z`;
    case "bottom":
      return `M0,0l${t / 2},${-t / 2}h${(s - t) / 2}v${-o}h${-s}v${o}h${(s - t) / 2}z`;
    case "bottom-right":
      return `M0,0l${-t},${-t}h${t - s}v${-o}h${s}z`;
    case "left":
      return `M0,0l${t / 2},${-t / 2}v${t / 2 - o / 2}h${s}v${o}h${-s}v${t / 2 - o / 2}z`;
  }
}
function Y2(e, t) {
  var i, s;
  const n = {};
  let r = this.format;
  r = W2(r, e, "x"), r = W2(r, e, "y"), this.format = r;
  for (const o in r) {
    const a = r[o];
    if (!(a === null || a === !1))
      if (o === "fx" || o === "fy")
        n[o] = !0;
      else {
        const c = Iy(e, o);
        c && (n[o] = c);
      }
  }
  for (const o in e) {
    if (o in n || o in r || mX.has(o)) continue;
    const a = Iy(e, o);
    a && (n[o] = a);
  }
  this.facet && (t.fx && !("fx" in r) && (n.fx = !0), t.fy && !("fy" in r) && (n.fy = !0));
  for (const o in n) {
    const a = this.format[o];
    if (typeof a == "string") {
      const c = ((i = n[o]) == null ? void 0 : i.value) ?? ((s = t[o]) == null ? void 0 : s.domain()) ?? [];
      this.format[o] = (qe(c) ? Au : ga)(a);
    } else if (a === void 0 || a === !0) {
      const c = t[o];
      this.format[o] = c != null && c.bandwidth ? Kg(c, c.domain()) : ia;
    }
  }
  return n;
}
function W2(e, t, n) {
  if (!(n in e)) return e;
  const r = `${n}1`, i = `${n}2`;
  if ((r in e || !(r in t)) && (i in e || !(i in t))) return e;
  const s = Object.entries(e), o = e[n];
  return s.splice(s.findIndex(([a]) => a === n) + 1, 0, [r, o], [i, o]), Object.fromEntries(s);
}
function _X(e, t, { title: n }) {
  return this.format.title(n.value[e], e);
}
function* vX(e, t, n, r, i) {
  for (const s in n) {
    if (s === "fx" || s === "fy") {
      yield {
        label: Eh(r, n, s),
        value: this.format[s](t[s], e)
      };
      continue;
    }
    if (s === "x1" && "x2" in n || s === "y1" && "y2" in n) continue;
    const o = n[s];
    if (s === "x2" && "x1" in n)
      yield {
        label: G2(r, n, "x"),
        value: X2(this.format.x2, n.x1, o, e)
      };
    else if (s === "y2" && "y1" in n)
      yield {
        label: G2(r, n, "y"),
        value: X2(this.format.y2, n.y1, o, e)
      };
    else {
      const a = o.value[e], c = o.scale;
      if (!Pe(a) && c == null) continue;
      yield {
        label: Eh(r, n, s),
        value: this.format[s](a, e),
        color: c === "color" ? i[s][e] : null,
        opacity: c === "opacity" ? i[s][e] : null
      };
    }
  }
}
function X2(e, t, n, r) {
  var i;
  return (i = n.hint) != null && i.length ? `${e(n.value[r] - t.value[r], r)}` : `${e(t.value[r], r)}–${e(n.value[r], r)}`;
}
function G2(e, t, n) {
  const r = Eh(e, t, `${n}1`, n), i = Eh(e, t, `${n}2`, n);
  return r === i ? r : `${r}–${i}`;
}
function Eh(e, t, n, r = n) {
  const i = t[n], s = e[(i == null ? void 0 : i.scale) ?? n];
  return String((s == null ? void 0 : s.label) ?? (i == null ? void 0 : i.label) ?? r);
}
function e1(e = {}) {
  var C;
  const { facet: t, style: n, title: r, subtitle: i, caption: s, ariaLabel: o, ariaDescription: a } = e, c = Yg(e.className), u = e.marks === void 0 ? [] : J2(e.marks);
  u.push(...TX(u));
  const l = $X(t, e), f = /* @__PURE__ */ new Map();
  for (const F of u) {
    const P = Z2(F, l, e);
    P && f.set(F, P);
  }
  const h = /* @__PURE__ */ new Map();
  l && Ua(h, [l], e), Ua(h, f, e);
  const d = J2(EX(u, h, e));
  for (const F of d) {
    const P = Z2(F, l, e);
    P && f.set(F, P);
  }
  u.unshift(...d);
  let p = GY(h, e);
  if (p !== void 0) {
    const F = l ? t0(p, l) : void 0;
    for (const U of u) {
      if (U.facet === null || U.facet === "super") continue;
      const Y = f.get(U);
      Y !== void 0 && (Y.facetsIndex = U.fx != null || U.fy != null ? t0(p, Y) : F);
    }
    const P = /* @__PURE__ */ new Set();
    for (const { facetsIndex: U } of f.values())
      U == null || U.forEach((Y, G) => {
        (Y == null ? void 0 : Y.length) > 0 && P.add(G);
      });
    p.forEach(
      0 < P.size && P.size < p.length ? (U, Y) => U.empty = !P.has(Y) : (U) => U.empty = !1
    );
    for (const U of u)
      if (U.facet === "exclude") {
        const Y = f.get(U);
        Y !== void 0 && (Y.facetsIndex = ZY(Y.facetsIndex));
      }
  }
  for (const F of ie.keys())
    _s(e[F]) && F !== "fx" && F !== "fy" && h.set(F, []);
  const y = /* @__PURE__ */ new Map();
  for (const F of u) {
    if (y.has(F)) throw new Error("duplicate mark; each mark must be unique");
    const { facetsIndex: P, channels: U } = f.get(F) ?? {}, { data: Y, facets: G, channels: K } = F.initialize(P, U, e);
    n1(K, e), y.set(F, { data: Y, facets: G, channels: K });
  }
  const m = Ny(Ua(h, y, e), e), g = EW(m, u, e);
  zY(m, g);
  const b = E2(m), { fx: w, fy: _ } = b, x = w || _ ? QA(m, g) : g, v = w || _ ? FX(b, g) : g, M = Bd(e), E = M.document, $ = nd("svg").call(E.documentElement);
  let N = $;
  M.ownerSVGElement = $, M.className = c, M.projection = oW(e, x), M.filterFacets = (F, P) => t0(p, { channels: P, groups: qg(F, P) }), M.getMarkState = (F) => {
    const P = y.get(F), U = f.get(F);
    return { ...P, channels: { ...P.channels, ...U == null ? void 0 : U.channels } };
  }, M.dispatchValue = (F) => {
    N.value !== F && (N.value = F, N.dispatchEvent(new Event("input", { bubbles: !0 })));
  };
  const A = /* @__PURE__ */ new Set();
  for (const [F, P] of y)
    if (F.initializer != null) {
      const U = F.facet === "super" ? v : x, Y = F.initializer(P.data, P.facets, P.channels, b, U, M);
      if (Y.data !== void 0 && (P.data = Y.data), Y.facets !== void 0 && (P.facets = Y.facets), Y.channels !== void 0) {
        const { fx: G, fy: K, ...H } = Y.channels;
        AX(H), Object.assign(P.channels, H);
        for (const V of Object.values(H)) {
          const { scale: W } = V;
          W != null && !kV(ie.get(W)) && (w8(V, e), A.add(W));
        }
        (G != null || K != null) && f.set(F, !0);
      }
    }
  if (A.size) {
    const F = /* @__PURE__ */ new Map();
    Ua(F, y, e, (G) => A.has(G)), Ua(h, y, e, (G) => A.has(G));
    const P = kX(Ny(F, e), m), { scales: U, ...Y } = E2(P);
    Object.assign(m, P), Object.assign(b, Y), Object.assign(b.scales, U);
  }
  let D, k;
  p !== void 0 && (D = { x: w == null ? void 0 : w.domain(), y: _ == null ? void 0 : _.domain() }, p = HY(p, D), k = JY(w, _, g));
  for (const [F, P] of y)
    P.values = F.scale(P.channels, b, M);
  const { width: S, height: I } = g;
  Wt($).attr("class", c).attr("fill", "currentColor").attr("font-family", "system-ui, sans-serif").attr("font-size", 10).attr("text-anchor", "middle").attr("width", S).attr("height", I).attr("viewBox", `0 0 ${S} ${I}`).attr("aria-label", o).attr("aria-description", a).call(
    (F) => (
      // Warning: if you edit this, change defaultClassName.
      F.append("style").text(
        `:where(.${c}) {
  --plot-background: white;
  display: block;
  height: auto;
  height: intrinsic;
  max-width: 100%;
}
:where(.${c} text),
:where(.${c} tspan) {
  white-space: pre;
}`
      )
    )
  ).call(Wg, n);
  for (const F of u) {
    const { channels: P, values: U, facets: Y } = y.get(F);
    if (p === void 0 || F.facet === "super") {
      let G = null;
      if (Y && (G = Y[0], G = F.filter(G, P, U), G.length === 0))
        continue;
      const K = F.render(G, b, U, v, M);
      if (K == null) continue;
      $.appendChild(K);
    } else {
      let G;
      for (const K of p) {
        if (!(((C = F.facetAnchor) == null ? void 0 : C.call(F, p, D, K)) ?? !K.empty)) continue;
        let H = null;
        if (Y) {
          const W = f.has(F);
          if (H = Y[W ? K.i : 0], H = F.filter(H, P, U), H.length === 0) continue;
          !W && H === Y[0] && (H = vs(H)), H.fx = K.x, H.fy = K.y, H.fi = K.i;
        }
        const V = F.render(H, b, U, x, M);
        if (V != null) {
          (G ?? (G = Wt($).append("g"))).append(() => V).datum(K);
          for (const W of ["aria-label", "aria-description", "aria-hidden", "transform"])
            V.hasAttribute(W) && (G.attr(W, V.getAttribute(W)), V.removeAttribute(W));
        }
      }
      G == null || G.selectChildren().attr("transform", k);
    }
  }
  const T = dX(m, M, e), { figure: R = r != null || i != null || s != null || T.length > 0 } = e;
  R && (N = E.createElement("figure"), N.className = `${c}-figure`, N.style.maxWidth = "initial", r != null && N.append(H2(E, r, "h2")), i != null && N.append(H2(E, i, "h3")), N.append(...T, $), s != null && N.append(xX(E, s)), "value" in $ && (N.value = $.value, delete $.value)), N.scale = XY(b.scales), N.legend = lX(m, M, e);
  const B = MY();
  return B > 0 && Wt($).append("text").attr("x", S).attr("y", 20).attr("dy", "-1em").attr("text-anchor", "end").attr("font-family", "initial").text("⚠️").append("title").text(`${B.toLocaleString("en-US")} warning${B === 1 ? "" : "s"}. Please check the console.`), N;
}
function H2(e, t, n) {
  if (t.ownerDocument) return t;
  const r = e.createElement(n);
  return r.append(t), r;
}
function xX(e, t) {
  const n = e.createElement("figcaption");
  return n.append(t), n;
}
function J2(e) {
  return e.flat(1 / 0).filter((t) => t != null).map(SX);
}
function SX(e) {
  return typeof e.render == "function" ? e : new MX(e);
}
class MX extends Ht {
  constructor(t) {
    if (typeof t != "function") throw new TypeError("invalid mark; missing render function");
    super(), this.render = t;
  }
  render() {
  }
}
function n1(e, t) {
  for (const n in e) w8(e[n], t);
  return e;
}
function w8(e, t) {
  const { scale: n, transform: r = !0 } = e;
  if (n == null || !r) return;
  const {
    type: i,
    percent: s,
    interval: o,
    transform: a = s ? (c) => c == null ? NaN : c * 100 : vA(o, i)
  } = t[n] ?? {};
  a != null && (e.value = Zt(e.value, a), e.transform = !1);
}
function AX(e) {
  for (const t in e)
    CA(t, e[t]);
}
function Ua(e, t, n, r = vV) {
  var i, s;
  for (const { channels: o } of t.values())
    for (const a in o) {
      const c = o[a], { scale: u } = c;
      if (u != null && r(u))
        if (u === "projection") {
          if (!uW(n)) {
            const l = ((i = n.x) == null ? void 0 : i.domain) === void 0, f = ((s = n.y) == null ? void 0 : s.domain) === void 0;
            if (l || f) {
              const [h, d] = fW(c);
              l && s0(e, "x", h), f && s0(e, "y", d);
            }
          }
        } else
          s0(e, u, c);
    }
  return e;
}
function s0(e, t, n) {
  const r = e.get(t);
  r !== void 0 ? r.push(n) : e.set(t, [n]);
}
function $X(e, t) {
  if (e == null) return;
  const { x: n, y: r } = e;
  if (n == null && r == null) return;
  const i = Qe(e.data);
  if (i == null) throw new Error("missing facet data");
  const s = {};
  n != null && (s.fx = Gc(i, { value: n, scale: "fx" })), r != null && (s.fy = Gc(i, { value: r, scale: "fy" })), n1(s, t);
  const o = qg(i, s);
  return { channels: s, groups: o, data: e.data };
}
function Z2(e, t, n) {
  var c;
  if (e.facet === null || e.facet === "super") return;
  const { fx: r, fy: i } = e;
  if (r != null || i != null) {
    const u = Qe(e.data ?? r ?? i);
    if (u === void 0) throw new Error(`missing facet data in ${e.ariaLabel}`);
    if (u === null) return;
    const l = {};
    return r != null && (l.fx = Gc(u, { value: r, scale: "fx" })), i != null && (l.fy = Gc(u, { value: i, scale: "fy" })), n1(l, n), { channels: l, groups: qg(u, l) };
  }
  if (t === void 0) return;
  const { channels: s, groups: o, data: a } = t;
  if (e.facet !== "auto" || e.data === a) return { channels: s, groups: o };
  a.length > 0 && (o.size > 1 || o.size === 1 && s.fx && s.fy && [...o][0][1].size > 1) && ((c = Qe(e.data)) == null ? void 0 : c.length) === a.length && ti(
    `Warning: the ${e.ariaLabel} mark appears to use faceted data, but isn’t faceted. The mark data has the same length as the facet data and the mark facet option is "auto", but the mark data and facet data are distinct. If this mark should be faceted, set the mark facet option to true; otherwise, suppress this warning by setting the mark facet option to false.`
  );
}
function IX(e, t = {}) {
  return tn({ ...t, x: null, y: null }, (n, r, i, s, o, a) => a.getMarkState(e));
}
function TX(e) {
  const t = [];
  for (const n of e) {
    let r = n.tip;
    if (r) {
      r === !0 ? r = {} : typeof r == "string" && (r = { pointer: r });
      let { pointer: i, preferredAnchor: s } = r;
      i = /^x$/i.test(i) ? Pd : /^y$/i.test(i) ? Zc : Cd, r = i(IX(n, r)), r.title = null, s === void 0 && (r.preferredAnchor = i === Zc ? "left" : "bottom");
      const o = b8(n.data, r);
      o.facet = n.facet, o.facetAnchor = n.facetAnchor, t.push(o);
    }
  }
  return t;
}
function EX(e, t, n) {
  let {
    projection: r,
    x: i = {},
    y: s = {},
    fx: o = {},
    fy: a = {},
    axis: c,
    grid: u,
    facet: l = {},
    facet: { axis: f = c, grid: h } = l,
    x: { axis: d = c, grid: p = d === null ? null : u } = i,
    y: { axis: y = c, grid: m = y === null ? null : u } = s,
    fx: { axis: g = f, grid: b = g === null ? null : h } = o,
    fy: { axis: w = f, grid: _ = w === null ? null : h } = a
  } = n;
  (r || !_s(i) && !K2("x", e)) && (d = p = null), (r || !_s(s) && !K2("y", e)) && (y = m = null), t.has("fx") || (g = b = null), t.has("fy") || (w = _ = null), d === void 0 && (d = !ml(e, "x")), y === void 0 && (y = !ml(e, "y")), g === void 0 && (g = !ml(e, "fx")), w === void 0 && (w = !ml(e, "fy")), d === !0 && (d = "bottom"), y === !0 && (y = "left"), g === !0 && (g = d === "top" || d === null ? "bottom" : "top"), w === !0 && (w = y === "right" || y === null ? "left" : "right");
  const x = [];
  return yl(x, _, n8, a), pl(x, w, Z$, "right", "left", l, a), yl(x, b, i8, o), pl(x, g, K$, "top", "bottom", l, o), yl(x, m, e8, s), pl(x, y, Jg, "left", "right", n, s), yl(x, p, r8, i), pl(x, d, Zg, "bottom", "top", n, i), x;
}
function pl(e, t, n, r, i, s, o) {
  if (!t) return;
  const a = NX(t);
  o = DX(a ? r : t, s, o);
  const { line: c } = o;
  (n === Jg || n === Zg) && c && !ra(c) && e.push(t1(OX(o))), e.push(n(o)), a && e.push(n({ ...o, anchor: i, label: null }));
}
function yl(e, t, n, r) {
  !t || ra(t) || e.push(n(LX(t, r)));
}
function NX(e) {
  return /^\s*both\s*$/i.test(e);
}
function DX(e, t, {
  line: n = t.line,
  ticks: r,
  tickSize: i,
  tickSpacing: s,
  tickPadding: o,
  tickFormat: a,
  tickRotate: c,
  fontVariant: u,
  ariaLabel: l,
  ariaDescription: f,
  label: h = t.label,
  labelAnchor: d,
  labelArrow: p = t.labelArrow,
  labelOffset: y
}) {
  return {
    anchor: e,
    line: n,
    ticks: r,
    tickSize: i,
    tickSpacing: s,
    tickPadding: o,
    tickFormat: a,
    tickRotate: c,
    fontVariant: u,
    ariaLabel: l,
    ariaDescription: f,
    label: h,
    labelAnchor: d,
    labelArrow: p,
    labelOffset: y
  };
}
function OX(e) {
  const { anchor: t, line: n } = e;
  return { anchor: t, facetAnchor: t + "-empty", stroke: n === !0 ? void 0 : n };
}
function LX(e, {
  stroke: t = Tu(e) ? e : void 0,
  ticks: n = RX(e) ? e : void 0,
  tickSpacing: r,
  ariaLabel: i,
  ariaDescription: s
}) {
  return {
    stroke: t,
    ticks: n,
    tickSpacing: r,
    ariaLabel: i,
    ariaDescription: s
  };
}
function RX(e) {
  switch (typeof e) {
    case "number":
      return !0;
    case "string":
      return !Tu(e);
  }
  return li(e) || typeof (e == null ? void 0 : e.range) == "function";
}
function ml(e, t) {
  const n = `${t}-axis `;
  return e.some((r) => {
    var i;
    return (i = r.ariaLabel) == null ? void 0 : i.startsWith(n);
  });
}
function K2(e, t) {
  for (const n of t)
    for (const r in n.channels) {
      const { scale: i } = n.channels[r];
      if (i === e || i === "projection")
        return !0;
    }
  return !1;
}
function kX(e, t) {
  for (const n in e) {
    const r = e[n], i = t[n];
    r.label === void 0 && i && (r.label = i.label);
  }
  return e;
}
function FX({ fx: e, fy: t }, n) {
  const { marginTop: r, marginRight: i, marginBottom: s, marginLeft: o, width: a, height: c } = zg(n), u = e && Q2(e), l = t && Q2(t);
  return {
    marginTop: t ? l[0] : r,
    marginRight: e ? a - u[1] : i,
    marginBottom: t ? c - l[1] : s,
    marginLeft: e ? u[0] : o,
    // Some marks, namely the x- and y-axis labels, want to know what the
    // desired (rather than actual) margins are for positioning.
    inset: {
      marginTop: n.marginTop,
      marginRight: n.marginRight,
      marginBottom: n.marginBottom,
      marginLeft: n.marginLeft
    },
    width: a,
    height: c
  };
}
function Q2(e) {
  const t = e.domain();
  let n = e(t[0]), r = e(t[t.length - 1]);
  return r < n && ([n, r] = [r, n]), [n, r + e.bandwidth()];
}
const BX = /* @__PURE__ */ new Map([
  ["basis", qj],
  ["basis-closed", jj],
  ["basis-open", Vj],
  ["bundle", Yj],
  ["bump-x", Dj],
  ["bump-y", Oj],
  ["cardinal", Wj],
  ["cardinal-closed", Xj],
  ["cardinal-open", Gj],
  ["catmull-rom", Hj],
  ["catmull-rom-closed", Jj],
  ["catmull-rom-open", Zj],
  ["linear", $u],
  ["linear-closed", Kj],
  ["monotone-x", Qj],
  ["monotone-y", tV],
  ["natural", eV],
  ["step", nV],
  ["step-after", iV],
  ["step-before", rV]
]);
function r1(e = $u, t) {
  if (typeof e == "function") return e;
  const n = BX.get(`${e}`.toLowerCase());
  if (!n) throw new Error(`unknown curve: ${e}`);
  if (t !== void 0) {
    if ("beta" in n)
      return n.beta(t);
    if ("tension" in n)
      return n.tension(t);
    if ("alpha" in n)
      return n.alpha(t);
  }
  return n;
}
function _8(e = aa, t) {
  return typeof e != "function" && `${e}`.toLowerCase() === "auto" ? aa : r1(e, t);
}
function aa(e) {
  return $u(e);
}
function Mi(e = { y: "count" }, t = {}) {
  [e, t] = a1(e, t);
  const { x: n, y: r } = t;
  return o1(Nh(n, t, yt), null, null, r, e, Fu(t));
}
function Ai(e = { x: "count" }, t = {}) {
  [e, t] = a1(e, t);
  const { x: n, y: r } = t;
  return o1(null, Nh(r, t, yt), n, null, e, Bu(t));
}
function cs(e = { fill: "count" }, t = {}) {
  [e, t] = a1(e, t);
  const { x: n, y: r } = CX(t);
  return o1(n, r, null, null, e, Fu(Bu(t)));
}
function v8(e, t, n = {}) {
  if ((n == null ? void 0 : n.interval) == null) return n;
  const { reduce: r = Fg } = n, i = { filter: null };
  return n[t] != null && (i[t] = r), n[`${t}1`] != null && (i[`${t}1`] = r), n[`${t}2`] != null && (i[`${t}2`] = r), e(i, n);
}
function i1(e = {}) {
  return v8(Mi, "y", qs(e, "x"));
}
function s1(e = {}) {
  return v8(Ai, "x", qs(e, "y"));
}
function o1(e, t, n, r, {
  data: i = kg,
  // TODO avoid materializing when unused?
  filter: s = Mh,
  // return only non-empty bins by default
  sort: o,
  reverse: a,
  ...c
  // output channel definitions
} = {}, u = {}) {
  e = t_(e), t = t_(t), c = PX(c, u), i = A8(i, yt), o = o == null ? void 0 : S8("sort", o, u), s = s == null ? void 0 : M8("filter", s, u), n != null && Ei(c, "x", "x1", "x2") && (n = null), r != null && Ei(c, "y", "y1", "y2") && (r = null);
  const [l, f] = We(e), [h, d] = We(e), [p, y] = We(t), [m, g] = We(t), [b, w] = n != null ? [n, "x"] : r != null ? [r, "y"] : [], [_, x] = We(b), {
    x: v,
    y: M,
    z: E,
    fill: $,
    stroke: N,
    x1: A,
    x2: D,
    // consumed if x is an output
    y1: k,
    y2: S,
    // consumed if y is an output
    domain: I,
    cumulative: T,
    thresholds: R,
    interval: B,
    ...C
  } = u, [F, P] = We(E), [U] = ze($), [Y] = ze(N), [G, K] = We(U), [H, V] = We(Y);
  return {
    ..."z" in u && { z: F || E },
    ..."fill" in u && { fill: G || $ },
    ..."stroke" in u && { stroke: H || N },
    ...Ar(C, (W, q, X) => {
      const Z = Sh($t(W, b), X == null ? void 0 : X[w]), z = $t(W, E), wt = $t(W, U), tt = $t(W, Y), It = Rg(c, { z, fill: wt, stroke: tt }), Et = [], J = [], Ct = Z && x([]), en = z && P([]), Zn = wt && K([]), W7 = tt && V([]), K1 = e && f([]), X7 = e && d([]), Q1 = t && y([]), G7 = t && g([]), H7 = qX(e, t, W);
      let J7 = 0;
      for (const js of c) js.initialize(W);
      o && o.initialize(W), s && s.initialize(W);
      for (const js of q) {
        const tb = [];
        for (const Vs of c) Vs.scope("facet", js);
        o && o.scope("facet", js), s && s.scope("facet", js);
        for (const [Vs, Z7] of Oo(js, It))
          for (const [K7, qu] of Oo(Z7, Z))
            for (const [Kn, Er] of H7(qu))
              if (It && (Er.z = Vs), !(s && !s.reduce(Kn, Er))) {
                tb.push(J7++), J.push(i.reduceIndex(Kn, W, Er)), Z && Ct.push(K7), z && en.push(It === z ? Vs : z[(Kn.length > 0 ? Kn : qu)[0]]), wt && Zn.push(It === wt ? Vs : wt[(Kn.length > 0 ? Kn : qu)[0]]), tt && W7.push(It === tt ? Vs : tt[(Kn.length > 0 ? Kn : qu)[0]]), K1 && (K1.push(Er.x1), X7.push(Er.x2)), Q1 && (Q1.push(Er.y1), G7.push(Er.y2));
                for (const Q7 of c) Q7.reduce(Kn, Er);
                o && o.reduce(Kn, Er);
              }
        Et.push(tb);
      }
      return kA(Et, o, a), { data: J, facets: Et };
    }),
    ...!Ei(c, "x") && (l ? { x1: l, x2: h, x: xh(l, h) } : { x: v, x1: A, x2: D }),
    ...!Ei(c, "y") && (p ? { y1: p, y2: m, y: xh(p, m) } : { y: M, y1: k, y2: S }),
    ..._ && { [w]: _ },
    ...Object.fromEntries(c.map(({ name: W, output: q }) => [W, q]))
  };
}
function a1({ cumulative: e, domain: t, thresholds: n, interval: r, ...i }, s) {
  return [i, { cumulative: e, domain: t, thresholds: n, interval: r, ...s }];
}
function Nh(e, { cumulative: t, domain: n, thresholds: r, interval: i }, s) {
  return e = { ..._a(e) }, e.domain === void 0 && (e.domain = n), e.cumulative === void 0 && (e.cumulative = t), e.thresholds === void 0 && (e.thresholds = r), e.interval === void 0 && (e.interval = i), e.value === void 0 && (e.value = s), e.thresholds = x8(e.thresholds, e.interval), e;
}
function CX(e) {
  let { x: t, y: n } = e;
  return t = Nh(t, e), n = Nh(n, e), [t.value, n.value] = Jn(t.value, n.value), { x: t, y: n };
}
function t_(e) {
  if (e == null) return;
  const { value: t, cumulative: n, domain: r = pe, thresholds: i } = e, s = (o) => {
    let a = $t(o, t), c;
    if (qe(a) || zX(i)) {
      a = Zt(a, yA, Float64Array);
      let [l, f] = typeof r == "function" ? r(a) : r, h = typeof i == "function" && !wo(i) ? i(a, l, f) : i;
      typeof h == "number" && (h = p6(l, f, h)), wo(h) && (r === pe && (l = h.floor(l), f = h.offset(h.floor(f))), h = h.range(l, h.offset(f))), c = h;
    } else {
      a = He(a);
      let [l, f] = typeof r == "function" ? r(a) : r, h = typeof i == "function" && !wo(i) ? i(a, l, f) : i;
      if (typeof h == "number")
        if (r === pe) {
          let d = Oc(l, f, h);
          if (isFinite(d))
            if (d > 0) {
              let p = Math.round(l / d), y = Math.round(f / d);
              p * d <= l || --p, y * d > f || ++y;
              let m = y - p + 1;
              h = new Float64Array(m);
              for (let g = 0; g < m; ++g) h[g] = (p + g) * d;
            } else if (d < 0) {
              d = -d;
              let p = Math.round(l * d), y = Math.round(f * d);
              p / d <= l || --p, y / d > f || ++y;
              let m = y - p + 1;
              h = new Float64Array(m);
              for (let g = 0; g < m; ++g) h[g] = (p + g) / d;
            } else
              h = [l];
          else
            h = [l];
        } else
          h = Fi(l, f, h);
      else wo(h) && (r === pe && (l = h.floor(l), f = h.offset(h.floor(f))), h = h.range(l, h.offset(f)));
      c = h;
    }
    const u = [];
    if (c.length === 1) u.push([c[0], c[0]]);
    else for (let l = 1; l < c.length; ++l) u.push([c[l - 1], c[l]]);
    return u.bin = (n < 0 ? VX : n > 0 ? jX : c1)(u, c, a), u;
  };
  return s.label = Mr(t), s;
}
function x8(e, t, n = e_) {
  if (e === void 0)
    return t === void 0 ? n : wa(t);
  if (typeof e == "string") {
    switch (e.toLowerCase()) {
      case "freedman-diaconis":
        return bk;
      case "scott":
        return gS;
      case "sturges":
        return Bm;
      case "auto":
        return e_;
    }
    return Md(e);
  }
  return e;
}
function PX(e, t) {
  return NA(e, t, S8);
}
function S8(e, t, n) {
  return Og(e, t, n, M8);
}
function M8(e, t, n) {
  return Lg(e, t, n, A8);
}
function A8(e, t) {
  return Od(e, t, UX);
}
function UX(e) {
  switch (`${e}`.toLowerCase()) {
    case "x":
      return YX;
    case "x1":
      return XX;
    case "x2":
      return GX;
    case "y":
      return WX;
    case "y1":
      return HX;
    case "y2":
      return JX;
    case "z":
      return FA;
  }
  throw new Error(`invalid bin reduce: ${e}`);
}
function e_(e, t, n) {
  return Math.min(200, gS(e, t, n));
}
function zX(e) {
  return AV(e) || li(e) && qe(e);
}
function qX(e, t, n) {
  const r = e == null ? void 0 : e(n), i = t == null ? void 0 : t(n);
  return r && i ? function* (s) {
    const o = r.bin(s);
    for (const [a, [c, u]] of r.entries()) {
      const l = i.bin(o[a]);
      for (const [f, [h, d]] of i.entries())
        yield [l[f], { data: n, x1: c, y1: h, x2: u, y2: d }];
    }
  } : r ? function* (s) {
    const o = r.bin(s);
    for (const [a, [c, u]] of r.entries())
      yield [o[a], { data: n, x1: c, x2: u }];
  } : function* (s) {
    const o = i.bin(s);
    for (const [a, [c, u]] of i.entries())
      yield [o[a], { data: n, y1: c, y2: u }];
  };
}
function c1(e, t, n) {
  return t = He(t), (r) => {
    var s;
    const i = e.map(() => []);
    for (const o of r) (s = i[Zh(t, n[o]) - 1]) == null || s.push(o);
    return i;
  };
}
function jX(e, t, n) {
  const r = c1(e, t, n);
  return (i) => {
    const s = r(i);
    for (let o = 1, a = s.length; o < a; ++o) {
      const c = s[o - 1], u = s[o];
      for (const l of c) u.push(l);
    }
    return s;
  };
}
function VX(e, t, n) {
  const r = c1(e, t, n);
  return (i) => {
    const s = r(i);
    for (let o = s.length - 2; o >= 0; --o) {
      const a = s[o + 1], c = s[o];
      for (const u of a) c.push(u);
    }
    return s;
  };
}
function $8(e, t) {
  const n = (+e + +t) / 2;
  return e instanceof Date ? new Date(n) : n;
}
const YX = {
  reduceIndex(e, t, { x1: n, x2: r }) {
    return $8(n, r);
  }
}, WX = {
  reduceIndex(e, t, { y1: n, y2: r }) {
    return $8(n, r);
  }
}, XX = {
  reduceIndex(e, t, { x1: n }) {
    return n;
  }
}, GX = {
  reduceIndex(e, t, { x2: n }) {
    return n;
  }
}, HX = {
  reduceIndex(e, t, { y1: n }) {
    return n;
  }
}, JX = {
  reduceIndex(e, t, { y2: n }) {
    return n;
  }
};
function u1(e = {}) {
  return gA(e) ? e : { ...e, x: yt };
}
function l1(e = {}) {
  return bA(e) ? e : { ...e, y: yt };
}
function ZX(e, t) {
  if (t.length === 1) return { data: e, facets: t };
  const n = e.length, r = new Uint8Array(n);
  let i = 0;
  for (const a of t)
    for (const c of a)
      r[c] && ++i, r[c] = 1;
  if (i === 0) return { data: e, facets: t };
  e = Yc(e);
  const s = e[dA] = new Uint32Array(n + i);
  t = t.map((a) => Yc(a, Uint32Array));
  let o = n;
  r.fill(0);
  for (const a of t)
    for (let c = 0, u = a.length; c < u; ++c) {
      const l = a[c];
      r[l] ? (a[c] = o, e[o] = e[l], s[o] = l, ++o) : s[l] = l, r[l] = 1;
    }
  return { data: e, facets: t };
}
function I8(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = Ma(e));
  const { y1: n, y: r = n, x: i, ...s } = t, [o, a, c, u] = Aa(r, i, "y", "x", e, s);
  return { ...o, y1: n, y: a, x1: c, x2: u, x: xh(c, u) };
}
function KX(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = Ma(e));
  const { y1: n, y: r = n, x: i } = t, [s, o, a] = Aa(r, i, "y", "x", e, t);
  return { ...s, y1: n, y: o, x: a };
}
function QX(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = Ma(e));
  const { y1: n, y: r = n, x: i } = t, [s, o, , a] = Aa(r, i, "y", "x", e, t);
  return { ...s, y1: n, y: o, x: a };
}
function T8(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = Ma(e));
  const { x1: n, x: r = n, y: i, ...s } = t, [o, a, c, u] = Aa(r, i, "x", "y", e, s);
  return { ...o, x1: n, x: a, y1: c, y2: u, y: xh(c, u) };
}
function tG(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = Ma(e));
  const { x1: n, x: r = n, y: i } = t, [s, o, a] = Aa(r, i, "x", "y", e, t);
  return { ...s, x1: n, x: o, y: a };
}
function eG(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = Ma(e));
  const { x1: n, x: r = n, y: i } = t, [s, o, , a] = Aa(r, i, "x", "y", e, t);
  return { ...s, x1: n, x: o, y: a };
}
function f1({ x: e, x1: t, x2: n, ...r } = {}) {
  return r = qs(r, "y"), t === void 0 && n === void 0 ? I8({ x: e, ...r }) : ([t, n] = wA(e, t, n), { ...r, x1: t, x2: n });
}
function h1({ y: e, y1: t, y2: n, ...r } = {}) {
  return r = qs(r, "x"), t === void 0 && n === void 0 ? T8({ y: e, ...r }) : ([t, n] = wA(e, t, n), { ...r, y1: t, y2: n });
}
function Ma(e) {
  const { offset: t, order: n, reverse: r, ...i } = e;
  return [{ offset: t, order: n, reverse: r }, i];
}
const nG = { length: !0 };
function Aa(e, t = wg, n, r, { offset: i, order: s, reverse: o }, a) {
  if (t === null) throw new Error(`stack requires ${r}`);
  const c = Zi(a), [u, l] = We(e), [f, h] = an(t), [d, p] = an(t);
  return f.hint = d.hint = nG, i = rG(i), s = oG(s, i, r), [
    Ar(a, (y, m, g) => {
      ({ data: y, facets: m } = ZX(y, m));
      const b = e == null ? void 0 : l(Sh($t(y, e), g == null ? void 0 : g[n])), w = $t(y, t, Float64Array), _ = $t(y, c), x = s && s(y, b, w, _), v = y.length, M = h(new Float64Array(v)), E = p(new Float64Array(v)), $ = [];
      for (const N of m) {
        const A = b ? Array.from(ci(N, (D) => b[D]).values()) : [N];
        if (x) for (const D of A) D.sort(x);
        for (const D of A) {
          let k = 0, S = 0;
          o && D.reverse();
          for (const I of D) {
            const T = w[I];
            T < 0 ? k = E[I] = (M[I] = k) + T : T > 0 ? S = E[I] = (M[I] = S) + T : E[I] = M[I] = S;
          }
        }
        $.push(A);
      }
      return i && i($, M, E, _), { data: y, facets: m };
    }),
    u,
    f,
    d
  ];
}
function rG(e) {
  if (e != null) {
    if (typeof e == "function") return e;
    switch (`${e}`.toLowerCase()) {
      case "expand":
      case "normalize":
        return iG;
      case "center":
      case "silhouette":
        return sG;
      case "wiggle":
        return N8;
    }
    throw new Error(`unknown offset: ${e}`);
  }
}
function E8(e, t) {
  let n = 0, r = 0;
  for (const i of e) {
    const s = t[i];
    s < n && (n = s), s > r && (r = s);
  }
  return [n, r];
}
function iG(e, t, n) {
  for (const r of e)
    for (const i of r) {
      const [s, o] = E8(i, n);
      for (const a of i) {
        const c = 1 / (o - s || 1);
        t[a] = c * (t[a] - s), n[a] = c * (n[a] - s);
      }
    }
}
function sG(e, t, n) {
  for (const r of e) {
    for (const i of r) {
      const [s, o] = E8(i, n);
      for (const a of i) {
        const c = (o + s) / 2;
        t[a] -= c, n[a] -= c;
      }
    }
    D8(r, t, n);
  }
  O8(e, t, n);
}
function N8(e, t, n, r) {
  for (const i of e) {
    const s = new Ts();
    let o = 0;
    for (const a of i) {
      let c = -1;
      const u = a.map((d) => Math.abs(n[d] - t[d])), l = a.map((d) => {
        c = r ? r[d] : ++c;
        const p = n[d] - t[d], y = s.has(c) ? p - s.get(c) : 0;
        return s.set(c, p), y;
      }), f = [0, ...uk(l)];
      for (const d of a)
        t[d] += o, n[d] += o;
      const h = br(u);
      h && (o -= br(u, (d, p) => (l[p] / 2 + f[p]) * d) / h);
    }
    D8(i, t, n);
  }
  O8(e, t, n);
}
function D8(e, t, n) {
  const r = ve(e, (i) => ve(i, (s) => t[s]));
  for (const i of e)
    for (const s of i)
      t[s] -= r, n[s] -= r;
}
function O8(e, t, n) {
  const r = e.length;
  if (r === 1) return;
  const i = e.map((a) => a.flat()), s = i.map((a) => (ve(a, (c) => t[c]) + ce(a, (c) => n[c])) / 2), o = ve(s);
  for (let a = 0; a < r; a++) {
    const c = o - s[a];
    for (const u of i[a])
      t[u] += c, n[u] += c;
  }
}
function oG(e, t, n) {
  if (e === void 0 && t === N8) return n_(Tn);
  if (e != null) {
    if (typeof e == "string") {
      const r = e.startsWith("-"), i = r ? _h : Tn;
      switch ((r ? e.slice(1) : e).toLowerCase()) {
        case "value":
        case n:
          return aG(i);
        case "z":
          return cG(i);
        case "sum":
          return uG(i);
        case "appearance":
          return lG(i);
        case "inside-out":
          return n_(i);
      }
      return r_(pA(e));
    }
    if (typeof e == "function") return (e.length === 1 ? r_ : fG)(e);
    if (Array.isArray(e)) return hG(e);
    throw new Error(`invalid order: ${e}`);
  }
}
function aG(e) {
  return (t, n, r) => (i, s) => e(r[i], r[s]);
}
function cG(e) {
  return (t, n, r, i) => (s, o) => e(i[s], i[o]);
}
function uG(e) {
  return Yd(
    e,
    (t, n, r, i) => Fm(
      ui(t),
      (s) => br(s, (o) => r[o]),
      (s) => i[s]
    )
  );
}
function lG(e) {
  return Yd(
    e,
    (t, n, r, i) => Fm(
      ui(t),
      (s) => n[Cm(s, (o) => r[o])],
      (s) => i[s]
    )
  );
}
function n_(e) {
  return Yd(e, (t, n, r, i) => {
    const s = ui(t), o = Fm(
      s,
      (f) => n[Cm(f, (h) => r[h])],
      (f) => i[f]
    ), a = To(
      s,
      (f) => br(f, (h) => r[h]),
      (f) => i[f]
    ), c = [], u = [];
    let l = 0;
    for (const f of o)
      l < 0 ? (l += a.get(f), c.push(f)) : (l -= a.get(f), u.push(f));
    return u.reverse().concat(c);
  });
}
function r_(e) {
  return (t) => {
    const n = $t(t, e);
    return (r, i) => Tn(n[r], n[i]);
  };
}
function fG(e) {
  return (t) => (n, r) => e(t[n], t[r]);
}
function hG(e) {
  return Yd(Tn, () => e);
}
function Yd(e, t) {
  return (n, r, i, s) => {
    if (!s) throw new Error("missing channel: z");
    const o = new Ts(t(n, r, i, s).map((a, c) => [a, c]));
    return (a, c) => e(o.get(s[a]), o.get(s[c]));
  };
}
const dG = {
  ariaLabel: "area",
  strokeWidth: 1,
  strokeLinecap: "round",
  strokeLinejoin: "round",
  strokeMiterlimit: 1
};
class Wd extends Ht {
  constructor(t, n = {}) {
    const { x1: r, y1: i, x2: s, y2: o, z: a, curve: c, tension: u } = n;
    super(
      t,
      {
        x1: { value: r, scale: "x" },
        y1: { value: i, scale: "y" },
        x2: { value: s, scale: "x", optional: !0 },
        y2: { value: o, scale: "y", optional: !0 },
        z: { value: Zi(n), optional: !0 }
      },
      n,
      dG
    ), this.z = a, this.curve = r1(c, u);
  }
  filter(t) {
    return t;
  }
  render(t, n, r, i, s) {
    const { x1: o, y1: a, x2: c = o, y2: u = a } = r;
    return Ot("svg:g", s).call(ne, this, i, s).call(Gt, this, n, 0, 0).call(
      (l) => l.selectAll().data(h$(t, [o, a, c, u], this, r)).enter().append("path").call(te, this).call(Ah, this, r).attr(
        "d",
        ug().curve(this.curve).defined((f) => f >= 0).x0((f) => o[f]).y0((f) => a[f]).x1((f) => c[f]).y1((f) => u[f])
      )
    ).node();
  }
}
function ky(e, t) {
  return t === void 0 ? ca(e, { x: Ad, y: Vc }) : new Wd(e, t);
}
function Kc(e, t) {
  const { y: n = Ve, ...r } = s1(t);
  return new Wd(e, f1(u1({ ...r, y1: n, y2: void 0 })));
}
function ca(e, t) {
  const { x: n = Ve, ...r } = i1(t);
  return new Wd(e, h1(l1({ ...r, x1: n, x2: void 0 })));
}
const pG = {
  ariaLabel: "link",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1
};
class L8 extends Ht {
  constructor(t, n = {}) {
    const { x1: r, y1: i, x2: s, y2: o, curve: a, tension: c } = n;
    super(
      t,
      {
        x1: { value: r, scale: "x" },
        y1: { value: i, scale: "y" },
        x2: { value: s, scale: "x", optional: !0 },
        y2: { value: o, scale: "y", optional: !0 }
      },
      n,
      pG
    ), this.curve = _8(a, c), va(this, n);
  }
  project(t, n, r) {
    this.curve !== aa && super.project(t, n, r);
  }
  render(t, n, r, i, s) {
    const { x1: o, y1: a, x2: c = o, y2: u = a } = r, { curve: l } = this;
    return Ot("svg:g", s).call(ne, this, i, s).call(Gt, this, n).call(
      (f) => f.selectAll().data(t).enter().append("path").call(te, this).attr(
        "d",
        l === aa && s.projection ? yG(s.projection, o, a, c, u) : (h) => {
          const d = Gr(), p = l(d);
          return p.lineStart(), p.point(o[h], a[h]), p.point(c[h], u[h]), p.lineEnd(), d;
        }
      ).call(ge, this, r).call(ku, this, r, s)
    ).node();
  }
}
function yG(e, t, n, r, i) {
  const s = Hi(e);
  return t = He(t), n = He(n), r = He(r), i = He(i), (o) => s({
    type: "LineString",
    coordinates: [
      [t[o], n[o]],
      [r[o], i[o]]
    ]
  });
}
function R8(e, { x: t, x1: n, x2: r, y: i, y1: s, y2: o, ...a } = {}) {
  return [n, r] = Dh(t, n, r), [s, o] = Dh(i, s, o), new L8(e, { ...a, x1: n, x2: r, y1: s, y2: o });
}
function Dh(e, t, n) {
  if (e === void 0) {
    if (t === void 0) {
      if (n !== void 0) return [n];
    } else if (n === void 0) return [t];
  } else {
    if (t === void 0)
      return n === void 0 ? [e] : [e, n];
    if (n === void 0)
      return [e, t];
  }
  return [t, n];
}
const mG = {
  ariaLabel: "arrow",
  fill: "none",
  stroke: "currentColor",
  strokeLinecap: "round",
  strokeMiterlimit: 1,
  strokeWidth: 1.5
};
class k8 extends Ht {
  constructor(t, n = {}) {
    const {
      x1: r,
      y1: i,
      x2: s,
      y2: o,
      bend: a = 0,
      headAngle: c = 60,
      headLength: u = 8,
      // Disable the arrow with headLength = 0; or, use Plot.link.
      inset: l = 0,
      insetStart: f = l,
      insetEnd: h = l,
      sweep: d
    } = n;
    super(
      t,
      {
        x1: { value: r, scale: "x" },
        y1: { value: i, scale: "y" },
        x2: { value: s, scale: "x", optional: !0 },
        y2: { value: o, scale: "y", optional: !0 }
      },
      n,
      mG
    ), this.bend = a === !0 ? 22.5 : Math.max(-90, Math.min(90, a)), this.headAngle = +c, this.headLength = +u, this.insetStart = +f, this.insetEnd = +h, this.sweep = gG(d);
  }
  render(t, n, r, i, s) {
    const { x1: o, y1: a, x2: c = o, y2: u = a, SW: l } = r, { strokeWidth: f, bend: h, headAngle: d, headLength: p, insetStart: y, insetEnd: m } = this, g = l ? (_) => l[_] : fn(f === void 0 ? 1 : f), b = d * Ih / 2, w = p / 1.5;
    return Ot("svg:g", s).call(ne, this, i, s).call(Gt, this, n).call(
      (_) => _.selectAll().data(t).enter().append("path").call(te, this).attr("d", (x) => {
        let v = o[x], M = a[x], E = c[x], $ = u[x];
        const N = Math.hypot(E - v, $ - M);
        if (N <= y + m) return null;
        let A = Math.atan2($ - M, E - v);
        const D = Math.min(w * g(x), N / 3), k = this.sweep(v, M, E, $) * h * Ih, S = Math.hypot(N / Math.tan(k), N) / 2;
        if (y || m)
          if (S < 1e5) {
            const G = Math.sign(k), [K, H] = bG([v, M], [E, $], S, G);
            if (y && ([v, M] = i_([K, H, S], [v, M, y], -G * Math.sign(y))), m) {
              const [V, W] = i_([K, H, S], [E, $, m], G * Math.sign(m));
              A += Math.atan2(W - H, V - K) - Math.atan2($ - H, E - K), E = V, $ = W;
            }
          } else {
            const G = E - v, K = $ - M, H = Math.hypot(G, K);
            y && (v += G / H * y, M += K / H * y), m && (E -= G / H * m, $ -= K / H * m);
          }
        const I = A + k, T = I + b, R = I - b, B = E - D * Math.cos(T), C = $ - D * Math.sin(T), F = E - D * Math.cos(R), P = $ - D * Math.sin(R), U = S < 1e5 ? `A${S},${S} 0,0,${k > 0 ? 1 : 0} ` : "L", Y = D ? `M${B},${C}L${E},${$}L${F},${P}` : "";
        return `M${v},${M}${U}${E},${$}${Y}`;
      }).call(ge, this, r)
    ).node();
  }
}
function gG(e = 1) {
  if (typeof e == "number") return fn(Math.sign(e));
  if (typeof e == "function") return (t, n, r, i) => Math.sign(e(t, n, r, i));
  switch (hn(e, "sweep", ["+x", "-x", "+y", "-y"])) {
    case "+x":
      return (t, n, r) => zt(t, r);
    case "-x":
      return (t, n, r) => Is(t, r);
    case "+y":
      return (t, n, r, i) => zt(n, i);
    case "-y":
      return (t, n, r, i) => Is(n, i);
  }
}
function bG([e, t], [n, r], i, s) {
  const o = n - e, a = r - t, c = Math.hypot(o, a), u = s * Math.sqrt(i * i - c * c / 4) / c;
  return [(e + n) / 2 - a * u, (t + r) / 2 + o * u];
}
function i_([e, t, n], [r, i, s], o) {
  const a = r - e, c = i - t, u = Math.hypot(a, c), l = (a * a + c * c - s * s + n * n) / (2 * u), f = o * Math.sqrt(n * n - l * l);
  return [e + (a * l + c * f) / u, t + (c * l - a * f) / u];
}
function wG(e, { x: t, x1: n, x2: r, y: i, y1: s, y2: o, ...a } = {}) {
  return [n, r] = Dh(t, n, r), [s, o] = Dh(i, s, o), new k8(e, { ...a, x1: n, x2: r, y1: s, y2: o });
}
class d1 extends Ht {
  constructor(t, n, r = {}, i) {
    super(t, n, r, i);
    const { inset: s = 0, insetTop: o = s, insetRight: a = s, insetBottom: c = s, insetLeft: u = s, rx: l, ry: f } = r;
    this.insetTop = Nt(o), this.insetRight = Nt(a), this.insetBottom = Nt(c), this.insetLeft = Nt(u), this.rx = oe(l, "auto"), this.ry = oe(f, "auto");
  }
  render(t, n, r, i, s) {
    const { rx: o, ry: a } = this;
    return Ot("svg:g", s).call(ne, this, i, s).call(this._transform, this, n).call(
      (c) => c.selectAll().data(t).enter().append("rect").call(te, this).attr("x", this._x(n, r, i)).attr("width", this._width(n, r, i)).attr("y", this._y(n, r, i)).attr("height", this._height(n, r, i)).call(at, "rx", o).call(at, "ry", a).call(ge, this, r)
    ).node();
  }
  _x(t, { x: n }, { marginLeft: r }) {
    const { insetLeft: i } = this;
    return n ? (s) => n[s] + i : r + i;
  }
  _y(t, { y: n }, { marginTop: r }) {
    const { insetTop: i } = this;
    return n ? (s) => n[s] + i : r + i;
  }
  _width({ x: t }, { x: n }, { marginRight: r, marginLeft: i, width: s }) {
    const { insetLeft: o, insetRight: a } = this, c = n && t ? t.bandwidth() : s - r - i;
    return Math.max(0, c - o - a);
  }
  _height({ y: t }, { y: n }, { marginTop: r, marginBottom: i, height: s }) {
    const { insetTop: o, insetBottom: a } = this, c = n && t ? t.bandwidth() : s - r - i;
    return Math.max(0, c - o - a);
  }
}
const F8 = {
  ariaLabel: "bar"
};
class B8 extends d1 {
  constructor(t, n = {}) {
    const { x1: r, x2: i, y: s } = n;
    super(
      t,
      {
        x1: { value: r, scale: "x" },
        x2: { value: i, scale: "x" },
        y: { value: s, scale: "y", type: "band", optional: !0 }
      },
      n,
      F8
    );
  }
  _transform(t, n, { x: r }) {
    t.call(Gt, n, { x: r }, 0, 0);
  }
  _x({ x: t }, { x1: n, x2: r }, { marginLeft: i }) {
    const { insetLeft: s } = this;
    return Mn(t) ? i + s : (o) => Math.min(n[o], r[o]) + s;
  }
  _width({ x: t }, { x1: n, x2: r }, { marginRight: i, marginLeft: s, width: o }) {
    const { insetLeft: a, insetRight: c } = this;
    return Mn(t) ? o - i - s - a - c : (u) => Math.max(0, Math.abs(r[u] - n[u]) - a - c);
  }
}
class C8 extends d1 {
  constructor(t, n = {}) {
    const { x: r, y1: i, y2: s } = n;
    super(
      t,
      {
        y1: { value: i, scale: "y" },
        y2: { value: s, scale: "y" },
        x: { value: r, scale: "x", type: "band", optional: !0 }
      },
      n,
      F8
    );
  }
  _transform(t, n, { y: r }) {
    t.call(Gt, n, { y: r }, 0, 0);
  }
  _y({ y: t }, { y1: n, y2: r }, { marginTop: i }) {
    const { insetTop: s } = this;
    return Mn(t) ? i + s : (o) => Math.min(n[o], r[o]) + s;
  }
  _height({ y: t }, { y1: n, y2: r }, { marginTop: i, marginBottom: s, height: o }) {
    const { insetTop: a, insetBottom: c } = this;
    return Mn(t) ? o - i - s - a - c : (u) => Math.max(0, Math.abs(r[u] - n[u]) - a - c);
  }
}
function ps(e, t = {}) {
  return $d(t) || (t = { ...t, y: Ve, x2: yt }), new B8(e, f1(S$(u1(t))));
}
function ys(e, t = {}) {
  return $d(t) || (t = { ...t, x: Ve, y2: yt }), new C8(e, h1(M$(l1(t))));
}
const _G = {
  ariaLabel: "cell"
};
class Xd extends d1 {
  constructor(t, { x: n, y: r, ...i } = {}) {
    super(
      t,
      {
        x: { value: n, scale: "x", type: "band", optional: !0 },
        y: { value: r, scale: "y", type: "band", optional: !0 }
      },
      i,
      _G
    );
  }
  _transform(t, n) {
    t.call(Gt, n, {}, 0, 0);
  }
}
function vo(e, { x: t, y: n, ...r } = {}) {
  return [t, n] = Jn(t, n), new Xd(e, { ...r, x: t, y: n });
}
function vG(e, { x: t = Ve, fill: n, stroke: r, ...i } = {}) {
  return n === void 0 && ze(r)[0] === void 0 && (n = yt), new Xd(e, { ...i, x: t, fill: n, stroke: r });
}
function xG(e, { y: t = Ve, fill: n, stroke: r, ...i } = {}) {
  return n === void 0 && ze(r)[0] === void 0 && (n = yt), new Xd(e, { ...i, y: t, fill: n, stroke: r });
}
const SG = {
  ariaLabel: "dot",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1.5
};
function p1(e) {
  return e.sort === void 0 && e.reverse === void 0 ? TA({ channel: "-r" }, e) : e;
}
class Gd extends Ht {
  constructor(t, n = {}) {
    const { x: r, y: i, r: s, rotate: o, symbol: a = jc, frameAnchor: c } = n, [u, l] = fe(o, 0), [f, h] = PV(a), [d, p] = fe(s, f == null ? 3 : 4.5);
    super(
      t,
      {
        x: { value: r, scale: "x", optional: !0 },
        y: { value: i, scale: "y", optional: !0 },
        r: { value: d, scale: "r", filter: Qr, optional: !0 },
        rotate: { value: u, optional: !0 },
        symbol: { value: f, scale: "auto", optional: !0 }
      },
      p1(n),
      SG
    ), this.r = p, this.rotate = l, this.symbol = h, this.frameAnchor = Eu(c);
    const { channels: y } = this, { symbol: m } = y;
    if (m) {
      const { fill: g, stroke: b } = y;
      m.hint = {
        fill: g ? g.value === m.value ? "color" : "currentColor" : this.fill ?? "currentColor",
        stroke: b ? b.value === m.value ? "color" : "currentColor" : this.stroke ?? "none"
      };
    }
  }
  render(t, n, r, i, s) {
    const { x: o, y: a } = n, { x: c, y: u, r: l, rotate: f, symbol: h } = r, { r: d, rotate: p, symbol: y } = this, [m, g] = $r(this, i), b = y === jc, w = l ? void 0 : d * d * Math.PI;
    return xd(d) && (t = []), Ot("svg:g", s).call(ne, this, i, s).call(Gt, this, { x: c && o, y: u && a }).call(
      (_) => _.selectAll().data(t).enter().append(b ? "circle" : "path").call(te, this).call(
        b ? (x) => {
          x.attr("cx", c ? (v) => c[v] : m).attr("cy", u ? (v) => u[v] : g).attr("r", l ? (v) => l[v] : d);
        } : (x) => {
          x.attr(
            "transform",
            zd`translate(${c ? (v) => c[v] : m},${u ? (v) => u[v] : g})${f ? (v) => ` rotate(${f[v]})` : p ? ` rotate(${p})` : ""}`
          ).attr(
            "d",
            l && h ? (v) => {
              const M = Gr();
              return h[v].draw(M, l[v] * l[v] * Math.PI), M;
            } : l ? (v) => {
              const M = Gr();
              return y.draw(M, l[v] * l[v] * Math.PI), M;
            } : h ? (v) => {
              const M = Gr();
              return h[v].draw(M, w), M;
            } : (() => {
              const v = Gr();
              return y.draw(v, w), v;
            })()
          );
        }
      ).call(ge, this, r)
    ).node();
  }
}
function ts(e, { x: t, y: n, ...r } = {}) {
  return r.frameAnchor === void 0 && ([t, n] = Jn(t, n)), new Gd(e, { ...r, x: t, y: n });
}
function MG(e, { x: t = yt, ...n } = {}) {
  return new Gd(e, $$({ ...n, x: t }));
}
function AG(e, { y: t = yt, ...n } = {}) {
  return new Gd(e, A$({ ...n, y: t }));
}
function $G(e, t) {
  return ts(e, { ...t, symbol: "circle" });
}
function IG(e, t) {
  return ts(e, { ...t, symbol: "hexagon" });
}
const TG = {
  ariaLabel: "line",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1.5,
  strokeLinecap: "round",
  strokeLinejoin: "round",
  strokeMiterlimit: 1
};
class Hd extends Ht {
  constructor(t, n = {}) {
    const { x: r, y: i, z: s, curve: o, tension: a } = n;
    super(
      t,
      {
        x: { value: r, scale: "x" },
        y: { value: i, scale: "y" },
        z: { value: Zi(n), optional: !0 }
      },
      n,
      TG
    ), this.z = s, this.curve = _8(o, a), va(this, n);
  }
  filter(t) {
    return t;
  }
  project(t, n, r) {
    this.curve !== aa && super.project(t, n, r);
  }
  render(t, n, r, i, s) {
    const { x: o, y: a } = r, { curve: c } = this;
    return Ot("svg:g", s).call(ne, this, i, s).call(Gt, this, n).call(
      (u) => u.selectAll().data(h$(t, [o, a], this, r)).enter().append("path").call(te, this).call(Ah, this, r).call(kW, this, r, s).attr(
        "d",
        c === aa && s.projection ? EG(s.projection, o, a) : FM().curve(c).defined((l) => l >= 0).x((l) => o[l]).y((l) => a[l])
      )
    ).node();
  }
}
function EG(e, t, n) {
  const r = Hi(e);
  return t = He(t), n = He(n), (i) => {
    let s = [];
    const o = [s];
    for (const a of i)
      a === -1 ? (s = [], o.push(s)) : s.push([t[a], n[a]]);
    return r({ type: "MultiLineString", coordinates: o });
  };
}
function Jd(e, { x: t, y: n, ...r } = {}) {
  return [t, n] = Jn(t, n), new Hd(e, { ...r, x: t, y: n });
}
function Qc(e, { x: t = yt, y: n = Ve, ...r } = {}) {
  return new Hd(e, s1({ ...r, x: t, y: n }));
}
function tu(e, { x: t = Ve, y: n = yt, ...r } = {}) {
  return new Hd(e, i1({ ...r, x: t, y: n }));
}
const NG = {
  ariaLabel: "rect"
};
class Zd extends Ht {
  constructor(t, n = {}) {
    const {
      x1: r,
      y1: i,
      x2: s,
      y2: o,
      inset: a = 0,
      insetTop: c = a,
      insetRight: u = a,
      insetBottom: l = a,
      insetLeft: f = a,
      rx: h,
      ry: d
    } = n;
    super(
      t,
      {
        x1: { value: r, scale: "x", type: r != null && s == null ? "band" : void 0, optional: !0 },
        y1: { value: i, scale: "y", type: i != null && o == null ? "band" : void 0, optional: !0 },
        x2: { value: s, scale: "x", optional: !0 },
        y2: { value: o, scale: "y", optional: !0 }
      },
      n,
      NG
    ), this.insetTop = Nt(c), this.insetRight = Nt(u), this.insetBottom = Nt(l), this.insetLeft = Nt(f), this.rx = oe(h, "auto"), this.ry = oe(d, "auto");
  }
  render(t, n, r, i, s) {
    const { x: o, y: a } = n, { x1: c, y1: u, x2: l, y2: f } = r, { marginTop: h, marginRight: d, marginBottom: p, marginLeft: y, width: m, height: g } = i, { projection: b } = s, { insetTop: w, insetRight: _, insetBottom: x, insetLeft: v, rx: M, ry: E } = this, $ = (o != null && o.bandwidth ? o.bandwidth() : 0) - v - _, N = (a != null && a.bandwidth ? a.bandwidth() : 0) - w - x;
    return Ot("svg:g", s).call(ne, this, i, s).call(Gt, this, {}, 0, 0).call(
      (A) => A.selectAll().data(t).enter().append("rect").call(te, this).attr(
        "x",
        c && (b || !Mn(o)) ? l ? (D) => Math.min(c[D], l[D]) + v : (D) => c[D] + v : y + v
      ).attr(
        "y",
        u && (b || !Mn(a)) ? f ? (D) => Math.min(u[D], f[D]) + w : (D) => u[D] + w : h + w
      ).attr(
        "width",
        c && (b || !Mn(o)) ? l ? (D) => Math.max(0, Math.abs(l[D] - c[D]) + $) : $ : m - d - y - _ - v
      ).attr(
        "height",
        u && (b || !Mn(a)) ? f ? (D) => Math.max(0, Math.abs(u[D] - f[D]) + N) : N : g - h - p - w - x
      ).call(at, "rx", M).call(at, "ry", E).call(ge, this, r)
    ).node();
  }
}
function y1(e, t) {
  return new Zd(e, v$(x$(t)));
}
function Oh(e, t = {}) {
  return $d(t) || (t = { ...t, y: Ve, x2: yt, interval: 1 }), new Zd(e, f1(x$(u1(t))));
}
function Lh(e, t = {}) {
  return $d(t) || (t = { ...t, x: Ve, y2: yt, interval: 1 }), new Zd(e, h1(v$(l1(t))));
}
function P8(e, t) {
  t = OG(t);
  const { x: n, y: r, color: i, size: s } = t, o = gl(e, n), a = gl(e, r), c = gl(e, i), u = gl(e, s);
  let {
    fx: l,
    fy: f,
    x: { value: h, reduce: d, zero: p, ...y },
    y: { value: m, reduce: g, zero: b, ...w },
    color: { value: _, color: x, reduce: v },
    size: { value: M, reduce: E },
    // TODO constant radius?
    mark: $
  } = t;
  if (d === void 0 && (d = g == null && h == null && M == null && m != null ? "count" : null), g === void 0 && (g = d == null && m == null && M == null && h != null ? "count" : null), E === void 0 && M == null && v == null && d == null && g == null && (h == null || se(o)) && (m == null || se(a)) && (E = "count"), p === void 0 && (p = bl(d) ? !0 : void 0), b === void 0 && (b = bl(g) ? !0 : void 0), h == null && m == null) throw new Error("must specify x or y");
  if (d != null && m == null) throw new Error("reducing x requires y");
  if (g != null && h == null) throw new Error("reducing y requires x");
  $ === void 0 && ($ = M != null || E != null ? "dot" : bl(d) || bl(g) || v != null ? "bar" : h != null && m != null ? se(o) || se(a) || d == null && g == null && !za(o) && !za(a) ? "dot" : "line" : h != null || m != null ? "rule" : null);
  let N, A, D;
  switch ($) {
    case "dot":
      D = ts, A = "stroke";
      break;
    case "line":
      D = o && a || d != null || g != null ? b || g != null || o && za(o) ? tu : p || d != null || a && za(a) ? Qc : Jd : o ? Qc : tu, A = "stroke", o_(c) && (N = null);
      break;
    case "area":
      D = !(b || g != null) && (p || d != null || a && za(a)) ? Kc : ca, A = "fill", o_(c) && (N = null);
      break;
    case "rule":
      D = o ? zi : qi, A = "stroke";
      break;
    case "bar":
      D = d != null ? se(a) ? s_(d) && o && se(o) ? vo : ps : Oh : g != null ? se(o) ? s_(g) && a && se(a) ? vo : ys : Lh : v != null || E != null ? o && se(o) && a && se(a) ? vo : o && se(o) ? ys : a && se(a) ? ps : y1 : o && _o(o) && !(a && _o(a)) ? ps : a && _o(a) && !(o && _o(o)) ? ys : vo, A = "fill";
      break;
    default:
      throw new Error(`invalid mark: ${$}`);
  }
  let k = {
    fx: l,
    fy: f,
    x: o ?? void 0,
    // treat null x as undefined for implicit stack
    y: a ?? void 0,
    // treat null y as undefined for implicit stack
    [A]: c ?? x,
    z: N,
    r: u ?? void 0,
    // treat null size as undefined for default constant radius
    tip: !0
  }, S, I = { [A]: v ?? void 0, r: E ?? void 0 };
  if (d != null && g != null)
    throw new Error("cannot reduce both x and y");
  return g != null ? (I.y = g, S = se(o) ? Wc : Mi) : d != null ? (I.x = d, S = se(a) ? Xc : Ai) : (v != null || E != null) && (o && a ? S = se(o) && se(a) ? Dg : se(o) ? Ai : se(a) ? Mi : cs : o ? S = se(o) ? Wc : Mi : a && (S = se(a) ? Xc : Ai)), (S === cs || S === Mi) && (k.x = { value: o, ...y }), (S === cs || S === Ai) && (k.y = { value: a, ...w }), p === void 0 && (p = o && !(S === cs || S === Mi) && (D === ps || D === Kc || D === Oh || D === qi)), b === void 0 && (b = a && !(S === cs || S === Ai) && (D === ys || D === ca || D === Lh || D === zi)), {
    fx: l ?? null,
    fy: f ?? null,
    x: {
      value: h ?? null,
      reduce: d ?? null,
      zero: !!p,
      ...y
    },
    y: {
      value: m ?? null,
      reduce: g ?? null,
      zero: !!b,
      ...w
    },
    color: {
      value: _ ?? null,
      reduce: v ?? null,
      ...x !== void 0 && { color: x }
    },
    size: {
      value: M ?? null,
      reduce: E ?? null
    },
    mark: $,
    markImpl: a_[D],
    markOptions: k,
    transformImpl: a_[S],
    transformOptions: I,
    colorMode: A
  };
}
function DG(e, t) {
  const n = P8(e, t), {
    fx: r,
    fy: i,
    x: { zero: s },
    y: { zero: o },
    markOptions: a,
    transformOptions: c,
    colorMode: u
  } = n, l = Fy[n.markImpl], f = Fy[n.transformImpl], h = r != null || i != null ? t1({ strokeOpacity: 0.1 }) : null, d = [s ? zi([0]) : null, o ? qi([0]) : null], p = l(e, f ? f(c, a) : a);
  return u === "stroke" ? En(h, d, p) : En(h, p, d);
}
function za(e) {
  let t, n;
  for (const r of e) {
    if (r == null) continue;
    if (t === void 0) {
      t = r;
      continue;
    }
    const i = Math.sign(zt(t, r));
    if (i) {
      if (n !== void 0 && i !== n) return !1;
      t = r, n = i;
    }
  }
  return !0;
}
function OG({ x: e, y: t, color: n, size: r, fx: i, fy: s, mark: o } = {}) {
  return rr(e) || (e = eo(e)), rr(t) || (t = eo(t)), rr(n) || (n = Tu(n) ? { color: n } : eo(n)), rr(r) || (r = eo(r)), rr(i) && ({ value: i } = eo(i)), rr(s) && ({ value: s } = eo(s)), o != null && (o = `${o}`.toLowerCase()), { x: e, y: t, color: n, size: r, fx: i, fy: s, mark: o };
}
function gl(e, t) {
  const n = $t(e, t.value);
  return n && (n.label = Mr(t.value)), n;
}
function eo(e) {
  return LG(e) ? { reduce: e } : { value: e };
}
function bl(e) {
  return /^(?:distinct|count|sum|proportion)$/i.test(e);
}
function s_(e) {
  return /^(?:first|last|mode)$/i.test(e);
}
function LG(e) {
  if (e == null) return !1;
  if (typeof e.reduceIndex == "function" || typeof e.reduce == "function" && Nn(e) || /^p\d{2}$/i.test(e)) return !0;
  switch (`${e}`.toLowerCase()) {
    case "first":
    case "last":
    case "count":
    case "distinct":
    case "sum":
    case "proportion":
    case "proportion-facet":
    case "deviation":
    case "min":
    case "min-index":
    case "max":
    case "max-index":
    case "mean":
    case "median":
    case "variance":
    case "mode":
      return !0;
  }
  return !1;
}
function o_(e) {
  return e ? new pa(e).size > e.length >> 1 : !1;
}
const Fy = {
  dot: ts,
  line: Jd,
  lineX: Qc,
  lineY: tu,
  areaX: Kc,
  areaY: ca,
  ruleX: zi,
  ruleY: qi,
  barX: ps,
  barY: ys,
  rect: y1,
  rectX: Oh,
  rectY: Lh,
  cell: vo,
  bin: cs,
  binX: Mi,
  binY: Ai,
  group: Dg,
  groupX: Wc,
  groupY: Xc
}, a_ = Object.fromEntries(Object.entries(Fy).map(([e, t]) => [t, e]));
function m1(e, t = {}) {
  let { x: n, x1: r, x2: i } = t;
  n === void 0 && r === void 0 && i === void 0 && (t = { ...t, x: n = yt });
  const s = {};
  return n != null && (s.x = e), r != null && (s.x1 = e), i != null && (s.x2 = e), vr(s, t);
}
function g1(e, t = {}) {
  let { y: n, y1: r, y2: i } = t;
  n === void 0 && r === void 0 && i === void 0 && (t = { ...t, y: n = yt });
  const s = {};
  return n != null && (s.y = e), r != null && (s.y1 = e), i != null && (s.y2 = e), vr(s, t);
}
function vr(e = {}, t = {}) {
  const n = Zi(t), r = Object.entries(e).map(([i, s]) => {
    const o = _A(i, t);
    if (o == null) throw new Error(`missing channel: ${i}`);
    const [a, c] = an(o);
    return { key: i, input: o, output: a, setOutput: c, map: RG(s) };
  });
  return {
    ...Ar(t, (i, s) => {
      const o = $t(i, n), a = r.map(({ input: u }) => $t(i, u)), c = r.map(({ setOutput: u }) => u(new Array(i.length)));
      for (const u of s)
        for (const l of o ? ci(u, (f) => o[f]).values() : [u])
          r.forEach(({ map: f }, h) => f.mapIndex(l, a[h], c[h]));
      return { data: i, facets: s };
    }),
    ...Object.fromEntries(r.map(({ key: i, output: s }) => [i, s]))
  };
}
function RG(e) {
  if (e == null) throw new Error("missing map");
  if (typeof e.mapIndex == "function") return e;
  if (typeof e.map == "function" && Nn(e)) return kG(e);
  if (typeof e == "function") return o0(xg(e));
  switch (`${e}`.toLowerCase()) {
    case "cumsum":
      return BG;
    case "rank":
      return o0((t, n) => _S(t, (r) => n[r]));
    case "quantile":
      return o0((t, n) => FG(t, (r) => n[r]));
  }
  throw new Error(`invalid map: ${e}`);
}
function kG(e) {
  return console.warn("deprecated map interface; implement mapIndex instead."), { mapIndex: e.map.bind(e) };
}
function FG(e, t) {
  const n = Kh(e, t) - 1;
  return _S(e, t).map((r) => r / n);
}
function o0(e) {
  return {
    mapIndex(t, n, r) {
      const i = e(t, n);
      if (i.length !== t.length) throw new Error("map function returned a mismatched length");
      for (let s = 0, o = t.length; s < o; ++s) r[t[s]] = i[s];
    }
  };
}
const BG = {
  mapIndex(e, t, n) {
    let r = 0;
    for (const i of e) n[i] = r += t[i];
  }
};
function CG(e = {}, t) {
  return arguments.length === 1 && (t = e), m1(Kd(e), t);
}
function PG(e = {}, t) {
  return arguments.length === 1 && (t = e), g1(Kd(e), t);
}
function Kd(e = {}) {
  typeof e == "number" && (e = { k: e });
  let { k: t, reduce: n, shift: r, anchor: i, strict: s } = e;
  if (i === void 0 && r !== void 0 && (i = zG(r), ti(`Warning: the shift option is deprecated; please use anchor "${i}" instead.`)), !((t = Math.floor(t)) > 0)) throw new Error(`invalid k: ${t}`);
  return qG(n)(t, UG(i, t), s);
}
function UG(e = "middle", t) {
  switch (`${e}`.toLowerCase()) {
    case "middle":
      return t - 1 >> 1;
    case "start":
      return 0;
    case "end":
      return t - 1;
  }
  throw new Error(`invalid anchor: ${e}`);
}
function zG(e) {
  switch (`${e}`.toLowerCase()) {
    case "centered":
      return "middle";
    case "leading":
      return "start";
    case "trailing":
      return "end";
  }
  throw new Error(`invalid shift: ${e}`);
}
function qG(e = "mean") {
  if (typeof e == "string") {
    if (/^p\d{2}$/i.test(e)) return wl(_g(e));
    switch (e.toLowerCase()) {
      case "deviation":
        return wl(fu);
      case "max":
        return _l((t, n) => ce(t, (r) => n[r]));
      case "mean":
        return jG;
      case "median":
        return wl(Lc);
      case "min":
        return _l((t, n) => ve(t, (r) => n[r]));
      case "mode":
        return _l((t, n) => wS(t, (r) => n[r]));
      case "sum":
        return U8;
      case "variance":
        return wl(Lm);
      case "difference":
        return WG;
      case "ratio":
        return XG;
      case "first":
        return GG;
      case "last":
        return HG;
    }
  }
  if (typeof e != "function") throw new Error(`invalid reduce: ${e}`);
  return _l(xg(e));
}
function wl(e) {
  return (t, n, r) => r ? {
    mapIndex(i, s, o) {
      const a = (u) => s[u] == null ? NaN : +s[u];
      let c = 0;
      for (let u = 0; u < t - 1; ++u) isNaN(a(u)) && ++c;
      for (let u = 0, l = i.length - t + 1; u < l; ++u)
        isNaN(a(u + t - 1)) && ++c, o[i[u + n]] = c === 0 ? e(vs(i, u, u + t), a) : NaN, isNaN(a(u)) && --c;
    }
  } : {
    mapIndex(i, s, o) {
      const a = (c) => s[c] == null ? NaN : +s[c];
      for (let c = -n; c < 0; ++c)
        o[i[c + n]] = e(vs(i, 0, c + t), a);
      for (let c = 0, u = i.length - n; c < u; ++c)
        o[i[c + n]] = e(vs(i, c, c + t), a);
    }
  };
}
function _l(e) {
  return (t, n, r) => r ? {
    mapIndex(i, s, o) {
      let a = 0;
      for (let c = 0; c < t - 1; ++c) a += Pe(s[i[c]]);
      for (let c = 0, u = i.length - t + 1; c < u; ++c)
        a += Pe(s[i[c + t - 1]]), a === t && (o[i[c + n]] = e(vs(i, c, c + t), s)), a -= Pe(s[i[c]]);
    }
  } : {
    mapIndex(i, s, o) {
      for (let a = -n; a < 0; ++a)
        o[i[a + n]] = e(vs(i, 0, a + t), s);
      for (let a = 0, c = i.length - n; a < c; ++a)
        o[i[a + n]] = e(vs(i, a, a + t), s);
    }
  };
}
function U8(e, t, n) {
  return n ? {
    mapIndex(r, i, s) {
      let o = 0, a = 0;
      for (let c = 0; c < e - 1; ++c) {
        const u = i[r[c]];
        u === null || isNaN(u) ? ++o : a += +u;
      }
      for (let c = 0, u = r.length - e + 1; c < u; ++c) {
        const l = i[r[c]], f = i[r[c + e - 1]];
        f === null || isNaN(f) ? ++o : a += +f, s[r[c + t]] = o === 0 ? a : NaN, l === null || isNaN(l) ? --o : a -= +l;
      }
    }
  } : {
    mapIndex(r, i, s) {
      let o = 0;
      const a = r.length;
      for (let c = 0, u = Math.min(a, e - t - 1); c < u; ++c)
        o += +i[r[c]] || 0;
      for (let c = -t, u = a - t; c < u; ++c)
        o += +i[r[c + e - 1]] || 0, s[r[c + t]] = o, o -= +i[r[c]] || 0;
    }
  };
}
function jG(e, t, n) {
  if (n) {
    const r = U8(e, t, n);
    return {
      mapIndex(i, s, o) {
        r.mapIndex(i, s, o);
        for (let a = 0, c = i.length - e + 1; a < c; ++a)
          o[i[a + t]] /= e;
      }
    };
  } else
    return {
      mapIndex(r, i, s) {
        let o = 0, a = 0;
        const c = r.length;
        for (let u = 0, l = Math.min(c, e - t - 1); u < l; ++u) {
          let f = i[r[u]];
          f !== null && !isNaN(f = +f) && (o += f, ++a);
        }
        for (let u = -t, l = c - t; u < l; ++u) {
          let f = i[r[u + e - 1]], h = i[r[u]];
          f !== null && !isNaN(f = +f) && (o += f, ++a), s[r[u + t]] = o / a, h !== null && !isNaN(h = +h) && (o -= h, --a);
        }
      }
    };
}
function VG(e, t, n, r) {
  for (let i = n + r; n < i; ++n) {
    const s = e[t[n]];
    if (Pe(s)) return s;
  }
}
function YG(e, t, n, r) {
  for (let i = n + r - 1; i >= n; --i) {
    const s = e[t[i]];
    if (Pe(s)) return s;
  }
}
function z8(e, t, n, r) {
  for (let i = n + r; n < i; ++n) {
    let s = e[t[n]];
    if (s !== null && !isNaN(s = +s)) return s;
  }
}
function q8(e, t, n, r) {
  for (let i = n + r - 1; i >= n; --i) {
    let s = e[t[i]];
    if (s !== null && !isNaN(s = +s)) return s;
  }
}
function WG(e, t, n) {
  return n ? {
    mapIndex(r, i, s) {
      for (let o = 0, a = r.length - e; o < a; ++o) {
        const c = i[r[o]], u = i[r[o + e - 1]];
        s[r[o + t]] = c === null || u === null ? NaN : u - c;
      }
    }
  } : {
    mapIndex(r, i, s) {
      for (let o = -t, a = r.length - e + t + 1; o < a; ++o)
        s[r[o + t]] = q8(i, r, o, e) - z8(i, r, o, e);
    }
  };
}
function XG(e, t, n) {
  return n ? {
    mapIndex(r, i, s) {
      for (let o = 0, a = r.length - e; o < a; ++o) {
        const c = i[r[o]], u = i[r[o + e - 1]];
        s[r[o + t]] = c === null || u === null ? NaN : u / c;
      }
    }
  } : {
    mapIndex(r, i, s) {
      for (let o = -t, a = r.length - e + t + 1; o < a; ++o)
        s[r[o + t]] = q8(i, r, o, e) / z8(i, r, o, e);
    }
  };
}
function GG(e, t, n) {
  return n ? {
    mapIndex(r, i, s) {
      for (let o = 0, a = r.length - e; o < a; ++o)
        s[r[o + t]] = i[r[o]];
    }
  } : {
    mapIndex(r, i, s) {
      for (let o = -t, a = r.length - e + t + 1; o < a; ++o)
        s[r[o + t]] = VG(i, r, o, e);
    }
  };
}
function HG(e, t, n) {
  return n ? {
    mapIndex(r, i, s) {
      for (let o = 0, a = r.length - e; o < a; ++o)
        s[r[o + t]] = i[r[o + e - 1]];
    }
  } : {
    mapIndex(r, i, s) {
      for (let o = -t, a = r.length - e + t + 1; o < a; ++o)
        s[r[o + t]] = YG(i, r, o, e);
    }
  };
}
const ei = {
  n: 20,
  k: 2,
  color: "currentColor",
  opacity: 0.2,
  strict: !0,
  anchor: "end"
};
function JG(e, {
  x: t = yt,
  y: n,
  k: r = ei.k,
  color: i = ei.color,
  opacity: s = ei.opacity,
  fill: o = i,
  fillOpacity: a = s,
  stroke: c = i,
  strokeOpacity: u,
  strokeWidth: l,
  ...f
} = {}) {
  return En(
    ee(o) ? null : Kc(
      e,
      vr(
        { x1: xs({ k: -r, ...f }), x2: xs({ k: r, ...f }) },
        { x1: t, x2: t, y: n, fill: o, fillOpacity: a, ...f }
      )
    ),
    ee(c) ? null : Qc(e, vr({ x: xs(f) }, { x: t, y: n, stroke: c, strokeOpacity: u, strokeWidth: l, ...f }))
  );
}
function ZG(e, {
  x: t,
  y: n = yt,
  k: r = ei.k,
  color: i = ei.color,
  opacity: s = ei.opacity,
  fill: o = i,
  fillOpacity: a = s,
  stroke: c = i,
  strokeOpacity: u,
  strokeWidth: l,
  ...f
} = {}) {
  return En(
    ee(o) ? null : ca(
      e,
      vr(
        { y1: xs({ k: -r, ...f }), y2: xs({ k: r, ...f }) },
        { x: t, y1: n, y2: n, fill: o, fillOpacity: a, ...f }
      )
    ),
    ee(c) ? null : tu(e, vr({ y: xs(f) }, { x: t, y: n, stroke: c, strokeOpacity: u, strokeWidth: l, ...f }))
  );
}
function xs({ n: e = ei.n, k: t = 0, strict: n = ei.strict, anchor: r = ei.anchor } = {}) {
  return Kd({ k: e, reduce: (i) => Qh(i) + t * (fu(i) || 0), strict: n, anchor: r });
}
const KG = {
  ariaLabel: "tick",
  fill: null,
  stroke: "currentColor"
};
class j8 extends Ht {
  constructor(t, n, r) {
    super(t, n, r, KG), va(this, r);
  }
  render(t, n, r, i, s) {
    return Ot("svg:g", s).call(ne, this, i, s).call(this._transform, this, n).call(
      (o) => o.selectAll().data(t).enter().append("line").call(te, this).attr("x1", this._x1(n, r, i)).attr("x2", this._x2(n, r, i)).attr("y1", this._y1(n, r, i)).attr("y2", this._y2(n, r, i)).call(ge, this, r).call(ku, this, r, s)
    ).node();
  }
}
class V8 extends j8 {
  constructor(t, n = {}) {
    const { x: r, y: i, inset: s = 0, insetTop: o = s, insetBottom: a = s } = n;
    super(
      t,
      {
        x: { value: r, scale: "x" },
        y: { value: i, scale: "y", type: "band", optional: !0 }
      },
      n
    ), this.insetTop = Nt(o), this.insetBottom = Nt(a);
  }
  _transform(t, n, { x: r }) {
    t.call(Gt, n, { x: r }, Ae, 0);
  }
  _x1(t, { x: n }) {
    return (r) => n[r];
  }
  _x2(t, { x: n }) {
    return (r) => n[r];
  }
  _y1({ y: t }, { y: n }, { marginTop: r }) {
    const { insetTop: i } = this;
    return n && t ? (s) => n[s] + i : r + i;
  }
  _y2({ y: t }, { y: n }, { height: r, marginBottom: i }) {
    const { insetBottom: s } = this;
    return n && t ? (o) => n[o] + t.bandwidth() - s : r - i - s;
  }
}
class Y8 extends j8 {
  constructor(t, n = {}) {
    const { x: r, y: i, inset: s = 0, insetRight: o = s, insetLeft: a = s } = n;
    super(
      t,
      {
        y: { value: i, scale: "y" },
        x: { value: r, scale: "x", type: "band", optional: !0 }
      },
      n
    ), this.insetRight = Nt(o), this.insetLeft = Nt(a);
  }
  _transform(t, n, { y: r }) {
    t.call(Gt, n, { y: r }, 0, Ae);
  }
  _x1({ x: t }, { x: n }, { marginLeft: r }) {
    const { insetLeft: i } = this;
    return n && t ? (s) => n[s] + i : r + i;
  }
  _x2({ x: t }, { x: n }, { width: r, marginRight: i }) {
    const { insetRight: s } = this;
    return n && t ? (o) => n[o] + t.bandwidth() - s : r - i - s;
  }
  _y1(t, { y: n }) {
    return (r) => n[r];
  }
  _y2(t, { y: n }) {
    return (r) => n[r];
  }
}
function W8(e, { x: t = yt, ...n } = {}) {
  return new V8(e, { ...n, x: t });
}
function X8(e, { y: t = yt, ...n } = {}) {
  return new Y8(e, { ...n, y: t });
}
function QG(e, {
  x: t = yt,
  y: n = null,
  fill: r = "#ccc",
  fillOpacity: i,
  stroke: s = "currentColor",
  strokeOpacity: o,
  strokeWidth: a = 2,
  sort: c,
  ...u
} = {}) {
  const l = n != null ? Xc : Ng;
  return En(
    qi(e, l({ x1: b1, x2: w1 }, { x: t, y: n, stroke: s, strokeOpacity: o, ...u })),
    ps(e, l({ x1: "p25", x2: "p75" }, { x: t, y: n, fill: r, fillOpacity: i, ...u })),
    W8(e, l({ x: "p50" }, { x: t, y: n, stroke: s, strokeOpacity: o, strokeWidth: a, sort: c, ...u })),
    ts(e, vr({ x: G8 }, { x: t, y: n, z: n, stroke: s, strokeOpacity: o, ...u }))
  );
}
function tH(e, {
  y: t = yt,
  x: n = null,
  fill: r = "#ccc",
  fillOpacity: i,
  stroke: s = "currentColor",
  strokeOpacity: o,
  strokeWidth: a = 2,
  sort: c,
  ...u
} = {}) {
  const l = n != null ? Wc : Ng;
  return En(
    zi(e, l({ y1: b1, y2: w1 }, { x: n, y: t, stroke: s, strokeOpacity: o, ...u })),
    ys(e, l({ y1: "p25", y2: "p75" }, { x: n, y: t, fill: r, fillOpacity: i, ...u })),
    X8(e, l({ y: "p50" }, { x: n, y: t, stroke: s, strokeOpacity: o, strokeWidth: a, sort: c, ...u })),
    ts(e, vr({ y: G8 }, { x: n, y: t, z: n, stroke: s, strokeOpacity: o, ...u }))
  );
}
function G8(e) {
  const t = b1(e), n = w1(e);
  return e.map((r) => r < t || r > n ? r : NaN);
}
function b1(e) {
  const t = H8(e) * 2.5 - J8(e) * 1.5;
  return ve(e, (n) => n >= t ? n : NaN);
}
function w1(e) {
  const t = J8(e) * 2.5 - H8(e) * 1.5;
  return ce(e, (n) => n <= t ? n : NaN);
}
function H8(e) {
  return Bi(e, 0.25);
}
function J8(e) {
  return Bi(e, 0.75);
}
const eH = {
  ariaLabel: "raster",
  stroke: null,
  pixelSize: 1
};
function no(e, t) {
  const n = +e;
  if (isNaN(n)) throw new Error(`invalid ${t}: ${e}`);
  return n;
}
function c_(e, t) {
  const n = Math.floor(e);
  if (isNaN(n)) throw new Error(`invalid ${t}: ${e}`);
  return n;
}
class Z8 extends Ht {
  constructor(t, n, r = {}, i) {
    let {
      width: s,
      height: o,
      x: a,
      y: c,
      x1: u = a == null ? 0 : void 0,
      y1: l = c == null ? 0 : void 0,
      x2: f = a == null ? s : void 0,
      y2: h = c == null ? o : void 0,
      pixelSize: d = i.pixelSize,
      blur: p = 0,
      interpolate: y
    } = r;
    if (s != null && (s = c_(s, "width")), o != null && (o = c_(o, "height")), u != null && (u = no(u, "x1")), l != null && (l = no(l, "y1")), f != null && (f = no(f, "x2")), h != null && (h = no(h, "y2")), a == null && (u == null || f == null)) throw new Error("missing x");
    if (c == null && (l == null || h == null)) throw new Error("missing y");
    t != null && s != null && o != null && (a === void 0 && u != null && f != null && (a = lH(u, f, s)), c === void 0 && l != null && h != null && (c = fH(l, h, s, o))), super(
      t,
      {
        x: { value: a, scale: "x", optional: !0 },
        y: { value: c, scale: "y", optional: !0 },
        x1: { value: u == null ? null : [u], scale: "x", optional: !0, filter: null },
        y1: { value: l == null ? null : [l], scale: "y", optional: !0, filter: null },
        x2: { value: f == null ? null : [f], scale: "x", optional: !0, filter: null },
        y2: { value: h == null ? null : [h], scale: "y", optional: !0, filter: null },
        ...n
      },
      r,
      i
    ), this.width = s, this.height = o, this.pixelSize = no(d, "pixelSize"), this.blur = no(p, "blur"), this.interpolate = a == null || c == null ? null : rH(y);
  }
}
class K8 extends Z8 {
  constructor(t, n = {}) {
    const { imageRendering: r } = n;
    if (t == null) {
      const { fill: i, fillOpacity: s } = n;
      fe(s)[0] !== void 0 && (n = By("fillOpacity", n)), ze(i)[0] !== void 0 && (n = By("fill", n));
    }
    super(t, void 0, n, eH), this.imageRendering = oe(r, "auto");
  }
  // Ignore the color scale, so the fill channel is returned unscaled.
  scale(t, { color: n, ...r }, i) {
    return super.scale(t, r, i);
  }
  render(t, n, r, i, s) {
    var I;
    const o = n[(I = r.channels.fill) == null ? void 0 : I.scale] ?? ((T) => T), { x: a, y: c } = r, { document: u } = s, [l, f, h, d] = t4(r, i, s), p = h - l, y = d - f, { pixelSize: m, width: g = Math.round(Math.abs(p) / m), height: b = Math.round(Math.abs(y) / m) } = this, w = g * b;
    let { fill: _, fillOpacity: x } = r, v = 0;
    if (this.interpolate) {
      const T = g / p, R = b / y, B = Zt(a, (F) => (F - l) * T, Float64Array), C = Zt(c, (F) => (F - f) * R, Float64Array);
      _ && (_ = this.interpolate(t, g, b, B, C, _)), x && (x = this.interpolate(t, g, b, B, C, x));
    } else this.data == null && t && (v = t.fi * w);
    const M = u.createElement("canvas");
    M.width = g, M.height = b;
    const E = M.getContext("2d"), $ = E.createImageData(g, b), N = $.data;
    let { r: A, g: D, b: k } = un(this.fill) ?? { r: 0, g: 0, b: 0 }, S = (this.fillOpacity ?? 1) * 255;
    for (let T = 0; T < w; ++T) {
      const R = T << 2;
      if (_) {
        const B = o(_[T + v]);
        if (B == null) {
          N[R + 3] = 0;
          continue;
        }
        ({ r: A, g: D, b: k } = un(B));
      }
      x && (S = x[T + v] * 255), N[R + 0] = A, N[R + 1] = D, N[R + 2] = k, N[R + 3] = S;
    }
    return this.blur > 0 && ek($, this.blur), E.putImageData($, 0, 0), Ot("svg:g", s).call(ne, this, i, s).call(Gt, this, n).call(
      (T) => T.append("image").attr("transform", `translate(${l},${f}) scale(${Math.sign(h - l)},${Math.sign(d - f)})`).attr("width", Math.abs(p)).attr("height", Math.abs(y)).attr("preserveAspectRatio", "none").call(at, "image-rendering", this.imageRendering).call(te, this).attr("xlink:href", M.toDataURL())
    ).node();
  }
}
function Q8(e, t, n) {
  arguments.length < 3 && (n = t, t = null);
  let { x: r, y: i, [e]: s, ...o } = n;
  return r === void 0 && i === void 0 && IV(t) && (r = Ad, i = Vc, s === void 0 && (s = xV)), [t, { ...o, x: r, y: i, [e]: s }];
}
function nH() {
  const [e, t] = Q8("fill", ...arguments);
  return new K8(
    e,
    e == null || t.fill !== void 0 || t.fillOpacity !== void 0 ? t : { ...t, fill: yt }
  );
}
function t4({ x1: e, y1: t, x2: n, y2: r }, i, { projection: s }) {
  const { width: o, height: a, marginTop: c, marginRight: u, marginBottom: l, marginLeft: f } = i;
  return [
    e && s == null ? e[0] : f,
    t && s == null ? t[0] : c,
    n && s == null ? n[0] : o - u,
    r && s == null ? r[0] : a - l
  ];
}
function e4({ x1: e, y1: t, x2: n, y2: r }, i, s, o) {
  const a = {};
  return e && (a.x1 = e), t && (a.y1 = t), n && (a.x2 = n), r && (a.y2 = r), t4(Bg(a, i), s, o);
}
function By(e, t = {}) {
  const { [e]: n } = t;
  if (typeof n != "function") throw new Error(`invalid ${e}: not a function`);
  return tn({ ...t, [e]: void 0 }, function(r, i, s, o, a, c) {
    const { x: u, y: l } = o;
    if (!u) throw new Error("missing scale: x");
    if (!l) throw new Error("missing scale: y");
    const [f, h, d, p] = e4(s, o, a, c), y = d - f, m = p - h, { pixelSize: g } = this, { width: b = Math.round(Math.abs(y) / g), height: w = Math.round(Math.abs(m) / g) } = t, _ = new Array(b * w * (i ? i.length : 1)), x = y / b, v = m / w;
    let M = 0;
    for (const E of i ?? [void 0])
      for (let $ = 0.5; $ < w; ++$)
        for (let N = 0.5; N < b; ++N, ++M)
          _[M] = n(u.invert(f + N * x), l.invert(h + $ * v), E);
    return { data: _, facets: i, channels: { [e]: { value: _, scale: "auto" } } };
  });
}
function rH(e) {
  if (typeof e == "function") return e;
  if (e == null) return Cy;
  switch (`${e}`.toLowerCase()) {
    case "none":
      return Cy;
    case "nearest":
      return v1;
    case "barycentric":
      return _1();
    case "random-walk":
      return x1();
  }
  throw new Error(`invalid interpolate: ${e}`);
}
function Cy(e, t, n, r, i, s) {
  const o = new Array(t * n);
  for (const a of e)
    r[a] < 0 || r[a] >= t || i[a] < 0 || i[a] >= n || (o[Math.floor(i[a]) * t + Math.floor(r[a])] = s[a]);
  return o;
}
function _1({ random: e = rg(42) } = {}) {
  return (t, n, r, i, s, o) => {
    const { points: a, triangles: c, hull: u } = Gi.from(
      t,
      (d) => i[d],
      (d) => s[d]
    ), l = new o.constructor(n * r).fill(NaN), f = new Uint8Array(n * r), h = uH(o, e);
    for (let d = 0; d < c.length; d += 3) {
      const p = c[d], y = c[d + 1], m = c[d + 2], g = a[2 * p], b = a[2 * y], w = a[2 * m], _ = a[2 * p + 1], x = a[2 * y + 1], v = a[2 * m + 1], M = Math.min(g, b, w), E = Math.max(g, b, w), $ = Math.min(_, x, v), N = Math.max(_, x, v), A = (x - v) * (g - w) + (_ - v) * (w - b);
      if (!A) continue;
      const D = o[t[p]], k = o[t[y]], S = o[t[m]];
      for (let I = Math.floor(M); I < E; ++I)
        for (let T = Math.floor($); T < N; ++T) {
          if (I < 0 || I >= n || T < 0 || T >= r) continue;
          const R = I + 0.5, B = T + 0.5, C = Math.sign(A), F = (x - v) * (R - w) + (B - v) * (w - b);
          if (F * C < 0) continue;
          const P = (v - _) * (R - w) + (B - v) * (g - w);
          if (P * C < 0) continue;
          const U = A - (F + P);
          if (U * C < 0) continue;
          const Y = I + n * T;
          l[Y] = h(D, F / A, k, P / A, S, U / A, I, T), f[Y] = 1;
        }
    }
    return iH(l, f, i, s, o, n, r, u, t, h), l;
  };
}
function iH(e, t, n, r, i, s, o, a, c, u) {
  n = Float64Array.from(a, (d) => n[c[d]]), r = Float64Array.from(a, (d) => r[c[d]]), i = Array.from(a, (d) => i[c[d]]);
  const l = n.length, f = Array.from({ length: l }, (d, p) => oH(p, n, r));
  let h = 0;
  for (let d = 0; d < o; ++d) {
    const p = d + 0.5;
    for (let y = 0; y < s; ++y) {
      const m = y + s * d;
      if (!t[m]) {
        const g = y + 0.5;
        for (let b = 0; b < l; ++b) {
          const w = (l + h + (b % 2 ? (b + 1) / 2 : -b / 2)) % l;
          if (f[w](g, p)) {
            const _ = sH(n.at(w - 1), r.at(w - 1), n[w], r[w], g, p);
            e[m] = u(i.at(w - 1), _, i[w], 1 - _, i[w], 0, y, d), h = w;
            break;
          }
        }
      }
    }
  }
}
function sH(e, t, n, r, i, s) {
  const o = n - e, a = r - t, c = o * (n - i) + a * (r - s), u = o * (i - e) + a * (s - t);
  return c > 0 && u > 0 ? c / (c + u) : +(c > u);
}
function qa(e, t, n, r) {
  return e * r - n * t;
}
function oH(e, t, n) {
  const r = t.length, i = t.at(e - 2), s = n.at(e - 2), o = t.at(e - 1), a = n.at(e - 1), c = t[e], u = n[e], l = t.at(e + 1 - r), f = n.at(e + 1 - r), h = o - c, d = a - u, p = i - o, y = s - a, m = c - l, g = u - f, b = Math.hypot(h, d), w = Math.hypot(p, y), _ = Math.hypot(m, g);
  return (x, v) => {
    const M = x - o, E = v - a, $ = x - c, N = v - u;
    return qa(M, E, $, N) > -1e-6 && qa(M, E, h, d) * w - qa(M, E, p, y) * b > -1e-6 && qa($, N, m, g) * b - qa($, N, h, d) * _ <= 0;
  };
}
function v1(e, t, n, r, i, s) {
  const o = new s.constructor(t * n), a = Gi.from(
    e,
    (l) => r[l],
    (l) => i[l]
  );
  let c, u;
  for (let l = 0.5, f = 0; l < n; ++l) {
    u = c;
    for (let h = 0.5; h < t; ++h, ++f)
      u = a.find(h, l, u), h === 0.5 && (c = u), o[f] = s[e[u]];
  }
  return o;
}
function x1({ random: e = rg(42), minDistance: t = 0.5, maxSteps: n = 2 } = {}) {
  return (r, i, s, o, a, c) => {
    const u = new c.constructor(i * s), l = Gi.from(
      r,
      (p) => o[p],
      (p) => a[p]
    );
    let f, h, d;
    for (let p = 0.5, y = 0; p < s; ++p) {
      h = f;
      for (let m = 0.5; m < i; ++m, ++y) {
        let g = m, b = p;
        d = h = l.find(g, b, h), m === 0.5 && (f = h);
        let w, _ = 0;
        for (; (w = Math.hypot(o[r[d]] - g, a[r[d]] - b)) > t && _ < n; ) {
          const x = e(m, p, _) * 2 * Math.PI;
          g += Math.cos(x) * w, b += Math.sin(x) * w, d = l.find(g, b, d), ++_;
        }
        u[y] = c[r[d]];
      }
    }
    return u;
  };
}
function aH(e, t, n, r, i, s) {
  return t * e + r * n + s * i;
}
function cH(e) {
  return (t, n, r, i, s, o, a, c) => {
    const u = e(a, c);
    return u < n ? t : u < n + i ? r : s;
  };
}
function uH(e, t) {
  return _o(e) || qe(e) ? aH : cH(t);
}
function lH(e, t, n) {
  return {
    transform(r) {
      const i = r.length, s = new Float64Array(i), o = (t - e) / n, a = e + o / 2;
      for (let c = 0; c < i; ++c) s[c] = c % n * o + a;
      return s;
    }
  };
}
function fH(e, t, n, r) {
  return {
    transform(i) {
      const s = i.length, o = new Float64Array(s), a = (t - e) / r, c = e + a / 2;
      for (let u = 0; u < s; ++u) o[u] = Math.floor(u / n) % r * a + c;
      return o;
    }
  };
}
const u_ = {
  ariaLabel: "contour",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1,
  pixelSize: 2
};
class n4 extends Z8 {
  constructor(t, { smooth: n = !0, value: r, ...i } = {}) {
    const s = f$({}, i, u_);
    if (r === void 0) {
      for (const a in s)
        if (s[a].value != null) {
          if (r !== void 0) throw new Error("ambiguous contour value");
          r = i[a], i[a] = "value";
        }
    }
    if (r != null) {
      const a = { transform: (c) => c.map((u) => u.value), label: Mr(r) };
      for (const c in s)
        i[c] === "value" && (i[c] = a);
    }
    if (t == null) {
      if (r == null) throw new Error("missing contour value");
      i = By("value", { value: r, ...i }), r = null;
    } else {
      let { interpolate: a } = i;
      r === void 0 && (r = yt), a === void 0 && (i.interpolate = "nearest");
    }
    super(t, { value: { value: r, optional: !0 } }, hH(i), u_);
    const o = { geometry: { value: yt } };
    for (const a in this.channels) {
      const c = this.channels[a], { scale: u } = c;
      u === "x" || u === "y" || a === "value" || (o[a] = c, delete this.channels[a]);
    }
    this.contourChannels = o, this.smooth = !!n;
  }
  filter(t, { x: n, y: r, value: i, ...s }, o) {
    return super.filter(t, s, o);
  }
  render(t, n, r, i, s) {
    const { geometry: o } = r, a = Hi();
    return Ot("svg:g", s).call(ne, this, i, s).call(Gt, this, n).call((c) => {
      c.selectAll().data(t).enter().append("path").call(te, this).attr("d", (u) => a(o[u])).call(ge, this, r);
    }).node();
  }
}
function hH({ thresholds: e, interval: t, ...n }) {
  return e = x8(e, t, Bm), tn(n, function(r, i, s, o, a, c) {
    const [u, l, f, h] = e4(s, o, a, c), d = f - u, p = h - l, { pixelSize: y, width: m = Math.round(Math.abs(d) / y), height: g = Math.round(Math.abs(p) / y) } = this, b = m / d, w = g / p, _ = s.value.value, x = [];
    if (this.interpolate) {
      const { x: N, y: A } = Fd(s, o, c), D = Zt(N, (T) => (T - u) * b, Float64Array), k = Zt(A, (T) => (T - l) * w, Float64Array), S = [s.x, s.y, s.value], I = [D, k, _];
      for (const T of i) {
        const R = this.filter(T, S, I);
        x.push(this.interpolate(R, m, g, D, k, _));
      }
    } else if (i) {
      const N = m * g, A = i.length;
      for (let D = 0; D < A; ++D) x.push(_.slice(D * N, D * N + N));
    } else
      x.push(_);
    if (this.blur > 0) for (const N of x) uS({ data: N, width: m, height: g }, this.blur);
    const v = dH(e, _, ...yH(x));
    if (v === null) throw new Error(`unsupported thresholds: ${e}`);
    const { contour: M } = zf().size([m, g]).smooth(this.smooth), E = [], $ = [];
    for (const N of x)
      $.push(sn(E.length, E.push(...Zt(v, (A) => M(N, A)))));
    for (const { coordinates: N } of E)
      for (const A of N)
        for (const D of A)
          for (const k of D)
            k[0] = k[0] / b + u, k[1] = k[1] / w + l;
    return {
      data: E,
      facets: $,
      channels: BA(this.contourChannels, E)
    };
  });
}
function dH(e, t, n, r) {
  if (typeof (e == null ? void 0 : e.range) == "function") return e.range(e.floor(n), r);
  if (typeof e == "function" && (e = e(t, n, r)), typeof e != "number") return Qe(e);
  const i = Fi(...yS(n, r, e), e);
  for (; i[i.length - 1] >= r; ) i.pop();
  for (; i[1] < n; ) i.shift();
  return i;
}
function pH() {
  return new n4(...Q8("value", ...arguments));
}
function yH(e) {
  return [ve(e, (t) => ve(t, l_)), ce(e, (t) => ce(t, l_))];
}
function l_(e) {
  return isFinite(e) ? e : NaN;
}
function mH(e, t) {
  return S1(Cd, e, t);
}
function gH(e, t = {}) {
  return S1(Pd, e, t);
}
function bH(e, t = {}) {
  return S1(Zc, e, t);
}
function S1(e, t, n = {}) {
  const { x: r, y: i, maxRadius: s } = n, o = e({ px: r, py: i, maxRadius: s }), a = [];
  r != null && a.push(zi(t, f_("x", { ...o, inset: -6 }, n))), i != null && a.push(qi(t, f_("y", { ...o, inset: -6 }, n))), r != null && a.push(sa(t, h_("x", { ...o, dy: 9, frameAnchor: "bottom", lineAnchor: "top" }, n))), i != null && a.push(sa(t, h_("y", { ...o, dx: -9, frameAnchor: "left", textAnchor: "end" }, n)));
  for (const c of a) c.ariaLabel = `crosshair ${c.ariaLabel}`;
  return En(...a);
}
function r4(e, { channels: t, ...n }, { facet: r, facetAnchor: i, fx: s, fy: o, [e]: a, channels: c, transform: u, initializer: l }) {
  return {
    ...n,
    facet: r,
    facetAnchor: i,
    fx: s,
    fy: o,
    [e]: a,
    channels: { ...t, ...c },
    transform: u,
    initializer: wH(e, l)
  };
}
function wH(e, t) {
  return t == null ? t : function(n, r, { x: i, y: s, px: o, py: a, ...c }, ...u) {
    const { channels: { x: l, y: f, ...h } = {}, ...d } = t.call(this, n, r, { ...c, x: o, y: a }, ...u);
    return {
      channels: {
        ...h,
        ...l && { px: l, ...e === "x" && { x: l } },
        ...f && { py: f, ...e === "y" && { y: f } }
      },
      ...d
    };
  };
}
function f_(e, t, n) {
  const {
    color: r = "currentColor",
    opacity: i = 0.2,
    ruleStroke: s = r,
    ruleStrokeOpacity: o = i,
    ruleStrokeWidth: a
  } = n;
  return {
    ...r4(e, t, n),
    stroke: s,
    strokeOpacity: o,
    strokeWidth: a
  };
}
function h_(e, t, n) {
  const {
    color: r = "currentColor",
    textFill: i = r,
    textFillOpacity: s,
    textStroke: o = "var(--plot-background)",
    textStrokeOpacity: a,
    textStrokeWidth: c = 5
  } = n;
  return {
    ...r4(e, t, _H(e, n)),
    fill: i,
    fillOpacity: s,
    stroke: o,
    strokeOpacity: a,
    strokeWidth: c
  };
}
function _H(e, t) {
  return tn(t, (n, r, i) => {
    var s;
    return { channels: { text: { value: (s = Iy(i, e)) == null ? void 0 : s.value } } };
  });
}
const vH = {
  ariaLabel: "delaunay link",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1
}, xH = {
  ariaLabel: "delaunay mesh",
  fill: null,
  stroke: "currentColor",
  strokeOpacity: 0.2
}, SH = {
  ariaLabel: "hull",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1.5,
  strokeMiterlimit: 1
}, MH = {
  ariaLabel: "voronoi",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1
}, AH = {
  ariaLabel: "voronoi mesh",
  fill: null,
  stroke: "currentColor",
  strokeOpacity: 0.2
};
class $H extends Ht {
  constructor(t, n = {}) {
    const { x: r, y: i, z: s, curve: o, tension: a } = n;
    super(
      t,
      {
        x: { value: r, scale: "x", optional: !0 },
        y: { value: i, scale: "y", optional: !0 },
        z: { value: s, optional: !0 }
      },
      n,
      vH
    ), this.curve = r1(o, a), va(this, n);
  }
  render(t, n, r, i, s) {
    const { x: o, y: a } = n, { x: c, y: u, z: l } = r, { curve: f } = this, [h, d] = $r(this, i), p = c ? (b) => c[b] : fn(h), y = u ? (b) => u[b] : fn(d), m = this;
    function g(b) {
      let w = -1;
      const _ = [], x = {};
      for (const S in r) x[S] = [];
      const v = [], M = [], E = [], $ = [];
      function N(S, I) {
        S = b[S], I = b[I], _.push(++w), v[w] = p(S), E[w] = y(S), M[w] = p(I), $[w] = y(I);
        for (const T in r) x[T].push(r[T][I]);
      }
      const { halfedges: A, hull: D, triangles: k } = Gi.from(b, p, y);
      for (let S = 0; S < A.length; ++S) {
        const I = A[S];
        I > S && N(k[S], k[I]);
      }
      for (let S = 0; S < D.length; ++S)
        N(D[S], D[(S + 1) % D.length]);
      Wt(this).selectAll().data(_).enter().append("path").call(te, m).attr("d", (S) => {
        const I = Gr(), T = f(I);
        return T.lineStart(), T.point(v[S], E[S]), T.point(M[S], $[S]), T.lineEnd(), I;
      }).call(ge, m, x).call(ku, m, x, s);
    }
    return Ot("svg:g", s).call(ne, this, i, s).call(Gt, this, { x: c && o, y: u && a }).call(
      l ? (b) => b.selectAll().data(ci(t, (w) => l[w]).values()).enter().append("g").each(g) : (b) => b.datum(t).each(g)
    ).node();
  }
}
class M1 extends Ht {
  constructor(t, n = {}, r, i = ({ z: s }) => s) {
    const { x: s, y: o } = n;
    super(
      t,
      {
        x: { value: s, scale: "x", optional: !0 },
        y: { value: o, scale: "y", optional: !0 },
        z: { value: i(n), optional: !0 }
      },
      n,
      r
    );
  }
  render(t, n, r, i, s) {
    const { x: o, y: a } = n, { x: c, y: u, z: l } = r, [f, h] = $r(this, i), d = c ? (g) => c[g] : fn(f), p = u ? (g) => u[g] : fn(h), y = this;
    function m(g) {
      const b = Gi.from(g, d, p);
      Wt(this).append("path").datum(g[0]).call(te, y).attr("d", y._render(b, i)).call(ge, y, r);
    }
    return Ot("svg:g", s).call(ne, this, i, s).call(Gt, this, { x: c && o, y: u && a }).call(
      l ? (g) => g.selectAll().data(ci(t, (b) => l[b]).values()).enter().append("g").each(m) : (g) => g.datum(t).each(m)
    ).node();
  }
}
class IH extends M1 {
  constructor(t, n = {}) {
    super(t, n, xH), this.fill = "none";
  }
  _render(t) {
    return t.render();
  }
}
class TH extends M1 {
  constructor(t, n = {}) {
    super(t, n, SH, Zi);
  }
  _render(t) {
    return t.renderHull();
  }
}
class EH extends Ht {
  constructor(t, n = {}) {
    const { x: r, y: i, z: s } = n;
    super(
      t,
      {
        x: { value: r, scale: "x", optional: !0 },
        y: { value: i, scale: "y", optional: !0 },
        z: { value: s, optional: !0 }
      },
      n,
      MH
    );
  }
  render(t, n, r, i, s) {
    const { x: o, y: a } = n, { x: c, y: u, z: l } = r, [f, h] = $r(this, i), d = c ? (g) => c[g] : fn(f), p = u ? (g) => u[g] : fn(h), y = this;
    function m(g) {
      const b = Gi.from(g, d, p), w = i4(b, i);
      Wt(this).selectAll().data(g).enter().append("path").call(te, y).attr("d", (_, x) => w.renderCell(x)).call(ge, y, r);
    }
    return Ot("svg:g", s).call(ne, this, i, s).call(Gt, this, { x: c && o, y: u && a }).call(
      l ? (g) => g.selectAll().data(ci(t, (b) => l[b]).values()).enter().append("g").each(m) : (g) => g.datum(t).each(m)
    ).node();
  }
}
class NH extends M1 {
  constructor(t, n) {
    super(t, n, AH), this.fill = "none";
  }
  _render(t, n) {
    return i4(t, n).render();
  }
}
function i4(e, t) {
  const { width: n, height: r, marginTop: i, marginRight: s, marginBottom: o, marginLeft: a } = t;
  return e.voronoi([a, i, n - s, r - o]);
}
function Cu(e, t, { x: n, y: r, ...i } = {}) {
  return [n, r] = Jn(n, r), new e(t, { ...i, x: n, y: r });
}
function DH(e, t) {
  return Cu($H, e, t);
}
function OH(e, t) {
  return Cu(IH, e, t);
}
function LH(e, t) {
  return Cu(TH, e, t);
}
function RH(e, t) {
  return Cu(EH, e, t);
}
function kH(e, t) {
  return Cu(NH, e, t);
}
const FH = {
  ariaLabel: "density",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1
};
class s4 extends Ht {
  constructor(t, { x: n, y: r, z: i, weight: s, fill: o, stroke: a, ...c } = {}) {
    const u = d_(o) && (o = "currentColor", !0), l = d_(a) && (a = "currentColor", !0);
    super(
      t,
      {
        x: { value: n, scale: "x", optional: !0 },
        y: { value: r, scale: "y", optional: !0 },
        z: { value: Zi({ z: i, fill: o, stroke: a }), optional: !0 },
        weight: { value: s, optional: !0 }
      },
      PH({ ...c, fill: o, stroke: a }, u, l),
      FH
    ), u && (this.fill = void 0), l && (this.stroke = void 0), this.z = i;
  }
  filter(t) {
    return t;
  }
  render(t, n, r, i, s) {
    const { contours: o } = r, a = Hi();
    return Ot("svg:g", s).call(ne, this, i, s).call(Gt, this, {}).call(
      (c) => c.selectAll().data(t).enter().append("path").call(te, this).call(ge, this, r).attr("d", (u) => a(o[u]))
    ).node();
  }
}
function BH(e, { x: t, y: n, ...r } = {}) {
  return [t, n] = Jn(t, n), new s4(e, { ...r, x: t, y: n });
}
const CH = /* @__PURE__ */ new Set(["x", "y", "z", "weight"]);
function PH(e, t, n) {
  let { bandwidth: i, thresholds: s } = e;
  return i = i === void 0 ? 20 : +i, s = s === void 0 ? 20 : typeof (s == null ? void 0 : s[Symbol.iterator]) == "function" ? He(s) : +s, tn(e, function(o, a, c, u, l, f) {
    var k;
    const h = c.weight ? He(c.weight.value) : null, d = (k = c.z) == null ? void 0 : k.value, { z: p } = this, [y, m] = $r(this, l), { width: g, height: b } = l, { x: w, y: _ } = Fd(c, u, f), x = Object.fromEntries(
      Object.entries(c).filter(([S]) => !CH.has(S)).map(([S, I]) => [S, { ...I, value: [] }])
    ), v = t && [], M = n && [], E = FP().x(w ? (S) => w[S] : y).y(_ ? (S) => _[S] : m).weight(h ? (S) => h[S] : 1).size([g, b]).bandwidth(i), $ = [];
    for (const S of a) {
      const I = [];
      $.push(I);
      for (const T of d ? Vg(S, d, p) : [S]) {
        const R = E.contours(T);
        I.push([T, R]);
      }
    }
    let N = s;
    if (!(N instanceof na)) {
      let S = 0;
      for (const I of $)
        for (const [, T] of I) {
          const R = T.max;
          R > S && (S = R);
        }
      N = Float64Array.from({ length: s - 1 }, (I, T) => S * 100 * (T + 1) / s);
    }
    const A = [], D = [];
    for (const S of $) {
      const I = [];
      A.push(I);
      for (const [T, R] of S)
        for (const B of N) {
          I.push(D.length), D.push(R(B / 100)), v && v.push(B), M && M.push(B);
          for (const C in x)
            x[C].value.push(c[C].value[T[0]]);
        }
    }
    return v && v.push(0), M && M.push(0), {
      data: o,
      facets: A,
      channels: {
        ...x,
        ...v && { fill: { value: v, scale: "color" } },
        ...M && { stroke: { value: M, scale: "color" } },
        contours: { value: D }
      }
    };
  });
}
function d_(e) {
  return /^density$/i.test(e);
}
function UH(e, {
  x1: t,
  x2: n,
  y1: r,
  y2: i,
  x: s = t === void 0 && n === void 0 ? Ve : void 0,
  y: o = r === void 0 && i === void 0 ? yt : void 0,
  fill: a,
  // ignored
  positiveFill: c = "#3ca951",
  negativeFill: u = "#4269d0",
  fillOpacity: l = 1,
  positiveFillOpacity: f = l,
  negativeFillOpacity: h = l,
  stroke: d,
  strokeOpacity: p,
  z: y = ze(d)[0],
  clip: m,
  // optional additional clip for area
  tip: g,
  render: b,
  ...w
} = {}) {
  return [t, n] = p_(s, t, n), [r, i] = p_(o, r, i), t === n && r === i && (r = gi(0)), { tip: g } = qs({ tip: g }, "x"), En(
    ee(c) ? null : Object.assign(
      ky(e, {
        x1: t,
        x2: n,
        y1: r,
        y2: i,
        z: y,
        fill: c,
        fillOpacity: f,
        render: $h(b, y_(!0)),
        clip: m,
        ...w
      }),
      { ariaLabel: "positive difference" }
    ),
    ee(u) ? null : Object.assign(
      ky(e, {
        x1: t,
        x2: n,
        y1: r,
        y2: i,
        z: y,
        fill: u,
        fillOpacity: h,
        render: $h(b, y_(!1)),
        clip: m,
        ...w
      }),
      { ariaLabel: "negative difference" }
    ),
    Jd(e, {
      x: n,
      y: i,
      z: y,
      stroke: d,
      strokeOpacity: p,
      tip: g,
      clip: !0,
      ...w
    })
  );
}
function p_(e, t, n) {
  return t === void 0 && n === void 0 ? t = n = gi(e) : t === void 0 ? (n = gi(n), t = e === void 0 ? n : gi(e)) : n === void 0 ? (t = gi(t), n = e === void 0 ? t : gi(e)) : (t = gi(t), n = gi(n)), [t, n];
}
function gi(e) {
  let t;
  const { value: n, label: r = Mr(n) } = _a(e);
  return { transform: (i) => t || (t = $t(i, n)), label: r };
}
function y_(e) {
  return (t, n, r, i, s, o) => {
    const { x1: a, x2: c } = r, { height: u } = i, l = new Float32Array(a.length), f = new Float32Array(c.length);
    (e === KA(n.y) < 0 ? l : f).fill(u);
    const h = o(t, n, { ...r, x2: a, y2: f }, i, s), d = o(t, n, { ...r, x1: c, y1: l }, i, s), p = h.querySelector("g") ?? h, y = d.querySelector("g") ?? d;
    for (let m = 0; p.firstChild; m += 2) {
      const g = Ly(), b = Ot("svg:clipPath", s).attr("id", g).node();
      b.appendChild(p.firstChild), y.childNodes[m].setAttribute("clip-path", `url(#${g})`), y.insertBefore(b, y.childNodes[m]);
    }
    return d;
  };
}
const zH = {
  ariaLabel: "geo",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1,
  strokeLinecap: "round",
  strokeLinejoin: "round",
  strokeMiterlimit: 1
};
class o4 extends Ht {
  constructor(t, n = {}) {
    const [r, i] = fe(n.r, 3);
    super(
      t,
      {
        geometry: { value: n.geometry, scale: "projection" },
        r: { value: r, scale: "r", filter: Qr, optional: !0 }
      },
      p1(n),
      zH
    ), this.r = i;
  }
  render(t, n, r, i, s) {
    const { geometry: o, r: a } = r, c = Hi(s.projection ?? qH(n)), { r: u } = this;
    return xd(u) ? t = [] : u !== void 0 && c.pointRadius(u), Ot("svg:g", s).call(ne, this, i, s).call(Gt, this, n).call((l) => {
      l.selectAll().data(t).enter().append("path").call(te, this).attr("d", a ? (f) => c.pointRadius(a[f])(o[f]) : (f) => c(o[f])).call(ge, this, r);
    }).node();
  }
}
function qH({ x: e, y: t }) {
  if (e || t)
    return e ?? (e = (n) => n), t ?? (t = (n) => n), ah({
      point(n, r) {
        this.stream.point(e(n), t(r));
      }
    });
}
function A1(e, { geometry: t = yt, ...n } = {}) {
  switch (e == null ? void 0 : e.type) {
    case "FeatureCollection":
      e = e.features;
      break;
    case "GeometryCollection":
      e = e.geometries;
      break;
    case "Feature":
    case "LineString":
    case "MultiLineString":
    case "MultiPoint":
    case "MultiPolygon":
    case "Point":
    case "Polygon":
    case "Sphere":
      e = [e];
      break;
  }
  return new o4(e, { geometry: t, ...n });
}
function jH({ strokeWidth: e = 1.5, ...t } = {}) {
  return A1({ type: "Sphere" }, { strokeWidth: e, ...t });
}
function VH({ strokeOpacity: e = 0.1, ...t } = {}) {
  return A1(DU(), { strokeOpacity: e, ...t });
}
const bc = 0.5, wc = 0;
function YH(e = { fill: "count" }, { binWidth: t, ...n } = {}) {
  const { z: r } = n;
  return t = t === void 0 ? 20 : Nt(t), e = DA(e, n), Ei(e, "fill") && (n.channels = { ...n.channels, fill: { value: [] } }), n.symbol === void 0 && (n.symbol = "hexagon"), n.r === void 0 && !Ei(e, "r") && (n.r = t / 2), tn(n, (i, s, o, a, c, u) => {
    let { x: l, y: f, z: h, fill: d, stroke: p, symbol: y } = o;
    if (l === void 0) throw new Error("missing channel: x");
    if (f === void 0) throw new Error("missing channel: y");
    ({ x: l, y: f } = Fd(o, a, u)), h = h ? h.value : $t(i, r), d = d == null ? void 0 : d.value, p = p == null ? void 0 : p.value, y = y == null ? void 0 : y.value;
    const m = Rg(e, { z: h, fill: d, stroke: p, symbol: y }), g = h && [], b = d && [], w = p && [], _ = y && [], x = [], v = [], M = [];
    let E = -1;
    for (const D of e) D.initialize(i);
    for (const D of s) {
      const k = [];
      for (const S of e) S.scope("facet", D);
      for (const [S, I] of Oo(D, m))
        for (const { index: T, extent: R } of WH(i, I, l, f, t)) {
          k.push(++E), v.push(R.x), M.push(R.y), h && g.push(m === h ? S : h[T[0]]), d && b.push(m === d ? S : d[T[0]]), p && w.push(m === p ? S : p[T[0]]), y && _.push(m === y ? S : y[T[0]]);
          for (const B of e) B.reduce(T, R);
        }
      x.push(k);
    }
    const $ = o.x.scale, N = o.y.scale, A = {
      x: { value: v, source: a[$] ? { value: Zt(v, a[$].invert), scale: $ } : null },
      y: { value: M, source: a[N] ? { value: Zt(M, a[N].invert), scale: N } : null },
      ...h && { z: { value: g } },
      ...d && { fill: { value: b, scale: "auto" } },
      ...p && { stroke: { value: w, scale: "auto" } },
      ...y && { symbol: { value: _, scale: "auto" } },
      ...Object.fromEntries(
        e.map(({ name: D, output: k }) => [
          D,
          {
            scale: "auto",
            label: k.label,
            radius: D === "r" ? t / 2 : void 0,
            value: k.transform()
          }
        ])
      )
    };
    return { data: i, facets: x, channels: A };
  });
}
function WH(e, t, n, r, i) {
  const s = i * (1.5 / $A), o = /* @__PURE__ */ new Map();
  for (const a of t) {
    let c = n[a], u = r[a];
    if (isNaN(c) || isNaN(u)) continue;
    let l = Math.round(u = (u - wc) / s), f = Math.round(c = (c - bc) / i - (l & 1) / 2), h = u - l;
    if (Math.abs(h) * 3 > 1) {
      let y = c - f, m = f + (c < f ? -1 : 1) / 2, g = l + (u < l ? -1 : 1), b = c - m, w = u - g;
      y * y + h * h > b * b + w * w && (f = m + (l & 1 ? 1 : -1) / 2, l = g);
    }
    const d = `${f},${l}`;
    let p = o.get(d);
    p === void 0 && (p = { index: [], extent: { data: e, x: (f + (l & 1) / 2) * i + bc, y: l * s + wc } }, o.set(d, p)), p.index.push(a);
  }
  return o.values();
}
const XH = {
  ariaLabel: "hexgrid",
  fill: "none",
  stroke: "currentColor",
  strokeOpacity: 0.1
};
function GH(e) {
  return new a4(e);
}
class a4 extends Ht {
  constructor({ binWidth: t = 20, clip: n = !0, ...r } = {}) {
    super(gc, void 0, { clip: n, ...r }, XH), this.binWidth = Nt(t);
  }
  render(t, n, r, i, s) {
    const { binWidth: o } = this, { marginTop: a, marginRight: c, marginBottom: u, marginLeft: l, width: f, height: h } = i, d = l - bc, p = f - c - bc, y = a - wc, m = h - u - wc, g = o / 2, b = g * IA, w = b / 2, _ = g * 2, x = b * 1.5, v = Math.floor(d / _), M = Math.ceil(p / _), E = Math.floor((y + w) / x), $ = Math.ceil((m - w) / x) + 1, N = `m0,${pi(-b)}l${pi(g)},${pi(w)}v${pi(b)}l${pi(-g)},${pi(w)}`;
    let A = N;
    for (let D = E; D < $; ++D)
      for (let k = v; k < M; ++k)
        A += `M${pi(k * _ + (D & 1) * g)},${pi(D * x)}${N}`;
    return Ot("svg:g", s).datum(0).call(ne, this, i, s).call(Gt, this, {}, Ae + bc, Ae + wc).call((D) => D.append("path").call(te, this).call(ge, this, r).attr("d", A)).node();
  }
}
function pi(e) {
  return Math.round(e * 1e3) / 1e3;
}
const HH = {
  ariaLabel: "image",
  fill: null,
  stroke: null
};
function JH(e) {
  return /^\.*\//.test(e);
}
function ZH(e) {
  return /^(blob|data|file|http|https):/i.test(e);
}
function KH(e) {
  return typeof e == "string" && (JH(e) || ZH(e)) ? [void 0, e] : [e, void 0];
}
class c4 extends Ht {
  constructor(t, n = {}) {
    let { x: r, y: i, r: s, width: o, height: a, rotate: c, src: u, preserveAspectRatio: l, crossOrigin: f, frameAnchor: h, imageRendering: d } = n;
    s == null && (s = void 0), s === void 0 && o === void 0 && a === void 0 ? o = a = 16 : o === void 0 && a !== void 0 ? o = a : a === void 0 && o !== void 0 && (a = o);
    const [p, y] = KH(u), [m, g] = fe(s), [b, w] = fe(o, g !== void 0 ? g * 2 : void 0), [_, x] = fe(a, g !== void 0 ? g * 2 : void 0), [v, M] = fe(c, 0);
    super(
      t,
      {
        x: { value: r, scale: "x", optional: !0 },
        y: { value: i, scale: "y", optional: !0 },
        r: { value: m, scale: "r", filter: Qr, optional: !0 },
        width: { value: b, filter: Qr, optional: !0 },
        height: { value: _, filter: Qr, optional: !0 },
        rotate: { value: v, optional: !0 },
        src: { value: p, optional: !0 }
      },
      p1(n),
      HH
    ), this.src = y, this.width = w, this.rotate = M, this.height = x, this.r = g, this.preserveAspectRatio = oe(l, "xMidYMid"), this.crossOrigin = Ne(f), this.frameAnchor = Eu(h), this.imageRendering = oe(d, "auto");
  }
  render(t, n, r, i, s) {
    const { x: o, y: a } = n, { x: c, y: u, width: l, height: f, r: h, rotate: d, src: p } = r, { r: y, width: m, height: g, rotate: b } = this, [w, _] = $r(this, i);
    return Ot("svg:g", s).call(ne, this, i, s).call(Gt, this, { x: c && o, y: u && a }).call(
      (x) => x.selectAll().data(t).enter().append("image").call(te, this).attr("x", m_(c, l, h, w, m, y)).attr("y", m_(u, f, h, _, g, y)).attr("width", l ? (v) => l[v] : m !== void 0 ? m : h ? (v) => h[v] * 2 : y * 2).attr("height", f ? (v) => f[v] : g !== void 0 ? g : h ? (v) => h[v] * 2 : y * 2).attr("transform", d ? (v) => `rotate(${d[v]})` : b ? `rotate(${b})` : null).attr("transform-origin", d || b ? zd`${c ? (v) => c[v] : w}px ${u ? (v) => u[v] : _}px` : null).call(at, "href", p ? (v) => p[v] : this.src).call(at, "preserveAspectRatio", this.preserveAspectRatio).call(at, "crossorigin", this.crossOrigin).call(at, "image-rendering", this.imageRendering).call(at, "clip-path", h ? (v) => `circle(${h[v]}px)` : y !== void 0 ? `circle(${y}px)` : null).call(ge, this, r)
    ).node();
  }
}
function m_(e, t, n, r, i, s) {
  return t && e ? (o) => e[o] - t[o] / 2 : t ? (o) => r - t[o] / 2 : e && i !== void 0 ? (o) => e[o] - i / 2 : i !== void 0 ? r - i / 2 : n && e ? (o) => e[o] - n[o] : n ? (o) => r - n[o] : e ? (o) => e[o] - s : r - s;
}
function QH(e, { x: t, y: n, ...r } = {}) {
  return r.frameAnchor === void 0 && ([t, n] = Jn(t, n)), new c4(e, { ...r, x: t, y: n });
}
function tJ(e, t, n) {
  var r = 1e-8, i = t - 1, s = n - 1, o = 0, a, c, u, l, f, h, d, p, y, m, g;
  if (e <= 0) return 0;
  if (e >= 1) return 1;
  for (t >= 1 && n >= 1 ? (u = e < 0.5 ? e : 1 - e, l = Math.sqrt(-2 * Math.log(u)), d = (2.30753 + l * 0.27061) / (1 + l * (0.99229 + l * 0.04481)) - l, e < 0.5 && (d = -d), p = (d * d - 3) / 6, y = 2 / (1 / (2 * t - 1) + 1 / (2 * n - 1)), m = d * Math.sqrt(p + y) / y - (1 / (2 * n - 1) - 1 / (2 * t - 1)) * (p + 5 / 6 - 2 / (3 * y)), d = t / (t + n * Math.exp(2 * m))) : (a = Math.log(t / (t + n)), c = Math.log(n / (t + n)), l = Math.exp(t * a) / t, f = Math.exp(n * c) / n, m = l + f, e < l / m ? d = Math.pow(t * m * e, 1 / t) : d = 1 - Math.pow(n * m * (1 - e), 1 / n)), g = -Ro(t) - Ro(n) + Ro(t + n); o < 10; o++) {
    if (d === 0 || d === 1) return d;
    if (h = eJ(d, t, n) - e, l = Math.exp(i * Math.log(d) + s * Math.log(1 - d) + g), f = h / l, d -= l = f / (1 - 0.5 * Math.min(1, f * (i / d - s / (1 - d)))), d <= 0 && (d = 0.5 * (d + l)), d >= 1 && (d = 0.5 * (d + l + 1)), Math.abs(l) < r * d && o > 0) break;
  }
  return d;
}
function eJ(e, t, n) {
  var r = e === 0 || e === 1 ? 0 : Math.exp(Ro(t + n) - Ro(t) - Ro(n) + t * Math.log(e) + n * Math.log(1 - e));
  return e < 0 || e > 1 ? !1 : e < (t + 1) / (t + n + 2) ? r * g_(e, t, n) / t : 1 - r * g_(1 - e, n, t) / n;
}
function g_(e, t, n) {
  var r = 1e-30, i = 1, s = t + n, o = t + 1, a = t - 1, c = 1, u = 1 - s * e / o, l, f, h, d;
  for (Math.abs(u) < r && (u = r), u = 1 / u, d = u; i <= 100 && (l = 2 * i, f = i * (n - i) * e / ((a + l) * (t + l)), u = 1 + f * u, Math.abs(u) < r && (u = r), c = 1 + f / c, Math.abs(c) < r && (c = r), u = 1 / u, d *= u * c, f = -(t + i) * (s + i) * e / ((t + l) * (o + l)), u = 1 + f * u, Math.abs(u) < r && (u = r), c = 1 + f / c, Math.abs(c) < r && (c = r), u = 1 / u, h = u * c, d *= h, !(Math.abs(h - 1) < 3e-7)); i++)
    ;
  return d;
}
function Ro(e) {
  var t = 0, n = [
    76.18009172947146,
    -86.5053203294167,
    24.01409824083091,
    -1.231739572450155,
    0.001208650973866179,
    -5395239384953e-18
  ], r = 1.000000000190015, i, s, o;
  for (o = (s = i = e) + 5.5, o -= (i + 0.5) * Math.log(o); t < 6; t++) r += n[t] / ++s;
  return Math.log(2.506628274631 * r / i) - o;
}
function nJ(e, t) {
  var n = tJ(2 * Math.min(e, 1 - e), 0.5 * t, 0.5);
  return n = Math.sqrt(t * (1 - n) / n), e > 0.5 ? n : -n;
}
const rJ = {
  ariaLabel: "linear-regression",
  fill: "currentColor",
  fillOpacity: 0.1,
  stroke: "currentColor",
  strokeWidth: 1.5,
  strokeLinecap: "round",
  strokeLinejoin: "round",
  strokeMiterlimit: 1
};
class u4 extends Ht {
  constructor(t, n = {}) {
    const { x: r, y: i, z: s, ci: o = 0.95, precision: a = 4 } = n;
    if (super(
      t,
      {
        x: { value: r, scale: "x" },
        y: { value: i, scale: "y" },
        z: { value: Zi(n), optional: !0 }
      },
      n,
      rJ
    ), this.z = s, this.ci = +o, this.precision = +a, !(0 <= this.ci && this.ci < 1)) throw new Error(`invalid ci; not in [0, 1): ${o}`);
    if (!(this.precision > 0)) throw new Error(`invalid precision: ${a}`);
  }
  render(t, n, r, i, s) {
    const { x: o, y: a, z: c } = r, { ci: u } = this;
    return Ot("svg:g", s).call(ne, this, i, s).call(Gt, this, n).call(
      (l) => l.selectAll().data(c ? Vg(t, c, this.z) : [t]).enter().call(
        (f) => f.append("path").attr("fill", "none").call(te, this).call(Ah, this, { ...r, fill: null, fillOpacity: null }).attr("d", (h) => this._renderLine(h, o, a)).call(
          u && !ra(this.fill) ? (h) => h.select(iJ).attr("stroke", "none").call(te, this).call(Ah, this, {
            ...r,
            stroke: null,
            strokeOpacity: null,
            strokeWidth: null
          }).attr("d", (d) => this._renderBand(d, o, a)) : () => {
          }
        )
      )
    ).node();
  }
}
function iJ() {
  return this.parentNode.insertBefore(this.ownerDocument.createElementNS(Es.svg, "path"), this);
}
class sJ extends u4 {
  constructor(t, n) {
    super(t, n);
  }
  _renderBand(t, n, r) {
    const { ci: i, precision: s } = this, [o, a] = pe(t, (l) => r[l]), c = Rh(t, r, n), u = l4(t, r, n, (1 - i) / 2, c);
    return ug().y((l) => l).x0((l) => u(l, -1)).x1((l) => u(l, 1))(sn(o, a - s / 2, s).concat(a));
  }
  _renderLine(t, n, r) {
    const [i, s] = pe(t, (a) => r[a]), o = Rh(t, r, n);
    return `M${o(i)},${i}L${o(s)},${s}`;
  }
}
class oJ extends u4 {
  constructor(t, n) {
    super(t, n);
  }
  _renderBand(t, n, r) {
    const { ci: i, precision: s } = this, [o, a] = pe(t, (l) => n[l]), c = Rh(t, n, r), u = l4(t, n, r, (1 - i) / 2, c);
    return ug().x((l) => l).y0((l) => u(l, -1)).y1((l) => u(l, 1))(sn(o, a - s / 2, s).concat(a));
  }
  _renderLine(t, n, r) {
    const [i, s] = pe(t, (a) => n[a]), o = Rh(t, n, r);
    return `M${i},${o(i)}L${s},${o(s)}`;
  }
}
function aJ(e, { y: t = Ve, x: n = yt, stroke: r, fill: i = ee(r) ? "currentColor" : r, ...s } = {}) {
  return new sJ(e, s1({ ...s, x: n, y: t, fill: i, stroke: r }));
}
function cJ(e, { x: t = Ve, y: n = yt, stroke: r, fill: i = ee(r) ? "currentColor" : r, ...s } = {}) {
  return new oJ(e, i1({ ...s, x: t, y: n, fill: i, stroke: r }));
}
function Rh(e, t, n) {
  let r = 0, i = 0, s = 0, o = 0;
  for (const l of e) {
    const f = t[l], h = n[l];
    r += f, i += h, s += f * h, o += f * f;
  }
  const a = e.length, c = (a * s - r * i) / (a * o - r * r), u = (i - c * r) / a;
  return (l) => c * l + u;
}
function l4(e, t, n, r, i) {
  const s = br(e, (l) => t[l]) / e.length;
  let o = 0, a = 0;
  for (const l of e)
    o += (t[l] - s) ** 2, a += (n[l] - i(t[l])) ** 2;
  const c = Math.sqrt(a / (e.length - 2)), u = nJ(r, e.length - 2);
  return (l, f) => {
    const h = i(l), d = c * Math.sqrt(1 / e.length + (l - s) ** 2 / o);
    return h + f * u * d;
  };
}
function Py({
  path: e = yt,
  // the delimited path
  delimiter: t,
  // how the path is separated
  frameAnchor: n,
  treeLayout: r = fh,
  treeSort: i,
  treeSeparation: s,
  treeAnchor: o,
  treeFilter: a,
  ...c
} = {}) {
  o = $1(o), i = h4(i), a != null && (a = zy(a)), n === void 0 && (n = o.frameAnchor);
  const u = d4(t), l = _4(c, zy), [f, h] = an(), [d, p] = an();
  return {
    x: f,
    y: d,
    frameAnchor: n,
    ...Ar(c, (y, m) => {
      const g = u($t(y, e)), b = h([]), w = p([]);
      let _ = -1;
      const x = [], v = [], M = W3().path(($) => g[$]), E = r();
      E.nodeSize && E.nodeSize([1, 1]), E.separation && s !== void 0 && E.separation(s ?? wg);
      for (const $ of l) $[kh] = $[b4]([]);
      for (const $ of m) {
        const N = [], A = M($.filter((D) => g[D] != null)).each((D) => D.data = y[D.data]);
        i != null && A.sort(i), E(A);
        for (const D of A.descendants())
          if (!(a != null && !a(D))) {
            N.push(++_), x[_] = D.data, o.position(D, _, b, w);
            for (const k of l) k[kh][_] = k[w4](D);
          }
        v.push(N);
      }
      return { data: x, facets: v };
    }),
    ...Object.fromEntries(l)
  };
}
function f4({
  path: e = yt,
  // the delimited path
  delimiter: t,
  // how the path is separated
  curve: n = "bump-x",
  stroke: r = "#555",
  strokeWidth: i = 1.5,
  strokeOpacity: s = 0.5,
  treeLayout: o = fh,
  treeSort: a,
  treeSeparation: c,
  treeAnchor: u,
  treeFilter: l,
  ...f
} = {}) {
  u = $1(u), a = h4(a), l != null && (l = w_(l)), f = { curve: n, stroke: r, strokeWidth: i, strokeOpacity: s, ...f };
  const h = d4(t), d = _4(f, w_), [p, y] = an(), [m, g] = an(), [b, w] = an(), [_, x] = an();
  return {
    x1: p,
    x2: m,
    y1: b,
    y2: _,
    ...Ar(f, (v, M) => {
      const E = h($t(v, e)), $ = y([]), N = g([]), A = w([]), D = x([]);
      let k = -1;
      const S = [], I = [], T = W3().path((B) => E[B]), R = o();
      R.nodeSize && R.nodeSize([1, 1]), R.separation && c !== void 0 && R.separation(c ?? wg);
      for (const B of d) B[kh] = B[b4]([]);
      for (const B of M) {
        const C = [], F = T(B.filter((P) => E[P] != null)).each((P) => P.data = v[P.data]);
        a != null && F.sort(a), R(F);
        for (const { source: P, target: U } of F.links())
          if (!(l != null && !l(U, P))) {
            C.push(++k), S[k] = U.data, u.position(P, k, $, A), u.position(U, k, N, D);
            for (const Y of d) Y[kh][k] = Y[w4](U, P);
          }
        I.push(C);
      }
      return { data: S, facets: I };
    }),
    ...Object.fromEntries(d)
  };
}
function $1(e = "left") {
  switch (`${e}`.trim().toLowerCase()) {
    case "left":
      return uJ;
    case "right":
      return lJ;
  }
  throw new Error(`invalid tree anchor: ${e}`);
}
const uJ = {
  frameAnchor: "left",
  dx: 6,
  position({ x: e, y: t }, n, r, i) {
    r[n] = t, i[n] = -e;
  }
}, lJ = {
  frameAnchor: "right",
  dx: -6,
  position({ x: e, y: t }, n, r, i) {
    r[n] = -t, i[n] = -e;
  }
};
function h4(e) {
  return e == null || typeof e == "function" ? e : `${e}`.trim().toLowerCase().startsWith("node:") ? b_(zy(e)) : b_(fJ(e));
}
function b_(e) {
  return (t, n) => Tn(e(t), e(n));
}
function fJ(e) {
  return (t) => {
    var n;
    return (n = t.data) == null ? void 0 : n[e];
  };
}
function d4(e = "/") {
  if (e = `${e}`, e === "/") return (n) => n;
  if (e.length !== 1) throw new Error("delimiter must be exactly one character");
  const t = e.charCodeAt(0);
  return (n) => n.map((r) => hJ(r, t));
}
const Uy = 92, p4 = 47;
function hJ(e, t) {
  if (t === Uy) throw new Error("delimiter cannot be backslash");
  let n = !1;
  for (let r = 0, i = e.length; r < i; ++r) {
    switch (e.charCodeAt(r)) {
      case Uy:
        if (!n) {
          n = !0;
          continue;
        }
        break;
      case t:
        n ? (e = e.slice(0, r - 1) + e.slice(r), --r, --i) : e = e.slice(0, r) + "/" + e.slice(r + 1);
        break;
      case p4:
        n ? (e = e.slice(0, r) + "\\\\" + e.slice(r), r += 2, i += 2) : (e = e.slice(0, r) + "\\" + e.slice(r), ++r, ++i);
        break;
    }
    n = !1;
  }
  return e;
}
function dJ(e) {
  let t = !1;
  for (let n = 0, r = e.length; n < r; ++n) {
    switch (e.charCodeAt(n)) {
      case Uy:
        if (!t) {
          t = !0;
          continue;
        }
      case p4:
        t && (e = e.slice(0, n - 1) + e.slice(n), --n, --r);
        break;
    }
    t = !1;
  }
  return e;
}
function y4(e) {
  return Nn(e) && typeof e.node == "function";
}
function pJ(e) {
  return Nn(e) && typeof e.link == "function";
}
function zy(e) {
  if (y4(e)) return e.node;
  if (e = `${e}`.trim().toLowerCase(), !!e.startsWith("node:")) {
    switch (e) {
      case "node:name":
        return jy;
      case "node:path":
        return qy;
      case "node:internal":
        return m4;
      case "node:external":
        return g4;
      case "node:depth":
        return Vy;
      case "node:height":
        return Yy;
    }
    throw new Error(`invalid node value: ${e}`);
  }
}
function w_(e) {
  if (y4(e)) return e.node;
  if (pJ(e)) return e.link;
  if (e = `${e}`.trim().toLowerCase(), !(!e.startsWith("node:") && !e.startsWith("parent:"))) {
    switch (e) {
      case "parent:name":
        return vl(jy);
      case "parent:path":
        return vl(qy);
      case "parent:depth":
        return vl(Vy);
      case "parent:height":
        return vl(Yy);
      case "node:name":
        return jy;
      case "node:path":
        return qy;
      case "node:internal":
        return m4;
      case "node:external":
        return g4;
      case "node:depth":
        return Vy;
      case "node:height":
        return Yy;
    }
    throw new Error(`invalid link value: ${e}`);
  }
}
function qy(e) {
  return e.id;
}
function jy(e) {
  return yJ(e.id);
}
function Vy(e) {
  return e.depth;
}
function Yy(e) {
  return e.height;
}
function m4(e) {
  return !!e.children;
}
function g4(e) {
  return !e.children;
}
function vl(e) {
  return (t, n) => n == null ? void 0 : e(n);
}
function yJ(e) {
  let t = e.length;
  for (; --t > 0 && !mJ(e, t); ) ;
  return dJ(e.slice(t + 1));
}
function mJ(e, t) {
  if (e[t] === "/") {
    let n = 0;
    for (; t > 0 && e[--t] === "\\"; ) ++n;
    if (!(n & 1)) return !0;
  }
  return !1;
}
const b4 = 2, w4 = 3, kh = 4;
function _4(e, t) {
  const n = [];
  for (const r in e) {
    const i = e[r], s = t(i);
    s !== void 0 && n.push([r, ...an(i), s]);
  }
  return n;
}
function v4(e, {
  fill: t,
  stroke: n,
  strokeWidth: r,
  strokeOpacity: i,
  strokeLinejoin: s,
  strokeLinecap: o,
  strokeMiterlimit: a,
  strokeDasharray: c,
  strokeDashoffset: u,
  marker: l,
  markerStart: f = l,
  markerEnd: h = l,
  dot: d = ee(f) && ee(h),
  text: p = "node:name",
  textStroke: y = "var(--plot-background)",
  title: m = "node:path",
  dx: g,
  dy: b,
  textAnchor: w,
  treeLayout: _ = fh,
  textLayout: x = _ === fh || _ === j3 ? "mirrored" : "normal",
  tip: v,
  ...M
} = {}) {
  if (g === void 0 && (g = $1(M.treeAnchor).dx), w !== void 0) throw new Error("textAnchor is not a configurable tree option");
  x = hn(x, "textLayout", ["mirrored", "normal"]);
  function E($) {
    return sa(
      e,
      Py({
        treeLayout: _,
        text: p,
        fill: t === void 0 ? "currentColor" : t,
        stroke: y,
        dx: g,
        dy: b,
        title: m,
        ...$,
        ...M
      })
    );
  }
  return En(
    R8(
      e,
      f4({
        treeLayout: _,
        markerStart: f,
        markerEnd: h,
        stroke: n !== void 0 ? n : t === void 0 ? "node:internal" : t,
        strokeWidth: r,
        strokeOpacity: i,
        strokeLinejoin: s,
        strokeLinecap: o,
        strokeMiterlimit: a,
        strokeDasharray: c,
        strokeDashoffset: u,
        ...M
      })
    ),
    d ? ts(e, Py({ treeLayout: _, fill: t === void 0 ? "node:internal" : t, title: m, tip: v, ...M })) : null,
    p != null ? x === "mirrored" ? [
      E({ textAnchor: "start", treeFilter: "node:external" }),
      E({ textAnchor: "end", treeFilter: "node:internal", dx: -g })
    ] : E() : null
  );
}
function gJ(e, t) {
  return v4(e, { ...t, treeLayout: j3 });
}
function bJ({ geometry: e = yt, ...t } = {}) {
  return tn({ ...t, x: null, y: null }, (n, r, i, s, o, { projection: a }) => {
    const c = $t(n, e), u = c.length, l = new Float64Array(u), f = new Float64Array(u), h = Hi(a);
    for (let d = 0; d < u; ++d) [l[d], f[d]] = h.centroid(c[d]);
    return {
      data: n,
      facets: r,
      channels: {
        x: { value: l, scale: a == null ? "x" : null, source: null },
        y: { value: f, scale: a == null ? "y" : null, source: null }
      }
    };
  });
}
function wJ({ geometry: e = yt, ...t } = {}) {
  let n;
  return {
    ...t,
    x: { transform: (r) => Float64Array.from(n = $t($t(r, e), wU), ([i]) => i) },
    y: { transform: () => Float64Array.from(n, ([, r]) => r) }
  };
}
function _J(e) {
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
function vJ(e, t, n, r, i) {
  for (var s = i + 1; r <= i; ) {
    var o = r + i >>> 1, a = e[o], c = n !== void 0 ? n(a, t) : a - t;
    c >= 0 ? (s = o, i = o - 1) : r = o + 1;
  }
  return s;
}
function xJ(e, t, n, r, i) {
  for (var s = i + 1; r <= i; ) {
    var o = r + i >>> 1, a = e[o], c = n !== void 0 ? n(a, t) : a - t;
    c > 0 ? (s = o, i = o - 1) : r = o + 1;
  }
  return s;
}
function SJ(e, t, n, r, i) {
  for (var s = r - 1; r <= i; ) {
    var o = r + i >>> 1, a = e[o], c = n !== void 0 ? n(a, t) : a - t;
    c < 0 ? (s = o, r = o + 1) : i = o - 1;
  }
  return s;
}
function MJ(e, t, n, r, i) {
  for (var s = r - 1; r <= i; ) {
    var o = r + i >>> 1, a = e[o], c = n !== void 0 ? n(a, t) : a - t;
    c <= 0 ? (s = o, r = o + 1) : i = o - 1;
  }
  return s;
}
function AJ(e, t, n, r, i) {
  for (; r <= i; ) {
    var s = r + i >>> 1, o = e[s], a = n !== void 0 ? n(o, t) : o - t;
    if (a === 0)
      return s;
    a <= 0 ? r = s + 1 : i = s - 1;
  }
  return -1;
}
function ja(e, t, n, r, i, s) {
  return typeof n == "function" ? s(e, t, n, r === void 0 ? 0 : r | 0, i === void 0 ? e.length - 1 : i | 0) : s(e, t, void 0, n === void 0 ? 0 : n | 0, r === void 0 ? e.length - 1 : r | 0);
}
var $J = {
  ge: function(e, t, n, r, i) {
    return ja(e, t, n, r, i, vJ);
  },
  gt: function(e, t, n, r, i) {
    return ja(e, t, n, r, i, xJ);
  },
  lt: function(e, t, n, r, i) {
    return ja(e, t, n, r, i, SJ);
  },
  le: function(e, t, n, r, i) {
    return ja(e, t, n, r, i, MJ);
  },
  eq: function(e, t, n, r, i) {
    return ja(e, t, n, r, i, AJ);
  }
}, Fh = $J, xo = 0, as = 1, Hl = 2, IJ = EJ;
function I1(e, t, n, r, i) {
  this.mid = e, this.left = t, this.right = n, this.leftPoints = r, this.rightPoints = i, this.count = (t ? t.count : 0) + (n ? n.count : 0) + r.length;
}
var Pu = I1.prototype;
function a0(e, t) {
  e.mid = t.mid, e.left = t.left, e.right = t.right, e.leftPoints = t.leftPoints, e.rightPoints = t.rightPoints, e.count = t.count;
}
function x4(e, t) {
  var n = ua(t);
  e.mid = n.mid, e.left = n.left, e.right = n.right, e.leftPoints = n.leftPoints, e.rightPoints = n.rightPoints, e.count = n.count;
}
function __(e, t) {
  var n = e.intervals([]);
  n.push(t), x4(e, n);
}
function v_(e, t) {
  var n = e.intervals([]), r = n.indexOf(t);
  return r < 0 ? xo : (n.splice(r, 1), x4(e, n), as);
}
Pu.intervals = function(e) {
  return e.push.apply(e, this.leftPoints), this.left && this.left.intervals(e), this.right && this.right.intervals(e), e;
};
Pu.insert = function(e) {
  var t = this.count - this.leftPoints.length;
  if (this.count += 1, e[1] < this.mid)
    this.left ? 4 * (this.left.count + 1) > 3 * (t + 1) ? __(this, e) : this.left.insert(e) : this.left = ua([e]);
  else if (e[0] > this.mid)
    this.right ? 4 * (this.right.count + 1) > 3 * (t + 1) ? __(this, e) : this.right.insert(e) : this.right = ua([e]);
  else {
    var n = Fh.ge(this.leftPoints, e, T1), r = Fh.ge(this.rightPoints, e, E1);
    this.leftPoints.splice(n, 0, e), this.rightPoints.splice(r, 0, e);
  }
};
Pu.remove = function(e) {
  var t = this.count - this.leftPoints;
  if (e[1] < this.mid) {
    if (!this.left)
      return xo;
    var n = this.right ? this.right.count : 0;
    if (4 * n > 3 * (t - 1))
      return v_(this, e);
    var r = this.left.remove(e);
    return r === Hl ? (this.left = null, this.count -= 1, as) : (r === as && (this.count -= 1), r);
  } else if (e[0] > this.mid) {
    if (!this.right)
      return xo;
    var i = this.left ? this.left.count : 0;
    if (4 * i > 3 * (t - 1))
      return v_(this, e);
    var r = this.right.remove(e);
    return r === Hl ? (this.right = null, this.count -= 1, as) : (r === as && (this.count -= 1), r);
  } else {
    if (this.count === 1)
      return this.leftPoints[0] === e ? Hl : xo;
    if (this.leftPoints.length === 1 && this.leftPoints[0] === e) {
      if (this.left && this.right) {
        for (var s = this, o = this.left; o.right; )
          s = o, o = o.right;
        if (s === this)
          o.right = this.right;
        else {
          var a = this.left, r = this.right;
          s.count -= o.count, s.right = o.left, o.left = a, o.right = r;
        }
        a0(this, o), this.count = (this.left ? this.left.count : 0) + (this.right ? this.right.count : 0) + this.leftPoints.length;
      } else this.left ? a0(this, this.left) : a0(this, this.right);
      return as;
    }
    for (var a = Fh.ge(this.leftPoints, e, T1); a < this.leftPoints.length && this.leftPoints[a][0] === e[0]; ++a)
      if (this.leftPoints[a] === e) {
        this.count -= 1, this.leftPoints.splice(a, 1);
        for (var r = Fh.ge(this.rightPoints, e, E1); r < this.rightPoints.length && this.rightPoints[r][1] === e[1]; ++r)
          if (this.rightPoints[r] === e)
            return this.rightPoints.splice(r, 1), as;
      }
    return xo;
  }
};
function S4(e, t, n) {
  for (var r = 0; r < e.length && e[r][0] <= t; ++r) {
    var i = n(e[r]);
    if (i)
      return i;
  }
}
function M4(e, t, n) {
  for (var r = e.length - 1; r >= 0 && e[r][1] >= t; --r) {
    var i = n(e[r]);
    if (i)
      return i;
  }
}
function A4(e, t) {
  for (var n = 0; n < e.length; ++n) {
    var r = t(e[n]);
    if (r)
      return r;
  }
}
Pu.queryPoint = function(e, t) {
  if (e < this.mid) {
    if (this.left) {
      var n = this.left.queryPoint(e, t);
      if (n)
        return n;
    }
    return S4(this.leftPoints, e, t);
  } else if (e > this.mid) {
    if (this.right) {
      var n = this.right.queryPoint(e, t);
      if (n)
        return n;
    }
    return M4(this.rightPoints, e, t);
  } else
    return A4(this.leftPoints, t);
};
Pu.queryInterval = function(e, t, n) {
  if (e < this.mid && this.left) {
    var r = this.left.queryInterval(e, t, n);
    if (r)
      return r;
  }
  if (t > this.mid && this.right) {
    var r = this.right.queryInterval(e, t, n);
    if (r)
      return r;
  }
  return t < this.mid ? S4(this.leftPoints, t, n) : e > this.mid ? M4(this.rightPoints, e, n) : A4(this.leftPoints, n);
};
function TJ(e, t) {
  return e - t;
}
function T1(e, t) {
  var n = e[0] - t[0];
  return n || e[1] - t[1];
}
function E1(e, t) {
  var n = e[1] - t[1];
  return n || e[0] - t[0];
}
function ua(e) {
  if (e.length === 0)
    return null;
  for (var t = [], n = 0; n < e.length; ++n)
    t.push(e[n][0], e[n][1]);
  t.sort(TJ);
  for (var r = t[t.length >> 1], i = [], s = [], o = [], n = 0; n < e.length; ++n) {
    var a = e[n];
    a[1] < r ? i.push(a) : r < a[0] ? s.push(a) : o.push(a);
  }
  var c = o, u = o.slice();
  return c.sort(T1), u.sort(E1), new I1(
    r,
    ua(i),
    ua(s),
    c,
    u
  );
}
function Wy(e) {
  this.root = e;
}
var $a = Wy.prototype;
$a.insert = function(e) {
  this.root ? this.root.insert(e) : this.root = new I1(e[0], null, null, [e], [e]);
};
$a.remove = function(e) {
  if (this.root) {
    var t = this.root.remove(e);
    return t === Hl && (this.root = null), t !== xo;
  }
  return !1;
};
$a.queryPoint = function(e, t) {
  if (this.root)
    return this.root.queryPoint(e, t);
};
$a.queryInterval = function(e, t, n) {
  if (e <= t && this.root)
    return this.root.queryInterval(e, t, n);
};
Object.defineProperty($a, "count", {
  get: function() {
    return this.root ? this.root.count : 0;
  }
});
Object.defineProperty($a, "intervals", {
  get: function() {
    return this.root ? this.root.intervals([]) : [];
  }
});
function EJ(e) {
  return !e || e.length === 0 ? new Wy(null) : new Wy(ua(e));
}
const NJ = /* @__PURE__ */ _J(IJ), DJ = ({ marginLeft: e }) => [1, e], OJ = ({ width: e, marginRight: t }) => [-1, e - t], LJ = ({ width: e, marginLeft: t, marginRight: n }) => [0, (t + e - n) / 2], RJ = ({ marginTop: e }) => [1, e], kJ = ({ height: e, marginBottom: t }) => [-1, e - t], FJ = ({ height: e, marginTop: t, marginBottom: n }) => [0, (t + e - n) / 2];
function $4(e) {
  return typeof e == "string" ? { anchor: e } : e;
}
function BJ(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = I4(e));
  let { anchor: n = "left", padding: r = 1, r: i = t.r } = $4(e);
  switch (`${n}`.toLowerCase()) {
    case "left":
      n = DJ;
      break;
    case "right":
      n = OJ;
      break;
    case "middle":
      n = LJ;
      break;
    default:
      throw new Error(`unknown dodge anchor: ${n}`);
  }
  return T4("x", "y", n, Nt(r), i, t);
}
function CJ(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = I4(e));
  let { anchor: n = "bottom", padding: r = 1, r: i = t.r } = $4(e);
  switch (`${n}`.toLowerCase()) {
    case "top":
      n = RJ;
      break;
    case "bottom":
      n = kJ;
      break;
    case "middle":
      n = FJ;
      break;
    default:
      throw new Error(`unknown dodge anchor: ${n}`);
  }
  return T4("y", "x", n, Nt(r), i, t);
}
function I4(e) {
  const { anchor: t, padding: n, ...r } = e, { r: i } = r;
  return [{ anchor: t, padding: n, r: i }, r];
}
function T4(e, t, n, r, i, s) {
  if (i != null && typeof i != "number") {
    let { channels: o, sort: a, reverse: c } = s;
    o = Sg(o), (o == null ? void 0 : o.r) === void 0 && (s = { ...s, channels: { ...o, r: { value: i, scale: "r" } } }), a === void 0 && c === void 0 && (s.sort = { channel: "-r" });
  }
  return tn(s, function(o, a, c, u, l, f) {
    let { [t]: h, r: d } = c;
    if (!c[t]) throw new Error(`missing channel: ${t}`);
    ({ [t]: h } = Fd(c, u, f));
    const p = d ? void 0 : i !== void 0 ? Nt(i) : this.r !== void 0 ? this.r : 3;
    d && (d = $t(d.value, u[d.scale] || yt, Float64Array));
    let [y, m] = n(l);
    const g = y ? UJ : PJ, b = new Float64Array(h.length), w = d ? (_) => d[_] : () => p;
    for (let _ of a) {
      const x = NJ();
      _ = _.filter(d ? (M) => vh(h[M]) && Qr(d[M]) : (M) => vh(h[M]));
      const v = new Float64Array(2 * _.length + 2);
      for (const M of _) {
        const E = w(M), $ = y ? E + r : 0, N = h[M] - E, A = h[M] + E;
        let D = 2;
        x.queryInterval(N - r, A + r, ([, , S]) => {
          const I = b[S] - $, T = h[M] - h[S], R = r + (d ? d[M] + d[S] : 2 * p), B = Math.sqrt(R * R - T * T);
          v[D++] = I - B, v[D++] = I + B;
        });
        let k = v.slice(0, D);
        y && (k = k.filter((S) => S >= 0));
        t: for (const S of k.sort(g)) {
          for (let I = 0; I < D; I += 2)
            if (v[I] + 1e-6 < S && S < v[I + 1] - 1e-6)
              continue t;
          b[M] = S + $;
          break;
        }
        x.insert([N, A, M]);
      }
    }
    y || (y = 1);
    for (const _ of a)
      for (const x of _)
        b[x] = b[x] * y + m;
    return {
      data: o,
      facets: a,
      channels: {
        [e]: { value: b, source: null },
        // don’t show in tooltip
        [t]: { value: h, source: c[t] },
        ...d && { r: { value: d, source: c.r } }
      }
    };
  });
}
function PJ(e, t) {
  return Math.abs(e) - Math.abs(t);
}
function UJ(e, t) {
  return e - t;
}
function zJ(e, t) {
  return arguments.length === 1 && ({ basis: e, ...t } = e), m1(N1(e), t);
}
function qJ(e, t) {
  return arguments.length === 1 && ({ basis: e, ...t } = e), g1(N1(e), t);
}
function N1(e) {
  if (e === void 0) return x_;
  if (typeof e == "function") return Qd(xg(e));
  if (/^p\d{2}$/i.test(e)) return Ia(_g(e));
  switch (`${e}`.toLowerCase()) {
    case "deviation":
      return YJ;
    case "first":
      return x_;
    case "last":
      return VJ;
    case "max":
      return WJ;
    case "mean":
      return XJ;
    case "median":
      return GJ;
    case "min":
      return HJ;
    case "sum":
      return JJ;
    case "extent":
      return jJ;
  }
  throw new Error(`invalid basis: ${e}`);
}
function Qd(e) {
  return {
    mapIndex(t, n, r) {
      const i = +e(t, n);
      for (const s of t)
        r[s] = n[s] === null ? NaN : n[s] / i;
    }
  };
}
function Ia(e) {
  return Qd((t, n) => e(t, (r) => n[r]));
}
const jJ = {
  mapIndex(e, t, n) {
    const [r, i] = pe(e, (o) => t[o]), s = i - r;
    for (const o of e)
      n[o] = t[o] === null ? NaN : (t[o] - r) / s;
  }
}, x_ = Qd((e, t) => {
  for (let n = 0; n < e.length; ++n) {
    const r = t[e[n]];
    if (Pe(r)) return r;
  }
}), VJ = Qd((e, t) => {
  for (let n = e.length - 1; n >= 0; --n) {
    const r = t[e[n]];
    if (Pe(r)) return r;
  }
}), YJ = {
  mapIndex(e, t, n) {
    const r = Qh(e, (s) => t[s]), i = fu(e, (s) => t[s]);
    for (const s of e)
      n[s] = t[s] === null ? NaN : i ? (t[s] - r) / i : 0;
  }
}, WJ = Ia(ce), XJ = Ia(Qh), GJ = Ia(Lc), HJ = Ia(ve), JJ = Ia(br);
function ZJ(e, t) {
  return KJ("x", e, t);
}
function KJ(e, t, n = {}) {
  let r, i = 1;
  if (typeof t == "number")
    i = t, r = (u, l) => +u + l;
  else {
    if (typeof t == "string") {
      const u = t.startsWith("-") ? -1 : 1;
      [t, i] = gg(t.replace(/^[+-]/, "")), i *= u;
    }
    t = Td(t), r = (u, l) => t.offset(u, l);
  }
  const s = `${e}1`, o = `${e}2`, a = vr(
    {
      [s]: (u) => u.map((l) => r(l, i)),
      [o]: (u) => u
    },
    n
  ), c = a[o].transform;
  return a[o].transform = () => {
    const u = c(), [l, f] = pe(u);
    return u.domain = i < 0 ? [l, r(f, i)] : [r(l, i), f], u;
  }, a;
}
function QJ(e, t = {}) {
  if (typeof e == "string")
    switch (e.toLowerCase()) {
      case "first":
        return D1(t);
      case "last":
        return O1(t);
    }
  if (typeof e == "function")
    return ji(null, e, t);
  let n, r;
  for (n in e) {
    if (r !== void 0) throw new Error("ambiguous selector; multiple inputs");
    r = tZ(e[n]);
  }
  if (r === void 0) throw new Error(`invalid selector: ${e}`);
  return ji(n, r, t);
}
function tZ(e) {
  if (typeof e == "function") return e;
  switch (`${e}`.toLowerCase()) {
    case "min":
      return L1;
    case "max":
      return R1;
  }
  throw new Error(`unknown selector: ${e}`);
}
function D1(e) {
  return ji(null, eZ, e);
}
function O1(e) {
  return ji(null, nZ, e);
}
function E4(e) {
  return ji("x", L1, e);
}
function N4(e) {
  return ji("y", L1, e);
}
function D4(e) {
  return ji("x", R1, e);
}
function O4(e) {
  return ji("y", R1, e);
}
function* eZ(e) {
  yield e[0];
}
function* nZ(e) {
  yield e[e.length - 1];
}
function* L1(e, t) {
  yield xk(e, (n) => t[n]);
}
function* R1(e, t) {
  yield Cm(e, (n) => t[n]);
}
function ji(e, t, n) {
  if (e != null) {
    if (n[e] == null) throw new Error(`missing channel: ${e}`);
    e = n[e];
  }
  const r = Zi(n);
  return Ar(n, (i, s) => {
    const o = $t(i, r), a = $t(i, e), c = [];
    for (const u of s) {
      const l = [];
      for (const f of o ? ci(u, (h) => o[h]).values() : [u])
        for (const h of t(f, a))
          l.push(h);
      c.push(l);
    }
    return { data: i, facets: c };
  });
}
Ht.prototype.plot = function({ marks: e = [], ...t } = {}) {
  return e1({ ...t, marks: [...e, this] });
};
const rZ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  Area: Wd,
  Arrow: k8,
  BarX: B8,
  BarY: C8,
  Cell: Xd,
  Contour: n4,
  Density: s4,
  Dot: Gd,
  Frame: m8,
  Geo: o4,
  Hexgrid: a4,
  Image: c4,
  Line: Hd,
  Link: L8,
  Mark: Ht,
  Raster: K8,
  Rect: Zd,
  RuleX: T$,
  RuleY: E$,
  Text: qd,
  TickX: V8,
  TickY: Y8,
  Tip: g8,
  Vector: jd,
  area: ky,
  areaX: Kc,
  areaY: ca,
  arrow: wG,
  auto: DG,
  autoSpec: P8,
  axisFx: K$,
  axisFy: Z$,
  axisX: Zg,
  axisY: Jg,
  barX: ps,
  barY: ys,
  bin: cs,
  binX: Mi,
  binY: Ai,
  bollinger: xs,
  bollingerX: JG,
  bollingerY: ZG,
  boxX: QG,
  boxY: tH,
  cell: vo,
  cellX: vG,
  cellY: xG,
  centroid: bJ,
  circle: $G,
  cluster: gJ,
  column: an,
  contour: pH,
  crosshair: mH,
  crosshairX: gH,
  crosshairY: bH,
  delaunayLink: DH,
  delaunayMesh: OH,
  density: BH,
  differenceY: UH,
  dodgeX: BJ,
  dodgeY: CJ,
  dot: ts,
  dotX: MG,
  dotY: AG,
  filter: UV,
  find: eY,
  formatIsoDate: l$,
  formatMonth: yW,
  formatNumber: u$,
  formatWeekday: mW,
  frame: t1,
  geo: A1,
  geoCentroid: wJ,
  graticule: VH,
  gridFx: i8,
  gridFy: n8,
  gridX: r8,
  gridY: e8,
  group: Dg,
  groupX: Wc,
  groupY: Xc,
  groupZ: Ng,
  hexagon: IG,
  hexbin: YH,
  hexgrid: GH,
  hull: LH,
  identity: yt,
  image: QH,
  indexOf: Ve,
  initializer: tn,
  interpolateNearest: v1,
  interpolateNone: Cy,
  interpolatorBarycentric: _1,
  interpolatorRandomWalk: x1,
  legend: uX,
  line: Jd,
  lineX: Qc,
  lineY: tu,
  linearRegressionX: aJ,
  linearRegressionY: cJ,
  link: R8,
  map: vr,
  mapX: m1,
  mapY: g1,
  marks: En,
  normalize: N1,
  normalizeX: zJ,
  normalizeY: qJ,
  numberInterval: xA,
  plot: e1,
  pointer: Cd,
  pointerX: Pd,
  pointerY: Zc,
  raster: nH,
  rect: y1,
  rectX: Oh,
  rectY: Lh,
  reverse: zV,
  ruleX: zi,
  ruleY: qi,
  scale: Jc,
  select: QJ,
  selectFirst: D1,
  selectLast: O1,
  selectMaxX: D4,
  selectMaxY: O4,
  selectMinX: E4,
  selectMinY: N4,
  shiftX: ZJ,
  shuffle: qV,
  sort: TA,
  sphere: jH,
  spike: ZW,
  stackX: I8,
  stackX1: KX,
  stackX2: QX,
  stackY: T8,
  stackY1: tG,
  stackY2: eG,
  text: sa,
  textX: L$,
  textY: R$,
  tickX: W8,
  tickY: X8,
  timeInterval: bg,
  tip: b8,
  transform: Ar,
  tree: v4,
  treeLink: f4,
  treeNode: Py,
  utcInterval: Md,
  valueof: $t,
  vector: V$,
  vectorX: Y$,
  vectorY: W$,
  voronoi: RH,
  voronoiMesh: kH,
  window: Kd,
  windowX: CG,
  windowY: PG
}, Symbol.toStringTag, { value: "Module" })), iZ = /* @__PURE__ */ new Map([
  ["style", "style"],
  ["width", "width"],
  ["height", "height"],
  ["margin", "margin"],
  ["marginLeft", "marginLeft"],
  ["marginRight", "marginRight"],
  ["marginTop", "marginTop"],
  ["marginBottom", "marginBottom"],
  ["align", "align"],
  ["aspectRatio", "aspectRatio"],
  ["axis", "axis"],
  ["inset", "inset"],
  ["grid", "grid"],
  ["label", "label"],
  ["padding", "padding"],
  ["xScale", "x.type"],
  ["xDomain", "x.domain"],
  ["xRange", "x.range"],
  ["xNice", "x.nice"],
  ["xInset", "x.inset"],
  ["xInsetLeft", "x.insetLeft"],
  ["xInsetRight", "x.insetRight"],
  ["xClamp", "x.clamp"],
  ["xRound", "x.round"],
  ["xAlign", "x.align"],
  ["xPadding", "x.padding"],
  ["xPaddingInner", "x.paddingInner"],
  ["xPaddingOuter", "x.paddingOuter"],
  ["xAxis", "x.axis"],
  ["xTicks", "x.ticks"],
  ["xTickSize", "x.tickSize"],
  ["xTickSpacing", "x.tickSpacing"],
  ["xTickPadding", "x.tickPadding"],
  ["xTickFormat", "x.tickFormat"],
  ["xTickRotate", "x.tickRotate"],
  ["xGrid", "x.grid"],
  ["xLine", "x.line"],
  ["xLabel", "x.label"],
  ["xLabelAnchor", "x.labelAnchor"],
  ["xLabelArrow", "x.labelArrow"],
  ["xLabelOffset", "x.labelOffset"],
  ["xFontVariant", "x.fontVariant"],
  ["xAriaLabel", "x.ariaLabel"],
  ["xAriaDescription", "x.ariaDescription"],
  ["xPercent", "x.percent"],
  ["xReverse", "x.reverse"],
  ["xZero", "x.zero"],
  ["xBase", "x.base"],
  ["xExponent", "x.exponent"],
  ["xConstant", "x.constant"],
  ["yScale", "y.type"],
  ["yDomain", "y.domain"],
  ["yRange", "y.range"],
  ["yNice", "y.nice"],
  ["yInset", "y.inset"],
  ["yInsetTop", "y.insetTop"],
  ["yInsetBottom", "y.insetBottom"],
  ["yClamp", "y.clamp"],
  ["yRound", "y.round"],
  ["yAlign", "y.align"],
  ["yPadding", "y.padding"],
  ["yPaddingInner", "y.paddingInner"],
  ["yPaddingOuter", "y.paddingOuter"],
  ["yAxis", "y.axis"],
  ["yTicks", "y.ticks"],
  ["yTickSize", "y.tickSize"],
  ["yTickSpacing", "y.tickSpacing"],
  ["yTickPadding", "y.tickPadding"],
  ["yTickFormat", "y.tickFormat"],
  ["yTickRotate", "y.tickRotate"],
  ["yGrid", "y.grid"],
  ["yLine", "y.line"],
  ["yLabel", "y.label"],
  ["yLabelAnchor", "y.labelAnchor"],
  ["yLabelArrow", "y.labelArrow"],
  ["yLabelOffset", "y.labelOffset"],
  ["yFontVariant", "y.fontVariant"],
  ["yAriaLabel", "y.ariaLabel"],
  ["yAriaDescription", "y.ariaDescription"],
  ["yPercent", "y.percent"],
  ["yReverse", "y.reverse"],
  ["yZero", "y.zero"],
  ["yBase", "y.base"],
  ["yExponent", "y.exponent"],
  ["yConstant", "y.constant"],
  ["facetMargin", "facet.margin"],
  ["facetMarginTop", "facet.marginTop"],
  ["facetMarginBottom", "facet.marginBottom"],
  ["facetMarginLeft", "facet.marginLeft"],
  ["facetMarginRight", "facet.marginRight"],
  ["facetGrid", "facet.grid"],
  ["facetLabel", "facet.label"],
  ["fxDomain", "fx.domain"],
  ["fxRange", "fx.range"],
  ["fxInset", "fx.inset"],
  ["fxInsetLeft", "fx.insetLeft"],
  ["fxInsetRight", "fx.insetRight"],
  ["fxRound", "fx.round"],
  ["fxAlign", "fx.align"],
  ["fxPadding", "fx.padding"],
  ["fxPaddingInner", "fx.paddingInner"],
  ["fxPaddingOuter", "fx.paddingOuter"],
  ["fxAxis", "fx.axis"],
  ["fxTicks", "fx.ticks"],
  ["fxTickSize", "fx.tickSize"],
  ["fxTickSpacing", "fx.tickSpacing"],
  ["fxTickPadding", "fx.tickPadding"],
  ["fxTickFormat", "fx.tickFormat"],
  ["fxTickRotate", "fx.tickRotate"],
  ["fxGrid", "fx.grid"],
  ["fxLine", "fx.line"],
  ["fxLabel", "fx.label"],
  ["fxLabelAnchor", "fx.labelAnchor"],
  ["fxLabelOffset", "fx.labelOffset"],
  ["fxFontVariant", "fx.fontVariant"],
  ["fxAriaLabel", "fx.ariaLabel"],
  ["fxAriaDescription", "fx.ariaDescription"],
  ["fxReverse", "fx.reverse"],
  ["fyDomain", "fy.domain"],
  ["fyRange", "fy.range"],
  ["fyInset", "fy,inset"],
  ["fyInsetTop", "fy.insetTop"],
  ["fyInsetBottom", "fy.insetBottom"],
  ["fyRound", "fy.round"],
  ["fyAlign", "fy.align"],
  ["fyPadding", "fy.padding"],
  ["fyPaddingInner", "fy.paddingInner"],
  ["fyPaddingOuter", "fy.paddingOuter"],
  ["fyAxis", "fy.axis"],
  ["fyTicks", "fy.ticks"],
  ["fyTickSize", "fy.tickSize"],
  ["fyTickSpacing", "fy.tickSpacing"],
  ["fyTickPadding", "fy.tickPadding"],
  ["fyTickFormat", "fy.tickFormat"],
  ["fyTickRotate", "fy.tickRotate"],
  ["fyGrid", "fy.grid"],
  ["fyLine", "fy.line"],
  ["fyLabel", "fy.label"],
  ["fyLabelAnchor", "fy.labelAnchor"],
  ["fyLabelOffset", "fy.labelOffset"],
  ["fyFontVariant", "fy.fontVariant"],
  ["fyAriaLabel", "fy.ariaLabel"],
  ["fyAriaDescription", "fy.ariaDescription"],
  ["fyReverse", "fy.reverse"],
  ["colorScale", "color.type"],
  ["colorDomain", "color.domain"],
  ["colorRange", "color.range"],
  ["colorClamp", "color.clamp"],
  ["colorN", "color.n"],
  ["colorNice", "color.nice"],
  ["colorScheme", "color.scheme"],
  ["colorInterpolate", "color.interpolate"],
  ["colorPivot", "color.pivot"],
  ["colorSymmetric", "color.symmetric"],
  ["colorLabel", "color.label"],
  ["colorPercent", "color.percent"],
  ["colorReverse", "color.reverse"],
  ["colorZero", "color.zero"],
  ["colorTickFormat", "color.tickFormat"],
  ["colorBase", "color.base"],
  ["colorExponent", "color.exponent"],
  ["colorConstant", "color.constant"],
  ["opacityScale", "opacity.type"],
  ["opacityDomain", "opacity.domain"],
  ["opacityRange", "opacity.range"],
  ["opacityClamp", "opacity.clamp"],
  ["opacityNice", "opacity.nice"],
  ["opacityLabel", "opacity.label"],
  ["opacityPercent", "opacity.percent"],
  ["opacityReverse", "opacity.reverse"],
  ["opacityZero", "opacity.zero"],
  ["opacityTickFormat", "opacity.tickFormat"],
  ["opacityBase", "opacity.base"],
  ["opacityExponent", "opacity.exponent"],
  ["opacityConstant", "opacity.constant"],
  ["symbolScale", "symbol.type"],
  ["symbolDomain", "symbol.domain"],
  ["symbolRange", "symbol.range"],
  ["rScale", "r.type"],
  ["rDomain", "r.domain"],
  ["rRange", "r.range"],
  ["rClamp", "r.clamp"],
  ["rNice", "r.nice"],
  ["rLabel", "r.label"],
  ["rPercent", "r.percent"],
  ["rZero", "r.zero"],
  ["rBase", "r.base"],
  ["rExponent", "r.exponent"],
  ["rConstant", "r.constant"],
  ["lengthScale", "length.type"],
  ["lengthDomain", "length.domain"],
  ["lengthRange", "length.range"],
  ["lengthClamp", "length.clamp"],
  ["lengthNice", "length.nice"],
  ["lengthPercent", "length.percent"],
  ["lengthZero", "length.zero"],
  ["lengthBase", "length.base"],
  ["lengthExponent", "length.exponent"],
  ["lengthConstant", "length.constant"],
  ["projectionType", "projection.type"],
  ["projectionParallels", "projection.parallels"],
  ["projectionPrecision", "projection.precision"],
  ["projectionRotate", "projection.rotate"],
  ["projectionDomain", "projection.domain"],
  ["projectionInset", "projection.inset"],
  ["projectionInsetLeft", "projection.insetLeft"],
  ["projectionInsetRight", "projection.insetRight"],
  ["projectionInsetTop", "projection.insetTop"],
  ["projectionInsetBottom", "projection.insetBottom"],
  ["projectionClip", "projection.clip"]
]);
function sZ(e, t, n) {
  for (let r = 0; r < t.length; ++r) {
    const i = t[r];
    r === t.length - 1 ? e[i] = n : e = e[i] || (e[i] = {});
  }
}
function oZ(e, t, n) {
  for (const r in e) {
    const i = iZ.get(r);
    if (i == null)
      throw new Error(`Unrecognized plot attribute: ${r}`);
    const s = e[r];
    typeof s == "symbol" ? n.push(r) : s !== void 0 && sZ(t, i.split("."), s);
  }
}
const aZ = /* @__PURE__ */ new Set([
  "frame",
  "hexgrid",
  "sphere",
  "graticule"
]), cZ = /* @__PURE__ */ new Map([
  ["first", D1],
  ["last", O1],
  ["maxX", D4],
  ["maxY", O4],
  ["minX", E4],
  ["minY", N4],
  ["nearest", Cd],
  ["nearestX", Pd],
  ["nearestXY", Zc]
]);
async function uZ(e) {
  var a;
  const t = { marks: [] }, n = [], { attributes: r, marks: i } = e;
  oZ(r, t, n);
  const s = [];
  for (const c of i)
    for (const { type: u, data: l, options: f } of c.plotSpecs()) {
      const { select: h, ...d } = f, p = ((a = cZ.get(h)) == null ? void 0 : a(d)) ?? d, y = aZ.has(u) ? [p] : [l, p];
      t.marks.push(rZ[u](...y)), s.push(c.index);
    }
  fZ(t, e);
  const o = e1(t);
  hZ(o, s), lZ(e, o, r, n);
  for (const c of e.interactors)
    await c.init(o);
  return o;
}
function lZ(e, t, n, r) {
  r.forEach((i) => {
    const s = n[i];
    if (s === uu) {
      if (!i.endsWith("Domain"))
        throw new Error(`Unsupported fixed attribute: ${i}`);
      const o = i.slice(0, -6), a = t.scale(o);
      a != null && a.domain && e.setAttribute(i, n[`${o}Reverse`] ? a.domain.slice().reverse() : a.domain);
    } else
      throw new Error(`Unrecognized symbol: ${s}`);
  });
}
function fZ(e, t) {
  const { marks: n } = t;
  xl("x", e, n), xl("y", e, n), xl("fx", e, n), xl("fy", e, n);
}
function xl(e, t, n) {
  const r = t[e] || {};
  if (r.axis === null || r.label !== void 0) return;
  const i = n.map((u) => {
    var l;
    return (l = u.channelField(e)) == null ? void 0 : l.field;
  });
  if (i.every((u) => u == null)) return;
  let s, o, a;
  for (let u = 0; u < i.length; ++u) {
    const { column: l, label: f } = i[u] || {};
    l === void 0 && f === void 0 || (s === void 0 && o === void 0 ? (s = l, o = f, a = dZ(n[u].data, e) || "number") : o !== f ? o = void 0 : s !== l && (s = void 0));
  }
  let c = o || s;
  if (c !== void 0) {
    if ((a === "number" || a === "date") && (e === "x" || e === "y")) {
      r.percent && (c = `${c} (%)`);
      const u = (e === "x" ? 1 : -1) * (r.reverse ? -1 : 1);
      e === "x" || r.labelAnchor === "center" ? c = e === "x" == u < 0 ? `← ${c}` : `${c} →` : c = `${u < 0 ? "↑ " : "↓ "}${c}`;
    }
    t[e] = { ...r, label: c };
  }
}
function hZ(e, t) {
  const n = e.querySelectorAll('g[aria-label="facet"]');
  if (n.length)
    for (const r of n)
      S_(r, t);
  else
    S_(e, t);
}
function S_(e, t) {
  let n = -1;
  for (const r of e.children) {
    const i = r.getAttribute("aria-label") || "";
    r.nodeName === "style" || i.includes("-axis") || i.includes("-grid") || r.setAttribute("data-index", t[++n]);
  }
}
function dZ(e, t) {
  if (!e) return;
  const { columns: n } = e, r = n[t] ?? n[t + "1"] ?? n[t + "2"];
  if (r) {
    for (const i of r)
      if (i != null)
        return i instanceof Date ? "date" : typeof i;
  }
}
const pZ = {
  width: 640,
  marginLeft: 40,
  marginRight: 20,
  marginTop: 20,
  marginBottom: 30
};
class yZ {
  constructor(t) {
    this.attributes = { ...pZ }, this.listeners = null, this.interactors = [], this.legends = [], this.marks = [], this.markset = null, this.element = t || document.createElement("div"), this.element.setAttribute("class", "plot"), this.element.style.display = "flex", this.element.value = this, this.params = /* @__PURE__ */ new Map(), this.synch = HR();
  }
  margins() {
    return {
      left: this.getAttribute("marginLeft"),
      top: this.getAttribute("marginTop"),
      bottom: this.getAttribute("marginBottom"),
      right: this.getAttribute("marginRight")
    };
  }
  innerWidth() {
    const { left: t, right: n } = this.margins();
    return this.getAttribute("width") - t - n;
  }
  innerHeight(t = 400) {
    const { top: n, bottom: r } = this.margins();
    let i = this.getAttribute("height");
    return i == null && (i = mZ(this, n, r) || t, this.setAttribute("height", i, { silent: !0 })), i - n - r;
  }
  pending(t) {
    this.synch.pending(t);
  }
  update(t) {
    return this.synch.ready(t) && !this.pendingRender && (this.pendingRender = !0, requestAnimationFrame(() => this.render())), this.synch.promise;
  }
  async render() {
    this.pendingRender = !1;
    const t = await uZ(this), n = this.legends.flatMap(({ legend: r, include: i }) => {
      const s = r.init(t);
      return i ? s : [];
    });
    this.element.replaceChildren(t, ...n), this.synch.resolve();
  }
  /**
   * @param {string} name The attribute to return.
   * @returns {*} The value of the attribute.
   */
  getAttribute(t) {
    return this.attributes[t];
  }
  /**
   * @param {string} name The name of the attribute to set.
   * @param {*} value The value to set.
   * @param {{silent: boolean}} [options] Options for setting the attribute.
   * @returns {boolean} whether the value changed.
   */
  setAttribute(t, n, r) {
    var i, s;
    return sS(this.attributes[t], n) ? (n === void 0 ? delete this.attributes[t] : this.attributes[t] = n, r != null && r.silent || (s = (i = this.listeners) == null ? void 0 : i.get(t)) == null || s.forEach((o) => o(t, n)), !0) : !1;
  }
  /**
   * @param {string} name The attribute name.
   * @param {*} callback The function to call when the attribute changes.
   * @returns {this}
   */
  addAttributeListener(t, n) {
    const r = this.listeners || (this.listeners = /* @__PURE__ */ new Map());
    return r.has(t) || r.set(t, /* @__PURE__ */ new Set()), r.get(t).add(n), this;
  }
  /**
   * @param {string} name The attribute name.
   * @param {*} callback The function to call when the attribute changes.
   * @returns {void}
   */
  removeAttributeListener(t, n) {
    var r, i;
    return (i = (r = this.listeners) == null ? void 0 : r.get(t)) == null ? void 0 : i.delete(n);
  }
  addParams(t, n) {
    const { params: r } = this;
    for (const i of n)
      r.has(i) ? r.get(i).push(t) : (r.set(i, [t]), i.addEventListener("value", () => Promise.allSettled(
        r.get(i).map((s) => s.requestQuery())
      )));
  }
  addMark(t) {
    return t.setPlot(this, this.marks.length), this.marks.push(t), this.markset = null, this;
  }
  get markSet() {
    return this.markset || (this.markset = new Set(this.marks));
  }
  addInteractor(t) {
    return this.interactors.push(t), this;
  }
  addLegend(t, n = !0) {
    t.setPlot(this), this.legends.push({ legend: t, include: n });
  }
}
function mZ(e, t, n) {
  const r = e.getAttribute("aspectRatio");
  if (r == null) return;
  const i = e.getAttribute("xDomain"), s = e.getAttribute("yDomain");
  if (!i || !s) return;
  const o = Math.abs(i[1] - i[0]);
  return Math.abs(s[1] - s[0]) * e.innerWidth() / (r * o) + t + n;
}
function L4(e) {
  return typeof e != "string" ? !1 : (e = e.toLowerCase().trim(), e === "none" || e === "currentcolor" || e.startsWith("url(") && e.endsWith(")") || // <funciri>, e.g. pattern or gradient
  e.startsWith("var(") && e.endsWith(")") || // CSS variable
  Ci(e) !== null);
}
const gZ = /* @__PURE__ */ new Set([
  "order",
  "sort",
  "label",
  "anchor",
  "curve",
  "tension",
  "marker",
  "markerStart",
  "markerMid",
  "markerEnd",
  "textAnchor",
  "lineAnchor",
  "lineHeight",
  "textOverflow",
  "monospace",
  "fontFamily",
  "fontSize",
  "fontStyle",
  "fontVariant",
  "fontWeight",
  "frameAnchor",
  "strokeLinejoin",
  "strokeLinecap",
  "strokeMiterlimit",
  "strokeDasharray",
  "strokeDashoffset",
  "mixBlendMode",
  "shapeRendering",
  "imageRendering",
  "preserveAspectRatio",
  "interpolate",
  "crossOrigin",
  "paintOrder",
  "pointerEvents",
  "target",
  "select"
]);
function bZ(e) {
  return gZ.has(e);
}
const wZ = /* @__PURE__ */ new Set([
  "asterisk",
  "circle",
  "cross",
  "diamond",
  "diamond2",
  "hexagon",
  "plus",
  "square",
  "square2",
  "star",
  "times",
  "triangle",
  "triangle2",
  "wye"
]);
function _Z(e) {
  return wZ.has(`${e}`.toLowerCase());
}
const R4 = (e) => e === "stroke" || e === "fill", vZ = (e) => /opacity$/i.test(e), xZ = (e) => e === "symbol", SZ = (e, t) => e !== "sort" && e !== "tip" && t != null && !Array.isArray(t), c0 = (e, t) => ({
  channel: e,
  field: t,
  as: t instanceof Ri ? t.column : e
}), u0 = (e, t) => ({ channel: e, value: t }), Xy = (e) => Array.isArray(e);
class es extends eu {
  constructor(t, n, r, i = {}) {
    var u;
    super((u = n == null ? void 0 : n.options) == null ? void 0 : u.filterBy), this.type = t, this.reqs = i, this.source = n, Xy(this.source) && (this.data = $s(this.source));
    const s = this.channels = [], o = this.detail = /* @__PURE__ */ new Set(), a = this.params = /* @__PURE__ */ new Set(), c = (l, f) => {
      const h = typeof f;
      if (l === "channels")
        for (const d in f)
          o.add(d), c(d, f[d]);
      else if (h === "function" && f[aS]) {
        const d = f(this, l);
        for (const p in d)
          c(p, d[p]);
      } else if (h === "string")
        bZ(l) || R4(l) && L4(f) || xZ(l) && _Z(f) ? s.push(u0(l, f)) : s.push(c0(l, Xh(f)));
      else if (jo(f))
        if (Array.isArray(f.columns))
          s.push(c0(l, f)), a.add(f);
        else {
          const d = u0(l, f.value);
          s.push(d), f.addEventListener("value", (p) => (d.value = p, this.update()));
        }
      else h === "object" && SZ(l, f) ? s.push(c0(l, f)) : f !== void 0 && s.push(u0(l, f));
    };
    for (const l in r)
      c(l, r[l]);
  }
  /**
   * @param {import('../plot.js').Plot} plot The plot.
   * @param {number} index
   */
  setPlot(t, n) {
    var r;
    this.plot = t, this.index = n, t.addParams(this, this.params), (r = this.source) != null && r.table && this.queryPending();
  }
  hasOwnData() {
    return this.source == null || Xy(this.source);
  }
  hasFieldInfo() {
    return !!this._fieldInfo;
  }
  channel(t) {
    return this.channels.find((n) => n.channel === t);
  }
  channelField(t, { exact: n = !1 } = {}) {
    const r = n ? this.channel(t) : this.channels.find((i) => i.channel.startsWith(t));
    return r != null && r.field ? r : null;
  }
  fields() {
    var s, o, a;
    if (this.hasOwnData()) return null;
    const { source: { table: t }, channels: n, reqs: r } = this, i = /* @__PURE__ */ new Map();
    for (const { channel: c, field: u } of n) {
      if (!u) continue;
      const l = ((s = u.stats) == null ? void 0 : s.stats) || [], f = ((o = u.stats) == null ? void 0 : o.column) ?? u, h = i.get(f) ?? i.set(f, /* @__PURE__ */ new Set()).get(f);
      l.forEach((d) => h.add(d)), (a = r[c]) == null || a.forEach((d) => h.add(d));
    }
    return Array.from(i, ([c, u]) => ({ table: t, column: c, stats: u }));
  }
  fieldInfo(t) {
    var r;
    const n = Object.fromEntries(t.map((i) => [i.column, i]));
    for (const i of this.channels) {
      const { field: s } = i;
      s && Object.assign(i, n[((r = s.stats) == null ? void 0 : r.column) ?? s]);
    }
    return this._fieldInfo = !0, this;
  }
  /**
   * Return a query specifying the data needed by this Mark client.
   * @param {*} [filter] The filtering criteria to apply in the query.
   * @returns {*} The client query
   */
  query(t = []) {
    if (this.hasOwnData()) return null;
    const { channels: n, source: { table: r } } = this;
    return k1(n, r).where(t);
  }
  queryPending() {
    return this.plot.pending(this), this;
  }
  /**
   * Provide query result data to the mark.
   */
  queryResult(t) {
    return this.data = $s(t), this;
  }
  update() {
    return this.plot.update(this);
  }
  /**
   * Generate an array of Plot mark specifications.
   * @returns {object[]}
   */
  plotSpecs() {
    const { type: t, data: n, detail: r, channels: i } = this;
    return k4(t, r, i, n);
  }
}
function gn(e, t) {
  const n = (t == null ? void 0 : t[e.as]) ?? e.as;
  return Object.hasOwn(e, "value") ? e.value : R4(e.channel) ? { value: n, scale: "color" } : vZ(e.channel) ? { value: n, scale: "opacity" } : n;
}
function k1(e, t, n = []) {
  const r = xt.from({ source: t }), i = /* @__PURE__ */ new Set();
  let s = !1;
  for (const o of e) {
    const { channel: a, field: c, as: u } = o;
    if (!n.includes(a)) {
      if (a === "orderby")
        r.orderby(o.value);
      else if (c) {
        if (c.aggregate)
          s = !0;
        else {
          if (i.has(u)) continue;
          i.add(u);
        }
        r.select({ [u]: c });
      }
    }
  }
  return s && r.groupby(Array.from(i)), r;
}
function k4(e, t, n, r, i = {}) {
  const { numRows: s, values: o, columns: a } = r ?? {}, c = {};
  for (const f of n) {
    const h = t.has(f.channel) ? c : i;
    h[f.channel] = gn(f, a);
  }
  return t.size && (i.channels = c), [{ type: e, data: o ?? (r ? { length: s } : null), options: i }];
}
function Bh(e, t) {
  const { plot: n } = e;
  let r = n.getAttribute(`${t}Scale`);
  if (!r) {
    const { type: s } = e.channelField(t);
    r = s === "date" ? "time" : "linear";
  }
  const i = { type: r };
  switch (r) {
    case "log":
      i.base = n.getAttribute(`${t}Base`) ?? 10;
      break;
    case "pow":
      i.exponent = n.getAttribute(`${t}Exponent`) ?? 1;
      break;
    case "symlog":
      i.constant = n.getAttribute(`${t}Constant`) ?? 1;
      break;
  }
  return Jx(i);
}
function Vi(e, t, n, r, i = 1, s) {
  const { field: o } = e.channelField(t);
  s = s ?? o;
  const { type: a, apply: c, sqlApply: u } = Bh(e, t), l = !!e.plot.getAttribute(`${t}Reverse`), [f, h] = r.map((b) => c(b)), d = u(s), p = a === "time" || a === "utc" ? d : s, y = h === f ? 0 : (n - i) / (h - f), m = y !== 1 ? ` * ${y}::DOUBLE` : "";
  return [l ? j`(${h} - ${d}::DOUBLE)${m}` : j`(${d}::DOUBLE - ${f})${m}`, p];
}
const F4 = { x: ["min", "max"] }, B4 = { y: ["min", "max"] }, C4 = { ...F4, ...B4 };
function P4(e, t, n, r, i) {
  const { plot: s } = e, o = s.getAttribute(r), a = s.getAttribute(i);
  if (Array.isArray(o) && !o[qn])
    return o;
  {
    const { column: c, min: u, max: l } = e.channelField(n), f = U4(t, c) || (a ? dd().domain([u, l]).nice().domain() : [u, l]);
    return o !== uu && (f[qn] = !0), s.setAttribute(r, f, { silent: !0 }), f;
  }
}
function Uu(e, t) {
  return P4(e, t, "x", "xDomain", "xNice");
}
function zu(e, t) {
  return P4(e, t, "y", "yDomain", "yNice");
}
function U4(e, t) {
  if (!e) return;
  let n, r;
  const i = (s, o) => {
    if (s === "BETWEEN" && `${o.field}` === t) {
      const { range: a } = o;
      a && (n == null || a[0] < n) && (n = a[0]), a && (r == null || a[1] > r) && (r = a[1]);
    }
  };
  return Array.isArray(e) ? e.forEach((s) => {
    var o;
    return (o = s.visit) == null ? void 0 : o.call(s, i);
  }) : e.visit && e.visit(i), n != null && r != null && n !== r ? [n, r] : void 0;
}
class MZ extends es {
  constructor(t, n, r) {
    const i = t.endsWith("X") ? "y" : t.endsWith("Y") ? "x" : null, s = i ? { [i]: ["min", "max"] } : void 0;
    super(t, n, r, s), this.dim = i;
  }
  /**
   * Return a query specifying the data needed by this Mark client.
   * @param {*} [filter] The filtering criteria to apply in the query.
   * @returns {*} The client query
   */
  query(t = []) {
    var y;
    const { plot: n, dim: r, source: i } = this, { optimize: s = !0 } = i.options || {}, o = super.query(t);
    if (!r) return o;
    const a = r === "x" ? "y" : "x", c = (y = this.channelField(a, { exact: !0 })) == null ? void 0 : y.as, { field: u, as: l, type: f, min: h, max: d } = this.channelField(r);
    if (s && (f === "date" || f === "number") && c) {
      const m = r === "x" ? n.innerWidth() : n.innerHeight(), [g, b] = U4(t, u) || [h, d], [w] = Vi(this, r, m, [g, b], 1, l), _ = o.select().map((x) => x.as).filter((x) => x !== l && x !== c);
      return AZ(o, w, l, c, _);
    } else
      return o.orderby(u);
  }
}
function AZ(e, t, n, r, i = []) {
  const s = j`FLOOR(${t})::INTEGER`, o = (a) => xt.from(e).select(a).groupby(s, i);
  return xt.union(
    o([{ [n]: Yo(n), [r]: I0(r, n) }, ...i]),
    o([{ [n]: Vo(n), [r]: T0(r, n) }, ...i]),
    o([{ [n]: I0(n, r), [r]: Yo(r) }, ...i]),
    o([{ [n]: T0(n, r), [r]: Vo(r) }, ...i])
  ).orderby(i, n);
}
function z4(e, t = []) {
  return new t.constructor(e);
}
function $Z(e, t, n) {
  const r = z4(e, n), i = n.length;
  for (let s = 0; s < i; ++s)
    r[t[s]] = n[s];
  return r;
}
function IZ(e, t, n, r, i, s, o) {
  const a = n.length, c = e * t, u = i.map((d) => r[d]), l = {}, f = [], h = new Int32Array(a);
  if (s != null && s.length) {
    const d = s.map((y) => r[y]), p = {};
    for (let y = 0; y < a; ++y) {
      const m = d.map((g) => g[y]);
      h[y] = p[m] ?? (p[m] = f.push(m) - 1);
    }
    for (let y = 0; y < s.length; ++y)
      l[s[y]] = f.map((m) => m[y]);
  } else
    f.push([]);
  if (o) {
    const d = n.map((m) => m % e), p = n.map((m) => Math.floor(m / e)), y = f.map(() => []);
    for (let m = 0; m < a; ++m)
      y[h[m]].push(m);
    i.forEach((m, g) => {
      const b = u[g];
      l[m] = f.map((w, _) => o(y[_], e, t, d, p, b));
    });
  } else
    i.forEach((d, p) => {
      const y = u[p], m = l[d] = f.map(() => z4(c, y));
      for (let g = 0; g < a; ++g)
        m[h[g]][n[g]] = y[g];
    });
  return { numRows: f.length, columns: l };
}
function F1(e) {
  let t = 1 / 0, n = -1 / 0;
  return e.forEach((r) => {
    const i = r.length;
    for (let s = 0; s < i; ++s) {
      const o = r[s];
      o < t && (t = o), o > n && (n = o);
    }
  }), Number.isFinite(t) && Number.isFinite(n) ? [t, n] : [0, 1];
}
function TZ(e) {
  const t = new pa();
  return e.forEach((n) => {
    const r = n.length;
    for (let i = 0; i < r; ++i)
      t.add(n[i]);
  }), Array.from(t).sort(zt);
}
function Ge(e, t) {
  return Di(e) ? (e.addEventListener("value", t), e.value) : e;
}
function Gy(e, t = !1) {
  const n = new Float64Array(5), r = new Float64Array(4);
  EZ(n, r, e);
  const i = Float64Array.of(
    0,
    r[1] - n[1] * r[0],
    r[2] - n[2] * r[0],
    r[3] - n[3] * r[0],
    -n[4] * r[0]
  ), s = 1 + n[1] + n[2] + n[3] + n[4], o = (r[0] + r[1] + r[2] + r[3]) / s, a = (i[1] + i[2] + i[3] + i[4]) / s;
  return {
    sigma: e,
    negative: t,
    a: n,
    b_causal: r,
    b_anticausal: i,
    sum_causal: o,
    sum_anticausal: a
  };
}
function EZ(e, t, n) {
  const i = Float64Array.of(
    0.84,
    1.8675,
    0.84,
    -1.8675,
    -0.34015,
    -0.1299,
    -0.34015,
    0.1299
  ), s = Math.exp(-1.783 / n), o = Math.exp(-1.723 / n), a = 0.6318 / n, c = 1.997 / n, u = Float64Array.of(
    -s * Math.cos(a),
    s * Math.sin(a),
    -s * Math.cos(-a),
    s * Math.sin(-a),
    -o * Math.cos(c),
    o * Math.sin(c),
    -o * Math.cos(-c),
    o * Math.sin(-c)
  ), l = n * 2.5066282746310007, f = Float64Array.of(i[0], i[1], 0, 0, 0, 0, 0, 0), h = Float64Array.of(1, 0, u[0], u[1], 0, 0, 0, 0, 0, 0);
  let d, p;
  for (p = 2; p < 8; p += 2) {
    for (f[p] = u[p] * f[p - 2] - u[p + 1] * f[p - 1], f[p + 1] = u[p] * f[p - 1] + u[p + 1] * f[p - 2], d = p - 2; d > 0; d -= 2)
      f[d] += u[p] * f[d - 2] - u[p + 1] * f[d - 1], f[d + 1] += u[p] * f[d - 1] + u[p + 1] * f[d - 2];
    for (d = 0; d <= p; d += 2)
      f[d] += i[p] * h[d] - i[p + 1] * h[d + 1], f[d + 1] += i[p] * h[d + 1] + i[p + 1] * h[d];
    for (h[p + 2] = u[p] * h[p] - u[p + 1] * h[p + 1], h[p + 3] = u[p] * h[p + 1] + u[p + 1] * h[p], d = p; d > 0; d -= 2)
      h[d] += u[p] * h[d - 2] - u[p + 1] * h[d - 1], h[d + 1] += u[p] * h[d - 1] + u[p + 1] * h[d - 2];
  }
  for (p = 0; p < 4; ++p)
    d = p << 1, t[p] = f[d] / l, e[p + 1] = h[d + 2];
}
function NZ(e, t, n, [r, i]) {
  const s = new Float64Array(Math.max(r, i)), o = new Float64Array(Math.max(r, i)), a = new Float64Array(5), c = new Float64Array(n.length);
  for (let u = 0, l = 0; u < i; ++u, l += r) {
    const f = c.subarray(l);
    Hy(e, n.subarray(l), r, 1, s, o, a, f);
  }
  for (let u = 0; u < r; ++u) {
    const l = c.subarray(u);
    Hy(t, l, i, r, s, o, a, l);
  }
  return c;
}
function Hy(e, t, n, r = 1, i = new Float64Array(n), s = new Float64Array(n), o = new Float64Array(5), a = i, c = DZ) {
  const u = r * 2, l = r * 3, f = r * 4, h = r * n;
  let d, p;
  for (c(
    i,
    t,
    n,
    r,
    e.b_causal,
    3,
    e.a,
    4,
    e.sum_causal,
    o,
    e.sigma
  ), p = 4, d = f; p < n; ++p, d += r)
    i[p] = e.b_causal[0] * t[d] + e.b_causal[1] * t[d - r] + e.b_causal[2] * t[d - u] + e.b_causal[3] * t[d - l] - e.a[1] * i[p - 1] - e.a[2] * i[p - 2] - e.a[3] * i[p - 3] - e.a[4] * i[p - 4];
  for (c(
    s,
    t,
    n,
    -r,
    e.b_anticausal,
    4,
    e.a,
    4,
    e.sum_anticausal,
    o,
    e.sigma
  ), p = 4, d = h - r * 5; p < n; ++p, d -= r)
    s[p] = e.b_anticausal[1] * t[d + r] + e.b_anticausal[2] * t[d + u] + e.b_anticausal[3] * t[d + l] + e.b_anticausal[4] * t[d + f] - e.a[1] * s[p - 1] - e.a[2] * s[p - 2] - e.a[3] * s[p - 3] - e.a[4] * s[p - 4];
  if (e.negative)
    for (p = 0, d = 0; p < n; ++p, d += r)
      a[d] = i[p] + s[n - p - 1];
  else
    for (p = 0, d = 0; p < n; ++p, d += r)
      a[d] = Math.max(0, i[p] + s[n - p - 1]);
  return a;
}
function DZ(e, t, n, r, i, s, o, a, c, u, l, f = 0.5) {
  const h = Math.abs(r) * n, d = r < 0 ? h + r : 0;
  let p, y, m;
  for (y = 0; y <= a; ++y)
    for (u[y] = y <= s ? i[y] : 0, m = 1; m <= a && m <= y; ++m)
      u[y] -= o[m] * u[y - m];
  for (m = 0; m < a; ++m)
    for (e[m] = 0, y = 1; y <= m; ++y)
      p = d + r * y, p >= 0 && p < h && (e[m] += u[m - y] * t[p]);
  const g = t[d], b = Math.ceil(l * 10);
  for (y = 0; y < b; ++y) {
    for (m = 0; m < a; ++m)
      e[m] += u[m] * g;
    if (c -= Math.abs(u[0]), c <= f) break;
    for (u[a] = y + a <= s ? i[y + a] : 0, m = 1; m <= a; ++m)
      u[a] -= o[m] * u[a - m];
    for (m = 0; m < a; ++m)
      u[m] = u[m + 1];
  }
}
const $i = "density";
class tp extends es {
  constructor(t, n, r) {
    const {
      bandwidth: i = 0,
      interpolate: s = "none",
      pixelSize: o = 1,
      pad: a = 1,
      width: c,
      height: u,
      ...l
    } = r, f = OZ(l);
    super(t, n, l, C4), this.densityMap = f, this.bandwidth = Ge(i, (h) => (this.bandwidth = h, this.grids ? this.convolve().update() : null)), this.interpolate = Ge(s, (h) => (this.interpolate = h, this.requestUpdate())), this.pixelSize = Ge(o, (h) => (this.pixelSize = h, this.requestUpdate())), this.pad = Ge(a, (h) => (this.pad = h, this.requestUpdate())), this.width = Ge(c, (h) => (this.width = h, this.requestUpdate())), this.height = Ge(u, (h) => (this.height = h, this.requestUpdate()));
  }
  /**
   * @param {import('../plot.js').Plot} plot The plot.
   * @param {number} index
   */
  setPlot(t, n) {
    const r = () => {
      this.hasFieldInfo() && this.requestUpdate();
    };
    t.addAttributeListener("xDomain", r), t.addAttributeListener("yDomain", r), super.setPlot(t, n);
  }
  get filterIndexable() {
    const t = this.plot.getAttribute("xDomain"), n = this.plot.getAttribute("yDomain");
    return t && n && !t[qn] && !n[qn];
  }
  query(t = []) {
    const { interpolate: n, pad: r, channels: i, densityMap: s, source: o } = this, [a, c] = this.extentX = Uu(this, t), [u, l] = this.extentY = zu(this, t), [f, h] = this.bins = this.binDimensions(), [d, p] = Vi(this, "x", f, [a, c], r), [y, m] = Vi(this, "y", h, [u, l], r), g = r ? [In(p, [+a, +c]), In(m, [+u, +l])] : [Tc(+a, p), Ic(p, +c), Tc(+u, m), Ic(m, +l)], b = xt.from(o.table).where(t.concat(g)), w = this.groupby = [], _ = {};
    for (const v of i)
      if (Object.hasOwn(v, "field")) {
        const { as: M, channel: E, field: $ } = v;
        $.aggregate ? (_[E] = $, s[E] = !0) : E === "weight" ? _[$i] = Bs($) : E !== "x" && E !== "y" && (b.select({ [M]: $ }), w.push(M));
      }
    const x = this.aggr = Object.keys(_);
    if (_.density && x.length > 1)
      throw new Error("Weight option can not be used with custom aggregates.");
    if (x.length || (x.push($i), _.density = Ni()), n === "linear") {
      if (x.length > 1)
        throw new Error("Linear binning not applicable to multiple aggregates.");
      if (!_.density)
        throw new Error("Linear binning not applicable to custom aggregates.");
      return kZ(b, d, y, _[$i], f, w);
    } else
      return RZ(b, d, y, _, f, w);
  }
  /**
   * @returns {[number, number]} The bin dimensions.
   */
  binDimensions() {
    const { plot: t, pixelSize: n, width: r, height: i } = this;
    return [
      r ?? Math.round(t.innerWidth() / n),
      i ?? Math.round(t.innerHeight() / n)
    ];
  }
  queryResult(t) {
    const [n, r] = this.bins, i = LZ(this.interpolate), { columns: s } = $s(t);
    return this.grids0 = IZ(n, r, s.index, s, this.aggr, this.groupby, i), this.convolve();
  }
  convolve() {
    const { aggr: t, bandwidth: n, bins: r, grids0: i, plot: s } = this;
    if (this.grids = i, n > 0) {
      const o = t.length === 1 ? t[0] : t.includes($i) ? $i : null;
      if (!o)
        return console.warn("No compatible grid found for smoothing."), this;
      const a = i.columns[o], c = s.innerWidth(), u = s.innerHeight(), [l, f] = r, h = a.some((y) => y.some((m) => m < 0)), d = Gy(n * (l - 1) / c, h), p = Gy(n * (f - 1) / u, h);
      this.grids = {
        numRows: i.numRows,
        columns: {
          ...i.columns,
          // @ts-ignore
          [o]: a.map((y) => NZ(d, p, y, r))
        }
      };
    }
    return this;
  }
}
function OZ(e) {
  const t = {};
  for (const n in e)
    e[n] === "density" && (delete e[n], t[n] = !0);
  return t;
}
function LZ(e = "none") {
  if (typeof e == "function") return e;
  switch (e.toLowerCase()) {
    case "none":
    case "linear":
      return;
    case "nearest":
      return v1;
    case "barycentric":
      return _1();
    case "random-walk":
      return x1();
  }
  throw new Error(`invalid interpolate: ${e}`);
}
function RZ(e, t, n, r, i, s) {
  return e.select({
    index: j`FLOOR(${t})::INTEGER + FLOOR(${n})::INTEGER * ${i}`,
    ...r
  }).groupby("index", s);
}
function kZ(e, t, n, r, i, s) {
  const o = r != null && r.column ? `* ${r.column}` : "", a = (h, d) => e.clone().select({ xp: t, yp: n, i: h, w: d }), c = a(
    j`FLOOR(xp)::INTEGER + FLOOR(yp)::INTEGER * ${i}`,
    j`(FLOOR(xp)::INTEGER + 1 - xp) * (FLOOR(yp)::INTEGER + 1 - yp)${o}`
  ), u = a(
    j`FLOOR(xp)::INTEGER + (FLOOR(yp)::INTEGER + 1) * ${i}`,
    j`(FLOOR(xp)::INTEGER + 1 - xp) * (yp - FLOOR(yp)::INTEGER)${o}`
  ), l = a(
    j`FLOOR(xp)::INTEGER + 1 + FLOOR(yp)::INTEGER * ${i}`,
    j`(xp - FLOOR(xp)::INTEGER) * (FLOOR(yp)::INTEGER + 1 - yp)${o}`
  ), f = a(
    j`FLOOR(xp)::INTEGER + 1 + (FLOOR(yp)::INTEGER + 1) * ${i}`,
    j`(xp - FLOOR(xp)::INTEGER) * (yp - FLOOR(yp)::INTEGER)${o}`
  );
  return xt.from(xt.unionAll(c, u, l, f)).select({ index: "i", density: Bs("w") }, s).groupby("index", s).having($m("density", 0));
}
class FZ extends tp {
  constructor(t, n) {
    const { thresholds: r = 10, ...i } = n;
    super("geo", t, {
      bandwidth: 20,
      interpolate: "linear",
      pixelSize: 2,
      ...i
    }), this.thresholds = Ge(r, (s) => (this.thresholds = s, this.grids ? this.contours().update() : null));
  }
  convolve() {
    return super.convolve().contours();
  }
  contours() {
    const { bins: t, densityMap: n, grids: r, thresholds: i, plot: s } = this, { numRows: o, columns: a } = r;
    let c = i, u;
    if (Array.isArray(c))
      u = c;
    else {
      const [, A] = F1(a.density);
      u = Array.from({ length: c - 1 }, (D, k) => A * (k + 1) / c);
    }
    (n.fill || n.stroke) && this.plot.getAttribute("colorScale") !== "log" && this.plot.setAttribute("colorZero", !0);
    const [l, f] = t, [h, d] = s.getAttribute("xDomain"), [p, y] = s.getAttribute("yDomain"), m = (d - h) / l, g = (y - p) / f, b = +h, w = +p, _ = (A) => b + A * m, x = (A) => w + A * g, v = zf().size(t), M = this.contourData = Array(o * u.length), { density: E, ...$ } = a, N = Object.entries($);
    for (let A = 0, D = 0; A < o; ++A) {
      const k = E[A], S = N.reduce((I, [T, R]) => (I[T] = R[A], I), {});
      for (let I = 0; I < u.length; ++I, ++D)
        M[D] = Object.assign(
          BZ(v.contour(k, u[I]), _, x),
          S
        );
    }
    return this;
  }
  plotSpecs() {
    const { type: t, channels: n, densityMap: r, contourData: i } = this, s = {};
    for (const o of n) {
      const { channel: a } = o;
      a !== "x" && a !== "y" && (s[a] = gn(o));
    }
    for (const o in r)
      r[o] && (s[o] = gn({ channel: o, as: "value" }));
    return [{ type: t, data: i, options: s }];
  }
}
function BZ(e, t, n) {
  function r(o) {
    o.forEach(i);
  }
  function i(o) {
    o.forEach(s);
  }
  function s(o) {
    o[0] = t(o[0]), o[1] = n(o[1]);
  }
  return e.coordinates.forEach(r), e;
}
function B1(e) {
  return Array.from({ length: e }, (t, n) => n);
}
function q4(e, t) {
  const n = t.reduce((i, s, o) => (i[s] = o, i), {}), r = B1(e.length);
  return r.sort((i, s) => n[e[i]] - n[e[s]]), r;
}
function j4(e, t) {
  if (typeof document < "u") {
    const n = document.createElement("canvas");
    return n.setAttribute("width", e), n.setAttribute("height", t), n;
  }
  throw new Error("Can not create a canvas instance.");
}
function CZ(e = 1) {
  const t = 255 * e | 0;
  return (n, r, i) => {
    for (let s = 0, o = 0; s < i; ++s)
      for (let a = 0; a < r; ++a, o += 4)
        n[o + 3] = t;
  };
}
function PZ(e) {
  const { apply: t } = e;
  return (n, r, i, s) => {
    for (let o = 0, a = 0; o < i; ++o)
      for (let c = 0, u = (i - o - 1) * r; c < r; ++c, a += 4)
        n[a + 3] = 255 * t(s[c + u]) | 0;
  };
}
function UZ(e = {}) {
  const { r: t = 0, g: n = 0, b: r = 0, opacity: i = 1 } = typeof e == "string" ? un(e) : e, s = new Uint8ClampedArray([t, n, r, 255 * i | 0]);
  return (o, a, c) => {
    for (let u = 0, l = 0; u < c; ++u)
      for (let f = 0; f < a; ++f, l += 4)
        o[l + 0] = s[0], o[l + 1] = s[1], o[l + 2] = s[2], o[l + 3] = s[3];
  };
}
function zZ(e) {
  const { domain: t, range: n } = e, r = /* @__PURE__ */ Object.create(null), i = new Uint8ClampedArray(4 * t.length), s = t.length - 1, o = n.length;
  for (let a = 0; a <= s; ++a) {
    const c = n[a % o], { r: u, g: l, b: f, opacity: h = 1 } = typeof c == "string" ? un(c) : c, d = a << 2;
    i[d + 0] = u, i[d + 1] = l, i[d + 2] = f, i[d + 3] = 255 * h | 0, r[t[a]] = d;
  }
  return (a, c, u, l) => {
    if (l.map)
      for (let f = 0, h = 0; f < u; ++f)
        for (let d = 0, p = (u - f - 1) * c; d < c; ++d, h += 4) {
          const y = r[l[d + p]];
          a[h + 0] = i[y + 0], a[h + 1] = i[y + 1], a[h + 2] = i[y + 2], a[h + 3] = i[y + 3];
        }
    else {
      const f = r[l];
      for (let h = 0, d = 0; h < u; ++h)
        for (let p = 0; p < c; ++p, d += 4)
          a[d + 0] = i[f + 0], a[d + 1] = i[f + 1], a[d + 2] = i[f + 2], a[d + 3] = i[f + 3];
    }
  };
}
function qZ(e, t, n) {
  const { interpolate: r } = t, i = new Uint8ClampedArray(4 * e), s = e - 1;
  for (let o = 0; o <= s; ++o) {
    const a = r(o / s), { r: c, g: u, b: l, opacity: f = 1 } = typeof a == "string" ? un(a) : a, h = o << 2;
    i[h + 0] = c, i[h + 1] = u, i[h + 2] = l, i[h + 3] = 255 * f | 0;
  }
  return (o, a, c, u) => {
    for (let l = 0, f = 0; l < c; ++l)
      for (let h = 0, d = (c - l - 1) * a; h < a; ++h, f += 4) {
        const p = s * n(u[h + d]) << 2;
        o[f + 0] = i[p + 0], o[f + 1] = i[p + 1], o[f + 2] = i[p + 2], o[f + 3] = i[p + 3];
      }
  };
}
class C1 extends tp {
  constructor(t, n) {
    super("image", t, n), this.image = null;
  }
  setPlot(t, n) {
    const r = () => {
      this.hasFieldInfo() && this.rasterize();
    };
    t.addAttributeListener("schemeColor", r), super.setPlot(t, n);
  }
  convolve() {
    return super.convolve().rasterize();
  }
  rasterize() {
    var g;
    const { bins: t, grids: n } = this, [r, i] = t, { numRows: s, columns: o } = n, { canvas: a, ctx: c, img: u } = XZ(this, r, i), { alpha: l, alphaProp: f, color: h, colorProp: d } = V4(this), p = o[f] ?? [], y = o[d] ?? [], m = s > 1 && d && ((g = this.groupby) != null && g.includes(d)) ? q4(y, this.plot.getAttribute("colorDomain")) : B1(s);
    return this.data = {
      numRows: s,
      columns: {
        src: Array.from({ length: s }, (b, w) => (h == null || h(u.data, r, i, y[m[w]]), l == null || l(u.data, r, i, p[m[w]]), c.putImageData(u, 0, 0), a.toDataURL()))
      }
    }, this;
  }
  plotSpecs() {
    var o;
    const { type: t, plot: n, data: { numRows: r, columns: i } } = this, s = {
      src: i.src,
      width: n.innerWidth(),
      height: n.innerHeight(),
      preserveAspectRatio: "none",
      imageRendering: (o = this.channel("imageRendering")) == null ? void 0 : o.value,
      frameAnchor: "middle"
    };
    return [{ type: t, data: { length: r }, options: s }];
  }
}
class jZ extends C1 {
  constructor(t, n) {
    super(t, {
      bandwidth: 20,
      interpolate: "linear",
      pixelSize: 2,
      ...n
    });
  }
}
function V4(e) {
  const { aggr: t, densityMap: n, groupby: r, plot: i } = e, s = t.includes($i), o = t.includes("fillOpacity"), a = e.channel("fill"), c = e.channel("fillOpacity");
  if (t.length > 2 || s && o)
    throw new Error("Invalid raster encodings. Try dropping an aggregate?");
  if (r.includes(c == null ? void 0 : c.as))
    throw new Error("Raster fillOpacity must be an aggregate or constant.");
  const u = n.fill || t.includes("fill") ? "grid" : r.includes(a == null ? void 0 : a.as) ? "group" : L4(a == null ? void 0 : a.value) ? a.value : s && i.getAttribute("colorScheme") ? "grid" : void 0, l = n.fillOpacity || t.includes("fillOpacity") ? "grid" : typeof (c == null ? void 0 : c.value) == "number" ? c.value : s && u !== "grid" ? "grid" : void 0;
  if (u !== "grid" && l !== "grid")
    throw new Error("Raster mark missing density values.");
  const f = (a == null ? void 0 : a.as) ?? (u === "grid" ? $i : null), h = (c == null ? void 0 : c.as) ?? (l === "grid" ? $i : null), d = u !== "grid" && u !== "group" ? UZ(u) : YZ(e, f), p = l !== "grid" ? CZ(l) : VZ(e, h);
  return { alphaProp: h, colorProp: f, alpha: p, color: d };
}
function VZ(e, t) {
  const { plot: n, grids: r } = e, i = n.getAttribute("opacityDomain"), s = i === uu, o = i == null ? void 0 : i[qn], a = !s && !o && i || F1(r.columns[t]);
  (s || o || !i) && (s || (a[qn] = !0), n.setAttribute("opacityDomain", a));
  const c = Jc({
    opacity: {
      type: n.getAttribute("opacityScale"),
      domain: a,
      clamp: n.getAttribute("opacityClamp"),
      nice: n.getAttribute("opacityNice"),
      reverse: n.getAttribute("opacityReverse"),
      zero: n.getAttribute("opacityZero"),
      base: n.getAttribute("opacityBase"),
      exponent: n.getAttribute("opacityExponent"),
      constant: n.getAttribute("opacityConstant")
    }
  });
  return PZ(c);
}
function YZ(e, t) {
  var h;
  const { plot: n, grids: r } = e, i = r.columns[t], s = !((h = i[0]) != null && h.map), o = s || Array.isArray(i[0]), a = n.getAttribute("colorDomain"), c = a === uu, u = a == null ? void 0 : a[qn], l = !c && !u && a || (s ? i.slice().sort(zt) : o ? TZ(i) : F1(i));
  (c || u || !a) && (c || (l[qn] = !0), n.setAttribute("colorDomain", l));
  const f = Jc({
    color: {
      type: n.getAttribute("colorScale"),
      domain: l,
      range: n.getAttribute("colorRange"),
      clamp: n.getAttribute("colorClamp"),
      n: n.getAttribute("colorN"),
      nice: n.getAttribute("colorNice"),
      reverse: n.getAttribute("colorReverse"),
      scheme: n.getAttribute("colorScheme"),
      interpolate: n.getAttribute("colorInterpolate"),
      pivot: n.getAttribute("colorPivot"),
      symmetric: n.getAttribute("colorSymmetric"),
      zero: n.getAttribute("colorZero"),
      base: n.getAttribute("colorBase"),
      exponent: n.getAttribute("colorExponent"),
      constant: n.getAttribute("colorConstant")
    }
  });
  if (o)
    return zZ(f);
  {
    const d = Jc({
      x: {
        type: WZ(f.type),
        domain: f.domain,
        reverse: f.reverse,
        range: [0, 1],
        clamp: f.clamp,
        base: f.base,
        exponent: f.exponent,
        constant: f.constant
      }
    });
    return qZ(1024, f, d.apply);
  }
}
function WZ(e) {
  return e.endsWith("symlog") ? "symlog" : e.endsWith("log") ? "log" : e.endsWith("pow") ? "pow" : e.endsWith("sqrt") ? "sqrt" : e === "diverging" ? "linear" : e;
}
function XZ(e, t, n) {
  if (!e.image || e.image.w !== t || e.image.h !== n) {
    const r = j4(t, n), i = r.getContext("2d", { willReadFrequently: !0 }), s = i.getImageData(0, 0, t, n);
    e.image = { canvas: r, ctx: i, img: s, w: t, h: n };
  }
  return e.image;
}
class GZ extends C1 {
  constructor(t, n) {
    const { normalize: r = !0, ...i } = n;
    super(t, i), this.normalize = Ge(r, (s) => (this.normalize = s, this.requestUpdate()));
  }
  query(t = []) {
    const { channels: n, normalize: r, source: i, pad: s } = this, [o, a] = this.bins = this.binDimensions(), [c] = Vi(this, "x", o, Uu(this, t), s), [u] = Vi(this, "y", a, zu(this, t), s), l = xt.from(i.table).where(HZ(this, t));
    this.aggr = ["density"];
    const f = this.groupby = [], h = [];
    for (const d of n)
      if (Object.hasOwn(d, "field")) {
        const { channel: p, field: y } = d;
        p === "z" ? (l.select({ [p]: y }), h.push("z")) : p !== "x" && p !== "y" && (l.select({ [p]: y }), f.push(p));
      }
    return JZ(l, c, u, h, o, a, f, r);
  }
}
function HZ(e, t) {
  if (Array.isArray(t) && !t.length) return t;
  const { column: n } = e.channelField("x"), { column: r } = e.channelField("y"), i = (o) => {
    const a = `${o.field}`;
    return o.op !== "BETWEEN" || a !== n && a !== r;
  }, s = (o) => o.op === "AND" ? ki(o.children.filter((a) => i(a))) : o;
  return Array.isArray(t) ? t.filter((o) => i(o)).map((o) => s(o)) : s(t);
}
function JZ(e, t, n, r, i, s, o = [], a = !0) {
  e.select({
    x: j`FLOOR(${t})::INTEGER`,
    y: j`FLOOR(${n})::INTEGER`
  });
  const c = o.concat(r), u = c.length ? `PARTITION BY ${c.join(", ")} ` : "", l = xt.from(e).select(c, {
    x0: "x",
    y0: "y",
    dx: j`(lead(x) OVER sw - x)`,
    dy: j`(lead(y) OVER sw - y)`
  }).window({ sw: j`${u}ORDER BY x ASC` }).qualify(ki(
    j`(x0 < ${i} OR x0 + dx < ${i})`,
    j`(y0 < ${s} OR y0 + dy < ${s})`,
    j`(x0 > 0 OR x0 + dx > 0)`,
    j`(y0 > 0 OR y0 + dy > 0)`
  )), f = xt.select({ x: j`GREATEST(MAX(ABS(dx)), MAX(ABS(dy)))` }).from("pairs"), h = xt.select({ i: j`UNNEST(range((${f})))::INTEGER` }), d = xt.unionAll(
    xt.select(c, {
      x: j`x0 + i`,
      y: j`y0 + ROUND(i * dy / dx::FLOAT)::INTEGER`
    }).from("pairs", "indices").where(j`ABS(dy) <= ABS(dx) AND i < ABS(dx)`),
    xt.select(c, {
      x: j`x0 + ROUND(SIGN(dy) * i * dx / dy::FLOAT)::INTEGER`,
      y: j`y0 + SIGN(dy) * i`
    }).from("pairs", "indices").where(j`ABS(dy) > ABS(dx) AND i < ABS(dy)`),
    xt.select(c, { x: "x0", y: "y0" }).from("pairs").where(Am("dx"))
  ), p = ["x"].concat(c).join(", "), y = xt.from("raster").select(
    c,
    "x",
    "y",
    a ? { w: j`1.0 / COUNT(*) OVER (PARTITION BY ${p})` } : null
  ).where(ki(In("x", [0, i], !0), In("y", [0, s], !0)));
  return xt.with({ pairs: l, indices: h, raster: d, points: y }).from("points").select(o, {
    index: j`x + y * ${i}::INTEGER`,
    density: a ? Bs("w") : Ni()
  }).groupby("index", o);
}
class Y4 extends es {
  constructor(t, n, r) {
    const { bins: i = 1024, bandwidth: s = 20, ...o } = r, a = t.endsWith("X") ? "y" : "x";
    super(t, n, o, a === "x" ? F4 : B4), this.dim = a, this.bins = Ge(i, (c) => (this.bins = c, this.requestUpdate())), this.bandwidth = Ge(s, (c) => (this.bandwidth = c, this.grid ? this.convolve().update() : null));
  }
  get filterIndexable() {
    const t = this.dim === "x" ? "xDomain" : "yDomain", n = this.plot.getAttribute(t);
    return n && !n[qn];
  }
  query(t = []) {
    if (this.hasOwnData()) throw new Error("Density1DMark requires a data source");
    const { bins: n, channels: r, dim: i, source: { table: s } } = this, o = this.extent = (i === "x" ? Uu : zu)(this, t), [a, c] = Vi(this, i, n, o), u = k1(r, s, [i]).where(t.concat(In(c, o))), l = this.channelField("weight") ? "weight" : null;
    return ZZ(u, a, l);
  }
  queryResult(t) {
    const { columns: { index: n, density: r } } = $s(t);
    return this.grid = $Z(this.bins, n, r), this.convolve();
  }
  convolve() {
    const { bins: t, bandwidth: n, dim: r, grid: i, plot: s, extent: [o, a] } = this, c = i.some((w) => w < 0), u = r === "x" ? s.innerWidth() : s.innerHeight(), l = Gy(n * (t - 1) / u, c), f = Hy(l, i, t), h = r === "x" ? "y" : "x", d = this.channelField(r).as, p = +o, y = (a - p) / (t - 1), m = 1 / y, g = new Float64Array(t), b = new Float64Array(t);
    for (let w = 0; w < t; ++w)
      g[w] = p + w * y, b[w] = f[w] * m;
    return this.data = { numRows: t, columns: { [d]: g, [h]: b } }, this;
  }
  plotSpecs() {
    const { type: t, data: { numRows: n, columns: r }, channels: i, dim: s } = this, o = s === "x" ? { y: r.y } : { x: r.x };
    for (const a of i)
      o[a.channel] = gn(a, r);
    return [{ type: t, data: { length: n }, options: o }];
  }
}
function ZZ(e, t, n) {
  const r = n ? `* ${n}` : "", i = e.clone().select({
    p: t,
    i: j`FLOOR(p)::INTEGER`,
    w: j`(FLOOR(p) + 1 - p)${r}`
  }), s = e.clone().select({
    p: t,
    i: j`FLOOR(p)::INTEGER + 1`,
    w: j`(p - FLOOR(p))${r}`
  });
  return xt.from(xt.unionAll(i, s)).select({ index: "i", density: Bs("w") }).groupby("index").having(Yx("density", 0));
}
class KZ extends tp {
  constructor(t, n) {
    const { type: r = "dot", ...i } = n;
    super(r, t, {
      bandwidth: 20,
      interpolate: "linear",
      pad: 0,
      pixelSize: 2,
      ...i
    });
  }
  convolve() {
    super.convolve();
    const { bins: t, pad: n, extentX: r, extentY: i } = this, [s, o] = t, a = Bh(this, "x"), c = Bh(this, "y"), [u, l] = r.map((m) => a.apply(m)), [f, h] = i.map((m) => c.apply(m)), d = (l - u) / (s - n), p = (h - f) / (o - n), y = n ? 0 : 0.5;
    return this.data = QZ(
      this.grids,
      t,
      u,
      f,
      d,
      p,
      a.invert,
      c.invert,
      y
    ), this;
  }
  plotSpecs() {
    const { type: t, channels: n, densityMap: r, data: { numRows: i, columns: s } } = this, o = {};
    for (const a of n) {
      const { channel: c } = a;
      o[c] = c === "x" || c === "y" ? s[c] : gn(a, s);
    }
    for (const a in r)
      r[a] && (o[a] = s.density);
    return [{ type: t, data: { length: i }, options: o }];
  }
}
function QZ(e, t, n, r, i, s, o, a, c) {
  const u = 1 / (i * s), [l, f] = t, h = l * f, d = h * e.numRows, p = new Float64Array(d), y = new Float64Array(d), m = new Float64Array(d), g = { x: p, y, density: m }, { density: b, ...w } = e.columns;
  for (const x in w)
    g[x] = new w[x].constructor(d);
  let _ = 0;
  for (let x = 0; x < e.numRows; ++x) {
    for (const M in w)
      g[M].fill(w[M][x], _, _ + h);
    const v = b[x];
    for (let M = 0, E = 0; E < f; ++E)
      for (let $ = 0; $ < l; ++$, ++_, ++M)
        p[_] = o(n + ($ + c) * i), y[_] = a(r + (E + c) * s), m[_] = v[M] * u;
  }
  return { numRows: d, columns: g };
}
function tK(e, t, n) {
  var r = 1e-8, i = t - 1, s = n - 1, o = 0, a, c, u, l, f, h, d, p, y, m, g;
  if (e <= 0) return 0;
  if (e >= 1) return 1;
  for (t >= 1 && n >= 1 ? (u = e < 0.5 ? e : 1 - e, l = Math.sqrt(-2 * Math.log(u)), d = (2.30753 + l * 0.27061) / (1 + l * (0.99229 + l * 0.04481)) - l, e < 0.5 && (d = -d), p = (d * d - 3) / 6, y = 2 / (1 / (2 * t - 1) + 1 / (2 * n - 1)), m = d * Math.sqrt(p + y) / y - (1 / (2 * n - 1) - 1 / (2 * t - 1)) * (p + 5 / 6 - 2 / (3 * y)), d = t / (t + n * Math.exp(2 * m))) : (a = Math.log(t / (t + n)), c = Math.log(n / (t + n)), l = Math.exp(t * a) / t, f = Math.exp(n * c) / n, m = l + f, e < l / m ? d = Math.pow(t * m * e, 1 / t) : d = 1 - Math.pow(n * m * (1 - e), 1 / n)), g = -ko(t) - ko(n) + ko(t + n); o < 10; o++) {
    if (d === 0 || d === 1) return d;
    if (h = eK(d, t, n) - e, l = Math.exp(i * Math.log(d) + s * Math.log(1 - d) + g), f = h / l, d -= l = f / (1 - 0.5 * Math.min(1, f * (i / d - s / (1 - d)))), d <= 0 && (d = 0.5 * (d + l)), d >= 1 && (d = 0.5 * (d + l + 1)), Math.abs(l) < r * d && o > 0) break;
  }
  return d;
}
function eK(e, t, n) {
  var r = e === 0 || e === 1 ? 0 : Math.exp(ko(t + n) - ko(t) - ko(n) + t * Math.log(e) + n * Math.log(1 - e));
  return e < 0 || e > 1 ? 0 : e < (t + 1) / (t + n + 2) ? r * M_(e, t, n) / t : 1 - r * M_(1 - e, n, t) / n;
}
function M_(e, t, n) {
  var r = 1e-30, i = 1, s = t + n, o = t + 1, a = t - 1, c = 1, u = 1 - s * e / o, l, f, h, d;
  for (Math.abs(u) < r && (u = r), u = 1 / u, d = u; i <= 100 && (l = 2 * i, f = i * (n - i) * e / ((a + l) * (t + l)), u = 1 + f * u, Math.abs(u) < r && (u = r), c = 1 + f / c, Math.abs(c) < r && (c = r), u = 1 / u, d *= u * c, f = -(t + i) * (s + i) * e / ((t + l) * (o + l)), u = 1 + f * u, Math.abs(u) < r && (u = r), c = 1 + f / c, Math.abs(c) < r && (c = r), u = 1 / u, h = u * c, d *= h, !(Math.abs(h - 1) < 3e-7)); i++)
    ;
  return d;
}
function ko(e) {
  var t = 0, n = [
    76.18009172947146,
    -86.5053203294167,
    24.01409824083091,
    -1.231739572450155,
    0.001208650973866179,
    -5395239384953e-18
  ], r = 1.000000000190015, i, s, o;
  for (o = (s = i = e) + 5.5, o -= (i + 0.5) * Math.log(o); t < 6; t++) r += n[t] / ++s;
  return Math.log(2.506628274631 * r / i) - o;
}
function nK(e, t) {
  var n = tK(2 * Math.min(e, 1 - e), 0.5 * t, 0.5);
  return n = Math.sqrt(t * (1 - n) / n), e > 0.5 ? n : -n;
}
function rK(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;
}
class W4 extends es {
  constructor(t, n, r) {
    const i = t.endsWith("X") ? "y" : "x", { ci: s = 0.95, ...o } = r;
    super(t, n, o), this.dim = i, this.field = this.channelField(i).field, this.channels = this.channels.filter((a) => a.channel !== i), this.ci = Ge(s, (a) => (this.ci = a, this.update()));
  }
  query(t = []) {
    const { channels: n, field: r, source: { table: i } } = this, s = n.concat([
      { field: Xx(r), as: "__avg__" },
      { field: Ni(r), as: "__n__" },
      { field: Gx(r), as: "__sd__" }
    ]);
    return k1(s, i).where(t);
  }
  queryResult(t) {
    return this.data = $s(t), this;
  }
  plotSpecs() {
    const { type: t, dim: n, detail: r, data: i, ci: s, channels: o } = this, a = Math.SQRT2 * rK(s), { columns: { __avg__: c, __sd__: u, __n__: l } } = i, f = {
      [`${n}1`]: c.map((h, d) => h - a * u[d] / Math.sqrt(l[d])),
      [`${n}2`]: c.map((h, d) => h + a * u[d] / Math.sqrt(l[d]))
    };
    return k4(t, r, o, i, f);
  }
}
const iK = "geom";
class sK extends es {
  constructor(t, n = {}, r) {
    !Xy(t) && !(n != null && n.geometry) && (n.geometry = Hx(iK)), super("geo", t, n, r);
  }
  queryResult(t) {
    var r;
    super.queryResult(t);
    const n = (r = this.channelField("geometry")) == null ? void 0 : r.as;
    if (n) {
      const { columns: i } = this.data;
      typeof i[n][0] == "string" && (i[n] = i[n].map((s) => JSON.parse(s)));
    }
    return this;
  }
}
class oK extends es {
  constructor(t, n) {
    const { type: r = "hexagon", binWidth: i = 20, ...s } = n;
    super(r, t, { r: i / 2, clip: !0, ...s }, C4), this.binWidth = Ge(i, (o) => (this.binWidth = o, this.requestUpdate()));
  }
  get filterIndexable() {
    const t = this.plot.getAttribute("xDomain"), n = this.plot.getAttribute("yDomain");
    return t && n && !t[qn] && !n[qn];
  }
  query(t = []) {
    if (this.hasOwnData()) return null;
    const { plot: n, binWidth: r, channels: i, source: s } = this;
    let o, a;
    const c = /* @__PURE__ */ new Set(), u = {};
    for (const _ of i)
      if (_.channel !== "orderby") {
        if (_.channel === "x")
          o = _;
        else if (_.channel === "y")
          a = _;
        else if (Object.hasOwn(_, "field")) {
          const { as: x, field: v } = _;
          u[x] = v, v.aggregate || c.add(x);
        }
      }
    const [l, f] = Uu(this, t), [h, d] = zu(this, t), p = 0.5 - n.getAttribute("marginLeft"), y = 0 - n.getAttribute("marginTop"), m = `${r}::DOUBLE`, g = `${r * (1.5 / Math.sqrt(3))}::DOUBLE`, b = `${n.innerWidth() / (f - l)}::DOUBLE`, w = `${n.innerHeight() / (d - h)}::DOUBLE`;
    return xt.select({
      [o.as]: j`${l}::DOUBLE + ((_x + 0.5 * (_y & 1)) * ${m} + ${p})::DOUBLE / ${b}`,
      [a.as]: j`${d}::DOUBLE - (_y * ${g} + ${y})::DOUBLE / ${w}`,
      ...u
    }).groupby("_x", "_y", ...c).from(
      // Subquery performs hex binning in screen space and also passes
      // original columns through (the DB should optimize this).
      xt.select({
        _py: j`(${w} * (${d}::DOUBLE - ${a.field}) - ${y}) / ${g}`,
        _pj: j`ROUND(_py)::INTEGER`,
        _px: j`(${b} * (${o.field} - ${l}::DOUBLE) - ${p}) / ${m} - 0.5 * (_pj & 1)`,
        _pi: j`ROUND(_px)::INTEGER`,
        _tt: j`ABS(_py-_pj) * 3 > 1 AND (_px-_pi)**2 + (_py-_pj)**2 > (_px - _pi - 0.5 * CASE WHEN _px < _pi THEN -1 ELSE 1 END)**2 + (_py - _pj - CASE WHEN _py < _pj THEN -1 ELSE 1 END)**2`,
        _x: j`CASE WHEN _tt THEN (_pi + (CASE WHEN _px < _pi THEN -0.5 ELSE 0.5 END) + (CASE WHEN _pj & 1 <> 0 THEN 0.5 ELSE -0.5 END))::INTEGER ELSE _pi END`,
        _y: j`CASE WHEN _tt THEN (_pj + CASE WHEN _py < _pj THEN -1 ELSE 1 END)::INTEGER ELSE _pj END`
      }, "*").from(s.table).where($c(o.field), $c(a.field), t)
    );
  }
}
class aK extends tp {
  constructor(t, n) {
    const { origin: r = [0, 0], dim: i = "xy", ...s } = n;
    super("image", t, s), this.image = null, this.origin = r, this.tileX = i.toLowerCase().includes("x"), this.tileY = i.toLowerCase().includes("y");
  }
  setPlot(t, n) {
    const r = () => {
      this.hasFieldInfo() && this.rasterize();
    };
    t.addAttributeListener("schemeColor", r), super.setPlot(t, n);
  }
  requestQuery() {
    return this.requestTiles();
  }
  query(t = []) {
    return this._filter = t, null;
  }
  tileQuery(t) {
    const { interpolate: n, pad: r, channels: i, densityMap: s, source: o } = this, [[a, c], [u, l]] = t, [f, h] = this.bins, [d, p] = Vi(this, "x", f, [a, c], r), [y, m] = Vi(this, "y", h, [u, l], r), g = r ? [In(p, [+a, +c]), In(m, [+u, +l])] : [Tc(+a, p), Ic(p, +c), Tc(+u, m), Ic(m, +l)], b = xt.from(o.table).where(g), w = this.groupby = [], _ = {};
    for (const v of i)
      if (Object.hasOwn(v, "field")) {
        const { as: M, channel: E, field: $ } = v;
        $.aggregate ? (_[E] = $, s[E] = !0) : E === "weight" ? _.density = Bs($) : E !== "x" && E !== "y" && (b.select({ [M]: $ }), w.push(M));
      }
    const x = this.aggr = Object.keys(_);
    if (_.density && x.length > 1)
      throw new Error("Weight option can not be used with custom aggregates.");
    if (x.length || (x.push("density"), _.density = Ni()), n === "linear") {
      if (x.length > 1)
        throw new Error("Linear binning not applicable to multiple aggregates.");
      if (!_.density)
        throw new Error("Linear binning not applicable to custom aggregates.");
      return hK(b, d, y, _.density, f, w);
    } else
      return fK(b, d, y, _, f, w);
  }
  async requestTiles() {
    const t = Wr();
    this.prefetch && t.cancel(this.prefetch);
    const { pad: n, tileX: r, tileY: i, origin: [s, o] } = this, [a, c] = this.bins = this.binDimensions(), [u, l] = Uu(this, this._filter), [f, h] = zu(this, this._filter), d = l - u, p = h - f, y = Math.floor((u - s) * (a - n) / d), m = Math.floor((f - o) * (c - n) / p), g = (A, D) => [
      [s + A * d, s + (A + 1) * d],
      [o + D * p, o + (D + 1) * p]
    ], b = Math.floor((u - s) / d), w = r ? A_((l - s) / d) : b, _ = Math.floor((f - o) / p), x = i ? A_((h - o) / p) : _, v = [];
    for (let A = b; A <= w; ++A)
      for (let D = _; D <= x; ++D)
        v.push([A, D]);
    const M = v.map(
      ([A, D]) => t.query(this.tileQuery(g(A, D)))
    ), E = [];
    if (r)
      for (let A = _; A <= x; ++A)
        E.push([w + 1, A]), E.push([b - 1, A]);
    if (i) {
      const A = r ? b - 1 : b, D = r ? w + 1 : w;
      for (let k = A; k <= D; ++k)
        E.push([k, x + 1]), E.push([k, _ - 1]);
    }
    this.prefetch = E.map(
      ([A, D]) => t.prefetch(this.tileQuery(g(A, D)))
    );
    const $ = await Promise.all(M), N = cK(a, c, y, m, v, $);
    this.grids0 = {
      numRows: N.length,
      columns: { density: [N] }
    }, this.convolve().update();
  }
  convolve() {
    return super.convolve().rasterize();
  }
  rasterize() {
    var g;
    const { bins: t, grids: n } = this, [r, i] = t, { numRows: s, columns: o } = n, { canvas: a, ctx: c, img: u } = lK(this, r, i), { alpha: l, alphaProp: f, color: h, colorProp: d } = V4(this), p = o[f] ?? [], y = o[d] ?? [], m = s > 1 && d && ((g = this.groupby) != null && g.includes(d)) ? q4(y, this.plot.getAttribute("colorDomain")) : B1(s);
    return this.data = {
      numRows: s,
      columns: {
        src: Array.from({ length: s }, (b, w) => (h == null || h(u.data, r, i, y[m[w]]), l == null || l(u.data, r, i, p[m[w]]), c.putImageData(u, 0, 0), a.toDataURL()))
      }
    }, this;
  }
  plotSpecs() {
    var o;
    const { type: t, plot: n, data: { numRows: r, columns: i } } = this, s = {
      src: i.src,
      width: n.innerWidth(),
      height: n.innerHeight(),
      preserveAspectRatio: "none",
      imageRendering: (o = this.channel("imageRendering")) == null ? void 0 : o.value,
      frameAnchor: "middle"
    };
    return [{ type: t, data: { length: r }, options: s }];
  }
}
function cK(e, t, n, r, i, s) {
  const o = new Float64Array(e * t);
  return s.forEach((a, c) => {
    const [u, l] = i[c], f = u * e - n, h = l * t - r;
    uK(e, t, o, a, f, h);
  }), o;
}
function uK(e, t, n, r, i, s) {
  const o = r.numRows;
  if (o === 0) return;
  const a = r.getChild("index").toArray(), c = r.getChild("density").toArray();
  for (let u = 0; u < o; ++u) {
    const l = a[u], f = i + l % e, h = s + Math.floor(l / e);
    0 <= f && f < e && 0 <= h && h < t && (n[f + h * e] = c[u]);
  }
}
function lK(e, t, n) {
  if (!e.image || e.image.w !== t || e.image.h !== n) {
    const r = j4(t, n), i = r.getContext("2d", { willReadFrequently: !0 }), s = i.getImageData(0, 0, t, n);
    e.image = { canvas: r, ctx: i, img: s, w: t, h: n };
  }
  return e.image;
}
function fK(e, t, n, r, i, s) {
  return e.select({
    index: j`FLOOR(${t})::INTEGER + FLOOR(${n})::INTEGER * ${i}`,
    ...r
  }).groupby("index", s);
}
function hK(e, t, n, r, i, s) {
  const o = r.column ? `* ${r.column}` : "", a = (h, d) => e.clone().select({ xp: t, yp: n, i: h, w: d }), c = a(
    j`FLOOR(xp)::INTEGER + FLOOR(yp)::INTEGER * ${i}`,
    j`(FLOOR(xp)::INTEGER + 1 - xp) * (FLOOR(yp)::INTEGER + 1 - yp)${o}`
  ), u = a(
    j`FLOOR(xp)::INTEGER + (FLOOR(yp)::INTEGER + 1) * ${i}`,
    j`(FLOOR(xp)::INTEGER + 1 - xp) * (yp - FLOOR(yp)::INTEGER)${o}`
  ), l = a(
    j`FLOOR(xp)::INTEGER + 1 + FLOOR(yp)::INTEGER * ${i}`,
    j`(xp - FLOOR(xp)::INTEGER) * (FLOOR(yp)::INTEGER + 1 - yp)${o}`
  ), f = a(
    j`FLOOR(xp)::INTEGER + 1 + (FLOOR(yp)::INTEGER + 1) * ${i}`,
    j`(xp - FLOOR(xp)::INTEGER) * (yp - FLOOR(yp)::INTEGER)${o}`
  );
  return xt.from(xt.unionAll(c, u, l, f)).select({ index: "i", density: Bs("w") }, s).groupby("index", s).having($m("density", 0));
}
function A_(e) {
  const t = Math.floor(e);
  return t === e ? t - 1 : t;
}
class dK extends es {
  constructor(t, n) {
    const { ci: r = 0.95, precision: i = 4, ...s } = n;
    super("line", t, s);
    const o = () => this.modelFit ? this.confidenceBand().update() : null;
    this.ci = Ge(r, (a) => (this.ci = a, o())), this.precision = Ge(i, (a) => (this.precision = a, o()));
  }
  query(t = []) {
    const n = this.channelField("x").as, r = this.channelField("y").as, i = Array.from(new Set(
      ["stroke", "z", "fx", "fy"].flatMap((s) => {
        var o;
        return ((o = this.channelField(s)) == null ? void 0 : o.as) || [];
      })
    ));
    return xt.from(super.query(t)).select({
      intercept: pL(r, n),
      slope: yL(r, n),
      n: mL(r, n),
      ssy: gL(r, n),
      ssx: bL(r, n),
      xm: wL(r, n),
      x0: E0(Yo(n).where($c(r))),
      x1: E0(Vo(n).where($c(r)))
    }).select(i).groupby(i);
  }
  queryResult(t) {
    return this.modelFit = $s(t), this.lineData = pK(this.modelFit), this.confidenceBand();
  }
  confidenceBand() {
    const { ci: t, modelFit: n, precision: r, plot: i } = this, s = i.innerWidth();
    return this.areaData = t ? yK(n, t, r, s) : null, this;
  }
  plotSpecs() {
    const { lineData: t, areaData: n, channels: r, ci: i } = this, s = t.columns, o = i ? n.columns : {}, a = { x: s.x, y: s.y }, c = { x: o.x, y1: o.y1, y2: o.y2, fillOpacity: 0.1 };
    for (const u of r)
      switch (u.channel) {
        case "x":
        case "y":
        case "fill":
          break;
        case "tip":
          c.tip = gn(u, o);
          break;
        case "stroke":
          a.stroke = gn(u, s), c.fill = gn(u, o);
          break;
        case "strokeOpacity":
          a.strokeOpacity = gn(u, s);
          break;
        case "fillOpacity":
          c.fillOpacity = gn(u, o);
          break;
        default:
          a[u.channel] = gn(u, s), c[u.channel] = gn(u, o);
          break;
      }
    return [
      ...i ? [{ type: "areaY", data: { length: n.numRows }, options: c }] : [],
      { type: "line", data: { length: t.numRows }, options: a }
    ];
  }
}
function l0(e, t) {
  if (e.concat) return e.concat(t);
  const n = new e.constructor(e.length + t.length);
  return n.set(e, 0), n.set(t, e.length), n;
}
function pK(e) {
  const { x0: t = [], x1: n = [], xm: r, intercept: i, slope: s, n: o, ssx: a, ssy: c, ...u } = e.columns, l = (d, p) => i[p] + d * s[p], f = l0(t, n), h = l0(t.map(l), n.map(l));
  for (const d in u)
    u[d] = l0(u[d], u[d]);
  return { numRows: f.length, columns: { x: f, y: h, ...u } };
}
function yK(e, t, n, r) {
  const i = e.numRows, { x0: s, x1: o, xm: a, intercept: c, slope: u, n: l, ssx: f, ssy: h, ...d } = e.columns, p = Object.keys(d), y = { x: [], y1: [], y2: [] };
  p.forEach((m) => y[m] = []);
  for (let m = 0; m < i; ++m) {
    const g = n * (o[m] - s[m]) / r, b = nK((1 - t) / 2, l[m] - 2) * Math.sqrt(h[m] / (l[m] - 2));
    sn(s[m], o[m] - g / 2, g).concat(o[m]).forEach((w) => {
      const _ = c[m] + w * u[m], x = b * Math.sqrt(1 / l[m] + (w - a[m]) ** 2 / f[m]);
      y.x.push(w), y.y1.push(_ - x), y.y2.push(_ + x), p.forEach((v) => y[v].push(d[v][m]));
    });
  }
  return { numRows: y.x.length, columns: y };
}
function mK(e) {
  const t = e.toLowerCase(), n = e.length;
  let r = "";
  for (let i = 0; i < n; ++i)
    r += (e[i] !== t[i] ? "-" : "") + t[i];
  return r;
}
function P1(e) {
  const t = {};
  for (const n in e)
    t[mK(n)] = e[n];
  return t;
}
function gK(e) {
  const { channels: t } = e, n = /* @__PURE__ */ new Set();
  let r = !1, i = !1;
  for (const s of t) {
    const { channel: o, field: a, as: c } = s;
    if (o === "orderby")
      r = !0;
    else if (a)
      if (a.aggregate)
        i = !0;
      else {
        if (n.has(c)) continue;
        n.add(c);
      }
  }
  return !r && i && n.size && e.channels.push({ channel: "orderby", value: Array.from(n) }), e;
}
class bK {
  constructor(t, {
    selection: n,
    channels: r = {}
  }) {
    this.mark = gK(t), this.selection = n;
    const i = Object.entries(P1(r));
    this.channels = i.length ? i : [["opacity", 0.2]], this.selection.addEventListener("value", C_(() => this.update()));
  }
  init(t) {
    this.svg = t;
    const n = this.values = [], r = this.mark.index, i = this.nodes = t.querySelectorAll(`[data-index="${r}"] > *`), { channels: s } = this;
    for (let o = 0; o < i.length; ++o) {
      const a = i[o];
      n.push(s.map((c) => a.getAttribute(c[0])));
    }
    return this.update();
  }
  async update() {
    const { svg: t, nodes: n, channels: r, values: i, mark: s, selection: o } = this;
    if (!t) return;
    const a = await wK(s, o);
    for (let c = 0; c < n.length; ++c) {
      const u = n[c], l = i[c], f = u.__data__, h = a(Array.isArray(f) ? f[0] : f);
      for (let d = 0; d < r.length; ++d) {
        const [p, y] = r[d];
        u.setAttribute(p, h ? l[d] : y);
      }
    }
  }
}
async function wK(e, t) {
  var c, u;
  const n = t == null ? void 0 : t.predicate(e);
  if (!n || n.length === 0)
    return () => !0;
  const r = (c = e.filterBy) == null ? void 0 : c.predicate(e, !0), i = { __: ki(n) }, s = e.query(r);
  (s.queries || [s]).forEach((l) => {
    l.groupby().length ? l.select(i) : l.$select(i);
  });
  const o = await e.coordinator.query(s), a = (u = o.getChild) == null ? void 0 : u.call(o, "__");
  return o.numRows || o.length ? a ? (l) => a.get(l) : (l) => o[l].__ : () => !1;
}
function U1(e) {
  const t = e.on;
  let n = !0;
  function r(i) {
    n = !1, i(), n = !0;
  }
  return e.reset = (...i) => {
    r(() => e.clear(...i));
  }, e.moveSilent = (...i) => {
    r(() => e.move(...i));
  }, e.on = (...i) => {
    if (i.length > 1 && i[1]) {
      const s = i[1];
      i[1] = (...o) => n && s(...o);
    }
    return t(...i);
  }, e;
}
function _K() {
  return U1(_P());
}
function vK() {
  return U1(bP());
}
function xK() {
  return U1(wP());
}
const $_ = 1e-12;
function Jy(e, t) {
  return e === t || e && t && Math.abs(e[0] - t[0]) < $_ && Math.abs(e[1] - t[1]) < $_ || !1;
}
function la(e, t) {
  var r;
  const n = (r = e.channelField(t)) == null ? void 0 : r.field;
  return (n == null ? void 0 : n.basis) || n;
}
function Zy(e, t, n = 1) {
  return t.invert(n * Math.floor(e / n));
}
function X4() {
  const e = this, t = e.getScreenCTM;
  let n;
  e.getScreenCTM = () => e.isConnected ? n = t.call(e) : n;
}
class z1 {
  constructor(t, {
    channel: n,
    selection: r,
    field: i = void 0,
    pixelSize: s = 1,
    peers: o = !0,
    brush: a
  }) {
    this.mark = t, this.channel = n, this.pixelSize = s || 1, this.selection = r, this.peers = o, this.field = i || la(t, n), this.style = a && P1(a), this.brush = n === "y" ? xK() : vK(), this.brush.on("brush end", ({ selection: c }) => this.publish(c));
  }
  reset() {
    this.value = void 0, this.g && this.brush.reset(this.g);
  }
  activate() {
    this.selection.activate(this.clause(this.value || [0, 1]));
  }
  publish(t) {
    let n;
    t && (n = t.map((r) => Zy(r, this.scale, this.pixelSize)).sort((r, i) => r - i)), Jy(n, this.value) || (this.value = n, this.g.call(this.brush.moveSilent, t), this.selection.update(this.clause(n)));
  }
  clause(t) {
    const { mark: n, pixelSize: r, field: i, scale: s } = this;
    return Om(i, t, {
      source: this,
      clients: this.peers ? n.plot.markSet : (/* @__PURE__ */ new Set()).add(n),
      scale: s,
      pixelSize: r
    });
  }
  init(t, n) {
    var l;
    const { brush: r, channel: i, style: s } = this;
    this.scale = t.scale(i);
    const o = t.scale("x").range, a = t.scale("y").range;
    r.extent([[ve(o), ve(a)], [ce(o), ce(a)]]);
    const c = (l = this.value) == null ? void 0 : l.map(this.scale.apply).sort(zt), u = Wt(t).selectAll('g[aria-label="facet"]');
    if (n = u.size() ? u : Wt(n ?? t), this.g = n.append("g").attr("class", `interval-${i}`).each(X4).call(r).call(r.moveSilent, c), s) {
      const f = this.g.selectAll("rect.selection");
      for (const h in s)
        f.attr(h, s[h]);
    }
    t.addEventListener("pointerenter", (f) => {
      f.buttons || this.activate();
    });
  }
}
class SK {
  constructor(t, {
    selection: n,
    xfield: r,
    yfield: i,
    pixelSize: s = 1,
    peers: o = !0,
    brush: a
  }) {
    this.mark = t, this.pixelSize = s || 1, this.selection = n, this.peers = o, this.xfield = r || la(t, "x"), this.yfield = i || la(t, "y"), this.style = a && P1(a), this.brush = _K(), this.brush.on("brush end", ({ selection: c }) => this.publish(c));
  }
  reset() {
    this.value = void 0, this.g && this.brush.reset(this.g);
  }
  activate() {
    this.selection.activate(this.clause(this.value || [[0, 1], [0, 1]]));
  }
  publish(t) {
    const { value: n, pixelSize: r, xscale: i, yscale: s } = this;
    let o, a;
    if (t) {
      const [c, u] = t;
      o = [c[0], u[0]].map((l) => Zy(l, i, r)).sort(zt), a = [c[1], u[1]].map((l) => Zy(l, s, r)).sort(zt);
    }
    (!Jy(o, n == null ? void 0 : n[0]) || !Jy(a, n == null ? void 0 : n[1])) && (this.value = t ? [o, a] : void 0, this.g.call(this.brush.moveSilent, t), this.selection.update(this.clause(this.value)));
  }
  clause(t) {
    const { mark: n, pixelSize: r, xfield: i, yfield: s, xscale: o, yscale: a } = this;
    return WR([i, s], t, {
      source: this,
      clients: this.peers ? n.plot.markSet : (/* @__PURE__ */ new Set()).add(n),
      scales: [o, a],
      pixelSize: r
    });
  }
  init(t) {
    const { brush: n, style: r } = this, i = this.xscale = t.scale("x"), s = this.yscale = t.scale("y"), o = i.range, a = s.range;
    n.extent([[ve(o), ve(a)], [ce(o), ce(a)]]);
    const c = Wt(t).selectAll('g[aria-label="facet"]'), u = c.size() ? c : Wt(t);
    if (this.g = u.append("g").attr("class", "interval-xy").each(X4).call(n), r) {
      const l = this.g.selectAll("rect.selection");
      for (const f in r)
        l.attr(f, r[f]);
    }
    if (this.value) {
      const [l, f] = this.value[0].map(i.apply).sort(zt), [h, d] = this.value[1].map(s.apply).sort(zt);
      this.g.call(n.moveSilent, [[l, h], [f, d]]);
    }
    t.addEventListener("pointerenter", (l) => {
      l.buttons || this.activate();
    });
  }
}
class q1 {
  constructor(t, {
    selection: n,
    pointer: r,
    channels: i,
    fields: s,
    maxRadius: o = 40
  }) {
    this.mark = t, this.selection = n, this.clients = (/* @__PURE__ */ new Set()).add(t), this.pointer = r, this.channels = i || (r === "x" ? ["x"] : r === "y" ? ["y"] : ["x", "y"]), this.fields = s || this.channels.map((a) => la(t, [a])), this.maxRadius = o, this.valueIndex = -1;
  }
  clause(t) {
    const { clients: n, fields: r } = this;
    return Dm(r, t && [t], {
      source: this,
      clients: n
    });
  }
  init(t) {
    const n = this, { mark: r, channels: i, selection: s, maxRadius: o } = this, { data: { columns: a } } = r, c = i.map((b) => r.channelField(b).as), u = !hr(s), l = Wt(t).selectAll('g[aria-label="facet"]'), f = l.size() ? l : Wt(t), h = t.scale("x").apply, d = t.scale("y").apply, p = Array.from(a[r.channelField("x").as], h), y = Array.from(a[r.channelField("y").as], d), m = this.pointer === "y" ? 0.01 : 1, g = this.pointer === "x" ? 0.01 : 1;
    f.on("pointerenter pointerdown pointermove", function(b) {
      const [w, _] = Ln(b, this), x = MK(p, y, w, _, m, g, o);
      if (x !== this.valueIndex) {
        this.valueIndex = x;
        const v = x < 0 ? void 0 : c.map((M) => a[M][x]);
        u ? x > -1 && s.update(v.length > 1 ? v : v[0]) : s.update(n.clause(v));
      }
    }), !u && (f.on("pointerleave", () => {
      s.update(n.clause(void 0));
    }), t.addEventListener("pointerenter", (b) => {
      if (!b.buttons) {
        const w = this.channels.map(() => 0);
        s.activate(this.clause(w));
      }
    }));
  }
}
function MK(e, t, n, r, i, s, o) {
  let a = o * o, c = -1;
  for (let u = 0; u < e.length; ++u) {
    const l = i * (e[u] - n), f = s * (t[u] - r), h = l * l + f * f;
    h <= a && (a = h, c = u);
  }
  return c;
}
const I_ = (e, t) => e - t;
class AK {
  constructor(t, {
    x: n = new Df(),
    y: r = new Df(),
    xfield: i,
    yfield: s,
    zoom: o = !0,
    panx: a = !0,
    pany: c = !0
  }) {
    this.mark = t, this.xsel = n, this.ysel = r, this.xfield = i || la(t, "x"), this.yfield = s || la(t, "y"), this.zoom = f0(o, [0, 1 / 0], [1, 1]), this.panx = this.xsel && a, this.pany = this.ysel && c;
    const { plot: u } = t;
    a && this.xsel.addEventListener("value", (l) => {
      u.setAttribute("xDomain", l) && u.update();
    }), c && this.ysel.addEventListener("value", (l) => {
      u.setAttribute("yDomain", l) && u.update();
    });
  }
  publish(t) {
    if (this.panx) {
      const n = $K(t, this.xscale);
      this.xsel.update(this.clause(n, this.xfield, this.xscale));
    }
    if (this.pany) {
      const n = IK(t, this.yscale);
      this.ysel.update(this.clause(n, this.yfield, this.yscale));
    }
  }
  clause(t, n, r) {
    return Om(n, t, {
      source: this,
      clients: this.mark.plot.markSet,
      scale: r
    });
  }
  init(t) {
    if (this.svg = t, this.initialized) return;
    this.initialized = !0;
    const { panx: n, pany: r, mark: { plot: { element: i } }, xsel: s, ysel: o } = this;
    this.xscale = t.scale("x"), this.yscale = t.scale("y");
    const a = this.xscale.range.slice().sort(I_), c = this.yscale.range.slice().sort(I_), u = f0(n, [-1 / 0, 1 / 0], a), l = f0(r, [-1 / 0, 1 / 0], c), f = fV().extent([[a[0], c[0]], [a[1], c[1]]]).scaleExtent(this.zoom).translateExtent([[u[0], l[0]], [u[1], l[1]]]).on("start", () => {
      this.xscale = this.svg.scale("x"), this.yscale = this.svg.scale("y");
    }).on("end", () => i.__zoom = new lr(1, 0, 0)).on("zoom", ({ transform: h }) => this.publish(h));
    if (Wt(i).call(f), n || r) {
      let h = !1;
      i.addEventListener("pointerenter", (d) => {
        if (!h && (h = !0, !d.buttons)) {
          if (n) {
            const { xscale: p, xfield: y } = this;
            s.activate(this.clause(p.domain, y, p));
          }
          if (r) {
            const { yscale: p, yfield: y } = this;
            o.activate(this.clause(p.domain, y, p));
          }
        }
      }), i.addEventListener("pointerleave", () => h = !1);
    }
  }
}
function f0(e, t, n) {
  return e ? Array.isArray(e) ? e : t : n;
}
function $K(e, t) {
  return t.range.map(e.invertX, e).map(t.invert, t);
}
function IK(e, t) {
  return t.range.map(e.invertY, e).map(t.invert, t);
}
class G4 {
  /**
   * @param {*} mark The mark to interact with.
   * @param {*} options The interactor options.
   */
  constructor(t, {
    selection: n,
    channels: r,
    peers: i = !0
  }) {
    this.value = null, this.mark = t, this.selection = n, this.peers = i;
    const s = this.fields = [], o = this.as = [];
    r.forEach((a) => {
      var u;
      const c = a === "color" ? ["color", "fill", "stroke"] : a === "x" ? ["x", "x1", "x2"] : a === "y" ? ["y", "y1", "y2"] : [a];
      for (let l = 0; l < c.length; ++l) {
        const f = t.channelField(c[l], { exact: !0 });
        if (f) {
          s.push(((u = f.field) == null ? void 0 : u.basis) || f.field), o.push(f.as);
          return;
        }
      }
      throw new Error(`Missing channel: ${a}`);
    });
  }
  clause(t) {
    const { fields: n, mark: r } = this;
    return Dm(n, t, {
      source: this,
      clients: this.peers ? r.plot.markSet : (/* @__PURE__ */ new Set()).add(r)
    });
  }
  init(t, n, r) {
    const { mark: i, as: s, selection: o } = this, { data: { columns: a = {} } = {} } = i;
    r ?? (r = (u) => s.map((l) => {
      const f = u.__data__;
      return a[l][Array.isArray(f) ? f[0] : f];
    })), n ?? (n = `[data-index="${i.index}"]`);
    const c = new Set(t.querySelectorAll(n));
    t.addEventListener("pointerdown", (u) => {
      const l = o.single ? o.value : this.value, f = u.target;
      let h = null;
      if (TK(c, f)) {
        const d = r(f);
        (u.shiftKey || u.metaKey) && (l != null && l.length) ? (h = l.filter((p) => Ky(p, d)), h.length === l.length && h.push(d)) : (l == null ? void 0 : l.length) === 1 && !Ky(l[0], d) ? h = null : h = [d];
      }
      this.value = h, EK(l, h) && o.update(this.clause(h));
    }), t.addEventListener("pointerenter", (u) => {
      u.buttons || this.selection.activate(this.clause([this.fields.map(() => 0)]));
    });
  }
}
function TK(e, t) {
  var n;
  return e.has(t) || e.has(t.parentNode) || e.has((n = t.parentNode) == null ? void 0 : n.parentNode);
}
function EK(e, t) {
  return e == null || t == null ? e != null || t != null : e.length !== t.length || e.some((n, r) => Ky(n, t[r]));
}
function Ky(e, t) {
  const n = e.length;
  if (t.length !== n) return !0;
  for (let r = 0; r < n; ++r)
    if (e[r] !== t[r]) return !0;
  return !1;
}
const H4 = ":scope > div, :scope > span", Jl = "swatch", T_ = "ramp";
class E_ {
  constructor(t, n) {
    const { as: r, field: i, ...s } = n;
    this.channel = t, this.options = s, this.type = null, this.handler = null, this.selection = r, this.field = i, this.legend = null, this.element = document.createElement("div"), this.element.setAttribute("class", "legend"), Object.defineProperty(this.element, "value", { value: this });
  }
  setPlot(t) {
    this.plot = t;
  }
  init(t) {
    const n = NK(this, t);
    return this.element.replaceChildren(n), this.element;
  }
  update() {
    if (!this.legend) return;
    const { selection: t, handler: n } = this, { single: r, value: i } = t, s = r ? i : t.valueFor(n), o = s && s.length ? new Set(s.map((c) => c[0])) : null, a = this.legend.querySelectorAll(H4);
    for (const c of a) {
      const u = o ? o.has(c.__data__) : !0;
      c.style.opacity = u ? 1 : 0.2;
    }
  }
}
function NK(e, t) {
  const { channel: n, plot: r, selection: i } = e, s = t.scale(n), o = s.type === "ordinal" ? Jl : T_, a = {
    label: r.getAttribute(`${n}Label`) ?? null,
    ...e.options
  }, c = o === Jl ? a : a.label ? { tickSize: 2, ...a } : { tickSize: 2, marginTop: 1, height: 29, ...a }, u = t.legend(n, c);
  e.legend = u;
  let l = !!i;
  if (l && o === T_) {
    const f = c.width ?? 240, h = RK(s, f);
    h ? u.scale = function(d) {
      return d === "x" ? { range: [0, f] } : d === "y" ? { range: [-10, 0] } : d === n ? h : void 0;
    } : l = !1;
  }
  if (l) {
    const f = DK(e, o);
    o === Jl ? (f.init(u, H4, (h) => [h.__data__]), e.update()) : f.init(u, u.querySelector("g:last-of-type"));
  }
  return u;
}
function DK(e, t) {
  const { channel: n, handler: r, selection: i } = e;
  if (r) return r;
  const s = OK(e);
  return t === Jl ? (e.handler = new G4(s, {
    selection: i,
    channels: [n],
    peers: !1
  }), i.addEventListener("value", () => e.update())) : e.handler = new z1(s, {
    selection: i,
    channel: n,
    brush: { fill: "none", stroke: "currentColor" },
    peers: !1
  }), e.handler;
}
function OK(e) {
  const { channel: t, plot: n } = e, r = e.field ?? LK(n.marks, t) ?? "value";
  if (r) {
    const i = { field: r };
    return { plot: n, channelField: (s) => t === s ? i : void 0 };
  }
}
function LK(e, t) {
  const n = t === "color" ? ["fill", "stroke"] : t === "opacity" ? ["opacity", "fillOpacity", "strokeOpacity"] : null;
  if (n == null) return null;
  for (let r = e.length - 1; r > -1; --r)
    for (const i of n) {
      const s = e[r].channelField(i, { exact: !0 });
      if (s) return s.field;
    }
  return null;
}
function RK(e, t) {
  const { apply: n, invert: r, interpolate: i, ...s } = e;
  let o = e.type;
  o.startsWith("diverging-") && (o = o.slice(11));
  let a;
  switch (o) {
    case "log":
    case "pow":
    case "sqrt":
    case "symlog":
      a = o;
      break;
    case "threshold":
    case "quantize":
    case "quantile":
      return console.warn(`Legends do not yet support ${o} scales.`), null;
    default:
      a = "linear";
  }
  return Jc({ x: { ...s, type: a, range: [0, t] } });
}
function Qy(e, t, n = 0, r = Math.LN10) {
  let i;
  const s = Math.ceil(Math.log(t) / r);
  let o = Math.max(
    n,
    Math.pow(10, Math.round(Math.log(e) / r) - s)
  );
  for (; Math.ceil(e / o) > t; )
    o *= 10;
  const a = [5, 2];
  for (let c = 0, u = a.length; c < u; ++c)
    i = o / a[c], i >= n && e / i <= t && (o = i);
  return o;
}
function kK(e, t, n) {
  let { step: r, steps: i, minstep: s = 0, nice: o = !0 } = n;
  if (o !== !1) {
    const a = t - e, c = Math.LN10;
    r = r || Qy(a, i || 25, s, c);
    let u = Math.log(r);
    const l = u >= 0 ? 0 : ~~(-u / c) + 1, f = Math.pow(10, -l - 1);
    u = Math.floor(e / r + f) * r, e = e < u ? u - r : u, t = Math.ceil(t / r) * r, i = Math.round((t - e) / r);
  }
  return { min: e, max: t, steps: i };
}
const J4 = "year", N_ = "month", D_ = "day", Sl = "hour", Ml = "minute", Al = "second", FK = "millisecond", cc = 1e3, uc = cc * 60, lc = uc * 60, ep = lc * 24, BK = ep * 7, O_ = ep * 30, CK = ep * 365, Va = [
  [Al, 1, cc],
  [Al, 5, 5 * cc],
  [Al, 15, 15 * cc],
  [Al, 30, 30 * cc],
  [Ml, 1, uc],
  [Ml, 5, 5 * uc],
  [Ml, 15, 15 * uc],
  [Ml, 30, 30 * uc],
  [Sl, 1, lc],
  [Sl, 3, 3 * lc],
  [Sl, 6, 6 * lc],
  [Sl, 12, 12 * lc],
  [D_, 1, ep],
  [D_, 7, BK],
  [N_, 1, O_],
  [N_, 3, 3 * O_],
  [J4, 1, CK]
];
function PK(e, t, n) {
  const r = t - e, i = r / n;
  let s = lu((o) => o[2]).right(Va, i);
  return s === Va.length ? { interval: J4, step: Qy(r, n) } : s ? (s = Va[i / Va[s - 1][2] < Va[s][2] / i ? s - 1 : s], { interval: s[0], step: s[1] }) : { interval: FK, step: Qy(r, n, 1) };
}
const UK = /* @__PURE__ */ new Set([
  "rectY-x",
  "rectX-y",
  "rect-x",
  "rect-y",
  "ruleY-x",
  "ruleX-y"
]);
function zK(e, t) {
  return UK.has(`${e.type}-${t}`);
}
function qK(e, t = {}) {
  const n = (r, i) => zK(r, i) ? {
    [`${i}1`]: h0(r, i, e, t),
    [`${i}2`]: h0(r, i, e, { ...t, offset: 1 })
  } : {
    [i]: h0(r, i, e, t)
  };
  return n[aS] = !0, n;
}
function h0(e, t, n, r) {
  return {
    column: n,
    label: n,
    get columns() {
      return [n];
    },
    get basis() {
      return n;
    },
    get stats() {
      return { column: n, stats: ["min", "max"] };
    },
    toString() {
      const { type: i, min: s, max: o } = e.channelField(t), { interval: a, steps: c, offset: u = 0 } = r, l = a ?? (i === "date" || jK(e, t) ? "date" : "number");
      if (l === "number") {
        const { apply: f, sqlApply: h, sqlInvert: d } = Bh(e, t), p = kK(f(s), f(o), r), y = h(n), m = p.min === 0 ? y : `(${y} - ${p.min})`, g = `${(p.max - p.min) / p.steps}::DOUBLE`, b = u ? `${u} + ` : "", w = `${p.min} + ${g} * (${b}FLOOR(${m} / ${g}))`;
        return `${d(w)}`;
      } else {
        const { interval: f, step: h = 1 } = l === "date" ? PK(s, o, c || 40) : r, d = u ? ` + INTERVAL ${u * h} ${f}` : "";
        return `(${$L(n, f, h)}${d})`;
      }
    }
  };
}
function jK(e, t) {
  const n = e.plot.getAttribute(`${t}Scale`);
  return n === "utc" || n === "time";
}
const VK = (e) => e && typeof e == "object" && !Array.isArray(e);
class YK extends eu {
  /**
   * Create a new menu input.
   * @param {object} [options] Options object
   * @param {HTMLElement} [options.element] The parent DOM element in which to
   *  place the menu elements. If undefined, a new `div` element is created.
   * @param {Selection} [options.filterBy] A selection to filter the database
   *  table indicated by the *from* option.
   * @param {Param} [options.as] The output param or selection. A selection
   *  clause is added for the currently selected menu option.
   * @param {string} [options.field] The database column name to use within
   *  generated selection clause predicates. Defaults to the *column* option.
   * @param {(any | { value: any, label?: string })[]} [options.options] An
   *  array of menu options, as literal values or option objects. Option
   *  objects have a `value` property and an optional `label` property. If no
   *  label or *format* function is provided, the string-coerced value is used.
   * @param {(value: any) => string} [options.format] A format function that
   *  takes an option value as input and generates a string label. The format
   *  function is not applied when an explicit label is provided in an option
   *  object.
   * @param {*} [options.value] The initial selected menu value.
   * @param {string} [options.from] The name of a database table to use as a data
   *  source for this widget. Used in conjunction with the *column* option.
   * @param {string} [options.column] The name of a database column from which
   *  to pull menu options. The unique column values are used as menu options.
   *  Used in conjunction with the *from* option.
   * @param {string} [options.label] A text label for this input.
   */
  constructor({
    element: t,
    filterBy: n,
    from: r,
    column: i,
    label: s = i,
    format: o = (f) => f,
    // TODO
    options: a,
    value: c,
    field: u = i,
    as: l
  } = {}) {
    super(n), this.from = r, this.column = i, this.format = o, this.field = u;
    const f = this.selection = l;
    this.element = t ?? document.createElement("div"), this.element.setAttribute("class", "input"), Object.defineProperty(this.element, "value", { value: this });
    const h = document.createElement("label");
    if (h.innerText = s || i, this.element.appendChild(h), this.select = document.createElement("select"), this.element.appendChild(this.select), a && (this.data = a.map((d) => VK(d) ? d : { value: d }), this.selectedValue(c ?? ""), this.update()), f) {
      const d = !hr(f);
      c != null && (!d || f.value === void 0) && this.publish(c), this.select.addEventListener("input", () => {
        this.publish(this.selectedValue() ?? null);
      }), d && this.selection.addEventListener("value", (p) => {
        p !== this.select.value && this.selectedValue(p);
      });
    }
  }
  selectedValue(t) {
    var n;
    if (arguments.length === 0) {
      const r = this.select.selectedIndex;
      return this.data[r].value;
    } else {
      const r = (n = this.data) == null ? void 0 : n.findIndex((i) => i.value === t);
      r >= 0 ? this.select.selectedIndex = r : this.select.value = String(t);
    }
  }
  reset() {
    this.select.selectedIndex = this.from ? 0 : -1;
  }
  publish(t) {
    const { selection: n, field: r } = this;
    if (hr(n)) {
      t === "" && (t = void 0);
      const i = oS(r, t, { source: this });
      n.update(i);
    } else Di(n) && n.update(t);
  }
  query(t = []) {
    const { from: n, column: r } = this;
    return n ? xt.from(n).select({ value: r }).distinct().where(t).orderby(r) : null;
  }
  queryResult(t) {
    return this.data = [{ value: "", label: "All" }, ...t], this;
  }
  update() {
    const { data: t, format: n, select: r, selection: i } = this;
    r.replaceChildren();
    for (const { value: s, label: o } of t) {
      const a = document.createElement("option");
      a.setAttribute("value", s), a.innerText = o ?? n(s), this.select.appendChild(a);
    }
    if (i) {
      const s = hr(i) ? i.valueFor(this) : i.value;
      this.selectedValue(s ?? "");
    }
    return this;
  }
}
let WK = 0;
class XK extends eu {
  /**
   * Create a new text search input.
   * @param {object} [options] Options object
   * @param {HTMLElement} [options.element] The parent DOM element in which to
   *  place the search elements. If undefined, a new `div` element is created.
   * @param {Selection} [options.filterBy] A selection to filter the database
   *  table indicated by the *from* option.
   * @param {Param} [options.as] The output param or selection. A selection
   *  clause is added based on the current text search query.
   * @param {string} [options.field] The database column name to use within
   *  generated selection clause predicates. Defaults to the *column* option.
   * @param {'contains' | 'prefix' | 'suffix' | 'regexp'} [options.type] The
   *  type of text search query to perform. One of:
   *  - `"contains"` (default): the query string may appear anywhere in the text
   *  - `"prefix"`: the query string must appear at the start of the text
   *  - `"suffix"`: the query string must appear at the end of the text
   *  - `"regexp"`: the query string is a regular expression the text must match
   * @param {string} [options.from] The name of a database table to use as an
   *  autocomplete data source for this widget. Used in conjunction with the
   *  *column* option.
   * @param {string} [options.column] The name of a database column from which
   *  to pull valid search results. The unique column values are used as search
   *  autocomplete values. Used in conjunction with the *from* option.
   * @param {string} [options.label] A text label for this input.
   */
  constructor({
    element: t,
    filterBy: n,
    from: r,
    column: i,
    label: s,
    type: o = "contains",
    field: a = i,
    as: c
  } = {}) {
    if (super(n), this.id = "search_" + ++WK, this.type = o, this.from = r, this.column = i, this.selection = c, this.field = a, this.element = t ?? document.createElement("div"), this.element.setAttribute("class", "input"), Object.defineProperty(this.element, "value", { value: this }), s) {
      const u = document.createElement("label");
      u.setAttribute("for", this.id), u.innerText = s, this.element.appendChild(u);
    }
    this.searchbox = document.createElement("input"), this.searchbox.setAttribute("id", this.id), this.searchbox.setAttribute("type", "text"), this.searchbox.setAttribute("placeholder", "Query"), this.element.appendChild(this.searchbox), this.selection && (this.searchbox.addEventListener("input", () => {
      this.publish(this.searchbox.value || null);
    }), hr(this.selection) || this.selection.addEventListener("value", (u) => {
      u !== this.searchbox.value && (this.searchbox.value = u);
    }));
  }
  reset() {
    this.searchbox.value = "";
  }
  publish(t) {
    const { selection: n, field: r, type: i } = this;
    if (hr(n)) {
      const s = GR(r, t, { source: this, method: i });
      n.update(s);
    } else Di(n) && n.update(t);
  }
  query(t = []) {
    const { from: n, column: r } = this;
    return n ? xt.from(n).select({ list: r }).distinct().where(t) : null;
  }
  queryResult(t) {
    return this.data = t, this;
  }
  update() {
    const t = document.createElement("datalist"), n = `${this.id}_list`;
    t.setAttribute("id", n);
    for (const r of this.data) {
      const i = document.createElement("option");
      i.setAttribute("value", r.list), t.append(i);
    }
    return this.datalist && this.datalist.remove(), this.element.appendChild(this.datalist = t), this.searchbox.setAttribute("list", n), this;
  }
}
let GK = 0;
class HK extends eu {
  /**
   * Create a new slider input.
   * @param {object} [options] Options object
   * @param {HTMLElement} [options.element] The parent DOM element in which to
   *  place the slider elements. If undefined, a new `div` element is created.
   * @param {Selection} [options.filterBy] A selection to filter the database
   *  table indicated by the *from* option.
   * @param {Param} [options.as] The output param or selection. A selection
   *  clause is added based on the currently selected slider option.
   * @param {string} [options.field] The database column name to use within
   *  generated selection clause predicates. Defaults to the *column* option.
   * @param {'point' | 'interval'} [options.select] The type of selection clause
   *  predicate to generate if the **as** option is a Selection.  If `'point'`
   *  (the default), the selection predicate is an equality check for the slider
   *  value. If `'interval'`, the predicate checks an interval from the minimum
   *  to the current slider value.
   * @param {number} [options.min] The minimum slider value.
   * @param {number} [options.max] The maximum slider value.
   * @param {number} [options.step] The slider step, the amount to increment
   *  between consecutive values.
   * @param {number} [options.value] The initial slider value.
   * @param {string} [options.from] The name of a database table to use as a data
   *  source for this widget. Used in conjunction with the *column* option.
   *  The minimum and maximum values of the column determine the slider range.
   * @param {string} [options.column] The name of a database column whose values
   *  determine the slider range. Used in conjunction with the *from* option.
   *  The minimum and maximum values of the column determine the slider range.
   * @param {string} [options.label] A text label for this input.
   * @param {number} [options.width] The width of the slider in screen pixels.
   */
  constructor({
    element: t,
    filterBy: n,
    as: r,
    min: i,
    max: s,
    step: o,
    from: a,
    column: c,
    label: u = c,
    value: l = r == null ? void 0 : r.value,
    select: f = "point",
    field: h = c,
    width: d
  } = {}) {
    var p;
    if (super(n), this.id = "slider_" + ++GK, this.from = a, this.column = c || "value", this.selection = r, this.selectionType = f, this.field = h, this.min = i, this.max = s, this.step = o, this.element = t || document.createElement("div"), this.element.setAttribute("class", "input"), Object.defineProperty(this.element, "value", { value: this }), u) {
      const y = document.createElement("label");
      y.setAttribute("for", this.id), y.innerText = u, this.element.appendChild(y);
    }
    this.slider = document.createElement("input"), this.slider.setAttribute("id", this.id), this.slider.setAttribute("type", "range"), d != null && (this.slider.style.width = `${+d}px`), i != null && this.slider.setAttribute("min", `${i}`), s != null && this.slider.setAttribute("max", `${s}`), o != null && this.slider.setAttribute("step", `${o}`), this.element.appendChild(this.slider), this.curval = document.createElement("label"), this.curval.setAttribute("for", this.id), this.curval.setAttribute("class", "value"), this.element.appendChild(this.curval), l != null && (this.slider.setAttribute("value", `${l}`), ((p = this.selection) == null ? void 0 : p.value) === void 0 && this.publish(l)), this.curval.innerText = this.slider.value, this.slider.addEventListener("input", () => {
      const { value: y } = this.slider;
      this.curval.innerText = y, this.selection && this.publish(+y);
    }), this.selection && !hr(this.selection) && this.selection.addEventListener("value", (y) => {
      y !== +this.slider.value && (this.slider.value = y, this.curval.innerText = y);
    });
  }
  query(t = []) {
    const { from: n, column: r } = this;
    return !n || this.min != null && this.max != null ? null : xt.select({ min: Yo(r), max: Vo(r) }).from(n).where(t);
  }
  queryResult(t) {
    const { min: n, max: r } = Array.from(t)[0];
    return this.min == null && (this.min = n, this.slider.setAttribute("min", `${n}`)), this.max == null && (this.max = r, this.slider.setAttribute("max", `${r}`)), this.step == null && (this.step = (r - n) / 500, this.slider.setAttribute("step", `${this.step}`)), this;
  }
  publish(t) {
    const { field: n, selectionType: r, selection: i } = this;
    if (hr(i))
      if (r === "interval") {
        const s = [this.min ?? 0, t];
        i.update(Om(n, s, {
          source: this,
          bin: "ceil",
          scale: { type: "identity", domain: s },
          pixelSize: this.step
        }));
      } else
        i.update(oS(n, t, { source: this }));
    else Di(this.selection) && i.update(t);
  }
}
const Z4 = Q4((e) => {
  const t = j1(e);
  return (n) => n == null ? "" : typeof n == "number" ? t(n) : n instanceof Date ? K4(n) : `${n}`;
}), j1 = Q4((e) => (t) => t === 0 ? "0" : t.toLocaleString(e));
Z4();
j1();
function K4(e) {
  return uA(e, "Invalid Date");
}
function Q4(e) {
  let t = null, n;
  return (r = "en") => r === t ? n : n = e(t = r);
}
let JK = -1;
class ZK extends eu {
  /**
   * Create a new Table instance.
   * @param {object} options Options object
   */
  constructor({
    element: t,
    filterBy: n,
    from: r,
    columns: i = ["*"],
    align: s = {},
    format: o,
    width: a,
    maxWidth: c,
    height: u = 500,
    rowBatch: l = 100,
    as: f
  } = {}) {
    super(n), this.id = `table-${++JK}`, this.from = r, this.columns = i, this.format = o, this.align = s, this.widths = typeof a == "object" ? a : {}, this.offset = 0, this.limit = +l, this.pending = !1, this.selection = f, this.currentRow = -1, this.sortHeader = null, this.sortColumn = null, this.sortDesc = !1, this.element = t || document.createElement("div"), this.element.setAttribute("id", this.id), Object.defineProperty(this.element, "value", { value: this }), typeof a == "number" && (this.element.style.width = `${a}px`), c && (this.element.style.maxWidth = `${c}px`), this.element.style.maxHeight = `${u}px`, this.element.style.overflow = "auto";
    let h = -1;
    this.element.addEventListener("scroll", (d) => {
      const { pending: p, loaded: y } = this, { scrollHeight: m, scrollTop: g, clientHeight: b } = d.target, w = g < h;
      h = g, !(w || p || y) && m - g < 2 * b && (this.pending = !0, this.requestData(this.offset + this.limit));
    }), this.tbl = document.createElement("table"), this.element.appendChild(this.tbl), this.head = document.createElement("thead"), this.tbl.appendChild(this.head), this.body = document.createElement("tbody"), this.tbl.appendChild(this.body), this.selection && (this.body.addEventListener("pointerover", (d) => {
      const p = KK(d.target);
      p > -1 && p !== this.currentRow && (this.currentRow = p, this.selection.update(this.clause([p])));
    }), this.body.addEventListener("pointerleave", () => {
      this.currentRow = -1, this.selection.update(this.clause());
    })), this.style = document.createElement("style"), this.element.appendChild(this.style);
  }
  clause(t = []) {
    const { data: n, limit: r, schema: i } = this, s = i.map((a) => a.column), o = t.map((a) => {
      const { columns: c } = n[~~(a / r)];
      return s.map((u) => c[u][a % r]);
    });
    return Dm(s, o, { source: this });
  }
  requestData(t = 0) {
    var r;
    this.offset = t;
    const n = this.query((r = this.filterBy) == null ? void 0 : r.predicate(this));
    this.requestQuery(n), Wr().prefetch(n.clone().offset(t + this.limit));
  }
  fields() {
    return this.columns.map((t) => Xh(this.from, t));
  }
  fieldInfo(t) {
    this.schema = t;
    const n = this.head;
    n.innerHTML = "";
    const r = document.createElement("tr");
    for (const { column: i } of t) {
      const s = document.createElement("th");
      s.addEventListener("click", (o) => this.sort(o, i)), s.appendChild(document.createElement("span")), s.appendChild(document.createTextNode(i)), r.appendChild(s);
    }
    return n.appendChild(r), this.formats = QK(this.format, t), this.style.innerText = nQ(
      this.id,
      tQ(this.align, t),
      eQ(this.widths, t)
    ), this;
  }
  query(t = []) {
    const { from: n, limit: r, offset: i, schema: s, sortColumn: o, sortDesc: a } = this;
    return xt.from(n).select(s.map((c) => c.column)).where(t).orderby(o ? a ? N9(o) : o : []).limit(r).offset(i);
  }
  queryResult(t) {
    return this.pending || (this.loaded = !1, this.data = [], this.body.replaceChildren(), this.offset = 0), this.data.push($s(t)), this;
  }
  update() {
    const { body: t, formats: n, data: r, schema: i, limit: s } = this, o = i.length, a = r.length - 1, c = s * a, { numRows: u, columns: l } = r[a], f = i.map((h) => l[h.column]);
    for (let h = 0; h < u; ++h) {
      const d = document.createElement("tr");
      Object.assign(d, { __row__: c + h });
      for (let p = 0; p < o; ++p) {
        const y = f[p][h], m = document.createElement("td");
        m.innerText = y == null ? "" : n[p](y), d.appendChild(m);
      }
      t.appendChild(d);
    }
    return u < s && (this.loaded = !0), this.pending = !1, this;
  }
  sort(t, n) {
    n === this.sortColumn ? this.sortDesc = !this.sortDesc : (this.sortColumn = n, this.sortDesc = !1);
    const r = t.currentTarget, i = this.sortHeader;
    i === r && t.metaKey ? (i.firstChild.textContent = "", this.sortHeader = null, this.sortColumn = null) : (i && (i.firstChild.textContent = ""), this.sortHeader = r, r.firstChild.textContent = this.sortDesc ? "▾" : "▴"), this.requestData();
  }
}
function KK(e) {
  const t = e.parentElement;
  return Object.hasOwn(t, "__row__") ? +t.__row__ : -1;
}
function QK(e = {}, t, n) {
  return t.map(({ column: r, type: i }) => {
    if (r in e)
      return e[r];
    switch (i) {
      case "number":
        return j1(n);
      case "date":
        return K4;
      default:
        return Z4(n);
    }
  });
}
function tQ(e = {}, t) {
  return t.map(({ column: n, type: r }) => n in e ? e[n] : r === "number" ? "right" : "left");
}
function eQ(e = {}, t) {
  return t.map(({ column: n }) => e[n]);
}
function nQ(e, t, n) {
  const r = [];
  return t.forEach((i, s) => {
    const o = +n[s];
    if (i !== "left" || o) {
      const a = i !== "left" ? `text-align:${i};` : "", c = o ? `width:${o}px;max-width:${o}px;` : "";
      r.push(`#${e} tr>:nth-child(${s + 1}) {${a}${c}}`);
    }
  }), r.join(" ");
}
function t5(e, ...t) {
  var r;
  const n = ((r = e == null ? void 0 : e.context) == null ? void 0 : r.coordinator) ?? Wr();
  for (const i of t)
    n.connect(i);
}
function np(e, t, n) {
  const r = new t(n);
  return t5(e, r), r.element;
}
function rQ(e) {
  return np(this, YK, e);
}
function iQ(e) {
  return np(this, XK, e);
}
function sQ(e) {
  return np(this, HK, e);
}
function oQ(e) {
  return np(this, ZK, e);
}
function e5({ direction: e = "vertical", wrap: t = !1 }, n) {
  const r = document.createElement("div");
  return r.style.display = "flex", r.style.flexDirection = e === "vertical" ? "column" : "row", r.style.flexWrap = t ? t === !0 ? "wrap" : t : "nowrap", r.style.justifyContent = "flex-start", r.style.alignItems = "flex-start", n.forEach((i) => r.appendChild(i)), Object.assign(r, { value: { element: r } }), r;
}
function aQ(...e) {
  return e5({ direction: "vertical" }, e.flat());
}
function cQ(...e) {
  return e5({ direction: "horizontal" }, e.flat());
}
function n5({ dim: e = "width", size: t = 10 }) {
  const n = document.createElement("span");
  return n.style.display = "inline-block", n.style[e] = Number.isNaN(+t) ? t : `${t}px`, Object.assign(n, { value: { element: n } });
}
function uQ(e) {
  return n5({ dim: "height", size: e });
}
function lQ(e) {
  return n5({ dim: "width", size: e });
}
class r5 extends Map {
  request(t, n) {
    if (this.has(t))
      n(this.get(t));
    else {
      const r = this.waiting || (this.waiting = /* @__PURE__ */ new Map()), i = r.get(t) || [];
      r.set(t, i.concat(n));
    }
  }
  set(t, n) {
    this.has(t) && console.warn(`Overwriting named plot "${t}".`);
    const { waiting: r } = this;
    return r != null && r.has(t) && (r.get(t).forEach((i) => i(n)), r.delete(t)), super.set(t, n);
  }
  clear() {
    var t;
    return (t = this.waiting) == null || t.clear(), super.clear();
  }
}
const V1 = new r5();
function fQ(e, t, n) {
  var i;
  (((i = e == null ? void 0 : e.context) == null ? void 0 : i.namedPlots) ?? V1).request(t, n);
}
function hQ(e, t, n) {
  var i;
  (((i = e == null ? void 0 : e.context) == null ? void 0 : i.namedPlots) ?? V1).set(t, n);
}
function i5(e) {
  return (t) => hQ(this, e, t);
}
function s5(e, t, n) {
  Di(n) ? (n.addEventListener("value", (r) => {
    e.setAttribute(t, r), e.update();
  }), n.value !== void 0 && e.setAttribute(t, n.value)) : e.setAttribute(t, n);
}
function dQ(e, t) {
  return (n) => {
    s5(n, e, t);
  };
}
function Y1(e) {
  return (t) => {
    for (const [n, r] of Object.entries(e))
      s5(t, n, r);
  };
}
function o5(e) {
  const { top: t, bottom: n, left: r, right: i } = e, s = {};
  return t !== void 0 && (s.marginTop = t), n !== void 0 && (s.marginBottom = n), r !== void 0 && (s.marginLeft = r), i !== void 0 && (s.marginRight = i), Y1(s);
}
function a5(e) {
  return Y1({
    marginTop: e,
    marginBottom: e,
    marginLeft: e,
    marginRight: e
  });
}
function c5(e) {
  return Y1({ xDomain: e, yDomain: e });
}
const O = (e) => (t) => dQ(e, t), u5 = O("style"), l5 = O("width"), f5 = O("height"), h5 = O("marginLeft"), d5 = O("marginRight"), p5 = O("marginTop"), y5 = O("marginBottom"), m5 = O("align"), g5 = O("aspectRatio"), b5 = O("axis"), w5 = O("inset"), _5 = O("grid"), v5 = O("label"), x5 = O("padding"), S5 = O("xScale"), M5 = O("xDomain"), A5 = O("xRange"), $5 = O("xNice"), I5 = O("xInset"), T5 = O("xInsetLeft"), E5 = O("xInsetRight"), N5 = O("xClamp"), D5 = O("xRound"), O5 = O("xAlign"), L5 = O("xPadding"), R5 = O("xPaddingInner"), k5 = O("xPaddingOuter"), F5 = O("xAxis"), B5 = O("xTicks"), C5 = O("xTickSize"), P5 = O("xTickSpacing"), U5 = O("xTickPadding"), z5 = O("xTickFormat"), q5 = O("xTickRotate"), j5 = O("xGrid"), V5 = O("xLine"), Y5 = O("xLabel"), W5 = O("xLabelAnchor"), X5 = O("xLabelArrow"), G5 = O("xLabelOffset"), H5 = O("xFontVariant"), J5 = O("xAriaLabel"), Z5 = O("xAriaDescription"), K5 = O("xPercent"), Q5 = O("xReverse"), tI = O("xZero"), eI = O("xBase"), nI = O("xExponent"), rI = O("xConstant"), iI = O("yScale"), sI = O("yDomain"), oI = O("yRange"), aI = O("yNice"), cI = O("yInset"), uI = O("yInsetTop"), lI = O("yInsetBottom"), fI = O("yClamp"), hI = O("yRound"), dI = O("yAlign"), pI = O("yPadding"), yI = O("yPaddingInner"), mI = O("yPaddingOuter"), gI = O("yAxis"), bI = O("yTicks"), wI = O("yTickSize"), _I = O("yTickSpacing"), vI = O("yTickPadding"), xI = O("yTickFormat"), SI = O("yTickRotate"), MI = O("yGrid"), AI = O("yLine"), $I = O("yLabel"), II = O("yLabelAnchor"), TI = O("yLabelArrow"), EI = O("yLabelOffset"), NI = O("yFontVariant"), DI = O("yAriaLabel"), OI = O("yAriaDescription"), LI = O("yPercent"), RI = O("yReverse"), kI = O("yZero"), FI = O("yBase"), BI = O("yExponent"), CI = O("yConstant"), PI = O("facetMargin"), UI = O("facetMarginTop"), zI = O("facetMarginBottom"), qI = O("facetMarginLeft"), jI = O("facetMarginRight"), VI = O("facetGrid"), YI = O("facetLabel"), WI = O("fxDomain"), XI = O("fxRange"), GI = O("fxInset"), HI = O("fxInsetLeft"), JI = O("fxInsetRight"), ZI = O("fxRound"), KI = O("fxAlign"), QI = O("fxPadding"), tT = O("fxPaddingInner"), eT = O("fxPaddingOuter"), nT = O("fxAxis"), rT = O("fxTicks"), iT = O("fxTickSize"), sT = O("fxTickSpacing"), oT = O("fxTickPadding"), aT = O("fxTickFormat"), cT = O("fxTickRotate"), uT = O("fxGrid"), lT = O("fxLine"), fT = O("fxLabel"), hT = O("fxLabelAnchor"), dT = O("fxLabelOffset"), pT = O("fxFontVariant"), yT = O("fxAriaLabel"), mT = O("fxAriaDescription"), gT = O("fxReverse"), bT = O("fyDomain"), wT = O("fyRange"), _T = O("fyInset"), vT = O("fyInsetTop"), xT = O("fyInsetBottom"), ST = O("fyRound"), MT = O("fyAlign"), AT = O("fyPadding"), $T = O("fyPaddingInner"), IT = O("fyPaddingOuter"), TT = O("fyAxis"), ET = O("fyTicks"), NT = O("fyTickSize"), DT = O("fyTickSpacing"), OT = O("fyTickPadding"), LT = O("fyTickFormat"), RT = O("fyTickRotate"), kT = O("fyGrid"), FT = O("fyLine"), BT = O("fyLabel"), CT = O("fyLabelAnchor"), PT = O("fyLabelOffset"), UT = O("fyFontVariant"), zT = O("fyAriaLabel"), qT = O("fyAriaDescription"), jT = O("fyReverse"), VT = O("colorScale"), YT = O("colorDomain"), WT = O("colorRange"), XT = O("colorClamp"), GT = O("colorN"), HT = O("colorNice"), JT = O("colorScheme"), ZT = O("colorInterpolate"), KT = O("colorPivot"), QT = O("colorSymmetric"), tE = O("colorLabel"), eE = O("colorPercent"), nE = O("colorReverse"), rE = O("colorZero"), iE = O("colorTickFormat"), sE = O("colorBase"), oE = O("colorExponent"), aE = O("colorConstant"), cE = O("opacityScale"), uE = O("opacityDomain"), lE = O("opacityRange"), fE = O("opacityClamp"), hE = O("opacityNice"), dE = O("opacityLabel"), pE = O("opacityPercent"), yE = O("opacityReverse"), mE = O("opacityZero"), gE = O("opacityTickFormat"), bE = O("opacityBase"), wE = O("opacityExponent"), _E = O("opacityConstant"), vE = O("symbolScale"), xE = O("symbolDomain"), SE = O("symbolRange"), ME = O("rScale"), AE = O("rDomain"), $E = O("rRange"), IE = O("rClamp"), TE = O("rNice"), EE = O("rLabel"), NE = O("rPercent"), DE = O("rZero"), OE = O("rBase"), LE = O("rExponent"), RE = O("rConstant"), kE = O("lengthScale"), FE = O("lengthDomain"), BE = O("lengthRange"), CE = O("lengthClamp"), PE = O("lengthNice"), UE = O("lengthPercent"), zE = O("lengthZero"), qE = O("lengthBase"), jE = O("lengthExponent"), VE = O("lengthConstant"), YE = O("projectionType"), WE = O("projectionParallels"), XE = O("projectionPrecision"), GE = O("projectionRotate"), HE = O("projectionDomain"), JE = O("projectionInset"), ZE = O("projectionInsetLeft"), KE = O("projectionInsetRight"), QE = O("projectionInsetTop"), tN = O("projectionInsetBottom"), eN = O("projectionClip"), pQ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  align: m5,
  aspectRatio: g5,
  axis: b5,
  colorBase: sE,
  colorClamp: XT,
  colorConstant: aE,
  colorDomain: YT,
  colorExponent: oE,
  colorInterpolate: ZT,
  colorLabel: tE,
  colorN: GT,
  colorNice: HT,
  colorPercent: eE,
  colorPivot: KT,
  colorRange: WT,
  colorReverse: nE,
  colorScale: VT,
  colorScheme: JT,
  colorSymmetric: QT,
  colorTickFormat: iE,
  colorZero: rE,
  facetGrid: VI,
  facetLabel: YI,
  facetMargin: PI,
  facetMarginBottom: zI,
  facetMarginLeft: qI,
  facetMarginRight: jI,
  facetMarginTop: UI,
  fxAlign: KI,
  fxAriaDescription: mT,
  fxAriaLabel: yT,
  fxAxis: nT,
  fxDomain: WI,
  fxFontVariant: pT,
  fxGrid: uT,
  fxInset: GI,
  fxInsetLeft: HI,
  fxInsetRight: JI,
  fxLabel: fT,
  fxLabelAnchor: hT,
  fxLabelOffset: dT,
  fxLine: lT,
  fxPadding: QI,
  fxPaddingInner: tT,
  fxPaddingOuter: eT,
  fxRange: XI,
  fxReverse: gT,
  fxRound: ZI,
  fxTickFormat: aT,
  fxTickPadding: oT,
  fxTickRotate: cT,
  fxTickSize: iT,
  fxTickSpacing: sT,
  fxTicks: rT,
  fyAlign: MT,
  fyAriaDescription: qT,
  fyAriaLabel: zT,
  fyAxis: TT,
  fyDomain: bT,
  fyFontVariant: UT,
  fyGrid: kT,
  fyInset: _T,
  fyInsetBottom: xT,
  fyInsetTop: vT,
  fyLabel: BT,
  fyLabelAnchor: CT,
  fyLabelOffset: PT,
  fyLine: FT,
  fyPadding: AT,
  fyPaddingInner: $T,
  fyPaddingOuter: IT,
  fyRange: wT,
  fyReverse: jT,
  fyRound: ST,
  fyTickFormat: LT,
  fyTickPadding: OT,
  fyTickRotate: RT,
  fyTickSize: NT,
  fyTickSpacing: DT,
  fyTicks: ET,
  grid: _5,
  height: f5,
  inset: w5,
  label: v5,
  lengthBase: qE,
  lengthClamp: CE,
  lengthConstant: VE,
  lengthDomain: FE,
  lengthExponent: jE,
  lengthNice: PE,
  lengthPercent: UE,
  lengthRange: BE,
  lengthScale: kE,
  lengthZero: zE,
  margin: a5,
  marginBottom: y5,
  marginLeft: h5,
  marginRight: d5,
  marginTop: p5,
  margins: o5,
  name: i5,
  opacityBase: bE,
  opacityClamp: fE,
  opacityConstant: _E,
  opacityDomain: uE,
  opacityExponent: wE,
  opacityLabel: dE,
  opacityNice: hE,
  opacityPercent: pE,
  opacityRange: lE,
  opacityReverse: yE,
  opacityScale: cE,
  opacityTickFormat: gE,
  opacityZero: mE,
  padding: x5,
  projectionClip: eN,
  projectionDomain: HE,
  projectionInset: JE,
  projectionInsetBottom: tN,
  projectionInsetLeft: ZE,
  projectionInsetRight: KE,
  projectionInsetTop: QE,
  projectionParallels: WE,
  projectionPrecision: XE,
  projectionRotate: GE,
  projectionType: YE,
  rBase: OE,
  rClamp: IE,
  rConstant: RE,
  rDomain: AE,
  rExponent: LE,
  rLabel: EE,
  rNice: TE,
  rPercent: NE,
  rRange: $E,
  rScale: ME,
  rZero: DE,
  style: u5,
  symbolDomain: xE,
  symbolRange: SE,
  symbolScale: vE,
  width: l5,
  xAlign: O5,
  xAriaDescription: Z5,
  xAriaLabel: J5,
  xAxis: F5,
  xBase: eI,
  xClamp: N5,
  xConstant: rI,
  xDomain: M5,
  xExponent: nI,
  xFontVariant: H5,
  xGrid: j5,
  xInset: I5,
  xInsetLeft: T5,
  xInsetRight: E5,
  xLabel: Y5,
  xLabelAnchor: W5,
  xLabelArrow: X5,
  xLabelOffset: G5,
  xLine: V5,
  xNice: $5,
  xPadding: L5,
  xPaddingInner: R5,
  xPaddingOuter: k5,
  xPercent: K5,
  xRange: A5,
  xReverse: Q5,
  xRound: D5,
  xScale: S5,
  xTickFormat: z5,
  xTickPadding: U5,
  xTickRotate: q5,
  xTickSize: C5,
  xTickSpacing: P5,
  xTicks: B5,
  xZero: tI,
  xyDomain: c5,
  yAlign: dI,
  yAriaDescription: OI,
  yAriaLabel: DI,
  yAxis: gI,
  yBase: FI,
  yClamp: fI,
  yConstant: CI,
  yDomain: sI,
  yExponent: BI,
  yFontVariant: NI,
  yGrid: MI,
  yInset: cI,
  yInsetBottom: lI,
  yInsetTop: uI,
  yLabel: $I,
  yLabelAnchor: II,
  yLabelArrow: TI,
  yLabelOffset: EI,
  yLine: AI,
  yNice: aI,
  yPadding: pI,
  yPaddingInner: yI,
  yPaddingOuter: mI,
  yPercent: LI,
  yRange: oI,
  yReverse: RI,
  yRound: hI,
  yScale: iI,
  yTickFormat: xI,
  yTickPadding: vI,
  yTickRotate: SI,
  yTickSize: wI,
  yTickSpacing: _I,
  yTicks: bI,
  yZero: kI
}, Symbol.toStringTag, { value: "Module" }));
function yQ(e, t) {
  return { table: e, options: t };
}
const mQ = /* @__PURE__ */ new Set([
  "frame",
  "axisX",
  "axisY",
  "axisFx",
  "axisFy",
  "gridX",
  "gridY",
  "gridFx",
  "gridFy",
  "hexgrid",
  "graticule",
  "sphere"
]);
function dt(e, t, n = {}) {
  arguments.length === 2 && !Array.isArray(t) && (n = t, t = mQ.has(e) ? null : [{}]);
  const r = e.startsWith("area") || e.startsWith("line") ? MZ : es;
  return rp(r, e, t, n);
}
function rp(e, t, n, r) {
  return (i) => {
    i.addMark(new e(t, n, r));
  };
}
function Ir(e, t, n) {
  return (r) => {
    r.addMark(new e(t, n));
  };
}
const nN = (...e) => dt("area", ...e), rN = (...e) => dt("areaX", ...e), iN = (...e) => dt("areaY", ...e), sN = (...e) => dt("line", ...e), oN = (...e) => dt("lineX", ...e), aN = (...e) => dt("lineY", ...e), cN = (...e) => dt("barX", ...e), uN = (...e) => dt("barY", ...e), lN = (...e) => dt("cell", ...e), fN = (...e) => dt("cellX", ...e), hN = (...e) => dt("cellY", ...e), dN = (...e) => dt("rect", ...e), pN = (...e) => dt("rectX", ...e), yN = (...e) => dt("rectY", ...e), mN = (...e) => dt("dot", ...e), gN = (...e) => dt("dotX", ...e), bN = (...e) => dt("dotY", ...e), wN = (...e) => dt("circle", ...e), _N = (...e) => dt("hexagon", ...e), vN = (...e) => dt("text", ...e), xN = (...e) => dt("textX", ...e), SN = (...e) => dt("textY", ...e), MN = (...e) => dt("ruleX", ...e), AN = (...e) => dt("ruleY", ...e), $N = (...e) => dt("tickX", ...e), IN = (...e) => dt("tickY", ...e), TN = (...e) => dt("vector", ...e), EN = (...e) => dt("vectoX", ...e), NN = (...e) => dt("vectorY", ...e), DN = (...e) => dt("spike", ...e), ON = (...e) => dt("image", ...e), LN = (...e) => rp(Y4, "areaX", ...e), RN = (...e) => rp(Y4, "areaY", ...e), kN = (...e) => Ir(KZ, ...e), FN = (...e) => Ir(GZ, ...e), BN = (...e) => Ir(FZ, ...e), CN = (...e) => Ir(jZ, ...e), PN = (...e) => Ir(C1, ...e), UN = (...e) => Ir(aK, ...e), zN = (...e) => Ir(oK, ...e), qN = (...e) => dt("hexgrid", ...e), jN = (...e) => Ir(dK, ...e), VN = (...e) => rp(W4, "ruleY", ...e), YN = (...e) => Ir(W4, "ruleX", ...e), WN = (...e) => dt("voronoi", ...e), XN = (...e) => dt("voronoiMesh", ...e), GN = (...e) => dt("delaunayLink", ...e), HN = (...e) => dt("delaunayMesh", ...e), JN = (...e) => dt("hull", ...e), ZN = (...e) => dt("arrow", ...e), KN = (...e) => dt("link", ...e), QN = (...e) => dt("frame", ...e), t7 = (...e) => dt("axisX", ...e), e7 = (...e) => dt("axisY", ...e), n7 = (...e) => dt("axisFx", ...e), r7 = (...e) => dt("axisFy", ...e), i7 = (...e) => dt("gridX", ...e), s7 = (...e) => dt("gridY", ...e), o7 = (...e) => dt("gridFx", ...e), a7 = (...e) => dt("gridFy", ...e), c7 = (...e) => Ir(sK, ...e), u7 = (...e) => dt("sphere", ...e), l7 = (...e) => dt("graticule", ...e), gQ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  area: nN,
  areaX: rN,
  areaY: iN,
  arrow: ZN,
  axisFx: n7,
  axisFy: r7,
  axisX: t7,
  axisY: e7,
  barX: cN,
  barY: uN,
  cell: lN,
  cellX: fN,
  cellY: hN,
  circle: wN,
  contour: BN,
  delaunayLink: GN,
  delaunayMesh: HN,
  denseLine: FN,
  density: kN,
  densityX: LN,
  densityY: RN,
  dot: mN,
  dotX: gN,
  dotY: bN,
  errorbarX: VN,
  errorbarY: YN,
  frame: QN,
  geo: c7,
  graticule: l7,
  gridFx: o7,
  gridFy: a7,
  gridX: i7,
  gridY: s7,
  heatmap: CN,
  hexagon: _N,
  hexbin: zN,
  hexgrid: qN,
  hull: JN,
  image: ON,
  line: sN,
  lineX: oN,
  lineY: aN,
  link: KN,
  raster: PN,
  rasterTile: UN,
  rect: dN,
  rectX: pN,
  rectY: yN,
  regressionY: jN,
  ruleX: MN,
  ruleY: AN,
  sphere: u7,
  spike: DN,
  text: vN,
  textX: xN,
  textY: SN,
  tickX: $N,
  tickY: IN,
  vector: TN,
  vectorX: EN,
  vectorY: NN,
  voronoi: WN,
  voronoiMesh: XN
}, Symbol.toStringTag, { value: "Module" }));
function hi(e, t) {
  return (n) => {
    const r = n.marks[n.marks.length - 1];
    n.addInteractor(new e(r, t));
  };
}
function f7({ by: e, ...t }) {
  return hi(bK, { selection: e, channels: t });
}
function Ta({ as: e, ...t }) {
  return hi(G4, { ...t, selection: e });
}
function h7(e) {
  return Ta({ ...e, channels: ["x"] });
}
function d7(e) {
  return Ta({ ...e, channels: ["y"] });
}
function p7(e) {
  return Ta({ ...e, channels: ["z"] });
}
function y7(e) {
  return Ta({ ...e, channels: ["color"] });
}
function m7({ as: e, ...t }) {
  return hi(q1, { ...t, selection: e, pointer: "xy" });
}
function g7({ as: e, ...t }) {
  return hi(q1, { ...t, selection: e, pointer: "x" });
}
function b7({ as: e, ...t }) {
  return hi(q1, { ...t, selection: e, pointer: "y" });
}
function w7({ as: e, ...t }) {
  return hi(z1, { ...t, selection: e, channel: "x" });
}
function _7({ as: e, ...t }) {
  return hi(z1, { ...t, selection: e, channel: "y" });
}
function v7({ as: e, ...t }) {
  return hi(SK, { ...t, selection: e });
}
function Ea(e) {
  return hi(AK, e);
}
function x7(e = {}) {
  return Ea({ ...e, zoom: !1 });
}
function S7(e = {}) {
  return Ea({ ...e, zoom: !1, pany: !1 });
}
function M7(e = {}) {
  return Ea({ ...e, zoom: !1, panx: !1 });
}
function A7(e = {}) {
  return Ea(e);
}
function $7(e = {}) {
  return Ea({ ...e, pany: !1 });
}
function I7(e = {}) {
  return Ea({ ...e, panx: !1 });
}
const bQ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  highlight: f7,
  intervalX: w7,
  intervalXY: v7,
  intervalY: _7,
  nearest: m7,
  nearestX: g7,
  nearestY: b7,
  pan: x7,
  panX: S7,
  panY: M7,
  panZoom: A7,
  panZoomX: $7,
  panZoomY: I7,
  toggle: Ta,
  toggleColor: y7,
  toggleX: h7,
  toggleY: d7,
  toggleZ: p7
}, Symbol.toStringTag, { value: "Module" }));
function W1(e, t = {}) {
  if (t.for) {
    const { for: n, ...r } = t, i = new E_(e, r), s = typeof n, o = (a) => a.addLegend(i, !1);
    return s === "string" ? fQ(this, n, o) : n.value && o(n.value), i.element;
  } else
    return (n) => n.addLegend(new E_(e, t));
}
function T7(e) {
  return W1.call(this, "color", e);
}
function E7(e) {
  return W1.call(this, "opacity", e);
}
function N7(e) {
  return W1.call(this, "symbol", e);
}
const wQ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  colorLegend: T7,
  opacityLegend: E7,
  symbolLegend: N7
}, Symbol.toStringTag, { value: "Module" }));
function _Q(...e) {
  const t = new yZ();
  return e.flat().forEach((n) => n(t)), t5(this, ...t.marks), t.update(), t.element;
}
const vQ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  Fixed: uu,
  Param: ms,
  Query: xt,
  Selection: Df,
  agg: Tt,
  align: m5,
  and: ki,
  area: nN,
  areaX: rN,
  areaY: iN,
  argmax: T0,
  argmin: I0,
  arrayAgg: SL,
  arrow: ZN,
  aspectRatio: g5,
  avg: Xx,
  axis: b5,
  axisFx: n7,
  axisFy: r7,
  axisX: t7,
  axisY: e7,
  barX: cN,
  barY: uN,
  bin: qK,
  cast: Tm,
  castDouble: E0,
  castInteger: ML,
  cell: lN,
  cellX: fN,
  cellY: hN,
  centroid: Em,
  centroidX: OL,
  centroidY: LL,
  circle: wN,
  colorBase: sE,
  colorClamp: XT,
  colorConstant: aE,
  colorDomain: YT,
  colorExponent: oE,
  colorInterpolate: ZT,
  colorLabel: tE,
  colorLegend: T7,
  colorN: GT,
  colorNice: HT,
  colorPercent: eE,
  colorPivot: KT,
  colorRange: WT,
  colorReverse: nE,
  colorScale: VT,
  colorScheme: JT,
  colorSymmetric: QT,
  colorTickFormat: iE,
  colorZero: rE,
  column: Xh,
  contour: BN,
  coordinator: Wr,
  corr: fL,
  count: Ni,
  covarPop: dL,
  covariance: hL,
  create: cu,
  cume_dist: Y9,
  dateDay: EL,
  dateMonth: IL,
  dateMonthDay: TL,
  delaunayLink: GN,
  delaunayMesh: HN,
  denseLine: FN,
  dense_rank: j9,
  density: kN,
  densityX: LN,
  densityY: RN,
  dot: mN,
  dotX: gN,
  dotY: bN,
  entropy: cL,
  eq: L9,
  errorbarX: VN,
  errorbarY: YN,
  facetGrid: VI,
  facetLabel: YI,
  facetMargin: PI,
  facetMarginBottom: zI,
  facetMarginLeft: qI,
  facetMarginRight: jI,
  facetMarginTop: UI,
  first: _L,
  first_value: H9,
  frame: QN,
  from: yQ,
  fxAlign: KI,
  fxAriaDescription: mT,
  fxAriaLabel: yT,
  fxAxis: nT,
  fxDomain: WI,
  fxFontVariant: pT,
  fxGrid: uT,
  fxInset: GI,
  fxInsetLeft: HI,
  fxInsetRight: JI,
  fxLabel: fT,
  fxLabelAnchor: hT,
  fxLabelOffset: dT,
  fxLine: lT,
  fxPadding: QI,
  fxPaddingInner: tT,
  fxPaddingOuter: eT,
  fxRange: XI,
  fxReverse: gT,
  fxRound: ZI,
  fxTickFormat: aT,
  fxTickPadding: oT,
  fxTickRotate: cT,
  fxTickSize: iT,
  fxTickSpacing: sT,
  fxTicks: rT,
  fyAlign: MT,
  fyAriaDescription: qT,
  fyAriaLabel: zT,
  fyAxis: TT,
  fyDomain: bT,
  fyFontVariant: UT,
  fyGrid: kT,
  fyInset: _T,
  fyInsetBottom: xT,
  fyInsetTop: vT,
  fyLabel: BT,
  fyLabelAnchor: CT,
  fyLabelOffset: PT,
  fyLine: FT,
  fyPadding: AT,
  fyPaddingInner: $T,
  fyPaddingOuter: IT,
  fyRange: wT,
  fyReverse: jT,
  fyRound: ST,
  fyTickFormat: LT,
  fyTickPadding: OT,
  fyTickRotate: RT,
  fyTickSize: NT,
  fyTickSpacing: DT,
  fyTicks: ET,
  geo: c7,
  geojson: Hx,
  graticule: l7,
  grid: _5,
  gridFx: o7,
  gridFy: a7,
  gridX: i7,
  gridY: s7,
  gt: Yx,
  gte: R9,
  hconcat: cQ,
  heatmap: CN,
  height: f5,
  hexagon: _N,
  hexbin: zN,
  hexgrid: qN,
  highlight: f7,
  hspace: lQ,
  hull: JN,
  image: ON,
  inset: w5,
  intervalX: w7,
  intervalXY: v7,
  intervalY: _7,
  isBetween: In,
  isDistinct: k9,
  isNotBetween: F9,
  isNotDistinct: Im,
  isNotNull: $c,
  isNull: Am,
  kurtosis: aL,
  label: v5,
  lag: X9,
  last: vL,
  last_value: J9,
  lead: G9,
  lengthBase: qE,
  lengthClamp: CE,
  lengthConstant: VE,
  lengthDomain: FE,
  lengthExponent: jE,
  lengthNice: PE,
  lengthPercent: UE,
  lengthRange: BE,
  lengthScale: kE,
  lengthZero: zE,
  line: sN,
  lineX: oN,
  lineY: aN,
  link: KN,
  literal: Hh,
  loadCSV: qL,
  loadExtension: Zx,
  loadJSON: jL,
  loadObjects: WL,
  loadParquet: VL,
  loadSpatial: YL,
  lt: Ic,
  lte: Tc,
  mad: tL,
  margin: a5,
  marginBottom: y5,
  marginLeft: h5,
  marginRight: d5,
  marginTop: p5,
  margins: o5,
  max: Vo,
  median: nL,
  menu: rQ,
  min: Yo,
  mode: iL,
  name: i5,
  nearest: m7,
  nearestX: g7,
  nearestY: b7,
  neq: $m,
  not: O9,
  nth_value: Z9,
  ntile: W9,
  opacityBase: bE,
  opacityClamp: fE,
  opacityConstant: _E,
  opacityDomain: uE,
  opacityExponent: wE,
  opacityLabel: dE,
  opacityLegend: E7,
  opacityNice: hE,
  opacityPercent: pE,
  opacityRange: lE,
  opacityReverse: yE,
  opacityScale: cE,
  opacityTickFormat: gE,
  opacityZero: mE,
  or: Mm,
  padding: x5,
  pan: x7,
  panX: S7,
  panY: M7,
  panZoom: A7,
  panZoomX: $7,
  panZoomY: I7,
  percent_rank: V9,
  plot: _Q,
  product: eL,
  projectionClip: eN,
  projectionDomain: HE,
  projectionInset: JE,
  projectionInsetBottom: tN,
  projectionInsetLeft: ZE,
  projectionInsetRight: KE,
  projectionInsetTop: QE,
  projectionParallels: WE,
  projectionPrecision: XE,
  projectionRotate: GE,
  projectionType: YE,
  quantile: rL,
  rBase: OE,
  rClamp: IE,
  rConstant: RE,
  rDomain: AE,
  rExponent: LE,
  rLabel: EE,
  rNice: TE,
  rPercent: NE,
  rRange: $E,
  rScale: ME,
  rZero: DE,
  rank: q9,
  raster: PN,
  rasterTile: UN,
  rect: dN,
  rectX: pN,
  rectY: yN,
  regressionY: jN,
  row_number: z9,
  ruleX: MN,
  ruleY: AN,
  search: iQ,
  skewness: oL,
  slider: sQ,
  sphere: u7,
  spike: DN,
  sql: j,
  stddev: Gx,
  stddevPop: lL,
  stringAgg: xL,
  style: u5,
  sum: Bs,
  symbolDomain: xE,
  symbolLegend: N7,
  symbolRange: SE,
  symbolScale: vE,
  table: oQ,
  text: vN,
  textX: xN,
  textY: SN,
  tickX: $N,
  tickY: IN,
  toggle: Ta,
  toggleColor: y7,
  toggleX: h7,
  toggleY: d7,
  toggleZ: p7,
  varPop: uL,
  variance: sL,
  vconcat: aQ,
  vector: TN,
  vectorX: EN,
  vectorY: NN,
  voronoi: WN,
  voronoiMesh: XN,
  vspace: uQ,
  width: l5,
  xAlign: O5,
  xAriaDescription: Z5,
  xAriaLabel: J5,
  xAxis: F5,
  xBase: eI,
  xClamp: N5,
  xConstant: rI,
  xDomain: M5,
  xExponent: nI,
  xFontVariant: H5,
  xGrid: j5,
  xInset: I5,
  xInsetLeft: T5,
  xInsetRight: E5,
  xLabel: Y5,
  xLabelAnchor: W5,
  xLabelArrow: X5,
  xLabelOffset: G5,
  xLine: V5,
  xNice: $5,
  xPadding: L5,
  xPaddingInner: R5,
  xPaddingOuter: k5,
  xPercent: K5,
  xRange: A5,
  xReverse: Q5,
  xRound: D5,
  xScale: S5,
  xTickFormat: z5,
  xTickPadding: U5,
  xTickRotate: q5,
  xTickSize: C5,
  xTickSpacing: P5,
  xTicks: B5,
  xZero: tI,
  xyDomain: c5,
  yAlign: dI,
  yAriaDescription: OI,
  yAriaLabel: DI,
  yAxis: gI,
  yBase: FI,
  yClamp: fI,
  yConstant: CI,
  yDomain: sI,
  yExponent: BI,
  yFontVariant: NI,
  yGrid: MI,
  yInset: cI,
  yInsetBottom: lI,
  yInsetTop: uI,
  yLabel: $I,
  yLabelAnchor: II,
  yLabelArrow: TI,
  yLabelOffset: EI,
  yLine: AI,
  yNice: aI,
  yPadding: pI,
  yPaddingInner: yI,
  yPaddingOuter: mI,
  yPercent: LI,
  yRange: oI,
  yReverse: RI,
  yRound: hI,
  yScale: iI,
  yTickFormat: xI,
  yTickPadding: vI,
  yTickRotate: SI,
  yTickSize: wI,
  yTickSpacing: _I,
  yTicks: bI,
  yZero: kI
}, Symbol.toStringTag, { value: "Module" }));
function xQ({
  coordinator: e = Wr(),
  namedPlots: t = new r5(),
  extensions: n = null,
  ...r
} = {}) {
  return {
    ...vQ,
    ...n,
    context: {
      coordinator: e,
      namedPlots: t,
      ...r
    }
  };
}
const SQ = "spec", D7 = "literal", MQ = "options", AQ = "selection", $Q = "paramref", IQ = "param", O7 = "select", tm = "value", TQ = "crossfilter", L7 = "intersect", EQ = "union", NQ = "single", DQ = "data", OQ = "expression", Fo = "sql", Ss = "agg", X1 = "input", Ch = "hconcat", Ph = "vconcat", Uh = "hspace", zh = "vspace", R7 = "mark", L_ = "from", qh = "plot", G1 = "legend", LQ = "attribute", k7 = "transform", RQ = "interactor", Zl = "Fixed";
class ue {
  constructor(t, n = null) {
    this.type = t, this.children = n;
  }
  /**
   * Instantiate this AST node to use in a live web application.
   * @param {import('../ast-to-dom.js').InstantiateContext} ctx The instantiation context.
   * @returns {*} The instantiated value of this node.
   */
  instantiate(t) {
    throw Error("instantiate not implemented");
  }
  /**
   * Generate ESM code for this AST node.
   * @param {import('../ast-to-esm.js').CodegenContext} ctx The code generator context.
   * @returns {string|void} The generated ESM code for the node.
   */
  codegen(t) {
    return Error("codegen not implemented");
  }
  /**
   * @returns {*} This AST node in JSON specification format.
   */
  toJSON() {
    return Error("toJSON not implemented");
  }
}
class kQ extends ue {
  constructor(t, n, r, i, s, o) {
    super(SQ, [t]), this.root = t, this.meta = n, this.config = r, this.data = i, this.params = s, this.plotDefaults = o;
  }
  toJSON() {
    const { root: t, meta: n, config: r, plotDefaults: i } = this, s = new Map(Object.entries(this.data)), o = new Map(Object.entries(this.params)), a = {};
    if (n && (a.meta = { ...n }), r && (a.config = { ...r }), s != null && s.size) {
      const c = a.data = {};
      for (const [u, l] of s)
        c[u] = l.toJSON();
    }
    if (o != null && o.size) {
      const c = a.params = {};
      for (const [u, l] of o)
        c[u] = l.toJSON();
    }
    if (i != null && i.length) {
      const c = a.plotDefaults = {};
      for (const u of i)
        Object.assign(c, u.toJSON());
    }
    return Object.assign(a, t.toJSON());
  }
}
function FQ(e) {
  const t = typeof e;
  return t === "object" ? e == null ? void 0 : e.param : t === "string" ? BQ(e) : null;
}
function BQ(e) {
  return (e == null ? void 0 : e[0]) === "$" ? e.slice(1) : null;
}
function R_(e) {
  return `$${e}`;
}
function CQ(e) {
  return [e].flat();
}
function Ms(e) {
  return Array.isArray(e);
}
function F7(e) {
  return e !== null && typeof e == "object" && !Ms(e);
}
function Kl(e) {
  return typeof e == "string";
}
function B7(e, t) {
  throw Object.assign(Error(e), { data: t });
}
const PQ = /^(?:[-+]\d{2})?\d{4}(?:-\d{2}(?:-\d{2})?)?(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d{3})?)?(?:Z|[-+]\d{2}:?\d{2})?)?$/;
function UQ(e, t) {
  return PQ.test(e += "") ? new Date(e) : t;
}
function Tr(e, t) {
  const n = {};
  for (const r in e)
    n[r] = t.maybeSelection(e[r]);
  return new ip(n);
}
class ip extends ue {
  constructor(t) {
    super(MQ), this.options = t;
  }
  filter(t) {
    const n = Object.fromEntries(
      Object.entries(this.options).filter(([r, i]) => t(r, i))
    );
    return new ip(n);
  }
  instantiate(t) {
    const { options: n } = this, r = {};
    for (const i in n)
      r[i] = n[i].instantiate(t);
    return r;
  }
  codegen(t) {
    const { options: n } = this, r = [];
    for (const i in n)
      r.push(`${i}: ${n[i].codegen(t)}`);
    return r.length ? `{${t.maybeLineWrap(r)}}` : "";
  }
  toJSON() {
    const { options: t } = this, n = {};
    for (const r in t)
      n[r] = t[r].toJSON();
    return n;
  }
}
const C7 = "table", P7 = "parquet", U7 = "csv", H1 = "json", J1 = "spatial", k_ = /* @__PURE__ */ new Map([
  [C7, YQ],
  [P7, WQ],
  [U7, XQ],
  [H1, GQ],
  [J1, HQ]
]);
function zQ(e, t, n) {
  const r = qQ(t);
  if (k_.has(r.type))
    return k_.get(r.type)(e, r, n);
  n.error("Unrecognized data format type.", t);
}
function qQ(e) {
  return Ms(e) && (e = { type: "json", data: e }), Kl(e) && (e = { type: "table", query: e }), { ...e, type: jQ(e) };
}
function jQ(e) {
  return e.type || VQ(e.file) || "table";
}
function VQ(e) {
  const t = e == null ? void 0 : e.lastIndexOf(".");
  return t > 0 ? e.slice(t + 1) : null;
}
function YQ(e, t, n) {
  const { query: r, type: i, ...s } = t;
  return new KQ(e, r, Tr(s, n));
}
function WQ(e, t, n) {
  const { file: r, type: i, ...s } = t;
  return new ttt(e, r, Tr(s, n));
}
function XQ(e, t, n) {
  const { file: r, type: i, ...s } = t;
  return new ett(e, r, Tr(s, n));
}
function GQ(e, t, n) {
  const { data: r, file: i, type: s, ...o } = t, a = Tr(o, n);
  return r ? new rtt(e, r, a) : new ntt(e, i, a);
}
function HQ(e, t, n) {
  const { file: r, type: i, ...s } = t;
  return new QQ(e, r, Tr(s, n));
}
function F_(e, t) {
  return t ? new URL(e, t).toString() : e;
}
function JQ(e, t) {
  const n = e == null ? void 0 : e.codegen(t);
  return n ? `, ${n}` : "";
}
class ZQ extends ue {
  constructor(t, n) {
    super(DQ), this.name = t, this.format = n;
  }
}
class Z1 extends ZQ {
  constructor(t, n) {
    super(t, n);
  }
  /**
   * Instantiate a table creation query.
   * @param {import('../ast-to-dom.js').InstantiateContext} ctx The instantiation context.
   * @returns {string|void} The instantiated query.
   */
  instantiateQuery(t) {
    t.error("instantiateQuery not implemented");
  }
  /**
   * Code generate a table creation query.
   * @param {import('../ast-to-esm.js').CodegenContext} ctx The code generator context.
   * @returns {string|void} The generated query code.
   */
  codegenQuery(t) {
    t.error("codegenQuery not implemented");
  }
  /**
   * Instantiate this AST node to use in a live web application.
   * @param {import('../ast-to-dom.js').InstantiateContext} ctx The instantiation context.
   * @returns {*} The instantiated value of this node.
   */
  instantiate(t) {
    const n = this.instantiateQuery(t);
    if (n) return n;
  }
  /**
   * Generate ESM code for this AST node.
   * @param {import('../ast-to-esm.js').CodegenContext} ctx The code generator context.
   * @returns {string|void} The generated ESM code for the node.
   */
  codegen(t) {
    const n = this.codegenQuery(t);
    if (n) return n;
  }
}
class KQ extends Z1 {
  constructor(t, n, r) {
    super(t, C7), this.query = n == null ? void 0 : n.trim(), this.options = r;
  }
  /**
   * Instantiate a table creation query.
   * @param {import('../ast-to-dom.js').InstantiateContext} ctx The instantiation context.
   * @returns {string|void} The instantiated query.
   */
  instantiateQuery(t) {
    const { name: n, query: r, options: i } = this;
    if (r)
      return t.api.create(n, r, i.instantiate(t));
  }
  /**
   * Code generate a table creation query.
   * @param {import('../ast-to-esm.js').CodegenContext} ctx The code generator context.
   * @returns {string|void} The generated query code.
   */
  codegenQuery(t) {
    const { name: n, query: r, options: i } = this;
    if (r)
      return `\`${cu(n, r, i.instantiate(t))}\``;
  }
  toJSON() {
    const { format: t, query: n, options: r } = this;
    return { type: t, query: n, ...r.toJSON() };
  }
}
class sp extends Z1 {
  constructor(t, n, r, i, s) {
    super(t, n), this.file = i, this.method = r, this.options = s;
  }
  /**
   * Instantiate a table creation query.
   * @param {import('../ast-to-dom.js').InstantiateContext} ctx The instantiation context.
   * @returns {string|void} The instantiated query.
   */
  instantiateQuery(t) {
    const { name: n, method: r, file: i, options: s } = this, o = F_(i, t.baseURL), a = s == null ? void 0 : s.instantiate(t);
    return t.api[r](n, o, a);
  }
  /**
   * Code generate a table creation query.
   * @param {import('../ast-to-esm.js').CodegenContext} ctx The code generator context.
   * @returns {string|void} The generated query code.
   */
  codegenQuery(t) {
    const { name: n, method: r, file: i, options: s } = this, o = F_(i, t.baseURL), a = JQ(s, t);
    return `${t.ns()}${r}("${n}", "${o}"${a})`;
  }
  toJSON() {
    const { format: t, file: n, options: r } = this;
    return { type: t, file: n, ...r.toJSON() };
  }
}
class QQ extends sp {
  constructor(t, n, r) {
    super(t, J1, "loadSpatial", n, r);
  }
}
class ttt extends sp {
  constructor(t, n, r) {
    super(t, P7, "loadParquet", n, r);
  }
}
class ett extends sp {
  constructor(t, n, r) {
    super(t, U7, "loadCSV", n, r);
  }
}
class ntt extends sp {
  constructor(t, n, r) {
    super(t, H1, "loadJSON", n, r);
  }
}
class rtt extends Z1 {
  constructor(t, n, r) {
    super(t, H1), this.data = n, this.options = r;
  }
  /**
   * Instantiate a table creation query.
   * @param {import('../ast-to-dom.js').InstantiateContext} ctx The instantiation context.
   * @returns {string|void} The instantiated query.
   */
  instantiateQuery(t) {
    const { name: n, data: r, options: i } = this;
    return t.api.loadObjects(n, r, i.instantiate(t));
  }
  /**
   * Code generate a table creation query.
   * @param {import('../ast-to-esm.js').CodegenContext} ctx The code generator context.
   * @returns {string|void} The generated query code.
   */
  codegenQuery(t) {
    const { name: n, data: r, options: i } = this, s = i ? "," + i.codegen(t) : "", o = `[
    ` + r.map((a) => JSON.stringify(a)).join(`,
    `) + `
  ]`;
    return `${t.ns()}loadObjects("${n}", ${o}${s})`;
  }
  toJSON() {
    const { format: t, data: n, options: r } = this;
    return { type: t, data: n, ...r.toJSON() };
  }
}
function itt(e) {
  var r;
  const t = (r = e.config) == null ? void 0 : r.extensions, n = new Set(t ? CQ(t) : []);
  for (const i of Object.values(e.data))
    i.format === J1 && n.add("spatial");
  return n;
}
async function stt(e, t) {
  const { data: n, params: r, plotDefaults: i } = e, s = new ott({ plotDefaults: i, ...t }), o = [], a = itt(e);
  o.push(...Array.from(a).map((c) => Zx(c)));
  for (const c of Object.values(n)) {
    const u = c.instantiate(s);
    u && o.push(u);
  }
  o.length > 0 && await s.coordinator.exec(o);
  for (const [c, u] of Object.entries(r))
    if (!s.activeParams.has(c)) {
      const l = u.instantiate(s);
      s.activeParams.set(c, l);
    }
  return {
    element: e.root.instantiate(s),
    params: s.activeParams
  };
}
class ott {
  constructor({
    api: t = xQ(),
    plotDefaults: n = [],
    params: r = /* @__PURE__ */ new Map(),
    baseURL: i = null
  } = {}) {
    this.api = t, this.plotDefaults = n, this.activeParams = r, this.baseURL = i, this.coordinator = t.context.coordinator;
  }
  error(t, n) {
    B7(t, n);
  }
}
class z7 extends ue {
  constructor(t) {
    super(D7), this.value = t;
  }
  instantiate() {
    return this.value;
  }
  codegen(t) {
    return t.stringify(this.value);
  }
  toJSON() {
    return this.value;
  }
}
class q7 extends ue {
  constructor(t = L7, n, r) {
    super(AQ), this.select = t, this.cross = n, this.empty = r;
  }
  instantiate(t) {
    const { select: n, cross: r, empty: i } = this;
    return t.api.Selection[n]({ cross: r, empty: i });
  }
  codegen(t) {
    const { select: n, cross: r, empty: i } = this, s = [["cross", r], ["empty", i]].filter((a) => a[1] != null).map((a) => `${a[0]}: ${a[1]}`), o = s.length ? `{ ${s.join(", ")} }` : "";
    return `${t.ns()}Selection.${n}(${o})`;
  }
  toJSON() {
    const { select: t, cross: n, empty: r } = this;
    return { select: t, cross: n, empty: r };
  }
}
const att = /* @__PURE__ */ new Set([tm, NQ, TQ, L7, EQ]);
function ctt(e, t) {
  const n = F7(e) ? e : { value: e }, { select: r = tm, cross: i, empty: s, date: o, value: a } = n;
  return att.has(r) || t.error(`Unrecognized param type: ${r}`, n), r !== tm ? new q7(r, i, s) : Ms(a) ? new em(a.map((c) => t.maybeParam(c))) : new em(a, o);
}
class em extends ue {
  constructor(t, n) {
    super(IQ), this.value = t, this.date = n;
  }
  instantiate(t) {
    const { date: n, value: r } = this, { Param: i } = t.api;
    return Ms(r) ? i.array(r.map((s) => s.instantiate(t))) : i.value(UQ(n, r));
  }
  codegen(t) {
    const { value: n, date: r } = this, i = `${t.ns()}Param.`;
    return Ms(n) ? `${i}array([${n.map((s) => s.codegen(t)).join(", ")}])` : r ? `${i}value(new Date(${JSON.stringify(r)}))` : `${i}value(${JSON.stringify(n)})`;
  }
  toJSON() {
    const { date: t, value: n } = this;
    return Ms(n) ? n.map((r) => r.toJSON()) : t ? { date: t } : n;
  }
}
class utt extends ue {
  constructor(t) {
    super($Q), this.name = t;
  }
  instantiate(t) {
    var n;
    return (n = t.activeParams) == null ? void 0 : n.get(this.name);
  }
  codegen() {
    return R_(this.name);
  }
  toJSON() {
    return R_(this.name);
  }
}
function j7(e, t, n) {
  var r, i;
  return (i = (r = n.plot) == null ? void 0 : r.attributes) != null && i.has(e) || n.error(`Unrecognized attribute: ${e}`), new ltt(
    e,
    t === Zl ? new ftt() : n.maybeParam(t)
  );
}
class ltt extends ue {
  constructor(t, n) {
    super(LQ), this.name = t, this.value = n;
  }
  instantiate(t) {
    const { name: n, value: r } = this;
    return t.api[n](r.instantiate(t));
  }
  codegen(t) {
    const { name: n, value: r } = this;
    return `${t.tab()}${t.ns()}${n}(${r.codegen(t)})`;
  }
  toJSON() {
    const { name: t, value: n } = this;
    return { [t]: n.toJSON() };
  }
}
class ftt extends ue {
  constructor() {
    super(D7), this.value = Zl;
  }
  instantiate(t) {
    return t.api[Zl];
  }
  codegen(t) {
    return `${t.ns()}${Zl}`;
  }
  toJSON() {
    return this.value;
  }
}
function htt(e, t) {
  const n = e[Ch].map((r) => t.parseComponent(r));
  return new dtt(n);
}
class dtt extends ue {
  constructor(t) {
    super(Ch, t);
  }
  instantiate(t) {
    return t.api[Ch](this.children.map((n) => n.instantiate(t)));
  }
  codegen(t) {
    t.indent();
    const n = this.children.map((r) => r.codegen(t));
    return t.undent(), `${t.tab()}${t.ns()}${this.type}(
${n.join(`,
`)}
${t.tab()})`;
  }
  toJSON() {
    return { [this.type]: this.children.map((t) => t.toJSON()) };
  }
}
function ptt(e) {
  return new ytt(e[Uh]);
}
class ytt extends ue {
  constructor(t) {
    super(Uh), this.value = t;
  }
  instantiate(t) {
    return t.api[Uh](this.value);
  }
  codegen(t) {
    return `${t.tab()}${t.ns()}${this.type}(${t.stringify(this.value)})`;
  }
  toJSON() {
    return { [this.type]: this.value };
  }
}
function mtt(e, t) {
  var i;
  const { [X1]: n, ...r } = e;
  return (i = t.inputs) != null && i.has(n) || t.error(`Unrecognized input type: ${n}`, e), new gtt(n, Tr(r, t));
}
class gtt extends ue {
  constructor(t, n) {
    super(X1), this.name = t, this.options = n;
  }
  instantiate(t) {
    return t.api[this.name](this.options.instantiate(t));
  }
  codegen(t) {
    const n = this.options.codegen(t);
    return `${t.tab()}${t.ns()}${this.name}(${n})`;
  }
  toJSON() {
    const { type: t, name: n, options: r } = this;
    return { [t]: n, ...r.toJSON() };
  }
}
function V7(e, t) {
  var s, o;
  const { [G1]: n, ...r } = e, i = `${n}Legend`;
  return (o = (s = t.plot) == null ? void 0 : s.legends) != null && o.has(i) || t.error(`Unrecognized legend type: ${n}`, e), new btt(i, n, Tr(r, t));
}
class btt extends ue {
  constructor(t, n, r) {
    super(G1), this.key = t, this.name = n, this.options = r;
  }
  instantiate(t) {
    return t.api[this.key](this.options.instantiate(t));
  }
  codegen(t) {
    const n = this.options.codegen(t);
    return `${t.tab()}${t.ns()}${this.key}(${n})`;
  }
  toJSON() {
    const { type: t, name: n, options: r } = this;
    return { [t]: n, ...r.toJSON() };
  }
}
function wtt(e, t) {
  var i, s;
  const { [O7]: n, ...r } = e;
  return (s = (i = t.plot) == null ? void 0 : i.interactors) != null && s.has(n) || t.error(`Unrecognized interactor type: ${n}`, e), new _tt(n, Tr(r, t));
}
class _tt extends ue {
  constructor(t, n) {
    super(RQ), this.name = t, this.options = n;
  }
  instantiate(t) {
    return t.api[this.name](this.options.instantiate(t));
  }
  codegen(t) {
    const n = this.options.codegen(t);
    return `${t.tab()}${t.ns()}${this.name}(${n})`;
  }
  toJSON() {
    const { name: t, options: n } = this;
    return { [O7]: t, ...n.toJSON() };
  }
}
function vtt(e, t) {
  const { label: n } = e, r = e[Fo] ? Fo : e[Ss] ? Ss : t.error("Unrecognized expression type", e), i = e[r], s = i.split(/(\\'|\\"|"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|\$\w+)/g), o = [""], a = [];
  for (let c = 0, u = 0; c < s.length; ++c) {
    const l = s[c];
    l.startsWith("$") ? (a[u] = t.maybeParam(l), o[++u] = "") : o[u] += l;
  }
  return new xtt(i, o, a, n, r === Ss);
}
class xtt extends ue {
  constructor(t, n, r, i, s) {
    super(OQ), this.value = t, this.spans = n, this.params = r, this.label = i, this.aggregate = s;
  }
  instantiate(t) {
    const { spans: n, params: r, label: i, aggregate: s } = this, o = t.api[s ? Ss : Fo], a = r.map((c) => c.instantiate(t));
    return o(n, ...a).annotate({ label: i });
  }
  codegen(t) {
    const { spans: n, params: r, label: i, aggregate: s } = this, o = s ? Ss : Fo;
    let a = "";
    const c = r.length;
    for (let u = 0; u < c; ++u)
      a += n[u] + "${" + r[u].codegen(t) + "}";
    return a += n[c], `${t.ns()}${o}\`${a}\`` + (i ? `.annotate({ label: ${JSON.stringify(i)} })` : "");
  }
  toJSON() {
    return { [this.aggregate ? Ss : Fo]: this.value };
  }
}
function Stt(e, t) {
  if (!e)
    return null;
  if (Ms(e))
    return new z7(e);
  const { from: n, ...r } = e;
  return new Mtt(n, Tr(r, t));
}
class Mtt extends ue {
  constructor(t, n) {
    super(L_), this.table = t, this.options = n;
  }
  instantiate(t) {
    const { table: n, options: r } = this;
    return t.api[L_](n, r.instantiate(t));
  }
  codegen(t) {
    const { type: n, table: r, options: i } = this, s = i.codegen(t);
    return `${t.ns()}${n}("${r}"${s ? ", " + s : ""})`;
  }
  toJSON() {
    const { type: t, table: n, options: r } = this;
    return { [t]: n, ...r.toJSON() };
  }
}
function $l(e) {
  return e == null ? [] : [e].flat();
}
function Att(e, t) {
  let n;
  for (const r in e)
    t.transforms.has(r) && (n = r);
  if (n)
    if (n === "bin") {
      const { bin: r, ...i } = e, [s] = $l(r);
      return new Itt(n, s, Tr(i, t));
    } else {
      const r = n === "count" && !e[n] ? [] : $l(e[n]), i = {
        distinct: e.distinct,
        orderby: $l(e.orderby).map((s) => t.maybeParam(s)),
        partitionby: $l(e.partitionby).map((s) => t.maybeParam(s)),
        rows: e.rows ? t.maybeParam(e.rows) : null,
        range: e.range ? t.maybeParam(e.range) : null
      };
      return new $tt(n, r, i);
    }
}
class $tt extends ue {
  constructor(t, n, r) {
    super(k7), this.name = t, this.args = n, this.options = r;
  }
  instantiate(t) {
    const { name: n, args: r, options: i } = this, { distinct: s, orderby: o, partitionby: a, rows: c, range: u } = i;
    let l = t.api[n](...r);
    return s && (l = l.distinct()), o.length && (l = l.orderby(o.map((f) => f.instantiate(t)))), a.length && (l = l.partitionby(a.map((f) => f.instantiate(t)))), c != null ? l = l.rows(c.instantiate(t)) : u != null && (l = l.range(u.instantiate(t))), l;
  }
  codegen(t) {
    const { name: n, args: r, options: i } = this, { distinct: s, orderby: o, partitionby: a, rows: c, range: u } = i;
    let l = `${t.ns()}${n}(` + r.map((f) => JSON.stringify(f)).join(", ") + ")";
    if (s && (l += ".distinct()"), o.length) {
      const f = o.map((h) => h.codegen(t));
      l += `.orderby(${f.join(", ")})`;
    }
    if (a.length) {
      const f = a.map((h) => h.codegen(t));
      l += `.partitionby(${f.join(", ")})`;
    }
    return c ? l += `.rows(${c.codegen(t)})` : u && (l += `.range(${u.codegen(t)})`), l;
  }
  toJSON() {
    const { name: t, args: n, options: r } = this, { distinct: i, orderby: s, partitionby: o, rows: a, range: c } = r, u = { [t]: d0(n) };
    return i && (u.distinct = !0), s.length && (u.orderby = d0(s.map((l) => l.toJSON()))), o.length && (u.partitionby = d0(o.map((l) => l.toJSON()))), a ? u.rows = a.toJSON() : c && (u.range = c.toJSON()), u;
  }
}
class Itt extends ue {
  constructor(t, n, r) {
    super(k7), this.name = t, this.arg = n, this.options = r;
  }
  instantiate(t) {
    const { name: n, arg: r, options: i } = this;
    return t.api[n](r, i.instantiate(t));
  }
  codegen(t) {
    const { name: n, arg: r, options: i } = this, s = i.codegen(t);
    return `${t.ns()}${n}(` + JSON.stringify(r) + (s ? `, ${s}` : "") + ")";
  }
  toJSON() {
    const { name: t, arg: n, options: r } = this;
    return { [t]: n, ...r.toJSON() };
  }
}
function d0(e) {
  return e.length === 0 ? "" : e.length === 1 ? e[0] : e;
}
function Ttt(e, t) {
  if (F7(e))
    return e[Fo] || e[Ss] ? vtt(e, t) : Att(e, t);
}
function Ett(e, t) {
  var a, c;
  const { mark: n, data: r, ...i } = e;
  (c = (a = t.plot) == null ? void 0 : a.marks) != null && c.has(n) || t.error(`Unrecognized mark type: ${n}`, e);
  const s = Stt(r, t), o = {};
  for (const u in i) {
    const l = i[u];
    o[u] = Ttt(l, t) || t.maybeParam(l);
  }
  return new Ntt(n, s, new ip(o));
}
class Ntt extends ue {
  constructor(t, n, r) {
    super(R7), this.name = t, this.data = n, this.options = r;
  }
  instantiate(t) {
    const { name: n, data: r, options: i } = this, s = i.instantiate(t);
    return r ? t.api[n](r.instantiate(t), s) : t.api[n](s);
  }
  codegen(t) {
    const { name: n, data: r, options: i } = this, s = r ? r.codegen(t) : "", o = i.codegen(t);
    let a;
    if (s && o) {
      t.indent();
      const c = i.codegen(t);
      a = `
${t.tab()}${s},
${t.tab()}${c}
`, t.undent(), a += t.tab();
    } else
      a = `${s}${o}`;
    return `${t.tab()}${t.ns()}${n}(${a})`;
  }
  toJSON() {
    const { type: t, name: n, data: r, options: i } = this;
    return {
      [t]: n,
      ...r ? { data: r.toJSON() } : {},
      ...i.toJSON()
    };
  }
}
function Dtt(e, t) {
  return Y7({ plot: [e] }, t);
}
function Y7(e, t) {
  const { [qh]: n, ...r } = e, i = Object.entries(r).map(([o, a]) => j7(o, a, t)), s = n.map((o) => Kl(o.mark) ? Ett(o, t) : Kl(o.legend) ? V7(o, t) : Kl(o.select) ? wtt(o, t) : t.error("Invalid plot entry.", o));
  return new Ott(s, i);
}
class Ott extends ue {
  constructor(t, n) {
    super(qh, t), this.attributes = n;
  }
  instantiate(t) {
    const n = [
      ...t.plotDefaults || [],
      ...this.attributes || []
    ];
    return t.api[qh](
      this.children.map((r) => r.instantiate(t)),
      n.map((r) => r.instantiate(t))
    );
  }
  codegen(t) {
    var o;
    const { type: n, children: r, attributes: i } = this;
    t.indent();
    const s = [
      ...r.map((a) => a.codegen(t)),
      ...(o = t.plotDefaults) != null && o.length ? [`${t.tab()}...defaultAttributes`] : [],
      ...i.map((a) => a.codegen(t))
    ].join(`,
`);
    return t.undent(), `${t.tab()}${t.ns()}${n}(
${s}
${t.tab()})`;
  }
  toJSON() {
    const { type: t, children: n, attributes: r } = this, i = { [t]: n.map((s) => s.toJSON()) };
    for (const s of r)
      Object.assign(i, s.toJSON());
    return i;
  }
}
function Ltt(e, t) {
  const n = e[Ph].map((r) => t.parseComponent(r));
  return new Rtt(n);
}
class Rtt extends ue {
  constructor(t) {
    super(Ph, t);
  }
  instantiate(t) {
    return t.api[Ph](this.children.map((n) => n.instantiate(t)));
  }
  codegen(t) {
    t.indent();
    const n = this.children.map((r) => r.codegen(t));
    return t.undent(), `${t.tab()}${t.ns()}${this.type}(
${n.join(`,
`)}
${t.tab()})`;
  }
  toJSON() {
    return { [this.type]: this.children.map((t) => t.toJSON()) };
  }
}
function ktt(e) {
  return new Ftt(e[zh]);
}
class Ftt extends ue {
  constructor(t) {
    super(zh), this.value = t;
  }
  instantiate(t) {
    return t.api[zh](this.value);
  }
  codegen(t) {
    return `${t.tab()}${t.ns()}${this.type}(${t.stringify(this.value)})`;
  }
  toJSON() {
    return { [this.type]: this.value };
  }
}
function Btt(e = []) {
  return new Map([
    [qh, Y7],
    [R7, Dtt],
    [G1, V7],
    [X1, mtt],
    [Ch, htt],
    [Ph, Ltt],
    [Uh, ptt],
    [zh, ktt],
    ...e
  ]);
}
function Ctt(e = []) {
  return /* @__PURE__ */ new Set([
    "menu",
    "search",
    "slider",
    "table",
    ...e
  ]);
}
function Ptt({
  attributes: e = Utt(),
  interactors: t = ztt(),
  legends: n = qtt(),
  marks: r = jtt()
} = {}) {
  return { attributes: e, interactors: t, legends: n, marks: r };
}
function Utt(e = []) {
  return /* @__PURE__ */ new Set([
    ...Object.keys(pQ),
    ...e
  ]);
}
function ztt(e = []) {
  return /* @__PURE__ */ new Set([
    ...Object.keys(bQ),
    ...e
  ]);
}
function qtt(e = []) {
  return /* @__PURE__ */ new Set([
    ...Object.keys(wQ),
    ...e
  ]);
}
function jtt(e = []) {
  return /* @__PURE__ */ new Set([
    ...Object.keys(gQ),
    ...e
  ]);
}
function Vtt(e = []) {
  return /* @__PURE__ */ new Set([
    "argmin",
    "argmax",
    "avg",
    "bin",
    "centroid",
    "centroidX",
    "centroidY",
    "count",
    "covariance",
    "covarPop",
    "dateMonth",
    "dateMonthDay",
    "dateDay",
    "first",
    "geojson",
    "last",
    "max",
    "median",
    "min",
    "mode",
    "product",
    "quantile",
    "stddev",
    "stddevPop",
    "sum",
    "variance",
    "varPop",
    "row_number",
    "rank",
    "dense_rank",
    "percent_rank",
    "cume_dist",
    "ntile",
    "lag",
    "lead",
    "first_value",
    "last_value",
    "nth_value",
    ...e
  ]);
}
function Ytt(e, t) {
  return new Wtt(t).parse(e);
}
class Wtt {
  /**
   * Create a new parser context.
   * @param {object} [options]
   * @param {Map<string, Function>} [options.components] Map of component names to parse functions.
   * @param {Set<string>} [options.transforms] The names of allowed transform functions.
   * @param {Set<string>} [options.inputs] The names of supported input widgets.
   * @param {PlotNames} [options.plot] The names of supported plot elements.
   * @param {any[]} [options.params] An array of [name, node] pairs of pre-parsed
   *  Param or Selection AST nodes.
   * @param {any[]} [options.datasets] An array of [name, node] pairs of pre-parsed
   *  dataset definition AST nodes.
   */
  constructor({
    components: t = Btt(),
    transforms: n = Vtt(),
    inputs: r = Ctt(),
    plot: i = Ptt(),
    params: s = [],
    datasets: o = []
  } = {}) {
    this.components = t, this.transforms = n, this.inputs = r, this.plot = i, this.params = new Map(s), this.datasets = new Map(o);
  }
  parse(t) {
    const {
      meta: n,
      config: r,
      data: i = {},
      params: s,
      plotDefaults: o = {},
      ...a
    } = t;
    for (const c in i)
      this.datasets.set(c, zQ(c, i[c], this));
    this.plotDefaults = Object.entries(o).map(([c, u]) => j7(c, u, this));
    for (const c in s)
      this.params.set(c, ctt(s[c], this));
    return new kQ(
      this.parseComponent(a),
      n ? { ...n } : void 0,
      r ? { ...r } : void 0,
      Object.fromEntries(this.datasets),
      Object.fromEntries(this.params),
      this.plotDefaults
    );
  }
  parseComponent(t) {
    for (const [n, r] of this.components)
      if (t[n] != null)
        return r(t, this);
    this.error("Invalid specification.", t);
  }
  /**
   * Test if a value is param reference, if so, generate a paramter definition
   * as needed and return a new ParamRefNode. Otherwise, return a LiteralNode.
   * @param {*} value The value to test.
   * @param {() => ParamNode | SelectionNode} [makeNode] A Param of Selection AST
   *  node constructor.
   * @returns {ParamRefNode|LiteralNode} An AST node for the input value.
   */
  maybeParam(t, n = () => new em()) {
    const { params: r } = this, i = FQ(t);
    if (i) {
      if (!r.has(i)) {
        const s = n();
        r.set(i, s);
      }
      return new utt(i);
    }
    return new z7(t);
  }
  maybeSelection(t) {
    return this.maybeParam(t, () => new q7());
  }
  error(t, n) {
    B7(t, n);
  }
}
var Se = [];
for (var p0 = 0; p0 < 256; ++p0)
  Se.push((p0 + 256).toString(16).slice(1));
function Xtt(e, t = 0) {
  return (Se[e[t + 0]] + Se[e[t + 1]] + Se[e[t + 2]] + Se[e[t + 3]] + "-" + Se[e[t + 4]] + Se[e[t + 5]] + "-" + Se[e[t + 6]] + Se[e[t + 7]] + "-" + Se[e[t + 8]] + Se[e[t + 9]] + "-" + Se[e[t + 10]] + Se[e[t + 11]] + Se[e[t + 12]] + Se[e[t + 13]] + Se[e[t + 14]] + Se[e[t + 15]]).toLowerCase();
}
var Il, Gtt = new Uint8Array(16);
function Htt() {
  if (!Il && (Il = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !Il))
    throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
  return Il(Gtt);
}
var Jtt = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
const B_ = {
  randomUUID: Jtt
};
function Ztt(e, t, n) {
  if (B_.randomUUID && !t && !e)
    return B_.randomUUID();
  e = e || {};
  var r = e.random || (e.rng || Htt)();
  if (r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, t) {
    n = n || 0;
    for (var i = 0; i < 16; ++i)
      t[n + i] = r[i];
    return t;
  }
  return Xtt(r);
}
const ret = {
  /** @type {import('anywidget/types').Initialize<Model>} */
  // eslint-disable-next-line no-unused-vars
  initialize(e) {
  },
  /** @type {import('anywidget/types').Render<Model>} */
  render(e) {
    e.el.classList.add("mosaic-widget");
    const t = () => e.model.get("spec"), n = () => e.model.get("temp_indexes"), r = Wr().logger(), i = /* @__PURE__ */ new Map();
    function s(l, f, h) {
      const d = Ztt();
      i.set(d, {
        query: l,
        startTime: performance.now(),
        resolve: f,
        reject: h
      }), e.model.send({ ...l, uuid: d });
    }
    const o = {
      query(l) {
        return new Promise((f, h) => s(l, f, h));
      }
    };
    function a() {
      Wr().clear(), V1.clear();
    }
    async function c() {
      const l = t();
      a(), r.log("Setting spec:", l);
      const f = await Ktt(l);
      e.el.replaceChildren(f.element);
      const h = {};
      for (const [d, p] of f.params)
        h[d] = {
          value: p.value,
          ...hr(p) ? { predicate: String(p.predicate()) } : {}
        }, p.addEventListener("value", (y) => {
          h[d] = {
            value: y,
            ...hr(p) ? { predicate: String(p.predicate()) } : {}
          }, e.model.set("params", h), e.model.save_changes();
        });
      e.model.set("params", h), e.model.save_changes();
    }
    e.model.on("change:spec", () => c());
    function u() {
      Wr().dataCubeIndexer.temp = n();
    }
    return e.model.on("change:temp_indexes", () => u()), e.model.on("msg:custom", (l, f) => {
      r.group(`query ${l.uuid}`), r.log("received message", l, f);
      const h = i.get(l.uuid);
      if (i.delete(l.uuid), r.log(h.query.sql, (performance.now() - h.startTime).toFixed(1)), l.error)
        h.reject(l.error), r.error(l.error);
      else
        switch (l.type) {
          case "arrow": {
            const d = Sm(f[0].buffer);
            r.log("table", d), h.resolve(d);
            break;
          }
          case "json": {
            r.log("json", l.result), h.resolve(l.result);
            break;
          }
          default: {
            h.resolve({});
            break;
          }
        }
      r.groupEnd("query");
    }), Wr().databaseConnector(o), u(), c(), () => {
      a();
    };
  }
};
function Ktt(e) {
  const t = Ytt(e);
  return stt(t);
}
export {
  ret as default
};
