const A_ = {};
function OI(e, t = !1) {
  let n, i, r = A_;
  function s(l) {
    n = e(l).then(() => {
      if (i) {
        const { value: u } = i;
        i = null, s(u);
      } else
        n = null;
    });
  }
  function o(l) {
    i = { event: l };
  }
  function a(l) {
    n ? o(l) : s(l);
  }
  function c(l) {
    r !== l && requestAnimationFrame(() => {
      const u = r;
      r = A_, a(u);
    }), r = l;
  }
  return t ? c : a;
}
class cf {
  /**
   * 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 = OI(() => 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.
   */
  fields() {
    return null;
  }
  /**
   * Called by the coordinator to set the field info for this client.
   * @returns {this}
   */
  fieldInfo() {
    return this;
  }
  /**
   * Return a query specifying the data needed by this client.
   */
  query() {
    return null;
  }
  /**
   * Called by the coordinator to inform the client that a query is pending.
   */
  queryPending() {
    return this;
  }
  /**
   * Called by the coordinator to return a query result.
   *
   * @param {*} data the query result
   * @returns {this}
   */
  queryResult() {
    return this;
  }
  /**
   * Called by the coordinator to report a query execution error.
   */
  queryError(t) {
    return console.error(t), 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 i;
    const n = t || this.query((i = this.filterBy) == null ? void 0 : i.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.
   */
  update() {
    return this;
  }
}
function W(e, t, n, i) {
  function r(s) {
    return s instanceof n ? s : new n(function(o) {
      o(s);
    });
  }
  return new (n || (n = Promise))(function(s, o) {
    function a(u) {
      try {
        l(i.next(u));
      } catch (f) {
        o(f);
      }
    }
    function c(u) {
      try {
        l(i.throw(u));
      } catch (f) {
        o(f);
      }
    }
    function l(u) {
      u.done ? s(u.value) : r(u.value).then(a, c);
    }
    l((i = i.apply(e, t || [])).next());
  });
}
function M_(e) {
  var t = typeof Symbol == "function" && Symbol.iterator, n = t && e[t], i = 0;
  if (n)
    return n.call(e);
  if (e && typeof e.length == "number")
    return {
      next: function() {
        return e && i >= e.length && (e = void 0), { value: e && e[i++], done: !e };
      }
    };
  throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
function H(e) {
  return this instanceof H ? (this.v = e, this) : new H(e);
}
function Re(e, t, n) {
  if (!Symbol.asyncIterator)
    throw new TypeError("Symbol.asyncIterator is not defined.");
  var i = n.apply(e, t || []), r, s = [];
  return r = {}, o("next"), o("throw"), o("return"), r[Symbol.asyncIterator] = function() {
    return this;
  }, r;
  function o(h) {
    i[h] && (r[h] = function(d) {
      return new Promise(function(p, y) {
        s.push([h, d, p, y]) > 1 || a(h, d);
      });
    });
  }
  function a(h, d) {
    try {
      c(i[h](d));
    } catch (p) {
      f(s[0][3], p);
    }
  }
  function c(h) {
    h.value instanceof H ? Promise.resolve(h.value.v).then(l, u) : f(s[0][2], h);
  }
  function l(h) {
    a("next", h);
  }
  function u(h) {
    a("throw", h);
  }
  function f(h, d) {
    h(d), s.shift(), s.length && a(s[0][0], s[0][1]);
  }
}
function Cs(e) {
  var t, n;
  return t = {}, i("next"), i("throw", function(r) {
    throw r;
  }), i("return"), t[Symbol.iterator] = function() {
    return this;
  }, t;
  function i(r, s) {
    t[r] = e[r] ? function(o) {
      return (n = !n) ? { value: H(e[r](o)), done: !1 } : s ? s(o) : o;
    } : s;
  }
}
function ai(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 M_ == "function" ? M_(e) : e[Symbol.iterator](), n = {}, i("next"), i("throw"), i("return"), n[Symbol.asyncIterator] = function() {
    return this;
  }, n);
  function i(s) {
    n[s] = e[s] && function(o) {
      return new Promise(function(a, c) {
        o = e[s](o), r(a, c, o.done, o.value);
      });
    };
  }
  function r(s, o, a, c) {
    Promise.resolve(c).then(function(l) {
      s({ value: l, done: a });
    }, o);
  }
}
const NC = new TextDecoder("utf-8"), dg = (e) => NC.decode(e), BC = new TextEncoder(), fb = (e) => BC.encode(e), OC = (e) => typeof e == "number", FC = (e) => typeof e == "boolean", on = (e) => typeof e == "function", Si = (e) => e != null && Object(e) === e, vu = (e) => Si(e) && on(e.then), Cy = (e) => Si(e) && on(e[Symbol.iterator]), hb = (e) => Si(e) && on(e[Symbol.asyncIterator]), pg = (e) => Si(e) && Si(e.schema), FI = (e) => Si(e) && "done" in e && "value" in e, EI = (e) => Si(e) && on(e.stat) && OC(e.fd), LI = (e) => Si(e) && db(e.body), RI = (e) => "_getDOMStream" in e && "_getNodeStream" in e, db = (e) => Si(e) && on(e.cancel) && on(e.getReader) && !RI(e), CI = (e) => Si(e) && on(e.read) && on(e.pipe) && FC(e.readable) && !RI(e), EC = (e) => Si(e) && on(e.clear) && on(e.bytes) && on(e.position) && on(e.setPosition) && on(e.capacity) && on(e.getBufferIdentifier) && on(e.createLong), pb = typeof SharedArrayBuffer < "u" ? SharedArrayBuffer : ArrayBuffer;
function LC(e) {
  const t = e[0] ? [e[0]] : [];
  let n, i, r, s;
  for (let o, a, c = 0, l = 0, u = e.length; ++c < u; ) {
    if (o = t[l], a = e[c], !o || !a || o.buffer !== a.buffer || a.byteOffset < o.byteOffset) {
      a && (t[++l] = a);
      continue;
    }
    if ({ byteOffset: n, byteLength: r } = o, { byteOffset: i, byteLength: s } = a, n + r < i || i + s < n) {
      a && (t[++l] = a);
      continue;
    }
    t[l] = new Uint8Array(o.buffer, n, i - n + s);
  }
  return t;
}
function $_(e, t, n = 0, i = t.byteLength) {
  const r = e.byteLength, s = new Uint8Array(e.buffer, e.byteOffset, r), o = new Uint8Array(t.buffer, t.byteOffset, Math.min(i, r));
  return s.set(o, n), e;
}
function cr(e, t) {
  const n = LC(e), i = n.reduce((u, f) => u + f.byteLength, 0);
  let r, s, o, a = 0, c = -1;
  const l = Math.min(t || Number.POSITIVE_INFINITY, i);
  for (const u = n.length; ++c < u; ) {
    if (r = n[c], s = r.subarray(0, Math.min(r.length, l - a)), l <= a + s.length) {
      s.length < r.length ? n[c] = r.subarray(s.length) : s.length === r.length && c++, o ? $_(o, s, a) : o = s;
      break;
    }
    $_(o || (o = new Uint8Array(l)), s, a), a += s.length;
  }
  return [o || new Uint8Array(0), n.slice(c), i - (o ? o.byteLength : 0)];
}
function re(e, t) {
  let n = FI(t) ? t.value : t;
  return n instanceof e ? e === Uint8Array ? new e(n.buffer, n.byteOffset, n.byteLength) : n : n ? (typeof n == "string" && (n = fb(n)), n instanceof ArrayBuffer ? new e(n) : n instanceof pb ? new e(n) : EC(n) ? re(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 bl = (e) => re(Int32Array, e), T_ = (e) => re(BigInt64Array, e), Yt = (e) => re(Uint8Array, e), yg = (e) => (e.next(), e);
function* RC(e, t) {
  const n = function* (r) {
    yield r;
  }, i = typeof t == "string" || ArrayBuffer.isView(t) || t instanceof ArrayBuffer || t instanceof pb ? n(t) : Cy(t) ? t : n(t);
  return yield* yg(function* (r) {
    let s = null;
    do
      s = r.next(yield re(e, s));
    while (!s.done);
  }(i[Symbol.iterator]())), new e();
}
const CC = (e) => RC(Uint8Array, e);
function kI(e, t) {
  return Re(this, arguments, function* () {
    if (vu(t))
      return yield H(yield H(yield* Cs(ai(kI(e, yield H(t))))));
    const i = function(o) {
      return Re(this, arguments, function* () {
        yield yield H(yield H(o));
      });
    }, r = function(o) {
      return Re(this, arguments, function* () {
        yield H(yield* Cs(ai(yg(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 pb ? i(t) : Cy(t) ? r(t) : hb(t) ? t : i(t);
    return yield H(
      // otherwise if AsyncIterable, use it
      yield* Cs(ai(yg(function(o) {
        return Re(this, arguments, function* () {
          let a = null;
          do
            a = yield H(o.next(yield yield H(re(e, a))));
          while (!a.done);
        });
      }(s[Symbol.asyncIterator]()))))
    ), yield H(new e());
  });
}
const kC = (e) => kI(Uint8Array, e);
function UC(e, t) {
  let n = 0;
  const i = e.length;
  if (i !== t.length)
    return !1;
  if (i > 0)
    do
      if (e[n] !== t[n])
        return !1;
    while (++n < i);
  return !0;
}
const Hn = {
  fromIterable(e) {
    return ih(zC(e));
  },
  fromAsyncIterable(e) {
    return ih(PC(e));
  },
  fromDOMStream(e) {
    return ih(VC(e));
  },
  fromNodeStream(e) {
    return ih(qC(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');
  }
}, ih = (e) => (e.next(), e);
function* zC(e) {
  let t, n = !1, i = [], r, s, o, a = 0;
  function c() {
    return s === "peek" ? cr(i, o)[0] : ([r, i, a] = cr(i, o), r);
  }
  ({ cmd: s, size: o } = (yield null) || { cmd: "read", size: 0 });
  const l = CC(e)[Symbol.iterator]();
  try {
    do
      if ({ done: t, value: r } = Number.isNaN(o - a) ? l.next() : l.next(o - a), !t && r.byteLength > 0 && (i.push(r), a += r.byteLength), t || o <= a)
        do
          ({ cmd: s, size: o } = yield c());
        while (o < a);
    while (!t);
  } catch (u) {
    (n = !0) && typeof l.throw == "function" && l.throw(u);
  } finally {
    n === !1 && typeof l.return == "function" && l.return(null);
  }
  return null;
}
function PC(e) {
  return Re(this, arguments, function* () {
    let n, i = !1, r = [], s, o, a, c = 0;
    function l() {
      return o === "peek" ? cr(r, a)[0] : ([s, r, c] = cr(r, a), s);
    }
    ({ cmd: o, size: a } = (yield yield H(null)) || { cmd: "read", size: 0 });
    const u = kC(e)[Symbol.asyncIterator]();
    try {
      do
        if ({ done: n, value: s } = Number.isNaN(a - c) ? yield H(u.next()) : yield H(u.next(a - c)), !n && s.byteLength > 0 && (r.push(s), c += s.byteLength), n || a <= c)
          do
            ({ cmd: o, size: a } = yield yield H(l()));
          while (a < c);
      while (!n);
    } catch (f) {
      (i = !0) && typeof u.throw == "function" && (yield H(u.throw(f)));
    } finally {
      i === !1 && typeof u.return == "function" && (yield H(u.return(new Uint8Array(0))));
    }
    return yield H(null);
  });
}
function VC(e) {
  return Re(this, arguments, function* () {
    let n = !1, i = !1, r = [], s, o, a, c = 0;
    function l() {
      return o === "peek" ? cr(r, a)[0] : ([s, r, c] = cr(r, a), s);
    }
    ({ cmd: o, size: a } = (yield yield H(null)) || { cmd: "read", size: 0 });
    const u = new jC(e);
    try {
      do
        if ({ done: n, value: s } = Number.isNaN(a - c) ? yield H(u.read()) : yield H(u.read(a - c)), !n && s.byteLength > 0 && (r.push(Yt(s)), c += s.byteLength), n || a <= c)
          do
            ({ cmd: o, size: a } = yield yield H(l()));
          while (a < c);
      while (!n);
    } catch (f) {
      (i = !0) && (yield H(u.cancel(f)));
    } finally {
      i === !1 ? yield H(u.cancel()) : e.locked && u.releaseLock();
    }
    return yield H(null);
  });
}
let jC = class {
  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 W(this, void 0, void 0, function* () {
      const { reader: n, source: i } = this;
      n && (yield n.cancel(t).catch(() => {
      })), i && i.locked && this.releaseLock();
    });
  }
  read(t) {
    return W(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 = Yt(n)), n;
    });
  }
};
const tm = (e, t) => {
  const n = (r) => i([t, r]);
  let i;
  return [t, n, new Promise((r) => (i = r) && e.once(t, n))];
};
function qC(e) {
  return Re(this, arguments, function* () {
    const n = [];
    let i = "error", r = !1, s = null, o, a, c = 0, l = [], u;
    function f() {
      return o === "peek" ? cr(l, a)[0] : ([u, l, c] = cr(l, a), u);
    }
    if ({ cmd: o, size: a } = (yield yield H(null)) || { cmd: "read", size: 0 }, e.isTTY)
      return yield yield H(new Uint8Array(0)), yield H(null);
    try {
      n[0] = tm(e, "end"), n[1] = tm(e, "error");
      do {
        if (n[2] = tm(e, "readable"), [i, s] = yield H(Promise.race(n.map((d) => d[2]))), i === "error")
          break;
        if ((r = i === "end") || (Number.isFinite(a - c) ? (u = Yt(e.read(a - c)), u.byteLength < a - c && (u = Yt(e.read()))) : u = Yt(e.read()), u.byteLength > 0 && (l.push(u), c += u.byteLength)), r || a <= c)
          do
            ({ cmd: o, size: a } = yield yield H(f()));
          while (a < c);
      } while (!r);
    } finally {
      yield H(h(n, i === "error" ? s : null));
    }
    return yield H(null);
    function h(d, p) {
      return u = l = null, new Promise((y, g) => {
        for (const [m, b] of d)
          e.off(m, b);
        try {
          const m = e.destroy;
          m && m.call(e, p), p = void 0;
        } catch (m) {
          p = m || p;
        } finally {
          p != null ? g(p) : y();
        }
      });
    }
  });
}
var Ee;
(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";
})(Ee || (Ee = {}));
var Mn;
(function(e) {
  e[e.Sparse = 0] = "Sparse", e[e.Dense = 1] = "Dense";
})(Mn || (Mn = {}));
var nn;
(function(e) {
  e[e.HALF = 0] = "HALF", e[e.SINGLE = 1] = "SINGLE", e[e.DOUBLE = 2] = "DOUBLE";
})(nn || (nn = {}));
var Ii;
(function(e) {
  e[e.DAY = 0] = "DAY", e[e.MILLISECOND = 1] = "MILLISECOND";
})(Ii || (Ii = {}));
var mt;
(function(e) {
  e[e.SECOND = 0] = "SECOND", e[e.MILLISECOND = 1] = "MILLISECOND", e[e.MICROSECOND = 2] = "MICROSECOND", e[e.NANOSECOND = 3] = "NANOSECOND";
})(mt || (mt = {}));
var lr;
(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";
})(lr || (lr = {}));
const em = 2, Ji = 4, Pr = 4, nt = 4, Is = new Int32Array(2), D_ = new Float32Array(Is.buffer), N_ = new Float64Array(Is.buffer), rh = new Uint16Array(new Uint8Array([1, 0]).buffer)[0] === 1;
var mg;
(function(e) {
  e[e.UTF8_BYTES = 1] = "UTF8_BYTES", e[e.UTF16_STRING = 2] = "UTF16_STRING";
})(mg || (mg = {}));
let ur = class UI {
  /**
   * 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 UI(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 Is[0] = this.readInt32(t), D_[0];
  }
  readFloat64(t) {
    return Is[rh ? 0 : 1] = this.readInt32(t), Is[rh ? 1 : 0] = this.readInt32(t + 4), N_[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) {
    D_[0] = n, this.writeInt32(t, Is[0]);
  }
  writeFloat64(t, n) {
    N_[0] = n, this.writeInt32(t, Is[rh ? 0 : 1]), this.writeInt32(t + 4, Is[rh ? 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_ + Ji + Pr)
      throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");
    let t = "";
    for (let n = 0; n < Pr; n++)
      t += String.fromCharCode(this.readInt8(this.position_ + Ji + 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 i = t - this.readInt32(t);
    return n < this.readInt16(i) ? this.readInt16(i + 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 i = this.readInt32(t);
    t += Ji;
    const r = this.bytes_.subarray(t, t + i);
    return n === mg.UTF8_BYTES ? r : this.text_decoder_.decode(r);
  }
  /**
   * 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) + Ji;
  }
  /**
   * 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 != Pr)
      throw new Error("FlatBuffers: file identifier must be length " + Pr);
    for (let n = 0; n < Pr; n++)
      if (t.charCodeAt(n) != this.readInt8(this.position() + Ji + n))
        return !1;
    return !0;
  }
  /**
   * A helper function for generating list for obj api
   */
  createScalarList(t, n) {
    const i = [];
    for (let r = 0; r < n; ++r) {
      const s = t(r);
      s !== null && i.push(s);
    }
    return i;
  }
  /**
   * 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 i = [];
    for (let r = 0; r < n; ++r) {
      const s = t(r);
      s !== null && i.push(s.unpack());
    }
    return i;
  }
}, ky = class zI {
  /**
   * 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 = ur.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 i = ~(this.bb.capacity() - this.space + n) + 1 & t - 1;
    for (; this.space < i + t + n; ) {
      const r = this.bb.capacity();
      this.bb = zI.growByteBuffer(this.bb), this.space += this.bb.capacity() - r;
    }
    this.pad(i);
  }
  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, i) {
    (this.force_defaults || n != i) && (this.addInt8(n), this.slot(t));
  }
  addFieldInt16(t, n, i) {
    (this.force_defaults || n != i) && (this.addInt16(n), this.slot(t));
  }
  addFieldInt32(t, n, i) {
    (this.force_defaults || n != i) && (this.addInt32(n), this.slot(t));
  }
  addFieldInt64(t, n, i) {
    (this.force_defaults || n !== i) && (this.addInt64(n), this.slot(t));
  }
  addFieldFloat32(t, n, i) {
    (this.force_defaults || n != i) && (this.addFloat32(n), this.slot(t));
  }
  addFieldFloat64(t, n, i) {
    (this.force_defaults || n != i) && (this.addFloat64(n), this.slot(t));
  }
  addFieldOffset(t, n, i) {
    (this.force_defaults || n != i) && (this.addOffset(n), this.slot(t));
  }
  /**
   * Structs are stored inline, so nothing additional is being added. `d` is always 0.
   */
  addFieldStruct(t, n, i) {
    n != i && (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 i = n << 1, r = ur.allocate(i);
    return r.setPosition(i - n), r.bytes().set(t.bytes(), i - n), r;
  }
  /**
   * Adds on offset, relative to where it will be written.
   *
   * @param offset The offset to add.
   */
  addOffset(t) {
    this.prep(Ji, 0), this.writeInt32(this.offset() - t + Ji);
  }
  /**
   * 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 i = n + 1;
    for (; n >= 0; n--)
      this.addInt16(this.vtable[n] != 0 ? t - this.vtable[n] : 0);
    const r = 2;
    this.addInt16(t - this.object_start);
    const s = (i + r) * em;
    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 l = em; l < s; l += em)
            if (this.bb.readInt16(a + l) != this.bb.readInt16(c + l))
              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, i) {
    const r = i ? nt : 0;
    if (n) {
      const s = n;
      if (this.prep(this.minalign, Ji + Pr + r), s.length != Pr)
        throw new TypeError("FlatBuffers: file identifier must be length " + Pr);
      for (let o = Pr - 1; o >= 0; o--)
        this.writeInt8(s.charCodeAt(o));
    }
    this.prep(this.minalign, Ji + r), this.addOffset(t), r && 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 i = this.bb.capacity() - t, r = i - this.bb.readInt32(i);
    if (!(n < this.bb.readInt16(r) && this.bb.readInt16(r + 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, i) {
    this.notNested(), this.vector_num_elems = n, this.prep(Ji, t * n), this.prep(i, 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;
    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);
    for (let i = 0, r = this.space, s = this.bb.bytes(); i < n.length; i++)
      s[r++] = n[i];
    return 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 i = 0; i < t.length; ++i) {
      const r = t[i];
      if (r !== null)
        n.push(this.createObjectOffset(r));
      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 wd;
(function(e) {
  e[e.BUFFER = 0] = "BUFFER";
})(wd || (wd = {}));
var vd;
(function(e) {
  e[e.LZ4_FRAME = 0] = "LZ4_FRAME", e[e.ZSTD = 1] = "ZSTD";
})(vd || (vd = {}));
let YC = class bo {
  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 bo()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsBodyCompression(t, n) {
    return t.setPosition(t.position() + nt), (n || new bo()).__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) : vd.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) : wd.BUFFER;
  }
  static startBodyCompression(t) {
    t.startObject(2);
  }
  static addCodec(t, n) {
    t.addFieldInt8(0, n, vd.LZ4_FRAME);
  }
  static addMethod(t, n) {
    t.addFieldInt8(1, n, wd.BUFFER);
  }
  static endBodyCompression(t) {
    return t.endObject();
  }
  static createBodyCompression(t, n, i) {
    return bo.startBodyCompression(t), bo.addCodec(t, n), bo.addMethod(t, i), bo.endBodyCompression(t);
  }
}, PI = class {
  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, i) {
    return t.prep(8, 16), t.writeInt64(BigInt(i ?? 0)), t.writeInt64(BigInt(n ?? 0)), t.offset();
  }
}, VI = 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, i) {
    return t.prep(8, 16), t.writeInt64(BigInt(i ?? 0)), t.writeInt64(BigInt(n ?? 0)), t.offset();
  }
}, Er = class gg {
  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 gg()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsRecordBatch(t, n) {
    return t.setPosition(t.position() + nt), (n || new gg()).__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 i = this.bb.__offset(this.bb_pos, 6);
    return i ? (n || new VI()).__init(this.bb.__vector(this.bb_pos + i) + 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 i = this.bb.__offset(this.bb_pos, 8);
    return i ? (n || new PI()).__init(this.bb.__vector(this.bb_pos + i) + 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 YC()).__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();
  }
}, Ta = class bg {
  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 bg()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDictionaryBatch(t, n) {
    return t.setPosition(t.position() + nt), (n || new bg()).__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 Er()).__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 xc;
(function(e) {
  e[e.Little = 0] = "Little", e[e.Big = 1] = "Big";
})(xc || (xc = {}));
var _d;
(function(e) {
  e[e.DenseArray = 0] = "DenseArray";
})(_d || (_d = {}));
let Ha = class wo {
  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 wo()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsInt(t, n) {
    return t.setPosition(t.position() + nt), (n || new wo()).__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, i) {
    return wo.startInt(t), wo.addBitWidth(t, n), wo.addIsSigned(t, i), wo.endInt(t);
  }
}, Da = class wg {
  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 wg()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDictionaryEncoding(t, n) {
    return t.setPosition(t.position() + nt), (n || new wg()).__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 Ha()).__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) : _d.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, _d.DenseArray);
  }
  static endDictionaryEncoding(t) {
    return t.endObject();
  }
}, ni = class vo {
  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 vo()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsKeyValue(t, n) {
    return t.setPosition(t.position() + nt), (n || new vo()).__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, i) {
    return vo.startKeyValue(t), vo.addKey(t, n), vo.addValue(t, i), vo.endKeyValue(t);
  }
}, B_ = class El {
  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 El()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsBinary(t, n) {
    return t.setPosition(t.position() + nt), (n || new El()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startBinary(t) {
    t.startObject(0);
  }
  static endBinary(t) {
    return t.endObject();
  }
  static createBinary(t) {
    return El.startBinary(t), El.endBinary(t);
  }
}, O_ = class Ll {
  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 Ll()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsBool(t, n) {
    return t.setPosition(t.position() + nt), (n || new Ll()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startBool(t) {
    t.startObject(0);
  }
  static endBool(t) {
    return t.endObject();
  }
  static createBool(t) {
    return Ll.startBool(t), Ll.endBool(t);
  }
}, zh = class Na {
  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 Na()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDate(t, n) {
    return t.setPosition(t.position() + nt), (n || new Na()).__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) : Ii.MILLISECOND;
  }
  static startDate(t) {
    t.startObject(1);
  }
  static addUnit(t, n) {
    t.addFieldInt16(0, n, Ii.MILLISECOND);
  }
  static endDate(t) {
    return t.endObject();
  }
  static createDate(t, n) {
    return Na.startDate(t), Na.addUnit(t, n), Na.endDate(t);
  }
}, Ba = class vs {
  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 vs()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDecimal(t, n) {
    return t.setPosition(t.position() + nt), (n || new vs()).__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, i, r) {
    return vs.startDecimal(t), vs.addPrecision(t, n), vs.addScale(t, i), vs.addBitWidth(t, r), vs.endDecimal(t);
  }
}, Ph = class Oa {
  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 Oa()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDuration(t, n) {
    return t.setPosition(t.position() + nt), (n || new Oa()).__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) : mt.MILLISECOND;
  }
  static startDuration(t) {
    t.startObject(1);
  }
  static addUnit(t, n) {
    t.addFieldInt16(0, n, mt.MILLISECOND);
  }
  static endDuration(t) {
    return t.endObject();
  }
  static createDuration(t, n) {
    return Oa.startDuration(t), Oa.addUnit(t, n), Oa.endDuration(t);
  }
}, Vh = class Fa {
  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 Fa()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFixedSizeBinary(t, n) {
    return t.setPosition(t.position() + nt), (n || new Fa()).__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 Fa.startFixedSizeBinary(t), Fa.addByteWidth(t, n), Fa.endFixedSizeBinary(t);
  }
}, jh = class Ea {
  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 Ea()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFixedSizeList(t, n) {
    return t.setPosition(t.position() + nt), (n || new Ea()).__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 Ea.startFixedSizeList(t), Ea.addListSize(t, n), Ea.endFixedSizeList(t);
  }
}, qh = class La {
  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 La()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFloatingPoint(t, n) {
    return t.setPosition(t.position() + nt), (n || new La()).__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) : nn.HALF;
  }
  static startFloatingPoint(t) {
    t.startObject(1);
  }
  static addPrecision(t, n) {
    t.addFieldInt16(0, n, nn.HALF);
  }
  static endFloatingPoint(t) {
    return t.endObject();
  }
  static createFloatingPoint(t, n) {
    return La.startFloatingPoint(t), La.addPrecision(t, n), La.endFloatingPoint(t);
  }
}, Yh = class Ra {
  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 Ra()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsInterval(t, n) {
    return t.setPosition(t.position() + nt), (n || new Ra()).__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) : lr.YEAR_MONTH;
  }
  static startInterval(t) {
    t.startObject(1);
  }
  static addUnit(t, n) {
    t.addFieldInt16(0, n, lr.YEAR_MONTH);
  }
  static endInterval(t) {
    return t.endObject();
  }
  static createInterval(t, n) {
    return Ra.startInterval(t), Ra.addUnit(t, n), Ra.endInterval(t);
  }
}, F_ = class Rl {
  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 Rl()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsLargeBinary(t, n) {
    return t.setPosition(t.position() + nt), (n || new Rl()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startLargeBinary(t) {
    t.startObject(0);
  }
  static endLargeBinary(t) {
    return t.endObject();
  }
  static createLargeBinary(t) {
    return Rl.startLargeBinary(t), Rl.endLargeBinary(t);
  }
}, E_ = class Cl {
  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 Cl()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsLargeUtf8(t, n) {
    return t.setPosition(t.position() + nt), (n || new Cl()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startLargeUtf8(t) {
    t.startObject(0);
  }
  static endLargeUtf8(t) {
    return t.endObject();
  }
  static createLargeUtf8(t) {
    return Cl.startLargeUtf8(t), Cl.endLargeUtf8(t);
  }
}, L_ = class kl {
  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 kl()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsList(t, n) {
    return t.setPosition(t.position() + nt), (n || new kl()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startList(t) {
    t.startObject(0);
  }
  static endList(t) {
    return t.endObject();
  }
  static createList(t) {
    return kl.startList(t), kl.endList(t);
  }
}, Wh = class Ca {
  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 Ca()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsMap(t, n) {
    return t.setPosition(t.position() + nt), (n || new Ca()).__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 Ca.startMap(t), Ca.addKeysSorted(t, n), Ca.endMap(t);
  }
}, R_ = class Ul {
  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 Ul()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsNull(t, n) {
    return t.setPosition(t.position() + nt), (n || new Ul()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startNull(t) {
    t.startObject(0);
  }
  static endNull(t) {
    return t.endObject();
  }
  static createNull(t) {
    return Ul.startNull(t), Ul.endNull(t);
  }
}, C_ = class zl {
  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 zl()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsStruct_(t, n) {
    return t.setPosition(t.position() + nt), (n || new zl()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startStruct_(t) {
    t.startObject(0);
  }
  static endStruct_(t) {
    return t.endObject();
  }
  static createStruct_(t) {
    return zl.startStruct_(t), zl.endStruct_(t);
  }
}, Pl = class _o {
  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 _o()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsTime(t, n) {
    return t.setPosition(t.position() + nt), (n || new _o()).__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) : mt.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, mt.MILLISECOND);
  }
  static addBitWidth(t, n) {
    t.addFieldInt32(1, n, 32);
  }
  static endTime(t) {
    return t.endObject();
  }
  static createTime(t, n, i) {
    return _o.startTime(t), _o.addUnit(t, n), _o.addBitWidth(t, i), _o.endTime(t);
  }
}, Vl = class xo {
  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 xo()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsTimestamp(t, n) {
    return t.setPosition(t.position() + nt), (n || new xo()).__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) : mt.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, mt.SECOND);
  }
  static addTimezone(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static endTimestamp(t) {
    return t.endObject();
  }
  static createTimestamp(t, n, i) {
    return xo.startTimestamp(t), xo.addUnit(t, n), xo.addTimezone(t, i), xo.endTimestamp(t);
  }
}, So = class Io {
  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 Io()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsUnion(t, n) {
    return t.setPosition(t.position() + nt), (n || new Io()).__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) : Mn.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, Mn.Sparse);
  }
  static addTypeIds(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static createTypeIdsVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let i = n.length - 1; i >= 0; i--)
      t.addInt32(n[i]);
    return t.endVector();
  }
  static startTypeIdsVector(t, n) {
    t.startVector(4, n, 4);
  }
  static endUnion(t) {
    return t.endObject();
  }
  static createUnion(t, n, i) {
    return Io.startUnion(t), Io.addMode(t, n), Io.addTypeIds(t, i), Io.endUnion(t);
  }
}, k_ = class jl {
  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 jl()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsUtf8(t, n) {
    return t.setPosition(t.position() + nt), (n || new jl()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startUtf8(t) {
    t.startObject(0);
  }
  static endUtf8(t) {
    return t.endObject();
  }
  static createUtf8(t) {
    return jl.startUtf8(t), jl.endUtf8(t);
  }
};
var he;
(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";
})(he || (he = {}));
let Gn = class Gh {
  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 Gh()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsField(t, n) {
    return t.setPosition(t.position() + nt), (n || new Gh()).__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) : he.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 Da()).__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 i = this.bb.__offset(this.bb_pos, 14);
    return i ? (n || new Gh()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + i) + 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 i = this.bb.__offset(this.bb_pos, 16);
    return i ? (n || new ni()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + i) + 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, he.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 i = n.length - 1; i >= 0; i--)
      t.addOffset(n[i]);
    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 i = n.length - 1; i >= 0; i--)
      t.addOffset(n[i]);
    return t.endVector();
  }
  static startCustomMetadataVector(t, n) {
    t.startVector(4, n, 4);
  }
  static endField(t) {
    return t.endObject();
  }
}, Yi = class Tr {
  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 Tr()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsSchema(t, n) {
    return t.setPosition(t.position() + nt), (n || new Tr()).__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) : xc.Little;
  }
  fields(t, n) {
    const i = this.bb.__offset(this.bb_pos, 6);
    return i ? (n || new Gn()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + i) + 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 i = this.bb.__offset(this.bb_pos, 8);
    return i ? (n || new ni()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + i) + 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, xc.Little);
  }
  static addFields(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static createFieldsVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let i = n.length - 1; i >= 0; i--)
      t.addOffset(n[i]);
    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 i = n.length - 1; i >= 0; i--)
      t.addOffset(n[i]);
    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 i = n.length - 1; i >= 0; i--)
      t.addInt64(n[i]);
    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, i, r, s) {
    return Tr.startSchema(t), Tr.addEndianness(t, n), Tr.addFields(t, i), Tr.addCustomMetadata(t, r), Tr.addFeatures(t, s), Tr.endSchema(t);
  }
};
var Qt;
(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";
})(Qt || (Qt = {}));
var F;
(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";
})(F || (F = {}));
var Lr;
(function(e) {
  e[e.OFFSET = 0] = "OFFSET", e[e.DATA = 1] = "DATA", e[e.VALIDITY = 2] = "VALIDITY", e[e.TYPE = 3] = "TYPE";
})(Lr || (Lr = {}));
const WC = void 0;
function _u(e) {
  if (e === null)
    return "null";
  if (e === WC)
    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) => _u(t))}]` : `[${e}]` : ArrayBuffer.isView(e) ? `[${e}]` : JSON.stringify(e, (t, n) => typeof n == "bigint" ? `${n}` : n);
}
const GC = Symbol.for("isArrowBigNum");
function Ei(e, ...t) {
  return t.length === 0 ? Object.setPrototypeOf(re(this.TypedArray, e), this.constructor.prototype) : Object.setPrototypeOf(new this.TypedArray(e, ...t), this.constructor.prototype);
}
Ei.prototype[GC] = !0;
Ei.prototype.toJSON = function() {
  return `"${Su(this)}"`;
};
Ei.prototype.valueOf = function() {
  return jI(this);
};
Ei.prototype.toString = function() {
  return Su(this);
};
Ei.prototype[Symbol.toPrimitive] = function(e = "default") {
  switch (e) {
    case "number":
      return jI(this);
    case "string":
      return Su(this);
    case "default":
      return XC(this);
  }
  return Su(this);
};
function sc(...e) {
  return Ei.apply(this, e);
}
function oc(...e) {
  return Ei.apply(this, e);
}
function xu(...e) {
  return Ei.apply(this, e);
}
Object.setPrototypeOf(sc.prototype, Object.create(Int32Array.prototype));
Object.setPrototypeOf(oc.prototype, Object.create(Uint32Array.prototype));
Object.setPrototypeOf(xu.prototype, Object.create(Uint32Array.prototype));
Object.assign(sc.prototype, Ei.prototype, { constructor: sc, signed: !0, TypedArray: Int32Array, BigIntArray: BigInt64Array });
Object.assign(oc.prototype, Ei.prototype, { constructor: oc, signed: !1, TypedArray: Uint32Array, BigIntArray: BigUint64Array });
Object.assign(xu.prototype, Ei.prototype, { constructor: xu, signed: !0, TypedArray: Uint32Array, BigIntArray: BigUint64Array });
function jI(e) {
  const { buffer: t, byteOffset: n, length: i, signed: r } = e, s = new BigUint64Array(t, n, i), o = r && s.at(-1) & BigInt(1) << BigInt(63);
  let a = BigInt(o ? 1 : 0), c = BigInt(0);
  if (o) {
    for (const l of s)
      a += ~l * (BigInt(1) << BigInt(32) * c++);
    a *= BigInt(-1);
  } else
    for (const l of s)
      a += l * (BigInt(1) << BigInt(32) * c++);
  return a;
}
const Su = (e) => {
  if (e.byteLength === 8)
    return `${new e.BigIntArray(e.buffer, e.byteOffset, 1)[0]}`;
  if (!e.signed)
    return nm(e);
  let t = new Uint16Array(e.buffer, e.byteOffset, e.byteLength / 2);
  if (new Int16Array([t.at(-1)])[0] >= 0)
    return nm(e);
  t = t.slice();
  let i = 1;
  for (let s = 0; s < t.length; s++) {
    const o = t[s], a = ~o + i;
    t[s] = a, i &= o === 0 ? 1 : 0;
  }
  return `-${nm(t)}`;
}, XC = (e) => e.byteLength === 8 ? new e.BigIntArray(e.buffer, e.byteOffset, 1)[0] : Su(e);
function nm(e) {
  let t = "";
  const n = new Uint32Array(2);
  let i = new Uint16Array(e.buffer, e.byteOffset, e.byteLength / 2);
  const r = new Uint32Array((i = new Uint16Array(i).reverse()).buffer);
  let s = -1;
  const o = i.length - 1;
  do {
    for (n[0] = i[s = 0]; s < o; )
      i[s++] = n[1] = n[0] / 10, n[0] = (n[0] - n[1] * 10 << 16) + i[s];
    i[s] = n[1] = n[0] / 10, n[0] = n[0] - n[1] * 10, t = `${n[0]}${t}`;
  } while (r[0] || r[1] || r[2] || r[3]);
  return t ?? "0";
}
let HC = class qI {
  /** @nocollapse */
  static new(t, n) {
    switch (n) {
      case !0:
        return new sc(t);
      case !1:
        return new oc(t);
    }
    switch (t.constructor) {
      case Int8Array:
      case Int16Array:
      case Int32Array:
      case BigInt64Array:
        return new sc(t);
    }
    return t.byteLength === 16 ? new xu(t) : new oc(t);
  }
  /** @nocollapse */
  static signed(t) {
    return new sc(t);
  }
  /** @nocollapse */
  static unsigned(t) {
    return new oc(t);
  }
  /** @nocollapse */
  static decimal(t) {
    return new xu(t);
  }
  constructor(t, n) {
    return qI.new(t, n);
  }
};
function pn(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);
}
var YI, WI, GI, XI, HI, JI, KI, ZI, QI, tA, eA, nA, iA, rA, sA, oA, aA, cA, lA, uA, fA, hA;
let gt = class vg {
  /** @nocollapse */
  static isNull(t) {
    return (t == null ? void 0 : t.typeId) === F.Null;
  }
  /** @nocollapse */
  static isInt(t) {
    return (t == null ? void 0 : t.typeId) === F.Int;
  }
  /** @nocollapse */
  static isFloat(t) {
    return (t == null ? void 0 : t.typeId) === F.Float;
  }
  /** @nocollapse */
  static isBinary(t) {
    return (t == null ? void 0 : t.typeId) === F.Binary;
  }
  /** @nocollapse */
  static isLargeBinary(t) {
    return (t == null ? void 0 : t.typeId) === F.LargeBinary;
  }
  /** @nocollapse */
  static isUtf8(t) {
    return (t == null ? void 0 : t.typeId) === F.Utf8;
  }
  /** @nocollapse */
  static isLargeUtf8(t) {
    return (t == null ? void 0 : t.typeId) === F.LargeUtf8;
  }
  /** @nocollapse */
  static isBool(t) {
    return (t == null ? void 0 : t.typeId) === F.Bool;
  }
  /** @nocollapse */
  static isDecimal(t) {
    return (t == null ? void 0 : t.typeId) === F.Decimal;
  }
  /** @nocollapse */
  static isDate(t) {
    return (t == null ? void 0 : t.typeId) === F.Date;
  }
  /** @nocollapse */
  static isTime(t) {
    return (t == null ? void 0 : t.typeId) === F.Time;
  }
  /** @nocollapse */
  static isTimestamp(t) {
    return (t == null ? void 0 : t.typeId) === F.Timestamp;
  }
  /** @nocollapse */
  static isInterval(t) {
    return (t == null ? void 0 : t.typeId) === F.Interval;
  }
  /** @nocollapse */
  static isDuration(t) {
    return (t == null ? void 0 : t.typeId) === F.Duration;
  }
  /** @nocollapse */
  static isList(t) {
    return (t == null ? void 0 : t.typeId) === F.List;
  }
  /** @nocollapse */
  static isStruct(t) {
    return (t == null ? void 0 : t.typeId) === F.Struct;
  }
  /** @nocollapse */
  static isUnion(t) {
    return (t == null ? void 0 : t.typeId) === F.Union;
  }
  /** @nocollapse */
  static isFixedSizeBinary(t) {
    return (t == null ? void 0 : t.typeId) === F.FixedSizeBinary;
  }
  /** @nocollapse */
  static isFixedSizeList(t) {
    return (t == null ? void 0 : t.typeId) === F.FixedSizeList;
  }
  /** @nocollapse */
  static isMap(t) {
    return (t == null ? void 0 : t.typeId) === F.Map;
  }
  /** @nocollapse */
  static isDictionary(t) {
    return (t == null ? void 0 : t.typeId) === F.Dictionary;
  }
  /** @nocollapse */
  static isDenseUnion(t) {
    return vg.isUnion(t) && t.mode === Mn.Dense;
  }
  /** @nocollapse */
  static isSparseUnion(t) {
    return vg.isUnion(t) && t.mode === Mn.Sparse;
  }
  constructor(t) {
    this.typeId = t;
  }
};
YI = Symbol.toStringTag;
gt[YI] = ((e) => (e.children = null, e.ArrayType = Array, e.OffsetArrayType = Int32Array, e[Symbol.toStringTag] = "DataType"))(gt.prototype);
let Us = class extends gt {
  constructor() {
    super(F.Null);
  }
  toString() {
    return "Null";
  }
};
WI = Symbol.toStringTag;
Us[WI] = ((e) => e[Symbol.toStringTag] = "Null")(Us.prototype);
let zs = class extends gt {
  constructor(t, n) {
    super(F.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}`;
  }
};
GI = Symbol.toStringTag;
zs[GI] = ((e) => (e.isSigned = null, e.bitWidth = null, e[Symbol.toStringTag] = "Int"))(zs.prototype);
let Iu = class extends zs {
  constructor() {
    super(!0, 32);
  }
  get ArrayType() {
    return Int32Array;
  }
};
Object.defineProperty(Iu.prototype, "ArrayType", { value: Int32Array });
let Au = class extends gt {
  constructor(t) {
    super(F.Float), this.precision = t;
  }
  get ArrayType() {
    switch (this.precision) {
      case nn.HALF:
        return Uint16Array;
      case nn.SINGLE:
        return Float32Array;
      case nn.DOUBLE:
        return Float64Array;
    }
    throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);
  }
  toString() {
    return `Float${this.precision << 5 || 16}`;
  }
};
XI = Symbol.toStringTag;
Au[XI] = ((e) => (e.precision = null, e[Symbol.toStringTag] = "Float"))(Au.prototype);
let xd = class extends gt {
  constructor() {
    super(F.Binary);
  }
  toString() {
    return "Binary";
  }
};
HI = Symbol.toStringTag;
xd[HI] = ((e) => (e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "Binary"))(xd.prototype);
let Sd = class extends gt {
  constructor() {
    super(F.LargeBinary);
  }
  toString() {
    return "LargeBinary";
  }
};
JI = Symbol.toStringTag;
Sd[JI] = ((e) => (e.ArrayType = Uint8Array, e.OffsetArrayType = BigInt64Array, e[Symbol.toStringTag] = "LargeBinary"))(Sd.prototype);
let Id = class extends gt {
  constructor() {
    super(F.Utf8);
  }
  toString() {
    return "Utf8";
  }
};
KI = Symbol.toStringTag;
Id[KI] = ((e) => (e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "Utf8"))(Id.prototype);
let Ad = class extends gt {
  constructor() {
    super(F.LargeUtf8);
  }
  toString() {
    return "LargeUtf8";
  }
};
ZI = Symbol.toStringTag;
Ad[ZI] = ((e) => (e.ArrayType = Uint8Array, e.OffsetArrayType = BigInt64Array, e[Symbol.toStringTag] = "LargeUtf8"))(Ad.prototype);
let Md = class extends gt {
  constructor() {
    super(F.Bool);
  }
  toString() {
    return "Bool";
  }
};
QI = Symbol.toStringTag;
Md[QI] = ((e) => (e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "Bool"))(Md.prototype);
let $d = class extends gt {
  constructor(t, n, i = 128) {
    super(F.Decimal), this.scale = t, this.precision = n, this.bitWidth = i;
  }
  toString() {
    return `Decimal[${this.precision}e${this.scale > 0 ? "+" : ""}${this.scale}]`;
  }
};
tA = Symbol.toStringTag;
$d[tA] = ((e) => (e.scale = null, e.precision = null, e.ArrayType = Uint32Array, e[Symbol.toStringTag] = "Decimal"))($d.prototype);
let Td = class extends gt {
  constructor(t) {
    super(F.Date), this.unit = t;
  }
  toString() {
    return `Date${(this.unit + 1) * 32}<${Ii[this.unit]}>`;
  }
};
eA = Symbol.toStringTag;
Td[eA] = ((e) => (e.unit = null, e.ArrayType = Int32Array, e[Symbol.toStringTag] = "Date"))(Td.prototype);
let Mu = class extends gt {
  constructor(t, n) {
    super(F.Time), this.unit = t, this.bitWidth = n;
  }
  toString() {
    return `Time${this.bitWidth}<${mt[this.unit]}>`;
  }
  get ArrayType() {
    switch (this.bitWidth) {
      case 32:
        return Int32Array;
      case 64:
        return BigInt64Array;
    }
    throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);
  }
};
nA = Symbol.toStringTag;
Mu[nA] = ((e) => (e.unit = null, e.bitWidth = null, e[Symbol.toStringTag] = "Time"))(Mu.prototype);
let Dd = class extends gt {
  constructor(t, n) {
    super(F.Timestamp), this.unit = t, this.timezone = n;
  }
  toString() {
    return `Timestamp<${mt[this.unit]}${this.timezone ? `, ${this.timezone}` : ""}>`;
  }
};
iA = Symbol.toStringTag;
Dd[iA] = ((e) => (e.unit = null, e.timezone = null, e.ArrayType = Int32Array, e[Symbol.toStringTag] = "Timestamp"))(Dd.prototype);
let Nd = class extends gt {
  constructor(t) {
    super(F.Interval), this.unit = t;
  }
  toString() {
    return `Interval<${lr[this.unit]}>`;
  }
};
rA = Symbol.toStringTag;
Nd[rA] = ((e) => (e.unit = null, e.ArrayType = Int32Array, e[Symbol.toStringTag] = "Interval"))(Nd.prototype);
let Bd = class extends gt {
  constructor(t) {
    super(F.Duration), this.unit = t;
  }
  toString() {
    return `Duration<${mt[this.unit]}>`;
  }
};
sA = Symbol.toStringTag;
Bd[sA] = ((e) => (e.unit = null, e.ArrayType = BigInt64Array, e[Symbol.toStringTag] = "Duration"))(Bd.prototype);
let Od = class extends gt {
  constructor(t) {
    super(F.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;
  }
};
oA = Symbol.toStringTag;
Od[oA] = ((e) => (e.children = null, e[Symbol.toStringTag] = "List"))(Od.prototype);
let fn = class extends gt {
  constructor(t) {
    super(F.Struct), this.children = t;
  }
  toString() {
    return `Struct<{${this.children.map((t) => `${t.name}:${t.type}`).join(", ")}}>`;
  }
};
aA = Symbol.toStringTag;
fn[aA] = ((e) => (e.children = null, e[Symbol.toStringTag] = "Struct"))(fn.prototype);
let Fd = class extends gt {
  constructor(t, n, i) {
    super(F.Union), this.mode = t, this.children = i, this.typeIds = n = Int32Array.from(n), this.typeIdToChildIndex = n.reduce((r, s, o) => (r[s] = o) && r || r, /* @__PURE__ */ Object.create(null));
  }
  toString() {
    return `${this[Symbol.toStringTag]}<${this.children.map((t) => `${t.type}`).join(" | ")}>`;
  }
};
cA = Symbol.toStringTag;
Fd[cA] = ((e) => (e.mode = null, e.typeIds = null, e.children = null, e.typeIdToChildIndex = null, e.ArrayType = Int8Array, e[Symbol.toStringTag] = "Union"))(Fd.prototype);
let Ed = class extends gt {
  constructor(t) {
    super(F.FixedSizeBinary), this.byteWidth = t;
  }
  toString() {
    return `FixedSizeBinary[${this.byteWidth}]`;
  }
};
lA = Symbol.toStringTag;
Ed[lA] = ((e) => (e.byteWidth = null, e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "FixedSizeBinary"))(Ed.prototype);
let Ld = class extends gt {
  constructor(t, n) {
    super(F.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}>`;
  }
};
uA = Symbol.toStringTag;
Ld[uA] = ((e) => (e.children = null, e.listSize = null, e[Symbol.toStringTag] = "FixedSizeList"))(Ld.prototype);
let Rd = class extends gt {
  constructor(t, n = !1) {
    var i, r, s;
    if (super(F.Map), this.children = [t], this.keysSorted = n, t && (t.name = "entries", !((i = t == null ? void 0 : t.type) === null || i === void 0) && i.children)) {
      const o = (r = t == null ? void 0 : t.type) === null || r === void 0 ? void 0 : r.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(", ")}}>`;
  }
};
fA = Symbol.toStringTag;
Rd[fA] = ((e) => (e.children = null, e.keysSorted = null, e[Symbol.toStringTag] = "Map_"))(Rd.prototype);
const JC = /* @__PURE__ */ ((e) => () => ++e)(-1);
let Sc = class extends gt {
  constructor(t, n, i, r) {
    super(F.Dictionary), this.indices = n, this.dictionary = t, this.isOrdered = r || !1, this.id = i == null ? JC() : pn(i);
  }
  get children() {
    return this.dictionary.children;
  }
  get valueType() {
    return this.dictionary;
  }
  get ArrayType() {
    return this.dictionary.ArrayType;
  }
  toString() {
    return `Dictionary<${this.indices}, ${this.dictionary}>`;
  }
};
hA = Symbol.toStringTag;
Sc[hA] = ((e) => (e.id = null, e.indices = null, e.isOrdered = null, e.dictionary = null, e[Symbol.toStringTag] = "Dictionary"))(Sc.prototype);
function Rr(e) {
  const t = e;
  switch (e.typeId) {
    case F.Decimal:
      return e.bitWidth / 32;
    case F.Timestamp:
      return 2;
    case F.Date:
      return 1 + t.unit;
    case F.Interval:
      return 1 + t.unit;
    case F.FixedSizeList:
      return t.listSize;
    case F.FixedSizeBinary:
      return t.byteWidth;
    default:
      return 1;
  }
}
let Ut = class {
  visitMany(t, ...n) {
    return t.map((i, r) => this.visit(i, ...n.map((s) => s[r])));
  }
  visit(...t) {
    return this.getVisitFn(t[0], !1).apply(this, t);
  }
  getVisitFn(t, n = !0) {
    return KC(this, t, n);
  }
  getVisitFnByTypeId(t, n = !0) {
    return ka(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 KC(e, t, n = !0) {
  return typeof t == "number" ? ka(e, t, n) : typeof t == "string" && t in F ? ka(e, F[t], n) : t && t instanceof gt ? ka(e, U_(t), n) : t != null && t.type && t.type instanceof gt ? ka(e, U_(t.type), n) : ka(e, F.NONE, n);
}
function ka(e, t, n = !0) {
  let i = null;
  switch (t) {
    case F.Null:
      i = e.visitNull;
      break;
    case F.Bool:
      i = e.visitBool;
      break;
    case F.Int:
      i = e.visitInt;
      break;
    case F.Int8:
      i = e.visitInt8 || e.visitInt;
      break;
    case F.Int16:
      i = e.visitInt16 || e.visitInt;
      break;
    case F.Int32:
      i = e.visitInt32 || e.visitInt;
      break;
    case F.Int64:
      i = e.visitInt64 || e.visitInt;
      break;
    case F.Uint8:
      i = e.visitUint8 || e.visitInt;
      break;
    case F.Uint16:
      i = e.visitUint16 || e.visitInt;
      break;
    case F.Uint32:
      i = e.visitUint32 || e.visitInt;
      break;
    case F.Uint64:
      i = e.visitUint64 || e.visitInt;
      break;
    case F.Float:
      i = e.visitFloat;
      break;
    case F.Float16:
      i = e.visitFloat16 || e.visitFloat;
      break;
    case F.Float32:
      i = e.visitFloat32 || e.visitFloat;
      break;
    case F.Float64:
      i = e.visitFloat64 || e.visitFloat;
      break;
    case F.Utf8:
      i = e.visitUtf8;
      break;
    case F.LargeUtf8:
      i = e.visitLargeUtf8;
      break;
    case F.Binary:
      i = e.visitBinary;
      break;
    case F.LargeBinary:
      i = e.visitLargeBinary;
      break;
    case F.FixedSizeBinary:
      i = e.visitFixedSizeBinary;
      break;
    case F.Date:
      i = e.visitDate;
      break;
    case F.DateDay:
      i = e.visitDateDay || e.visitDate;
      break;
    case F.DateMillisecond:
      i = e.visitDateMillisecond || e.visitDate;
      break;
    case F.Timestamp:
      i = e.visitTimestamp;
      break;
    case F.TimestampSecond:
      i = e.visitTimestampSecond || e.visitTimestamp;
      break;
    case F.TimestampMillisecond:
      i = e.visitTimestampMillisecond || e.visitTimestamp;
      break;
    case F.TimestampMicrosecond:
      i = e.visitTimestampMicrosecond || e.visitTimestamp;
      break;
    case F.TimestampNanosecond:
      i = e.visitTimestampNanosecond || e.visitTimestamp;
      break;
    case F.Time:
      i = e.visitTime;
      break;
    case F.TimeSecond:
      i = e.visitTimeSecond || e.visitTime;
      break;
    case F.TimeMillisecond:
      i = e.visitTimeMillisecond || e.visitTime;
      break;
    case F.TimeMicrosecond:
      i = e.visitTimeMicrosecond || e.visitTime;
      break;
    case F.TimeNanosecond:
      i = e.visitTimeNanosecond || e.visitTime;
      break;
    case F.Decimal:
      i = e.visitDecimal;
      break;
    case F.List:
      i = e.visitList;
      break;
    case F.Struct:
      i = e.visitStruct;
      break;
    case F.Union:
      i = e.visitUnion;
      break;
    case F.DenseUnion:
      i = e.visitDenseUnion || e.visitUnion;
      break;
    case F.SparseUnion:
      i = e.visitSparseUnion || e.visitUnion;
      break;
    case F.Dictionary:
      i = e.visitDictionary;
      break;
    case F.Interval:
      i = e.visitInterval;
      break;
    case F.IntervalDayTime:
      i = e.visitIntervalDayTime || e.visitInterval;
      break;
    case F.IntervalYearMonth:
      i = e.visitIntervalYearMonth || e.visitInterval;
      break;
    case F.Duration:
      i = e.visitDuration;
      break;
    case F.DurationSecond:
      i = e.visitDurationSecond || e.visitDuration;
      break;
    case F.DurationMillisecond:
      i = e.visitDurationMillisecond || e.visitDuration;
      break;
    case F.DurationMicrosecond:
      i = e.visitDurationMicrosecond || e.visitDuration;
      break;
    case F.DurationNanosecond:
      i = e.visitDurationNanosecond || e.visitDuration;
      break;
    case F.FixedSizeList:
      i = e.visitFixedSizeList;
      break;
    case F.Map:
      i = e.visitMap;
      break;
  }
  if (typeof i == "function")
    return i;
  if (!n)
    return () => null;
  throw new Error(`Unrecognized type '${F[t]}'`);
}
function U_(e) {
  switch (e.typeId) {
    case F.Null:
      return F.Null;
    case F.Int: {
      const { bitWidth: t, isSigned: n } = e;
      switch (t) {
        case 8:
          return n ? F.Int8 : F.Uint8;
        case 16:
          return n ? F.Int16 : F.Uint16;
        case 32:
          return n ? F.Int32 : F.Uint32;
        case 64:
          return n ? F.Int64 : F.Uint64;
      }
      return F.Int;
    }
    case F.Float:
      switch (e.precision) {
        case nn.HALF:
          return F.Float16;
        case nn.SINGLE:
          return F.Float32;
        case nn.DOUBLE:
          return F.Float64;
      }
      return F.Float;
    case F.Binary:
      return F.Binary;
    case F.LargeBinary:
      return F.LargeBinary;
    case F.Utf8:
      return F.Utf8;
    case F.LargeUtf8:
      return F.LargeUtf8;
    case F.Bool:
      return F.Bool;
    case F.Decimal:
      return F.Decimal;
    case F.Time:
      switch (e.unit) {
        case mt.SECOND:
          return F.TimeSecond;
        case mt.MILLISECOND:
          return F.TimeMillisecond;
        case mt.MICROSECOND:
          return F.TimeMicrosecond;
        case mt.NANOSECOND:
          return F.TimeNanosecond;
      }
      return F.Time;
    case F.Timestamp:
      switch (e.unit) {
        case mt.SECOND:
          return F.TimestampSecond;
        case mt.MILLISECOND:
          return F.TimestampMillisecond;
        case mt.MICROSECOND:
          return F.TimestampMicrosecond;
        case mt.NANOSECOND:
          return F.TimestampNanosecond;
      }
      return F.Timestamp;
    case F.Date:
      switch (e.unit) {
        case Ii.DAY:
          return F.DateDay;
        case Ii.MILLISECOND:
          return F.DateMillisecond;
      }
      return F.Date;
    case F.Interval:
      switch (e.unit) {
        case lr.DAY_TIME:
          return F.IntervalDayTime;
        case lr.YEAR_MONTH:
          return F.IntervalYearMonth;
      }
      return F.Interval;
    case F.Duration:
      switch (e.unit) {
        case mt.SECOND:
          return F.DurationSecond;
        case mt.MILLISECOND:
          return F.DurationMillisecond;
        case mt.MICROSECOND:
          return F.DurationMicrosecond;
        case mt.NANOSECOND:
          return F.DurationNanosecond;
      }
      return F.Duration;
    case F.Map:
      return F.Map;
    case F.List:
      return F.List;
    case F.Struct:
      return F.Struct;
    case F.Union:
      switch (e.mode) {
        case Mn.Dense:
          return F.DenseUnion;
        case Mn.Sparse:
          return F.SparseUnion;
      }
      return F.Union;
    case F.FixedSizeBinary:
      return F.FixedSizeBinary;
    case F.FixedSizeList:
      return F.FixedSizeList;
    case F.Dictionary:
      return F.Dictionary;
  }
  throw new Error(`Unrecognized type '${F[e.typeId]}'`);
}
Ut.prototype.visitInt8 = null;
Ut.prototype.visitInt16 = null;
Ut.prototype.visitInt32 = null;
Ut.prototype.visitInt64 = null;
Ut.prototype.visitUint8 = null;
Ut.prototype.visitUint16 = null;
Ut.prototype.visitUint32 = null;
Ut.prototype.visitUint64 = null;
Ut.prototype.visitFloat16 = null;
Ut.prototype.visitFloat32 = null;
Ut.prototype.visitFloat64 = null;
Ut.prototype.visitDateDay = null;
Ut.prototype.visitDateMillisecond = null;
Ut.prototype.visitTimestampSecond = null;
Ut.prototype.visitTimestampMillisecond = null;
Ut.prototype.visitTimestampMicrosecond = null;
Ut.prototype.visitTimestampNanosecond = null;
Ut.prototype.visitTimeSecond = null;
Ut.prototype.visitTimeMillisecond = null;
Ut.prototype.visitTimeMicrosecond = null;
Ut.prototype.visitTimeNanosecond = null;
Ut.prototype.visitDenseUnion = null;
Ut.prototype.visitSparseUnion = null;
Ut.prototype.visitIntervalDayTime = null;
Ut.prototype.visitIntervalYearMonth = null;
Ut.prototype.visitDuration = null;
Ut.prototype.visitDurationSecond = null;
Ut.prototype.visitDurationMillisecond = null;
Ut.prototype.visitDurationMicrosecond = null;
Ut.prototype.visitDurationNanosecond = null;
const dA = new Float64Array(1), ya = new Uint32Array(dA.buffer);
function pA(e) {
  const t = (e & 31744) >> 10, n = (e & 1023) / 1024, i = Math.pow(-1, (e & 32768) >> 15);
  switch (t) {
    case 31:
      return i * (n ? Number.NaN : 1 / 0);
    case 0:
      return i * (n ? 6103515625e-14 * n : 0);
  }
  return i * Math.pow(2, t - 15) * (1 + n);
}
function ZC(e) {
  if (e !== e)
    return 32256;
  dA[0] = e;
  const t = (ya[1] & 2147483648) >> 16 & 65535;
  let n = ya[1] & 2146435072, i = 0;
  return n >= 1089470464 ? ya[0] > 0 ? n = 31744 : (n = (n & 2080374784) >> 16, i = (ya[1] & 1048575) >> 10) : n <= 1056964608 ? (i = 1048576 + (ya[1] & 1048575), i = 1048576 + (i << (n >> 20) - 998) >> 21, n = 0) : (n = n - 1056964608 >> 10, i = (ya[1] & 1048575) + 512 >> 10), t | n | i & 65535;
}
let vt = class extends Ut {
};
function Dt(e) {
  return (t, n, i) => {
    if (t.setValid(n, i != null))
      return e(t, n, i);
  };
}
const QC = (e, t, n) => {
  e[t] = Math.trunc(n / 864e5);
}, yb = (e, t, n) => {
  e[t] = Math.trunc(n % 4294967296), e[t + 1] = Math.trunc(n / 4294967296);
}, tk = (e, t, n) => {
  e[t] = Math.trunc(n * 1e3 % 4294967296), e[t + 1] = Math.trunc(n * 1e3 / 4294967296);
}, ek = (e, t, n) => {
  e[t] = Math.trunc(n * 1e6 % 4294967296), e[t + 1] = Math.trunc(n * 1e6 / 4294967296);
}, yA = (e, t, n, i) => {
  if (n + 1 < t.length) {
    const r = pn(t[n]), s = pn(t[n + 1]);
    e.set(i.subarray(0, s - r), r);
  }
}, nk = ({ offset: e, values: t }, n, i) => {
  const r = e + n;
  i ? t[r >> 3] |= 1 << r % 8 : t[r >> 3] &= ~(1 << r % 8);
}, os = ({ values: e }, t, n) => {
  e[t] = n;
}, mb = ({ values: e }, t, n) => {
  e[t] = n;
}, mA = ({ values: e }, t, n) => {
  e[t] = ZC(n);
}, ik = (e, t, n) => {
  switch (e.type.precision) {
    case nn.HALF:
      return mA(e, t, n);
    case nn.SINGLE:
    case nn.DOUBLE:
      return mb(e, t, n);
  }
}, gA = ({ values: e }, t, n) => {
  QC(e, t, n.valueOf());
}, bA = ({ values: e }, t, n) => {
  yb(e, t * 2, n.valueOf());
}, rk = ({ stride: e, values: t }, n, i) => {
  t.set(i.subarray(0, e), e * n);
}, wA = ({ values: e, valueOffsets: t }, n, i) => yA(e, t, n, i), vA = ({ values: e, valueOffsets: t }, n, i) => yA(e, t, n, fb(i)), sk = (e, t, n) => {
  e.type.unit === Ii.DAY ? gA(e, t, n) : bA(e, t, n);
}, _A = ({ values: e }, t, n) => yb(e, t * 2, n / 1e3), xA = ({ values: e }, t, n) => yb(e, t * 2, n), SA = ({ values: e }, t, n) => tk(e, t * 2, n), IA = ({ values: e }, t, n) => ek(e, t * 2, n), ok = (e, t, n) => {
  switch (e.type.unit) {
    case mt.SECOND:
      return _A(e, t, n);
    case mt.MILLISECOND:
      return xA(e, t, n);
    case mt.MICROSECOND:
      return SA(e, t, n);
    case mt.NANOSECOND:
      return IA(e, t, n);
  }
}, AA = ({ values: e }, t, n) => {
  e[t] = n;
}, MA = ({ values: e }, t, n) => {
  e[t] = n;
}, $A = ({ values: e }, t, n) => {
  e[t] = n;
}, TA = ({ values: e }, t, n) => {
  e[t] = n;
}, ak = (e, t, n) => {
  switch (e.type.unit) {
    case mt.SECOND:
      return AA(e, t, n);
    case mt.MILLISECOND:
      return MA(e, t, n);
    case mt.MICROSECOND:
      return $A(e, t, n);
    case mt.NANOSECOND:
      return TA(e, t, n);
  }
}, ck = ({ values: e, stride: t }, n, i) => {
  e.set(i.subarray(0, t), t * n);
}, lk = (e, t, n) => {
  const i = e.children[0], r = e.valueOffsets, s = ci.getVisitFn(i);
  if (Array.isArray(n))
    for (let o = -1, a = r[t], c = r[t + 1]; a < c; )
      s(i, a++, n[++o]);
  else
    for (let o = -1, a = r[t], c = r[t + 1]; a < c; )
      s(i, a++, n.get(++o));
}, uk = (e, t, n) => {
  const i = e.children[0], { valueOffsets: r } = e, s = ci.getVisitFn(i);
  let { [t]: o, [t + 1]: a } = r;
  const c = n instanceof Map ? n.entries() : Object.entries(n);
  for (const l of c)
    if (s(i, o, l), ++o >= a)
      break;
}, fk = (e, t) => (n, i, r, s) => i && n(i, e, t[s]), hk = (e, t) => (n, i, r, s) => i && n(i, e, t.get(s)), dk = (e, t) => (n, i, r, s) => i && n(i, e, t.get(r.name)), pk = (e, t) => (n, i, r, s) => i && n(i, e, t[r.name]), yk = (e, t, n) => {
  const i = e.type.children.map((s) => ci.getVisitFn(s.type)), r = n instanceof Map ? dk(t, n) : n instanceof Ne ? hk(t, n) : Array.isArray(n) ? fk(t, n) : pk(t, n);
  e.type.children.forEach((s, o) => r(i[o], e.children[o], s, o));
}, mk = (e, t, n) => {
  e.type.mode === Mn.Dense ? DA(e, t, n) : NA(e, t, n);
}, DA = (e, t, n) => {
  const i = e.type.typeIdToChildIndex[e.typeIds[t]], r = e.children[i];
  ci.visit(r, e.valueOffsets[t], n);
}, NA = (e, t, n) => {
  const i = e.type.typeIdToChildIndex[e.typeIds[t]], r = e.children[i];
  ci.visit(r, t, n);
}, gk = (e, t, n) => {
  var i;
  (i = e.dictionary) === null || i === void 0 || i.set(e.values[t], n);
}, bk = (e, t, n) => {
  e.type.unit === lr.DAY_TIME ? BA(e, t, n) : OA(e, t, n);
}, BA = ({ values: e }, t, n) => {
  e.set(n.subarray(0, 2), 2 * t);
}, OA = ({ values: e }, t, n) => {
  e[t] = n[0] * 12 + n[1] % 12;
}, FA = ({ values: e }, t, n) => {
  e[t] = n;
}, EA = ({ values: e }, t, n) => {
  e[t] = n;
}, LA = ({ values: e }, t, n) => {
  e[t] = n;
}, RA = ({ values: e }, t, n) => {
  e[t] = n;
}, wk = (e, t, n) => {
  switch (e.type.unit) {
    case mt.SECOND:
      return FA(e, t, n);
    case mt.MILLISECOND:
      return EA(e, t, n);
    case mt.MICROSECOND:
      return LA(e, t, n);
    case mt.NANOSECOND:
      return RA(e, t, n);
  }
}, vk = (e, t, n) => {
  const { stride: i } = e, r = e.children[0], s = ci.getVisitFn(r);
  if (Array.isArray(n))
    for (let o = -1, a = t * i; ++o < i; )
      s(r, a + o, n[o]);
  else
    for (let o = -1, a = t * i; ++o < i; )
      s(r, a + o, n.get(o));
};
vt.prototype.visitBool = Dt(nk);
vt.prototype.visitInt = Dt(os);
vt.prototype.visitInt8 = Dt(os);
vt.prototype.visitInt16 = Dt(os);
vt.prototype.visitInt32 = Dt(os);
vt.prototype.visitInt64 = Dt(os);
vt.prototype.visitUint8 = Dt(os);
vt.prototype.visitUint16 = Dt(os);
vt.prototype.visitUint32 = Dt(os);
vt.prototype.visitUint64 = Dt(os);
vt.prototype.visitFloat = Dt(ik);
vt.prototype.visitFloat16 = Dt(mA);
vt.prototype.visitFloat32 = Dt(mb);
vt.prototype.visitFloat64 = Dt(mb);
vt.prototype.visitUtf8 = Dt(vA);
vt.prototype.visitLargeUtf8 = Dt(vA);
vt.prototype.visitBinary = Dt(wA);
vt.prototype.visitLargeBinary = Dt(wA);
vt.prototype.visitFixedSizeBinary = Dt(rk);
vt.prototype.visitDate = Dt(sk);
vt.prototype.visitDateDay = Dt(gA);
vt.prototype.visitDateMillisecond = Dt(bA);
vt.prototype.visitTimestamp = Dt(ok);
vt.prototype.visitTimestampSecond = Dt(_A);
vt.prototype.visitTimestampMillisecond = Dt(xA);
vt.prototype.visitTimestampMicrosecond = Dt(SA);
vt.prototype.visitTimestampNanosecond = Dt(IA);
vt.prototype.visitTime = Dt(ak);
vt.prototype.visitTimeSecond = Dt(AA);
vt.prototype.visitTimeMillisecond = Dt(MA);
vt.prototype.visitTimeMicrosecond = Dt($A);
vt.prototype.visitTimeNanosecond = Dt(TA);
vt.prototype.visitDecimal = Dt(ck);
vt.prototype.visitList = Dt(lk);
vt.prototype.visitStruct = Dt(yk);
vt.prototype.visitUnion = Dt(mk);
vt.prototype.visitDenseUnion = Dt(DA);
vt.prototype.visitSparseUnion = Dt(NA);
vt.prototype.visitDictionary = Dt(gk);
vt.prototype.visitInterval = Dt(bk);
vt.prototype.visitIntervalDayTime = Dt(BA);
vt.prototype.visitIntervalYearMonth = Dt(OA);
vt.prototype.visitDuration = Dt(wk);
vt.prototype.visitDurationSecond = Dt(FA);
vt.prototype.visitDurationMillisecond = Dt(EA);
vt.prototype.visitDurationMicrosecond = Dt(LA);
vt.prototype.visitDurationNanosecond = Dt(RA);
vt.prototype.visitFixedSizeList = Dt(vk);
vt.prototype.visitMap = Dt(uk);
const ci = new vt(), pi = Symbol.for("parent"), ac = Symbol.for("rowIndex");
let gb = class {
  constructor(t, n) {
    return this[pi] = t, this[ac] = n, new Proxy(this, new xk());
  }
  toArray() {
    return Object.values(this.toJSON());
  }
  toJSON() {
    const t = this[ac], n = this[pi], i = n.type.children, r = {};
    for (let s = -1, o = i.length; ++s < o; )
      r[i[s].name] = $n.visit(n.children[s], t);
    return r;
  }
  toString() {
    return `{${[...this].map(([t, n]) => `${_u(t)}: ${_u(n)}`).join(", ")}}`;
  }
  [Symbol.for("nodejs.util.inspect.custom")]() {
    return this.toString();
  }
  [Symbol.iterator]() {
    return new _k(this[pi], this[ac]);
  }
}, _k = class {
  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,
        $n.visit(this.children[t], this.rowIndex)
      ]
    }) : { done: !0, value: null };
  }
};
Object.defineProperties(gb.prototype, {
  [Symbol.toStringTag]: { enumerable: !1, configurable: !1, value: "Row" },
  [pi]: { writable: !0, enumerable: !1, configurable: !1, value: null },
  [ac]: { writable: !0, enumerable: !1, configurable: !1, value: -1 }
});
let xk = class {
  isExtensible() {
    return !1;
  }
  deleteProperty() {
    return !1;
  }
  preventExtensions() {
    return !0;
  }
  ownKeys(t) {
    return t[pi].type.children.map((n) => n.name);
  }
  has(t, n) {
    return t[pi].type.children.findIndex((i) => i.name === n) !== -1;
  }
  getOwnPropertyDescriptor(t, n) {
    if (t[pi].type.children.findIndex((i) => i.name === n) !== -1)
      return { writable: !0, enumerable: !0, configurable: !0 };
  }
  get(t, n) {
    if (Reflect.has(t, n))
      return t[n];
    const i = t[pi].type.children.findIndex((r) => r.name === n);
    if (i !== -1) {
      const r = $n.visit(t[pi].children[i], t[ac]);
      return Reflect.set(t, n, r), r;
    }
  }
  set(t, n, i) {
    const r = t[pi].type.children.findIndex((s) => s.name === n);
    return r !== -1 ? (ci.visit(t[pi].children[r], t[ac], i), Reflect.set(t, n, i)) : Reflect.has(t, n) || typeof n == "symbol" ? Reflect.set(t, n, i) : !1;
  }
}, at = class extends Ut {
};
function _t(e) {
  return (t, n) => t.getValid(n) ? e(t, n) : null;
}
const Sk = (e, t) => 864e5 * e[t], bb = (e, t) => 4294967296 * e[t + 1] + (e[t] >>> 0), Ik = (e, t) => 4294967296 * (e[t + 1] / 1e3) + (e[t] >>> 0) / 1e3, Ak = (e, t) => 4294967296 * (e[t + 1] / 1e6) + (e[t] >>> 0) / 1e6, CA = (e) => new Date(e), Mk = (e, t) => CA(Sk(e, t)), $k = (e, t) => CA(bb(e, t)), Tk = (e, t) => null, kA = (e, t, n) => {
  if (n + 1 >= t.length)
    return null;
  const i = pn(t[n]), r = pn(t[n + 1]);
  return e.subarray(i, r);
}, Dk = ({ offset: e, values: t }, n) => {
  const i = e + n;
  return (t[i >> 3] & 1 << i % 8) !== 0;
}, UA = ({ values: e }, t) => Mk(e, t), zA = ({ values: e }, t) => $k(e, t * 2), no = ({ stride: e, values: t }, n) => t[e * n], Nk = ({ stride: e, values: t }, n) => pA(t[e * n]), PA = ({ values: e }, t) => e[t], Bk = ({ stride: e, values: t }, n) => t.subarray(e * n, e * (n + 1)), VA = ({ values: e, valueOffsets: t }, n) => kA(e, t, n), jA = ({ values: e, valueOffsets: t }, n) => {
  const i = kA(e, t, n);
  return i !== null ? dg(i) : null;
}, Ok = ({ values: e }, t) => e[t], Fk = ({ type: e, values: t }, n) => e.precision !== nn.HALF ? t[n] : pA(t[n]), Ek = (e, t) => e.type.unit === Ii.DAY ? UA(e, t) : zA(e, t), qA = ({ values: e }, t) => 1e3 * bb(e, t * 2), YA = ({ values: e }, t) => bb(e, t * 2), WA = ({ values: e }, t) => Ik(e, t * 2), GA = ({ values: e }, t) => Ak(e, t * 2), Lk = (e, t) => {
  switch (e.type.unit) {
    case mt.SECOND:
      return qA(e, t);
    case mt.MILLISECOND:
      return YA(e, t);
    case mt.MICROSECOND:
      return WA(e, t);
    case mt.NANOSECOND:
      return GA(e, t);
  }
}, XA = ({ values: e }, t) => e[t], HA = ({ values: e }, t) => e[t], JA = ({ values: e }, t) => e[t], KA = ({ values: e }, t) => e[t], Rk = (e, t) => {
  switch (e.type.unit) {
    case mt.SECOND:
      return XA(e, t);
    case mt.MILLISECOND:
      return HA(e, t);
    case mt.MICROSECOND:
      return JA(e, t);
    case mt.NANOSECOND:
      return KA(e, t);
  }
}, Ck = ({ values: e, stride: t }, n) => HC.decimal(e.subarray(t * n, t * (n + 1))), kk = (e, t) => {
  const { valueOffsets: n, stride: i, children: r } = e, { [t * i]: s, [t * i + 1]: o } = n, c = r[0].slice(s, o - s);
  return new Ne([c]);
}, Uk = (e, t) => {
  const { valueOffsets: n, children: i } = e, { [t]: r, [t + 1]: s } = n, o = i[0];
  return new wb(o.slice(r, s - r));
}, zk = (e, t) => new gb(e, t), Pk = (e, t) => e.type.mode === Mn.Dense ? ZA(e, t) : QA(e, t), ZA = (e, t) => {
  const n = e.type.typeIdToChildIndex[e.typeIds[t]], i = e.children[n];
  return $n.visit(i, e.valueOffsets[t]);
}, QA = (e, t) => {
  const n = e.type.typeIdToChildIndex[e.typeIds[t]], i = e.children[n];
  return $n.visit(i, t);
}, Vk = (e, t) => {
  var n;
  return (n = e.dictionary) === null || n === void 0 ? void 0 : n.get(e.values[t]);
}, jk = (e, t) => e.type.unit === lr.DAY_TIME ? tM(e, t) : eM(e, t), tM = ({ values: e }, t) => e.subarray(2 * t, 2 * (t + 1)), eM = ({ values: e }, t) => {
  const n = e[t], i = new Int32Array(2);
  return i[0] = Math.trunc(n / 12), i[1] = Math.trunc(n % 12), i;
}, nM = ({ values: e }, t) => e[t], iM = ({ values: e }, t) => e[t], rM = ({ values: e }, t) => e[t], sM = ({ values: e }, t) => e[t], qk = (e, t) => {
  switch (e.type.unit) {
    case mt.SECOND:
      return nM(e, t);
    case mt.MILLISECOND:
      return iM(e, t);
    case mt.MICROSECOND:
      return rM(e, t);
    case mt.NANOSECOND:
      return sM(e, t);
  }
}, Yk = (e, t) => {
  const { stride: n, children: i } = e, s = i[0].slice(t * n, n);
  return new Ne([s]);
};
at.prototype.visitNull = _t(Tk);
at.prototype.visitBool = _t(Dk);
at.prototype.visitInt = _t(Ok);
at.prototype.visitInt8 = _t(no);
at.prototype.visitInt16 = _t(no);
at.prototype.visitInt32 = _t(no);
at.prototype.visitInt64 = _t(PA);
at.prototype.visitUint8 = _t(no);
at.prototype.visitUint16 = _t(no);
at.prototype.visitUint32 = _t(no);
at.prototype.visitUint64 = _t(PA);
at.prototype.visitFloat = _t(Fk);
at.prototype.visitFloat16 = _t(Nk);
at.prototype.visitFloat32 = _t(no);
at.prototype.visitFloat64 = _t(no);
at.prototype.visitUtf8 = _t(jA);
at.prototype.visitLargeUtf8 = _t(jA);
at.prototype.visitBinary = _t(VA);
at.prototype.visitLargeBinary = _t(VA);
at.prototype.visitFixedSizeBinary = _t(Bk);
at.prototype.visitDate = _t(Ek);
at.prototype.visitDateDay = _t(UA);
at.prototype.visitDateMillisecond = _t(zA);
at.prototype.visitTimestamp = _t(Lk);
at.prototype.visitTimestampSecond = _t(qA);
at.prototype.visitTimestampMillisecond = _t(YA);
at.prototype.visitTimestampMicrosecond = _t(WA);
at.prototype.visitTimestampNanosecond = _t(GA);
at.prototype.visitTime = _t(Rk);
at.prototype.visitTimeSecond = _t(XA);
at.prototype.visitTimeMillisecond = _t(HA);
at.prototype.visitTimeMicrosecond = _t(JA);
at.prototype.visitTimeNanosecond = _t(KA);
at.prototype.visitDecimal = _t(Ck);
at.prototype.visitList = _t(kk);
at.prototype.visitStruct = _t(zk);
at.prototype.visitUnion = _t(Pk);
at.prototype.visitDenseUnion = _t(ZA);
at.prototype.visitSparseUnion = _t(QA);
at.prototype.visitDictionary = _t(Vk);
at.prototype.visitInterval = _t(jk);
at.prototype.visitIntervalDayTime = _t(tM);
at.prototype.visitIntervalYearMonth = _t(eM);
at.prototype.visitDuration = _t(qk);
at.prototype.visitDurationSecond = _t(nM);
at.prototype.visitDurationMillisecond = _t(iM);
at.prototype.visitDurationMicrosecond = _t(rM);
at.prototype.visitDurationNanosecond = _t(sM);
at.prototype.visitFixedSizeList = _t(Yk);
at.prototype.visitMap = _t(Uk);
const $n = new at(), Ki = Symbol.for("keys"), cc = Symbol.for("vals");
let wb = class {
  constructor(t) {
    return this[Ki] = new Ne([t.children[0]]).memoize(), this[cc] = t.children[1], new Proxy(this, new Gk());
  }
  [Symbol.iterator]() {
    return new Wk(this[Ki], this[cc]);
  }
  get size() {
    return this[Ki].length;
  }
  toArray() {
    return Object.values(this.toJSON());
  }
  toJSON() {
    const t = this[Ki], n = this[cc], i = {};
    for (let r = -1, s = t.length; ++r < s; )
      i[t.get(r)] = $n.visit(n, r);
    return i;
  }
  toString() {
    return `{${[...this].map(([t, n]) => `${_u(t)}: ${_u(n)}`).join(", ")}}`;
  }
  [Symbol.for("nodejs.util.inspect.custom")]() {
    return this.toString();
  }
}, Wk = class {
  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),
        $n.visit(this.vals, t)
      ]
    });
  }
}, Gk = class {
  isExtensible() {
    return !1;
  }
  deleteProperty() {
    return !1;
  }
  preventExtensions() {
    return !0;
  }
  ownKeys(t) {
    return t[Ki].toArray().map(String);
  }
  has(t, n) {
    return t[Ki].includes(n);
  }
  getOwnPropertyDescriptor(t, n) {
    if (t[Ki].indexOf(n) !== -1)
      return { writable: !0, enumerable: !0, configurable: !0 };
  }
  get(t, n) {
    if (Reflect.has(t, n))
      return t[n];
    const i = t[Ki].indexOf(n);
    if (i !== -1) {
      const r = $n.visit(Reflect.get(t, cc), i);
      return Reflect.set(t, n, r), r;
    }
  }
  set(t, n, i) {
    const r = t[Ki].indexOf(n);
    return r !== -1 ? (ci.visit(Reflect.get(t, cc), r, i), Reflect.set(t, n, i)) : Reflect.has(t, n) ? Reflect.set(t, n, i) : !1;
  }
};
Object.defineProperties(wb.prototype, {
  [Symbol.toStringTag]: { enumerable: !1, configurable: !1, value: "Row" },
  [Ki]: { writable: !0, enumerable: !1, configurable: !1, value: null },
  [cc]: { writable: !0, enumerable: !1, configurable: !1, value: null }
});
let z_;
function oM(e, t, n, i) {
  const { length: r = 0 } = e;
  let s = typeof t != "number" ? 0 : t, o = typeof n != "number" ? r : n;
  return s < 0 && (s = (s % r + r) % r), o < 0 && (o = (o % r + r) % r), o < s && (z_ = s, s = o, o = z_), o > r && (o = r), i ? i(e, s, o) : [s, o];
}
const P_ = (e) => e !== e;
function Kc(e) {
  if (typeof e !== "object" || e === null)
    return P_(e) ? P_ : (n) => n === e;
  if (e instanceof Date) {
    const n = e.valueOf();
    return (i) => i instanceof Date ? i.valueOf() === n : !1;
  }
  return ArrayBuffer.isView(e) ? (n) => n ? UC(e, n) : !1 : e instanceof Map ? Hk(e) : Array.isArray(e) ? Xk(e) : e instanceof Ne ? Jk(e) : Kk(e, !0);
}
function Xk(e) {
  const t = [];
  for (let n = -1, i = e.length; ++n < i; )
    t[n] = Kc(e[n]);
  return Uy(t);
}
function Hk(e) {
  let t = -1;
  const n = [];
  for (const i of e.values())
    n[++t] = Kc(i);
  return Uy(n);
}
function Jk(e) {
  const t = [];
  for (let n = -1, i = e.length; ++n < i; )
    t[n] = Kc(e.get(n));
  return Uy(t);
}
function Kk(e, t = !1) {
  const n = Object.keys(e);
  if (!t && n.length === 0)
    return () => !1;
  const i = [];
  for (let r = -1, s = n.length; ++r < s; )
    i[r] = Kc(e[n[r]]);
  return Uy(i, n);
}
function Uy(e, t) {
  return (n) => {
    if (!n || typeof n != "object")
      return !1;
    switch (n.constructor) {
      case Array:
        return Zk(e, n);
      case Map:
        return V_(e, n, n.keys());
      case wb:
      case gb:
      case Object:
      case void 0:
        return V_(e, n, t || Object.keys(n));
    }
    return n instanceof Ne ? Qk(e, n) : !1;
  };
}
function Zk(e, t) {
  const n = e.length;
  if (t.length !== n)
    return !1;
  for (let i = -1; ++i < n; )
    if (!e[i](t[i]))
      return !1;
  return !0;
}
function Qk(e, t) {
  const n = e.length;
  if (t.length !== n)
    return !1;
  for (let i = -1; ++i < n; )
    if (!e[i](t.get(i)))
      return !1;
  return !0;
}
function V_(e, t, n) {
  const i = n[Symbol.iterator](), r = 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(), l = i.next(), u = r.next();
  for (; o < a && !l.done && !u.done && !c.done && !(l.value !== u.value || !e[o](c.value)); ++o, l = i.next(), u = r.next(), c = s.next())
    ;
  return o === a && l.done && u.done && c.done ? !0 : (i.return && i.return(), r.return && r.return(), s.return && s.return(), !1);
}
function aM(e, t, n, i) {
  return (n & 1 << i) !== 0;
}
function t7(e, t, n, i) {
  return (n & 1 << i) >> i;
}
function j_(e, t, n) {
  const i = n.byteLength + 7 & -8;
  if (e > 0 || n.byteLength < i) {
    const r = new Uint8Array(i);
    return r.set(e % 8 === 0 ? n.subarray(e >> 3) : (
      // Otherwise iterate each bit from the offset and return a new one
      _g(new vb(n, e, t, null, aM)).subarray(0, i)
    )), r;
  }
  return n;
}
function _g(e) {
  const t = [];
  let n = 0, i = 0, r = 0;
  for (const o of e)
    o && (r |= 1 << i), ++i === 8 && (t[n++] = r, r = i = 0);
  (n === 0 || i > 0) && (t[n++] = r);
  const s = new Uint8Array(t.length + 7 & -8);
  return s.set(t), s;
}
let vb = class {
  constructor(t, n, i, r, s) {
    this.bytes = t, this.length = i, this.context = r, 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 xg(e, t, n) {
  if (n - t <= 0)
    return 0;
  if (n - t < 8) {
    let s = 0;
    for (const o of new vb(e, t, n - t, e, t7))
      s += o;
    return s;
  }
  const i = n >> 3 << 3, r = 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
    xg(e, t, r) + // Get the popcnt of bits between the right hand side, and the next lowest multiple of 8
    xg(e, i, n) + // Get the popcnt of all bits between the left and right hand sides' multiples of 8
    e7(e, r >> 3, i - r >> 3)
  );
}
function e7(e, t, n) {
  let i = 0, r = Math.trunc(t);
  const s = new DataView(e.buffer, e.byteOffset, e.byteLength), o = n === void 0 ? e.byteLength : r + n;
  for (; o - r >= 4; )
    i += im(s.getUint32(r)), r += 4;
  for (; o - r >= 2; )
    i += im(s.getUint16(r)), r += 2;
  for (; o - r >= 1; )
    i += im(s.getUint8(r)), r += 1;
  return i;
}
function im(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 n7 = -1;
let de = class Sg {
  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 gt.isSparseUnion(t) ? this.children.some((n) => n.nullable) : gt.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: i, nullBitmap: r, typeIds: s } = this;
    return n && (t += n.byteLength), i && (t += i.byteLength), r && (t += r.byteLength), s && (t += s.byteLength), this.children.reduce((o, a) => o + a.byteLength, t);
  }
  get nullCount() {
    if (gt.isUnion(this.type))
      return this.children.reduce((i, r) => i + r.nullCount, 0);
    let t = this._nullCount, n;
    return t <= n7 && (n = this.nullBitmap) && (this._nullCount = t = this.length - xg(n, this.offset, this.offset + this.length)), t;
  }
  constructor(t, n, i, r, 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(i || 0, 0)), this._nullCount = Math.floor(Math.max(r || 0, -1));
    let c;
    s instanceof Sg ? (this.stride = s.stride, this.values = s.values, this.typeIds = s.typeIds, this.nullBitmap = s.nullBitmap, this.valueOffsets = s.valueOffsets) : (this.stride = Rr(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 (gt.isUnion(n)) {
      const i = n, r = this.children[i.typeIdToChildIndex[this.typeIds[t]]], s = i.mode === Mn.Dense ? this.valueOffsets[t] : t;
      return r.getValid(s);
    }
    if (this.nullable && this.nullCount > 0) {
      const i = this.offset + t;
      return (this.nullBitmap[i >> 3] & 1 << i % 8) !== 0;
    }
    return !0;
  }
  setValid(t, n) {
    let i;
    const { type: r } = this;
    if (gt.isUnion(r)) {
      const s = r, o = this.children[s.typeIdToChildIndex[this.typeIds[t]]], a = s.mode === Mn.Dense ? this.valueOffsets[t] : t;
      i = o.getValid(a), o.setValid(a, n);
    } else {
      let { nullBitmap: s } = this;
      const { offset: o, length: a } = this, c = o + t, l = 1 << c % 8, u = c >> 3;
      (!s || s.byteLength <= u) && (s = new Uint8Array((o + a + 63 & -64) >> 3).fill(255), this.nullCount > 0 && s.set(j_(o, a, this.nullBitmap), 0), Object.assign(this, { nullBitmap: s, _nullCount: -1 }));
      const f = s[u];
      i = (f & l) !== 0, n ? s[u] = f | l : s[u] = f & ~l;
    }
    return i !== !!n && (this._nullCount = this.nullCount + (n ? -1 : 1)), n;
  }
  clone(t = this.type, n = this.offset, i = this.length, r = this._nullCount, s = this, o = this.children) {
    return new Sg(t, n, i, r, s, o, this.dictionary);
  }
  slice(t, n) {
    const { stride: i, typeId: r, children: s } = this, o = +(this._nullCount === 0) - 1, a = r === 16 ? i : 1, c = this._sliceBuffers(t, n, i, r);
    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 === F.Null)
      return this.clone(this.type, 0, t, 0);
    const { length: n, nullCount: i } = this, r = new Uint8Array((t + 63 & -64) >> 3).fill(255, 0, n >> 3);
    r[n >> 3] = (1 << n - (n & -8)) - 1, i > 0 && r.set(j_(this.offset, n, this.nullBitmap), 0);
    const s = this.buffers;
    return s[Lr.VALIDITY] = r, this.clone(this.type, 0, t, i + (t - n), s);
  }
  _sliceBuffers(t, n, i, r) {
    let s;
    const { buffers: o } = this;
    return (s = o[Lr.TYPE]) && (o[Lr.TYPE] = s.subarray(t, t + n)), (s = o[Lr.OFFSET]) && (o[Lr.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[Lr.DATA]) && (o[Lr.DATA] = r === 6 ? s : s.subarray(i * t, i * (t + n))), o;
  }
  _sliceChildren(t, n, i) {
    return t.map((r) => r.slice(n, i));
  }
};
de.prototype.children = Object.freeze([]);
let i7 = class Xh extends Ut {
  visit(t) {
    return this.getVisitFn(t.type).call(this, t);
  }
  visitNull(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["length"]: r = 0 } = t;
    return new de(n, i, r, r);
  }
  visitBool(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Yt(t.nullBitmap), s = re(n.ArrayType, t.data), { ["length"]: o = s.length >> 3, ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new de(n, i, o, a, [void 0, s, r]);
  }
  visitInt(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Yt(t.nullBitmap), s = re(n.ArrayType, t.data), { ["length"]: o = s.length, ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new de(n, i, o, a, [void 0, s, r]);
  }
  visitFloat(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Yt(t.nullBitmap), s = re(n.ArrayType, t.data), { ["length"]: o = s.length, ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new de(n, i, o, a, [void 0, s, r]);
  }
  visitUtf8(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Yt(t.data), s = Yt(t.nullBitmap), o = bl(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new de(n, i, a, c, [o, r, s]);
  }
  visitLargeUtf8(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Yt(t.data), s = Yt(t.nullBitmap), o = T_(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new de(n, i, a, c, [o, r, s]);
  }
  visitBinary(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Yt(t.data), s = Yt(t.nullBitmap), o = bl(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new de(n, i, a, c, [o, r, s]);
  }
  visitLargeBinary(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Yt(t.data), s = Yt(t.nullBitmap), o = T_(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new de(n, i, a, c, [o, r, s]);
  }
  visitFixedSizeBinary(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Yt(t.nullBitmap), s = re(n.ArrayType, t.data), { ["length"]: o = s.length / Rr(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new de(n, i, o, a, [void 0, s, r]);
  }
  visitDate(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Yt(t.nullBitmap), s = re(n.ArrayType, t.data), { ["length"]: o = s.length / Rr(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new de(n, i, o, a, [void 0, s, r]);
  }
  visitTimestamp(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Yt(t.nullBitmap), s = re(n.ArrayType, t.data), { ["length"]: o = s.length / Rr(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new de(n, i, o, a, [void 0, s, r]);
  }
  visitTime(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Yt(t.nullBitmap), s = re(n.ArrayType, t.data), { ["length"]: o = s.length / Rr(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new de(n, i, o, a, [void 0, s, r]);
  }
  visitDecimal(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Yt(t.nullBitmap), s = re(n.ArrayType, t.data), { ["length"]: o = s.length / Rr(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new de(n, i, o, a, [void 0, s, r]);
  }
  visitList(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["child"]: r } = t, s = Yt(t.nullBitmap), o = bl(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new de(n, i, a, c, [o, void 0, s], [r]);
  }
  visitStruct(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["children"]: r = [] } = t, s = Yt(t.nullBitmap), { length: o = r.reduce((c, { length: l }) => Math.max(c, l), 0), nullCount: a = t.nullBitmap ? -1 : 0 } = t;
    return new de(n, i, o, a, [void 0, void 0, s], r);
  }
  visitUnion(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["children"]: r = [] } = t, s = re(n.ArrayType, t.typeIds), { ["length"]: o = s.length, ["nullCount"]: a = -1 } = t;
    if (gt.isSparseUnion(n))
      return new de(n, i, o, a, [void 0, void 0, void 0, s], r);
    const c = bl(t.valueOffsets);
    return new de(n, i, o, a, [c, void 0, void 0, s], r);
  }
  visitDictionary(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Yt(t.nullBitmap), s = re(n.indices.ArrayType, t.data), { ["dictionary"]: o = new Ne([new Xh().visit({ type: n.dictionary })]) } = t, { ["length"]: a = s.length, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new de(n, i, a, c, [void 0, s, r], [], o);
  }
  visitInterval(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Yt(t.nullBitmap), s = re(n.ArrayType, t.data), { ["length"]: o = s.length / Rr(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new de(n, i, o, a, [void 0, s, r]);
  }
  visitDuration(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Yt(t.nullBitmap), s = re(n.ArrayType, t.data), { ["length"]: o = s.length, ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new de(n, i, o, a, [void 0, s, r]);
  }
  visitFixedSizeList(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["child"]: r = new Xh().visit({ type: n.valueType }) } = t, s = Yt(t.nullBitmap), { ["length"]: o = r.length / Rr(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new de(n, i, o, a, [void 0, void 0, s], [r]);
  }
  visitMap(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["child"]: r = new Xh().visit({ type: n.childType }) } = t, s = Yt(t.nullBitmap), o = bl(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new de(n, i, a, c, [o, void 0, s], [r]);
  }
};
const r7 = new i7();
function Rt(e) {
  return r7.visit(e);
}
let q_ = class {
  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 s7(e) {
  return e.some((t) => t.nullable);
}
function cM(e) {
  return e.reduce((t, n) => t + n.nullCount, 0);
}
function lM(e) {
  return e.reduce((t, n, i) => (t[i + 1] = t[i] + n.length, t), new Uint32Array(e.length + 1));
}
function uM(e, t, n, i) {
  const r = [];
  for (let s = -1, o = e.length; ++s < o; ) {
    const a = e[s], c = t[s], { length: l } = a;
    if (c >= i)
      break;
    if (n >= c + l)
      continue;
    if (c >= n && c + l <= i) {
      r.push(a);
      continue;
    }
    const u = Math.max(0, n - c), f = Math.min(i - c, l);
    r.push(a.slice(u, f - u));
  }
  return r.length === 0 && r.push(e[0].slice(0, 0)), r;
}
function _b(e, t, n, i) {
  let r = 0, s = 0, o = t.length - 1;
  do {
    if (r >= o - 1)
      return n < t[o] ? i(e, r, n - t[r]) : null;
    s = r + Math.trunc((o - r) * 0.5), n < t[s] ? o = s : r = s;
  } while (r < o);
}
function xb(e, t) {
  return e.getValid(t);
}
function Cd(e) {
  function t(n, i, r) {
    return e(n[i], r);
  }
  return function(n) {
    const i = this.data;
    return _b(i, this._offsets, n, t);
  };
}
function fM(e) {
  let t;
  function n(i, r, s) {
    return e(i[r], s, t);
  }
  return function(i, r) {
    const s = this.data;
    t = r;
    const o = _b(s, this._offsets, i, n);
    return t = void 0, o;
  };
}
function hM(e) {
  let t;
  function n(i, r, s) {
    let o = s, a = 0, c = 0;
    for (let l = r - 1, u = i.length; ++l < u; ) {
      const f = i[l];
      if (~(a = e(f, t, o)))
        return c + a;
      o = 0, c += f.length;
    }
    return -1;
  }
  return function(i, r) {
    t = i;
    const s = this.data, o = typeof r != "number" ? n(s, 0, 0) : _b(s, this._offsets, r, n);
    return t = void 0, o;
  };
}
let ct = class extends Ut {
};
function o7(e, t) {
  return t === null && e.length > 0 ? 0 : -1;
}
function a7(e, t) {
  const { nullBitmap: n } = e;
  if (!n || e.nullCount <= 0)
    return -1;
  let i = 0;
  for (const r of new vb(n, e.offset + (t || 0), e.length, n, aM)) {
    if (!r)
      return i;
    ++i;
  }
  return -1;
}
function Bt(e, t, n) {
  if (t === void 0)
    return -1;
  if (t === null)
    switch (e.typeId) {
      case F.Union:
        break;
      case F.Dictionary:
        break;
      default:
        return a7(e, n);
    }
  const i = $n.getVisitFn(e), r = Kc(t);
  for (let s = (n || 0) - 1, o = e.length; ++s < o; )
    if (r(i(e, s)))
      return s;
  return -1;
}
function dM(e, t, n) {
  const i = $n.getVisitFn(e), r = Kc(t);
  for (let s = (n || 0) - 1, o = e.length; ++s < o; )
    if (r(i(e, s)))
      return s;
  return -1;
}
ct.prototype.visitNull = o7;
ct.prototype.visitBool = Bt;
ct.prototype.visitInt = Bt;
ct.prototype.visitInt8 = Bt;
ct.prototype.visitInt16 = Bt;
ct.prototype.visitInt32 = Bt;
ct.prototype.visitInt64 = Bt;
ct.prototype.visitUint8 = Bt;
ct.prototype.visitUint16 = Bt;
ct.prototype.visitUint32 = Bt;
ct.prototype.visitUint64 = Bt;
ct.prototype.visitFloat = Bt;
ct.prototype.visitFloat16 = Bt;
ct.prototype.visitFloat32 = Bt;
ct.prototype.visitFloat64 = Bt;
ct.prototype.visitUtf8 = Bt;
ct.prototype.visitLargeUtf8 = Bt;
ct.prototype.visitBinary = Bt;
ct.prototype.visitLargeBinary = Bt;
ct.prototype.visitFixedSizeBinary = Bt;
ct.prototype.visitDate = Bt;
ct.prototype.visitDateDay = Bt;
ct.prototype.visitDateMillisecond = Bt;
ct.prototype.visitTimestamp = Bt;
ct.prototype.visitTimestampSecond = Bt;
ct.prototype.visitTimestampMillisecond = Bt;
ct.prototype.visitTimestampMicrosecond = Bt;
ct.prototype.visitTimestampNanosecond = Bt;
ct.prototype.visitTime = Bt;
ct.prototype.visitTimeSecond = Bt;
ct.prototype.visitTimeMillisecond = Bt;
ct.prototype.visitTimeMicrosecond = Bt;
ct.prototype.visitTimeNanosecond = Bt;
ct.prototype.visitDecimal = Bt;
ct.prototype.visitList = Bt;
ct.prototype.visitStruct = Bt;
ct.prototype.visitUnion = Bt;
ct.prototype.visitDenseUnion = dM;
ct.prototype.visitSparseUnion = dM;
ct.prototype.visitDictionary = Bt;
ct.prototype.visitInterval = Bt;
ct.prototype.visitIntervalDayTime = Bt;
ct.prototype.visitIntervalYearMonth = Bt;
ct.prototype.visitDuration = Bt;
ct.prototype.visitDurationSecond = Bt;
ct.prototype.visitDurationMillisecond = Bt;
ct.prototype.visitDurationMicrosecond = Bt;
ct.prototype.visitDurationNanosecond = Bt;
ct.prototype.visitFixedSizeList = Bt;
ct.prototype.visitMap = Bt;
const kd = new ct();
let lt = class extends Ut {
};
function xt(e) {
  const { type: t } = e;
  if (e.nullCount === 0 && e.stride === 1 && (t.typeId === F.Timestamp || t instanceof zs && t.bitWidth !== 64 || t instanceof Mu && t.bitWidth !== 64 || t instanceof Au && t.precision !== nn.HALF))
    return new q_(e.data.length, (i) => {
      const r = e.data[i];
      return r.values.subarray(0, r.length)[Symbol.iterator]();
    });
  let n = 0;
  return new q_(e.data.length, (i) => {
    const s = e.data[i].length, o = e.slice(n, n + s);
    return n += s, new c7(o);
  });
}
let c7 = class {
  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;
  }
};
lt.prototype.visitNull = xt;
lt.prototype.visitBool = xt;
lt.prototype.visitInt = xt;
lt.prototype.visitInt8 = xt;
lt.prototype.visitInt16 = xt;
lt.prototype.visitInt32 = xt;
lt.prototype.visitInt64 = xt;
lt.prototype.visitUint8 = xt;
lt.prototype.visitUint16 = xt;
lt.prototype.visitUint32 = xt;
lt.prototype.visitUint64 = xt;
lt.prototype.visitFloat = xt;
lt.prototype.visitFloat16 = xt;
lt.prototype.visitFloat32 = xt;
lt.prototype.visitFloat64 = xt;
lt.prototype.visitUtf8 = xt;
lt.prototype.visitLargeUtf8 = xt;
lt.prototype.visitBinary = xt;
lt.prototype.visitLargeBinary = xt;
lt.prototype.visitFixedSizeBinary = xt;
lt.prototype.visitDate = xt;
lt.prototype.visitDateDay = xt;
lt.prototype.visitDateMillisecond = xt;
lt.prototype.visitTimestamp = xt;
lt.prototype.visitTimestampSecond = xt;
lt.prototype.visitTimestampMillisecond = xt;
lt.prototype.visitTimestampMicrosecond = xt;
lt.prototype.visitTimestampNanosecond = xt;
lt.prototype.visitTime = xt;
lt.prototype.visitTimeSecond = xt;
lt.prototype.visitTimeMillisecond = xt;
lt.prototype.visitTimeMicrosecond = xt;
lt.prototype.visitTimeNanosecond = xt;
lt.prototype.visitDecimal = xt;
lt.prototype.visitList = xt;
lt.prototype.visitStruct = xt;
lt.prototype.visitUnion = xt;
lt.prototype.visitDenseUnion = xt;
lt.prototype.visitSparseUnion = xt;
lt.prototype.visitDictionary = xt;
lt.prototype.visitInterval = xt;
lt.prototype.visitIntervalDayTime = xt;
lt.prototype.visitIntervalYearMonth = xt;
lt.prototype.visitDuration = xt;
lt.prototype.visitDurationSecond = xt;
lt.prototype.visitDurationMillisecond = xt;
lt.prototype.visitDurationMicrosecond = xt;
lt.prototype.visitDurationNanosecond = xt;
lt.prototype.visitFixedSizeList = xt;
lt.prototype.visitMap = xt;
const Sb = new lt();
var pM;
const yM = {}, mM = {};
let Ne = class Ao {
  constructor(t) {
    var n, i, r;
    const s = t[0] instanceof Ao ? t.flatMap((a) => a.data) : t;
    if (s.length === 0 || s.some((a) => !(a instanceof de)))
      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: l } = yM[o.typeId], u = s[0];
        this.isValid = (f) => xb(u, f), this.get = (f) => a(u, f), this.set = (f, h) => c(u, f, h), this.indexOf = (f) => l(u, f), this._offsets = [0, u.length];
        break;
      }
      default:
        Object.setPrototypeOf(this, mM[o.typeId]), this._offsets = lM(s);
        break;
    }
    this.data = s, this.type = o, this.stride = Rr(o), this.numChildren = (r = (i = o.children) === null || i === void 0 ? void 0 : i.length) !== null && r !== void 0 ? r : 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 s7(this.data);
  }
  /**
   * The number of null elements in this Vector.
   */
  get nullCount() {
    return cM(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 `${F[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;
  }
  /**
   * 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 Sb.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 Ao(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 Ao(oM(this, t, n, ({ data: i, _offsets: r }, s, o) => uM(i, r, 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: i, stride: r, ArrayType: s } = this;
    switch (t.typeId) {
      case F.Int:
      case F.Float:
      case F.Decimal:
      case F.Time:
      case F.Timestamp:
        switch (n.length) {
          case 0:
            return new s();
          case 1:
            return n[0].values.subarray(0, i * r);
          default:
            return n.reduce((o, { values: a, length: c }) => (o.array.set(a.subarray(0, c * r), o.offset), o.offset += c * r, o), { array: new s(i * r), 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((i) => i.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 Ao(this.data.map(({ children: n }) => n[t])) : null;
  }
  get isMemoized() {
    return gt.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 (gt.isDictionary(this.type)) {
      const t = new Y_(this.data[0].dictionary), n = this.data.map((i) => {
        const r = i.clone();
        return r.dictionary = t, r;
      });
      return new Ao(n);
    }
    return new Y_(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 (gt.isDictionary(this.type) && this.isMemoized) {
      const t = this.data[0].dictionary.unmemoize(), n = this.data.map((i) => {
        const r = i.clone();
        return r.dictionary = t, r;
      });
      return new Ao(n);
    }
    return this;
  }
};
pM = Symbol.toStringTag;
Ne[pM] = ((e) => {
  e.type = gt.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(F).map((n) => F[n]).filter((n) => typeof n == "number" && n !== F.NONE);
  for (const n of t) {
    const i = $n.getVisitFnByTypeId(n), r = ci.getVisitFnByTypeId(n), s = kd.getVisitFnByTypeId(n);
    yM[n] = { get: i, set: r, indexOf: s }, mM[n] = Object.create(e, {
      isValid: { value: Cd(xb) },
      get: { value: Cd($n.getVisitFnByTypeId(n)) },
      set: { value: fM(ci.getVisitFnByTypeId(n)) },
      indexOf: { value: hM(kd.getVisitFnByTypeId(n)) }
    });
  }
  return "Vector";
})(Ne.prototype);
let Y_ = class gM extends Ne {
  constructor(t) {
    super(t.data);
    const n = this.get, i = this.set, r = 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) {
        i.call(this, o, a), s[o] = a;
      }
    }), Object.defineProperty(this, "slice", {
      value: (o, a) => new gM(r.call(this, o, a))
    }), Object.defineProperty(this, "isMemoized", { value: !0 }), Object.defineProperty(this, "unmemoize", {
      value: () => new Ne(this.data)
    }), Object.defineProperty(this, "memoize", {
      value: () => this
    });
  }
}, Ig = class {
  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, i, r) {
    return t.prep(8, 24), t.writeInt64(BigInt(r ?? 0)), t.pad(4), t.writeInt32(i), t.writeInt64(BigInt(n ?? 0)), t.offset();
  }
}, Vi = class Ag {
  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 Ag()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFooter(t, n) {
    return t.setPosition(t.position() + nt), (n || new Ag()).__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) : Ee.V1;
  }
  schema(t) {
    const n = this.bb.__offset(this.bb_pos, 6);
    return n ? (t || new Yi()).__init(this.bb.__indirect(this.bb_pos + n), this.bb) : null;
  }
  dictionaries(t, n) {
    const i = this.bb.__offset(this.bb_pos, 8);
    return i ? (n || new Ig()).__init(this.bb.__vector(this.bb_pos + i) + 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 i = this.bb.__offset(this.bb_pos, 10);
    return i ? (n || new Ig()).__init(this.bb.__vector(this.bb_pos + i) + 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 i = this.bb.__offset(this.bb_pos, 12);
    return i ? (n || new ni()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + i) + 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, Ee.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 i = n.length - 1; i >= 0; i--)
      t.addOffset(n[i]);
    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);
  }
}, _e = class Mo {
  constructor(t = [], n, i, r = Ee.V5) {
    this.fields = t || [], this.metadata = n || /* @__PURE__ */ new Map(), i || (i = $g(t)), this.dictionaries = i, this.metadataVersion = r;
  }
  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), i = this.fields.filter((r) => n.has(r.name));
    return new Mo(i, 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((i) => this.fields[i]).filter(Boolean);
    return new Mo(n, this.metadata);
  }
  assign(...t) {
    const n = t[0] instanceof Mo ? t[0] : Array.isArray(t[0]) ? new Mo(t[0]) : new Mo(t), i = [...this.fields], r = sh(sh(/* @__PURE__ */ new Map(), this.metadata), n.metadata), s = n.fields.filter((a) => {
      const c = i.findIndex((l) => l.name === a.name);
      return ~c ? (i[c] = a.clone({
        metadata: sh(sh(/* @__PURE__ */ new Map(), i[c].metadata), a.metadata)
      })) && !1 : !0;
    }), o = $g(s, /* @__PURE__ */ new Map());
    return new Mo([...i, ...s], r, new Map([...this.dictionaries, ...o]));
  }
};
_e.prototype.fields = null;
_e.prototype.metadata = null;
_e.prototype.dictionaries = null;
let Te = class Mg {
  /** @nocollapse */
  static new(...t) {
    let [n, i, r, s] = t;
    return t[0] && typeof t[0] == "object" && ({ name: n } = t[0], i === void 0 && (i = t[0].type), r === void 0 && (r = t[0].nullable), s === void 0 && (s = t[0].metadata)), new Mg(`${n}`, i, r, s);
  }
  constructor(t, n, i = !1, r) {
    this.name = t, this.type = n, this.nullable = i, this.metadata = r || /* @__PURE__ */ new Map();
  }
  get typeId() {
    return this.type.typeId;
  }
  get [Symbol.toStringTag]() {
    return "Field";
  }
  toString() {
    return `${this.name}: ${this.type}`;
  }
  clone(...t) {
    let [n, i, r, s] = t;
    return !t[0] || typeof t[0] != "object" ? [n = this.name, i = this.type, r = this.nullable, s = this.metadata] = t : { name: n = this.name, type: i = this.type, nullable: r = this.nullable, metadata: s = this.metadata } = t[0], Mg.new(n, i, r, s);
  }
};
Te.prototype.type = null;
Te.prototype.name = null;
Te.prototype.nullable = null;
Te.prototype.metadata = null;
function sh(e, t) {
  return new Map([...e || /* @__PURE__ */ new Map(), ...t || /* @__PURE__ */ new Map()]);
}
function $g(e, t = /* @__PURE__ */ new Map()) {
  for (let n = -1, i = e.length; ++n < i; ) {
    const s = e[n].type;
    if (gt.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 && $g(s.children, t);
  }
  return t;
}
var l7 = ky, u7 = ur;
let Ib = class {
  /** @nocollapse */
  static decode(t) {
    t = new u7(Yt(t));
    const n = Vi.getRootAsFooter(t), i = _e.decode(n.schema(), /* @__PURE__ */ new Map(), n.version());
    return new f7(i, n);
  }
  /** @nocollapse */
  static encode(t) {
    const n = new l7(), i = _e.encode(n, t.schema);
    Vi.startRecordBatchesVector(n, t.numRecordBatches);
    for (const o of [...t.recordBatches()].slice().reverse())
      Ud.encode(n, o);
    const r = n.endVector();
    Vi.startDictionariesVector(n, t.numDictionaries);
    for (const o of [...t.dictionaryBatches()].slice().reverse())
      Ud.encode(n, o);
    const s = n.endVector();
    return Vi.startFooter(n), Vi.addSchema(n, i), Vi.addVersion(n, Ee.V5), Vi.addRecordBatches(n, r), Vi.addDictionaries(n, s), Vi.finishFooterBuffer(n, Vi.endFooter(n)), n.asUint8Array();
  }
  get numRecordBatches() {
    return this._recordBatches.length;
  }
  get numDictionaries() {
    return this._dictionaryBatches.length;
  }
  constructor(t, n = Ee.V5, i, r) {
    this.schema = t, this.version = n, i && (this._recordBatches = i), r && (this._dictionaryBatches = r);
  }
  *recordBatches() {
    for (let t, n = -1, i = this.numRecordBatches; ++n < i; )
      (t = this.getRecordBatch(n)) && (yield t);
  }
  *dictionaryBatches() {
    for (let t, n = -1, i = this.numDictionaries; ++n < i; )
      (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;
  }
}, f7 = class extends Ib {
  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 Ud.decode(n);
    }
    return null;
  }
  getDictionaryBatch(t) {
    if (t >= 0 && t < this.numDictionaries) {
      const n = this._footer.dictionaries(t);
      if (n)
        return Ud.decode(n);
    }
    return null;
  }
}, Ud = class bM {
  /** @nocollapse */
  static decode(t) {
    return new bM(t.metaDataLength(), t.bodyLength(), t.offset());
  }
  /** @nocollapse */
  static encode(t, n) {
    const { metaDataLength: i } = n, r = BigInt(n.offset), s = BigInt(n.bodyLength);
    return Ig.createBlock(t, r, i, s);
  }
  constructor(t, n, i) {
    this.metaDataLength = t, this.offset = pn(i), this.bodyLength = pn(n);
  }
};
const xe = Object.freeze({ done: !0, value: void 0 });
let W_ = class {
  constructor(t) {
    this._json = t;
  }
  get schema() {
    return this._json.schema;
  }
  get batches() {
    return this._json.batches || [];
  }
  get dictionaries() {
    return this._json.dictionaries || [];
  }
}, wM = class {
  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());
  }
}, h7 = class extends wM {
  constructor() {
    super(), this._values = [], this.resolvers = [], this._closedPromise = new Promise((t) => this._closedPromiseResolve = t);
  }
  get closed() {
    return this._closedPromise;
  }
  cancel(t) {
    return W(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(xe);
      this._closedPromiseResolve(), this._closedPromiseResolve = void 0;
    }
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  toDOMStream(t) {
    return Hn.toDOMStream(this._closedPromiseResolve || this._error ? this : this._values, t);
  }
  toNodeStream(t) {
    return Hn.toNodeStream(this._closedPromiseResolve || this._error ? this : this._values, t);
  }
  throw(t) {
    return W(this, void 0, void 0, function* () {
      return yield this.abort(t), xe;
    });
  }
  return(t) {
    return W(this, void 0, void 0, function* () {
      return yield this.close(), xe;
    });
  }
  read(t) {
    return W(this, void 0, void 0, function* () {
      return (yield this.next(t, "read")).value;
    });
  }
  peek(t) {
    return W(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, i) => {
      this.resolvers.push({ resolve: n, reject: i });
    }) : Promise.resolve(xe);
  }
  _ensureOpen() {
    if (this._closedPromiseResolve)
      return !0;
    throw new Error("AsyncQueue is closed");
  }
}, d7 = class extends h7 {
  write(t) {
    if ((t = Yt(t)).byteLength > 0)
      return super.write(t);
  }
  toString(t = !1) {
    return t ? dg(this.toUint8Array(!0)) : this.toUint8Array(!1).then(dg);
  }
  toUint8Array(t = !1) {
    return t ? cr(this._values)[0] : W(this, void 0, void 0, function* () {
      var n, i, r, s;
      const o = [];
      let a = 0;
      try {
        for (var c = !0, l = ai(this), u; u = yield l.next(), n = u.done, !n; c = !0) {
          s = u.value, c = !1;
          const f = s;
          o.push(f), a += f.byteLength;
        }
      } catch (f) {
        i = { error: f };
      } finally {
        try {
          !c && !n && (r = l.return) && (yield r.call(l));
        } finally {
          if (i)
            throw i.error;
        }
      }
      return cr(o, a)[0];
    });
  }
}, zd = class {
  constructor(t) {
    t && (this.source = new p7(Hn.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);
  }
}, Pd = class vM {
  constructor(t) {
    t instanceof vM ? this.source = t.source : t instanceof d7 ? this.source = new yo(Hn.fromAsyncIterable(t)) : CI(t) ? this.source = new yo(Hn.fromNodeStream(t)) : db(t) ? this.source = new yo(Hn.fromDOMStream(t)) : LI(t) ? this.source = new yo(Hn.fromDOMStream(t.body)) : Cy(t) ? this.source = new yo(Hn.fromIterable(t)) : vu(t) ? this.source = new yo(Hn.fromAsyncIterable(t)) : hb(t) && (this.source = new yo(Hn.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);
  }
}, p7 = class {
  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) || xe);
  }
  return(t) {
    return Object.create(this.source.return && this.source.return(t) || xe);
  }
}, yo = class {
  constructor(t) {
    this.source = t, this._closedPromise = new Promise((n) => this._closedPromiseResolve = n);
  }
  cancel(t) {
    return W(this, void 0, void 0, function* () {
      yield this.return(t);
    });
  }
  get closed() {
    return this._closedPromise;
  }
  read(t) {
    return W(this, void 0, void 0, function* () {
      return (yield this.next(t, "read")).value;
    });
  }
  peek(t) {
    return W(this, void 0, void 0, function* () {
      return (yield this.next(t, "peek")).value;
    });
  }
  next(t, n = "read") {
    return W(this, void 0, void 0, function* () {
      return yield this.source.next({ cmd: n, size: t });
    });
  }
  throw(t) {
    return W(this, void 0, void 0, function* () {
      const n = this.source.throw && (yield this.source.throw(t)) || xe;
      return this._closedPromiseResolve && this._closedPromiseResolve(), this._closedPromiseResolve = void 0, Object.create(n);
    });
  }
  return(t) {
    return W(this, void 0, void 0, function* () {
      const n = this.source.return && (yield this.source.return(t)) || xe;
      return this._closedPromiseResolve && this._closedPromiseResolve(), this._closedPromiseResolve = void 0, Object.create(n);
    });
  }
}, G_ = class extends zd {
  constructor(t, n) {
    super(), this.position = 0, this.buffer = Yt(t), this.size = n === void 0 ? this.buffer.byteLength : n;
  }
  readInt32(t) {
    const { buffer: n, byteOffset: i } = this.readAt(t, 4);
    return new DataView(n, i).getInt32(0, !0);
  }
  seek(t) {
    return this.position = Math.min(t, this.size), t < this.size;
  }
  read(t) {
    const { buffer: n, size: i, position: r } = this;
    return n && r < i ? (typeof t != "number" && (t = Number.POSITIVE_INFINITY), this.position = Math.min(i, r + Math.min(i - r, t)), n.subarray(r, this.position)) : null;
  }
  readAt(t, n) {
    const i = this.buffer, r = Math.min(this.size, t + n);
    return i ? i.subarray(t, r) : 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 };
  }
}, Vd = class extends Pd {
  constructor(t, n) {
    super(), this.position = 0, this._handle = t, typeof n == "number" ? this.size = n : this._pending = W(this, void 0, void 0, function* () {
      this.size = (yield t.stat()).size, delete this._pending;
    });
  }
  readInt32(t) {
    return W(this, void 0, void 0, function* () {
      const { buffer: n, byteOffset: i } = yield this.readAt(t, 4);
      return new DataView(n, i).getInt32(0, !0);
    });
  }
  seek(t) {
    return W(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 W(this, void 0, void 0, function* () {
      this._pending && (yield this._pending);
      const { _handle: n, size: i, position: r } = this;
      if (n && r < i) {
        typeof t != "number" && (t = Number.POSITIVE_INFINITY);
        let s = r, o = 0, a = 0;
        const c = Math.min(i, s + Math.min(i - s, t)), l = new Uint8Array(Math.max(0, (this.position = c) - s));
        for (; (s += a) < c && (o += a) < l.byteLength; )
          ({ bytesRead: a } = yield n.read(l, o, l.byteLength - o, s));
        return l;
      }
      return null;
    });
  }
  readAt(t, n) {
    return W(this, void 0, void 0, function* () {
      this._pending && (yield this._pending);
      const { _handle: i, size: r } = this;
      if (i && t + n < r) {
        const s = Math.min(r, t + n), o = new Uint8Array(s - t);
        return (yield i.read(o, 0, n, t)).buffer;
      }
      return new Uint8Array(n);
    });
  }
  close() {
    return W(this, void 0, void 0, function* () {
      const t = this._handle;
      this._handle = null, t && (yield t.close());
    });
  }
  throw(t) {
    return W(this, void 0, void 0, function* () {
      return yield this.close(), { done: !0, value: t };
    });
  }
  return(t) {
    return W(this, void 0, void 0, function* () {
      return yield this.close(), { done: !0, value: t };
    });
  }
};
const y7 = 65536;
function Ja(e) {
  return e < 0 && (e = 4294967295 + e + 1), `0x${e.toString(16)}`;
}
const Ic = 8, Ab = [
  1,
  10,
  100,
  1e3,
  1e4,
  1e5,
  1e6,
  1e7,
  1e8
];
let _M = class {
  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
    ]), i = new Uint32Array([
      t.buffer[1] >>> 16,
      t.buffer[1] & 65535,
      t.buffer[0] >>> 16,
      t.buffer[0] & 65535
    ]);
    let r = n[3] * i[3];
    this.buffer[0] = r & 65535;
    let s = r >>> 16;
    return r = n[2] * i[3], s += r, r = n[3] * i[2] >>> 0, s += r, this.buffer[0] += s << 16, this.buffer[1] = s >>> 0 < r ? y7 : 0, this.buffer[1] += s >>> 16, this.buffer[1] += n[1] * i[3] + n[2] * i[2] + n[3] * i[1], this.buffer[1] += n[0] * i[3] + n[1] * i[2] + n[2] * i[1] + n[3] * i[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 `${Ja(this.buffer[1])} ${Ja(this.buffer[0])}`;
  }
}, Fe = class Dr extends _M {
  times(t) {
    return this._times(t), this;
  }
  plus(t) {
    return this._plus(t), this;
  }
  /** @nocollapse */
  static from(t, n = new Uint32Array(2)) {
    return Dr.fromString(typeof t == "string" ? t : t.toString(), n);
  }
  /** @nocollapse */
  static fromNumber(t, n = new Uint32Array(2)) {
    return Dr.fromString(t.toString(), n);
  }
  /** @nocollapse */
  static fromString(t, n = new Uint32Array(2)) {
    const i = t.length, r = new Dr(n);
    for (let s = 0; s < i; ) {
      const o = Ic < i - s ? Ic : i - s, a = new Dr(new Uint32Array([Number.parseInt(t.slice(s, s + o), 10), 0])), c = new Dr(new Uint32Array([Ab[o], 0]));
      r.times(c), r.plus(a), s += o;
    }
    return r;
  }
  /** @nocollapse */
  static convertArray(t) {
    const n = new Uint32Array(t.length * 2);
    for (let i = -1, r = t.length; ++i < r; )
      Dr.from(t[i], new Uint32Array(n.buffer, n.byteOffset + 2 * i * 4, 2));
    return n;
  }
  /** @nocollapse */
  static multiply(t, n) {
    return new Dr(new Uint32Array(t.buffer)).times(n);
  }
  /** @nocollapse */
  static add(t, n) {
    return new Dr(new Uint32Array(t.buffer)).plus(n);
  }
}, cu = class Nr extends _M {
  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, i = t.buffer[1] << 0;
    return n < i || n === i && this.buffer[0] < t.buffer[0];
  }
  /** @nocollapse */
  static from(t, n = new Uint32Array(2)) {
    return Nr.fromString(typeof t == "string" ? t : t.toString(), n);
  }
  /** @nocollapse */
  static fromNumber(t, n = new Uint32Array(2)) {
    return Nr.fromString(t.toString(), n);
  }
  /** @nocollapse */
  static fromString(t, n = new Uint32Array(2)) {
    const i = t.startsWith("-"), r = t.length, s = new Nr(n);
    for (let o = i ? 1 : 0; o < r; ) {
      const a = Ic < r - o ? Ic : r - o, c = new Nr(new Uint32Array([Number.parseInt(t.slice(o, o + a), 10), 0])), l = new Nr(new Uint32Array([Ab[a], 0]));
      s.times(l), s.plus(c), o += a;
    }
    return i ? s.negate() : s;
  }
  /** @nocollapse */
  static convertArray(t) {
    const n = new Uint32Array(t.length * 2);
    for (let i = -1, r = t.length; ++i < r; )
      Nr.from(t[i], new Uint32Array(n.buffer, n.byteOffset + 2 * i * 4, 2));
    return n;
  }
  /** @nocollapse */
  static multiply(t, n) {
    return new Nr(new Uint32Array(t.buffer)).times(n);
  }
  /** @nocollapse */
  static add(t, n) {
    return new Nr(new Uint32Array(t.buffer)).plus(n);
  }
}, m7 = class Br {
  constructor(t) {
    this.buffer = t;
  }
  high() {
    return new cu(new Uint32Array(this.buffer.buffer, this.buffer.byteOffset + 8, 2));
  }
  low() {
    return new cu(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 Fe(new Uint32Array([this.buffer[3], 0])), i = new Fe(new Uint32Array([this.buffer[2], 0])), r = new Fe(new Uint32Array([this.buffer[1], 0])), s = new Fe(new Uint32Array([this.buffer[0], 0])), o = new Fe(new Uint32Array([t.buffer[3], 0])), a = new Fe(new Uint32Array([t.buffer[2], 0])), c = new Fe(new Uint32Array([t.buffer[1], 0])), l = new Fe(new Uint32Array([t.buffer[0], 0]));
    let u = Fe.multiply(s, l);
    this.buffer[0] = u.low();
    const f = new Fe(new Uint32Array([u.high(), 0]));
    return u = Fe.multiply(r, l), f.plus(u), u = Fe.multiply(s, c), f.plus(u), this.buffer[1] = f.low(), this.buffer[3] = f.lessThan(u) ? 1 : 0, this.buffer[2] = f.high(), new Fe(new Uint32Array(this.buffer.buffer, this.buffer.byteOffset + 8, 2)).plus(Fe.multiply(i, l)).plus(Fe.multiply(r, c)).plus(Fe.multiply(s, a)), this.buffer[3] += Fe.multiply(n, l).plus(Fe.multiply(i, c)).plus(Fe.multiply(r, a)).plus(Fe.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 `${Ja(this.buffer[3])} ${Ja(this.buffer[2])} ${Ja(this.buffer[1])} ${Ja(this.buffer[0])}`;
  }
  /** @nocollapse */
  static multiply(t, n) {
    return new Br(new Uint32Array(t.buffer)).times(n);
  }
  /** @nocollapse */
  static add(t, n) {
    return new Br(new Uint32Array(t.buffer)).plus(n);
  }
  /** @nocollapse */
  static from(t, n = new Uint32Array(4)) {
    return Br.fromString(typeof t == "string" ? t : t.toString(), n);
  }
  /** @nocollapse */
  static fromNumber(t, n = new Uint32Array(4)) {
    return Br.fromString(t.toString(), n);
  }
  /** @nocollapse */
  static fromString(t, n = new Uint32Array(4)) {
    const i = t.startsWith("-"), r = t.length, s = new Br(n);
    for (let o = i ? 1 : 0; o < r; ) {
      const a = Ic < r - o ? Ic : r - o, c = new Br(new Uint32Array([Number.parseInt(t.slice(o, o + a), 10), 0, 0, 0])), l = new Br(new Uint32Array([Ab[a], 0, 0, 0]));
      s.times(l), s.plus(c), o += a;
    }
    return i ? s.negate() : s;
  }
  /** @nocollapse */
  static convertArray(t) {
    const n = new Uint32Array(t.length * 4);
    for (let i = -1, r = t.length; ++i < r; )
      Br.from(t[i], new Uint32Array(n.buffer, n.byteOffset + 4 * 4 * i, 4));
    return n;
  }
}, xM = class extends Ut {
  constructor(t, n, i, r, s = Ee.V5) {
    super(), this.nodesIndex = -1, this.buffersIndex = -1, this.bytes = t, this.nodes = n, this.buffers = i, this.dictionaries = r, this.metadataVersion = s;
  }
  visit(t) {
    return super.visit(t instanceof Te ? t.type : t);
  }
  visitNull(t, { length: n } = this.nextFieldNode()) {
    return Rt({ type: t, length: n });
  }
  visitBool(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitInt(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitFloat(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitUtf8(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), valueOffsets: this.readOffsets(t), data: this.readData(t) });
  }
  visitLargeUtf8(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), valueOffsets: this.readOffsets(t), data: this.readData(t) });
  }
  visitBinary(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), valueOffsets: this.readOffsets(t), data: this.readData(t) });
  }
  visitLargeBinary(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), valueOffsets: this.readOffsets(t), data: this.readData(t) });
  }
  visitFixedSizeBinary(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitDate(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitTimestamp(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitTime(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitDecimal(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitList(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), valueOffsets: this.readOffsets(t), child: this.visit(t.children[0]) });
  }
  visitStruct(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), children: this.visitMany(t.children) });
  }
  visitUnion(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return this.metadataVersion < Ee.V5 && this.readNullBitmap(t, i), t.mode === Mn.Sparse ? this.visitSparseUnion(t, { length: n, nullCount: i }) : this.visitDenseUnion(t, { length: n, nullCount: i });
  }
  visitDenseUnion(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, typeIds: this.readTypeIds(t), valueOffsets: this.readOffsets(t), children: this.visitMany(t.children) });
  }
  visitSparseUnion(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, typeIds: this.readTypeIds(t), children: this.visitMany(t.children) });
  }
  visitDictionary(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t.indices), dictionary: this.readDictionary(t) });
  }
  visitInterval(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitDuration(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitFixedSizeList(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), child: this.visit(t.children[0]) });
  }
  visitMap(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), 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, i = this.nextBufferRange()) {
    return n > 0 && this.readData(t, i) || new Uint8Array(0);
  }
  readOffsets(t, n) {
    return this.readData(t, n);
  }
  readTypeIds(t, n) {
    return this.readData(t, n);
  }
  readData(t, { length: n, offset: i } = this.nextBufferRange()) {
    return this.bytes.subarray(i, i + n);
  }
  readDictionary(t) {
    return this.dictionaries.get(t.id);
  }
}, g7 = class extends xM {
  constructor(t, n, i, r, s) {
    super(new Uint8Array(0), n, i, r, s), this.sources = t;
  }
  readNullBitmap(t, n, { offset: i } = this.nextBufferRange()) {
    return n <= 0 ? new Uint8Array(0) : _g(this.sources[i]);
  }
  readOffsets(t, { offset: n } = this.nextBufferRange()) {
    return re(Uint8Array, re(t.OffsetArrayType, this.sources[n]));
  }
  readTypeIds(t, { offset: n } = this.nextBufferRange()) {
    return re(Uint8Array, re(t.ArrayType, this.sources[n]));
  }
  readData(t, { offset: n } = this.nextBufferRange()) {
    const { sources: i } = this;
    return gt.isTimestamp(t) || (gt.isInt(t) || gt.isTime(t)) && t.bitWidth === 64 || gt.isDuration(t) || gt.isDate(t) && t.unit === Ii.MILLISECOND ? re(Uint8Array, cu.convertArray(i[n])) : gt.isDecimal(t) ? re(Uint8Array, m7.convertArray(i[n])) : gt.isBinary(t) || gt.isLargeBinary(t) || gt.isFixedSizeBinary(t) ? b7(i[n]) : gt.isBool(t) ? _g(i[n]) : gt.isUtf8(t) || gt.isLargeUtf8(t) ? fb(i[n].join("")) : re(Uint8Array, re(t.ArrayType, i[n].map((r) => +r)));
  }
};
function b7(e) {
  const t = e.join(""), n = new Uint8Array(t.length / 2);
  for (let i = 0; i < t.length; i += 2)
    n[i >> 1] = Number.parseInt(t.slice(i, i + 2), 16);
  return n;
}
let ut = class extends Ut {
  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((i, r) => this.compareFields(i, n[r]));
  }
  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 wn(e, t) {
  return t instanceof e.constructor;
}
function sa(e, t) {
  return e === t || wn(e, t);
}
function as(e, t) {
  return e === t || wn(e, t) && e.bitWidth === t.bitWidth && e.isSigned === t.isSigned;
}
function zy(e, t) {
  return e === t || wn(e, t) && e.precision === t.precision;
}
function w7(e, t) {
  return e === t || wn(e, t) && e.byteWidth === t.byteWidth;
}
function Mb(e, t) {
  return e === t || wn(e, t) && e.unit === t.unit;
}
function lf(e, t) {
  return e === t || wn(e, t) && e.unit === t.unit && e.timezone === t.timezone;
}
function uf(e, t) {
  return e === t || wn(e, t) && e.unit === t.unit && e.bitWidth === t.bitWidth;
}
function v7(e, t) {
  return e === t || wn(e, t) && e.children.length === t.children.length && Ps.compareManyFields(e.children, t.children);
}
function _7(e, t) {
  return e === t || wn(e, t) && e.children.length === t.children.length && Ps.compareManyFields(e.children, t.children);
}
function $b(e, t) {
  return e === t || wn(e, t) && e.mode === t.mode && e.typeIds.every((n, i) => n === t.typeIds[i]) && Ps.compareManyFields(e.children, t.children);
}
function x7(e, t) {
  return e === t || wn(e, t) && e.id === t.id && e.isOrdered === t.isOrdered && Ps.visit(e.indices, t.indices) && Ps.visit(e.dictionary, t.dictionary);
}
function Tb(e, t) {
  return e === t || wn(e, t) && e.unit === t.unit;
}
function ff(e, t) {
  return e === t || wn(e, t) && e.unit === t.unit;
}
function S7(e, t) {
  return e === t || wn(e, t) && e.listSize === t.listSize && e.children.length === t.children.length && Ps.compareManyFields(e.children, t.children);
}
function I7(e, t) {
  return e === t || wn(e, t) && e.keysSorted === t.keysSorted && e.children.length === t.children.length && Ps.compareManyFields(e.children, t.children);
}
ut.prototype.visitNull = sa;
ut.prototype.visitBool = sa;
ut.prototype.visitInt = as;
ut.prototype.visitInt8 = as;
ut.prototype.visitInt16 = as;
ut.prototype.visitInt32 = as;
ut.prototype.visitInt64 = as;
ut.prototype.visitUint8 = as;
ut.prototype.visitUint16 = as;
ut.prototype.visitUint32 = as;
ut.prototype.visitUint64 = as;
ut.prototype.visitFloat = zy;
ut.prototype.visitFloat16 = zy;
ut.prototype.visitFloat32 = zy;
ut.prototype.visitFloat64 = zy;
ut.prototype.visitUtf8 = sa;
ut.prototype.visitLargeUtf8 = sa;
ut.prototype.visitBinary = sa;
ut.prototype.visitLargeBinary = sa;
ut.prototype.visitFixedSizeBinary = w7;
ut.prototype.visitDate = Mb;
ut.prototype.visitDateDay = Mb;
ut.prototype.visitDateMillisecond = Mb;
ut.prototype.visitTimestamp = lf;
ut.prototype.visitTimestampSecond = lf;
ut.prototype.visitTimestampMillisecond = lf;
ut.prototype.visitTimestampMicrosecond = lf;
ut.prototype.visitTimestampNanosecond = lf;
ut.prototype.visitTime = uf;
ut.prototype.visitTimeSecond = uf;
ut.prototype.visitTimeMillisecond = uf;
ut.prototype.visitTimeMicrosecond = uf;
ut.prototype.visitTimeNanosecond = uf;
ut.prototype.visitDecimal = sa;
ut.prototype.visitList = v7;
ut.prototype.visitStruct = _7;
ut.prototype.visitUnion = $b;
ut.prototype.visitDenseUnion = $b;
ut.prototype.visitSparseUnion = $b;
ut.prototype.visitDictionary = x7;
ut.prototype.visitInterval = Tb;
ut.prototype.visitIntervalDayTime = Tb;
ut.prototype.visitIntervalYearMonth = Tb;
ut.prototype.visitDuration = ff;
ut.prototype.visitDurationSecond = ff;
ut.prototype.visitDurationMillisecond = ff;
ut.prototype.visitDurationMicrosecond = ff;
ut.prototype.visitDurationNanosecond = ff;
ut.prototype.visitFixedSizeList = S7;
ut.prototype.visitMap = I7;
const Ps = new ut();
function A7(e, t) {
  return Ps.compareSchemas(e, t);
}
function rm(e, t) {
  return M7(e, t.map((n) => n.data.concat()));
}
function M7(e, t) {
  const n = [...e.fields], i = [], r = { numBatches: t.reduce((f, h) => Math.max(f, h.length), 0) };
  let s = 0, o = 0, a = -1;
  const c = t.length;
  let l, u = [];
  for (; r.numBatches-- > 0; ) {
    for (o = Number.POSITIVE_INFINITY, a = -1; ++a < c; )
      u[a] = l = t[a].shift(), o = Math.min(o, l ? l.length : o);
    Number.isFinite(o) && (u = $7(n, o, u, t, r), o > 0 && (i[s++] = Rt({
      type: new fn(n),
      length: o,
      nullCount: 0,
      children: u.slice()
    })));
  }
  return [
    e = e.assign(n),
    i.map((f) => new gi(e, f))
  ];
}
function $7(e, t, n, i, r) {
  var s;
  const o = (t + 63 & -64) >> 3;
  for (let a = -1, c = i.length; ++a < c; ) {
    const l = n[a], u = l == null ? void 0 : l.length;
    if (u >= t)
      u === t ? n[a] = l : (n[a] = l.slice(0, t), r.numBatches = Math.max(r.numBatches, i[a].unshift(l.slice(t, u - t))));
    else {
      const f = e[a];
      e[a] = f.clone({ nullable: !0 }), n[a] = (s = l == null ? void 0 : l._changeLengthAndBackfillNullBitmap(t)) !== null && s !== void 0 ? s : Rt({
        type: f.type,
        length: t,
        nullCount: t,
        nullBitmap: new Uint8Array(o)
      });
    }
  }
  return n;
}
var SM;
let $u = class $o {
  constructor(...t) {
    var n, i;
    if (t.length === 0)
      return this.batches = [], this.schema = new _e([]), this._offsets = [0], this;
    let r, s;
    t[0] instanceof _e && (r = t.shift()), t.at(-1) instanceof Uint32Array && (s = t.pop());
    const o = (c) => {
      if (c) {
        if (c instanceof gi)
          return [c];
        if (c instanceof $o)
          return c.batches;
        if (c instanceof de) {
          if (c.type instanceof fn)
            return [new gi(new _e(c.type.children), c)];
        } else {
          if (Array.isArray(c))
            return c.flatMap((l) => o(l));
          if (typeof c[Symbol.iterator] == "function")
            return [...c].flatMap((l) => o(l));
          if (typeof c == "object") {
            const l = Object.keys(c), u = l.map((d) => new Ne([c[d]])), f = r ?? new _e(l.map((d, p) => new Te(String(d), u[p].type, u[p].nullable))), [, h] = rm(f, u);
            return h.length === 0 ? [new gi(c)] : h;
          }
        }
      }
      return [];
    }, a = t.flatMap((c) => o(c));
    if (r = (i = r ?? ((n = a[0]) === null || n === void 0 ? void 0 : n.schema)) !== null && i !== void 0 ? i : new _e([]), !(r instanceof _e))
      throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");
    for (const c of a) {
      if (!(c instanceof gi))
        throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");
      if (!A7(r, c.schema))
        throw new TypeError("Table and inner RecordBatch schemas must be equivalent.");
    }
    this.schema = r, this.batches = a, this._offsets = s ?? lM(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 = cM(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;
  }
  /**
   * 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 ? Sb.visit(new Ne(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, i = this.data.concat(t.flatMap(({ data: r }) => r));
    return new $o(n, i.map((r) => new gi(n, r)));
  }
  /**
   * 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 i = this.schema;
    [t, n] = oM({ length: this.numRows }, t, n);
    const r = uM(this.data, this._offsets, t, n);
    return new $o(i, r.map((s) => new gi(i, 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((i) => i.children[t]);
      if (n.length === 0) {
        const { type: i } = this.schema.fields[t], r = Rt({ type: i, length: 0, nullCount: 0 });
        n.push(r._changeLengthAndBackfillNullBitmap(this.numRows));
      }
      return new Ne(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 i;
    return this.setChildAt((i = this.schema.fields) === null || i === void 0 ? void 0 : i.findIndex((r) => r.name === t), n);
  }
  setChildAt(t, n) {
    let i = this.schema, r = [...this.batches];
    if (t > -1 && t < this.numCols) {
      n || (n = new Ne([Rt({ type: new Us(), length: this.numRows })]));
      const s = i.fields.slice(), o = s[t].clone({ type: n.type }), a = this.schema.fields.map((c, l) => this.getChildAt(l));
      [s[t], a[t]] = [o, n], [i, r] = rm(i, a);
    }
    return new $o(i, r);
  }
  /**
   * 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((i, r, s) => i.set(r.name, s), /* @__PURE__ */ new Map());
    return this.selectAt(t.map((i) => n.get(i)).filter((i) => i > -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), i = this.batches.map((r) => r.selectAt(t));
    return new $o(n, i);
  }
  assign(t) {
    const n = this.schema.fields, [i, r] = t.schema.fields.reduce((a, c, l) => {
      const [u, f] = a, h = n.findIndex((d) => d.name === c.name);
      return ~h ? f[h] = l : u.push(l), a;
    }, [[], []]), s = this.schema.assign(t.schema), o = [
      ...n.map((a, c) => [c, r[c]]).map(([a, c]) => c === void 0 ? this.getChildAt(a) : t.getChildAt(c)),
      ...i.map((a) => t.getChildAt(a))
    ].filter(Boolean);
    return new $o(...rm(s, o));
  }
};
SM = Symbol.toStringTag;
$u[SM] = ((e) => (e.schema = null, e.batches = [], e._offsets = new Uint32Array([0]), e._nullCount = -1, e[Symbol.isConcatSpreadable] = !0, e.isValid = Cd(xb), e.get = Cd($n.getVisitFn(F.Struct)), e.set = fM(ci.getVisitFn(F.Struct)), e.indexOf = hM(kd.getVisitFn(F.Struct)), "Table"))($u.prototype);
var IM;
let gi = class ql {
  constructor(...t) {
    switch (t.length) {
      case 2: {
        if ([this.schema] = t, !(this.schema instanceof _e))
          throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");
        if ([
          ,
          this.data = Rt({
            nullCount: 0,
            type: new fn(this.schema.fields),
            children: this.schema.fields.map((n) => Rt({ type: n.type, nullCount: 0 }))
          })
        ] = t, !(this.data instanceof de))
          throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");
        [this.schema, this.data] = X_(this.schema, this.data.children);
        break;
      }
      case 1: {
        const [n] = t, { fields: i, children: r, length: s } = Object.keys(n).reduce((c, l, u) => (c.children[u] = n[l], c.length = Math.max(c.length, n[l].length), c.fields[u] = Te.new({ name: l, type: n[l].type, nullable: !0 }), c), {
          length: 0,
          fields: new Array(),
          children: new Array()
        }), o = new _e(i), a = Rt({ type: new fn(i), length: s, children: r, nullCount: 0 });
        [this.schema, this.data] = X_(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 = AM(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 element 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 element to read.
   */
  get(t) {
    return $n.visit(this.data, t);
  }
  /**
   * Set a row by position.
   * @param index The index of the element to write.
   * @param value The value to set.
   */
  set(t, n) {
    return ci.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 kd.visit(this.data, t, n);
  }
  /**
   * Iterator for rows in this RecordBatch.
   */
  [Symbol.iterator]() {
    return Sb.visit(new Ne([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 $u(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 element at the index 'end'.
   */
  slice(t, n) {
    const [i] = new Ne([this.data]).slice(t, n).data;
    return new ql(this.schema, i);
  }
  /**
   * 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((i) => i.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 Ne([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 i;
    return this.setChildAt((i = this.schema.fields) === null || i === void 0 ? void 0 : i.findIndex((r) => r.name === t), n);
  }
  setChildAt(t, n) {
    let i = this.schema, r = this.data;
    if (t > -1 && t < this.numCols) {
      n || (n = new Ne([Rt({ type: new Us(), length: this.numRows })]));
      const s = i.fields.slice(), o = r.children.slice(), a = s[t].clone({ type: n.type });
      [s[t], o[t]] = [a, n.data[0]], i = new _e(s, new Map(this.schema.metadata)), r = Rt({ type: new fn(s), children: o });
    }
    return new ql(i, r);
  }
  /**
   * 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), i = new fn(n.fields), r = [];
    for (const s of t) {
      const o = this.schema.fields.findIndex((a) => a.name === s);
      ~o && (r[o] = this.data.children[o]);
    }
    return new ql(n, Rt({ type: i, length: this.numRows, children: r }));
  }
  /**
   * 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), i = t.map((s) => this.data.children[s]).filter(Boolean), r = Rt({ type: new fn(n.fields), length: this.numRows, children: i });
    return new ql(n, r);
  }
};
IM = Symbol.toStringTag;
gi[IM] = ((e) => (e._nullCount = -1, e[Symbol.isConcatSpreadable] = !0, "RecordBatch"))(gi.prototype);
function X_(e, t, n = t.reduce((i, r) => Math.max(i, r.length), 0)) {
  var i;
  const r = [...e.fields], s = [...t], o = (n + 63 & -64) >> 3;
  for (const [a, c] of e.fields.entries()) {
    const l = t[a];
    (!l || l.length !== n) && (r[a] = c.clone({ nullable: !0 }), s[a] = (i = l == null ? void 0 : l._changeLengthAndBackfillNullBitmap(n)) !== null && i !== void 0 ? i : Rt({
      type: c.type,
      length: n,
      nullCount: n,
      nullBitmap: new Uint8Array(o)
    }));
  }
  return [
    e.assign(r),
    Rt({ type: new fn(r), length: n, children: s })
  ];
}
function AM(e, t, n = /* @__PURE__ */ new Map()) {
  var i, r;
  if (((i = e == null ? void 0 : e.length) !== null && i !== void 0 ? i : 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 l of [c, ...((r = c == null ? void 0 : c.dictionary) === null || r === void 0 ? void 0 : r.data) || []])
        AM(a.children, l == null ? void 0 : l.children, n);
      if (gt.isDictionary(a)) {
        const { id: l } = a;
        if (!n.has(l))
          c != null && c.dictionary && n.set(l, c.dictionary);
        else if (n.get(l) !== c.dictionary)
          throw new Error("Cannot create Schema containing two different dictionaries with the same Id");
      }
    }
  return n;
}
let MM = class extends gi {
  constructor(t) {
    const n = t.fields.map((r) => Rt({ type: r.type })), i = Rt({ type: new fn(t.fields), nullCount: 0, children: n });
    super(t, i);
  }
}, gs = class ji {
  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 ji()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsMessage(t, n) {
    return t.setPosition(t.position() + nt), (n || new ji()).__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) : Ee.V1;
  }
  headerType() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? this.bb.readUint8(this.bb_pos + t) : Qt.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 i = this.bb.__offset(this.bb_pos, 12);
    return i ? (n || new ni()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + i) + 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, Ee.V1);
  }
  static addHeaderType(t, n) {
    t.addFieldInt8(1, n, Qt.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 i = n.length - 1; i >= 0; i--)
      t.addOffset(n[i]);
    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, i, r, s, o) {
    return ji.startMessage(t), ji.addVersion(t, n), ji.addHeaderType(t, i), ji.addHeader(t, r), ji.addBodyLength(t, s), ji.addCustomMetadata(t, o), ji.endMessage(t);
  }
}, T7 = class extends Ut {
  visit(t, n) {
    return t == null || n == null ? void 0 : super.visit(t, n);
  }
  visitNull(t, n) {
    return R_.startNull(n), R_.endNull(n);
  }
  visitInt(t, n) {
    return Ha.startInt(n), Ha.addBitWidth(n, t.bitWidth), Ha.addIsSigned(n, t.isSigned), Ha.endInt(n);
  }
  visitFloat(t, n) {
    return qh.startFloatingPoint(n), qh.addPrecision(n, t.precision), qh.endFloatingPoint(n);
  }
  visitBinary(t, n) {
    return B_.startBinary(n), B_.endBinary(n);
  }
  visitLargeBinary(t, n) {
    return F_.startLargeBinary(n), F_.endLargeBinary(n);
  }
  visitBool(t, n) {
    return O_.startBool(n), O_.endBool(n);
  }
  visitUtf8(t, n) {
    return k_.startUtf8(n), k_.endUtf8(n);
  }
  visitLargeUtf8(t, n) {
    return E_.startLargeUtf8(n), E_.endLargeUtf8(n);
  }
  visitDecimal(t, n) {
    return Ba.startDecimal(n), Ba.addScale(n, t.scale), Ba.addPrecision(n, t.precision), Ba.addBitWidth(n, t.bitWidth), Ba.endDecimal(n);
  }
  visitDate(t, n) {
    return zh.startDate(n), zh.addUnit(n, t.unit), zh.endDate(n);
  }
  visitTime(t, n) {
    return Pl.startTime(n), Pl.addUnit(n, t.unit), Pl.addBitWidth(n, t.bitWidth), Pl.endTime(n);
  }
  visitTimestamp(t, n) {
    const i = t.timezone && n.createString(t.timezone) || void 0;
    return Vl.startTimestamp(n), Vl.addUnit(n, t.unit), i !== void 0 && Vl.addTimezone(n, i), Vl.endTimestamp(n);
  }
  visitInterval(t, n) {
    return Yh.startInterval(n), Yh.addUnit(n, t.unit), Yh.endInterval(n);
  }
  visitDuration(t, n) {
    return Ph.startDuration(n), Ph.addUnit(n, t.unit), Ph.endDuration(n);
  }
  visitList(t, n) {
    return L_.startList(n), L_.endList(n);
  }
  visitStruct(t, n) {
    return C_.startStruct_(n), C_.endStruct_(n);
  }
  visitUnion(t, n) {
    So.startTypeIdsVector(n, t.typeIds.length);
    const i = So.createTypeIdsVector(n, t.typeIds);
    return So.startUnion(n), So.addMode(n, t.mode), So.addTypeIds(n, i), So.endUnion(n);
  }
  visitDictionary(t, n) {
    const i = this.visit(t.indices, n);
    return Da.startDictionaryEncoding(n), Da.addId(n, BigInt(t.id)), Da.addIsOrdered(n, t.isOrdered), i !== void 0 && Da.addIndexType(n, i), Da.endDictionaryEncoding(n);
  }
  visitFixedSizeBinary(t, n) {
    return Vh.startFixedSizeBinary(n), Vh.addByteWidth(n, t.byteWidth), Vh.endFixedSizeBinary(n);
  }
  visitFixedSizeList(t, n) {
    return jh.startFixedSizeList(n), jh.addListSize(n, t.listSize), jh.endFixedSizeList(n);
  }
  visitMap(t, n) {
    return Wh.startMap(n), Wh.addKeysSorted(n, t.keysSorted), Wh.endMap(n);
  }
};
const sm = new T7();
function D7(e, t = /* @__PURE__ */ new Map()) {
  return new _e(B7(e, t), Hh(e.metadata), t);
}
function $M(e) {
  return new Ai(e.count, TM(e.columns), DM(e.columns));
}
function N7(e) {
  return new ns($M(e.data), e.id, e.isDelta);
}
function B7(e, t) {
  return (e.fields || []).filter(Boolean).map((n) => Te.fromJSON(n, t));
}
function H_(e, t) {
  return (e.children || []).filter(Boolean).map((n) => Te.fromJSON(n, t));
}
function TM(e) {
  return (e || []).reduce((t, n) => [
    ...t,
    new Zc(n.count, O7(n.VALIDITY)),
    ...TM(n.children)
  ], []);
}
function DM(e, t = []) {
  for (let n = -1, i = (e || []).length; ++n < i; ) {
    const r = e[n];
    r.VALIDITY && t.push(new qr(t.length, r.VALIDITY.length)), r.TYPE_ID && t.push(new qr(t.length, r.TYPE_ID.length)), r.OFFSET && t.push(new qr(t.length, r.OFFSET.length)), r.DATA && t.push(new qr(t.length, r.DATA.length)), t = DM(r.children, t);
  }
  return t;
}
function O7(e) {
  return (e || []).reduce((t, n) => t + +(n === 0), 0);
}
function F7(e, t) {
  let n, i, r, s, o, a;
  return !t || !(s = e.dictionary) ? (o = K_(e, H_(e, t)), r = new Te(e.name, o, e.nullable, Hh(e.metadata))) : t.has(n = s.id) ? (i = (i = s.indexType) ? J_(i) : new Iu(), a = new Sc(t.get(n), i, n, s.isOrdered), r = new Te(e.name, a, e.nullable, Hh(e.metadata))) : (i = (i = s.indexType) ? J_(i) : new Iu(), t.set(n, o = K_(e, H_(e, t))), a = new Sc(o, i, n, s.isOrdered), r = new Te(e.name, a, e.nullable, Hh(e.metadata))), r || null;
}
function Hh(e = []) {
  return new Map(e.map(({ key: t, value: n }) => [t, n]));
}
function J_(e) {
  return new zs(e.isSigned, e.bitWidth);
}
function K_(e, t) {
  const n = e.type.name;
  switch (n) {
    case "NONE":
      return new Us();
    case "null":
      return new Us();
    case "binary":
      return new xd();
    case "largebinary":
      return new Sd();
    case "utf8":
      return new Id();
    case "largeutf8":
      return new Ad();
    case "bool":
      return new Md();
    case "list":
      return new Od((t || [])[0]);
    case "struct":
      return new fn(t || []);
    case "struct_":
      return new fn(t || []);
  }
  switch (n) {
    case "int": {
      const i = e.type;
      return new zs(i.isSigned, i.bitWidth);
    }
    case "floatingpoint": {
      const i = e.type;
      return new Au(nn[i.precision]);
    }
    case "decimal": {
      const i = e.type;
      return new $d(i.scale, i.precision, i.bitWidth);
    }
    case "date": {
      const i = e.type;
      return new Td(Ii[i.unit]);
    }
    case "time": {
      const i = e.type;
      return new Mu(mt[i.unit], i.bitWidth);
    }
    case "timestamp": {
      const i = e.type;
      return new Dd(mt[i.unit], i.timezone);
    }
    case "interval": {
      const i = e.type;
      return new Nd(lr[i.unit]);
    }
    case "duration": {
      const i = e.type;
      return new Bd(mt[i.unit]);
    }
    case "union": {
      const i = e.type, [r, ...s] = (i.mode + "").toLowerCase(), o = r.toUpperCase() + s.join("");
      return new Fd(Mn[o], i.typeIds || [], t || []);
    }
    case "fixedsizebinary": {
      const i = e.type;
      return new Ed(i.byteWidth);
    }
    case "fixedsizelist": {
      const i = e.type;
      return new Ld(i.listSize, (t || [])[0]);
    }
    case "map": {
      const i = e.type;
      return new Rd((t || [])[0], i.keysSorted);
    }
  }
  throw new Error(`Unrecognized type: "${n}"`);
}
var E7 = ky, L7 = ur;
let lu = class Ua {
  /** @nocollapse */
  static fromJSON(t, n) {
    const i = new Ua(0, Ee.V5, n);
    return i._createHeader = R7(t, n), i;
  }
  /** @nocollapse */
  static decode(t) {
    t = new L7(Yt(t));
    const n = gs.getRootAsMessage(t), i = n.bodyLength(), r = n.version(), s = n.headerType(), o = new Ua(i, r, s);
    return o._createHeader = C7(n, s), o;
  }
  /** @nocollapse */
  static encode(t) {
    const n = new E7();
    let i = -1;
    return t.isSchema() ? i = _e.encode(n, t.header()) : t.isRecordBatch() ? i = Ai.encode(n, t.header()) : t.isDictionaryBatch() && (i = ns.encode(n, t.header())), gs.startMessage(n), gs.addVersion(n, Ee.V5), gs.addHeader(n, i), gs.addHeaderType(n, t.headerType), gs.addBodyLength(n, BigInt(t.bodyLength)), gs.finishMessageBuffer(n, gs.endMessage(n)), n.asUint8Array();
  }
  /** @nocollapse */
  static from(t, n = 0) {
    if (t instanceof _e)
      return new Ua(0, Ee.V5, Qt.Schema, t);
    if (t instanceof Ai)
      return new Ua(n, Ee.V5, Qt.RecordBatch, t);
    if (t instanceof ns)
      return new Ua(n, Ee.V5, Qt.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 === Qt.Schema;
  }
  isRecordBatch() {
    return this.headerType === Qt.RecordBatch;
  }
  isDictionaryBatch() {
    return this.headerType === Qt.DictionaryBatch;
  }
  constructor(t, n, i, r) {
    this._version = n, this._headerType = i, this.body = new Uint8Array(0), r && (this._createHeader = () => r), this._bodyLength = pn(t);
  }
}, Ai = class {
  get nodes() {
    return this._nodes;
  }
  get length() {
    return this._length;
  }
  get buffers() {
    return this._buffers;
  }
  constructor(t, n, i) {
    this._nodes = n, this._buffers = i, this._length = pn(t);
  }
}, ns = class {
  get id() {
    return this._id;
  }
  get data() {
    return this._data;
  }
  get isDelta() {
    return this._isDelta;
  }
  get length() {
    return this.data.length;
  }
  get nodes() {
    return this.data.nodes;
  }
  get buffers() {
    return this.data.buffers;
  }
  constructor(t, n, i = !1) {
    this._data = t, this._isDelta = i, this._id = pn(n);
  }
}, qr = class {
  constructor(t, n) {
    this.offset = pn(t), this.length = pn(n);
  }
}, Zc = class {
  constructor(t, n) {
    this.length = pn(t), this.nullCount = pn(n);
  }
};
function R7(e, t) {
  return () => {
    switch (t) {
      case Qt.Schema:
        return _e.fromJSON(e);
      case Qt.RecordBatch:
        return Ai.fromJSON(e);
      case Qt.DictionaryBatch:
        return ns.fromJSON(e);
    }
    throw new Error(`Unrecognized Message type: { name: ${Qt[t]}, type: ${t} }`);
  };
}
function C7(e, t) {
  return () => {
    switch (t) {
      case Qt.Schema:
        return _e.decode(e.header(new Yi()), /* @__PURE__ */ new Map(), e.version());
      case Qt.RecordBatch:
        return Ai.decode(e.header(new Er()), e.version());
      case Qt.DictionaryBatch:
        return ns.decode(e.header(new Ta()), e.version());
    }
    throw new Error(`Unrecognized Message type: { name: ${Qt[t]}, type: ${t} }`);
  };
}
Te.encode = X7;
Te.decode = W7;
Te.fromJSON = F7;
_e.encode = G7;
_e.decode = k7;
_e.fromJSON = D7;
Ai.encode = H7;
Ai.decode = U7;
Ai.fromJSON = $M;
ns.encode = J7;
ns.decode = z7;
ns.fromJSON = N7;
Zc.encode = K7;
Zc.decode = V7;
qr.encode = Z7;
qr.decode = P7;
function k7(e, t = /* @__PURE__ */ new Map(), n = Ee.V5) {
  const i = Y7(e, t);
  return new _e(i, Jh(e), t, n);
}
function U7(e, t = Ee.V5) {
  if (e.compression() !== null)
    throw new Error("Record batch compression not implemented");
  return new Ai(e.length(), j7(e), q7(e, t));
}
function z7(e, t = Ee.V5) {
  return new ns(Ai.decode(e.data(), t), e.id(), e.isDelta());
}
function P7(e) {
  return new qr(e.offset(), e.length());
}
function V7(e) {
  return new Zc(e.length(), e.nullCount());
}
function j7(e) {
  const t = [];
  for (let n, i = -1, r = -1, s = e.nodesLength(); ++i < s; )
    (n = e.nodes(i)) && (t[++r] = Zc.decode(n));
  return t;
}
function q7(e, t) {
  const n = [];
  for (let i, r = -1, s = -1, o = e.buffersLength(); ++r < o; )
    (i = e.buffers(r)) && (t < Ee.V4 && (i.bb_pos += 8 * (r + 1)), n[++s] = qr.decode(i));
  return n;
}
function Y7(e, t) {
  const n = [];
  for (let i, r = -1, s = -1, o = e.fieldsLength(); ++r < o; )
    (i = e.fields(r)) && (n[++s] = Te.decode(i, t));
  return n;
}
function Z_(e, t) {
  const n = [];
  for (let i, r = -1, s = -1, o = e.childrenLength(); ++r < o; )
    (i = e.children(r)) && (n[++s] = Te.decode(i, t));
  return n;
}
function W7(e, t) {
  let n, i, r, s, o, a;
  return !t || !(a = e.dictionary()) ? (r = t2(e, Z_(e, t)), i = new Te(e.name(), r, e.nullable(), Jh(e))) : t.has(n = pn(a.id())) ? (s = (s = a.indexType()) ? Q_(s) : new Iu(), o = new Sc(t.get(n), s, n, a.isOrdered()), i = new Te(e.name(), o, e.nullable(), Jh(e))) : (s = (s = a.indexType()) ? Q_(s) : new Iu(), t.set(n, r = t2(e, Z_(e, t))), o = new Sc(r, s, n, a.isOrdered()), i = new Te(e.name(), o, e.nullable(), Jh(e))), i || null;
}
function Jh(e) {
  const t = /* @__PURE__ */ new Map();
  if (e)
    for (let n, i, r = -1, s = Math.trunc(e.customMetadataLength()); ++r < s; )
      (n = e.customMetadata(r)) && (i = n.key()) != null && t.set(i, n.value());
  return t;
}
function Q_(e) {
  return new zs(e.isSigned(), e.bitWidth());
}
function t2(e, t) {
  const n = e.typeType();
  switch (n) {
    case he.NONE:
      return new Us();
    case he.Null:
      return new Us();
    case he.Binary:
      return new xd();
    case he.LargeBinary:
      return new Sd();
    case he.Utf8:
      return new Id();
    case he.LargeUtf8:
      return new Ad();
    case he.Bool:
      return new Md();
    case he.List:
      return new Od((t || [])[0]);
    case he.Struct_:
      return new fn(t || []);
  }
  switch (n) {
    case he.Int: {
      const i = e.type(new Ha());
      return new zs(i.isSigned(), i.bitWidth());
    }
    case he.FloatingPoint: {
      const i = e.type(new qh());
      return new Au(i.precision());
    }
    case he.Decimal: {
      const i = e.type(new Ba());
      return new $d(i.scale(), i.precision(), i.bitWidth());
    }
    case he.Date: {
      const i = e.type(new zh());
      return new Td(i.unit());
    }
    case he.Time: {
      const i = e.type(new Pl());
      return new Mu(i.unit(), i.bitWidth());
    }
    case he.Timestamp: {
      const i = e.type(new Vl());
      return new Dd(i.unit(), i.timezone());
    }
    case he.Interval: {
      const i = e.type(new Yh());
      return new Nd(i.unit());
    }
    case he.Duration: {
      const i = e.type(new Ph());
      return new Bd(i.unit());
    }
    case he.Union: {
      const i = e.type(new So());
      return new Fd(i.mode(), i.typeIdsArray() || [], t || []);
    }
    case he.FixedSizeBinary: {
      const i = e.type(new Vh());
      return new Ed(i.byteWidth());
    }
    case he.FixedSizeList: {
      const i = e.type(new jh());
      return new Ld(i.listSize(), (t || [])[0]);
    }
    case he.Map: {
      const i = e.type(new Wh());
      return new Rd((t || [])[0], i.keysSorted());
    }
  }
  throw new Error(`Unrecognized type: "${he[n]}" (${n})`);
}
function G7(e, t) {
  const n = t.fields.map((s) => Te.encode(e, s));
  Yi.startFieldsVector(e, n.length);
  const i = Yi.createFieldsVector(e, n), r = t.metadata && t.metadata.size > 0 ? Yi.createCustomMetadataVector(e, [...t.metadata].map(([s, o]) => {
    const a = e.createString(`${s}`), c = e.createString(`${o}`);
    return ni.startKeyValue(e), ni.addKey(e, a), ni.addValue(e, c), ni.endKeyValue(e);
  })) : -1;
  return Yi.startSchema(e), Yi.addFields(e, i), Yi.addEndianness(e, Q7 ? xc.Little : xc.Big), r !== -1 && Yi.addCustomMetadata(e, r), Yi.endSchema(e);
}
function X7(e, t) {
  let n = -1, i = -1, r = -1;
  const s = t.type;
  let o = t.typeId;
  gt.isDictionary(s) ? (o = s.dictionary.typeId, r = sm.visit(s, e), i = sm.visit(s.dictionary, e)) : i = sm.visit(s, e);
  const a = (s.children || []).map((u) => Te.encode(e, u)), c = Gn.createChildrenVector(e, a), l = t.metadata && t.metadata.size > 0 ? Gn.createCustomMetadataVector(e, [...t.metadata].map(([u, f]) => {
    const h = e.createString(`${u}`), d = e.createString(`${f}`);
    return ni.startKeyValue(e), ni.addKey(e, h), ni.addValue(e, d), ni.endKeyValue(e);
  })) : -1;
  return t.name && (n = e.createString(t.name)), Gn.startField(e), Gn.addType(e, i), Gn.addTypeType(e, o), Gn.addChildren(e, c), Gn.addNullable(e, !!t.nullable), n !== -1 && Gn.addName(e, n), r !== -1 && Gn.addDictionary(e, r), l !== -1 && Gn.addCustomMetadata(e, l), Gn.endField(e);
}
function H7(e, t) {
  const n = t.nodes || [], i = t.buffers || [];
  Er.startNodesVector(e, n.length);
  for (const o of n.slice().reverse())
    Zc.encode(e, o);
  const r = e.endVector();
  Er.startBuffersVector(e, i.length);
  for (const o of i.slice().reverse())
    qr.encode(e, o);
  const s = e.endVector();
  return Er.startRecordBatch(e), Er.addLength(e, BigInt(t.length)), Er.addNodes(e, r), Er.addBuffers(e, s), Er.endRecordBatch(e);
}
function J7(e, t) {
  const n = Ai.encode(e, t.data);
  return Ta.startDictionaryBatch(e), Ta.addId(e, BigInt(t.id)), Ta.addIsDelta(e, t.isDelta), Ta.addData(e, n), Ta.endDictionaryBatch(e);
}
function K7(e, t) {
  return VI.createFieldNode(e, BigInt(t.length), BigInt(t.nullCount));
}
function Z7(e, t) {
  return PI.createBuffer(e, BigInt(t.offset), BigInt(t.length));
}
const Q7 = (() => {
  const e = new ArrayBuffer(2);
  return new DataView(e).setInt16(
    0,
    256,
    !0
    /* littleEndian */
  ), new Int16Array(e)[0] === 256;
})(), Db = (e) => `Expected ${Qt[e]} Message in stream, but was null or length 0.`, Nb = (e) => `Header pointer of flatbuffer-encoded ${Qt[e]} Message is null or length 0.`, NM = (e, t) => `Expected to read ${e} metadata bytes, but only read ${t}.`, BM = (e, t) => `Expected to read ${e} bytes for message body, but only read ${t}.`;
let OM = class {
  constructor(t) {
    this.source = t instanceof zd ? t : new zd(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 ? xe : 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(Db(t));
    return n.value;
  }
  readMessageBody(t) {
    if (t <= 0)
      return new Uint8Array(0);
    const n = Yt(this.source.read(t));
    if (n.byteLength < t)
      throw new Error(BM(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 = Qt.Schema, i = this.readMessage(n), r = i == null ? void 0 : i.header();
    if (t && !r)
      throw new Error(Nb(n));
    return r;
  }
  readMetadataLength() {
    const t = this.source.read(Py), n = t && new ur(t), i = (n == null ? void 0 : n.readInt32(0)) || 0;
    return { done: i === 0, value: i };
  }
  readMetadata(t) {
    const n = this.source.read(t);
    if (!n)
      return xe;
    if (n.byteLength < t)
      throw new Error(NM(t, n.byteLength));
    return { done: !1, value: lu.decode(n) };
  }
}, t9 = class {
  constructor(t, n) {
    this.source = t instanceof Pd ? t : EI(t) ? new Vd(t, n) : new Pd(t);
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  next() {
    return W(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 ? xe : t;
    });
  }
  throw(t) {
    return W(this, void 0, void 0, function* () {
      return yield this.source.throw(t);
    });
  }
  return(t) {
    return W(this, void 0, void 0, function* () {
      return yield this.source.return(t);
    });
  }
  readMessage(t) {
    return W(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(Db(t));
      return n.value;
    });
  }
  readMessageBody(t) {
    return W(this, void 0, void 0, function* () {
      if (t <= 0)
        return new Uint8Array(0);
      const n = Yt(yield this.source.read(t));
      if (n.byteLength < t)
        throw new Error(BM(t, n.byteLength));
      return (
        /* 1. */
        n.byteOffset % 8 === 0 && /* 2. */
        n.byteOffset + n.byteLength <= n.buffer.byteLength ? n : n.slice()
      );
    });
  }
  readSchema(t = !1) {
    return W(this, void 0, void 0, function* () {
      const n = Qt.Schema, i = yield this.readMessage(n), r = i == null ? void 0 : i.header();
      if (t && !r)
        throw new Error(Nb(n));
      return r;
    });
  }
  readMetadataLength() {
    return W(this, void 0, void 0, function* () {
      const t = yield this.source.read(Py), n = t && new ur(t), i = (n == null ? void 0 : n.readInt32(0)) || 0;
      return { done: i === 0, value: i };
    });
  }
  readMetadata(t) {
    return W(this, void 0, void 0, function* () {
      const n = yield this.source.read(t);
      if (!n)
        return xe;
      if (n.byteLength < t)
        throw new Error(NM(t, n.byteLength));
      return { done: !1, value: lu.decode(n) };
    });
  }
}, e9 = class extends OM {
  constructor(t) {
    super(new Uint8Array(0)), this._schema = !1, this._body = [], this._batchIndex = 0, this._dictionaryIndex = 0, this._json = t instanceof W_ ? t : new W_(t);
  }
  next() {
    const { _json: t } = this;
    if (!this._schema)
      return this._schema = !0, { done: !1, value: lu.fromJSON(t.schema, Qt.Schema) };
    if (this._dictionaryIndex < t.dictionaries.length) {
      const n = t.dictionaries[this._dictionaryIndex++];
      return this._body = n.data.columns, { done: !1, value: lu.fromJSON(n, Qt.DictionaryBatch) };
    }
    if (this._batchIndex < t.batches.length) {
      const n = t.batches[this._batchIndex++];
      return this._body = n.columns, { done: !1, value: lu.fromJSON(n, Qt.RecordBatch) };
    }
    return this._body = [], xe;
  }
  readMessageBody(t) {
    return n(this._body);
    function n(i) {
      return (i || []).reduce((r, s) => [
        ...r,
        ...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(Db(t));
    return n.value;
  }
  readSchema() {
    const t = Qt.Schema, n = this.readMessage(t), i = n == null ? void 0 : n.header();
    if (!n || !i)
      throw new Error(Nb(t));
    return i;
  }
};
const Py = 4, Tg = "ARROW1", jd = new Uint8Array(Tg.length);
for (let e = 0; e < Tg.length; e += 1)
  jd[e] = Tg.codePointAt(e);
function Bb(e, t = 0) {
  for (let n = -1, i = jd.length; ++n < i; )
    if (jd[n] !== e[t + n])
      return !1;
  return !0;
}
const hf = jd.length, FM = hf + Py, n9 = hf * 2 + Py;
let df = class Kh extends wM {
  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 vu(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 Hn.toDOMStream(this.isSync() ? { [Symbol.iterator]: () => this } : { [Symbol.asyncIterator]: () => this });
  }
  toNodeStream() {
    return Hn.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 Kh ? t : pg(t) ? o9(t) : EI(t) ? l9(t) : vu(t) ? W(this, void 0, void 0, function* () {
      return yield Kh.from(yield t);
    }) : LI(t) || db(t) || CI(t) || hb(t) ? c9(new Pd(t)) : a9(new zd(t));
  }
  /** @nocollapse */
  static readAll(t) {
    return t instanceof Kh ? t.isSync() ? e2(t) : n2(t) : pg(t) || ArrayBuffer.isView(t) || Cy(t) || FI(t) ? e2(t) : n2(t);
  }
}, qd = class extends df {
  constructor(t) {
    super(t), this._impl = t;
  }
  readAll() {
    return [...this];
  }
  [Symbol.iterator]() {
    return this._impl[Symbol.iterator]();
  }
  [Symbol.asyncIterator]() {
    return Re(this, arguments, function* () {
      yield H(yield* Cs(ai(this[Symbol.iterator]())));
    });
  }
}, Yd = class extends df {
  constructor(t) {
    super(t), this._impl = t;
  }
  readAll() {
    var t, n, i, r;
    return W(this, void 0, void 0, function* () {
      const s = new Array();
      try {
        for (var o = !0, a = ai(this), c; c = yield a.next(), t = c.done, !t; o = !0) {
          r = c.value, o = !1;
          const l = r;
          s.push(l);
        }
      } catch (l) {
        n = { error: l };
      } finally {
        try {
          !o && !t && (i = a.return) && (yield i.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]();
  }
}, EM = class extends qd {
  constructor(t) {
    super(t), this._impl = t;
  }
}, i9 = class extends Yd {
  constructor(t) {
    super(t), this._impl = t;
  }
}, LM = class {
  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 i = this._loadVectors(t, n, this.schema.fields), r = Rt({ type: new fn(this.schema.fields), length: t.length, children: i });
    return new gi(this.schema, r);
  }
  _loadDictionaryBatch(t, n) {
    const { id: i, isDelta: r } = t, { dictionaries: s, schema: o } = this, a = s.get(i);
    if (r || !a) {
      const c = o.dictionaries.get(i), l = this._loadVectors(t.data, n, [c]);
      return (a && r ? a.concat(new Ne(l)) : new Ne(l)).memoize();
    }
    return a.memoize();
  }
  _loadVectors(t, n, i) {
    return new xM(n, t.nodes, t.buffers, this.dictionaries, this.schema.metadataVersion).visitMany(i);
  }
}, Wd = class extends LM {
  constructor(t, n) {
    super(n), this._reader = pg(t) ? new e9(this._handle = t) : new OM(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 = CM(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) : xe;
  }
  return(t) {
    return !this.closed && this.autoDestroy && (this.closed = !0) ? this.reset()._reader.return(t) : xe;
  }
  next() {
    if (this.closed)
      return xe;
    let t;
    const { _reader: n } = this;
    for (; t = this._readNextMessageAndValidate(); )
      if (t.isSchema())
        this.reset(t.header());
      else if (t.isRecordBatch()) {
        this._recordBatchIndex++;
        const i = t.header(), r = n.readMessageBody(t.bodyLength);
        return { done: !1, value: this._loadRecordBatch(i, r) };
      } else if (t.isDictionaryBatch()) {
        this._dictionaryIndex++;
        const i = t.header(), r = n.readMessageBody(t.bodyLength), s = this._loadDictionaryBatch(i, r);
        this.dictionaries.set(i.id, s);
      }
    return this.schema && this._recordBatchIndex === 0 ? (this._recordBatchIndex++, { done: !1, value: new MM(this.schema) }) : this.return();
  }
  _readNextMessageAndValidate(t) {
    return this._reader.readMessage(t);
  }
}, Gd = class extends LM {
  constructor(t, n) {
    super(n), this._reader = new t9(this._handle = t);
  }
  isAsync() {
    return !0;
  }
  isStream() {
    return !0;
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  cancel() {
    return W(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 W(this, void 0, void 0, function* () {
      return this.closed || (this.autoDestroy = CM(this, t), this.schema || (this.schema = yield this._reader.readSchema()) || (yield this.cancel())), this;
    });
  }
  throw(t) {
    return W(this, void 0, void 0, function* () {
      return !this.closed && this.autoDestroy && (this.closed = !0) ? yield this.reset()._reader.throw(t) : xe;
    });
  }
  return(t) {
    return W(this, void 0, void 0, function* () {
      return !this.closed && this.autoDestroy && (this.closed = !0) ? yield this.reset()._reader.return(t) : xe;
    });
  }
  next() {
    return W(this, void 0, void 0, function* () {
      if (this.closed)
        return xe;
      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 i = t.header(), r = yield n.readMessageBody(t.bodyLength);
          return { done: !1, value: this._loadRecordBatch(i, r) };
        } else if (t.isDictionaryBatch()) {
          this._dictionaryIndex++;
          const i = t.header(), r = yield n.readMessageBody(t.bodyLength), s = this._loadDictionaryBatch(i, r);
          this.dictionaries.set(i.id, s);
        }
      return this.schema && this._recordBatchIndex === 0 ? (this._recordBatchIndex++, { done: !1, value: new MM(this.schema) }) : yield this.return();
    });
  }
  _readNextMessageAndValidate(t) {
    return W(this, void 0, void 0, function* () {
      return yield this._reader.readMessage(t);
    });
  }
}, RM = class extends Wd {
  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 G_ ? t : new G_(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 i = (n = this._footer) === null || n === void 0 ? void 0 : n.getRecordBatch(t);
    if (i && this._handle.seek(i.offset)) {
      const r = this._reader.readMessage(Qt.RecordBatch);
      if (r != null && r.isRecordBatch()) {
        const s = r.header(), o = this._reader.readMessageBody(r.bodyLength);
        return this._loadRecordBatch(s, o);
      }
    }
    return null;
  }
  _readDictionaryBatch(t) {
    var n;
    const i = (n = this._footer) === null || n === void 0 ? void 0 : n.getDictionaryBatch(t);
    if (i && this._handle.seek(i.offset)) {
      const r = this._reader.readMessage(Qt.DictionaryBatch);
      if (r != null && r.isDictionaryBatch()) {
        const s = r.header(), o = this._reader.readMessageBody(r.bodyLength), a = this._loadDictionaryBatch(s, o);
        this.dictionaries.set(s.id, a);
      }
    }
  }
  _readFooter() {
    const { _handle: t } = this, n = t.size - FM, i = t.readInt32(n), r = t.readAt(n - i, i);
    return Ib.decode(r);
  }
  _readNextMessageAndValidate(t) {
    var n;
    if (this._footer || this.open(), this._footer && this._recordBatchIndex < this.numRecordBatches) {
      const i = (n = this._footer) === null || n === void 0 ? void 0 : n.getRecordBatch(this._recordBatchIndex);
      if (i && this._handle.seek(i.offset))
        return this._reader.readMessage(t);
    }
    return null;
  }
}, r9 = class extends Gd {
  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 i = typeof n[0] != "number" ? n.shift() : void 0, r = n[0] instanceof Map ? n.shift() : void 0;
    super(t instanceof Vd ? t : new Vd(t, i), r);
  }
  isFile() {
    return !0;
  }
  isAsync() {
    return !0;
  }
  open(t) {
    const n = Object.create(null, {
      open: { get: () => super.open }
    });
    return W(this, void 0, void 0, function* () {
      if (!this.closed && !this._footer) {
        this.schema = (this._footer = yield this._readFooter()).schema;
        for (const i of this._footer.dictionaryBatches())
          i && (yield this._readDictionaryBatch(this._dictionaryIndex++));
      }
      return yield n.open.call(this, t);
    });
  }
  readRecordBatch(t) {
    var n;
    return W(this, void 0, void 0, function* () {
      if (this.closed)
        return null;
      this._footer || (yield this.open());
      const i = (n = this._footer) === null || n === void 0 ? void 0 : n.getRecordBatch(t);
      if (i && (yield this._handle.seek(i.offset))) {
        const r = yield this._reader.readMessage(Qt.RecordBatch);
        if (r != null && r.isRecordBatch()) {
          const s = r.header(), o = yield this._reader.readMessageBody(r.bodyLength);
          return this._loadRecordBatch(s, o);
        }
      }
      return null;
    });
  }
  _readDictionaryBatch(t) {
    var n;
    return W(this, void 0, void 0, function* () {
      const i = (n = this._footer) === null || n === void 0 ? void 0 : n.getDictionaryBatch(t);
      if (i && (yield this._handle.seek(i.offset))) {
        const r = yield this._reader.readMessage(Qt.DictionaryBatch);
        if (r != null && r.isDictionaryBatch()) {
          const s = r.header(), o = yield this._reader.readMessageBody(r.bodyLength), a = this._loadDictionaryBatch(s, o);
          this.dictionaries.set(s.id, a);
        }
      }
    });
  }
  _readFooter() {
    return W(this, void 0, void 0, function* () {
      const { _handle: t } = this;
      t._pending && (yield t._pending);
      const n = t.size - FM, i = yield t.readInt32(n), r = yield t.readAt(n - i, i);
      return Ib.decode(r);
    });
  }
  _readNextMessageAndValidate(t) {
    return W(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;
    });
  }
}, s9 = class extends Wd {
  constructor(t, n) {
    super(t, n);
  }
  _loadVectors(t, n, i) {
    return new g7(n, t.nodes, t.buffers, this.dictionaries, this.schema.metadataVersion).visitMany(i);
  }
};
function CM(e, t) {
  return t && typeof t.autoDestroy == "boolean" ? t.autoDestroy : e.autoDestroy;
}
function* e2(e) {
  const t = df.from(e);
  try {
    if (!t.open({ autoDestroy: !1 }).closed)
      do
        yield t;
      while (!t.reset().open().closed);
  } finally {
    t.cancel();
  }
}
function n2(e) {
  return Re(this, arguments, function* () {
    const n = yield H(df.from(e));
    try {
      if (!(yield H(n.open({ autoDestroy: !1 }))).closed)
        do
          yield yield H(n);
        while (!(yield H(n.reset().open())).closed);
    } finally {
      yield H(n.cancel());
    }
  });
}
function o9(e) {
  return new qd(new s9(e));
}
function a9(e) {
  const t = e.peek(hf + 7 & -8);
  return t && t.byteLength >= 4 ? Bb(t) ? new EM(new RM(e.read())) : new qd(new Wd(e)) : new qd(new Wd(function* () {
  }()));
}
function c9(e) {
  return W(this, void 0, void 0, function* () {
    const t = yield e.peek(hf + 7 & -8);
    return t && t.byteLength >= 4 ? Bb(t) ? new EM(new RM(yield e.read())) : new Yd(new Gd(e)) : new Yd(new Gd(function() {
      return Re(this, arguments, function* () {
      });
    }()));
  });
}
function l9(e) {
  return W(this, void 0, void 0, function* () {
    const { size: t } = yield e.stat(), n = new Vd(e, t);
    return t >= n9 && Bb(yield n.readAt(0, hf + 7 & -8)) ? new i9(new r9(n)) : new Yd(new Gd(n));
  });
}
function kM(e) {
  const t = df.from(e);
  return vu(t) ? t.then((n) => kM(n)) : t.isAsync() ? t.readAll().then((n) => new $u(n)) : new $u(t.readAll());
}
function u9(e = "ws://localhost:3000/") {
  const t = [];
  let n = !1, i = null, r;
  const s = {
    open() {
      n = !0, c();
    },
    close() {
      for (n = !1, i = null, r = null; t.length; )
        t.shift().reject("Socket closed");
    },
    error(l) {
      if (i) {
        const { reject: u } = i;
        i = null, c(), u(l);
      } else
        console.error("WebSocket error: ", l);
    },
    message({ data: l }) {
      if (i) {
        const { query: u, resolve: f, reject: h } = i;
        if (i = null, c(), typeof l == "string") {
          const d = JSON.parse(l);
          d.error ? h(d.error) : f(d);
        } else if (u.type === "exec")
          f();
        else if (u.type === "arrow")
          f(kM(l.arrayBuffer()));
        else
          throw new Error(`Unexpected socket data: ${l}`);
      } else
        console.log("WebSocket message: ", l);
    }
  };
  function o() {
    r = new WebSocket(e);
    for (const l in s)
      r.addEventListener(l, s[l]);
  }
  function a(l, u, f) {
    r == null && o(), t.push({ query: l, resolve: u, reject: f }), n && !i && c();
  }
  function c() {
    t.length && (i = t.shift(), r.send(JSON.stringify(i.query)));
  }
  return {
    get connected() {
      return n;
    },
    query(l) {
      return new Promise(
        (u, f) => a(l, u, f)
      );
    }
  };
}
class Vs {
  /**
   * 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 i = n.startsWith("*") ? n : `"${n}"`;
      return `${t ? `${i2(t)}.` : ""}${i}`;
    } else
      return t ? i2(t) : "NULL";
  }
}
function i2(e) {
  return e.split(".").map((n) => `"${n}"`).join(".");
}
function f9(e, t) {
  return e instanceof Vs && e.column === t;
}
function oe(e) {
  return typeof e == "string" ? Vy(e) : e;
}
function Zh(e) {
  return typeof e == "string" ? h9(e) : e;
}
function h9(e) {
  return new Vs(e);
}
function Vy(e, t) {
  return arguments.length === 1 && (t = e, e = null), new Vs(e, t);
}
function pf(e) {
  switch (typeof e) {
    case "boolean":
      return e ? "TRUE" : "FALSE";
    case "string":
      return `'${e}'`;
    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(), i = e.getUTCMonth(), r = e.getUTCDate();
        return t === Date.UTC(n, i, r) ? `MAKE_DATE(${n}, ${i + 1}, ${r})` : `EPOCH_MS(${t})`;
      } else
        return e instanceof RegExp ? `'${e.source}'` : String(e);
  }
}
const Ac = (e) => typeof (e == null ? void 0 : e.addEventListener) == "function";
function UM(e) {
  return e instanceof jy;
}
class jy {
  /**
   * Create a new SQL expression instance.
   * @param {(string|SQLExpression|Ref)[]} parts The parts of the expression.
   * @param {string[]} [columns=[]] The column dependencies
   * @param {object} [props] Additional properties for this expression.
   */
  constructor(t, n, i) {
    this._expr = Array.isArray(t) ? t : [t], this._deps = n || [], this.annotate(i);
    const r = this._expr.filter((s) => Ac(s));
    r.length > 0 ? (this._params = Array.from(new Set(r)), this._params.forEach((s) => {
      s.addEventListener("value", () => {
        var o;
        return d9(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 i = new Set(t.flatMap((r) => {
        var o;
        const s = (o = r.value) == null ? void 0 : o.columns;
        return Array.isArray(s) ? s : [];
      }));
      if (i.size) {
        const r = new Set(n);
        return i.forEach((s) => r.add(s)), Array.from(r);
      }
    }
    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} 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) => Ac(t) && !UM(t) ? pf(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 i = this.map || (this.map = /* @__PURE__ */ new Map());
    (i.get(t) || (i.set(t, /* @__PURE__ */ new Set()), i.get(t))).add(n);
  }
}
function d9(e, t) {
  if (t != null && t.size)
    return Promise.allSettled(Array.from(t, (n) => n(e)));
}
function zM(e, t) {
  const n = [e[0]], i = /* @__PURE__ */ new Set(), r = t.length;
  for (let s = 0, o = 0; s < r; ) {
    const a = t[s];
    Ac(a) ? n[++o] = a : (Array.isArray(a == null ? void 0 : a.columns) && a.columns.forEach((l) => i.add(l)), n[o] += typeof a == "string" ? a : pf(a));
    const c = e[++s];
    Ac(n[o]) ? n[++o] = c : n[o] += c;
  }
  return { spans: n, cols: Array.from(i) };
}
function q(e, ...t) {
  const { spans: n, cols: i } = zM(e, t);
  return new jy(n, i);
}
function p9(e) {
  const t = oe(e);
  return q`${t} DESC NULLS LAST`.annotate({ label: t == null ? void 0 : t.label, desc: !0 });
}
const Qc = (e) => ({
  value: e,
  toString: () => pf(e)
});
function yf(e) {
  var t;
  e(this.op, this), (t = this.children) == null || t.forEach((n) => n.visit(e));
}
function PM(e, t) {
  const n = t.filter((r) => r != null).map(oe), i = n.map((r, s) => s ? ` ${e} ` : "");
  return n.length === 1 ? i.push("") : n.length > 1 && (i[0] = "(", i.push(")")), q(i, ...n).annotate({ op: e, children: n, visit: yf });
}
const js = (...e) => PM("AND", e.flat()), Ob = (...e) => PM("OR", e.flat()), y9 = (e) => (t) => q`(${e} ${oe(t)})`.annotate({ op: e, a: t, visit: yf }), m9 = y9("NOT"), VM = (e) => (t) => q`(${oe(t)} ${e})`.annotate({ op: e, a: t, visit: yf }), Fb = VM("IS NULL"), Tu = VM("IS NOT NULL"), io = (e) => (t, n) => q`(${oe(t)} ${e} ${oe(n)})`.annotate({ op: e, a: t, b: n, visit: yf }), qy = io("="), Eb = io("<>"), Du = io("<"), jM = io(">"), Nu = io("<="), g9 = io(">="), b9 = io("IS DISTINCT FROM"), qM = io("IS NOT DISTINCT FROM");
function YM(e, t, n, i) {
  t = oe(t);
  const r = e.startsWith("NOT ") ? "NOT " : "";
  return (n ? i ? q`${r}(${n[0]} <= ${t} AND ${t} < ${n[1]})` : q`(${t} ${e} ${n[0]} AND ${n[1]})` : q``).annotate({ op: e, visit: yf, field: t, range: n });
}
const Tn = (e, t, n) => YM("BETWEEN", e, t, n), w9 = (e, t, n) => YM("NOT BETWEEN", e, t, n);
function Xd(e, t) {
  return Array.from({ length: e }, () => t);
}
function cs(e, t) {
  return (...n) => {
    const i = n.map(oe), r = t ? `::${t}` : "";
    return (i.length ? q([`${e}(`, ...Xd(i.length - 1, ", "), `)${r}`], ...i) : q`${e}()${r}`).annotate({ func: e, args: i });
  };
}
const v9 = cs("REGEXP_MATCHES"), _9 = cs("CONTAINS"), x9 = cs("PREFIX"), S9 = cs("SUFFIX");
class Ts extends jy {
  constructor(t, n, i, r, s = "", o = "", a = "") {
    let c;
    if (r && !(s || o || a))
      c = r ? q`${n} OVER "${r}"` : q`${n} OVER ()`;
    else {
      const h = s && o ? " " : "", d = (s || o) && a ? " " : "";
      c = q`${n} OVER (${r ? `"${r}" ` : ""}${s}${h}${o}${d}${a})`;
    }
    i && (c = q`(${c})::${i}`);
    const { _expr: u, _deps: f } = c;
    super(u, f, { window: t, func: n, type: i, name: r, group: s, order: o, frame: a });
  }
  get basis() {
    return this.column;
  }
  get label() {
    const { func: t } = this;
    return t.label ?? t.toString();
  }
  over(t) {
    const { window: n, func: i, type: r, group: s, order: o, frame: a } = this;
    return new Ts(n, i, r, t, s, o, a);
  }
  partitionby(...t) {
    const n = t.flat().filter((u) => u).map(oe), i = q(
      ["PARTITION BY ", Xd(n.length - 1, ", "), ""],
      ...n
    ), { window: r, func: s, type: o, name: a, order: c, frame: l } = this;
    return new Ts(r, s, o, a, i, c, l);
  }
  orderby(...t) {
    const n = t.flat().filter((u) => u).map(oe), i = q(
      ["ORDER BY ", Xd(n.length - 1, ", "), ""],
      ...n
    ), { window: r, func: s, type: o, name: a, group: c, frame: l } = this;
    return new Ts(r, s, o, a, c, i, l);
  }
  rows(t) {
    const n = r2("ROWS", t), { window: i, func: r, type: s, name: o, group: a, order: c } = this;
    return new Ts(i, r, s, o, a, c, n);
  }
  range(t) {
    const n = r2("RANGE", t), { window: i, func: r, type: s, name: o, group: a, order: c } = this;
    return new Ts(i, r, s, o, a, c, n);
  }
}
function r2(e, t) {
  if (Ac(t)) {
    const n = q`${t}`;
    return n.toString = () => `${e} ${s2(t.value)}`, n;
  }
  return `${e} ${s2(t)}`;
}
function s2(e) {
  const [t, n] = e, i = t === 0 ? "CURRENT ROW" : Number.isFinite(t) ? `${Math.abs(t)} PRECEDING` : "UNBOUNDED PRECEDING", r = n === 0 ? "CURRENT ROW" : Number.isFinite(n) ? `${Math.abs(n)} FOLLOWING` : "UNBOUNDED FOLLOWING";
  return `BETWEEN ${i} AND ${r}`;
}
function Li(e, t) {
  return (...n) => {
    const i = cs(e)(...n);
    return new Ts(e, i, t);
  };
}
const I9 = Li("ROW_NUMBER", "INTEGER"), A9 = Li("RANK", "INTEGER"), M9 = Li("DENSE_RANK", "INTEGER"), $9 = Li("PERCENT_RANK"), T9 = Li("CUME_DIST"), D9 = Li("NTILE"), N9 = Li("LAG"), B9 = Li("LEAD"), O9 = Li("FIRST_VALUE"), F9 = Li("LAST_VALUE"), E9 = Li("NTH_VALUE");
function L9(e, ...t) {
  return q(e, ...t).annotate({ aggregate: !0 });
}
class uu extends jy {
  constructor(t, n, i, r, s) {
    n = (n || []).map(oe);
    const { strings: o, exprs: a } = R9(t, n, i, r, s), { spans: c, cols: l } = zM(o, a);
    super(c, l, { aggregate: t, args: n, type: i, isDistinct: r, filter: s });
  }
  get basis() {
    return this.column;
  }
  get label() {
    const { aggregate: t, args: n, isDistinct: i } = this, r = i ? "DISTINCT" + (n.length ? " " : "") : "", s = n.length ? `(${r}${n.map(C9).join(", ")})` : "";
    return `${t.toLowerCase()}${s}`;
  }
  distinct() {
    const { aggregate: t, args: n, type: i, filter: r } = this;
    return new uu(t, n, i, !0, r);
  }
  where(t) {
    const { aggregate: n, args: i, type: r, isDistinct: s } = this;
    return new uu(n, i, r, s, t);
  }
  window() {
    const { aggregate: t, args: n, type: i, isDistinct: r } = this, s = new uu(t, n, null, r);
    return new Ts(t, s, i);
  }
  partitionby(...t) {
    return this.window().partitionby(...t);
  }
  orderby(...t) {
    return this.window().orderby(...t);
  }
  rows(t, n) {
    return this.window().rows(t, n);
  }
  range(t, n) {
    return this.window().range(t, n);
  }
}
function R9(e, t, n, i, r) {
  const s = `)${n ? `::${n}` : ""}`;
  let o = [`${e}(${i ? "DISTINCT " : ""}`], a = [];
  return t.length ? (o = o.concat([
    ...Xd(t.length - 1, ", "),
    `${s}${r ? " FILTER (WHERE " : ""}`,
    ...r ? [")"] : []
  ]), a = [...t, ...r ? [r] : []]) : o[0] += "*" + s, { exprs: a, strings: o };
}
function C9(e) {
  const t = pf(e);
  return t && t.startsWith('"') && t.endsWith('"') ? t.slice(1, -1) : t;
}
function Kt(e, t) {
  return (...n) => new uu(e, n, t);
}
const ko = Kt("COUNT", "INTEGER"), k9 = Kt("AVG"), U9 = Kt("MAD"), Mc = Kt("MAX"), $c = Kt("MIN"), oa = Kt("SUM", "DOUBLE"), z9 = Kt("PRODUCT"), P9 = Kt("MEDIAN"), V9 = Kt("QUANTILE"), j9 = Kt("MODE"), q9 = Kt("VARIANCE"), Y9 = Kt("STDDEV"), W9 = Kt("SKEWNESS"), G9 = Kt("KURTOSIS"), X9 = Kt("ENTROPY"), H9 = Kt("VAR_POP"), J9 = Kt("STDDEV_POP"), K9 = Kt("CORR"), Z9 = Kt("COVAR_POP"), Q9 = Kt("REGR_INTERCEPT"), tU = Kt("REGR_SLOPE"), eU = Kt("REGR_COUNT"), nU = Kt("REGR_SYY"), iU = Kt("REGR_SXX"), rU = Kt("REGR_AVGX"), sU = Kt("FIRST"), oU = Kt("LAST"), Dg = Kt("ARG_MIN"), Ng = Kt("ARG_MAX"), aU = Kt("STRING_AGG"), cU = Kt("ARRAY_AGG");
function Lb(e, t) {
  const n = oe(e), i = q`CAST(${n} AS ${t})`;
  return Object.defineProperty(i, "label", {
    enumerable: !0,
    get() {
      return e.label;
    }
  }), Object.defineProperty(i, "aggregate", {
    enumerable: !0,
    get() {
      return e.aggregate || !1;
    }
  }), i;
}
const Bg = (e) => Lb(e, "DOUBLE"), lU = (e) => Lb(e, "INTEGER"), uU = (e) => q`epoch_ms(${oe(e)})`, fU = (e) => {
  const t = oe(e);
  return q`MAKE_DATE(2012, MONTH(${t}), 1)`.annotate({ label: "month" });
}, hU = (e) => {
  const t = oe(e);
  return q`MAKE_DATE(2012, MONTH(${t}), DAY(${t}))`.annotate({ label: "date" });
}, dU = (e) => {
  const t = oe(e);
  return q`MAKE_DATE(2012, 1, DAY(${t}))`.annotate({ label: "date" });
}, WM = cs("ST_AsGeoJSON"), pU = cs("ST_X"), yU = cs("ST_Y"), Rb = cs("ST_CENTROID"), mU = (e) => pU(Rb(e)), gU = (e) => yU(Rb(e));
class Et {
  static select(...t) {
    return new Et().select(...t);
  }
  static from(...t) {
    return new Et().from(...t);
  }
  static with(...t) {
    return new Et().with(...t);
  }
  static union(...t) {
    return new Bo("UNION", t.flat());
  }
  static unionAll(...t) {
    return new Bo("UNION ALL", t.flat());
  }
  static intersect(...t) {
    return new Bo("INTERSECT", t.flat());
  }
  static except(...t) {
    return new Bo("EXCEPT", t.flat());
  }
  static describe(t) {
    const n = t.clone(), { clone: i, toString: r } = n;
    return Object.assign(n, {
      describe: !0,
      clone: () => Et.describe(i.call(n)),
      toString: () => `DESCRIBE ${r.call(n)}`
    });
  }
  constructor() {
    this.query = {
      with: [],
      select: [],
      from: [],
      where: [],
      groupby: [],
      having: [],
      window: [],
      qualify: [],
      orderby: []
    };
  }
  clone() {
    const t = new Et();
    return t.query = { ...this.query }, t;
  }
  with(...t) {
    const { query: n } = this;
    if (t.length === 0)
      return n.with;
    {
      const i = [], r = (s, o) => {
        const a = o.clone();
        a.cteFor = this, i.push({ as: s, query: a });
      };
      return t.flat().forEach((s) => {
        if (s != null)
          if (s.as && s.query)
            r(s.as, s.query);
          else
            for (const o in s)
              r(o, s[o]);
      }), n.with = n.with.concat(i), this;
    }
  }
  select(...t) {
    const { query: n } = this;
    if (t.length === 0)
      return n.select;
    {
      const i = [];
      for (const r of t.flat())
        if (r != null)
          if (typeof r == "string")
            i.push({ as: r, expr: oe(r) });
          else if (r instanceof Vs)
            i.push({ as: r.column, expr: r });
          else if (Array.isArray(r))
            i.push({ as: r[0], expr: r[1] });
          else
            for (const s in r)
              i.push({ as: oh(s), expr: oe(r[s]) });
      return n.select = n.select.concat(i), this;
    }
  }
  $select(...t) {
    return this.query.select = [], this.select(...t);
  }
  distinct(t = !0) {
    return this.query.distinct = !!t, this;
  }
  from(...t) {
    const { query: n } = this;
    if (t.length === 0)
      return n.from;
    {
      const i = [];
      return t.flat().forEach((r) => {
        if (r != null)
          if (typeof r == "string")
            i.push({ as: r, from: Zh(r) });
          else if (r instanceof Vs)
            i.push({ as: r.table, from: r });
          else if (Qh(r) || UM(r))
            i.push({ from: r });
          else if (Array.isArray(r))
            i.push({ as: oh(r[0]), from: Zh(r[1]) });
          else
            for (const s in r)
              i.push({ as: oh(s), from: Zh(r[s]) });
      }), n.from = n.from.concat(i), this;
    }
  }
  $from(...t) {
    return this.query.from = [], this.from(...t);
  }
  sample(t, n) {
    const { query: i } = this;
    if (arguments.length === 0)
      return i.sample;
    {
      let r = t;
      return typeof t == "number" && (r = t > 0 && t < 1 ? { perc: 100 * t, method: n } : { rows: Math.round(t), method: n }), i.sample = r, this;
    }
  }
  where(...t) {
    const { query: n } = this;
    return t.length === 0 ? n.where : (n.where = n.where.concat(
      t.flat().filter((i) => i)
    ), this);
  }
  $where(...t) {
    return this.query.where = [], this.where(...t);
  }
  groupby(...t) {
    const { query: n } = this;
    return t.length === 0 ? n.groupby : (n.groupby = n.groupby.concat(
      t.flat().filter((i) => i).map(oe)
    ), this);
  }
  $groupby(...t) {
    return this.query.groupby = [], this.groupby(...t);
  }
  having(...t) {
    const { query: n } = this;
    return t.length === 0 ? n.having : (n.having = n.having.concat(
      t.flat().filter((i) => i)
    ), this);
  }
  window(...t) {
    const { query: n } = this;
    if (t.length === 0)
      return n.window;
    {
      const i = [];
      return t.flat().forEach((r) => {
        if (r != null)
          for (const s in r)
            i.push({ as: oh(s), expr: r[s] });
      }), n.window = n.window.concat(i), this;
    }
  }
  qualify(...t) {
    const { query: n } = this;
    return t.length === 0 ? n.qualify : (n.qualify = n.qualify.concat(
      t.flat().filter((i) => i)
    ), this);
  }
  orderby(...t) {
    const { query: n } = this;
    return t.length === 0 ? n.orderby : (n.orderby = n.orderby.concat(
      t.flat().filter((i) => i).map(oe)
    ), 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 { query: t, cteFor: n } = this, i = ((n == null ? void 0 : n.query) || t).with, r = i == null ? void 0 : i.reduce((o, { as: a, query: c }) => (o[a] = c, o), {}), s = [];
    return t.from.forEach(({ from: o }) => {
      if (Qh(o))
        s.push(o);
      else if (r[o.table]) {
        const a = r[o.table];
        s.push(a);
      }
    }), s;
  }
  toString() {
    const {
      with: t,
      select: n,
      distinct: i,
      from: r,
      sample: s,
      where: o,
      groupby: a,
      having: c,
      window: l,
      qualify: u,
      orderby: f,
      limit: h,
      offset: d
    } = this.query, p = [];
    if (t.length) {
      const g = t.map(({ as: m, query: b }) => `"${m}" AS (${b})`);
      p.push(`WITH ${g.join(", ")}`);
    }
    const y = n.map(
      ({ as: g, expr: m }) => f9(m, g) && !m.table ? `${m}` : `${m} AS "${g}"`
    );
    if (p.push(`SELECT${i ? " DISTINCT" : ""} ${y.join(", ")}`), r.length) {
      const g = r.map(({ as: m, from: b }) => {
        const w = Qh(b) ? `(${b})` : `${b}`;
        return !m || m === b.table ? w : `${w} AS "${m}"`;
      });
      p.push(`FROM ${g.join(", ")}`);
    }
    if (o.length) {
      const g = o.map(String).filter((m) => m).join(" AND ");
      g && p.push(`WHERE ${g}`);
    }
    if (s) {
      const { rows: g, perc: m, method: b, seed: w } = s, v = g ? `${g} ROWS` : `${m} PERCENT`, _ = b ? ` (${b}${w != null ? `, ${w}` : ""})` : "";
      p.push(`USING SAMPLE ${v}${_}`);
    }
    if (a.length && p.push(`GROUP BY ${a.join(", ")}`), c.length) {
      const g = c.map(String).filter((m) => m).join(" AND ");
      g && p.push(`HAVING ${g}`);
    }
    if (l.length) {
      const g = l.map(({ as: m, expr: b }) => `"${m}" AS (${b})`);
      p.push(`WINDOW ${g.join(", ")}`);
    }
    if (u.length) {
      const g = u.map(String).filter((m) => m).join(" AND ");
      g && p.push(`QUALIFY ${g}`);
    }
    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 Bo {
  constructor(t, n) {
    this.op = t, this.queries = n.map((i) => i.clone()), this.query = { orderby: [] };
  }
  clone() {
    const t = new Bo(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((i) => i).map(oe)
    ), 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((i) => i.cteFor = n), t;
  }
  toString() {
    const { op: t, queries: n, query: { orderby: i, limit: r, offset: s } } = this, o = [n.join(` ${t} `)];
    return i.length && o.push(`ORDER BY ${i.join(", ")}`), Number.isFinite(r) && o.push(`LIMIT ${r}`), Number.isFinite(s) && o.push(`OFFSET ${s}`), o.join(" ");
  }
}
function Qh(e) {
  return e instanceof Et || e instanceof Bo;
}
function bU(e) {
  return Qh(e) && e.describe;
}
function oh(e) {
  return wU(e) ? e.slice(1, -1) : e;
}
function wU(e) {
  return e[0] === '"' && e[e.length - 1] === '"';
}
const td = (e) => e;
function vU() {
  return {
    apply: td,
    invert: td,
    sqlApply: oe,
    sqlInvert: td
  };
}
function _U({ base: e } = {}) {
  if (e == null || e === Math.E)
    return {
      apply: Math.log,
      invert: Math.exp,
      sqlApply: (t) => q`LN(${oe(t)})`,
      sqlInvert: (t) => q`EXP(${t})`
    };
  if (e === 10)
    return {
      apply: Math.log10,
      invert: (t) => Math.pow(10, t),
      sqlApply: (t) => q`LOG(${oe(t)})`,
      sqlInvert: (t) => q`POW(10, ${t})`
    };
  {
    const t = +e;
    return {
      apply: (n) => Math.log(n) / Math.log(t),
      invert: (n) => Math.pow(t, n),
      sqlApply: (n) => q`LN(${oe(n)}) / LN(${t})`,
      sqlInvert: (n) => q`POW(${t}, ${n})`
    };
  }
}
function xU({ 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 = oe(n), q`SIGN(${n}) * LN(${t} + ABS(${n}))`),
    sqlInvert: (n) => q`SIGN(${n}) * (EXP(ABS(${n})) - ${t})`
  };
}
function SU() {
  return {
    apply: (e) => Math.sign(e) * Math.sqrt(Math.abs(e)),
    invert: (e) => Math.sign(e) * e * e,
    sqlApply: (e) => (e = oe(e), q`SIGN(${e}) * SQRT(ABS(${e}))`),
    sqlInvert: (e) => q`SIGN(${e}) * (${e}) ** 2`
  };
}
function IU({ 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 = oe(n), q`SIGN(${n}) * POW(ABS(${n}), ${t})`),
    sqlInvert: (n) => q`SIGN(${n}) * POW(ABS(${n}), 1/${t})`
  };
}
function o2() {
  return {
    apply: (e) => +e,
    invert: (e) => new Date(e),
    sqlApply: (e) => e instanceof Date ? +e : uU(oe(e)),
    sqlInvert: td
  };
}
const AU = {
  linear: vU,
  log: _U,
  symlog: xU,
  sqrt: SU,
  pow: IU,
  time: o2,
  utc: o2
};
function GM(e) {
  const t = AU[e.type];
  return t ? { ...e, ...t(e) } : null;
}
function mf(e, t, {
  replace: n = !1,
  temp: i = !0,
  view: r = !1
} = {}) {
  return "CREATE" + (n ? " OR REPLACE " : " ") + (i ? "TEMP " : "") + (r ? "VIEW" : "TABLE") + (n ? " " : " IF NOT EXISTS ") + e + " AS " + t;
}
function XM(e) {
  return `INSTALL ${e}; LOAD ${e}`;
}
function MU(e, {
  columns: t = Object.keys((e == null ? void 0 : e[0]) || {})
} = {}) {
  let n = [];
  if (Array.isArray(t) ? (n = t, t = n.reduce((r, s) => (r[s] = s, r), {})) : t && (n = Object.keys(t)), !n.length)
    throw new Error("Can not create table from empty column set.");
  const i = [];
  for (const r of e) {
    const s = n.map((o) => `${pf(r[o])} AS "${t[o]}"`);
    i.push(`(SELECT ${s.join(", ")})`);
  }
  return i.join(" UNION ALL ");
}
function Yy(e, t, n, i = {}, r = {}) {
  const { select: s = ["*"], where: o, view: a, temp: c, replace: l, ...u } = i, f = OU({ ...r, ...u }), h = `${e}('${n}'${f ? ", " + f : ""})`, d = o ? ` WHERE ${o}` : "", p = `SELECT ${s.join(", ")} FROM ${h}${d}`;
  return mf(t, p, { view: a, temp: c, replace: l });
}
function $U(e, t, n) {
  return Yy("read_csv", e, t, n, { auto_detect: !0, sample_size: -1 });
}
function TU(e, t, n) {
  return Yy("read_json", e, t, n, { auto_detect: !0, json_format: "auto" });
}
function DU(e, t, n) {
  return Yy("read_parquet", e, t, n);
}
function NU(e, t, n = {}) {
  const { options: i, ...r } = n;
  if (i) {
    const s = Array.isArray(i) ? i.join(", ") : typeof i == "string" ? i : Object.entries(i).map(([o, a]) => `${o}=${a}`).join(", ");
    r.open_options = s.toUpperCase();
  }
  return Yy("st_read", e, t, r);
}
function BU(e, t, n = {}) {
  const { select: i = ["*"], ...r } = n, s = MU(t), o = i.length === 1 && i[0] === "*" ? s : `SELECT ${i} FROM ${s}`;
  return mf(e, o, r);
}
function OU(e) {
  return Object.entries(e).map(([t, n]) => `${t}=${Og(n)}`).join(", ");
}
function Og(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) => Og(t)).join(", ") + "]" : "{" + Object.entries(e).map(([t, n]) => `'${t}': ${Og(n)}`).join(", ") + "}";
    default:
      return e;
  }
}
function FU(e) {
  let t = 2166136261;
  for (let n = 0, i = e.length; n < i; ++n) {
    const r = e.charCodeAt(n), s = r & 65280;
    s && (t = a2(t ^ s >> 8)), t = a2(t ^ r & 255);
  }
  return EU(t);
}
function a2(e) {
  return e + (e << 1) + (e << 4) + (e << 7) + (e << 8) + (e << 24);
}
function EU(e) {
  return e += e << 13, e ^= e >>> 7, e += e << 3, e ^= e >>> 17, e += e << 5, e & 4294967295;
}
class LU {
  /**
   *
   * @param {import('./Coordinator.js').Coordinator} mc a Mosaic coordinator
   * @param {*} options Options hash to configure the data cube indexes and pass selections to the coordinator.
   */
  constructor(t, { selection: n, temp: i = !0 }) {
    this.mc = t, this.selection = n, this.temp = i, this.reset();
  }
  reset() {
    this.enabled = !1, this.clients = null, this.indices = null, this.activeView = null;
  }
  clear() {
    this.indices && (this.mc.cancel(Array.from(this.indices.values(), (t) => t.result)), this.indices = null);
  }
  index(t, n) {
    var l, u;
    if (this.clients !== t) {
      const f = Array.from(t, l2), h = (l = f[0]) == null ? void 0 : l.from;
      this.enabled = f.every((d) => d && d.from === h), this.clients = t, this.activeView = null, this.clear();
    }
    if (!this.enabled)
      return !1;
    n = n || this.selection.active;
    const { source: i } = n;
    if (i && i === ((u = this.activeView) == null ? void 0 : u.source))
      return !0;
    if (this.clear(), !i)
      return !1;
    const r = this.activeView = RU(n);
    if (!r)
      return !1;
    this.mc.logger().warn("DATA CUBE INDEX CONSTRUCTION");
    const s = this.selection.remove(i), o = this.indices = /* @__PURE__ */ new Map(), { mc: a, temp: c } = this;
    for (const f of t) {
      if (s.skip(f, n))
        continue;
      const h = l2(f), d = f.query(s.predicate(f)).select({ ...r.columns, ...h.count }).groupby(Object.keys(r.columns)), [p] = d.subqueries;
      if (p) {
        const v = Object.values(r.columns).map((_) => _.columns[0]);
        kU(p, v);
      }
      const y = d.orderby();
      d.query.orderby = [];
      const g = d.toString(), b = `cube_index_${(FU(g) >>> 0).toString(16)}`, w = a.exec(mf(b, g, { temp: c }));
      o.set(f, { table: b, result: w, order: y, ...h });
    }
  }
  async update() {
    const { clients: t, selection: n, activeView: i } = this, r = i.predicate(n.active.predicate);
    return Promise.all(
      Array.from(t).map((s) => this.updateClient(s, r))
    );
  }
  async updateClient(t, n) {
    const i = this.indices.get(t);
    if (!i)
      return;
    n || (n = this.activeView.predicate(this.selection.active.predicate));
    const { table: r, dims: s, aggr: o, order: a = [] } = i, c = Et.select(s, o).from(r).groupby(s).where(n).orderby(a);
    return this.mc.updateClient(t, c);
  }
}
function RU(e) {
  var c;
  const { source: t, schema: n } = e;
  let i = (c = e.predicate) == null ? void 0 : c.columns;
  if (!n || !i)
    return null;
  const { type: r, scales: s, pixelSize: o = 1 } = n;
  let a;
  if (r === "interval" && s) {
    const l = s.map((u) => CU(u, o));
    if (l.some((u) => u == null))
      return null;
    l.length === 1 ? (a = (u) => u ? Tn("active0", u.range.map(l[0])) : [], i = { active0: l[0](e.predicate.field) }) : (a = (u) => u ? js(u.children.map(({ range: f }, h) => Tn(`active${h}`, f.map(l[h])))) : [], i = Object.fromEntries(
      e.predicate.children.map((u, f) => [`active${f}`, l[f](u.field)])
    ));
  } else if (r === "point")
    a = (l) => l, i = Object.fromEntries(i.map((l) => [l.toString(), l]));
  else
    return null;
  return { source: t, columns: i, predicate: a };
}
function CU(e, t) {
  const { apply: n, sqlApply: i } = GM(e);
  if (n) {
    const { domain: r, range: s } = e, o = n(Math.min(...r)), a = n(Math.max(...r)), c = Math.abs(s[1] - s[0]) / (a - o) / t, l = t === 1 ? "" : `${t}::INTEGER * `;
    return (u) => q`${l}FLOOR(${c}::DOUBLE * (${i(u)} - ${o}::DOUBLE))::INTEGER`;
  }
}
const c2 = { from: NaN };
function l2(e) {
  var a;
  if (!e.filterIndexable)
    return c2;
  const t = e.query(), n = Fg(t);
  if (!n || !t.groupby)
    return c2;
  const i = new Set(t.groupby().map((c) => c.column)), r = [], s = [];
  let o;
  for (const { as: c, expr: { aggregate: l } } of t.select())
    switch ((a = l == null ? void 0 : l.toUpperCase) == null ? void 0 : a.call(l)) {
      case "COUNT":
      case "SUM":
        r.push({ [c]: q`SUM("${c}")::DOUBLE` });
        break;
      case "AVG":
        o = "_count_", r.push({ [c]: q`(SUM("${c}" * ${o}) / SUM(${o}))::DOUBLE` });
        break;
      case "MAX":
        r.push({ [c]: q`MAX("${c}")` });
        break;
      case "MIN":
        r.push({ [c]: q`MIN("${c}")` });
        break;
      default:
        if (i.has(c))
          s.push(c);
        else
          return null;
    }
  return {
    aggr: r,
    dims: s,
    count: o ? { [o]: q`COUNT(*)` } : {},
    from: n
  };
}
function Fg(e) {
  const t = e.subqueries;
  if (e.select) {
    const i = e.from();
    if (!i.length)
      return;
    if (t.length === 0)
      return i[0].from.table;
  }
  const n = Fg(t[0]);
  for (let i = 1; i < t.length; ++i) {
    const r = Fg(t[i]);
    if (r !== void 0 && r !== n)
      return NaN;
  }
  return n;
}
function kU(e, t) {
  const n = /* @__PURE__ */ new Set(), i = (r) => {
    n.has(r) || (n.add(r), r.select && r.from().length && r.select(t), r.subqueries.forEach(i));
  };
  i(e);
}
class UU {
  /**
   * @param {import('./Coordinator.js').Coordinator} coordinator The Mosaic coordinator.
   * @param {*} selection The shared filter selection.
   * @param {*} index Boolean flag or options hash for data cube indexer.
   *  Falsy values disable indexing.
   */
  constructor(t, n, i = !0) {
    this.mc = t, this.selection = n, this.clients = /* @__PURE__ */ new Set(), this.indexer = i ? new LU(this.mc, { ...i, selection: n }) : null;
    const { value: r, activate: s } = this.handlers = {
      value: () => this.update(),
      activate: (o) => {
        var a;
        return (a = this.indexer) == null ? void 0 : a.index(this.clients, o);
      }
    };
    n.addEventListener("value", r), n.addEventListener("activate", s);
  }
  finalize() {
    const { value: t, activate: n } = this.handlers;
    this.selection.removeEventListener("value", t), this.selection.removeEventListener("activate", n);
  }
  reset() {
    var t;
    (t = this.indexer) == null || t.reset();
  }
  add(t) {
    return (this.clients = new Set(this.clients)).add(t), this;
  }
  remove(t) {
    return this.clients.has(t) && (this.clients = new Set(this.clients)).delete(t), this;
  }
  update() {
    const { mc: t, indexer: n, clients: i, selection: r } = this;
    return n != null && n.index(i) ? n.update() : zU(t, i, r);
  }
}
function zU(e, t, n) {
  return Promise.all(Array.from(t).map((i) => {
    const r = n.predicate(i);
    if (r != null)
      return e.updateClient(i, i.query(r));
  }));
}
function HM() {
  let e, t;
  const n = new Promise((i, r) => {
    e = i, t = r;
  });
  return n.fulfill = (i) => (e(i), n), n.reject = (i) => (t(i), n), n;
}
function PU(e) {
  return (typeof requestAnimationFrame < "u" ? requestAnimationFrame : typeof setImmediate < "u" ? setImmediate : setTimeout)(e);
}
function VU(e, t, n) {
  let i = [], r = 0;
  function s() {
    const o = jU(i, t);
    i = [], r = 0;
    for (const a of o)
      YU(a, e, n), XU(a, t);
  }
  return {
    add(o, a) {
      o.request.type === "arrow" ? (r = r || PU(() => s()), i.push({ entry: o, priority: a, index: i.length })) : e(o, a);
    }
  };
}
function jU(e, t) {
  const n = [], i = /* @__PURE__ */ new Map();
  for (const r of e) {
    const { entry: { request: s } } = r, o = qU(s.query, t);
    if (!i.has(o)) {
      const a = [];
      n.push(a), i.set(o, a);
    }
    i.get(o).push(r);
  }
  return n;
}
function qU(e, t) {
  const n = `${e}`;
  if (e instanceof Et && !t.get(n)) {
    if (e.orderby().length || e.where().length || e.qualify().length || e.having().length)
      return n;
    const i = e.clone().$select("*"), r = e.groupby();
    if (r.length) {
      const s = {};
      e.select().forEach(({ as: o, expr: a }) => s[o] = a), i.$groupby(r.map((o) => o instanceof Vs && s[o.column] || o));
    }
    return `${i}`;
  } else
    return n;
}
function YU(e, t, n) {
  if (WU(e))
    t({
      request: {
        type: "arrow",
        cache: !1,
        record: !1,
        query: e.query = GU(e, n)
      },
      result: e.result = HM()
    });
  else
    for (const { entry: i, priority: r } of e)
      t(i, r);
}
function WU(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 GU(e, t) {
  const n = e.maps = [], i = /* @__PURE__ */ new Map();
  for (const o of e) {
    const { query: a } = o.entry.request, c = [];
    n.push(c);
    for (const { as: l, expr: u } of a.select()) {
      const f = `${u}`;
      i.has(f) || i.set(f, [`col${i.size}`, u]);
      const [h] = i.get(f);
      c.push([h, l]);
    }
    t(`${a}`);
  }
  const r = e[0].entry.request.query.clone(), s = r.groupby();
  if (s.length) {
    const o = {};
    e.maps[0].forEach(([a, c]) => o[c] = a), r.$groupby(s.map((a) => a instanceof Vs && o[a.column] || a));
  }
  return r.$select(Array.from(i.values()));
}
async function XU(e, t) {
  const { maps: n, query: i, result: r } = e;
  if (!n)
    return;
  let s;
  try {
    s = await r;
  } catch (a) {
    for (const { entry: c } of e)
      c.result.reject(a);
    return;
  }
  const o = bU(i);
  e.forEach(({ entry: a }, c) => {
    const { request: l, result: u } = a, f = n[c], h = o && f ? JU(s, f) : f ? HU(s, f) : s;
    l.cache && t.set(String(l.query), h), u.fulfill(h);
  });
}
function HU(e, t) {
  const n = {};
  for (const [i, r] of t)
    n[r] = e.getChild(i);
  return new e.constructor(n);
}
function JU(e, t) {
  const n = new Map(t), i = [];
  for (const r of e)
    n.has(r.column_name) && i.push({ ...r, column_name: n.get(r.column_name) });
  return i;
}
const KU = typeof requestIdleCallback < "u" ? requestIdleCallback : setTimeout, ZU = () => ({
  get: () => {
  },
  set: (e, t) => t,
  clear: () => {
  }
});
function QU({
  max: e = 1e3,
  // max entries
  ttl: t = 3 * 60 * 60 * 1e3
  // time-to-live, default 3 hours
} = {}) {
  let n = /* @__PURE__ */ new Map();
  function i() {
    const r = performance.now() - t;
    let s = null, o = 1 / 0;
    for (const [a, c] of n) {
      const { last: l } = c;
      l < o && (s = a, o = l), r > l && n.delete(a);
    }
    s && n.delete(s);
  }
  return {
    get(r) {
      const s = n.get(r);
      if (s)
        return s.last = performance.now(), s.value;
    },
    set(r, s) {
      return n.set(r, { last: performance.now(), value: s }), n.size > e && KU(i), s;
    },
    clear() {
      n = /* @__PURE__ */ new Map();
    }
  };
}
function tz(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, i) {
      const r = t[i];
      if (!r)
        throw new Error(`Invalid queue priority rank: ${i}`);
      const s = { item: n, next: null };
      r.head === null ? r.head = r.tail = s : r.tail = r.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 i of t) {
        let { head: r, tail: s } = i;
        for (let o = null, a = r; a; o = a, a = a.next)
          n(a.item) && (a === r ? r = a.next : o.next = a.next, a === s && (s = o || r));
        i.head = r, i.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: i } = n;
        if (i !== null)
          return n.head = i.next, n.tail === i && (n.tail = null), i.item;
      }
    }
  };
}
const As = { High: 0, Normal: 1, Low: 2 };
function ez() {
  const e = tz(3);
  let t, n, i, r = [], s = null, o;
  function a() {
    if (s || e.isEmpty())
      return;
    const { request: f, result: h } = e.next();
    s = u(f, h), s.finally(() => {
      s = null, a();
    });
  }
  function c(f, h = As.Normal) {
    e.insert(f, h), a();
  }
  function l(f) {
    r.length && f && r.forEach((h) => h.add(f));
  }
  async function u(f, h) {
    try {
      const { query: d, type: p, cache: y = !1, record: g = !0, options: m } = f, b = d ? `${d}` : null;
      if (g && l(b), y) {
        const _ = n.get(b);
        if (_) {
          i.debug("Cache"), h.fulfill(_);
          return;
        }
      }
      const w = performance.now(), v = await t.query({ type: p, sql: b, ...m });
      y && n.set(b, v), i.debug(`Request: ${(performance.now() - w).toFixed(1)}`), h.fulfill(v);
    } catch (d) {
      h.reject(d);
    }
  }
  return {
    cache(f) {
      return f !== void 0 ? n = f === !0 ? QU() : f || ZU() : n;
    },
    logger(f) {
      return f ? i = f : i;
    },
    connector(f) {
      return f ? t = f : t;
    },
    consolidate(f) {
      f && !o ? o = VU(c, n, l) : !f && o && (o = null);
    },
    request(f, h = As.Normal) {
      const d = HM(), p = { request: f, result: d };
      return o ? o.add(p, h) : c(p, h), d;
    },
    cancel(f) {
      const h = new Set(f);
      e.remove(({ result: d }) => h.has(d));
    },
    clear() {
      e.remove(({ result: f }) => (f.reject("Cleared"), !0));
    },
    record() {
      let f = [];
      const h = {
        add(d) {
          f.push(d);
        },
        reset() {
          f = [];
        },
        snapshot() {
          return f.slice();
        },
        stop() {
          return r = r.filter((d) => d !== h), f;
        }
      };
      return r.push(h), h;
    }
  };
}
function JM(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":
      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}`);
  }
}
const Cb = 2, nz = 3, kb = 7, KM = 10;
function Ub(e) {
  return typeof (e == null ? void 0 : e.getChild) == "function";
}
function iz(e) {
  switch (e.typeId) {
    case Cb:
    case nz:
    case kb:
      return Float64Array;
    default:
      return Array;
  }
}
function ZM(e) {
  const { typeId: t } = e;
  if (t === KM)
    return (n) => n == null ? n : new Date(n);
  if (t === Cb && e.bitWidth >= 64)
    return (n) => n == null ? n : Number(n);
  if (t === kb) {
    const n = 1 / Math.pow(10, e.scale);
    return (i) => i == null ? i : QM(i, n);
  }
  return (n) => n;
}
function Hd(e) {
  const { type: t } = e, { typeId: n } = t;
  if (n === KM) {
    const i = e.length, r = new Array(i);
    for (let s = 0; s < i; ++s) {
      const o = e.get(s);
      r[s] = o == null ? null : new Date(o);
    }
    return r;
  }
  if (n === Cb && t.bitWidth >= 64) {
    const i = e.length, r = new Float64Array(i);
    for (let s = 0; s < i; ++s) {
      const o = e.get(s);
      r[s] = o == null ? NaN : Number(o);
    }
    return r;
  }
  if (n === kb) {
    const i = 1 / Math.pow(10, t.scale), r = e.length, s = new Float64Array(r);
    for (let o = 0; o < r; ++o) {
      const a = e.get(o);
      s[o] = a == null ? NaN : QM(a, i);
    }
    return s;
  }
  return e.toArray();
}
const u2 = Array.from(
  { length: 8 },
  (e, t) => Math.pow(2, t * 32)
);
function QM(e, t) {
  const n = e.length;
  let i = 0;
  if (e.signed && (e[n - 1] | 0) < 0) {
    for (let r = 0; r < n; ++r)
      i += ~(e[r] | 0) * u2[r];
    i = -(i + 1);
  } else
    for (let r = 0; r < n; ++r)
      i += e[r] * u2[r];
  return i * t;
}
const rz = "count", sz = "nulls", oz = "max", az = "min", cz = "distinct", lz = {
  [rz]: ko,
  [cz]: (e) => ko(e).distinct(),
  [oz]: Mc,
  [az]: $c,
  [sz]: (e) => ko().where(Fb(e))
};
function uz(e, t, n) {
  return Et.from(e).select(Array.from(n, (i) => [i, lz[i](t)]));
}
async function fz(e, t) {
  return t.length === 1 && `${t[0].column}` == "*" ? dz(e, t[0].table) : (await Promise.all(t.map((n) => hz(e, n)))).filter((n) => n);
}
async function hz(e, { table: t, column: n, stats: i }) {
  const r = Et.from({ source: t }).select({ column: n }).groupby(n.aggregate ? q`ALL` : []), [s] = Array.from(await e.query(Et.describe(r))), o = {
    table: t,
    column: `${n}`,
    sqlType: s.column_type,
    type: JM(s.column_type),
    nullable: s.null === "YES"
  };
  if (!(i != null && i.length || i != null && i.size))
    return o;
  const a = await e.query(
    uz(t, n, i),
    { persist: !0 }
  );
  for (let c = 0; c < a.numCols; ++c) {
    const { name: l } = a.schema.fields[c], u = a.getChildAt(c), f = ZM(u.type);
    o[l] = f(u.get(0));
  }
  return o;
}
async function dz(e, t) {
  const n = await e.query(`DESCRIBE ${Zh(t)}`);
  return Array.from(n).map((i) => ({
    table: t,
    column: i.column_name,
    sqlType: i.column_type,
    type: JM(i.column_type),
    nullable: i.null === "YES"
  }));
}
function pz() {
  return {
    debug() {
    },
    info() {
    },
    log() {
    },
    warn() {
    },
    error() {
    }
  };
}
let ah;
function Yr(e) {
  return e ? ah = e : ah == null && (ah = new yz()), ah;
}
class yz {
  constructor(t = u9(), n = {}) {
    const {
      logger: i = console,
      manager: r = ez()
    } = n;
    this.manager = r, this.logger(i), this.configure(n), this.databaseConnector(t), this.clear();
  }
  logger(t) {
    return arguments.length && (this._logger = t || pz(), this.manager.logger(this._logger)), this._logger;
  }
  configure({ cache: t = !0, consolidate: n = !0, indexes: i = !0 }) {
    this.manager.cache(t), this.manager.consolidate(n), this.indexes = i;
  }
  clear({ clients: t = !0, cache: n = !0 } = {}) {
    var i, r;
    this.manager.clear(), t && ((i = this.clients) == null || i.forEach((s) => this.disconnect(s)), (r = this.filterGroups) == null || r.forEach((s) => s.finalize()), this.clients = /* @__PURE__ */ new Set(), this.filterGroups = /* @__PURE__ */ new Map()), n && this.manager.cache().clear();
  }
  databaseConnector(t) {
    return this.manager.connector(t);
  }
  // -- Query Management ----
  cancel(t) {
    this.manager.cancel(t);
  }
  exec(t, { priority: n = As.Normal } = {}) {
    return t = Array.isArray(t) ? t.join(`;
`) : t, this.manager.request({ type: "exec", query: t }, n);
  }
  query(t, {
    type: n = "arrow",
    cache: i = !0,
    priority: r = As.Normal,
    ...s
  } = {}) {
    return this.manager.request({ type: n, query: t, cache: i, options: s }, r);
  }
  prefetch(t, n = {}) {
    return this.query(t, { ...n, cache: !0, priority: As.Low });
  }
  createBundle(t, n, i = As.Low) {
    const r = { name: t, queries: n };
    return this.manager.request({ type: "create-bundle", options: r }, i);
  }
  loadBundle(t, n = As.High) {
    const i = { name: t };
    return this.manager.request({ type: "load-bundle", options: i }, n);
  }
  // -- Client Management ----
  updateClient(t, n, i = As.Normal) {
    return t.queryPending(), this.query(n, { priority: i }).then(
      (r) => t.queryResult(r).update(),
      (r) => {
        t.queryError(r), this._logger.error(r);
      }
    );
  }
  requestQuery(t, n) {
    var i;
    return (i = this.filterGroups.get(t.filterBy)) == null || i.reset(), n ? this.updateClient(t, n) : t.update();
  }
  /**
   * Connect a client to the coordinator.
   *
   * @param {import('./MosaicClient.js').MosaicClient} client the client to disconnect
   */
  async connect(t) {
    const { clients: n, filterGroups: i, indexes: r } = this;
    if (n.has(t))
      throw new Error("Client already connected.");
    n.add(t), t.coordinator = this;
    const s = t.fields();
    s != null && s.length && t.fieldInfo(await fz(this, s));
    const o = t.filterBy;
    if (o)
      if (i.has(o))
        i.get(o).add(t);
      else {
        const a = new UU(this, o, r);
        i.set(o, a.add(t));
      }
    t.requestQuery();
  }
  /**
   * Disconnect a client from the coordinator.
   *
   * @param {import('./MosaicClient.js').MosaicClient} client the client to disconnect
   */
  disconnect(t) {
    var r;
    const { clients: n, filterGroups: i } = this;
    n.has(t) && (n.delete(t), (r = i.get(t.filterBy)) == null || r.remove(t), t.coordinator = null);
  }
}
class mz {
  /**
   * 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: *) => 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 gz()
    }), 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: *) => Promise?} callback The event handler
   *  callback function to remove.
   */
  removeEventListener(t, n) {
    const i = this._callbacks.get(t);
    i && i.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 {*} 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() {
    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();
  }
  /**
   * 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 i = this._callbacks.get(t) || {};
    if (i.pending)
      i.queue.enqueue(n, this.emitQueueFilter(t, n));
    else {
      const r = this.willEmit(t, n), { callbacks: s, queue: o } = i;
      if (s != null && s.size) {
        const a = Promise.allSettled(Array.from(s, (c) => c(r))).then(() => {
          i.pending = null, o.isEmpty() || this.emit(t, o.dequeue());
        });
        i.pending = a;
      }
    }
  }
}
class gz {
  /**
   * 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 i = { value: t };
    if (n && this.next) {
      let r = this;
      for (; r.next; )
        n(r.next.value) ? r = r.next : r.next = r.next.next;
      r.next = i;
    } else
      this.next = i;
  }
  /**
   * 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 t3(e, t) {
  return e === t ? !1 : e instanceof Date && t instanceof Date ? +e != +t : Array.isArray(e) && Array.isArray(t) ? bz(e, t) : !0;
}
function bz(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 ks(e) {
  return e instanceof Uo;
}
class Uo extends mz {
  /**
   * 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 Uo(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) => ks(n))) {
      const n = new Uo(), i = () => n.update(t.map((r) => ks(r) ? r.value : r));
      return i(), t.forEach((r) => ks(r) ? r.addEventListener("value", i) : 0), n;
    }
    return new Uo(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 t3(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 Xo(e) {
  return e instanceof Jd;
}
let Jd = class za extends Uo {
  /**
   * 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.
   * @returns {Selection} The new Selection instance.
   */
  static intersect({ cross: t = !1 } = {}) {
    return new za(new wl({ cross: t }));
  }
  /**
   * 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.
   * @returns {Selection} The new Selection instance.
   */
  static union({ cross: t = !1 } = {}) {
    return new za(new wl({ cross: t, 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.
   * @returns {Selection} The new Selection instance.
   */
  static single({ cross: t = !1 } = {}) {
    return new za(new wl({ cross: t, single: !0 }));
  }
  /**
   * Create a new Selection instance with a
   * cross-filtered intersect resolution strategy.
   * @returns {Selection} The new Selection instance.
   */
  static crossfilter() {
    return new za(new wl({ cross: !0 }));
  }
  /**
   * Create a new Selection instance.
   * @param {SelectionResolver} resolver The selection resolution
   *  strategy to apply.
   */
  constructor(t = new wl()) {
    super([]), this._resolved = this._value, this._resolver = t;
  }
  /**
   * Create a cloned copy of this Selection instance.
   * @returns {this} A clone of this selection.
   */
  clone() {
    const t = new za(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 {this} 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 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 current array of selection clauses.
   */
  get clauses() {
    return super.value;
  }
  /**
   * Indicate if this selection has a single resolution strategy.
   */
  get single() {
    return this._resolver.single;
  }
  /**
   * 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 input event value.
   * @returns {*} 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: i } = this, r = n ? null : i.active;
    return this._resolver.predicate(i, r, t);
  }
};
class wl {
  /**
   * 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.
   */
  constructor({ union: t, cross: n, single: i } = {}) {
    this.union = !!t, this.cross = !!n, this.single = !!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, i = !1) {
    const { source: r, predicate: s } = n, o = t.filter((c) => r !== c.source), a = this.single ? [] : o;
    return this.single && i && o.forEach((c) => {
      var l, u;
      return (u = (l = c.source) == null ? void 0 : l.reset) == null ? void 0 : u.call(l);
    }), 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 i;
    return this.cross && ((i = n == null ? void 0 : n.clients) == null ? void 0 : i.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, i) {
    const { union: r } = this;
    if (this.skip(i, n))
      return;
    const s = t.filter((o) => !this.skip(i, o)).map((o) => o.predicate);
    return r && s.length > 1 ? Ob(s) : s;
  }
  /**
   * 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 i = (n = t.active) == null ? void 0 : n.source;
      return (r) => {
        var s;
        return ((s = r.active) == null ? void 0 : s.source) !== i;
      };
    }
  }
}
function wz() {
  const e = /* @__PURE__ */ new Set();
  let t, n = new Promise((i) => t = i);
  return {
    /**
     * Mark an item as pending.
     * @param {*} item An item to synchronize on.
     */
    pending(i) {
      e.add(i);
    },
    /**
     * 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(i) {
      return e.delete(i), e.size === 0;
    },
    /**
     * Resolve the current synchronization cycle, causing the synchronize
     * promise to resolve and thereby trigger downstream updates.
     */
    resolve() {
      n = new Promise((i) => {
        t(), t = i;
      });
    },
    /**
     * The promise for the current synchronization cycle.
     * @return {Promise} The synchronization promise.
     */
    get promise() {
      return n;
    }
  };
}
const gf = Symbol("Fixed"), Mi = Symbol("Transient"), e3 = Symbol("Transform");
function me(e, t) {
  return e == null || t == null ? NaN : e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN;
}
function Ho(e, t) {
  return e == null || t == null ? NaN : t < e ? -1 : t > e ? 1 : t >= e ? 0 : NaN;
}
function Wy(e) {
  let t, n, i;
  e.length !== 2 ? (t = me, n = (a, c) => me(e(a), c), i = (a, c) => e(a) - c) : (t = e === me || e === Ho ? e : vz, n = e, i = e);
  function r(a, c, l = 0, u = a.length) {
    if (l < u) {
      if (t(c, c) !== 0)
        return u;
      do {
        const f = l + u >>> 1;
        n(a[f], c) < 0 ? l = f + 1 : u = f;
      } while (l < u);
    }
    return l;
  }
  function s(a, c, l = 0, u = a.length) {
    if (l < u) {
      if (t(c, c) !== 0)
        return u;
      do {
        const f = l + u >>> 1;
        n(a[f], c) <= 0 ? l = f + 1 : u = f;
      } while (l < u);
    }
    return l;
  }
  function o(a, c, l = 0, u = a.length) {
    const f = r(a, c, l, u - 1);
    return f > l && i(a[f - 1], c) > -i(a[f], c) ? f - 1 : f;
  }
  return { left: r, center: o, right: s };
}
function vz() {
  return 0;
}
function n3(e) {
  return e === null ? NaN : +e;
}
function* _z(e, t) {
  if (t === void 0)
    for (let n of e)
      n != null && (n = +n) >= n && (yield n);
  else {
    let n = -1;
    for (let i of e)
      (i = t(i, ++n, e)) != null && (i = +i) >= i && (yield i);
  }
}
const xz = Wy(me), Gy = xz.right;
Wy(n3).center;
const i3 = r3(s3), Sz = r3(Iz);
function r3(e) {
  return function(t, n, i = n) {
    if (!((n = +n) >= 0))
      throw new RangeError("invalid rx");
    if (!((i = +i) >= 0))
      throw new RangeError("invalid ry");
    let { data: r, width: s, height: o } = t;
    if (!((s = Math.floor(s)) >= 0))
      throw new RangeError("invalid width");
    if (!((o = Math.floor(o !== void 0 ? o : r.length / s)) >= 0))
      throw new RangeError("invalid height");
    if (!s || !o || !n && !i)
      return t;
    const a = n && e(n), c = i && e(i), l = r.slice();
    return a && c ? (ma(a, l, r, s, o), ma(a, r, l, s, o), ma(a, l, r, s, o), ga(c, r, l, s, o), ga(c, l, r, s, o), ga(c, r, l, s, o)) : a ? (ma(a, r, l, s, o), ma(a, l, r, s, o), ma(a, r, l, s, o)) : c && (ga(c, r, l, s, o), ga(c, l, r, s, o), ga(c, r, l, s, o)), t;
  };
}
function ma(e, t, n, i, r) {
  for (let s = 0, o = i * r; s < o; )
    e(t, n, s, s += i, 1);
}
function ga(e, t, n, i, r) {
  for (let s = 0, o = i * r; s < i; ++s)
    e(t, n, s, s + o, i);
}
function Iz(e) {
  const t = s3(e);
  return (n, i, r, s, o) => {
    r <<= 2, s <<= 2, o <<= 2, t(n, i, r + 0, s + 0, o), t(n, i, r + 1, s + 1, o), t(n, i, r + 2, s + 2, o), t(n, i, r + 3, s + 3, o);
  };
}
function s3(e) {
  const t = Math.floor(e);
  if (t === e)
    return Az(e);
  const n = e - t, i = 2 * e + 1;
  return (r, s, o, a, c) => {
    if (!((a -= c) >= o))
      return;
    let l = t * s[o];
    const u = c * t, f = u + c;
    for (let h = o, d = o + u; h < d; h += c)
      l += s[Math.min(a, h)];
    for (let h = o, d = a; h <= d; h += c)
      l += s[Math.min(a, h + u)], r[h] = (l + n * (s[Math.max(o, h - f)] + s[Math.min(a, h + f)])) / i, l -= s[Math.max(o, h - u)];
  };
}
function Az(e) {
  const t = 2 * e + 1;
  return (n, i, r, s, o) => {
    if (!((s -= o) >= r))
      return;
    let a = e * i[r];
    const c = o * e;
    for (let l = r, u = r + c; l < u; l += o)
      a += i[Math.min(s, l)];
    for (let l = r, u = s; l <= u; l += o)
      a += i[Math.min(s, l + c)], n[l] = a / t, a -= i[Math.max(r, l - c)];
  };
}
function Xy(e, t) {
  let n = 0;
  if (t === void 0)
    for (let i of e)
      i != null && (i = +i) >= i && ++n;
  else {
    let i = -1;
    for (let r of e)
      (r = t(r, ++i, e)) != null && (r = +r) >= r && ++n;
  }
  return n;
}
function Mz(e) {
  return e.length | 0;
}
function $z(e) {
  return !(e > 0);
}
function Tz(e) {
  return typeof e != "object" || "length" in e ? e : Array.from(e);
}
function Dz(e) {
  return (t) => e(...t);
}
function Nz(...e) {
  const t = typeof e[e.length - 1] == "function" && Dz(e.pop());
  e = e.map(Tz);
  const n = e.map(Mz), i = e.length - 1, r = new Array(i + 1).fill(0), s = [];
  if (i < 0 || n.some($z))
    return s;
  for (; ; ) {
    s.push(r.map((a, c) => e[c][a]));
    let o = i;
    for (; ++r[o] === n[o]; ) {
      if (o === 0)
        return t ? s.map(t) : s;
      r[o--] = 0;
    }
  }
}
function Bz(e, t) {
  var n = 0, i = 0;
  return Float64Array.from(e, t === void 0 ? (r) => n += +r || 0 : (r) => n += +t(r, i++, e) || 0);
}
function zb(e, t) {
  let n = 0, i, r = 0, s = 0;
  if (t === void 0)
    for (let o of e)
      o != null && (o = +o) >= o && (i = o - r, r += i / ++n, s += i * (o - r));
  else {
    let o = -1;
    for (let a of e)
      (a = t(a, ++o, e)) != null && (a = +a) >= a && (i = a - r, r += i / ++n, s += i * (a - r));
  }
  if (n > 1)
    return s / (n - 1);
}
function bf(e, t) {
  const n = zb(e, t);
  return n && Math.sqrt(n);
}
function ke(e, t) {
  let n, i;
  if (t === void 0)
    for (const r of e)
      r != null && (n === void 0 ? r >= r && (n = i = r) : (n > r && (n = r), i < r && (i = r)));
  else {
    let r = -1;
    for (let s of e)
      (s = t(s, ++r, e)) != null && (n === void 0 ? s >= s && (n = i = s) : (n > s && (n = s), i < s && (i = s)));
  }
  return [n, i];
}
class sr {
  constructor() {
    this._partials = new Float64Array(32), this._n = 0;
  }
  add(t) {
    const n = this._partials;
    let i = 0;
    for (let r = 0; r < this._n && r < 32; r++) {
      const s = n[r], o = t + s, a = Math.abs(t) < Math.abs(s) ? t - (o - s) : s - (o - t);
      a && (n[i++] = a), t = o;
    }
    return n[i] = t, this._n = i + 1, this;
  }
  valueOf() {
    const t = this._partials;
    let n = this._n, i, r, s, o = 0;
    if (n > 0) {
      for (o = t[--n]; n > 0 && (i = o, r = t[--n], o = i + r, s = r - (o - i), !s); )
        ;
      n > 0 && (s < 0 && t[n - 1] < 0 || s > 0 && t[n - 1] > 0) && (r = s * 2, i = o + r, r == i - o && (o = i));
    }
    return o;
  }
}
class Jo extends Map {
  constructor(t, n = c3) {
    if (super(), Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: n } }), t != null)
      for (const [i, r] of t)
        this.set(i, r);
  }
  get(t) {
    return super.get(Eg(this, t));
  }
  has(t) {
    return super.has(Eg(this, t));
  }
  set(t, n) {
    return super.set(o3(this, t), n);
  }
  delete(t) {
    return super.delete(a3(this, t));
  }
}
class tl extends Set {
  constructor(t, n = c3) {
    if (super(), Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: n } }), t != null)
      for (const i of t)
        this.add(i);
  }
  has(t) {
    return super.has(Eg(this, t));
  }
  add(t) {
    return super.add(o3(this, t));
  }
  delete(t) {
    return super.delete(a3(this, t));
  }
}
function Eg({ _intern: e, _key: t }, n) {
  const i = t(n);
  return e.has(i) ? e.get(i) : n;
}
function o3({ _intern: e, _key: t }, n) {
  const i = t(n);
  return e.has(i) ? e.get(i) : (e.set(i, n), n);
}
function a3({ _intern: e, _key: t }, n) {
  const i = t(n);
  return e.has(i) && (n = e.get(i), e.delete(i)), n;
}
function c3(e) {
  return e !== null && typeof e == "object" ? e.valueOf() : e;
}
function Lg(e) {
  return e;
}
function ls(e, ...t) {
  return Pb(e, Lg, Lg, t);
}
function lc(e, t, ...n) {
  return Pb(e, Lg, t, n);
}
function Oz(e, t, ...n) {
  return Pb(e, Array.from, t, n);
}
function Pb(e, t, n, i) {
  return function r(s, o) {
    if (o >= i.length)
      return n(s);
    const a = new Jo(), c = i[o++];
    let l = -1;
    for (const u of s) {
      const f = c(u, ++l, s), h = a.get(f);
      h ? h.push(u) : a.set(f, [u]);
    }
    for (const [u, f] of a)
      a.set(u, r(f, o));
    return t(a);
  }(e, 0);
}
function Fz(e, t) {
  return Array.from(t, (n) => e[n]);
}
function Bu(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 i = Uint32Array.from(e, (r, s) => s);
    return t.length > 1 ? (t = t.map((r) => e.map(r)), i.sort((r, s) => {
      for (const o of t) {
        const a = Ou(o[r], o[s]);
        if (a)
          return a;
      }
    })) : (n = e.map(n), i.sort((r, s) => Ou(n[r], n[s]))), Fz(e, i);
  }
  return e.sort(Vb(n));
}
function Vb(e = me) {
  if (e === me)
    return Ou;
  if (typeof e != "function")
    throw new TypeError("compare is not a function");
  return (t, n) => {
    const i = e(t, n);
    return i || i === 0 ? i : (e(n, n) === 0) - (e(t, t) === 0);
  };
}
function Ou(e, t) {
  return (e == null || !(e >= e)) - (t == null || !(t >= t)) || (e < t ? -1 : e > t ? 1 : 0);
}
function jb(e, t, n) {
  return (t.length !== 2 ? Bu(lc(e, t, n), ([i, r], [s, o]) => me(r, o) || me(i, s)) : Bu(ls(e, n), ([i, r], [s, o]) => t(r, o) || me(i, s))).map(([i]) => i);
}
const Ez = Math.sqrt(50), Lz = Math.sqrt(10), Rz = Math.sqrt(2);
function Kd(e, t, n) {
  const i = (t - e) / Math.max(0, n), r = Math.floor(Math.log10(i)), s = i / Math.pow(10, r), o = s >= Ez ? 10 : s >= Lz ? 5 : s >= Rz ? 2 : 1;
  let a, c, l;
  return r < 0 ? (l = Math.pow(10, -r) / o, a = Math.round(e * l), c = Math.round(t * l), a / l < e && ++a, c / l > t && --c, l = -l) : (l = Math.pow(10, r) * o, a = Math.round(e / l), c = Math.round(t / l), a * l < e && ++a, c * l > t && --c), c < a && 0.5 <= n && n < 2 ? Kd(e, t, n * 2) : [a, c, l];
}
function qs(e, t, n) {
  if (t = +t, e = +e, n = +n, !(n > 0))
    return [];
  if (e === t)
    return [e];
  const i = t < e, [r, s, o] = i ? Kd(t, e, n) : Kd(e, t, n);
  if (!(s >= r))
    return [];
  const a = s - r + 1, c = new Array(a);
  if (i)
    if (o < 0)
      for (let l = 0; l < a; ++l)
        c[l] = (s - l) / -o;
    else
      for (let l = 0; l < a; ++l)
        c[l] = (s - l) * o;
  else if (o < 0)
    for (let l = 0; l < a; ++l)
      c[l] = (r + l) / -o;
  else
    for (let l = 0; l < a; ++l)
      c[l] = (r + l) * o;
  return c;
}
function Fu(e, t, n) {
  return t = +t, e = +e, n = +n, Kd(e, t, n)[2];
}
function Rg(e, t, n) {
  t = +t, e = +e, n = +n;
  const i = t < e, r = i ? Fu(t, e, n) : Fu(e, t, n);
  return (i ? -1 : 1) * (r < 0 ? 1 / -r : r);
}
function l3(e, t, n) {
  let i;
  for (; ; ) {
    const r = Fu(e, t, n);
    if (r === i || r === 0 || !isFinite(r))
      return [e, t];
    r > 0 ? (e = Math.floor(e / r) * r, t = Math.ceil(t / r) * r) : r < 0 && (e = Math.ceil(e * r) / r, t = Math.floor(t * r) / r), i = r;
  }
}
function qb(e) {
  return Math.max(1, Math.ceil(Math.log(Xy(e)) / Math.LN2) + 1);
}
function De(e, t) {
  let n;
  if (t === void 0)
    for (const i of e)
      i != null && (n < i || n === void 0 && i >= i) && (n = i);
  else {
    let i = -1;
    for (let r of e)
      (r = t(r, ++i, e)) != null && (n < r || n === void 0 && r >= r) && (n = r);
  }
  return n;
}
function Cz(e, t) {
  let n, i = -1, r = -1;
  if (t === void 0)
    for (const s of e)
      ++r, s != null && (n < s || n === void 0 && s >= s) && (n = s, i = r);
  else
    for (let s of e)
      (s = t(s, ++r, e)) != null && (n < s || n === void 0 && s >= s) && (n = s, i = r);
  return i;
}
function Ye(e, t) {
  let n;
  if (t === void 0)
    for (const i of e)
      i != null && (n > i || n === void 0 && i >= i) && (n = i);
  else {
    let i = -1;
    for (let r of e)
      (r = t(r, ++i, e)) != null && (n > r || n === void 0 && r >= r) && (n = r);
  }
  return n;
}
function kz(e, t) {
  let n, i = -1, r = -1;
  if (t === void 0)
    for (const s of e)
      ++r, s != null && (n > s || n === void 0 && s >= s) && (n = s, i = r);
  else
    for (let s of e)
      (s = t(s, ++r, e)) != null && (n > s || n === void 0 && s >= s) && (n = s, i = r);
  return i;
}
function u3(e, t, n = 0, i = 1 / 0, r) {
  if (t = Math.floor(t), n = Math.floor(Math.max(0, n)), i = Math.floor(Math.min(e.length - 1, i)), !(n <= t && t <= i))
    return e;
  for (r = r === void 0 ? Ou : Vb(r); i > n; ) {
    if (i - n > 600) {
      const c = i - n + 1, l = t - n + 1, u = Math.log(c), f = 0.5 * Math.exp(2 * u / 3), h = 0.5 * Math.sqrt(u * f * (c - f) / c) * (l - c / 2 < 0 ? -1 : 1), d = Math.max(n, Math.floor(t - l * f / c + h)), p = Math.min(i, Math.floor(t + (c - l) * f / c + h));
      u3(e, t, d, p, r);
    }
    const s = e[t];
    let o = n, a = i;
    for (vl(e, n, t), r(e[i], s) > 0 && vl(e, n, i); o < a; ) {
      for (vl(e, o, a), ++o, --a; r(e[o], s) < 0; )
        ++o;
      for (; r(e[a], s) > 0; )
        --a;
    }
    r(e[n], s) === 0 ? vl(e, n, a) : (++a, vl(e, a, i)), a <= t && (n = a + 1), t <= a && (i = a - 1);
  }
  return e;
}
function vl(e, t, n) {
  const i = e[t];
  e[t] = e[n], e[n] = i;
}
function Yb(e, t = me) {
  let n, i = !1;
  if (t.length === 1) {
    let r;
    for (const s of e) {
      const o = t(s);
      (i ? me(o, r) > 0 : me(o, o) === 0) && (n = s, r = o, i = !0);
    }
  } else
    for (const r of e)
      (i ? t(r, n) > 0 : t(r, r) === 0) && (n = r, i = !0);
  return n;
}
function Ys(e, t, n) {
  if (e = Float64Array.from(_z(e, n)), !(!(i = e.length) || isNaN(t = +t))) {
    if (t <= 0 || i < 2)
      return Ye(e);
    if (t >= 1)
      return De(e);
    var i, r = (i - 1) * t, s = Math.floor(r), o = De(u3(e, s).subarray(0, s + 1)), a = Ye(e.subarray(s + 1));
    return o + (a - o) * (r - s);
  }
}
function Uz(e, t, n = n3) {
  if (!(!(i = e.length) || isNaN(t = +t))) {
    if (t <= 0 || i < 2)
      return +n(e[0], 0, e);
    if (t >= 1)
      return +n(e[i - 1], i - 1, e);
    var i, r = (i - 1) * t, s = Math.floor(r), o = +n(e[s], s, e), a = +n(e[s + 1], s + 1, e);
    return o + (a - o) * (r - s);
  }
}
function zz(e, t, n) {
  const i = Xy(e), r = Ys(e, 0.75) - Ys(e, 0.25);
  return i && r ? Math.ceil((n - t) / (2 * r * Math.pow(i, -1 / 3))) : 1;
}
function f3(e, t, n) {
  const i = Xy(e), r = bf(e);
  return i && r ? Math.ceil((n - t) * Math.cbrt(i) / (3.49 * r)) : 1;
}
function Hy(e, t) {
  let n = 0, i = 0;
  if (t === void 0)
    for (let r of e)
      r != null && (r = +r) >= r && (++n, i += r);
  else {
    let r = -1;
    for (let s of e)
      (s = t(s, ++r, e)) != null && (s = +s) >= s && (++n, i += s);
  }
  if (n)
    return i / n;
}
function Eu(e, t) {
  return Ys(e, 0.5, t);
}
function* Pz(e) {
  for (const t of e)
    yield* t;
}
function h3(e) {
  return Array.from(Pz(e));
}
function d3(e, t) {
  const n = new Jo();
  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 i, r = 0;
  for (const [s, o] of n)
    o > r && (r = o, i = s);
  return i;
}
function Vz(e, t = jz) {
  const n = [];
  let i, r = !1;
  for (const s of e)
    r && n.push(t(i, s)), i = s, r = !0;
  return n;
}
function jz(e, t) {
  return [e, t];
}
function Cn(e, t, n) {
  e = +e, t = +t, n = (r = arguments.length) < 2 ? (t = e, e = 0, 1) : r < 3 ? 1 : +n;
  for (var i = -1, r = Math.max(0, Math.ceil((t - e) / n)) | 0, s = new Array(r); ++i < r; )
    s[i] = e + i * n;
  return s;
}
function p3(e, t = me) {
  if (typeof e[Symbol.iterator] != "function")
    throw new TypeError("values is not iterable");
  let n = Array.from(e);
  const i = new Float64Array(n.length);
  t.length !== 2 && (n = n.map(t), t = me);
  const r = (a, c) => t(n[a], n[c]);
  let s, o;
  return e = Uint32Array.from(n, (a, c) => c), e.sort(t === me ? (a, c) => Ou(n[a], n[c]) : Vb(r)), e.forEach((a, c) => {
    const l = r(a, s === void 0 ? a : s);
    l >= 0 ? ((s === void 0 || l > 0) && (s = a, o = c), i[a] = o) : i[a] = NaN;
  }), i;
}
function qz(e, t = me) {
  let n, i = !1;
  if (t.length === 1) {
    let r;
    for (const s of e) {
      const o = t(s);
      (i ? me(o, r) < 0 : me(o, o) === 0) && (n = s, r = o, i = !0);
    }
  } else
    for (const r of e)
      (i ? t(r, n) < 0 : t(r, r) === 0) && (n = r, i = !0);
  return n;
}
function fr(e, t) {
  let n = 0;
  if (t === void 0)
    for (let i of e)
      (i = +i) && (n += i);
  else {
    let i = -1;
    for (let r of e)
      (r = +t(r, ++i, e)) && (n += r);
  }
  return n;
}
function Zd(e) {
  if (typeof e[Symbol.iterator] != "function")
    throw new TypeError("values is not iterable");
  return Array.from(e).reverse();
}
function Yz(e) {
  return e;
}
var om = 1, am = 2, Cg = 3, ch = 4, f2 = 1e-6;
function Wz(e) {
  return "translate(" + e + ",0)";
}
function Gz(e) {
  return "translate(0," + e + ")";
}
function Xz(e) {
  return (t) => +e(t);
}
function Hz(e, t) {
  return t = Math.max(0, e.bandwidth() - t * 2) / 2, e.round() && (t = Math.round(t)), (n) => +e(n) + t;
}
function Jz() {
  return !this.__axis;
}
function Kz(e, t) {
  var n = [], i = null, r = null, s = 6, o = 6, a = 3, c = typeof window < "u" && window.devicePixelRatio > 1 ? 0 : 0.5, l = e === om || e === ch ? -1 : 1, u = e === ch || e === am ? "x" : "y", f = e === om || e === Cg ? Wz : Gz;
  function h(d) {
    var p = i ?? (t.ticks ? t.ticks.apply(t, n) : t.domain()), y = r ?? (t.tickFormat ? t.tickFormat.apply(t, n) : Yz), g = Math.max(s, 0) + a, m = t.range(), b = +m[0] + c, w = +m[m.length - 1] + c, v = (t.bandwidth ? Hz : Xz)(t.copy(), c), _ = d.selection ? d.selection() : d, x = _.selectAll(".domain").data([null]), I = _.selectAll(".tick").data(p, t).order(), N = I.exit(), A = I.enter().append("g").attr("class", "tick"), D = I.select("line"), M = I.select("text");
    x = x.merge(x.enter().insert("path", ".tick").attr("class", "domain").attr("stroke", "currentColor")), I = I.merge(A), D = D.merge(A.append("line").attr("stroke", "currentColor").attr(u + "2", l * s)), M = M.merge(A.append("text").attr("fill", "currentColor").attr(u, l * g).attr("dy", e === om ? "0em" : e === Cg ? "0.71em" : "0.32em")), d !== _ && (x = x.transition(d), I = I.transition(d), D = D.transition(d), M = M.transition(d), N = N.transition(d).attr("opacity", f2).attr("transform", function(B) {
      return isFinite(B = v(B)) ? f(B + c) : this.getAttribute("transform");
    }), A.attr("opacity", f2).attr("transform", function(B) {
      var R = this.parentNode.__axis;
      return f((R && isFinite(R = R(B)) ? R : v(B)) + c);
    })), N.remove(), x.attr("d", e === ch || e === am ? o ? "M" + l * o + "," + b + "H" + c + "V" + w + "H" + l * o : "M" + c + "," + b + "V" + w : o ? "M" + b + "," + l * o + "V" + c + "H" + w + "V" + l * o : "M" + b + "," + c + "H" + w), I.attr("opacity", 1).attr("transform", function(B) {
      return f(v(B) + c);
    }), D.attr(u + "2", l * s), M.attr(u, l * g).text(y), _.filter(Jz).attr("fill", "none").attr("font-size", 10).attr("font-family", "sans-serif").attr("text-anchor", e === am ? "start" : e === ch ? "end" : "middle"), _.each(function() {
      this.__axis = v;
    });
  }
  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 ? (i = d == null ? null : Array.from(d), h) : i && i.slice();
  }, h.tickFormat = function(d) {
    return arguments.length ? (r = d, h) : r;
  }, 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 Zz(e) {
  return Kz(Cg, e);
}
var Qz = { value: () => {
} };
function Jy() {
  for (var e = 0, t = arguments.length, n = {}, i; e < t; ++e) {
    if (!(i = arguments[e] + "") || i in n || /[\s.]/.test(i))
      throw new Error("illegal type: " + i);
    n[i] = [];
  }
  return new ed(n);
}
function ed(e) {
  this._ = e;
}
function tP(e, t) {
  return e.trim().split(/^|\s+/).map(function(n) {
    var i = "", r = n.indexOf(".");
    if (r >= 0 && (i = n.slice(r + 1), n = n.slice(0, r)), n && !t.hasOwnProperty(n))
      throw new Error("unknown type: " + n);
    return { type: n, name: i };
  });
}
ed.prototype = Jy.prototype = {
  constructor: ed,
  on: function(e, t) {
    var n = this._, i = tP(e + "", n), r, s = -1, o = i.length;
    if (arguments.length < 2) {
      for (; ++s < o; )
        if ((r = (e = i[s]).type) && (r = eP(n[r], e.name)))
          return r;
      return;
    }
    if (t != null && typeof t != "function")
      throw new Error("invalid callback: " + t);
    for (; ++s < o; )
      if (r = (e = i[s]).type)
        n[r] = h2(n[r], e.name, t);
      else if (t == null)
        for (r in n)
          n[r] = h2(n[r], e.name, null);
    return this;
  },
  copy: function() {
    var e = {}, t = this._;
    for (var n in t)
      e[n] = t[n].slice();
    return new ed(e);
  },
  call: function(e, t) {
    if ((r = arguments.length - 2) > 0)
      for (var n = new Array(r), i = 0, r, s; i < r; ++i)
        n[i] = arguments[i + 2];
    if (!this._.hasOwnProperty(e))
      throw new Error("unknown type: " + e);
    for (s = this._[e], i = 0, r = s.length; i < r; ++i)
      s[i].value.apply(t, n);
  },
  apply: function(e, t, n) {
    if (!this._.hasOwnProperty(e))
      throw new Error("unknown type: " + e);
    for (var i = this._[e], r = 0, s = i.length; r < s; ++r)
      i[r].value.apply(t, n);
  }
};
function eP(e, t) {
  for (var n = 0, i = e.length, r; n < i; ++n)
    if ((r = e[n]).name === t)
      return r.value;
}
function h2(e, t, n) {
  for (var i = 0, r = e.length; i < r; ++i)
    if (e[i].name === t) {
      e[i] = Qz, e = e.slice(0, i).concat(e.slice(i + 1));
      break;
    }
  return n != null && e.push({ name: t, value: n }), e;
}
var kg = "http://www.w3.org/1999/xhtml";
const Ko = {
  svg: "http://www.w3.org/2000/svg",
  xhtml: kg,
  xlink: "http://www.w3.org/1999/xlink",
  xml: "http://www.w3.org/XML/1998/namespace",
  xmlns: "http://www.w3.org/2000/xmlns/"
};
function Ky(e) {
  var t = e += "", n = t.indexOf(":");
  return n >= 0 && (t = e.slice(0, n)) !== "xmlns" && (e = e.slice(n + 1)), Ko.hasOwnProperty(t) ? { space: Ko[t], local: e } : e;
}
function nP(e) {
  return function() {
    var t = this.ownerDocument, n = this.namespaceURI;
    return n === kg && t.documentElement.namespaceURI === kg ? t.createElement(e) : t.createElementNS(n, e);
  };
}
function iP(e) {
  return function() {
    return this.ownerDocument.createElementNS(e.space, e.local);
  };
}
function Zy(e) {
  var t = Ky(e);
  return (t.local ? iP : nP)(t);
}
function rP() {
}
function Wb(e) {
  return e == null ? rP : function() {
    return this.querySelector(e);
  };
}
function sP(e) {
  typeof e != "function" && (e = Wb(e));
  for (var t = this._groups, n = t.length, i = new Array(n), r = 0; r < n; ++r)
    for (var s = t[r], o = s.length, a = i[r] = new Array(o), c, l, u = 0; u < o; ++u)
      (c = s[u]) && (l = e.call(c, c.__data__, u, s)) && ("__data__" in c && (l.__data__ = c.__data__), a[u] = l);
  return new zn(i, this._parents);
}
function oP(e) {
  return e == null ? [] : Array.isArray(e) ? e : Array.from(e);
}
function aP() {
  return [];
}
function y3(e) {
  return e == null ? aP : function() {
    return this.querySelectorAll(e);
  };
}
function cP(e) {
  return function() {
    return oP(e.apply(this, arguments));
  };
}
function lP(e) {
  typeof e == "function" ? e = cP(e) : e = y3(e);
  for (var t = this._groups, n = t.length, i = [], r = [], s = 0; s < n; ++s)
    for (var o = t[s], a = o.length, c, l = 0; l < a; ++l)
      (c = o[l]) && (i.push(e.call(c, c.__data__, l, o)), r.push(c));
  return new zn(i, r);
}
function m3(e) {
  return function() {
    return this.matches(e);
  };
}
function g3(e) {
  return function(t) {
    return t.matches(e);
  };
}
var uP = Array.prototype.find;
function fP(e) {
  return function() {
    return uP.call(this.children, e);
  };
}
function hP() {
  return this.firstElementChild;
}
function dP(e) {
  return this.select(e == null ? hP : fP(typeof e == "function" ? e : g3(e)));
}
var pP = Array.prototype.filter;
function yP() {
  return Array.from(this.children);
}
function mP(e) {
  return function() {
    return pP.call(this.children, e);
  };
}
function gP(e) {
  return this.selectAll(e == null ? yP : mP(typeof e == "function" ? e : g3(e)));
}
function bP(e) {
  typeof e != "function" && (e = m3(e));
  for (var t = this._groups, n = t.length, i = new Array(n), r = 0; r < n; ++r)
    for (var s = t[r], o = s.length, a = i[r] = [], c, l = 0; l < o; ++l)
      (c = s[l]) && e.call(c, c.__data__, l, s) && a.push(c);
  return new zn(i, this._parents);
}
function b3(e) {
  return new Array(e.length);
}
function wP() {
  return new zn(this._enter || this._groups.map(b3), this._parents);
}
function Qd(e, t) {
  this.ownerDocument = e.ownerDocument, this.namespaceURI = e.namespaceURI, this._next = null, this._parent = e, this.__data__ = t;
}
Qd.prototype = {
  constructor: Qd,
  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 vP(e) {
  return function() {
    return e;
  };
}
function _P(e, t, n, i, r, s) {
  for (var o = 0, a, c = t.length, l = s.length; o < l; ++o)
    (a = t[o]) ? (a.__data__ = s[o], i[o] = a) : n[o] = new Qd(e, s[o]);
  for (; o < c; ++o)
    (a = t[o]) && (r[o] = a);
}
function xP(e, t, n, i, r, s, o) {
  var a, c, l = /* @__PURE__ */ new Map(), u = t.length, f = s.length, h = new Array(u), d;
  for (a = 0; a < u; ++a)
    (c = t[a]) && (h[a] = d = o.call(c, c.__data__, a, t) + "", l.has(d) ? r[a] = c : l.set(d, c));
  for (a = 0; a < f; ++a)
    d = o.call(e, s[a], a, s) + "", (c = l.get(d)) ? (i[a] = c, c.__data__ = s[a], l.delete(d)) : n[a] = new Qd(e, s[a]);
  for (a = 0; a < u; ++a)
    (c = t[a]) && l.get(h[a]) === c && (r[a] = c);
}
function SP(e) {
  return e.__data__;
}
function IP(e, t) {
  if (!arguments.length)
    return Array.from(this, SP);
  var n = t ? xP : _P, i = this._parents, r = this._groups;
  typeof e != "function" && (e = vP(e));
  for (var s = r.length, o = new Array(s), a = new Array(s), c = new Array(s), l = 0; l < s; ++l) {
    var u = i[l], f = r[l], h = f.length, d = AP(e.call(u, u && u.__data__, l, i)), p = d.length, y = a[l] = new Array(p), g = o[l] = new Array(p), m = c[l] = new Array(h);
    n(u, f, y, g, m, d, t);
    for (var b = 0, w = 0, v, _; b < p; ++b)
      if (v = y[b]) {
        for (b >= w && (w = b + 1); !(_ = g[w]) && ++w < p; )
          ;
        v._next = _ || null;
      }
  }
  return o = new zn(o, i), o._enter = a, o._exit = c, o;
}
function AP(e) {
  return typeof e == "object" && "length" in e ? e : Array.from(e);
}
function MP() {
  return new zn(this._exit || this._groups.map(b3), this._parents);
}
function $P(e, t, n) {
  var i = this.enter(), r = this, s = this.exit();
  return typeof e == "function" ? (i = e(i), i && (i = i.selection())) : i = i.append(e + ""), t != null && (r = t(r), r && (r = r.selection())), n == null ? s.remove() : n(s), i && r ? i.merge(r).order() : r;
}
function TP(e) {
  for (var t = e.selection ? e.selection() : e, n = this._groups, i = t._groups, r = n.length, s = i.length, o = Math.min(r, s), a = new Array(r), c = 0; c < o; ++c)
    for (var l = n[c], u = i[c], f = l.length, h = a[c] = new Array(f), d, p = 0; p < f; ++p)
      (d = l[p] || u[p]) && (h[p] = d);
  for (; c < r; ++c)
    a[c] = n[c];
  return new zn(a, this._parents);
}
function DP() {
  for (var e = this._groups, t = -1, n = e.length; ++t < n; )
    for (var i = e[t], r = i.length - 1, s = i[r], o; --r >= 0; )
      (o = i[r]) && (s && o.compareDocumentPosition(s) ^ 4 && s.parentNode.insertBefore(o, s), s = o);
  return this;
}
function NP(e) {
  e || (e = BP);
  function t(f, h) {
    return f && h ? e(f.__data__, h.__data__) : !f - !h;
  }
  for (var n = this._groups, i = n.length, r = new Array(i), s = 0; s < i; ++s) {
    for (var o = n[s], a = o.length, c = r[s] = new Array(a), l, u = 0; u < a; ++u)
      (l = o[u]) && (c[u] = l);
    c.sort(t);
  }
  return new zn(r, this._parents).order();
}
function BP(e, t) {
  return e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN;
}
function OP() {
  var e = arguments[0];
  return arguments[0] = this, e.apply(null, arguments), this;
}
function FP() {
  return Array.from(this);
}
function EP() {
  for (var e = this._groups, t = 0, n = e.length; t < n; ++t)
    for (var i = e[t], r = 0, s = i.length; r < s; ++r) {
      var o = i[r];
      if (o)
        return o;
    }
  return null;
}
function LP() {
  let e = 0;
  for (const t of this)
    ++e;
  return e;
}
function RP() {
  return !this.node();
}
function CP(e) {
  for (var t = this._groups, n = 0, i = t.length; n < i; ++n)
    for (var r = t[n], s = 0, o = r.length, a; s < o; ++s)
      (a = r[s]) && e.call(a, a.__data__, s, r);
  return this;
}
function kP(e) {
  return function() {
    this.removeAttribute(e);
  };
}
function UP(e) {
  return function() {
    this.removeAttributeNS(e.space, e.local);
  };
}
function zP(e, t) {
  return function() {
    this.setAttribute(e, t);
  };
}
function PP(e, t) {
  return function() {
    this.setAttributeNS(e.space, e.local, t);
  };
}
function VP(e, t) {
  return function() {
    var n = t.apply(this, arguments);
    n == null ? this.removeAttribute(e) : this.setAttribute(e, n);
  };
}
function jP(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 qP(e, t) {
  var n = Ky(e);
  if (arguments.length < 2) {
    var i = this.node();
    return n.local ? i.getAttributeNS(n.space, n.local) : i.getAttribute(n);
  }
  return this.each((t == null ? n.local ? UP : kP : typeof t == "function" ? n.local ? jP : VP : n.local ? PP : zP)(n, t));
}
function w3(e) {
  return e.ownerDocument && e.ownerDocument.defaultView || e.document && e || e.defaultView;
}
function YP(e) {
  return function() {
    this.style.removeProperty(e);
  };
}
function WP(e, t, n) {
  return function() {
    this.style.setProperty(e, t, n);
  };
}
function GP(e, t, n) {
  return function() {
    var i = t.apply(this, arguments);
    i == null ? this.style.removeProperty(e) : this.style.setProperty(e, i, n);
  };
}
function XP(e, t, n) {
  return arguments.length > 1 ? this.each((t == null ? YP : typeof t == "function" ? GP : WP)(e, t, n ?? "")) : Tc(this.node(), e);
}
function Tc(e, t) {
  return e.style.getPropertyValue(t) || w3(e).getComputedStyle(e, null).getPropertyValue(t);
}
function HP(e) {
  return function() {
    delete this[e];
  };
}
function JP(e, t) {
  return function() {
    this[e] = t;
  };
}
function KP(e, t) {
  return function() {
    var n = t.apply(this, arguments);
    n == null ? delete this[e] : this[e] = n;
  };
}
function ZP(e, t) {
  return arguments.length > 1 ? this.each((t == null ? HP : typeof t == "function" ? KP : JP)(e, t)) : this.node()[e];
}
function v3(e) {
  return e.trim().split(/^|\s+/);
}
function Gb(e) {
  return e.classList || new _3(e);
}
function _3(e) {
  this._node = e, this._names = v3(e.getAttribute("class") || "");
}
_3.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 x3(e, t) {
  for (var n = Gb(e), i = -1, r = t.length; ++i < r; )
    n.add(t[i]);
}
function S3(e, t) {
  for (var n = Gb(e), i = -1, r = t.length; ++i < r; )
    n.remove(t[i]);
}
function QP(e) {
  return function() {
    x3(this, e);
  };
}
function tV(e) {
  return function() {
    S3(this, e);
  };
}
function eV(e, t) {
  return function() {
    (t.apply(this, arguments) ? x3 : S3)(this, e);
  };
}
function nV(e, t) {
  var n = v3(e + "");
  if (arguments.length < 2) {
    for (var i = Gb(this.node()), r = -1, s = n.length; ++r < s; )
      if (!i.contains(n[r]))
        return !1;
    return !0;
  }
  return this.each((typeof t == "function" ? eV : t ? QP : tV)(n, t));
}
function iV() {
  this.textContent = "";
}
function rV(e) {
  return function() {
    this.textContent = e;
  };
}
function sV(e) {
  return function() {
    var t = e.apply(this, arguments);
    this.textContent = t ?? "";
  };
}
function oV(e) {
  return arguments.length ? this.each(e == null ? iV : (typeof e == "function" ? sV : rV)(e)) : this.node().textContent;
}
function aV() {
  this.innerHTML = "";
}
function cV(e) {
  return function() {
    this.innerHTML = e;
  };
}
function lV(e) {
  return function() {
    var t = e.apply(this, arguments);
    this.innerHTML = t ?? "";
  };
}
function uV(e) {
  return arguments.length ? this.each(e == null ? aV : (typeof e == "function" ? lV : cV)(e)) : this.node().innerHTML;
}
function fV() {
  this.nextSibling && this.parentNode.appendChild(this);
}
function hV() {
  return this.each(fV);
}
function dV() {
  this.previousSibling && this.parentNode.insertBefore(this, this.parentNode.firstChild);
}
function pV() {
  return this.each(dV);
}
function yV(e) {
  var t = typeof e == "function" ? e : Zy(e);
  return this.select(function() {
    return this.appendChild(t.apply(this, arguments));
  });
}
function mV() {
  return null;
}
function gV(e, t) {
  var n = typeof e == "function" ? e : Zy(e), i = t == null ? mV : typeof t == "function" ? t : Wb(t);
  return this.select(function() {
    return this.insertBefore(n.apply(this, arguments), i.apply(this, arguments) || null);
  });
}
function bV() {
  var e = this.parentNode;
  e && e.removeChild(this);
}
function wV() {
  return this.each(bV);
}
function vV() {
  var e = this.cloneNode(!1), t = this.parentNode;
  return t ? t.insertBefore(e, this.nextSibling) : e;
}
function _V() {
  var e = this.cloneNode(!0), t = this.parentNode;
  return t ? t.insertBefore(e, this.nextSibling) : e;
}
function xV(e) {
  return this.select(e ? _V : vV);
}
function SV(e) {
  return arguments.length ? this.property("__data__", e) : this.node().__data__;
}
function IV(e) {
  return function(t) {
    e.call(this, t, this.__data__);
  };
}
function AV(e) {
  return e.trim().split(/^|\s+/).map(function(t) {
    var n = "", i = t.indexOf(".");
    return i >= 0 && (n = t.slice(i + 1), t = t.slice(0, i)), { type: t, name: n };
  });
}
function MV(e) {
  return function() {
    var t = this.__on;
    if (t) {
      for (var n = 0, i = -1, r = t.length, s; n < r; ++n)
        s = t[n], (!e.type || s.type === e.type) && s.name === e.name ? this.removeEventListener(s.type, s.listener, s.options) : t[++i] = s;
      ++i ? t.length = i : delete this.__on;
    }
  };
}
function $V(e, t, n) {
  return function() {
    var i = this.__on, r, s = IV(t);
    if (i) {
      for (var o = 0, a = i.length; o < a; ++o)
        if ((r = i[o]).type === e.type && r.name === e.name) {
          this.removeEventListener(r.type, r.listener, r.options), this.addEventListener(r.type, r.listener = s, r.options = n), r.value = t;
          return;
        }
    }
    this.addEventListener(e.type, s, n), r = { type: e.type, name: e.name, value: t, listener: s, options: n }, i ? i.push(r) : this.__on = [r];
  };
}
function TV(e, t, n) {
  var i = AV(e + ""), r, s = i.length, o;
  if (arguments.length < 2) {
    var a = this.node().__on;
    if (a) {
      for (var c = 0, l = a.length, u; c < l; ++c)
        for (r = 0, u = a[c]; r < s; ++r)
          if ((o = i[r]).type === u.type && o.name === u.name)
            return u.value;
    }
    return;
  }
  for (a = t ? $V : MV, r = 0; r < s; ++r)
    this.each(a(i[r], t, n));
  return this;
}
function I3(e, t, n) {
  var i = w3(e), r = i.CustomEvent;
  typeof r == "function" ? r = new r(t, n) : (r = i.document.createEvent("Event"), n ? (r.initEvent(t, n.bubbles, n.cancelable), r.detail = n.detail) : r.initEvent(t, !1, !1)), e.dispatchEvent(r);
}
function DV(e, t) {
  return function() {
    return I3(this, e, t);
  };
}
function NV(e, t) {
  return function() {
    return I3(this, e, t.apply(this, arguments));
  };
}
function BV(e, t) {
  return this.each((typeof t == "function" ? NV : DV)(e, t));
}
function* OV() {
  for (var e = this._groups, t = 0, n = e.length; t < n; ++t)
    for (var i = e[t], r = 0, s = i.length, o; r < s; ++r)
      (o = i[r]) && (yield o);
}
var A3 = [null];
function zn(e, t) {
  this._groups = e, this._parents = t;
}
function wf() {
  return new zn([[document.documentElement]], A3);
}
function FV() {
  return this;
}
zn.prototype = wf.prototype = {
  constructor: zn,
  select: sP,
  selectAll: lP,
  selectChild: dP,
  selectChildren: gP,
  filter: bP,
  data: IP,
  enter: wP,
  exit: MP,
  join: $P,
  merge: TP,
  selection: FV,
  order: DP,
  sort: NP,
  call: OP,
  nodes: FP,
  node: EP,
  size: LP,
  empty: RP,
  each: CP,
  attr: qP,
  style: XP,
  property: ZP,
  classed: nV,
  text: oV,
  html: uV,
  raise: hV,
  lower: pV,
  append: yV,
  insert: gV,
  remove: wV,
  clone: xV,
  datum: SV,
  on: TV,
  dispatch: BV,
  [Symbol.iterator]: OV
};
function ce(e) {
  return typeof e == "string" ? new zn([[document.querySelector(e)]], [document.documentElement]) : new zn([[e]], A3);
}
function EV(e) {
  let t;
  for (; t = e.sourceEvent; )
    e = t;
  return e;
}
function yi(e, t) {
  if (e = EV(e), t === void 0 && (t = e.currentTarget), t) {
    var n = t.ownerSVGElement || t;
    if (n.createSVGPoint) {
      var i = n.createSVGPoint();
      return i.x = e.clientX, i.y = e.clientY, i = i.matrixTransform(t.getScreenCTM().inverse()), [i.x, i.y];
    }
    if (t.getBoundingClientRect) {
      var r = t.getBoundingClientRect();
      return [e.clientX - r.left - t.clientLeft, e.clientY - r.top - t.clientTop];
    }
  }
  return [e.pageX, e.pageY];
}
const Ug = { capture: !0, passive: !1 };
function zg(e) {
  e.preventDefault(), e.stopImmediatePropagation();
}
function M3(e) {
  var t = e.document.documentElement, n = ce(e).on("dragstart.drag", zg, Ug);
  "onselectstart" in t ? n.on("selectstart.drag", zg, Ug) : (t.__noselect = t.style.MozUserSelect, t.style.MozUserSelect = "none");
}
function $3(e, t) {
  var n = e.document.documentElement, i = ce(e).on("dragstart.drag", null);
  t && (i.on("click.drag", zg, Ug), setTimeout(function() {
    i.on("click.drag", null);
  }, 0)), "onselectstart" in n ? i.on("selectstart.drag", null) : (n.style.MozUserSelect = n.__noselect, delete n.__noselect);
}
function el(e, t, n) {
  e.prototype = t.prototype = n, n.constructor = e;
}
function vf(e, t) {
  var n = Object.create(e.prototype);
  for (var i in t)
    n[i] = t[i];
  return n;
}
function ro() {
}
var Zo = 0.7, Dc = 1 / Zo, uc = "\\s*([+-]?\\d+)\\s*", Lu = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", or = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", LV = /^#([0-9a-f]{3,8})$/, RV = new RegExp(`^rgb\\(${uc},${uc},${uc}\\)$`), CV = new RegExp(`^rgb\\(${or},${or},${or}\\)$`), kV = new RegExp(`^rgba\\(${uc},${uc},${uc},${Lu}\\)$`), UV = new RegExp(`^rgba\\(${or},${or},${or},${Lu}\\)$`), zV = new RegExp(`^hsl\\(${Lu},${or},${or}\\)$`), PV = new RegExp(`^hsla\\(${Lu},${or},${or},${Lu}\\)$`), d2 = {
  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
};
el(ro, Ws, {
  copy(e) {
    return Object.assign(new this.constructor(), this, e);
  },
  displayable() {
    return this.rgb().displayable();
  },
  hex: p2,
  // Deprecated! Use color.formatHex.
  formatHex: p2,
  formatHex8: VV,
  formatHsl: jV,
  formatRgb: y2,
  toString: y2
});
function p2() {
  return this.rgb().formatHex();
}
function VV() {
  return this.rgb().formatHex8();
}
function jV() {
  return T3(this).formatHsl();
}
function y2() {
  return this.rgb().formatRgb();
}
function Ws(e) {
  var t, n;
  return e = (e + "").trim().toLowerCase(), (t = LV.exec(e)) ? (n = t[1].length, t = parseInt(t[1], 16), n === 6 ? m2(t) : n === 3 ? new qe(t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | t & 240, (t & 15) << 4 | t & 15, 1) : n === 8 ? lh(t >> 24 & 255, t >> 16 & 255, t >> 8 & 255, (t & 255) / 255) : n === 4 ? lh(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 = RV.exec(e)) ? new qe(t[1], t[2], t[3], 1) : (t = CV.exec(e)) ? new qe(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, 1) : (t = kV.exec(e)) ? lh(t[1], t[2], t[3], t[4]) : (t = UV.exec(e)) ? lh(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, t[4]) : (t = zV.exec(e)) ? w2(t[1], t[2] / 100, t[3] / 100, 1) : (t = PV.exec(e)) ? w2(t[1], t[2] / 100, t[3] / 100, t[4]) : d2.hasOwnProperty(e) ? m2(d2[e]) : e === "transparent" ? new qe(NaN, NaN, NaN, 0) : null;
}
function m2(e) {
  return new qe(e >> 16 & 255, e >> 8 & 255, e & 255, 1);
}
function lh(e, t, n, i) {
  return i <= 0 && (e = t = n = NaN), new qe(e, t, n, i);
}
function Xb(e) {
  return e instanceof ro || (e = Ws(e)), e ? (e = e.rgb(), new qe(e.r, e.g, e.b, e.opacity)) : new qe();
}
function Pn(e, t, n, i) {
  return arguments.length === 1 ? Xb(e) : new qe(e, t, n, i ?? 1);
}
function qe(e, t, n, i) {
  this.r = +e, this.g = +t, this.b = +n, this.opacity = +i;
}
el(qe, Pn, vf(ro, {
  brighter(e) {
    return e = e == null ? Dc : Math.pow(Dc, e), new qe(this.r * e, this.g * e, this.b * e, this.opacity);
  },
  darker(e) {
    return e = e == null ? Zo : Math.pow(Zo, e), new qe(this.r * e, this.g * e, this.b * e, this.opacity);
  },
  rgb() {
    return this;
  },
  clamp() {
    return new qe(zo(this.r), zo(this.g), zo(this.b), tp(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: g2,
  // Deprecated! Use color.formatHex.
  formatHex: g2,
  formatHex8: qV,
  formatRgb: b2,
  toString: b2
}));
function g2() {
  return `#${Oo(this.r)}${Oo(this.g)}${Oo(this.b)}`;
}
function qV() {
  return `#${Oo(this.r)}${Oo(this.g)}${Oo(this.b)}${Oo((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`;
}
function b2() {
  const e = tp(this.opacity);
  return `${e === 1 ? "rgb(" : "rgba("}${zo(this.r)}, ${zo(this.g)}, ${zo(this.b)}${e === 1 ? ")" : `, ${e})`}`;
}
function tp(e) {
  return isNaN(e) ? 1 : Math.max(0, Math.min(1, e));
}
function zo(e) {
  return Math.max(0, Math.min(255, Math.round(e) || 0));
}
function Oo(e) {
  return e = zo(e), (e < 16 ? "0" : "") + e.toString(16);
}
function w2(e, t, n, i) {
  return i <= 0 ? e = t = n = NaN : n <= 0 || n >= 1 ? e = t = NaN : t <= 0 && (e = NaN), new wi(e, t, n, i);
}
function T3(e) {
  if (e instanceof wi)
    return new wi(e.h, e.s, e.l, e.opacity);
  if (e instanceof ro || (e = Ws(e)), !e)
    return new wi();
  if (e instanceof wi)
    return e;
  e = e.rgb();
  var t = e.r / 255, n = e.g / 255, i = e.b / 255, r = Math.min(t, n, i), s = Math.max(t, n, i), o = NaN, a = s - r, c = (s + r) / 2;
  return a ? (t === s ? o = (n - i) / a + (n < i) * 6 : n === s ? o = (i - t) / a + 2 : o = (t - n) / a + 4, a /= c < 0.5 ? s + r : 2 - s - r, o *= 60) : a = c > 0 && c < 1 ? 0 : o, new wi(o, a, c, e.opacity);
}
function Pg(e, t, n, i) {
  return arguments.length === 1 ? T3(e) : new wi(e, t, n, i ?? 1);
}
function wi(e, t, n, i) {
  this.h = +e, this.s = +t, this.l = +n, this.opacity = +i;
}
el(wi, Pg, vf(ro, {
  brighter(e) {
    return e = e == null ? Dc : Math.pow(Dc, e), new wi(this.h, this.s, this.l * e, this.opacity);
  },
  darker(e) {
    return e = e == null ? Zo : Math.pow(Zo, e), new wi(this.h, this.s, this.l * e, this.opacity);
  },
  rgb() {
    var e = this.h % 360 + (this.h < 0) * 360, t = isNaN(e) || isNaN(this.s) ? 0 : this.s, n = this.l, i = n + (n < 0.5 ? n : 1 - n) * t, r = 2 * n - i;
    return new qe(
      cm(e >= 240 ? e - 240 : e + 120, r, i),
      cm(e, r, i),
      cm(e < 120 ? e + 240 : e - 120, r, i),
      this.opacity
    );
  },
  clamp() {
    return new wi(v2(this.h), uh(this.s), uh(this.l), tp(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 = tp(this.opacity);
    return `${e === 1 ? "hsl(" : "hsla("}${v2(this.h)}, ${uh(this.s) * 100}%, ${uh(this.l) * 100}%${e === 1 ? ")" : `, ${e})`}`;
  }
}));
function v2(e) {
  return e = (e || 0) % 360, e < 0 ? e + 360 : e;
}
function uh(e) {
  return Math.max(0, Math.min(1, e || 0));
}
function cm(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 D3 = Math.PI / 180, N3 = 180 / Math.PI, ep = 18, B3 = 0.96422, O3 = 1, F3 = 0.82521, E3 = 4 / 29, fc = 6 / 29, L3 = 3 * fc * fc, YV = fc * fc * fc;
function R3(e) {
  if (e instanceof ar)
    return new ar(e.l, e.a, e.b, e.opacity);
  if (e instanceof Wr)
    return C3(e);
  e instanceof qe || (e = Xb(e));
  var t = hm(e.r), n = hm(e.g), i = hm(e.b), r = lm((0.2225045 * t + 0.7168786 * n + 0.0606169 * i) / O3), s, o;
  return t === n && n === i ? s = o = r : (s = lm((0.4360747 * t + 0.3850649 * n + 0.1430804 * i) / B3), o = lm((0.0139322 * t + 0.0971045 * n + 0.7141733 * i) / F3)), new ar(116 * r - 16, 500 * (s - r), 200 * (r - o), e.opacity);
}
function Vg(e, t, n, i) {
  return arguments.length === 1 ? R3(e) : new ar(e, t, n, i ?? 1);
}
function ar(e, t, n, i) {
  this.l = +e, this.a = +t, this.b = +n, this.opacity = +i;
}
el(ar, Vg, vf(ro, {
  brighter(e) {
    return new ar(this.l + ep * (e ?? 1), this.a, this.b, this.opacity);
  },
  darker(e) {
    return new ar(this.l - ep * (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 = B3 * um(t), e = O3 * um(e), n = F3 * um(n), new qe(
      fm(3.1338561 * t - 1.6168667 * e - 0.4906146 * n),
      fm(-0.9787684 * t + 1.9161415 * e + 0.033454 * n),
      fm(0.0719453 * t - 0.2289914 * e + 1.4052427 * n),
      this.opacity
    );
  }
}));
function lm(e) {
  return e > YV ? Math.pow(e, 1 / 3) : e / L3 + E3;
}
function um(e) {
  return e > fc ? e * e * e : L3 * (e - E3);
}
function fm(e) {
  return 255 * (e <= 31308e-7 ? 12.92 * e : 1.055 * Math.pow(e, 1 / 2.4) - 0.055);
}
function hm(e) {
  return (e /= 255) <= 0.04045 ? e / 12.92 : Math.pow((e + 0.055) / 1.055, 2.4);
}
function WV(e) {
  if (e instanceof Wr)
    return new Wr(e.h, e.c, e.l, e.opacity);
  if (e instanceof ar || (e = R3(e)), e.a === 0 && e.b === 0)
    return new Wr(NaN, 0 < e.l && e.l < 100 ? 0 : NaN, e.l, e.opacity);
  var t = Math.atan2(e.b, e.a) * N3;
  return new Wr(t < 0 ? t + 360 : t, Math.sqrt(e.a * e.a + e.b * e.b), e.l, e.opacity);
}
function jg(e, t, n, i) {
  return arguments.length === 1 ? WV(e) : new Wr(e, t, n, i ?? 1);
}
function Wr(e, t, n, i) {
  this.h = +e, this.c = +t, this.l = +n, this.opacity = +i;
}
function C3(e) {
  if (isNaN(e.h))
    return new ar(e.l, 0, 0, e.opacity);
  var t = e.h * D3;
  return new ar(e.l, Math.cos(t) * e.c, Math.sin(t) * e.c, e.opacity);
}
el(Wr, jg, vf(ro, {
  brighter(e) {
    return new Wr(this.h, this.c, this.l + ep * (e ?? 1), this.opacity);
  },
  darker(e) {
    return new Wr(this.h, this.c, this.l - ep * (e ?? 1), this.opacity);
  },
  rgb() {
    return C3(this).rgb();
  }
}));
var k3 = -0.14861, Hb = 1.78277, Jb = -0.29227, Qy = -0.90649, Ru = 1.97294, _2 = Ru * Qy, x2 = Ru * Hb, S2 = Hb * Jb - Qy * k3;
function GV(e) {
  if (e instanceof Po)
    return new Po(e.h, e.s, e.l, e.opacity);
  e instanceof qe || (e = Xb(e));
  var t = e.r / 255, n = e.g / 255, i = e.b / 255, r = (S2 * i + _2 * t - x2 * n) / (S2 + _2 - x2), s = i - r, o = (Ru * (n - r) - Jb * s) / Qy, a = Math.sqrt(o * o + s * s) / (Ru * r * (1 - r)), c = a ? Math.atan2(o, s) * N3 - 120 : NaN;
  return new Po(c < 0 ? c + 360 : c, a, r, e.opacity);
}
function hr(e, t, n, i) {
  return arguments.length === 1 ? GV(e) : new Po(e, t, n, i ?? 1);
}
function Po(e, t, n, i) {
  this.h = +e, this.s = +t, this.l = +n, this.opacity = +i;
}
el(Po, hr, vf(ro, {
  brighter(e) {
    return e = e == null ? Dc : Math.pow(Dc, e), new Po(this.h, this.s, this.l * e, this.opacity);
  },
  darker(e) {
    return e = e == null ? Zo : Math.pow(Zo, e), new Po(this.h, this.s, this.l * e, this.opacity);
  },
  rgb() {
    var e = isNaN(this.h) ? 0 : (this.h + 120) * D3, t = +this.l, n = isNaN(this.s) ? 0 : this.s * t * (1 - t), i = Math.cos(e), r = Math.sin(e);
    return new qe(
      255 * (t + n * (k3 * i + Hb * r)),
      255 * (t + n * (Jb * i + Qy * r)),
      255 * (t + n * (Ru * i)),
      this.opacity
    );
  }
}));
function XV(e, t, n, i, r) {
  var s = e * e, o = s * e;
  return ((1 - 3 * e + 3 * s - o) * t + (4 - 6 * s + 3 * o) * n + (1 + 3 * e + 3 * s - 3 * o) * i + o * r) / 6;
}
function HV(e) {
  var t = e.length - 1;
  return function(n) {
    var i = n <= 0 ? n = 0 : n >= 1 ? (n = 1, t - 1) : Math.floor(n * t), r = e[i], s = e[i + 1], o = i > 0 ? e[i - 1] : 2 * r - s, a = i < t - 1 ? e[i + 2] : 2 * s - r;
    return XV((n - i / t) * t, o, r, s, a);
  };
}
const t0 = (e) => () => e;
function U3(e, t) {
  return function(n) {
    return e + n * t;
  };
}
function JV(e, t, n) {
  return e = Math.pow(e, n), t = Math.pow(t, n) - e, n = 1 / n, function(i) {
    return Math.pow(e + i * t, n);
  };
}
function Kb(e, t) {
  var n = t - e;
  return n ? U3(e, n > 180 || n < -180 ? n - 360 * Math.round(n / 360) : n) : t0(isNaN(e) ? t : e);
}
function KV(e) {
  return (e = +e) == 1 ? en : function(t, n) {
    return n - t ? JV(t, n, e) : t0(isNaN(t) ? n : t);
  };
}
function en(e, t) {
  var n = t - e;
  return n ? U3(e, n) : t0(isNaN(e) ? t : e);
}
const Qo = function e(t) {
  var n = KV(t);
  function i(r, s) {
    var o = n((r = Pn(r)).r, (s = Pn(s)).r), a = n(r.g, s.g), c = n(r.b, s.b), l = en(r.opacity, s.opacity);
    return function(u) {
      return r.r = o(u), r.g = a(u), r.b = c(u), r.opacity = l(u), r + "";
    };
  }
  return i.gamma = e, i;
}(1);
function ZV(e) {
  return function(t) {
    var n = t.length, i = new Array(n), r = new Array(n), s = new Array(n), o, a;
    for (o = 0; o < n; ++o)
      a = Pn(t[o]), i[o] = a.r || 0, r[o] = a.g || 0, s[o] = a.b || 0;
    return i = e(i), r = e(r), s = e(s), a.opacity = 1, function(c) {
      return a.r = i(c), a.g = r(c), a.b = s(c), a + "";
    };
  };
}
var QV = ZV(HV);
function tj(e, t) {
  t || (t = []);
  var n = e ? Math.min(t.length, e.length) : 0, i = t.slice(), r;
  return function(s) {
    for (r = 0; r < n; ++r)
      i[r] = e[r] * (1 - s) + t[r] * s;
    return i;
  };
}
function ej(e) {
  return ArrayBuffer.isView(e) && !(e instanceof DataView);
}
function nj(e, t) {
  var n = t ? t.length : 0, i = e ? Math.min(n, e.length) : 0, r = new Array(i), s = new Array(n), o;
  for (o = 0; o < i; ++o)
    r[o] = nl(e[o], t[o]);
  for (; o < n; ++o)
    s[o] = t[o];
  return function(a) {
    for (o = 0; o < i; ++o)
      s[o] = r[o](a);
    return s;
  };
}
function ij(e, t) {
  var n = /* @__PURE__ */ new Date();
  return e = +e, t = +t, function(i) {
    return n.setTime(e * (1 - i) + t * i), n;
  };
}
function Qe(e, t) {
  return e = +e, t = +t, function(n) {
    return e * (1 - n) + t * n;
  };
}
function rj(e, t) {
  var n = {}, i = {}, r;
  (e === null || typeof e != "object") && (e = {}), (t === null || typeof t != "object") && (t = {});
  for (r in t)
    r in e ? n[r] = nl(e[r], t[r]) : i[r] = t[r];
  return function(s) {
    for (r in n)
      i[r] = n[r](s);
    return i;
  };
}
var qg = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, dm = new RegExp(qg.source, "g");
function sj(e) {
  return function() {
    return e;
  };
}
function oj(e) {
  return function(t) {
    return e(t) + "";
  };
}
function z3(e, t) {
  var n = qg.lastIndex = dm.lastIndex = 0, i, r, s, o = -1, a = [], c = [];
  for (e = e + "", t = t + ""; (i = qg.exec(e)) && (r = dm.exec(t)); )
    (s = r.index) > n && (s = t.slice(n, s), a[o] ? a[o] += s : a[++o] = s), (i = i[0]) === (r = r[0]) ? a[o] ? a[o] += r : a[++o] = r : (a[++o] = null, c.push({ i: o, x: Qe(i, r) })), n = dm.lastIndex;
  return n < t.length && (s = t.slice(n), a[o] ? a[o] += s : a[++o] = s), a.length < 2 ? c[0] ? oj(c[0].x) : sj(t) : (t = c.length, function(l) {
    for (var u = 0, f; u < t; ++u)
      a[(f = c[u]).i] = f.x(l);
    return a.join("");
  });
}
function nl(e, t) {
  var n = typeof t, i;
  return t == null || n === "boolean" ? t0(t) : (n === "number" ? Qe : n === "string" ? (i = Ws(t)) ? (t = i, Qo) : z3 : t instanceof Ws ? Qo : t instanceof Date ? ij : ej(t) ? tj : Array.isArray(t) ? nj : typeof t.valueOf != "function" && typeof t.toString != "function" || isNaN(t) ? rj : Qe)(e, t);
}
function Zb(e, t) {
  return e = +e, t = +t, function(n) {
    return Math.round(e * (1 - n) + t * n);
  };
}
var I2 = 180 / Math.PI, Yg = {
  translateX: 0,
  translateY: 0,
  rotate: 0,
  skewX: 0,
  scaleX: 1,
  scaleY: 1
};
function P3(e, t, n, i, r, s) {
  var o, a, c;
  return (o = Math.sqrt(e * e + t * t)) && (e /= o, t /= o), (c = e * n + t * i) && (n -= e * c, i -= t * c), (a = Math.sqrt(n * n + i * i)) && (n /= a, i /= a, c /= a), e * i < t * n && (e = -e, t = -t, c = -c, o = -o), {
    translateX: r,
    translateY: s,
    rotate: Math.atan2(t, e) * I2,
    skewX: Math.atan(c) * I2,
    scaleX: o,
    scaleY: a
  };
}
var fh;
function aj(e) {
  const t = new (typeof DOMMatrix == "function" ? DOMMatrix : WebKitCSSMatrix)(e + "");
  return t.isIdentity ? Yg : P3(t.a, t.b, t.c, t.d, t.e, t.f);
}
function cj(e) {
  return e == null || (fh || (fh = document.createElementNS("http://www.w3.org/2000/svg", "g")), fh.setAttribute("transform", e), !(e = fh.transform.baseVal.consolidate())) ? Yg : (e = e.matrix, P3(e.a, e.b, e.c, e.d, e.e, e.f));
}
function V3(e, t, n, i) {
  function r(l) {
    return l.length ? l.pop() + " " : "";
  }
  function s(l, u, f, h, d, p) {
    if (l !== f || u !== h) {
      var y = d.push("translate(", null, t, null, n);
      p.push({ i: y - 4, x: Qe(l, f) }, { i: y - 2, x: Qe(u, h) });
    } else
      (f || h) && d.push("translate(" + f + t + h + n);
  }
  function o(l, u, f, h) {
    l !== u ? (l - u > 180 ? u += 360 : u - l > 180 && (l += 360), h.push({ i: f.push(r(f) + "rotate(", null, i) - 2, x: Qe(l, u) })) : u && f.push(r(f) + "rotate(" + u + i);
  }
  function a(l, u, f, h) {
    l !== u ? h.push({ i: f.push(r(f) + "skewX(", null, i) - 2, x: Qe(l, u) }) : u && f.push(r(f) + "skewX(" + u + i);
  }
  function c(l, u, f, h, d, p) {
    if (l !== f || u !== h) {
      var y = d.push(r(d) + "scale(", null, ",", null, ")");
      p.push({ i: y - 4, x: Qe(l, f) }, { i: y - 2, x: Qe(u, h) });
    } else
      (f !== 1 || h !== 1) && d.push(r(d) + "scale(" + f + "," + h + ")");
  }
  return function(l, u) {
    var f = [], h = [];
    return l = e(l), u = e(u), s(l.translateX, l.translateY, u.translateX, u.translateY, f, h), o(l.rotate, u.rotate, f, h), a(l.skewX, u.skewX, f, h), c(l.scaleX, l.scaleY, u.scaleX, u.scaleY, f, h), l = u = null, function(d) {
      for (var p = -1, y = h.length, g; ++p < y; )
        f[(g = h[p]).i] = g.x(d);
      return f.join("");
    };
  };
}
var lj = V3(aj, "px, ", "px)", "deg)"), uj = V3(cj, ", ", ")", ")"), fj = 1e-12;
function A2(e) {
  return ((e = Math.exp(e)) + 1 / e) / 2;
}
function hj(e) {
  return ((e = Math.exp(e)) - 1 / e) / 2;
}
function dj(e) {
  return ((e = Math.exp(2 * e)) - 1) / (e + 1);
}
const pj = function e(t, n, i) {
  function r(s, o) {
    var a = s[0], c = s[1], l = s[2], u = o[0], f = o[1], h = o[2], d = u - a, p = f - c, y = d * d + p * p, g, m;
    if (y < fj)
      m = Math.log(h / l) / t, g = function(I) {
        return [
          a + I * d,
          c + I * p,
          l * Math.exp(t * I * m)
        ];
      };
    else {
      var b = Math.sqrt(y), w = (h * h - l * l + i * y) / (2 * l * n * b), v = (h * h - l * l - i * y) / (2 * h * n * b), _ = Math.log(Math.sqrt(w * w + 1) - w), x = Math.log(Math.sqrt(v * v + 1) - v);
      m = (x - _) / t, g = function(I) {
        var N = I * m, A = A2(_), D = l / (n * b) * (A * dj(t * N + _) - hj(_));
        return [
          a + D * d,
          c + D * p,
          l * A / A2(t * N + _)
        ];
      };
    }
    return g.duration = m * 1e3 * t / Math.SQRT2, g;
  }
  return r.rho = function(s) {
    var o = Math.max(1e-3, +s), a = o * o, c = a * a;
    return e(o, a, c);
  }, r;
}(Math.SQRT2, 2, 4);
function yj(e) {
  return function(t, n) {
    var i = e((t = Pg(t)).h, (n = Pg(n)).h), r = en(t.s, n.s), s = en(t.l, n.l), o = en(t.opacity, n.opacity);
    return function(a) {
      return t.h = i(a), t.s = r(a), t.l = s(a), t.opacity = o(a), t + "";
    };
  };
}
const mj = yj(Kb);
function gj(e, t) {
  var n = en((e = Vg(e)).l, (t = Vg(t)).l), i = en(e.a, t.a), r = en(e.b, t.b), s = en(e.opacity, t.opacity);
  return function(o) {
    return e.l = n(o), e.a = i(o), e.b = r(o), e.opacity = s(o), e + "";
  };
}
function bj(e) {
  return function(t, n) {
    var i = e((t = jg(t)).h, (n = jg(n)).h), r = en(t.c, n.c), s = en(t.l, n.l), o = en(t.opacity, n.opacity);
    return function(a) {
      return t.h = i(a), t.c = r(a), t.l = s(a), t.opacity = o(a), t + "";
    };
  };
}
const wj = bj(Kb);
function j3(e) {
  return function t(n) {
    n = +n;
    function i(r, s) {
      var o = e((r = hr(r)).h, (s = hr(s)).h), a = en(r.s, s.s), c = en(r.l, s.l), l = en(r.opacity, s.opacity);
      return function(u) {
        return r.h = o(u), r.s = a(u), r.l = c(Math.pow(u, n)), r.opacity = l(u), r + "";
      };
    }
    return i.gamma = t, i;
  }(1);
}
j3(Kb);
var Qb = j3(en);
function e0(e, t) {
  t === void 0 && (t = e, e = nl);
  for (var n = 0, i = t.length - 1, r = t[0], s = new Array(i < 0 ? 0 : i); n < i; )
    s[n] = e(r, r = t[++n]);
  return function(o) {
    var a = Math.max(0, Math.min(i - 1, Math.floor(o *= i)));
    return s[a](o - a);
  };
}
function $i(e, t) {
  for (var n = new Array(t), i = 0; i < t; ++i)
    n[i] = e(i / (t - 1));
  return n;
}
var Nc = 0, Yl = 0, _l = 0, q3 = 1e3, np, Wl, ip = 0, ta = 0, n0 = 0, Cu = typeof performance == "object" && performance.now ? performance : Date, Y3 = typeof window == "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(e) {
  setTimeout(e, 17);
};
function tw() {
  return ta || (Y3(vj), ta = Cu.now() + n0);
}
function vj() {
  ta = 0;
}
function rp() {
  this._call = this._time = this._next = null;
}
rp.prototype = W3.prototype = {
  constructor: rp,
  restart: function(e, t, n) {
    if (typeof e != "function")
      throw new TypeError("callback is not a function");
    n = (n == null ? tw() : +n) + (t == null ? 0 : +t), !this._next && Wl !== this && (Wl ? Wl._next = this : np = this, Wl = this), this._call = e, this._time = n, Wg();
  },
  stop: function() {
    this._call && (this._call = null, this._time = 1 / 0, Wg());
  }
};
function W3(e, t, n) {
  var i = new rp();
  return i.restart(e, t, n), i;
}
function _j() {
  tw(), ++Nc;
  for (var e = np, t; e; )
    (t = ta - e._time) >= 0 && e._call.call(void 0, t), e = e._next;
  --Nc;
}
function M2() {
  ta = (ip = Cu.now()) + n0, Nc = Yl = 0;
  try {
    _j();
  } finally {
    Nc = 0, Sj(), ta = 0;
  }
}
function xj() {
  var e = Cu.now(), t = e - ip;
  t > q3 && (n0 -= t, ip = e);
}
function Sj() {
  for (var e, t = np, n, i = 1 / 0; t; )
    t._call ? (i > t._time && (i = t._time), e = t, t = t._next) : (n = t._next, t._next = null, t = e ? e._next = n : np = n);
  Wl = e, Wg(i);
}
function Wg(e) {
  if (!Nc) {
    Yl && (Yl = clearTimeout(Yl));
    var t = e - ta;
    t > 24 ? (e < 1 / 0 && (Yl = setTimeout(M2, e - Cu.now() - n0)), _l && (_l = clearInterval(_l))) : (_l || (ip = Cu.now(), _l = setInterval(xj, q3)), Nc = 1, Y3(M2));
  }
}
function $2(e, t, n) {
  var i = new rp();
  return t = t == null ? 0 : +t, i.restart((r) => {
    i.stop(), e(r + t);
  }, t, n), i;
}
var Ij = Jy("start", "end", "cancel", "interrupt"), Aj = [], G3 = 0, T2 = 1, Gg = 2, nd = 3, D2 = 4, Xg = 5, id = 6;
function i0(e, t, n, i, r, s) {
  var o = e.__transition;
  if (!o)
    e.__transition = {};
  else if (n in o)
    return;
  Mj(e, n, {
    name: t,
    index: i,
    // For context during callback.
    group: r,
    // For context during callback.
    on: Ij,
    tween: Aj,
    time: s.time,
    delay: s.delay,
    duration: s.duration,
    ease: s.ease,
    timer: null,
    state: G3
  });
}
function ew(e, t) {
  var n = Ri(e, t);
  if (n.state > G3)
    throw new Error("too late; already scheduled");
  return n;
}
function gr(e, t) {
  var n = Ri(e, t);
  if (n.state > nd)
    throw new Error("too late; already running");
  return n;
}
function Ri(e, t) {
  var n = e.__transition;
  if (!n || !(n = n[t]))
    throw new Error("transition not found");
  return n;
}
function Mj(e, t, n) {
  var i = e.__transition, r;
  i[t] = n, n.timer = W3(s, 0, n.time);
  function s(l) {
    n.state = T2, n.timer.restart(o, n.delay, n.time), n.delay <= l && o(l - n.delay);
  }
  function o(l) {
    var u, f, h, d;
    if (n.state !== T2)
      return c();
    for (u in i)
      if (d = i[u], d.name === n.name) {
        if (d.state === nd)
          return $2(o);
        d.state === D2 ? (d.state = id, d.timer.stop(), d.on.call("interrupt", e, e.__data__, d.index, d.group), delete i[u]) : +u < t && (d.state = id, d.timer.stop(), d.on.call("cancel", e, e.__data__, d.index, d.group), delete i[u]);
      }
    if ($2(function() {
      n.state === nd && (n.state = D2, n.timer.restart(a, n.delay, n.time), a(l));
    }), n.state = Gg, n.on.call("start", e, e.__data__, n.index, n.group), n.state === Gg) {
      for (n.state = nd, r = new Array(h = n.tween.length), u = 0, f = -1; u < h; ++u)
        (d = n.tween[u].value.call(e, e.__data__, n.index, n.group)) && (r[++f] = d);
      r.length = f + 1;
    }
  }
  function a(l) {
    for (var u = l < n.duration ? n.ease.call(null, l / n.duration) : (n.timer.restart(c), n.state = Xg, 1), f = -1, h = r.length; ++f < h; )
      r[f].call(e, u);
    n.state === Xg && (n.on.call("end", e, e.__data__, n.index, n.group), c());
  }
  function c() {
    n.state = id, n.timer.stop(), delete i[t];
    for (var l in i)
      return;
    delete e.__transition;
  }
}
function hc(e, t) {
  var n = e.__transition, i, r, s = !0, o;
  if (n) {
    t = t == null ? null : t + "";
    for (o in n) {
      if ((i = n[o]).name !== t) {
        s = !1;
        continue;
      }
      r = i.state > Gg && i.state < Xg, i.state = id, i.timer.stop(), i.on.call(r ? "interrupt" : "cancel", e, e.__data__, i.index, i.group), delete n[o];
    }
    s && delete e.__transition;
  }
}
function $j(e) {
  return this.each(function() {
    hc(this, e);
  });
}
function Tj(e, t) {
  var n, i;
  return function() {
    var r = gr(this, e), s = r.tween;
    if (s !== n) {
      i = n = s;
      for (var o = 0, a = i.length; o < a; ++o)
        if (i[o].name === t) {
          i = i.slice(), i.splice(o, 1);
          break;
        }
    }
    r.tween = i;
  };
}
function Dj(e, t, n) {
  var i, r;
  if (typeof n != "function")
    throw new Error();
  return function() {
    var s = gr(this, e), o = s.tween;
    if (o !== i) {
      r = (i = o).slice();
      for (var a = { name: t, value: n }, c = 0, l = r.length; c < l; ++c)
        if (r[c].name === t) {
          r[c] = a;
          break;
        }
      c === l && r.push(a);
    }
    s.tween = r;
  };
}
function Nj(e, t) {
  var n = this._id;
  if (e += "", arguments.length < 2) {
    for (var i = Ri(this.node(), n).tween, r = 0, s = i.length, o; r < s; ++r)
      if ((o = i[r]).name === e)
        return o.value;
    return null;
  }
  return this.each((t == null ? Tj : Dj)(n, e, t));
}
function nw(e, t, n) {
  var i = e._id;
  return e.each(function() {
    var r = gr(this, i);
    (r.value || (r.value = {}))[t] = n.apply(this, arguments);
  }), function(r) {
    return Ri(r, i).value[t];
  };
}
function X3(e, t) {
  var n;
  return (typeof t == "number" ? Qe : t instanceof Ws ? Qo : (n = Ws(t)) ? (t = n, Qo) : z3)(e, t);
}
function Bj(e) {
  return function() {
    this.removeAttribute(e);
  };
}
function Oj(e) {
  return function() {
    this.removeAttributeNS(e.space, e.local);
  };
}
function Fj(e, t, n) {
  var i, r = n + "", s;
  return function() {
    var o = this.getAttribute(e);
    return o === r ? null : o === i ? s : s = t(i = o, n);
  };
}
function Ej(e, t, n) {
  var i, r = n + "", s;
  return function() {
    var o = this.getAttributeNS(e.space, e.local);
    return o === r ? null : o === i ? s : s = t(i = o, n);
  };
}
function Lj(e, t, n) {
  var i, r, 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 === i && c === r ? s : (r = c, s = t(i = o, a)));
  };
}
function Rj(e, t, n) {
  var i, r, 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 === i && c === r ? s : (r = c, s = t(i = o, a)));
  };
}
function Cj(e, t) {
  var n = Ky(e), i = n === "transform" ? uj : X3;
  return this.attrTween(e, typeof t == "function" ? (n.local ? Rj : Lj)(n, i, nw(this, "attr." + e, t)) : t == null ? (n.local ? Oj : Bj)(n) : (n.local ? Ej : Fj)(n, i, t));
}
function kj(e, t) {
  return function(n) {
    this.setAttribute(e, t.call(this, n));
  };
}
function Uj(e, t) {
  return function(n) {
    this.setAttributeNS(e.space, e.local, t.call(this, n));
  };
}
function zj(e, t) {
  var n, i;
  function r() {
    var s = t.apply(this, arguments);
    return s !== i && (n = (i = s) && Uj(e, s)), n;
  }
  return r._value = t, r;
}
function Pj(e, t) {
  var n, i;
  function r() {
    var s = t.apply(this, arguments);
    return s !== i && (n = (i = s) && kj(e, s)), n;
  }
  return r._value = t, r;
}
function Vj(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 i = Ky(e);
  return this.tween(n, (i.local ? zj : Pj)(i, t));
}
function jj(e, t) {
  return function() {
    ew(this, e).delay = +t.apply(this, arguments);
  };
}
function qj(e, t) {
  return t = +t, function() {
    ew(this, e).delay = t;
  };
}
function Yj(e) {
  var t = this._id;
  return arguments.length ? this.each((typeof e == "function" ? jj : qj)(t, e)) : Ri(this.node(), t).delay;
}
function Wj(e, t) {
  return function() {
    gr(this, e).duration = +t.apply(this, arguments);
  };
}
function Gj(e, t) {
  return t = +t, function() {
    gr(this, e).duration = t;
  };
}
function Xj(e) {
  var t = this._id;
  return arguments.length ? this.each((typeof e == "function" ? Wj : Gj)(t, e)) : Ri(this.node(), t).duration;
}
function Hj(e, t) {
  if (typeof t != "function")
    throw new Error();
  return function() {
    gr(this, e).ease = t;
  };
}
function Jj(e) {
  var t = this._id;
  return arguments.length ? this.each(Hj(t, e)) : Ri(this.node(), t).ease;
}
function Kj(e, t) {
  return function() {
    var n = t.apply(this, arguments);
    if (typeof n != "function")
      throw new Error();
    gr(this, e).ease = n;
  };
}
function Zj(e) {
  if (typeof e != "function")
    throw new Error();
  return this.each(Kj(this._id, e));
}
function Qj(e) {
  typeof e != "function" && (e = m3(e));
  for (var t = this._groups, n = t.length, i = new Array(n), r = 0; r < n; ++r)
    for (var s = t[r], o = s.length, a = i[r] = [], c, l = 0; l < o; ++l)
      (c = s[l]) && e.call(c, c.__data__, l, s) && a.push(c);
  return new is(i, this._parents, this._name, this._id);
}
function tq(e) {
  if (e._id !== this._id)
    throw new Error();
  for (var t = this._groups, n = e._groups, i = t.length, r = n.length, s = Math.min(i, r), o = new Array(i), a = 0; a < s; ++a)
    for (var c = t[a], l = n[a], u = c.length, f = o[a] = new Array(u), h, d = 0; d < u; ++d)
      (h = c[d] || l[d]) && (f[d] = h);
  for (; a < i; ++a)
    o[a] = t[a];
  return new is(o, this._parents, this._name, this._id);
}
function eq(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 nq(e, t, n) {
  var i, r, s = eq(t) ? ew : gr;
  return function() {
    var o = s(this, e), a = o.on;
    a !== i && (r = (i = a).copy()).on(t, n), o.on = r;
  };
}
function iq(e, t) {
  var n = this._id;
  return arguments.length < 2 ? Ri(this.node(), n).on.on(e) : this.each(nq(n, e, t));
}
function rq(e) {
  return function() {
    var t = this.parentNode;
    for (var n in this.__transition)
      if (+n !== e)
        return;
    t && t.removeChild(this);
  };
}
function sq() {
  return this.on("end.remove", rq(this._id));
}
function oq(e) {
  var t = this._name, n = this._id;
  typeof e != "function" && (e = Wb(e));
  for (var i = this._groups, r = i.length, s = new Array(r), o = 0; o < r; ++o)
    for (var a = i[o], c = a.length, l = s[o] = new Array(c), u, f, h = 0; h < c; ++h)
      (u = a[h]) && (f = e.call(u, u.__data__, h, a)) && ("__data__" in u && (f.__data__ = u.__data__), l[h] = f, i0(l[h], t, n, h, l, Ri(u, n)));
  return new is(s, this._parents, t, n);
}
function aq(e) {
  var t = this._name, n = this._id;
  typeof e != "function" && (e = y3(e));
  for (var i = this._groups, r = i.length, s = [], o = [], a = 0; a < r; ++a)
    for (var c = i[a], l = c.length, u, f = 0; f < l; ++f)
      if (u = c[f]) {
        for (var h = e.call(u, u.__data__, f, c), d, p = Ri(u, n), y = 0, g = h.length; y < g; ++y)
          (d = h[y]) && i0(d, t, n, y, h, p);
        s.push(h), o.push(u);
      }
  return new is(s, o, t, n);
}
var cq = wf.prototype.constructor;
function lq() {
  return new cq(this._groups, this._parents);
}
function uq(e, t) {
  var n, i, r;
  return function() {
    var s = Tc(this, e), o = (this.style.removeProperty(e), Tc(this, e));
    return s === o ? null : s === n && o === i ? r : r = t(n = s, i = o);
  };
}
function H3(e) {
  return function() {
    this.style.removeProperty(e);
  };
}
function fq(e, t, n) {
  var i, r = n + "", s;
  return function() {
    var o = Tc(this, e);
    return o === r ? null : o === i ? s : s = t(i = o, n);
  };
}
function hq(e, t, n) {
  var i, r, s;
  return function() {
    var o = Tc(this, e), a = n(this), c = a + "";
    return a == null && (c = a = (this.style.removeProperty(e), Tc(this, e))), o === c ? null : o === i && c === r ? s : (r = c, s = t(i = o, a));
  };
}
function dq(e, t) {
  var n, i, r, s = "style." + t, o = "end." + s, a;
  return function() {
    var c = gr(this, e), l = c.on, u = c.value[s] == null ? a || (a = H3(t)) : void 0;
    (l !== n || r !== u) && (i = (n = l).copy()).on(o, r = u), c.on = i;
  };
}
function pq(e, t, n) {
  var i = (e += "") == "transform" ? lj : X3;
  return t == null ? this.styleTween(e, uq(e, i)).on("end.style." + e, H3(e)) : typeof t == "function" ? this.styleTween(e, hq(e, i, nw(this, "style." + e, t))).each(dq(this._id, e)) : this.styleTween(e, fq(e, i, t), n).on("end.style." + e, null);
}
function yq(e, t, n) {
  return function(i) {
    this.style.setProperty(e, t.call(this, i), n);
  };
}
function mq(e, t, n) {
  var i, r;
  function s() {
    var o = t.apply(this, arguments);
    return o !== r && (i = (r = o) && yq(e, o, n)), i;
  }
  return s._value = t, s;
}
function gq(e, t, n) {
  var i = "style." + (e += "");
  if (arguments.length < 2)
    return (i = this.tween(i)) && i._value;
  if (t == null)
    return this.tween(i, null);
  if (typeof t != "function")
    throw new Error();
  return this.tween(i, mq(e, t, n ?? ""));
}
function bq(e) {
  return function() {
    this.textContent = e;
  };
}
function wq(e) {
  return function() {
    var t = e(this);
    this.textContent = t ?? "";
  };
}
function vq(e) {
  return this.tween("text", typeof e == "function" ? wq(nw(this, "text", e)) : bq(e == null ? "" : e + ""));
}
function _q(e) {
  return function(t) {
    this.textContent = e.call(this, t);
  };
}
function xq(e) {
  var t, n;
  function i() {
    var r = e.apply(this, arguments);
    return r !== n && (t = (n = r) && _q(r)), t;
  }
  return i._value = e, i;
}
function Sq(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, xq(e));
}
function Iq() {
  for (var e = this._name, t = this._id, n = J3(), i = this._groups, r = i.length, s = 0; s < r; ++s)
    for (var o = i[s], a = o.length, c, l = 0; l < a; ++l)
      if (c = o[l]) {
        var u = Ri(c, t);
        i0(c, e, n, l, o, {
          time: u.time + u.delay + u.duration,
          delay: 0,
          duration: u.duration,
          ease: u.ease
        });
      }
  return new is(i, this._parents, e, n);
}
function Aq() {
  var e, t, n = this, i = n._id, r = n.size();
  return new Promise(function(s, o) {
    var a = { value: o }, c = { value: function() {
      --r === 0 && s();
    } };
    n.each(function() {
      var l = gr(this, i), u = l.on;
      u !== e && (t = (e = u).copy(), t._.cancel.push(a), t._.interrupt.push(a), t._.end.push(c)), l.on = t;
    }), r === 0 && s();
  });
}
var Mq = 0;
function is(e, t, n, i) {
  this._groups = e, this._parents = t, this._name = n, this._id = i;
}
function J3() {
  return ++Mq;
}
var xr = wf.prototype;
is.prototype = {
  constructor: is,
  select: oq,
  selectAll: aq,
  selectChild: xr.selectChild,
  selectChildren: xr.selectChildren,
  filter: Qj,
  merge: tq,
  selection: lq,
  transition: Iq,
  call: xr.call,
  nodes: xr.nodes,
  node: xr.node,
  size: xr.size,
  empty: xr.empty,
  each: xr.each,
  on: iq,
  attr: Cj,
  attrTween: Vj,
  style: pq,
  styleTween: gq,
  text: vq,
  textTween: Sq,
  remove: sq,
  tween: Nj,
  delay: Yj,
  duration: Xj,
  ease: Jj,
  easeVarying: Zj,
  end: Aq,
  [Symbol.iterator]: xr[Symbol.iterator]
};
function $q(e) {
  return ((e *= 2) <= 1 ? e * e * e : (e -= 2) * e * e + 2) / 2;
}
var Tq = {
  time: null,
  // Set on use.
  delay: 0,
  duration: 250,
  ease: $q
};
function Dq(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 Nq(e) {
  var t, n;
  e instanceof is ? (t = e._id, e = e._name) : (t = J3(), (n = Tq).time = tw(), e = e == null ? null : e + "");
  for (var i = this._groups, r = i.length, s = 0; s < r; ++s)
    for (var o = i[s], a = o.length, c, l = 0; l < a; ++l)
      (c = o[l]) && i0(c, e, t, l, o, n || Dq(c, t));
  return new is(i, this._parents, e, t);
}
wf.prototype.interrupt = $j;
wf.prototype.transition = Nq;
const pm = (e) => () => e;
function Bq(e, {
  sourceEvent: t,
  target: n,
  selection: i,
  mode: r,
  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: i, enumerable: !0, configurable: !0 },
    mode: { value: r, enumerable: !0, configurable: !0 },
    _: { value: s }
  });
}
function Oq(e) {
  e.stopImmediatePropagation();
}
function ym(e) {
  e.preventDefault(), e.stopImmediatePropagation();
}
var N2 = { name: "drag" }, mm = { name: "space" }, ba = { name: "handle" }, wa = { name: "center" };
const { abs: B2, max: Je, min: Ke } = Math;
function O2(e) {
  return [+e[0], +e[1]];
}
function Hg(e) {
  return [O2(e[0]), O2(e[1])];
}
var rd = {
  name: "x",
  handles: ["w", "e"].map(ku),
  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]];
  }
}, sd = {
  name: "y",
  handles: ["n", "s"].map(ku),
  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]];
  }
}, Fq = {
  name: "xy",
  handles: ["n", "w", "e", "s", "nw", "ne", "sw", "se"].map(ku),
  input: function(e) {
    return e == null ? null : Hg(e);
  },
  output: function(e) {
    return e;
  }
}, Sr = {
  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"
}, F2 = {
  e: "w",
  w: "e",
  nw: "ne",
  ne: "nw",
  se: "sw",
  sw: "se"
}, E2 = {
  n: "s",
  s: "n",
  nw: "sw",
  ne: "se",
  se: "ne",
  sw: "nw"
}, Eq = {
  overlay: 1,
  selection: 1,
  n: null,
  e: 1,
  s: null,
  w: -1,
  nw: -1,
  ne: 1,
  se: 1,
  sw: -1
}, Lq = {
  overlay: 1,
  selection: 1,
  n: -1,
  e: null,
  s: 1,
  w: null,
  nw: -1,
  ne: -1,
  se: 1,
  sw: 1
};
function ku(e) {
  return { type: e };
}
function Rq(e) {
  return !e.ctrlKey && !e.button;
}
function Cq() {
  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 kq() {
  return navigator.maxTouchPoints || "ontouchstart" in this;
}
function gm(e) {
  for (; !e.__brush; )
    if (!(e = e.parentNode))
      return;
  return e.__brush;
}
function Uq(e) {
  return e[0][0] === e[1][0] || e[0][1] === e[1][1];
}
function zq() {
  return iw(rd);
}
function Pq() {
  return iw(sd);
}
function Vq() {
  return iw(Fq);
}
function iw(e) {
  var t = Cq, n = Rq, i = kq, r = !0, s = Jy("start", "brush", "end"), o = 6, a;
  function c(g) {
    var m = g.property("__brush", y).selectAll(".overlay").data([ku("overlay")]);
    m.enter().append("rect").attr("class", "overlay").attr("pointer-events", "all").attr("cursor", Sr.overlay).merge(m).each(function() {
      var w = gm(this).extent;
      ce(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]);
    }), g.selectAll(".selection").data([ku("selection")]).enter().append("rect").attr("class", "selection").attr("cursor", Sr.selection).attr("fill", "#777").attr("fill-opacity", 0.3).attr("stroke", "#fff").attr("shape-rendering", "crispEdges");
    var b = g.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 Sr[w.type];
    }), g.each(l).attr("fill", "none").attr("pointer-events", "all").on("mousedown.brush", h).filter(i).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(g, m, b) {
    g.tween ? g.on("start.brush", function(w) {
      u(this, arguments).beforestart().start(w);
    }).on("interrupt.brush end.brush", function(w) {
      u(this, arguments).end(w);
    }).tween("brush", function() {
      var w = this, v = w.__brush, _ = u(w, arguments), x = v.selection, I = e.input(typeof m == "function" ? m.apply(this, arguments) : m, v.extent), N = nl(x, I);
      function A(D) {
        v.selection = D === 1 && I === null ? null : N(D), l.call(w), _.brush();
      }
      return x !== null && I !== null ? A : A(1);
    }) : g.each(function() {
      var w = this, v = arguments, _ = w.__brush, x = e.input(typeof m == "function" ? m.apply(w, v) : m, _.extent), I = u(w, v).beforestart();
      hc(w), _.selection = x === null ? null : x, l.call(w), I.start(b).brush(b).end(b);
    });
  }, c.clear = function(g, m) {
    c.move(g, null, m);
  };
  function l() {
    var g = ce(this), m = gm(this).selection;
    m ? (g.selectAll(".selection").style("display", null).attr("x", m[0][0]).attr("y", m[0][1]).attr("width", m[1][0] - m[0][0]).attr("height", m[1][1] - m[0][1]), g.selectAll(".handle").style("display", null).attr("x", function(b) {
      return b.type[b.type.length - 1] === "e" ? m[1][0] - o / 2 : m[0][0] - o / 2;
    }).attr("y", function(b) {
      return b.type[0] === "s" ? m[1][1] - o / 2 : m[0][1] - o / 2;
    }).attr("width", function(b) {
      return b.type === "n" || b.type === "s" ? m[1][0] - m[0][0] + o : o;
    }).attr("height", function(b) {
      return b.type === "e" || b.type === "w" ? m[1][1] - m[0][1] + o : o;
    })) : g.selectAll(".selection,.handle").style("display", "none").attr("x", null).attr("y", null).attr("width", null).attr("height", null);
  }
  function u(g, m, b) {
    var w = g.__brush.emitter;
    return w && (!b || !w.clean) ? w : new f(g, m, b);
  }
  function f(g, m, b) {
    this.that = g, this.args = m, this.state = g.__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(g, m) {
      return this.starting ? (this.starting = !1, this.emit("start", g, m)) : this.emit("brush", g), this;
    },
    brush: function(g, m) {
      return this.emit("brush", g, m), this;
    },
    end: function(g, m) {
      return --this.active === 0 && (delete this.state.emitter, this.emit("end", g, m)), this;
    },
    emit: function(g, m, b) {
      var w = ce(this.that).datum();
      s.call(
        g,
        this.that,
        new Bq(g, {
          sourceEvent: m,
          target: c,
          selection: e.output(this.state.selection),
          mode: b,
          dispatch: s
        }),
        w
      );
    }
  };
  function h(g) {
    if (a && !g.touches || !n.apply(this, arguments))
      return;
    var m = this, b = g.target.__data__.type, w = (r && g.metaKey ? b = "overlay" : b) === "selection" ? N2 : r && g.altKey ? wa : ba, v = e === sd ? null : Eq[b], _ = e === rd ? null : Lq[b], x = gm(m), I = x.extent, N = x.selection, A = I[0][0], D, M, B = I[0][1], R, S, $ = I[1][0], T, L, k = I[1][1], U, C, z = 0, P = 0, G, K = v && _ && r && g.shiftKey, tt, Z, Y = Array.from(g.touches || [g], (Q) => {
      const Zt = Q.identifier;
      return Q = yi(Q, m), Q.point0 = Q.slice(), Q.identifier = Zt, Q;
    });
    hc(m);
    var X = u(m, arguments, !0).beforestart();
    if (b === "overlay") {
      N && (G = !0);
      const Q = [Y[0], Y[1] || Y[0]];
      x.selection = N = [[
        D = e === sd ? A : Ke(Q[0][0], Q[1][0]),
        R = e === rd ? B : Ke(Q[0][1], Q[1][1])
      ], [
        T = e === sd ? $ : Je(Q[0][0], Q[1][0]),
        U = e === rd ? k : Je(Q[0][1], Q[1][1])
      ]], Y.length > 1 && Ft(g);
    } else
      D = N[0][0], R = N[0][1], T = N[1][0], U = N[1][1];
    M = D, S = R, L = T, C = U;
    var j = ce(m).attr("pointer-events", "none"), J = j.selectAll(".overlay").attr("cursor", Sr[b]);
    if (g.touches)
      X.moved = V, X.ended = rt;
    else {
      var et = ce(g.view).on("mousemove.brush", V, !0).on("mouseup.brush", rt, !0);
      r && et.on("keydown.brush", Vt, !0).on("keyup.brush", jt, !0), M3(g.view);
    }
    l.call(m), X.start(g, w.name);
    function V(Q) {
      for (const Zt of Q.changedTouches || [Q])
        for (const En of Y)
          En.identifier === Zt.identifier && (En.cur = yi(Zt, m));
      if (K && !tt && !Z && Y.length === 1) {
        const Zt = Y[0];
        B2(Zt.cur[0] - Zt[0]) > B2(Zt.cur[1] - Zt[1]) ? Z = !0 : tt = !0;
      }
      for (const Zt of Y)
        Zt.cur && (Zt[0] = Zt.cur[0], Zt[1] = Zt.cur[1]);
      G = !0, ym(Q), Ft(Q);
    }
    function Ft(Q) {
      const Zt = Y[0], En = Zt.point0;
      var zi;
      switch (z = Zt[0] - En[0], P = Zt[1] - En[1], w) {
        case mm:
        case N2: {
          v && (z = Je(A - D, Ke($ - T, z)), M = D + z, L = T + z), _ && (P = Je(B - R, Ke(k - U, P)), S = R + P, C = U + P);
          break;
        }
        case ba: {
          Y[1] ? (v && (M = Je(A, Ke($, Y[0][0])), L = Je(A, Ke($, Y[1][0])), v = 1), _ && (S = Je(B, Ke(k, Y[0][1])), C = Je(B, Ke(k, Y[1][1])), _ = 1)) : (v < 0 ? (z = Je(A - D, Ke($ - D, z)), M = D + z, L = T) : v > 0 && (z = Je(A - T, Ke($ - T, z)), M = D, L = T + z), _ < 0 ? (P = Je(B - R, Ke(k - R, P)), S = R + P, C = U) : _ > 0 && (P = Je(B - U, Ke(k - U, P)), S = R, C = U + P));
          break;
        }
        case wa: {
          v && (M = Je(A, Ke($, D - z * v)), L = Je(A, Ke($, T + z * v))), _ && (S = Je(B, Ke(k, R - P * _)), C = Je(B, Ke(k, U + P * _)));
          break;
        }
      }
      L < M && (v *= -1, zi = D, D = T, T = zi, zi = M, M = L, L = zi, b in F2 && J.attr("cursor", Sr[b = F2[b]])), C < S && (_ *= -1, zi = R, R = U, U = zi, zi = S, S = C, C = zi, b in E2 && J.attr("cursor", Sr[b = E2[b]])), x.selection && (N = x.selection), tt && (M = N[0][0], L = N[1][0]), Z && (S = N[0][1], C = N[1][1]), (N[0][0] !== M || N[0][1] !== S || N[1][0] !== L || N[1][1] !== C) && (x.selection = [[M, S], [L, C]], l.call(m), X.brush(Q, w.name));
    }
    function rt(Q) {
      if (Oq(Q), Q.touches) {
        if (Q.touches.length)
          return;
        a && clearTimeout(a), a = setTimeout(function() {
          a = null;
        }, 500);
      } else
        $3(Q.view, G), et.on("keydown.brush keyup.brush mousemove.brush mouseup.brush", null);
      j.attr("pointer-events", "all"), J.attr("cursor", Sr.overlay), x.selection && (N = x.selection), Uq(N) && (x.selection = null, l.call(m)), X.end(Q, w.name);
    }
    function Vt(Q) {
      switch (Q.keyCode) {
        case 16: {
          K = v && _;
          break;
        }
        case 18: {
          w === ba && (v && (T = L - z * v, D = M + z * v), _ && (U = C - P * _, R = S + P * _), w = wa, Ft(Q));
          break;
        }
        case 32: {
          (w === ba || w === wa) && (v < 0 ? T = L - z : v > 0 && (D = M - z), _ < 0 ? U = C - P : _ > 0 && (R = S - P), w = mm, J.attr("cursor", Sr.selection), Ft(Q));
          break;
        }
        default:
          return;
      }
      ym(Q);
    }
    function jt(Q) {
      switch (Q.keyCode) {
        case 16: {
          K && (tt = Z = K = !1, Ft(Q));
          break;
        }
        case 18: {
          w === wa && (v < 0 ? T = L : v > 0 && (D = M), _ < 0 ? U = C : _ > 0 && (R = S), w = ba, Ft(Q));
          break;
        }
        case 32: {
          w === mm && (Q.altKey ? (v && (T = L - z * v, D = M + z * v), _ && (U = C - P * _, R = S + P * _), w = wa) : (v < 0 ? T = L : v > 0 && (D = M), _ < 0 ? U = C : _ > 0 && (R = S), w = ba), J.attr("cursor", Sr[b]), Ft(Q));
          break;
        }
        default:
          return;
      }
      ym(Q);
    }
  }
  function d(g) {
    u(this, arguments).moved(g);
  }
  function p(g) {
    u(this, arguments).ended(g);
  }
  function y() {
    var g = this.__brush || { selection: null };
    return g.extent = Hg(t.apply(this, arguments)), g.dim = e, g;
  }
  return c.extent = function(g) {
    return arguments.length ? (t = typeof g == "function" ? g : pm(Hg(g)), c) : t;
  }, c.filter = function(g) {
    return arguments.length ? (n = typeof g == "function" ? g : pm(!!g), c) : n;
  }, c.touchable = function(g) {
    return arguments.length ? (i = typeof g == "function" ? g : pm(!!g), c) : i;
  }, c.handleSize = function(g) {
    return arguments.length ? (o = +g, c) : o;
  }, c.keyModifiers = function(g) {
    return arguments.length ? (r = !!g, c) : r;
  }, c.on = function() {
    var g = s.on.apply(s, arguments);
    return g === s ? c : g;
  }, c;
}
const Jg = Math.PI, Kg = 2 * Jg, To = 1e-6, jq = Kg - To;
function K3(e) {
  this._ += e[0];
  for (let t = 1, n = e.length; t < n; ++t)
    this._ += arguments[t] + e[t];
}
function qq(e) {
  let t = Math.floor(e);
  if (!(t >= 0))
    throw new Error(`invalid digits: ${e}`);
  if (t > 15)
    return K3;
  const n = 10 ** t;
  return function(i) {
    this._ += i[0];
    for (let r = 1, s = i.length; r < s; ++r)
      this._ += Math.round(arguments[r] * n) / n + i[r];
  };
}
let Z3 = class {
  constructor(t) {
    this._x0 = this._y0 = // start of current subpath
    this._x1 = this._y1 = null, this._ = "", this._append = t == null ? K3 : qq(t);
  }
  moveTo(t, n) {
    this._append`M${this._x0 = this._x1 = +t},${this._y0 = this._y1 = +n}`;
  }
  closePath() {
    this._x1 !== null && (this._x1 = this._x0, this._y1 = this._y0, this._append`Z`);
  }
  lineTo(t, n) {
    this._append`L${this._x1 = +t},${this._y1 = +n}`;
  }
  quadraticCurveTo(t, n, i, r) {
    this._append`Q${+t},${+n},${this._x1 = +i},${this._y1 = +r}`;
  }
  bezierCurveTo(t, n, i, r, s, o) {
    this._append`C${+t},${+n},${+i},${+r},${this._x1 = +s},${this._y1 = +o}`;
  }
  arcTo(t, n, i, r, s) {
    if (t = +t, n = +n, i = +i, r = +r, s = +s, s < 0)
      throw new Error(`negative radius: ${s}`);
    let o = this._x1, a = this._y1, c = i - t, l = r - n, u = o - t, f = a - n, h = u * u + f * f;
    if (this._x1 === null)
      this._append`M${this._x1 = t},${this._y1 = n}`;
    else if (h > To)
      if (!(Math.abs(f * c - l * u) > To) || !s)
        this._append`L${this._x1 = t},${this._y1 = n}`;
      else {
        let d = i - o, p = r - a, y = c * c + l * l, g = d * d + p * p, m = Math.sqrt(y), b = Math.sqrt(h), w = s * Math.tan((Jg - Math.acos((y + h - g) / (2 * m * b))) / 2), v = w / b, _ = w / m;
        Math.abs(v - 1) > To && this._append`L${t + v * u},${n + v * f}`, this._append`A${s},${s},0,0,${+(f * d > u * p)},${this._x1 = t + _ * c},${this._y1 = n + _ * l}`;
      }
  }
  arc(t, n, i, r, s, o) {
    if (t = +t, n = +n, i = +i, o = !!o, i < 0)
      throw new Error(`negative radius: ${i}`);
    let a = i * Math.cos(r), c = i * Math.sin(r), l = t + a, u = n + c, f = 1 ^ o, h = o ? r - s : s - r;
    this._x1 === null ? this._append`M${l},${u}` : (Math.abs(this._x1 - l) > To || Math.abs(this._y1 - u) > To) && this._append`L${l},${u}`, i && (h < 0 && (h = h % Kg + Kg), h > jq ? this._append`A${i},${i},0,1,${f},${t - a},${n - c}A${i},${i},0,1,${f},${this._x1 = l},${this._y1 = u}` : h > To && this._append`A${i},${i},0,${+(h >= Jg)},${f},${this._x1 = t + i * Math.cos(s)},${this._y1 = n + i * Math.sin(s)}`);
  }
  rect(t, n, i, r) {
    this._append`M${this._x0 = this._x1 = +t},${this._y0 = this._y1 = +n}h${i = +i}v${+r}h${-i}Z`;
  }
  toString() {
    return this._;
  }
};
function Gr(e = 3) {
  return new Z3(+e);
}
var Yq = Array.prototype, Q3 = Yq.slice;
function Wq(e, t) {
  return e - t;
}
function Gq(e) {
  for (var t = 0, n = e.length, i = e[n - 1][1] * e[0][0] - e[n - 1][0] * e[0][1]; ++t < n; )
    i += e[t - 1][1] * e[t][0] - e[t - 1][0] * e[t][1];
  return i;
}
const Ms = (e) => () => e;
function Xq(e, t) {
  for (var n = -1, i = t.length, r; ++n < i; )
    if (r = Hq(e, t[n]))
      return r;
  return 0;
}
function Hq(e, t) {
  for (var n = t[0], i = t[1], r = -1, s = 0, o = e.length, a = o - 1; s < o; a = s++) {
    var c = e[s], l = c[0], u = c[1], f = e[a], h = f[0], d = f[1];
    if (Jq(c, f, t))
      return 0;
    u > i != d > i && n < (h - l) * (i - u) / (d - u) + l && (r = -r);
  }
  return r;
}
function Jq(e, t, n) {
  var i;
  return Kq(e, t, n) && Zq(e[i = +(e[0] === t[0])], n[i], t[i]);
}
function Kq(e, t, n) {
  return (t[0] - e[0]) * (n[1] - e[1]) === (n[0] - e[0]) * (t[1] - e[1]);
}
function Zq(e, t, n) {
  return e <= t && t <= n || n <= t && t <= e;
}
function Qq() {
}
var Ir = [
  [],
  [[[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 sp() {
  var e = 1, t = 1, n = qb, i = c;
  function r(l) {
    var u = n(l);
    if (Array.isArray(u))
      u = u.slice().sort(Wq);
    else {
      const f = ke(l, tY);
      for (u = qs(...l3(f[0], f[1], u), u); u[u.length - 1] >= f[1]; )
        u.pop();
      for (; u[1] < f[0]; )
        u.shift();
    }
    return u.map((f) => s(l, f));
  }
  function s(l, u) {
    const f = u == null ? NaN : +u;
    if (isNaN(f))
      throw new Error(`invalid value: ${u}`);
    var h = [], d = [];
    return o(l, f, function(p) {
      i(p, l, f), Gq(p) > 0 ? h.push([p]) : d.push(p);
    }), d.forEach(function(p) {
      for (var y = 0, g = h.length, m; y < g; ++y)
        if (Xq((m = h[y])[0], p) !== -1) {
          m.push(p);
          return;
        }
    }), {
      type: "MultiPolygon",
      value: u,
      coordinates: h
    };
  }
  function o(l, u, f) {
    var h = new Array(), d = new Array(), p, y, g, m, b, w;
    for (p = y = -1, m = mo(l[0], u), Ir[m << 1].forEach(v); ++p < e - 1; )
      g = m, m = mo(l[p + 1], u), Ir[g | m << 1].forEach(v);
    for (Ir[m << 0].forEach(v); ++y < t - 1; ) {
      for (p = -1, m = mo(l[y * e + e], u), b = mo(l[y * e], u), Ir[m << 1 | b << 2].forEach(v); ++p < e - 1; )
        g = m, m = mo(l[y * e + e + p + 1], u), w = b, b = mo(l[y * e + p + 1], u), Ir[g | m << 1 | b << 2 | w << 3].forEach(v);
      Ir[m | b << 3].forEach(v);
    }
    for (p = -1, b = l[y * e] >= u, Ir[b << 2].forEach(v); ++p < e - 1; )
      w = b, b = mo(l[y * e + p + 1], u), Ir[b << 2 | w << 3].forEach(v);
    Ir[b << 3].forEach(v);
    function v(_) {
      var x = [_[0][0] + p, _[0][1] + y], I = [_[1][0] + p, _[1][1] + y], N = a(x), A = a(I), D, M;
      (D = d[N]) ? (M = h[A]) ? (delete d[D.end], delete h[M.start], D === M ? (D.ring.push(I), f(D.ring)) : h[D.start] = d[M.end] = { start: D.start, end: M.end, ring: D.ring.concat(M.ring) }) : (delete d[D.end], D.ring.push(I), d[D.end = A] = D) : (D = h[A]) ? (M = d[N]) ? (delete h[D.start], delete d[M.end], D === M ? (D.ring.push(I), f(D.ring)) : h[M.start] = d[D.end] = { start: M.start, end: D.end, ring: M.ring.concat(D.ring) }) : (delete h[D.start], D.ring.unshift(x), h[D.start = N] = D) : h[N] = d[A] = { start: N, end: A, ring: [x, I] };
    }
  }
  function a(l) {
    return l[0] * 2 + l[1] * (e + 1) * 4;
  }
  function c(l, u, f) {
    l.forEach(function(h) {
      var d = h[0], p = h[1], y = d | 0, g = p | 0, m = bm(u[g * e + y]);
      d > 0 && d < e && y === d && (h[0] = L2(d, bm(u[g * e + y - 1]), m, f)), p > 0 && p < t && g === p && (h[1] = L2(p, bm(u[(g - 1) * e + y]), m, f));
    });
  }
  return r.contour = s, r.size = function(l) {
    if (!arguments.length)
      return [e, t];
    var u = Math.floor(l[0]), f = Math.floor(l[1]);
    if (!(u >= 0 && f >= 0))
      throw new Error("invalid size");
    return e = u, t = f, r;
  }, r.thresholds = function(l) {
    return arguments.length ? (n = typeof l == "function" ? l : Array.isArray(l) ? Ms(Q3.call(l)) : Ms(l), r) : n;
  }, r.smooth = function(l) {
    return arguments.length ? (i = l ? c : Qq, r) : i === c;
  }, r;
}
function tY(e) {
  return isFinite(e) ? e : NaN;
}
function mo(e, t) {
  return e == null ? !1 : +e >= t;
}
function bm(e) {
  return e == null || isNaN(e = +e) ? -1 / 0 : e;
}
function L2(e, t, n, i) {
  const r = i - t, s = n - t, o = isFinite(r) || isFinite(s) ? r / s : Math.sign(r) / Math.sign(s);
  return isNaN(o) ? e : e + o - 0.5;
}
function eY(e) {
  return e[0];
}
function nY(e) {
  return e[1];
}
function iY() {
  return 1;
}
function rY() {
  var e = eY, t = nY, n = iY, i = 960, r = 500, s = 20, o = 2, a = s * 3, c = i + a * 2 >> o, l = r + a * 2 >> o, u = Ms(20);
  function f(b) {
    var w = new Float32Array(c * l), v = Math.pow(2, -o), _ = -1;
    for (const R of b) {
      var x = (e(R, ++_, b) + a) * v, I = (t(R, _, b) + a) * v, N = +n(R, _, b);
      if (N && x >= 0 && x < c && I >= 0 && I < l) {
        var A = Math.floor(x), D = Math.floor(I), M = x - A - 0.5, B = I - D - 0.5;
        w[A + D * c] += (1 - M) * (1 - B) * N, w[A + 1 + D * c] += M * (1 - B) * N, w[A + 1 + (D + 1) * c] += M * B * N, w[A + (D + 1) * c] += (1 - M) * B * N;
      }
    }
    return i3({ data: w, width: c, height: l }, s * v), w;
  }
  function h(b) {
    var w = f(b), v = u(w), _ = Math.pow(2, 2 * o);
    return Array.isArray(v) || (v = qs(Number.MIN_VALUE, De(w) / _, v)), sp().size([c, l]).thresholds(v.map((x) => x * _))(w).map((x, I) => (x.value = +v[I], d(x)));
  }
  h.contours = function(b) {
    var w = f(b), v = sp().size([c, l]), _ = Math.pow(2, 2 * o), x = (I) => {
      I = +I;
      var N = d(v.contour(w, I * _));
      return N.value = I, N;
    };
    return Object.defineProperty(x, "max", { get: () => De(w) / _ }), x;
  };
  function d(b) {
    return b.coordinates.forEach(p), b;
  }
  function p(b) {
    b.forEach(y);
  }
  function y(b) {
    b.forEach(g);
  }
  function g(b) {
    b[0] = b[0] * Math.pow(2, o) - a, b[1] = b[1] * Math.pow(2, o) - a;
  }
  function m() {
    return a = s * 3, c = i + a * 2 >> o, l = r + a * 2 >> o, h;
  }
  return h.x = function(b) {
    return arguments.length ? (e = typeof b == "function" ? b : Ms(+b), h) : e;
  }, h.y = function(b) {
    return arguments.length ? (t = typeof b == "function" ? b : Ms(+b), h) : t;
  }, h.weight = function(b) {
    return arguments.length ? (n = typeof b == "function" ? b : Ms(+b), h) : n;
  }, h.size = function(b) {
    if (!arguments.length)
      return [i, r];
    var w = +b[0], v = +b[1];
    if (!(w >= 0 && v >= 0))
      throw new Error("invalid size");
    return i = w, r = v, m();
  }, 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), m();
  }, h.thresholds = function(b) {
    return arguments.length ? (u = typeof b == "function" ? b : Array.isArray(b) ? Ms(Q3.call(b)) : Ms(b), h) : u;
  }, 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, m();
  }, h;
}
const Kr = 11102230246251565e-32, Ze = 134217729, sY = (3 + 8 * Kr) * Kr;
function wm(e, t, n, i, r) {
  let s, o, a, c, l = t[0], u = i[0], f = 0, h = 0;
  u > l == u > -l ? (s = l, l = t[++f]) : (s = u, u = i[++h]);
  let d = 0;
  if (f < e && h < n)
    for (u > l == u > -l ? (o = l + s, a = s - (o - l), l = t[++f]) : (o = u + s, a = s - (o - u), u = i[++h]), s = o, a !== 0 && (r[d++] = a); f < e && h < n; )
      u > l == u > -l ? (o = s + l, c = o - s, a = s - (o - c) + (l - c), l = t[++f]) : (o = s + u, c = o - s, a = s - (o - c) + (u - c), u = i[++h]), s = o, a !== 0 && (r[d++] = a);
  for (; f < e; )
    o = s + l, c = o - s, a = s - (o - c) + (l - c), l = t[++f], s = o, a !== 0 && (r[d++] = a);
  for (; h < n; )
    o = s + u, c = o - s, a = s - (o - c) + (u - c), u = i[++h], s = o, a !== 0 && (r[d++] = a);
  return (s !== 0 || d === 0) && (r[d++] = s), d;
}
function oY(e, t) {
  let n = t[0];
  for (let i = 1; i < e; i++)
    n += t[i];
  return n;
}
function _f(e) {
  return new Float64Array(e);
}
const aY = (3 + 16 * Kr) * Kr, cY = (2 + 12 * Kr) * Kr, lY = (9 + 64 * Kr) * Kr * Kr, va = _f(4), R2 = _f(8), C2 = _f(12), k2 = _f(16), sn = _f(4);
function uY(e, t, n, i, r, s, o) {
  let a, c, l, u, f, h, d, p, y, g, m, b, w, v, _, x, I, N;
  const A = e - r, D = n - r, M = t - s, B = i - s;
  v = A * B, h = Ze * A, d = h - (h - A), p = A - d, h = Ze * B, y = h - (h - B), g = B - y, _ = p * g - (v - d * y - p * y - d * g), x = M * D, h = Ze * M, d = h - (h - M), p = M - d, h = Ze * D, y = h - (h - D), g = D - y, I = p * g - (x - d * y - p * y - d * g), m = _ - I, f = _ - m, va[0] = _ - (m + f) + (f - I), b = v + m, f = b - v, w = v - (b - f) + (m - f), m = w - x, f = w - m, va[1] = w - (m + f) + (f - x), N = b + m, f = N - b, va[2] = b - (N - f) + (m - f), va[3] = N;
  let R = oY(4, va), S = cY * o;
  if (R >= S || -R >= S || (f = e - A, a = e - (A + f) + (f - r), f = n - D, l = n - (D + f) + (f - r), f = t - M, c = t - (M + f) + (f - s), f = i - B, u = i - (B + f) + (f - s), a === 0 && c === 0 && l === 0 && u === 0) || (S = lY * o + sY * Math.abs(R), R += A * u + B * a - (M * l + D * c), R >= S || -R >= S))
    return R;
  v = a * B, h = Ze * a, d = h - (h - a), p = a - d, h = Ze * B, y = h - (h - B), g = B - y, _ = p * g - (v - d * y - p * y - d * g), x = c * D, h = Ze * c, d = h - (h - c), p = c - d, h = Ze * D, y = h - (h - D), g = D - y, I = p * g - (x - d * y - p * y - d * g), m = _ - I, f = _ - m, sn[0] = _ - (m + f) + (f - I), b = v + m, f = b - v, w = v - (b - f) + (m - f), m = w - x, f = w - m, sn[1] = w - (m + f) + (f - x), N = b + m, f = N - b, sn[2] = b - (N - f) + (m - f), sn[3] = N;
  const $ = wm(4, va, 4, sn, R2);
  v = A * u, h = Ze * A, d = h - (h - A), p = A - d, h = Ze * u, y = h - (h - u), g = u - y, _ = p * g - (v - d * y - p * y - d * g), x = M * l, h = Ze * M, d = h - (h - M), p = M - d, h = Ze * l, y = h - (h - l), g = l - y, I = p * g - (x - d * y - p * y - d * g), m = _ - I, f = _ - m, sn[0] = _ - (m + f) + (f - I), b = v + m, f = b - v, w = v - (b - f) + (m - f), m = w - x, f = w - m, sn[1] = w - (m + f) + (f - x), N = b + m, f = N - b, sn[2] = b - (N - f) + (m - f), sn[3] = N;
  const T = wm($, R2, 4, sn, C2);
  v = a * u, h = Ze * a, d = h - (h - a), p = a - d, h = Ze * u, y = h - (h - u), g = u - y, _ = p * g - (v - d * y - p * y - d * g), x = c * l, h = Ze * c, d = h - (h - c), p = c - d, h = Ze * l, y = h - (h - l), g = l - y, I = p * g - (x - d * y - p * y - d * g), m = _ - I, f = _ - m, sn[0] = _ - (m + f) + (f - I), b = v + m, f = b - v, w = v - (b - f) + (m - f), m = w - x, f = w - m, sn[1] = w - (m + f) + (f - x), N = b + m, f = N - b, sn[2] = b - (N - f) + (m - f), sn[3] = N;
  const L = wm(T, C2, 4, sn, k2);
  return k2[L - 1];
}
function hh(e, t, n, i, r, s) {
  const o = (t - s) * (n - r), a = (e - r) * (i - s), c = o - a, l = Math.abs(o + a);
  return Math.abs(c) >= aY * l ? c : -uY(e, t, n, i, r, s, l);
}
const U2 = Math.pow(2, -52), dh = new Uint32Array(512);
class op {
  static from(t, n = yY, i = mY) {
    const r = t.length, s = new Float64Array(r * 2);
    for (let o = 0; o < r; o++) {
      const a = t[o];
      s[2 * o] = n(a), s[2 * o + 1] = i(a);
    }
    return new op(s);
  }
  constructor(t) {
    const n = t.length >> 1;
    if (n > 0 && typeof t[0] != "number")
      throw new Error("Expected coords to contain numbers.");
    this.coords = t;
    const i = Math.max(2 * n - 5, 0);
    this._triangles = new Uint32Array(i * 3), this._halfedges = new Int32Array(i * 3), this._hashSize = Math.ceil(Math.sqrt(n)), this._hullPrev = new Uint32Array(n), this._hullNext = new Uint32Array(n), this._hullTri = new Uint32Array(n), this._hullHash = new Int32Array(this._hashSize), this._ids = new Uint32Array(n), this._dists = new Float64Array(n), this.update();
  }
  update() {
    const { coords: t, _hullPrev: n, _hullNext: i, _hullTri: r, _hullHash: s } = this, o = t.length >> 1;
    let a = 1 / 0, c = 1 / 0, l = -1 / 0, u = -1 / 0;
    for (let A = 0; A < o; A++) {
      const D = t[2 * A], M = t[2 * A + 1];
      D < a && (a = D), M < c && (c = M), D > l && (l = D), M > u && (u = M), this._ids[A] = A;
    }
    const f = (a + l) / 2, h = (c + u) / 2;
    let d, p, y;
    for (let A = 0, D = 1 / 0; A < o; A++) {
      const M = vm(f, h, t[2 * A], t[2 * A + 1]);
      M < D && (d = A, D = M);
    }
    const g = t[2 * d], m = t[2 * d + 1];
    for (let A = 0, D = 1 / 0; A < o; A++) {
      if (A === d)
        continue;
      const M = vm(g, m, t[2 * A], t[2 * A + 1]);
      M < D && M > 0 && (p = A, D = M);
    }
    let b = t[2 * p], w = t[2 * p + 1], v = 1 / 0;
    for (let A = 0; A < o; A++) {
      if (A === d || A === p)
        continue;
      const D = dY(g, m, b, w, t[2 * A], t[2 * A + 1]);
      D < v && (y = A, v = D);
    }
    let _ = t[2 * y], x = t[2 * y + 1];
    if (v === 1 / 0) {
      for (let M = 0; M < o; M++)
        this._dists[M] = t[2 * M] - t[0] || t[2 * M + 1] - t[1];
      Ka(this._ids, this._dists, 0, o - 1);
      const A = new Uint32Array(o);
      let D = 0;
      for (let M = 0, B = -1 / 0; M < o; M++) {
        const R = this._ids[M], S = this._dists[R];
        S > B && (A[D++] = R, B = S);
      }
      this.hull = A.subarray(0, D), this.triangles = new Uint32Array(0), this.halfedges = new Uint32Array(0);
      return;
    }
    if (hh(g, m, b, w, _, x) < 0) {
      const A = p, D = b, M = w;
      p = y, b = _, w = x, y = A, _ = D, x = M;
    }
    const I = pY(g, m, b, w, _, x);
    this._cx = I.x, this._cy = I.y;
    for (let A = 0; A < o; A++)
      this._dists[A] = vm(t[2 * A], t[2 * A + 1], I.x, I.y);
    Ka(this._ids, this._dists, 0, o - 1), this._hullStart = d;
    let N = 3;
    i[d] = n[y] = p, i[p] = n[d] = y, i[y] = n[p] = d, r[d] = 0, r[p] = 1, r[y] = 2, s.fill(-1), s[this._hashKey(g, m)] = d, s[this._hashKey(b, w)] = p, s[this._hashKey(_, x)] = y, this.trianglesLen = 0, this._addTriangle(d, p, y, -1, -1, -1);
    for (let A = 0, D, M; A < this._ids.length; A++) {
      const B = this._ids[A], R = t[2 * B], S = t[2 * B + 1];
      if (A > 0 && Math.abs(R - D) <= U2 && Math.abs(S - M) <= U2 || (D = R, M = S, B === d || B === p || B === y))
        continue;
      let $ = 0;
      for (let C = 0, z = this._hashKey(R, S); C < this._hashSize && ($ = s[(z + C) % this._hashSize], !($ !== -1 && $ !== i[$])); C++)
        ;
      $ = n[$];
      let T = $, L;
      for (; L = i[T], hh(R, S, t[2 * T], t[2 * T + 1], t[2 * L], t[2 * L + 1]) >= 0; )
        if (T = L, T === $) {
          T = -1;
          break;
        }
      if (T === -1)
        continue;
      let k = this._addTriangle(T, B, i[T], -1, -1, r[T]);
      r[B] = this._legalize(k + 2), r[T] = k, N++;
      let U = i[T];
      for (; L = i[U], hh(R, S, t[2 * U], t[2 * U + 1], t[2 * L], t[2 * L + 1]) < 0; )
        k = this._addTriangle(U, B, L, r[B], -1, r[U]), r[B] = this._legalize(k + 2), i[U] = U, N--, U = L;
      if (T === $)
        for (; L = n[T], hh(R, S, t[2 * L], t[2 * L + 1], t[2 * T], t[2 * T + 1]) < 0; )
          k = this._addTriangle(L, B, T, -1, r[T], r[L]), this._legalize(k + 2), r[L] = k, i[T] = T, N--, T = L;
      this._hullStart = n[B] = T, i[T] = n[U] = B, i[B] = U, s[this._hashKey(R, S)] = B, s[this._hashKey(t[2 * T], t[2 * T + 1])] = T;
    }
    this.hull = new Uint32Array(N);
    for (let A = 0, D = this._hullStart; A < N; A++)
      this.hull[A] = D, D = i[D];
    this.triangles = this._triangles.subarray(0, this.trianglesLen), this.halfedges = this._halfedges.subarray(0, this.trianglesLen);
  }
  _hashKey(t, n) {
    return Math.floor(fY(t - this._cx, n - this._cy) * this._hashSize) % this._hashSize;
  }
  _legalize(t) {
    const { _triangles: n, _halfedges: i, coords: r } = this;
    let s = 0, o = 0;
    for (; ; ) {
      const a = i[t], c = t - t % 3;
      if (o = c + (t + 2) % 3, a === -1) {
        if (s === 0)
          break;
        t = dh[--s];
        continue;
      }
      const l = a - a % 3, u = c + (t + 1) % 3, f = l + (a + 2) % 3, h = n[o], d = n[t], p = n[u], y = n[f];
      if (hY(
        r[2 * h],
        r[2 * h + 1],
        r[2 * d],
        r[2 * d + 1],
        r[2 * p],
        r[2 * p + 1],
        r[2 * y],
        r[2 * y + 1]
      )) {
        n[t] = y, n[a] = h;
        const m = i[f];
        if (m === -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, m), this._link(a, i[o]), this._link(o, f);
        const b = l + (a + 1) % 3;
        s < dh.length && (dh[s++] = b);
      } else {
        if (s === 0)
          break;
        t = dh[--s];
      }
    }
    return o;
  }
  _link(t, n) {
    this._halfedges[t] = n, n !== -1 && (this._halfedges[n] = t);
  }
  // add a new triangle given vertex indices and adjacent half-edge ids
  _addTriangle(t, n, i, r, s, o) {
    const a = this.trianglesLen;
    return this._triangles[a] = t, this._triangles[a + 1] = n, this._triangles[a + 2] = i, this._link(a, r), this._link(a + 1, s), this._link(a + 2, o), this.trianglesLen += 3, a;
  }
}
function fY(e, t) {
  const n = e / (Math.abs(e) + Math.abs(t));
  return (t > 0 ? 3 - n : 1 + n) / 4;
}
function vm(e, t, n, i) {
  const r = e - n, s = t - i;
  return r * r + s * s;
}
function hY(e, t, n, i, r, s, o, a) {
  const c = e - o, l = t - a, u = n - o, f = i - a, h = r - o, d = s - a, p = c * c + l * l, y = u * u + f * f, g = h * h + d * d;
  return c * (f * g - y * d) - l * (u * g - y * h) + p * (u * d - f * h) < 0;
}
function dY(e, t, n, i, r, s) {
  const o = n - e, a = i - t, c = r - e, l = s - t, u = o * o + a * a, f = c * c + l * l, h = 0.5 / (o * l - a * c), d = (l * u - a * f) * h, p = (o * f - c * u) * h;
  return d * d + p * p;
}
function pY(e, t, n, i, r, s) {
  const o = n - e, a = i - t, c = r - e, l = s - t, u = o * o + a * a, f = c * c + l * l, h = 0.5 / (o * l - a * c), d = e + (l * u - a * f) * h, p = t + (o * f - c * u) * h;
  return { x: d, y: p };
}
function Ka(e, t, n, i) {
  if (i - n <= 20)
    for (let r = n + 1; r <= i; r++) {
      const s = e[r], o = t[s];
      let a = r - 1;
      for (; a >= n && t[e[a]] > o; )
        e[a + 1] = e[a--];
      e[a + 1] = s;
    }
  else {
    const r = n + i >> 1;
    let s = n + 1, o = i;
    xl(e, r, s), t[e[n]] > t[e[i]] && xl(e, n, i), t[e[s]] > t[e[i]] && xl(e, s, i), t[e[n]] > t[e[s]] && xl(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;
      xl(e, s, o);
    }
    e[n + 1] = e[o], e[o] = a, i - s + 1 >= o - n ? (Ka(e, t, s, i), Ka(e, t, n, o - 1)) : (Ka(e, t, n, o - 1), Ka(e, t, s, i));
  }
}
function xl(e, t, n) {
  const i = e[t];
  e[t] = e[n], e[n] = i;
}
function yY(e) {
  return e[0];
}
function mY(e) {
  return e[1];
}
const z2 = 1e-6;
class Fo {
  constructor() {
    this._x0 = this._y0 = // start of current subpath
    this._x1 = this._y1 = null, this._ = "";
  }
  moveTo(t, n) {
    this._ += `M${this._x0 = this._x1 = +t},${this._y0 = this._y1 = +n}`;
  }
  closePath() {
    this._x1 !== null && (this._x1 = this._x0, this._y1 = this._y0, this._ += "Z");
  }
  lineTo(t, n) {
    this._ += `L${this._x1 = +t},${this._y1 = +n}`;
  }
  arc(t, n, i) {
    t = +t, n = +n, i = +i;
    const r = t + i, s = n;
    if (i < 0)
      throw new Error("negative radius");
    this._x1 === null ? this._ += `M${r},${s}` : (Math.abs(this._x1 - r) > z2 || Math.abs(this._y1 - s) > z2) && (this._ += "L" + r + "," + s), i && (this._ += `A${i},${i},0,1,1,${t - i},${n}A${i},${i},0,1,1,${this._x1 = r},${this._y1 = s}`);
  }
  rect(t, n, i, r) {
    this._ += `M${this._x0 = this._x1 = +t},${this._y0 = this._y1 = +n}h${+i}v${+r}h${-i}Z`;
  }
  value() {
    return this._ || null;
  }
}
class Zg {
  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 gY = class {
  constructor(t, [n, i, r, s] = [0, 0, 960, 500]) {
    if (!((r = +r) >= (n = +n)) || !((s = +s) >= (i = +i)))
      throw new Error("invalid bounds");
    this.delaunay = t, this._circumcenters = new Float64Array(t.points.length * 2), this.vectors = new Float64Array(t.points.length * 2), this.xmax = r, this.xmin = n, this.ymax = s, this.ymin = i, this._init();
  }
  update() {
    return this.delaunay.update(), this._init(), this;
  }
  _init() {
    const { delaunay: { points: t, hull: n, triangles: i }, vectors: r } = this;
    let s, o;
    const a = this.circumcenters = this._circumcenters.subarray(0, i.length / 3 * 2);
    for (let y = 0, g = 0, m = i.length, b, w; y < m; y += 3, g += 2) {
      const v = i[y] * 2, _ = i[y + 1] * 2, x = i[y + 2] * 2, I = t[v], N = t[v + 1], A = t[_], D = t[_ + 1], M = t[x], B = t[x + 1], R = A - I, S = D - N, $ = M - I, T = B - N, L = (R * T - S * $) * 2;
      if (Math.abs(L) < 1e-9) {
        if (s === void 0) {
          s = o = 0;
          for (const U of n)
            s += t[U * 2], o += t[U * 2 + 1];
          s /= n.length, o /= n.length;
        }
        const k = 1e9 * Math.sign((s - I) * T - (o - N) * $);
        b = (I + M) / 2 - k * T, w = (N + B) / 2 + k * $;
      } else {
        const k = 1 / L, U = R * R + S * S, C = $ * $ + T * T;
        b = I + (T * U - S * C) * k, w = N + (R * C - $ * U) * k;
      }
      a[g] = b, a[g + 1] = w;
    }
    let c = n[n.length - 1], l, u = c * 4, f, h = t[2 * c], d, p = t[2 * c + 1];
    r.fill(0);
    for (let y = 0; y < n.length; ++y)
      c = n[y], l = u, f = h, d = p, u = c * 4, h = t[2 * c], p = t[2 * c + 1], r[l + 2] = r[u] = d - p, r[l + 3] = r[u + 1] = h - f;
  }
  render(t) {
    const n = t == null ? t = new Fo() : void 0, { delaunay: { halfedges: i, inedges: r, hull: s }, circumcenters: o, vectors: a } = this;
    if (s.length <= 1)
      return null;
    for (let u = 0, f = i.length; u < f; ++u) {
      const h = i[u];
      if (h < u)
        continue;
      const d = Math.floor(u / 3) * 2, p = Math.floor(h / 3) * 2, y = o[d], g = o[d + 1], m = o[p], b = o[p + 1];
      this._renderSegment(y, g, m, b, t);
    }
    let c, l = s[s.length - 1];
    for (let u = 0; u < s.length; ++u) {
      c = l, l = s[u];
      const f = Math.floor(r[l] / 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 Fo() : void 0;
    return t.rect(this.xmin, this.ymin, this.xmax - this.xmin, this.ymax - this.ymin), n && n.value();
  }
  renderCell(t, n) {
    const i = n == null ? n = new Fo() : void 0, r = this._clip(t);
    if (r === null || !r.length)
      return;
    n.moveTo(r[0], r[1]);
    let s = r.length;
    for (; r[0] === r[s - 2] && r[1] === r[s - 1] && s > 1; )
      s -= 2;
    for (let o = 2; o < s; o += 2)
      (r[o] !== r[o - 2] || r[o + 1] !== r[o - 1]) && n.lineTo(r[o], r[o + 1]);
    return n.closePath(), i && i.value();
  }
  *cellPolygons() {
    const { delaunay: { points: t } } = this;
    for (let n = 0, i = t.length / 2; n < i; ++n) {
      const r = this.cellPolygon(n);
      r && (r.index = n, yield r);
    }
  }
  cellPolygon(t) {
    const n = new Zg();
    return this.renderCell(t, n), n.value();
  }
  _renderSegment(t, n, i, r, s) {
    let o;
    const a = this._regioncode(t, n), c = this._regioncode(i, r);
    a === 0 && c === 0 ? (s.moveTo(t, n), s.lineTo(i, r)) : (o = this._clipSegment(t, n, i, r, a, c)) && (s.moveTo(o[0], o[1]), s.lineTo(o[2], o[3]));
  }
  contains(t, n, i) {
    return n = +n, n !== n || (i = +i, i !== i) ? !1 : this.delaunay._step(t, n, i) === t;
  }
  *neighbors(t) {
    const n = this._clip(t);
    if (n)
      for (const i of this.delaunay.neighbors(t)) {
        const r = this._clip(i);
        if (r) {
          t:
            for (let s = 0, o = n.length; s < o; s += 2)
              for (let a = 0, c = r.length; a < c; a += 2)
                if (n[s] === r[a] && n[s + 1] === r[a + 1] && n[(s + 2) % o] === r[(a + c - 2) % c] && n[(s + 3) % o] === r[(a + c - 1) % c]) {
                  yield i;
                  break t;
                }
        }
      }
  }
  _cell(t) {
    const { circumcenters: n, delaunay: { inedges: i, halfedges: r, triangles: s } } = this, o = i[t];
    if (o === -1)
      return null;
    const a = [];
    let c = o;
    do {
      const l = Math.floor(c / 3);
      if (a.push(n[l * 2], n[l * 2 + 1]), c = c % 3 === 2 ? c - 2 : c + 1, s[c] !== t)
        break;
      c = r[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: i } = this, r = t * 4;
    return this._simplify(i[r] || i[r + 1] ? this._clipInfinite(t, n, i[r], i[r + 1], i[r + 2], i[r + 3]) : this._clipFinite(t, n));
  }
  _clipFinite(t, n) {
    const i = n.length;
    let r = null, s, o, a = n[i - 2], c = n[i - 1], l, u = this._regioncode(a, c), f, h = 0;
    for (let d = 0; d < i; d += 2)
      if (s = a, o = c, a = n[d], c = n[d + 1], l = u, u = this._regioncode(a, c), l === 0 && u === 0)
        f = h, h = 0, r ? r.push(a, c) : r = [a, c];
      else {
        let p, y, g, m, b;
        if (l === 0) {
          if ((p = this._clipSegment(s, o, a, c, l, u)) === null)
            continue;
          [y, g, m, b] = p;
        } else {
          if ((p = this._clipSegment(a, c, s, o, u, l)) === null)
            continue;
          [m, b, y, g] = p, f = h, h = this._edgecode(y, g), f && h && this._edge(t, f, h, r, r.length), r ? r.push(y, g) : r = [y, g];
        }
        f = h, h = this._edgecode(m, b), f && h && this._edge(t, f, h, r, r.length), r ? r.push(m, b) : r = [m, b];
      }
    if (r)
      f = h, h = this._edgecode(r[0], r[1]), f && h && this._edge(t, f, h, r, r.length);
    else if (this.contains(t, (this.xmin + this.xmax) / 2, (this.ymin + this.ymax) / 2))
      return [this.xmax, this.ymin, this.xmax, this.ymax, this.xmin, this.ymax, this.xmin, this.ymin];
    return r;
  }
  _clipSegment(t, n, i, r, s, o) {
    const a = s < o;
    for (a && ([t, n, i, r, s, o] = [i, r, t, n, o, s]); ; ) {
      if (s === 0 && o === 0)
        return a ? [i, r, t, n] : [t, n, i, r];
      if (s & o)
        return null;
      let c, l, u = s || o;
      u & 8 ? (c = t + (i - t) * (this.ymax - n) / (r - n), l = this.ymax) : u & 4 ? (c = t + (i - t) * (this.ymin - n) / (r - n), l = this.ymin) : u & 2 ? (l = n + (r - n) * (this.xmax - t) / (i - t), c = this.xmax) : (l = n + (r - n) * (this.xmin - t) / (i - t), c = this.xmin), s ? (t = c, n = l, s = this._regioncode(t, n)) : (i = c, r = l, o = this._regioncode(i, r));
    }
  }
  _clipInfinite(t, n, i, r, s, o) {
    let a = Array.from(n), c;
    if ((c = this._project(a[0], a[1], i, r)) && 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 l = 0, u = a.length, f, h = this._edgecode(a[u - 2], a[u - 1]); l < u; l += 2)
        f = h, h = this._edgecode(a[l], a[l + 1]), f && h && (l = this._edge(t, f, h, a, l), u = a.length);
    else
      this.contains(t, (this.xmin + this.xmax) / 2, (this.ymin + this.ymax) / 2) && (a = [this.xmin, this.ymin, this.xmax, this.ymin, this.xmax, this.ymax, this.xmin, this.ymax]);
    return a;
  }
  _edge(t, n, i, r, s) {
    for (; n !== i; ) {
      let o, a;
      switch (n) {
        case 5:
          n = 4;
          continue;
        case 4:
          n = 6, o = this.xmax, a = this.ymin;
          break;
        case 6:
          n = 2;
          continue;
        case 2:
          n = 10, o = this.xmax, a = this.ymax;
          break;
        case 10:
          n = 8;
          continue;
        case 8:
          n = 9, o = this.xmin, a = this.ymax;
          break;
        case 9:
          n = 1;
          continue;
        case 1:
          n = 5, o = this.xmin, a = this.ymin;
          break;
      }
      (r[s] !== o || r[s + 1] !== a) && this.contains(t, o, a) && (r.splice(s, 0, o, a), s += 2);
    }
    return s;
  }
  _project(t, n, i, r) {
    let s = 1 / 0, o, a, c;
    if (r < 0) {
      if (n <= this.ymin)
        return null;
      (o = (this.ymin - n) / r) < s && (c = this.ymin, a = t + (s = o) * i);
    } else if (r > 0) {
      if (n >= this.ymax)
        return null;
      (o = (this.ymax - n) / r) < s && (c = this.ymax, a = t + (s = o) * i);
    }
    if (i > 0) {
      if (t >= this.xmax)
        return null;
      (o = (this.xmax - t) / i) < s && (a = this.xmax, c = n + (s = o) * r);
    } else if (i < 0) {
      if (t <= this.xmin)
        return null;
      (o = (this.xmin - t) / i) < s && (a = this.xmin, c = n + (s = o) * r);
    }
    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 i = (n + 2) % t.length, r = (n + 4) % t.length;
        (t[n] === t[i] && t[i] === t[r] || t[n + 1] === t[i + 1] && t[i + 1] === t[r + 1]) && (t.splice(i, 2), n -= 2);
      }
      t.length || (t = null);
    }
    return t;
  }
};
const bY = 2 * Math.PI, _a = Math.pow;
function wY(e) {
  return e[0];
}
function vY(e) {
  return e[1];
}
function _Y(e) {
  const { triangles: t, coords: n } = e;
  for (let i = 0; i < t.length; i += 3) {
    const r = 2 * t[i], s = 2 * t[i + 1], o = 2 * t[i + 2];
    if ((n[o] - n[r]) * (n[s + 1] - n[r + 1]) - (n[s] - n[r]) * (n[o + 1] - n[r + 1]) > 1e-10)
      return !1;
  }
  return !0;
}
function xY(e, t, n) {
  return [e + Math.sin(e + t) * n, t + Math.cos(e - t) * n];
}
class Ci {
  static from(t, n = wY, i = vY, r) {
    return new Ci("length" in t ? SY(t, n, i, r) : Float64Array.from(IY(t, n, i, r)));
  }
  constructor(t) {
    this._delaunator = new op(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 && _Y(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], l = this.collinear[this.collinear.length - 1], u = [n[2 * c], n[2 * c + 1], n[2 * l], n[2 * l + 1]], f = 1e-8 * Math.hypot(u[3] - u[1], u[2] - u[0]);
      for (let h = 0, d = n.length / 2; h < d; ++h) {
        const p = xY(n[2 * h], n[2 * h + 1], f);
        n[2 * h] = p[0], n[2 * h + 1] = p[1];
      }
      this._delaunator = new op(n);
    } else
      delete this.collinear;
    const i = this.halfedges = this._delaunator.halfedges, r = this.hull = this._delaunator.hull, s = this.triangles = this._delaunator.triangles, o = this.inedges.fill(-1), a = this._hullIndex.fill(-1);
    for (let c = 0, l = i.length; c < l; ++c) {
      const u = s[c % 3 === 2 ? c - 2 : c + 1];
      (i[c] === -1 || o[u] === -1) && (o[u] = c);
    }
    for (let c = 0, l = r.length; c < l; ++c)
      a[r[c]] = c;
    r.length <= 2 && r.length > 0 && (this.triangles = new Int32Array(3).fill(-1), this.halfedges = new Int32Array(3).fill(-1), this.triangles[0] = r[0], o[r[0]] = 1, r.length === 2 && (o[r[1]] = 0, this.triangles[1] = r[1], this.triangles[2] = r[1]));
  }
  voronoi(t) {
    return new gY(this, t);
  }
  *neighbors(t) {
    const { inedges: n, hull: i, _hullIndex: r, halfedges: s, triangles: o, collinear: a } = this;
    if (a) {
      const f = a.indexOf(t);
      f > 0 && (yield a[f - 1]), f < a.length - 1 && (yield a[f + 1]);
      return;
    }
    const c = n[t];
    if (c === -1)
      return;
    let l = c, u = -1;
    do {
      if (yield u = o[l], l = l % 3 === 2 ? l - 2 : l + 1, o[l] !== t)
        return;
      if (l = s[l], l === -1) {
        const f = i[(r[t] + 1) % i.length];
        f !== u && (yield f);
        return;
      }
    } while (l !== c);
  }
  find(t, n, i = 0) {
    if (t = +t, t !== t || (n = +n, n !== n))
      return -1;
    const r = i;
    let s;
    for (; (s = this._step(i, t, n)) >= 0 && s !== i && s !== r; )
      i = s;
    return s;
  }
  _step(t, n, i) {
    const { inedges: r, hull: s, _hullIndex: o, halfedges: a, triangles: c, points: l } = this;
    if (r[t] === -1 || !l.length)
      return (t + 1) % (l.length >> 1);
    let u = t, f = _a(n - l[t * 2], 2) + _a(i - l[t * 2 + 1], 2);
    const h = r[t];
    let d = h;
    do {
      let p = c[d];
      const y = _a(n - l[p * 2], 2) + _a(i - l[p * 2 + 1], 2);
      if (y < f && (f = y, u = 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 && _a(n - l[d * 2], 2) + _a(i - l[d * 2 + 1], 2) < f)
          return d;
        break;
      }
    } while (d !== h);
    return u;
  }
  render(t) {
    const n = t == null ? t = new Fo() : void 0, { points: i, halfedges: r, triangles: s } = this;
    for (let o = 0, a = r.length; o < a; ++o) {
      const c = r[o];
      if (c < o)
        continue;
      const l = s[o] * 2, u = s[c] * 2;
      t.moveTo(i[l], i[l + 1]), t.lineTo(i[u], i[u + 1]);
    }
    return this.renderHull(t), n && n.value();
  }
  renderPoints(t, n) {
    n === void 0 && (!t || typeof t.moveTo != "function") && (n = t, t = null), n = n == null ? 2 : +n;
    const i = t == null ? t = new Fo() : void 0, { points: r } = this;
    for (let s = 0, o = r.length; s < o; s += 2) {
      const a = r[s], c = r[s + 1];
      t.moveTo(a + n, c), t.arc(a, c, n, 0, bY);
    }
    return i && i.value();
  }
  renderHull(t) {
    const n = t == null ? t = new Fo() : void 0, { hull: i, points: r } = this, s = i[0] * 2, o = i.length;
    t.moveTo(r[s], r[s + 1]);
    for (let a = 1; a < o; ++a) {
      const c = 2 * i[a];
      t.lineTo(r[c], r[c + 1]);
    }
    return t.closePath(), n && n.value();
  }
  hullPolygon() {
    const t = new Zg();
    return this.renderHull(t), t.value();
  }
  renderTriangle(t, n) {
    const i = n == null ? n = new Fo() : void 0, { points: r, triangles: s } = this, o = s[t *= 3] * 2, a = s[t + 1] * 2, c = s[t + 2] * 2;
    return n.moveTo(r[o], r[o + 1]), n.lineTo(r[a], r[a + 1]), n.lineTo(r[c], r[c + 1]), n.closePath(), i && i.value();
  }
  *trianglePolygons() {
    const { triangles: t } = this;
    for (let n = 0, i = t.length / 3; n < i; ++n)
      yield this.trianglePolygon(n);
  }
  trianglePolygon(t) {
    const n = new Zg();
    return this.renderTriangle(t, n), n.value();
  }
}
function SY(e, t, n, i) {
  const r = e.length, s = new Float64Array(r * 2);
  for (let o = 0; o < r; ++o) {
    const a = e[o];
    s[o * 2] = t.call(i, a, o, e), s[o * 2 + 1] = n.call(i, a, o, e);
  }
  return s;
}
function* IY(e, t, n, i) {
  let r = 0;
  for (const s of e)
    yield t.call(i, s, r, e), yield n.call(i, s, r, e), ++r;
}
function AY(e) {
  return Math.abs(e = Math.round(e)) >= 1e21 ? e.toLocaleString("en").replace(/,/g, "") : e.toString(10);
}
function ap(e, t) {
  if ((n = (e = t ? e.toExponential(t - 1) : e.toExponential()).indexOf("e")) < 0)
    return null;
  var n, i = e.slice(0, n);
  return [
    i.length > 1 ? i[0] + i.slice(2) : i,
    +e.slice(n + 1)
  ];
}
function Bc(e) {
  return e = ap(Math.abs(e)), e ? e[1] : NaN;
}
function MY(e, t) {
  return function(n, i) {
    for (var r = n.length, s = [], o = 0, a = e[0], c = 0; r > 0 && a > 0 && (c + a + 1 > i && (a = Math.max(1, i - c)), s.push(n.substring(r -= a, r + a)), !((c += a + 1) > i)); )
      a = e[o = (o + 1) % e.length];
    return s.reverse().join(t);
  };
}
function $Y(e) {
  return function(t) {
    return t.replace(/[0-9]/g, function(n) {
      return e[+n];
    });
  };
}
var TY = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
function Uu(e) {
  if (!(t = TY.exec(e)))
    throw new Error("invalid format: " + e);
  var t;
  return new rw({
    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]
  });
}
Uu.prototype = rw.prototype;
function rw(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 + "";
}
rw.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 DY(e) {
  t:
    for (var t = e.length, n = 1, i = -1, r; n < t; ++n)
      switch (e[n]) {
        case ".":
          i = r = n;
          break;
        case "0":
          i === 0 && (i = n), r = n;
          break;
        default:
          if (!+e[n])
            break t;
          i > 0 && (i = 0);
          break;
      }
  return i > 0 ? e.slice(0, i) + e.slice(r + 1) : e;
}
var t$;
function NY(e, t) {
  var n = ap(e, t);
  if (!n)
    return e + "";
  var i = n[0], r = n[1], s = r - (t$ = Math.max(-8, Math.min(8, Math.floor(r / 3))) * 3) + 1, o = i.length;
  return s === o ? i : s > o ? i + new Array(s - o + 1).join("0") : s > 0 ? i.slice(0, s) + "." + i.slice(s) : "0." + new Array(1 - s).join("0") + ap(e, Math.max(0, t + s - 1))[0];
}
function P2(e, t) {
  var n = ap(e, t);
  if (!n)
    return e + "";
  var i = n[0], r = n[1];
  return r < 0 ? "0." + new Array(-r).join("0") + i : i.length > r + 1 ? i.slice(0, r + 1) + "." + i.slice(r + 1) : i + new Array(r - i.length + 2).join("0");
}
const V2 = {
  "%": (e, t) => (e * 100).toFixed(t),
  b: (e) => Math.round(e).toString(2),
  c: (e) => e + "",
  d: AY,
  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) => P2(e * 100, t),
  r: P2,
  s: NY,
  X: (e) => Math.round(e).toString(16).toUpperCase(),
  x: (e) => Math.round(e).toString(16)
};
function j2(e) {
  return e;
}
var q2 = Array.prototype.map, Y2 = ["y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"];
function BY(e) {
  var t = e.grouping === void 0 || e.thousands === void 0 ? j2 : MY(q2.call(e.grouping, Number), e.thousands + ""), n = e.currency === void 0 ? "" : e.currency[0] + "", i = e.currency === void 0 ? "" : e.currency[1] + "", r = e.decimal === void 0 ? "." : e.decimal + "", s = e.numerals === void 0 ? j2 : $Y(q2.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 l(f) {
    f = Uu(f);
    var h = f.fill, d = f.align, p = f.sign, y = f.symbol, g = f.zero, m = f.width, b = f.comma, w = f.precision, v = f.trim, _ = f.type;
    _ === "n" ? (b = !0, _ = "g") : V2[_] || (w === void 0 && (w = 12), v = !0, _ = "g"), (g || h === "0" && d === "=") && (g = !0, h = "0", d = "=");
    var x = y === "$" ? n : y === "#" && /[boxX]/.test(_) ? "0" + _.toLowerCase() : "", I = y === "$" ? i : /[%p]/.test(_) ? o : "", N = V2[_], A = /[defgprs%]/.test(_);
    w = w === void 0 ? 6 : /[gprs]/.test(_) ? Math.max(1, Math.min(21, w)) : Math.max(0, Math.min(20, w));
    function D(M) {
      var B = x, R = I, S, $, T;
      if (_ === "c")
        R = N(M) + R, M = "";
      else {
        M = +M;
        var L = M < 0 || 1 / M < 0;
        if (M = isNaN(M) ? c : N(Math.abs(M), w), v && (M = DY(M)), L && +M == 0 && p !== "+" && (L = !1), B = (L ? p === "(" ? p : a : p === "-" || p === "(" ? "" : p) + B, R = (_ === "s" ? Y2[8 + t$ / 3] : "") + R + (L && p === "(" ? ")" : ""), A) {
          for (S = -1, $ = M.length; ++S < $; )
            if (T = M.charCodeAt(S), 48 > T || T > 57) {
              R = (T === 46 ? r + M.slice(S + 1) : M.slice(S)) + R, M = M.slice(0, S);
              break;
            }
        }
      }
      b && !g && (M = t(M, 1 / 0));
      var k = B.length + M.length + R.length, U = k < m ? new Array(m - k + 1).join(h) : "";
      switch (b && g && (M = t(U + M, U.length ? m - R.length : 1 / 0), U = ""), d) {
        case "<":
          M = B + M + R + U;
          break;
        case "=":
          M = B + U + M + R;
          break;
        case "^":
          M = U.slice(0, k = U.length >> 1) + B + M + R + U.slice(k);
          break;
        default:
          M = U + B + M + R;
          break;
      }
      return s(M);
    }
    return D.toString = function() {
      return f + "";
    }, D;
  }
  function u(f, h) {
    var d = l((f = Uu(f), f.type = "f", f)), p = Math.max(-8, Math.min(8, Math.floor(Bc(h) / 3))) * 3, y = Math.pow(10, -p), g = Y2[8 + p / 3];
    return function(m) {
      return d(y * m) + g;
    };
  }
  return {
    format: l,
    formatPrefix: u
  };
}
var ph, il, e$;
OY({
  thousands: ",",
  grouping: [3],
  currency: ["$", ""]
});
function OY(e) {
  return ph = BY(e), il = ph.format, e$ = ph.formatPrefix, ph;
}
function FY(e) {
  return Math.max(0, -Bc(Math.abs(e)));
}
function EY(e, t) {
  return Math.max(0, Math.max(-8, Math.min(8, Math.floor(Bc(t) / 3))) * 3 - Bc(Math.abs(e)));
}
function LY(e, t) {
  return e = Math.abs(e), t = Math.abs(t) - e, Math.max(0, Bc(t) - Bc(e)) + 1;
}
var wt = 1e-6, cp = 1e-12, kt = Math.PI, $e = kt / 2, W2 = kt / 4, Vn = kt * 2, Xe = 180 / kt, Xt = kt / 180, Jt = Math.abs, rl = Math.atan, Ti = Math.atan2, $t = Math.cos, yh = Math.ceil, n$ = Math.exp, Qg = Math.hypot, lp = Math.log, _m = Math.pow, ot = Math.sin, ii = Math.sign || function(e) {
  return e > 0 ? 1 : e < 0 ? -1 : 0;
}, yn = Math.sqrt, sw = Math.tan;
function i$(e) {
  return e > 1 ? 0 : e < -1 ? kt : Math.acos(e);
}
function Dn(e) {
  return e > 1 ? $e : e < -1 ? -$e : Math.asin(e);
}
function kn() {
}
function up(e, t) {
  e && X2.hasOwnProperty(e.type) && X2[e.type](e, t);
}
var G2 = {
  Feature: function(e, t) {
    up(e.geometry, t);
  },
  FeatureCollection: function(e, t) {
    for (var n = e.features, i = -1, r = n.length; ++i < r; )
      up(n[i].geometry, t);
  }
}, X2 = {
  Sphere: function(e, t) {
    t.sphere();
  },
  Point: function(e, t) {
    e = e.coordinates, t.point(e[0], e[1], e[2]);
  },
  MultiPoint: function(e, t) {
    for (var n = e.coordinates, i = -1, r = n.length; ++i < r; )
      e = n[i], t.point(e[0], e[1], e[2]);
  },
  LineString: function(e, t) {
    t1(e.coordinates, t, 0);
  },
  MultiLineString: function(e, t) {
    for (var n = e.coordinates, i = -1, r = n.length; ++i < r; )
      t1(n[i], t, 0);
  },
  Polygon: function(e, t) {
    H2(e.coordinates, t);
  },
  MultiPolygon: function(e, t) {
    for (var n = e.coordinates, i = -1, r = n.length; ++i < r; )
      H2(n[i], t);
  },
  GeometryCollection: function(e, t) {
    for (var n = e.geometries, i = -1, r = n.length; ++i < r; )
      up(n[i], t);
  }
};
function t1(e, t, n) {
  var i = -1, r = e.length - n, s;
  for (t.lineStart(); ++i < r; )
    s = e[i], t.point(s[0], s[1], s[2]);
  t.lineEnd();
}
function H2(e, t) {
  var n = -1, i = e.length;
  for (t.polygonStart(); ++n < i; )
    t1(e[n], t, 1);
  t.polygonEnd();
}
function Ds(e, t) {
  e && G2.hasOwnProperty(e.type) ? G2[e.type](e, t) : up(e, t);
}
function e1(e) {
  return [Ti(e[1], e[0]), Dn(e[2])];
}
function Oc(e) {
  var t = e[0], n = e[1], i = $t(n);
  return [i * $t(t), i * ot(t), ot(n)];
}
function mh(e, t) {
  return e[0] * t[0] + e[1] * t[1] + e[2] * t[2];
}
function fp(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 xm(e, t) {
  e[0] += t[0], e[1] += t[1], e[2] += t[2];
}
function gh(e, t) {
  return [e[0] * t, e[1] * t, e[2] * t];
}
function n1(e) {
  var t = yn(e[0] * e[0] + e[1] * e[1] + e[2] * e[2]);
  e[0] /= t, e[1] /= t, e[2] /= t;
}
var Gl, hp, dp, pp, yp, mp, gp, bp, i1, r1, s1, r$, s$, cn, ln, un, _i = {
  sphere: kn,
  point: ow,
  lineStart: J2,
  lineEnd: K2,
  polygonStart: function() {
    _i.lineStart = kY, _i.lineEnd = UY;
  },
  polygonEnd: function() {
    _i.lineStart = J2, _i.lineEnd = K2;
  }
};
function ow(e, t) {
  e *= Xt, t *= Xt;
  var n = $t(t);
  xf(n * $t(e), n * ot(e), ot(t));
}
function xf(e, t, n) {
  ++Gl, dp += (e - dp) / Gl, pp += (t - pp) / Gl, yp += (n - yp) / Gl;
}
function J2() {
  _i.point = RY;
}
function RY(e, t) {
  e *= Xt, t *= Xt;
  var n = $t(t);
  cn = n * $t(e), ln = n * ot(e), un = ot(t), _i.point = CY, xf(cn, ln, un);
}
function CY(e, t) {
  e *= Xt, t *= Xt;
  var n = $t(t), i = n * $t(e), r = n * ot(e), s = ot(t), o = Ti(yn((o = ln * s - un * r) * o + (o = un * i - cn * s) * o + (o = cn * r - ln * i) * o), cn * i + ln * r + un * s);
  hp += o, mp += o * (cn + (cn = i)), gp += o * (ln + (ln = r)), bp += o * (un + (un = s)), xf(cn, ln, un);
}
function K2() {
  _i.point = ow;
}
function kY() {
  _i.point = zY;
}
function UY() {
  o$(r$, s$), _i.point = ow;
}
function zY(e, t) {
  r$ = e, s$ = t, e *= Xt, t *= Xt, _i.point = o$;
  var n = $t(t);
  cn = n * $t(e), ln = n * ot(e), un = ot(t), xf(cn, ln, un);
}
function o$(e, t) {
  e *= Xt, t *= Xt;
  var n = $t(t), i = n * $t(e), r = n * ot(e), s = ot(t), o = ln * s - un * r, a = un * i - cn * s, c = cn * r - ln * i, l = Qg(o, a, c), u = Dn(l), f = l && -u / l;
  i1.add(f * o), r1.add(f * a), s1.add(f * c), hp += u, mp += u * (cn + (cn = i)), gp += u * (ln + (ln = r)), bp += u * (un + (un = s)), xf(cn, ln, un);
}
function PY(e) {
  Gl = hp = dp = pp = yp = mp = gp = bp = 0, i1 = new sr(), r1 = new sr(), s1 = new sr(), Ds(e, _i);
  var t = +i1, n = +r1, i = +s1, r = Qg(t, n, i);
  return r < cp && (t = mp, n = gp, i = bp, hp < wt && (t = dp, n = pp, i = yp), r = Qg(t, n, i), r < cp) ? [NaN, NaN] : [Ti(n, t) * Xe, Dn(i / r) * Xe];
}
function o1(e, t) {
  function n(i, r) {
    return i = e(i, r), t(i[0], i[1]);
  }
  return e.invert && t.invert && (n.invert = function(i, r) {
    return i = t.invert(i, r), i && e.invert(i[0], i[1]);
  }), n;
}
function a1(e, t) {
  return Jt(e) > kt && (e -= Math.round(e / Vn) * Vn), [e, t];
}
a1.invert = a1;
function a$(e, t, n) {
  return (e %= Vn) ? t || n ? o1(Q2(e), tx(t, n)) : Q2(e) : t || n ? tx(t, n) : a1;
}
function Z2(e) {
  return function(t, n) {
    return t += e, Jt(t) > kt && (t -= Math.round(t / Vn) * Vn), [t, n];
  };
}
function Q2(e) {
  var t = Z2(e);
  return t.invert = Z2(-e), t;
}
function tx(e, t) {
  var n = $t(e), i = ot(e), r = $t(t), s = ot(t);
  function o(a, c) {
    var l = $t(c), u = $t(a) * l, f = ot(a) * l, h = ot(c), d = h * n + u * i;
    return [
      Ti(f * r - d * s, u * n - h * i),
      Dn(d * r + f * s)
    ];
  }
  return o.invert = function(a, c) {
    var l = $t(c), u = $t(a) * l, f = ot(a) * l, h = ot(c), d = h * r - f * s;
    return [
      Ti(f * r + h * s, u * n + d * i),
      Dn(d * n - u * i)
    ];
  }, o;
}
function VY(e) {
  e = a$(e[0] * Xt, e[1] * Xt, e.length > 2 ? e[2] * Xt : 0);
  function t(n) {
    return n = e(n[0] * Xt, n[1] * Xt), n[0] *= Xe, n[1] *= Xe, n;
  }
  return t.invert = function(n) {
    return n = e.invert(n[0] * Xt, n[1] * Xt), n[0] *= Xe, n[1] *= Xe, n;
  }, t;
}
function jY(e, t, n, i, r, s) {
  if (n) {
    var o = $t(t), a = ot(t), c = i * n;
    r == null ? (r = t + i * Vn, s = t - c / 2) : (r = ex(o, r), s = ex(o, s), (i > 0 ? r < s : r > s) && (r += i * Vn));
    for (var l, u = r; i > 0 ? u > s : u < s; u -= c)
      l = e1([o, -a * $t(u), -a * ot(u)]), e.point(l[0], l[1]);
  }
}
function ex(e, t) {
  t = Oc(t), t[0] -= e, n1(t);
  var n = i$(-t[1]);
  return ((-t[2] < 0 ? -n : n) + Vn - wt) % Vn;
}
function c$() {
  var e = [], t;
  return {
    point: function(n, i, r) {
      t.push([n, i, r]);
    },
    lineStart: function() {
      e.push(t = []);
    },
    lineEnd: kn,
    rejoin: function() {
      e.length > 1 && e.push(e.pop().concat(e.shift()));
    },
    result: function() {
      var n = e;
      return e = [], t = null, n;
    }
  };
}
function od(e, t) {
  return Jt(e[0] - t[0]) < wt && Jt(e[1] - t[1]) < wt;
}
function bh(e, t, n, i) {
  this.x = e, this.z = t, this.o = n, this.e = i, this.v = !1, this.n = this.p = null;
}
function l$(e, t, n, i, r) {
  var s = [], o = [], a, c;
  if (e.forEach(function(p) {
    if (!((y = p.length - 1) <= 0)) {
      var y, g = p[0], m = p[y], b;
      if (od(g, m)) {
        if (!g[2] && !m[2]) {
          for (r.lineStart(), a = 0; a < y; ++a)
            r.point((g = p[a])[0], g[1]);
          r.lineEnd();
          return;
        }
        m[0] += 2 * wt;
      }
      s.push(b = new bh(g, p, null, !0)), o.push(b.o = new bh(g, null, b, !1)), s.push(b = new bh(m, p, null, !1)), o.push(b.o = new bh(m, null, b, !0));
    }
  }), !!s.length) {
    for (o.sort(t), nx(s), nx(o), a = 0, c = o.length; a < c; ++a)
      o[a].e = n = !n;
    for (var l = s[0], u, f; ; ) {
      for (var h = l, d = !0; h.v; )
        if ((h = h.n) === l)
          return;
      u = h.z, r.lineStart();
      do {
        if (h.v = h.o.v = !0, h.e) {
          if (d)
            for (a = 0, c = u.length; a < c; ++a)
              r.point((f = u[a])[0], f[1]);
          else
            i(h.x, h.n.x, 1, r);
          h = h.n;
        } else {
          if (d)
            for (u = h.p.z, a = u.length - 1; a >= 0; --a)
              r.point((f = u[a])[0], f[1]);
          else
            i(h.x, h.p.x, -1, r);
          h = h.p;
        }
        h = h.o, u = h.z, d = !d;
      } while (!h.v);
      r.lineEnd();
    }
  }
}
function nx(e) {
  if (t = e.length) {
    for (var t, n = 0, i = e[0], r; ++n < t; )
      i.n = r = e[n], r.p = i, i = r;
    i.n = r = e[0], r.p = i;
  }
}
function Sm(e) {
  return Jt(e[0]) <= kt ? e[0] : ii(e[0]) * ((Jt(e[0]) + kt) % Vn - kt);
}
function qY(e, t) {
  var n = Sm(t), i = t[1], r = ot(i), s = [ot(n), -$t(n), 0], o = 0, a = 0, c = new sr();
  r === 1 ? i = $e + wt : r === -1 && (i = -$e - wt);
  for (var l = 0, u = e.length; l < u; ++l)
    if (h = (f = e[l]).length)
      for (var f, h, d = f[h - 1], p = Sm(d), y = d[1] / 2 + W2, g = ot(y), m = $t(y), b = 0; b < h; ++b, p = v, g = x, m = I, d = w) {
        var w = f[b], v = Sm(w), _ = w[1] / 2 + W2, x = ot(_), I = $t(_), N = v - p, A = N >= 0 ? 1 : -1, D = A * N, M = D > kt, B = g * x;
        if (c.add(Ti(B * A * ot(D), m * I + B * $t(D))), o += M ? N + A * Vn : N, M ^ p >= n ^ v >= n) {
          var R = fp(Oc(d), Oc(w));
          n1(R);
          var S = fp(s, R);
          n1(S);
          var $ = (M ^ N >= 0 ? -1 : 1) * Dn(S[2]);
          (i > $ || i === $ && (R[0] || R[1])) && (a += M ^ N >= 0 ? 1 : -1);
        }
      }
  return (o < -wt || o < wt && c < -cp) ^ a & 1;
}
function u$(e, t, n, i) {
  return function(r) {
    var s = t(r), o = c$(), a = t(o), c = !1, l, u, f, h = {
      point: d,
      lineStart: y,
      lineEnd: g,
      polygonStart: function() {
        h.point = m, h.lineStart = b, h.lineEnd = w, u = [], l = [];
      },
      polygonEnd: function() {
        h.point = d, h.lineStart = y, h.lineEnd = g, u = h3(u);
        var v = qY(l, i);
        u.length ? (c || (r.polygonStart(), c = !0), l$(u, WY, v, n, r)) : v && (c || (r.polygonStart(), c = !0), r.lineStart(), n(null, null, 1, r), r.lineEnd()), c && (r.polygonEnd(), c = !1), u = l = null;
      },
      sphere: function() {
        r.polygonStart(), r.lineStart(), n(null, null, 1, r), r.lineEnd(), r.polygonEnd();
      }
    };
    function d(v, _) {
      e(v, _) && r.point(v, _);
    }
    function p(v, _) {
      s.point(v, _);
    }
    function y() {
      h.point = p, s.lineStart();
    }
    function g() {
      h.point = d, s.lineEnd();
    }
    function m(v, _) {
      f.push([v, _]), a.point(v, _);
    }
    function b() {
      a.lineStart(), f = [];
    }
    function w() {
      m(f[0][0], f[0][1]), a.lineEnd();
      var v = a.clean(), _ = o.result(), x, I = _.length, N, A, D;
      if (f.pop(), l.push(f), f = null, !!I) {
        if (v & 1) {
          if (A = _[0], (N = A.length - 1) > 0) {
            for (c || (r.polygonStart(), c = !0), r.lineStart(), x = 0; x < N; ++x)
              r.point((D = A[x])[0], D[1]);
            r.lineEnd();
          }
          return;
        }
        I > 1 && v & 2 && _.push(_.pop().concat(_.shift())), u.push(_.filter(YY));
      }
    }
    return h;
  };
}
function YY(e) {
  return e.length > 1;
}
function WY(e, t) {
  return ((e = e.x)[0] < 0 ? e[1] - $e - wt : $e - e[1]) - ((t = t.x)[0] < 0 ? t[1] - $e - wt : $e - t[1]);
}
const ix = u$(
  function() {
    return !0;
  },
  GY,
  HY,
  [-kt, -$e]
);
function GY(e) {
  var t = NaN, n = NaN, i = NaN, r;
  return {
    lineStart: function() {
      e.lineStart(), r = 1;
    },
    point: function(s, o) {
      var a = s > 0 ? kt : -kt, c = Jt(s - t);
      Jt(c - kt) < wt ? (e.point(t, n = (n + o) / 2 > 0 ? $e : -$e), e.point(i, n), e.lineEnd(), e.lineStart(), e.point(a, n), e.point(s, n), r = 0) : i !== a && c >= kt && (Jt(t - i) < wt && (t -= i * wt), Jt(s - a) < wt && (s -= a * wt), n = XY(t, n, s, o), e.point(i, n), e.lineEnd(), e.lineStart(), e.point(a, n), r = 0), e.point(t = s, n = o), i = a;
    },
    lineEnd: function() {
      e.lineEnd(), t = n = NaN;
    },
    clean: function() {
      return 2 - r;
    }
  };
}
function XY(e, t, n, i) {
  var r, s, o = ot(e - n);
  return Jt(o) > wt ? rl((ot(t) * (s = $t(i)) * ot(n) - ot(i) * (r = $t(t)) * ot(e)) / (r * s * o)) : (t + i) / 2;
}
function HY(e, t, n, i) {
  var r;
  if (e == null)
    r = n * $e, i.point(-kt, r), i.point(0, r), i.point(kt, r), i.point(kt, 0), i.point(kt, -r), i.point(0, -r), i.point(-kt, -r), i.point(-kt, 0), i.point(-kt, r);
  else if (Jt(e[0] - t[0]) > wt) {
    var s = e[0] < t[0] ? kt : -kt;
    r = n * s / 2, i.point(-s, r), i.point(0, r), i.point(s, r);
  } else
    i.point(t[0], t[1]);
}
function JY(e) {
  var t = $t(e), n = 6 * Xt, i = t > 0, r = Jt(t) > wt;
  function s(u, f, h, d) {
    jY(d, e, n, h, u, f);
  }
  function o(u, f) {
    return $t(u) * $t(f) > t;
  }
  function a(u) {
    var f, h, d, p, y;
    return {
      lineStart: function() {
        p = d = !1, y = 1;
      },
      point: function(g, m) {
        var b = [g, m], w, v = o(g, m), _ = i ? v ? 0 : l(g, m) : v ? l(g + (g < 0 ? kt : -kt), m) : 0;
        if (!f && (p = d = v) && u.lineStart(), v !== d && (w = c(f, b), (!w || od(f, w) || od(b, w)) && (b[2] = 1)), v !== d)
          y = 0, v ? (u.lineStart(), w = c(b, f), u.point(w[0], w[1])) : (w = c(f, b), u.point(w[0], w[1], 2), u.lineEnd()), f = w;
        else if (r && f && i ^ v) {
          var x;
          !(_ & h) && (x = c(b, f, !0)) && (y = 0, i ? (u.lineStart(), u.point(x[0][0], x[0][1]), u.point(x[1][0], x[1][1]), u.lineEnd()) : (u.point(x[1][0], x[1][1]), u.lineEnd(), u.lineStart(), u.point(x[0][0], x[0][1], 3)));
        }
        v && (!f || !od(f, b)) && u.point(b[0], b[1]), f = b, d = v, h = _;
      },
      lineEnd: function() {
        d && u.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(u, f, h) {
    var d = Oc(u), p = Oc(f), y = [1, 0, 0], g = fp(d, p), m = mh(g, g), b = g[0], w = m - b * b;
    if (!w)
      return !h && u;
    var v = t * m / w, _ = -t * b / w, x = fp(y, g), I = gh(y, v), N = gh(g, _);
    xm(I, N);
    var A = x, D = mh(I, A), M = mh(A, A), B = D * D - M * (mh(I, I) - 1);
    if (!(B < 0)) {
      var R = yn(B), S = gh(A, (-D - R) / M);
      if (xm(S, I), S = e1(S), !h)
        return S;
      var $ = u[0], T = f[0], L = u[1], k = f[1], U;
      T < $ && (U = $, $ = T, T = U);
      var C = T - $, z = Jt(C - kt) < wt, P = z || C < wt;
      if (!z && k < L && (U = L, L = k, k = U), P ? z ? L + k > 0 ^ S[1] < (Jt(S[0] - $) < wt ? L : k) : L <= S[1] && S[1] <= k : C > kt ^ ($ <= S[0] && S[0] <= T)) {
        var G = gh(A, (-D + R) / M);
        return xm(G, I), [S, e1(G)];
      }
    }
  }
  function l(u, f) {
    var h = i ? e : kt - e, d = 0;
    return u < -h ? d |= 1 : u > h && (d |= 2), f < -h ? d |= 4 : f > h && (d |= 8), d;
  }
  return u$(o, a, s, i ? [0, -e] : [-kt, e - kt]);
}
function KY(e, t, n, i, r, s) {
  var o = e[0], a = e[1], c = t[0], l = t[1], u = 0, f = 1, h = c - o, d = l - a, p;
  if (p = n - o, !(!h && p > 0)) {
    if (p /= h, h < 0) {
      if (p < u)
        return;
      p < f && (f = p);
    } else if (h > 0) {
      if (p > f)
        return;
      p > u && (u = p);
    }
    if (p = r - o, !(!h && p < 0)) {
      if (p /= h, h < 0) {
        if (p > f)
          return;
        p > u && (u = p);
      } else if (h > 0) {
        if (p < u)
          return;
        p < f && (f = p);
      }
      if (p = i - a, !(!d && p > 0)) {
        if (p /= d, d < 0) {
          if (p < u)
            return;
          p < f && (f = p);
        } else if (d > 0) {
          if (p > f)
            return;
          p > u && (u = p);
        }
        if (p = s - a, !(!d && p < 0)) {
          if (p /= d, d < 0) {
            if (p > f)
              return;
            p > u && (u = p);
          } else if (d > 0) {
            if (p < u)
              return;
            p < f && (f = p);
          }
          return u > 0 && (e[0] = o + u * h, e[1] = a + u * d), f < 1 && (t[0] = o + f * h, t[1] = a + f * d), !0;
        }
      }
    }
  }
}
var Xl = 1e9, wh = -Xl;
function f$(e, t, n, i) {
  function r(l, u) {
    return e <= l && l <= n && t <= u && u <= i;
  }
  function s(l, u, f, h) {
    var d = 0, p = 0;
    if (l == null || (d = o(l, f)) !== (p = o(u, f)) || c(l, u) < 0 ^ f > 0)
      do
        h.point(d === 0 || d === 3 ? e : n, d > 1 ? i : t);
      while ((d = (d + f + 4) % 4) !== p);
    else
      h.point(u[0], u[1]);
  }
  function o(l, u) {
    return Jt(l[0] - e) < wt ? u > 0 ? 0 : 3 : Jt(l[0] - n) < wt ? u > 0 ? 2 : 1 : Jt(l[1] - t) < wt ? u > 0 ? 1 : 0 : u > 0 ? 3 : 2;
  }
  function a(l, u) {
    return c(l.x, u.x);
  }
  function c(l, u) {
    var f = o(l, 1), h = o(u, 1);
    return f !== h ? f - h : f === 0 ? u[1] - l[1] : f === 1 ? l[0] - u[0] : f === 2 ? l[1] - u[1] : u[0] - l[0];
  }
  return function(l) {
    var u = l, f = c$(), h, d, p, y, g, m, b, w, v, _, x, I = {
      point: N,
      lineStart: B,
      lineEnd: R,
      polygonStart: D,
      polygonEnd: M
    };
    function N($, T) {
      r($, T) && u.point($, T);
    }
    function A() {
      for (var $ = 0, T = 0, L = d.length; T < L; ++T)
        for (var k = d[T], U = 1, C = k.length, z = k[0], P, G, K = z[0], tt = z[1]; U < C; ++U)
          P = K, G = tt, z = k[U], K = z[0], tt = z[1], G <= i ? tt > i && (K - P) * (i - G) > (tt - G) * (e - P) && ++$ : tt <= i && (K - P) * (i - G) < (tt - G) * (e - P) && --$;
      return $;
    }
    function D() {
      u = f, h = [], d = [], x = !0;
    }
    function M() {
      var $ = A(), T = x && $, L = (h = h3(h)).length;
      (T || L) && (l.polygonStart(), T && (l.lineStart(), s(null, null, 1, l), l.lineEnd()), L && l$(h, a, $, s, l), l.polygonEnd()), u = l, h = d = p = null;
    }
    function B() {
      I.point = S, d && d.push(p = []), _ = !0, v = !1, b = w = NaN;
    }
    function R() {
      h && (S(y, g), m && v && f.rejoin(), h.push(f.result())), I.point = N, v && u.lineEnd();
    }
    function S($, T) {
      var L = r($, T);
      if (d && p.push([$, T]), _)
        y = $, g = T, m = L, _ = !1, L && (u.lineStart(), u.point($, T));
      else if (L && v)
        u.point($, T);
      else {
        var k = [b = Math.max(wh, Math.min(Xl, b)), w = Math.max(wh, Math.min(Xl, w))], U = [$ = Math.max(wh, Math.min(Xl, $)), T = Math.max(wh, Math.min(Xl, T))];
        KY(k, U, e, t, n, i) ? (v || (u.lineStart(), u.point(k[0], k[1])), u.point(U[0], U[1]), L || u.lineEnd(), x = !1) : L && (u.lineStart(), u.point($, T), x = !1);
      }
      b = $, w = T, v = L;
    }
    return I;
  };
}
function rx(e, t, n) {
  var i = Cn(e, t - wt, n).concat(t);
  return function(r) {
    return i.map(function(s) {
      return [r, s];
    });
  };
}
function sx(e, t, n) {
  var i = Cn(e, t - wt, n).concat(t);
  return function(r) {
    return i.map(function(s) {
      return [s, r];
    });
  };
}
function ZY() {
  var e, t, n, i, r, s, o, a, c = 10, l = c, u = 90, f = 360, h, d, p, y, g = 2.5;
  function m() {
    return { type: "MultiLineString", coordinates: b() };
  }
  function b() {
    return Cn(yh(i / u) * u, n, u).map(p).concat(Cn(yh(a / f) * f, o, f).map(y)).concat(Cn(yh(t / c) * c, e, c).filter(function(w) {
      return Jt(w % u) > wt;
    }).map(h)).concat(Cn(yh(s / l) * l, r, l).filter(function(w) {
      return Jt(w % f) > wt;
    }).map(d));
  }
  return m.lines = function() {
    return b().map(function(w) {
      return { type: "LineString", coordinates: w };
    });
  }, m.outline = function() {
    return {
      type: "Polygon",
      coordinates: [
        p(i).concat(
          y(o).slice(1),
          p(n).reverse().slice(1),
          y(a).reverse().slice(1)
        )
      ]
    };
  }, m.extent = function(w) {
    return arguments.length ? m.extentMajor(w).extentMinor(w) : m.extentMinor();
  }, m.extentMajor = function(w) {
    return arguments.length ? (i = +w[0][0], n = +w[1][0], a = +w[0][1], o = +w[1][1], i > n && (w = i, i = n, n = w), a > o && (w = a, a = o, o = w), m.precision(g)) : [[i, a], [n, o]];
  }, m.extentMinor = function(w) {
    return arguments.length ? (t = +w[0][0], e = +w[1][0], s = +w[0][1], r = +w[1][1], t > e && (w = t, t = e, e = w), s > r && (w = s, s = r, r = w), m.precision(g)) : [[t, s], [e, r]];
  }, m.step = function(w) {
    return arguments.length ? m.stepMajor(w).stepMinor(w) : m.stepMinor();
  }, m.stepMajor = function(w) {
    return arguments.length ? (u = +w[0], f = +w[1], m) : [u, f];
  }, m.stepMinor = function(w) {
    return arguments.length ? (c = +w[0], l = +w[1], m) : [c, l];
  }, m.precision = function(w) {
    return arguments.length ? (g = +w, h = rx(s, r, 90), d = sx(t, e, g), p = rx(a, o, 90), y = sx(i, n, g), m) : g;
  }, m.extentMajor([[-180, -90 + wt], [180, 90 - wt]]).extentMinor([[-180, -80 - wt], [180, 80 + wt]]);
}
function QY() {
  return ZY()();
}
const c1 = (e) => e;
var Im = new sr(), l1 = new sr(), h$, d$, u1, f1, Vr = {
  point: kn,
  lineStart: kn,
  lineEnd: kn,
  polygonStart: function() {
    Vr.lineStart = tW, Vr.lineEnd = nW;
  },
  polygonEnd: function() {
    Vr.lineStart = Vr.lineEnd = Vr.point = kn, Im.add(Jt(l1)), l1 = new sr();
  },
  result: function() {
    var e = Im / 2;
    return Im = new sr(), e;
  }
};
function tW() {
  Vr.point = eW;
}
function eW(e, t) {
  Vr.point = p$, h$ = u1 = e, d$ = f1 = t;
}
function p$(e, t) {
  l1.add(f1 * e - u1 * t), u1 = e, f1 = t;
}
function nW() {
  p$(h$, d$);
}
var Fc = 1 / 0, wp = Fc, zu = -Fc, vp = zu, _p = {
  point: iW,
  lineStart: kn,
  lineEnd: kn,
  polygonStart: kn,
  polygonEnd: kn,
  result: function() {
    var e = [[Fc, wp], [zu, vp]];
    return zu = vp = -(wp = Fc = 1 / 0), e;
  }
};
function iW(e, t) {
  e < Fc && (Fc = e), e > zu && (zu = e), t < wp && (wp = t), t > vp && (vp = t);
}
var h1 = 0, d1 = 0, Hl = 0, xp = 0, Sp = 0, Za = 0, p1 = 0, y1 = 0, Jl = 0, y$, m$, Zi, Qi, ei = {
  point: ea,
  lineStart: ox,
  lineEnd: ax,
  polygonStart: function() {
    ei.lineStart = oW, ei.lineEnd = aW;
  },
  polygonEnd: function() {
    ei.point = ea, ei.lineStart = ox, ei.lineEnd = ax;
  },
  result: function() {
    var e = Jl ? [p1 / Jl, y1 / Jl] : Za ? [xp / Za, Sp / Za] : Hl ? [h1 / Hl, d1 / Hl] : [NaN, NaN];
    return h1 = d1 = Hl = xp = Sp = Za = p1 = y1 = Jl = 0, e;
  }
};
function ea(e, t) {
  h1 += e, d1 += t, ++Hl;
}
function ox() {
  ei.point = rW;
}
function rW(e, t) {
  ei.point = sW, ea(Zi = e, Qi = t);
}
function sW(e, t) {
  var n = e - Zi, i = t - Qi, r = yn(n * n + i * i);
  xp += r * (Zi + e) / 2, Sp += r * (Qi + t) / 2, Za += r, ea(Zi = e, Qi = t);
}
function ax() {
  ei.point = ea;
}
function oW() {
  ei.point = cW;
}
function aW() {
  g$(y$, m$);
}
function cW(e, t) {
  ei.point = g$, ea(y$ = Zi = e, m$ = Qi = t);
}
function g$(e, t) {
  var n = e - Zi, i = t - Qi, r = yn(n * n + i * i);
  xp += r * (Zi + e) / 2, Sp += r * (Qi + t) / 2, Za += r, r = Qi * e - Zi * t, p1 += r * (Zi + e), y1 += r * (Qi + t), Jl += r * 3, ea(Zi = e, Qi = t);
}
function b$(e) {
  this._context = e;
}
b$.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, Vn);
        break;
      }
    }
  },
  result: kn
};
var m1 = new sr(), Am, w$, v$, Kl, Zl, Pu = {
  point: kn,
  lineStart: function() {
    Pu.point = lW;
  },
  lineEnd: function() {
    Am && _$(w$, v$), Pu.point = kn;
  },
  polygonStart: function() {
    Am = !0;
  },
  polygonEnd: function() {
    Am = null;
  },
  result: function() {
    var e = +m1;
    return m1 = new sr(), e;
  }
};
function lW(e, t) {
  Pu.point = _$, w$ = Kl = e, v$ = Zl = t;
}
function _$(e, t) {
  Kl -= e, Zl -= t, m1.add(yn(Kl * Kl + Zl * Zl)), Kl = e, Zl = t;
}
let cx, Ip, lx, ux;
class fx {
  constructor(t) {
    this._append = t == null ? x$ : uW(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 !== lx || this._append !== Ip) {
          const i = this._radius, r = this._;
          this._ = "", this._append`m0,${i}a${i},${i} 0 1,1 0,${-2 * i}a${i},${i} 0 1,1 0,${2 * i}z`, lx = i, Ip = this._append, ux = this._, this._ = r;
        }
        this._ += ux;
        break;
      }
    }
  }
  result() {
    const t = this._;
    return this._ = "", t.length ? t : null;
  }
}
function x$(e) {
  let t = 1;
  this._ += e[0];
  for (const n = e.length; t < n; ++t)
    this._ += arguments[t] + e[t];
}
function uW(e) {
  const t = Math.floor(e);
  if (!(t >= 0))
    throw new RangeError(`invalid digits: ${e}`);
  if (t > 15)
    return x$;
  if (t !== cx) {
    const n = 10 ** t;
    cx = t, Ip = function(r) {
      let s = 1;
      this._ += r[0];
      for (const o = r.length; s < o; ++s)
        this._ += Math.round(arguments[s] * n) / n + r[s];
    };
  }
  return Ip;
}
function so(e, t) {
  let n = 3, i = 4.5, r, s;
  function o(a) {
    return a && (typeof i == "function" && s.pointRadius(+i.apply(this, arguments)), Ds(a, r(s))), s.result();
  }
  return o.area = function(a) {
    return Ds(a, r(Vr)), Vr.result();
  }, o.measure = function(a) {
    return Ds(a, r(Pu)), Pu.result();
  }, o.bounds = function(a) {
    return Ds(a, r(_p)), _p.result();
  }, o.centroid = function(a) {
    return Ds(a, r(ei)), ei.result();
  }, o.projection = function(a) {
    return arguments.length ? (r = a == null ? (e = null, c1) : (e = a).stream, o) : e;
  }, o.context = function(a) {
    return arguments.length ? (s = a == null ? (t = null, new fx(n)) : new b$(t = a), typeof i != "function" && s.pointRadius(i), o) : t;
  }, o.pointRadius = function(a) {
    return arguments.length ? (i = typeof a == "function" ? a : (s.pointRadius(+a), +a), o) : i;
  }, o.digits = function(a) {
    if (!arguments.length)
      return n;
    if (a == null)
      n = null;
    else {
      const c = Math.floor(a);
      if (!(c >= 0))
        throw new RangeError(`invalid digits: ${a}`);
      n = c;
    }
    return t === null && (s = new fx(n)), o;
  }, o.projection(e).digits(n).context(t);
}
function Ap(e) {
  return {
    stream: r0(e)
  };
}
function r0(e) {
  return function(t) {
    var n = new g1();
    for (var i in e)
      n[i] = e[i];
    return n.stream = t, n;
  };
}
function g1() {
}
g1.prototype = {
  constructor: g1,
  point: function(e, t) {
    this.stream.point(e, t);
  },
  sphere: function() {
    this.stream.sphere();
  },
  lineStart: function() {
    this.stream.lineStart();
  },
  lineEnd: function() {
    this.stream.lineEnd();
  },
  polygonStart: function() {
    this.stream.polygonStart();
  },
  polygonEnd: function() {
    this.stream.polygonEnd();
  }
};
function aw(e, t, n) {
  var i = e.clipExtent && e.clipExtent();
  return e.scale(150).translate([0, 0]), i != null && e.clipExtent(null), Ds(n, e.stream(_p)), t(_p.result()), i != null && e.clipExtent(i), e;
}
function cw(e, t, n) {
  return aw(e, function(i) {
    var r = t[1][0] - t[0][0], s = t[1][1] - t[0][1], o = Math.min(r / (i[1][0] - i[0][0]), s / (i[1][1] - i[0][1])), a = +t[0][0] + (r - o * (i[1][0] + i[0][0])) / 2, c = +t[0][1] + (s - o * (i[1][1] + i[0][1])) / 2;
    e.scale(150 * o).translate([a, c]);
  }, n);
}
function S$(e, t, n) {
  return cw(e, [[0, 0], t], n);
}
function I$(e, t, n) {
  return aw(e, function(i) {
    var r = +t, s = r / (i[1][0] - i[0][0]), o = (r - s * (i[1][0] + i[0][0])) / 2, a = -s * i[0][1];
    e.scale(150 * s).translate([o, a]);
  }, n);
}
function A$(e, t, n) {
  return aw(e, function(i) {
    var r = +t, s = r / (i[1][1] - i[0][1]), o = -s * i[0][0], a = (r - s * (i[1][1] + i[0][1])) / 2;
    e.scale(150 * s).translate([o, a]);
  }, n);
}
var hx = 16, fW = $t(30 * Xt);
function dx(e, t) {
  return +t ? dW(e, t) : hW(e);
}
function hW(e) {
  return r0({
    point: function(t, n) {
      t = e(t, n), this.stream.point(t[0], t[1]);
    }
  });
}
function dW(e, t) {
  function n(i, r, s, o, a, c, l, u, f, h, d, p, y, g) {
    var m = l - i, b = u - r, w = m * m + b * b;
    if (w > 4 * t && y--) {
      var v = o + h, _ = a + d, x = c + p, I = yn(v * v + _ * _ + x * x), N = Dn(x /= I), A = Jt(Jt(x) - 1) < wt || Jt(s - f) < wt ? (s + f) / 2 : Ti(_, v), D = e(A, N), M = D[0], B = D[1], R = M - i, S = B - r, $ = b * R - m * S;
      ($ * $ / w > t || Jt((m * R + b * S) / w - 0.5) > 0.3 || o * h + a * d + c * p < fW) && (n(i, r, s, o, a, c, M, B, A, v /= I, _ /= I, x, y, g), g.point(M, B), n(M, B, A, v, _, x, l, u, f, h, d, p, y, g));
    }
  }
  return function(i) {
    var r, s, o, a, c, l, u, f, h, d, p, y, g = {
      point: m,
      lineStart: b,
      lineEnd: v,
      polygonStart: function() {
        i.polygonStart(), g.lineStart = _;
      },
      polygonEnd: function() {
        i.polygonEnd(), g.lineStart = b;
      }
    };
    function m(N, A) {
      N = e(N, A), i.point(N[0], N[1]);
    }
    function b() {
      f = NaN, g.point = w, i.lineStart();
    }
    function w(N, A) {
      var D = Oc([N, A]), M = e(N, A);
      n(f, h, u, d, p, y, f = M[0], h = M[1], u = N, d = D[0], p = D[1], y = D[2], hx, i), i.point(f, h);
    }
    function v() {
      g.point = m, i.lineEnd();
    }
    function _() {
      b(), g.point = x, g.lineEnd = I;
    }
    function x(N, A) {
      w(r = N, A), s = f, o = h, a = d, c = p, l = y, g.point = w;
    }
    function I() {
      n(f, h, u, d, p, y, s, o, r, a, c, l, hx, i), g.lineEnd = v, v();
    }
    return g;
  };
}
var pW = r0({
  point: function(e, t) {
    this.stream.point(e * Xt, t * Xt);
  }
});
function yW(e) {
  return r0({
    point: function(t, n) {
      var i = e(t, n);
      return this.stream.point(i[0], i[1]);
    }
  });
}
function mW(e, t, n, i, r) {
  function s(o, a) {
    return o *= i, a *= r, [t + e * o, n - e * a];
  }
  return s.invert = function(o, a) {
    return [(o - t) / e * i, (n - a) / e * r];
  }, s;
}
function px(e, t, n, i, r, s) {
  if (!s)
    return mW(e, t, n, i, r);
  var o = $t(s), a = ot(s), c = o * e, l = a * e, u = o / e, f = a / e, h = (a * n - o * t) / e, d = (a * t + o * n) / e;
  function p(y, g) {
    return y *= i, g *= r, [c * y - l * g + t, n - l * y - c * g];
  }
  return p.invert = function(y, g) {
    return [i * (u * y - f * g + h), r * (d - f * y - u * g)];
  }, p;
}
function oo(e) {
  return M$(function() {
    return e;
  })();
}
function M$(e) {
  var t, n = 150, i = 480, r = 250, s = 0, o = 0, a = 0, c = 0, l = 0, u, f = 0, h = 1, d = 1, p = null, y = ix, g = null, m, b, w, v = c1, _ = 0.5, x, I, N, A, D;
  function M($) {
    return N($[0] * Xt, $[1] * Xt);
  }
  function B($) {
    return $ = N.invert($[0], $[1]), $ && [$[0] * Xe, $[1] * Xe];
  }
  M.stream = function($) {
    return A && D === $ ? A : A = pW(yW(u)(y(x(v(D = $)))));
  }, M.preclip = function($) {
    return arguments.length ? (y = $, p = void 0, S()) : y;
  }, M.postclip = function($) {
    return arguments.length ? (v = $, g = m = b = w = null, S()) : v;
  }, M.clipAngle = function($) {
    return arguments.length ? (y = +$ ? JY(p = $ * Xt) : (p = null, ix), S()) : p * Xe;
  }, M.clipExtent = function($) {
    return arguments.length ? (v = $ == null ? (g = m = b = w = null, c1) : f$(g = +$[0][0], m = +$[0][1], b = +$[1][0], w = +$[1][1]), S()) : g == null ? null : [[g, m], [b, w]];
  }, M.scale = function($) {
    return arguments.length ? (n = +$, R()) : n;
  }, M.translate = function($) {
    return arguments.length ? (i = +$[0], r = +$[1], R()) : [i, r];
  }, M.center = function($) {
    return arguments.length ? (s = $[0] % 360 * Xt, o = $[1] % 360 * Xt, R()) : [s * Xe, o * Xe];
  }, M.rotate = function($) {
    return arguments.length ? (a = $[0] % 360 * Xt, c = $[1] % 360 * Xt, l = $.length > 2 ? $[2] % 360 * Xt : 0, R()) : [a * Xe, c * Xe, l * Xe];
  }, M.angle = function($) {
    return arguments.length ? (f = $ % 360 * Xt, R()) : f * Xe;
  }, M.reflectX = function($) {
    return arguments.length ? (h = $ ? -1 : 1, R()) : h < 0;
  }, M.reflectY = function($) {
    return arguments.length ? (d = $ ? -1 : 1, R()) : d < 0;
  }, M.precision = function($) {
    return arguments.length ? (x = dx(I, _ = $ * $), S()) : yn(_);
  }, M.fitExtent = function($, T) {
    return cw(M, $, T);
  }, M.fitSize = function($, T) {
    return S$(M, $, T);
  }, M.fitWidth = function($, T) {
    return I$(M, $, T);
  }, M.fitHeight = function($, T) {
    return A$(M, $, T);
  };
  function R() {
    var $ = px(n, 0, 0, h, d, f).apply(null, t(s, o)), T = px(n, i - $[0], r - $[1], h, d, f);
    return u = a$(a, c, l), I = o1(t, T), N = o1(u, I), x = dx(I, _), S();
  }
  function S() {
    return A = D = null, M;
  }
  return function() {
    return t = e.apply(this, arguments), M.invert = t.invert && B, R();
  };
}
function lw(e) {
  var t = 0, n = kt / 3, i = M$(e), r = i(t, n);
  return r.parallels = function(s) {
    return arguments.length ? i(t = s[0] * Xt, n = s[1] * Xt) : [t * Xe, n * Xe];
  }, r;
}
function gW(e) {
  var t = $t(e);
  function n(i, r) {
    return [i * t, ot(r) / t];
  }
  return n.invert = function(i, r) {
    return [i / t, Dn(r * t)];
  }, n;
}
function bW(e, t) {
  var n = ot(e), i = (n + ot(t)) / 2;
  if (Jt(i) < wt)
    return gW(e);
  var r = 1 + n * (2 * i - n), s = yn(r) / i;
  function o(a, c) {
    var l = yn(r - 2 * i * ot(c)) / i;
    return [l * ot(a *= i), s - l * $t(a)];
  }
  return o.invert = function(a, c) {
    var l = s - c, u = Ti(a, Jt(l)) * ii(l);
    return l * i < 0 && (u -= kt * ii(a) * ii(l)), [u / i, Dn((r - (a * a + l * l) * i * i) / (2 * i))];
  }, o;
}
function Mp() {
  return lw(bW).scale(155.424).center([0, 33.6442]);
}
function $$() {
  return Mp().parallels([29.5, 45.5]).scale(1070).translate([480, 250]).rotate([96, 0]).center([-0.6, 38.7]);
}
function wW(e) {
  var t = e.length;
  return {
    point: function(n, i) {
      for (var r = -1; ++r < t; )
        e[r].point(n, i);
    },
    sphere: function() {
      for (var n = -1; ++n < t; )
        e[n].sphere();
    },
    lineStart: function() {
      for (var n = -1; ++n < t; )
        e[n].lineStart();
    },
    lineEnd: function() {
      for (var n = -1; ++n < t; )
        e[n].lineEnd();
    },
    polygonStart: function() {
      for (var n = -1; ++n < t; )
        e[n].polygonStart();
    },
    polygonEnd: function() {
      for (var n = -1; ++n < t; )
        e[n].polygonEnd();
    }
  };
}
function vW() {
  var e, t, n = $$(), i, r = Mp().rotate([154, 0]).center([-2, 58.5]).parallels([55, 65]), s, o = Mp().rotate([157, 0]).center([-3, 19.9]).parallels([8, 18]), a, c, l = { point: function(h, d) {
    c = [h, d];
  } };
  function u(h) {
    var d = h[0], p = h[1];
    return c = null, i.point(d, p), c || (s.point(d, p), c) || (a.point(d, p), c);
  }
  u.invert = function(h) {
    var d = n.scale(), p = n.translate(), y = (h[0] - p[0]) / d, g = (h[1] - p[1]) / d;
    return (g >= 0.12 && g < 0.234 && y >= -0.425 && y < -0.214 ? r : g >= 0.166 && g < 0.234 && y >= -0.214 && y < -0.115 ? o : n).invert(h);
  }, u.stream = function(h) {
    return e && t === h ? e : e = wW([n.stream(t = h), r.stream(h), o.stream(h)]);
  }, u.precision = function(h) {
    return arguments.length ? (n.precision(h), r.precision(h), o.precision(h), f()) : n.precision();
  }, u.scale = function(h) {
    return arguments.length ? (n.scale(h), r.scale(h * 0.35), o.scale(h), u.translate(n.translate())) : n.scale();
  }, u.translate = function(h) {
    if (!arguments.length)
      return n.translate();
    var d = n.scale(), p = +h[0], y = +h[1];
    return i = n.translate(h).clipExtent([[p - 0.455 * d, y - 0.238 * d], [p + 0.455 * d, y + 0.238 * d]]).stream(l), s = r.translate([p - 0.307 * d, y + 0.201 * d]).clipExtent([[p - 0.425 * d + wt, y + 0.12 * d + wt], [p - 0.214 * d - wt, y + 0.234 * d - wt]]).stream(l), a = o.translate([p - 0.205 * d, y + 0.212 * d]).clipExtent([[p - 0.214 * d + wt, y + 0.166 * d + wt], [p - 0.115 * d - wt, y + 0.234 * d - wt]]).stream(l), f();
  }, u.fitExtent = function(h, d) {
    return cw(u, h, d);
  }, u.fitSize = function(h, d) {
    return S$(u, h, d);
  }, u.fitWidth = function(h, d) {
    return I$(u, h, d);
  }, u.fitHeight = function(h, d) {
    return A$(u, h, d);
  };
  function f() {
    return e = t = null, u;
  }
  return u.scale(1070);
}
function T$(e) {
  return function(t, n) {
    var i = $t(t), r = $t(n), s = e(i * r);
    return s === 1 / 0 ? [2, 0] : [
      s * r * ot(t),
      s * ot(n)
    ];
  };
}
function Sf(e) {
  return function(t, n) {
    var i = yn(t * t + n * n), r = e(i), s = ot(r), o = $t(r);
    return [
      Ti(t * s, i * o),
      Dn(i && n * s / i)
    ];
  };
}
var D$ = T$(function(e) {
  return yn(2 / (1 + e));
});
D$.invert = Sf(function(e) {
  return 2 * Dn(e / 2);
});
function _W() {
  return oo(D$).scale(124.75).clipAngle(180 - 1e-3);
}
var N$ = T$(function(e) {
  return (e = i$(e)) && e / ot(e);
});
N$.invert = Sf(function(e) {
  return e;
});
function xW() {
  return oo(N$).scale(79.4188).clipAngle(180 - 1e-3);
}
function s0(e, t) {
  return [e, lp(sw(($e + t) / 2))];
}
s0.invert = function(e, t) {
  return [e, 2 * rl(n$(t)) - $e];
};
function SW() {
  return B$(s0).scale(961 / Vn);
}
function B$(e) {
  var t = oo(e), n = t.center, i = t.scale, r = t.translate, s = t.clipExtent, o = null, a, c, l;
  t.scale = function(f) {
    return arguments.length ? (i(f), u()) : i();
  }, t.translate = function(f) {
    return arguments.length ? (r(f), u()) : r();
  }, t.center = function(f) {
    return arguments.length ? (n(f), u()) : n();
  }, t.clipExtent = function(f) {
    return arguments.length ? (f == null ? o = a = c = l = null : (o = +f[0][0], a = +f[0][1], c = +f[1][0], l = +f[1][1]), u()) : o == null ? null : [[o, a], [c, l]];
  };
  function u() {
    var f = kt * i(), h = t(VY(t.rotate()).invert([0, 0]));
    return s(o == null ? [[h[0] - f, h[1] - f], [h[0] + f, h[1] + f]] : e === s0 ? [[Math.max(h[0] - f, o), a], [Math.min(h[0] + f, c), l]] : [[o, Math.max(h[1] - f, a)], [c, Math.min(h[1] + f, l)]]);
  }
  return u();
}
function vh(e) {
  return sw(($e + e) / 2);
}
function IW(e, t) {
  var n = $t(e), i = e === t ? ot(e) : lp(n / $t(t)) / lp(vh(t) / vh(e)), r = n * _m(vh(e), i) / i;
  if (!i)
    return s0;
  function s(o, a) {
    r > 0 ? a < -$e + wt && (a = -$e + wt) : a > $e - wt && (a = $e - wt);
    var c = r / _m(vh(a), i);
    return [c * ot(i * o), r - c * $t(i * o)];
  }
  return s.invert = function(o, a) {
    var c = r - a, l = ii(i) * yn(o * o + c * c), u = Ti(o, Jt(c)) * ii(c);
    return c * i < 0 && (u -= kt * ii(o) * ii(c)), [u / i, 2 * rl(_m(r / l, 1 / i)) - $e];
  }, s;
}
function AW() {
  return lw(IW).scale(109.5).parallels([30, 30]);
}
function $p(e, t) {
  return [e, t];
}
$p.invert = $p;
function MW() {
  return oo($p).scale(152.63);
}
function $W(e, t) {
  var n = $t(e), i = e === t ? ot(e) : (n - $t(t)) / (t - e), r = n / i + e;
  if (Jt(i) < wt)
    return $p;
  function s(o, a) {
    var c = r - a, l = i * o;
    return [c * ot(l), r - c * $t(l)];
  }
  return s.invert = function(o, a) {
    var c = r - a, l = Ti(o, Jt(c)) * ii(c);
    return c * i < 0 && (l -= kt * ii(o) * ii(c)), [l / i, r - ii(i) * yn(o * o + c * c)];
  }, s;
}
function TW() {
  return lw($W).scale(131.154).center([0, 13.9389]);
}
var fu = 1.340264, hu = -0.081106, du = 893e-6, pu = 3796e-6, Tp = yn(3) / 2, DW = 12;
function O$(e, t) {
  var n = Dn(Tp * ot(t)), i = n * n, r = i * i * i;
  return [
    e * $t(n) / (Tp * (fu + 3 * hu * i + r * (7 * du + 9 * pu * i))),
    n * (fu + hu * i + r * (du + pu * i))
  ];
}
O$.invert = function(e, t) {
  for (var n = t, i = n * n, r = i * i * i, s = 0, o, a, c; s < DW && (a = n * (fu + hu * i + r * (du + pu * i)) - t, c = fu + 3 * hu * i + r * (7 * du + 9 * pu * i), n -= o = a / c, i = n * n, r = i * i * i, !(Jt(o) < cp)); ++s)
    ;
  return [
    Tp * e * (fu + 3 * hu * i + r * (7 * du + 9 * pu * i)) / $t(n),
    Dn(ot(n) / Tp)
  ];
};
function NW() {
  return oo(O$).scale(177.158);
}
function F$(e, t) {
  var n = $t(t), i = $t(e) * n;
  return [n * ot(e) / i, ot(t) / i];
}
F$.invert = Sf(rl);
function BW() {
  return oo(F$).scale(144.049).clipAngle(60);
}
function E$(e, t) {
  return [$t(t) * ot(e), ot(t)];
}
E$.invert = Sf(Dn);
function OW() {
  return oo(E$).scale(249.5).clipAngle(90 + wt);
}
function L$(e, t) {
  var n = $t(t), i = 1 + $t(e) * n;
  return [n * ot(e) / i, ot(t) / i];
}
L$.invert = Sf(function(e) {
  return 2 * rl(e);
});
function FW() {
  return oo(L$).scale(250).clipAngle(142);
}
function R$(e, t) {
  return [lp(sw(($e + t) / 2)), -e];
}
R$.invert = function(e, t) {
  return [-t, 2 * rl(n$(e)) - $e];
};
function EW() {
  var e = B$(R$), t = e.center, n = e.rotate;
  return e.center = function(i) {
    return arguments.length ? t([-i[1], i[0]]) : (i = t(), [i[1], -i[0]]);
  }, e.rotate = function(i) {
    return arguments.length ? n([i[0], i[1], i.length > 2 ? i[2] + 90 : 90]) : (i = n(), [i[0], i[1], i[2] - 90]);
  }, n([0, 0, 90]).scale(159.155);
}
function LW(e, t) {
  return e.parent === t.parent ? 1 : 2;
}
function RW(e) {
  return e.reduce(CW, 0) / e.length;
}
function CW(e, t) {
  return e + t.x;
}
function kW(e) {
  return 1 + e.reduce(UW, 0);
}
function UW(e, t) {
  return Math.max(e, t.y);
}
function zW(e) {
  for (var t; t = e.children; )
    e = t[0];
  return e;
}
function PW(e) {
  for (var t; t = e.children; )
    e = t[t.length - 1];
  return e;
}
function C$() {
  var e = LW, t = 1, n = 1, i = !1;
  function r(s) {
    var o, a = 0;
    s.eachAfter(function(h) {
      var d = h.children;
      d ? (h.x = RW(d), h.y = kW(d)) : (h.x = o ? a += e(h, o) : 0, h.y = 0, o = h);
    });
    var c = zW(s), l = PW(s), u = c.x - e(c, l) / 2, f = l.x + e(l, c) / 2;
    return s.eachAfter(i ? function(h) {
      h.x = (h.x - s.x) * t, h.y = (s.y - h.y) * n;
    } : function(h) {
      h.x = (h.x - u) / (f - u) * t, h.y = (1 - (s.y ? h.y / s.y : 1)) * n;
    });
  }
  return r.separation = function(s) {
    return arguments.length ? (e = s, r) : e;
  }, r.size = function(s) {
    return arguments.length ? (i = !1, t = +s[0], n = +s[1], r) : i ? null : [t, n];
  }, r.nodeSize = function(s) {
    return arguments.length ? (i = !0, t = +s[0], n = +s[1], r) : i ? [t, n] : null;
  }, r;
}
function VW(e) {
  var t = 0, n = e.children, i = n && n.length;
  if (!i)
    t = 1;
  else
    for (; --i >= 0; )
      t += n[i].value;
  e.value = t;
}
function jW() {
  return this.eachAfter(VW);
}
function qW(e, t) {
  let n = -1;
  for (const i of this)
    e.call(t, i, ++n, this);
  return this;
}
function YW(e, t) {
  for (var n = this, i = [n], r, s, o = -1; n = i.pop(); )
    if (e.call(t, n, ++o, this), r = n.children)
      for (s = r.length - 1; s >= 0; --s)
        i.push(r[s]);
  return this;
}
function WW(e, t) {
  for (var n = this, i = [n], r = [], s, o, a, c = -1; n = i.pop(); )
    if (r.push(n), s = n.children)
      for (o = 0, a = s.length; o < a; ++o)
        i.push(s[o]);
  for (; n = r.pop(); )
    e.call(t, n, ++c, this);
  return this;
}
function GW(e, t) {
  let n = -1;
  for (const i of this)
    if (e.call(t, i, ++n, this))
      return i;
}
function XW(e) {
  return this.eachAfter(function(t) {
    for (var n = +e(t.data) || 0, i = t.children, r = i && i.length; --r >= 0; )
      n += i[r].value;
    t.value = n;
  });
}
function HW(e) {
  return this.eachBefore(function(t) {
    t.children && t.children.sort(e);
  });
}
function JW(e) {
  for (var t = this, n = KW(t, e), i = [t]; t !== n; )
    t = t.parent, i.push(t);
  for (var r = i.length; e !== n; )
    i.splice(r, 0, e), e = e.parent;
  return i;
}
function KW(e, t) {
  if (e === t)
    return e;
  var n = e.ancestors(), i = t.ancestors(), r = null;
  for (e = n.pop(), t = i.pop(); e === t; )
    r = e, e = n.pop(), t = i.pop();
  return r;
}
function ZW() {
  for (var e = this, t = [e]; e = e.parent; )
    t.push(e);
  return t;
}
function QW() {
  return Array.from(this);
}
function tG() {
  var e = [];
  return this.eachBefore(function(t) {
    t.children || e.push(t);
  }), e;
}
function eG() {
  var e = this, t = [];
  return e.each(function(n) {
    n !== e && t.push({ source: n.parent, target: n });
  }), t;
}
function* nG() {
  var e = this, t, n = [e], i, r, s;
  do
    for (t = n.reverse(), n = []; e = t.pop(); )
      if (yield e, i = e.children)
        for (r = 0, s = i.length; r < s; ++r)
          n.push(i[r]);
  while (n.length);
}
function k$(e, t) {
  e instanceof Map ? (e = [void 0, e], t === void 0 && (t = sG)) : t === void 0 && (t = rG);
  for (var n = new Ec(e), i, r = [n], s, o, a, c; i = r.pop(); )
    if ((o = t(i.data)) && (c = (o = Array.from(o)).length))
      for (i.children = o, a = c - 1; a >= 0; --a)
        r.push(s = o[a] = new Ec(o[a])), s.parent = i, s.depth = i.depth + 1;
  return n.eachBefore(U$);
}
function iG() {
  return k$(this).eachBefore(oG);
}
function rG(e) {
  return e.children;
}
function sG(e) {
  return Array.isArray(e) ? e[1] : null;
}
function oG(e) {
  e.data.value !== void 0 && (e.value = e.data.value), e.data = e.data.data;
}
function U$(e) {
  var t = 0;
  do
    e.height = t;
  while ((e = e.parent) && e.height < ++t);
}
function Ec(e) {
  this.data = e, this.depth = this.height = 0, this.parent = null;
}
Ec.prototype = k$.prototype = {
  constructor: Ec,
  count: jW,
  each: qW,
  eachAfter: WW,
  eachBefore: YW,
  find: GW,
  sum: XW,
  sort: HW,
  path: JW,
  ancestors: ZW,
  descendants: QW,
  leaves: tG,
  links: eG,
  copy: iG,
  [Symbol.iterator]: nG
};
function Mm(e) {
  return e == null ? null : aG(e);
}
function aG(e) {
  if (typeof e != "function")
    throw new Error();
  return e;
}
var cG = { depth: -1 }, yx = {}, $m = {};
function lG(e) {
  return e.id;
}
function uG(e) {
  return e.parentId;
}
function z$() {
  var e = lG, t = uG, n;
  function i(r) {
    var s = Array.from(r), o = e, a = t, c, l, u, f, h, d, p, y, g = /* @__PURE__ */ new Map();
    if (n != null) {
      const m = s.map((v, _) => fG(n(v, _, r))), b = m.map(mx), w = new Set(m).add("");
      for (const v of b)
        w.has(v) || (w.add(v), m.push(v), b.push(mx(v)), s.push($m));
      o = (v, _) => m[_], a = (v, _) => b[_];
    }
    for (u = 0, c = s.length; u < c; ++u)
      l = s[u], d = s[u] = new Ec(l), (p = o(l, u, r)) != null && (p += "") && (y = d.id = p, g.set(y, g.has(y) ? yx : d)), (p = a(l, u, r)) != null && (p += "") && (d.parent = p);
    for (u = 0; u < c; ++u)
      if (d = s[u], p = d.parent) {
        if (h = g.get(p), !h)
          throw new Error("missing: " + p);
        if (h === yx)
          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 === $m && f.children.length === 1; )
        f = f.children[0], --c;
      for (let m = s.length - 1; m >= 0 && (d = s[m], d.data === $m); --m)
        d.data = null;
    }
    if (f.parent = cG, f.eachBefore(function(m) {
      m.depth = m.parent.depth + 1, --c;
    }).eachBefore(U$), f.parent = null, c > 0)
      throw new Error("cycle");
    return f;
  }
  return i.id = function(r) {
    return arguments.length ? (e = Mm(r), i) : e;
  }, i.parentId = function(r) {
    return arguments.length ? (t = Mm(r), i) : t;
  }, i.path = function(r) {
    return arguments.length ? (n = Mm(r), i) : n;
  }, i;
}
function fG(e) {
  e = `${e}`;
  let t = e.length;
  return b1(e, t - 1) && !b1(e, t - 2) && (e = e.slice(0, -1)), e[0] === "/" ? e : `/${e}`;
}
function mx(e) {
  let t = e.length;
  if (t < 2)
    return "";
  for (; --t > 1 && !b1(e, t); )
    ;
  return e.slice(0, t);
}
function b1(e, t) {
  if (e[t] === "/") {
    let n = 0;
    for (; t > 0 && e[--t] === "\\"; )
      ++n;
    if (!(n & 1))
      return !0;
  }
  return !1;
}
function hG(e, t) {
  return e.parent === t.parent ? 1 : 2;
}
function Tm(e) {
  var t = e.children;
  return t ? t[0] : e.t;
}
function Dm(e) {
  var t = e.children;
  return t ? t[t.length - 1] : e.t;
}
function dG(e, t, n) {
  var i = n / (t.i - e.i);
  t.c -= i, t.s += n, e.c += i, t.z += n, t.m += n;
}
function pG(e) {
  for (var t = 0, n = 0, i = e.children, r = i.length, s; --r >= 0; )
    s = i[r], s.z += t, s.m += t, t += s.s + (n += s.c);
}
function yG(e, t, n) {
  return e.a.parent === t.parent ? e.a : n;
}
function ad(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;
}
ad.prototype = Object.create(Ec.prototype);
function mG(e) {
  for (var t = new ad(e, 0), n, i = [t], r, s, o, a; n = i.pop(); )
    if (s = n._.children)
      for (n.children = new Array(a = s.length), o = a - 1; o >= 0; --o)
        i.push(r = n.children[o] = new ad(s[o], o)), r.parent = n;
  return (t.parent = new ad(null, 0)).children = [t], t;
}
function Dp() {
  var e = hG, t = 1, n = 1, i = null;
  function r(l) {
    var u = mG(l);
    if (u.eachAfter(s), u.parent.m = -u.z, u.eachBefore(o), i)
      l.eachBefore(c);
    else {
      var f = l, h = l, d = l;
      l.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, g = t / (h.x + p + y), m = n / (d.depth || 1);
      l.eachBefore(function(b) {
        b.x = (b.x + y) * g, b.y = b.depth * m;
      });
    }
    return l;
  }
  function s(l) {
    var u = l.children, f = l.parent.children, h = l.i ? f[l.i - 1] : null;
    if (u) {
      pG(l);
      var d = (u[0].z + u[u.length - 1].z) / 2;
      h ? (l.z = h.z + e(l._, h._), l.m = l.z - d) : l.z = d;
    } else
      h && (l.z = h.z + e(l._, h._));
    l.parent.A = a(l, h, l.parent.A || f[0]);
  }
  function o(l) {
    l._.x = l.z + l.parent.m, l.m += l.parent.m;
  }
  function a(l, u, f) {
    if (u) {
      for (var h = l, d = l, p = u, y = h.parent.children[0], g = h.m, m = d.m, b = p.m, w = y.m, v; p = Dm(p), h = Tm(h), p && h; )
        y = Tm(y), d = Dm(d), d.a = l, v = p.z + b - h.z - g + e(p._, h._), v > 0 && (dG(yG(p, l, f), l, v), g += v, m += v), b += p.m, g += h.m, w += y.m, m += d.m;
      p && !Dm(d) && (d.t = p, d.m += b - m), h && !Tm(y) && (y.t = h, y.m += g - w, f = l);
    }
    return f;
  }
  function c(l) {
    l.x *= t, l.y = l.depth * n;
  }
  return r.separation = function(l) {
    return arguments.length ? (e = l, r) : e;
  }, r.size = function(l) {
    return arguments.length ? (i = !1, t = +l[0], n = +l[1], r) : i ? null : [t, n];
  }, r.nodeSize = function(l) {
    return arguments.length ? (i = !0, t = +l[0], n = +l[1], r) : i ? [t, n] : null;
  }, r;
}
const gG = 1664525, bG = 1013904223, gx = 1 / 4294967296;
function If(e = Math.random()) {
  let t = (0 <= e && e < 1 ? e / gx : Math.abs(e)) | 0;
  return () => (t = gG * t + bG | 0, gx * (t >>> 0));
}
function br(e, t) {
  switch (arguments.length) {
    case 0:
      break;
    case 1:
      this.range(e);
      break;
    default:
      this.range(t).domain(e);
      break;
  }
  return this;
}
function o0(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 w1 = Symbol("implicit");
function uw() {
  var e = new Jo(), t = [], n = [], i = w1;
  function r(s) {
    let o = e.get(s);
    if (o === void 0) {
      if (i !== w1)
        return i;
      e.set(s, o = t.push(s) - 1);
    }
    return n[o % n.length];
  }
  return r.domain = function(s) {
    if (!arguments.length)
      return t.slice();
    t = [], e = new Jo();
    for (const o of s)
      e.has(o) || e.set(o, t.push(o) - 1);
    return r;
  }, r.range = function(s) {
    return arguments.length ? (n = Array.from(s), r) : n.slice();
  }, r.unknown = function(s) {
    return arguments.length ? (i = s, r) : i;
  }, r.copy = function() {
    return uw(t, n).unknown(i);
  }, br.apply(r, arguments), r;
}
function a0() {
  var e = uw().unknown(void 0), t = e.domain, n = e.range, i = 0, r = 1, s, o, a = !1, c = 0, l = 0, u = 0.5;
  delete e.unknown;
  function f() {
    var h = t().length, d = r < i, p = d ? r : i, y = d ? i : r;
    s = (y - p) / Math.max(1, h - c + l * 2), a && (s = Math.floor(s)), p += (y - p - s * (h - c)) * u, o = s * (1 - c), a && (p = Math.round(p), o = Math.round(o));
    var g = Cn(h).map(function(m) {
      return p + s * m;
    });
    return n(d ? g.reverse() : g);
  }
  return e.domain = function(h) {
    return arguments.length ? (t(h), f()) : t();
  }, e.range = function(h) {
    return arguments.length ? ([i, r] = h, i = +i, r = +r, f()) : [i, r];
  }, e.rangeRound = function(h) {
    return [i, r] = h, i = +i, r = +r, 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, l = +h), f()) : c;
  }, e.paddingInner = function(h) {
    return arguments.length ? (c = Math.min(1, h), f()) : c;
  }, e.paddingOuter = function(h) {
    return arguments.length ? (l = +h, f()) : l;
  }, e.align = function(h) {
    return arguments.length ? (u = Math.max(0, Math.min(1, h)), f()) : u;
  }, e.copy = function() {
    return a0(t(), [i, r]).round(a).paddingInner(c).paddingOuter(l).align(u);
  }, br.apply(f(), arguments);
}
function P$(e) {
  var t = e.copy;
  return e.padding = e.paddingOuter, delete e.paddingInner, delete e.paddingOuter, e.copy = function() {
    return P$(t());
  }, e;
}
function wG() {
  return P$(a0.apply(null, arguments).paddingInner(1));
}
function vG(e) {
  return function() {
    return e;
  };
}
function v1(e) {
  return +e;
}
var bx = [0, 1];
function ri(e) {
  return e;
}
function _1(e, t) {
  return (t -= e = +e) ? function(n) {
    return (n - e) / t;
  } : vG(isNaN(t) ? NaN : 0.5);
}
function _G(e, t) {
  var n;
  return e > t && (n = e, e = t, t = n), function(i) {
    return Math.max(e, Math.min(t, i));
  };
}
function xG(e, t, n) {
  var i = e[0], r = e[1], s = t[0], o = t[1];
  return r < i ? (i = _1(r, i), s = n(o, s)) : (i = _1(i, r), s = n(s, o)), function(a) {
    return s(i(a));
  };
}
function SG(e, t, n) {
  var i = Math.min(e.length, t.length) - 1, r = new Array(i), s = new Array(i), o = -1;
  for (e[i] < e[0] && (e = e.slice().reverse(), t = t.slice().reverse()); ++o < i; )
    r[o] = _1(e[o], e[o + 1]), s[o] = n(t[o], t[o + 1]);
  return function(a) {
    var c = Gy(e, a, 1, i) - 1;
    return s[c](r[c](a));
  };
}
function Af(e, t) {
  return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown());
}
function c0() {
  var e = bx, t = bx, n = nl, i, r, s, o = ri, a, c, l;
  function u() {
    var h = Math.min(e.length, t.length);
    return o !== ri && (o = _G(e[0], e[h - 1])), a = h > 2 ? SG : xG, c = l = null, f;
  }
  function f(h) {
    return h == null || isNaN(h = +h) ? s : (c || (c = a(e.map(i), t, n)))(i(o(h)));
  }
  return f.invert = function(h) {
    return o(r((l || (l = a(t, e.map(i), Qe)))(h)));
  }, f.domain = function(h) {
    return arguments.length ? (e = Array.from(h, v1), u()) : e.slice();
  }, f.range = function(h) {
    return arguments.length ? (t = Array.from(h), u()) : t.slice();
  }, f.rangeRound = function(h) {
    return t = Array.from(h), n = Zb, u();
  }, f.clamp = function(h) {
    return arguments.length ? (o = h ? !0 : ri, u()) : o !== ri;
  }, f.interpolate = function(h) {
    return arguments.length ? (n = h, u()) : n;
  }, f.unknown = function(h) {
    return arguments.length ? (s = h, f) : s;
  }, function(h, d) {
    return i = h, r = d, u();
  };
}
function V$() {
  return c0()(ri, ri);
}
function IG(e, t, n, i) {
  var r = Rg(e, t, n), s;
  switch (i = Uu(i ?? ",f"), i.type) {
    case "s": {
      var o = Math.max(Math.abs(e), Math.abs(t));
      return i.precision == null && !isNaN(s = EY(r, o)) && (i.precision = s), e$(i, o);
    }
    case "":
    case "e":
    case "g":
    case "p":
    case "r": {
      i.precision == null && !isNaN(s = LY(r, Math.max(Math.abs(e), Math.abs(t)))) && (i.precision = s - (i.type === "e"));
      break;
    }
    case "f":
    case "%": {
      i.precision == null && !isNaN(s = FY(r)) && (i.precision = s - (i.type === "%") * 2);
      break;
    }
  }
  return il(i);
}
function Mf(e) {
  var t = e.domain;
  return e.ticks = function(n) {
    var i = t();
    return qs(i[0], i[i.length - 1], n ?? 10);
  }, e.tickFormat = function(n, i) {
    var r = t();
    return IG(r[0], r[r.length - 1], n ?? 10, i);
  }, e.nice = function(n) {
    n == null && (n = 10);
    var i = t(), r = 0, s = i.length - 1, o = i[r], a = i[s], c, l, u = 10;
    for (a < o && (l = o, o = a, a = l, l = r, r = s, s = l); u-- > 0; ) {
      if (l = Fu(o, a, n), l === c)
        return i[r] = o, i[s] = a, t(i);
      if (l > 0)
        o = Math.floor(o / l) * l, a = Math.ceil(a / l) * l;
      else if (l < 0)
        o = Math.ceil(o * l) / l, a = Math.floor(a * l) / l;
      else
        break;
      c = l;
    }
    return e;
  }, e;
}
function l0() {
  var e = V$();
  return e.copy = function() {
    return Af(e, l0());
  }, br.apply(e, arguments), Mf(e);
}
function j$(e) {
  var t;
  function n(i) {
    return i == null || isNaN(i = +i) ? t : i;
  }
  return n.invert = n, n.domain = n.range = function(i) {
    return arguments.length ? (e = Array.from(i, v1), n) : e.slice();
  }, n.unknown = function(i) {
    return arguments.length ? (t = i, n) : t;
  }, n.copy = function() {
    return j$(e).unknown(t);
  }, e = arguments.length ? Array.from(e, v1) : [0, 1], Mf(n);
}
function q$(e, t) {
  e = e.slice();
  var n = 0, i = e.length - 1, r = e[n], s = e[i], o;
  return s < r && (o = n, n = i, i = o, o = r, r = s, s = o), e[n] = t.floor(r), e[i] = t.ceil(s), e;
}
function wx(e) {
  return Math.log(e);
}
function vx(e) {
  return Math.exp(e);
}
function AG(e) {
  return -Math.log(-e);
}
function MG(e) {
  return -Math.exp(-e);
}
function $G(e) {
  return isFinite(e) ? +("1e" + e) : e < 0 ? 0 : e;
}
function TG(e) {
  return e === 10 ? $G : e === Math.E ? Math.exp : (t) => Math.pow(e, t);
}
function DG(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 _x(e) {
  return (t, n) => -e(-t, n);
}
function Y$(e) {
  const t = e(wx, vx), n = t.domain;
  let i = 10, r, s;
  function o() {
    return r = DG(i), s = TG(i), n()[0] < 0 ? (r = _x(r), s = _x(s), e(AG, MG)) : e(wx, vx), t;
  }
  return t.base = function(a) {
    return arguments.length ? (i = +a, o()) : i;
  }, t.domain = function(a) {
    return arguments.length ? (n(a), o()) : n();
  }, t.ticks = (a) => {
    const c = n();
    let l = c[0], u = c[c.length - 1];
    const f = u < l;
    f && ([l, u] = [u, l]);
    let h = r(l), d = r(u), p, y;
    const g = a == null ? 10 : +a;
    let m = [];
    if (!(i % 1) && d - h < g) {
      if (h = Math.floor(h), d = Math.ceil(d), l > 0) {
        for (; h <= d; ++h)
          for (p = 1; p < i; ++p)
            if (y = h < 0 ? p / s(-h) : p * s(h), !(y < l)) {
              if (y > u)
                break;
              m.push(y);
            }
      } else
        for (; h <= d; ++h)
          for (p = i - 1; p >= 1; --p)
            if (y = h > 0 ? p / s(-h) : p * s(h), !(y < l)) {
              if (y > u)
                break;
              m.push(y);
            }
      m.length * 2 < g && (m = qs(l, u, g));
    } else
      m = qs(h, d, Math.min(d - h, g)).map(s);
    return f ? m.reverse() : m;
  }, t.tickFormat = (a, c) => {
    if (a == null && (a = 10), c == null && (c = i === 10 ? "s" : ","), typeof c != "function" && (!(i % 1) && (c = Uu(c)).precision == null && (c.trim = !0), c = il(c)), a === 1 / 0)
      return c;
    const l = Math.max(1, i * a / t.ticks().length);
    return (u) => {
      let f = u / s(Math.round(r(u)));
      return f * i < i - 0.5 && (f *= i), f <= l ? c(u) : "";
    };
  }, t.nice = () => n(q$(n(), {
    floor: (a) => s(Math.floor(r(a))),
    ceil: (a) => s(Math.ceil(r(a)))
  })), t;
}
function W$() {
  const e = Y$(c0()).domain([1, 10]);
  return e.copy = () => Af(e, W$()).base(e.base()), br.apply(e, arguments), e;
}
function xx(e) {
  return function(t) {
    return Math.sign(t) * Math.log1p(Math.abs(t / e));
  };
}
function Sx(e) {
  return function(t) {
    return Math.sign(t) * Math.expm1(Math.abs(t)) * e;
  };
}
function G$(e) {
  var t = 1, n = e(xx(t), Sx(t));
  return n.constant = function(i) {
    return arguments.length ? e(xx(t = +i), Sx(t)) : t;
  }, Mf(n);
}
function X$() {
  var e = G$(c0());
  return e.copy = function() {
    return Af(e, X$()).constant(e.constant());
  }, br.apply(e, arguments);
}
function Ix(e) {
  return function(t) {
    return t < 0 ? -Math.pow(-t, e) : Math.pow(t, e);
  };
}
function NG(e) {
  return e < 0 ? -Math.sqrt(-e) : Math.sqrt(e);
}
function BG(e) {
  return e < 0 ? -e * e : e * e;
}
function H$(e) {
  var t = e(ri, ri), n = 1;
  function i() {
    return n === 1 ? e(ri, ri) : n === 0.5 ? e(NG, BG) : e(Ix(n), Ix(1 / n));
  }
  return t.exponent = function(r) {
    return arguments.length ? (n = +r, i()) : n;
  }, Mf(t);
}
function J$() {
  var e = H$(c0());
  return e.copy = function() {
    return Af(e, J$()).exponent(e.exponent());
  }, br.apply(e, arguments), e;
}
function K$() {
  var e = [], t = [], n = [], i;
  function r() {
    var o = 0, a = Math.max(1, t.length);
    for (n = new Array(a - 1); ++o < a; )
      n[o - 1] = Uz(e, o / a);
    return s;
  }
  function s(o) {
    return o == null || isNaN(o = +o) ? i : t[Gy(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(me), r();
  }, s.range = function(o) {
    return arguments.length ? (t = Array.from(o), r()) : t.slice();
  }, s.unknown = function(o) {
    return arguments.length ? (i = o, s) : i;
  }, s.quantiles = function() {
    return n.slice();
  }, s.copy = function() {
    return K$().domain(e).range(t).unknown(i);
  }, br.apply(s, arguments);
}
function Z$() {
  var e = [0.5], t = [0, 1], n, i = 1;
  function r(s) {
    return s != null && s <= s ? t[Gy(e, s, 0, i)] : n;
  }
  return r.domain = function(s) {
    return arguments.length ? (e = Array.from(s), i = Math.min(e.length, t.length - 1), r) : e.slice();
  }, r.range = function(s) {
    return arguments.length ? (t = Array.from(s), i = Math.min(e.length, t.length - 1), r) : t.slice();
  }, r.invertExtent = function(s) {
    var o = t.indexOf(s);
    return [e[o - 1], e[o]];
  }, r.unknown = function(s) {
    return arguments.length ? (n = s, r) : n;
  }, r.copy = function() {
    return Z$().domain(e).range(t).unknown(n);
  }, br.apply(r, arguments);
}
const Nm = /* @__PURE__ */ new Date(), Bm = /* @__PURE__ */ new Date();
function Ue(e, t, n, i) {
  function r(s) {
    return e(s = arguments.length === 0 ? /* @__PURE__ */ new Date() : /* @__PURE__ */ new Date(+s)), s;
  }
  return r.floor = (s) => (e(s = /* @__PURE__ */ new Date(+s)), s), r.ceil = (s) => (e(s = new Date(s - 1)), t(s, 1), e(s), s), r.round = (s) => {
    const o = r(s), a = r.ceil(s);
    return s - o < a - s ? o : a;
  }, r.offset = (s, o) => (t(s = /* @__PURE__ */ new Date(+s), o == null ? 1 : Math.floor(o)), s), r.range = (s, o, a) => {
    const c = [];
    if (s = r.ceil(s), a = a == null ? 1 : Math.floor(a), !(s < o) || !(a > 0))
      return c;
    let l;
    do
      c.push(l = /* @__PURE__ */ new Date(+s)), t(s, a), e(s);
    while (l < s && s < o);
    return c;
  }, r.filter = (s) => Ue((o) => {
    if (o >= o)
      for (; e(o), !s(o); )
        o.setTime(o - 1);
  }, (o, a) => {
    if (o >= o)
      if (a < 0)
        for (; ++a <= 0; )
          for (; t(o, -1), !s(o); )
            ;
      else
        for (; --a >= 0; )
          for (; t(o, 1), !s(o); )
            ;
  }), n && (r.count = (s, o) => (Nm.setTime(+s), Bm.setTime(+o), e(Nm), e(Bm), Math.floor(n(Nm, Bm))), r.every = (s) => (s = Math.floor(s), !isFinite(s) || !(s > 0) ? null : s > 1 ? r.filter(i ? (o) => i(o) % s === 0 : (o) => r.count(0, o) % s === 0) : r)), r;
}
const Np = Ue(() => {
}, (e, t) => {
  e.setTime(+e + t);
}, (e, t) => t - e);
Np.every = (e) => (e = Math.floor(e), !isFinite(e) || !(e > 0) ? null : e > 1 ? Ue((t) => {
  t.setTime(Math.floor(t / e) * e);
}, (t, n) => {
  t.setTime(+t + n * e);
}, (t, n) => (n - t) / e) : Np);
Np.range;
const Xr = 1e3, si = Xr * 60, Hr = si * 60, rs = Hr * 24, fw = rs * 7, Ax = rs * 30, Om = rs * 365, xi = Ue((e) => {
  e.setTime(e - e.getMilliseconds());
}, (e, t) => {
  e.setTime(+e + t * Xr);
}, (e, t) => (t - e) / Xr, (e) => e.getUTCSeconds());
xi.range;
const $f = Ue((e) => {
  e.setTime(e - e.getMilliseconds() - e.getSeconds() * Xr);
}, (e, t) => {
  e.setTime(+e + t * si);
}, (e, t) => (t - e) / si, (e) => e.getMinutes());
$f.range;
const Tf = Ue((e) => {
  e.setUTCSeconds(0, 0);
}, (e, t) => {
  e.setTime(+e + t * si);
}, (e, t) => (t - e) / si, (e) => e.getUTCMinutes());
Tf.range;
const Df = Ue((e) => {
  e.setTime(e - e.getMilliseconds() - e.getSeconds() * Xr - e.getMinutes() * si);
}, (e, t) => {
  e.setTime(+e + t * Hr);
}, (e, t) => (t - e) / Hr, (e) => e.getHours());
Df.range;
const Nf = Ue((e) => {
  e.setUTCMinutes(0, 0, 0);
}, (e, t) => {
  e.setTime(+e + t * Hr);
}, (e, t) => (t - e) / Hr, (e) => e.getUTCHours());
Nf.range;
const aa = Ue(
  (e) => e.setHours(0, 0, 0, 0),
  (e, t) => e.setDate(e.getDate() + t),
  (e, t) => (t - e - (t.getTimezoneOffset() - e.getTimezoneOffset()) * si) / rs,
  (e) => e.getDate() - 1
);
aa.range;
const u0 = Ue((e) => {
  e.setUTCHours(0, 0, 0, 0);
}, (e, t) => {
  e.setUTCDate(e.getUTCDate() + t);
}, (e, t) => (t - e) / rs, (e) => e.getUTCDate() - 1);
u0.range;
const f0 = Ue((e) => {
  e.setUTCHours(0, 0, 0, 0);
}, (e, t) => {
  e.setUTCDate(e.getUTCDate() + t);
}, (e, t) => (t - e) / rs, (e) => Math.floor(e / rs));
f0.range;
function ca(e) {
  return Ue((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()) * si) / fw);
}
const Lc = ca(0), Vu = ca(1), Q$ = ca(2), t6 = ca(3), na = ca(4), e6 = ca(5), n6 = ca(6);
Lc.range;
Vu.range;
Q$.range;
t6.range;
na.range;
e6.range;
n6.range;
function la(e) {
  return Ue((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) / fw);
}
const Rc = la(0), ju = la(1), i6 = la(2), r6 = la(3), ia = la(4), s6 = la(5), o6 = la(6);
Rc.range;
ju.range;
i6.range;
r6.range;
ia.range;
s6.range;
o6.range;
const Bf = Ue((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());
Bf.range;
const Of = Ue((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());
Of.range;
const Di = Ue((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());
Di.every = (e) => !isFinite(e = Math.floor(e)) || !(e > 0) ? null : Ue((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);
});
Di.range;
const Ni = Ue((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());
Ni.every = (e) => !isFinite(e = Math.floor(e)) || !(e > 0) ? null : Ue((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);
});
Ni.range;
function a6(e, t, n, i, r, s) {
  const o = [
    [xi, 1, Xr],
    [xi, 5, 5 * Xr],
    [xi, 15, 15 * Xr],
    [xi, 30, 30 * Xr],
    [s, 1, si],
    [s, 5, 5 * si],
    [s, 15, 15 * si],
    [s, 30, 30 * si],
    [r, 1, Hr],
    [r, 3, 3 * Hr],
    [r, 6, 6 * Hr],
    [r, 12, 12 * Hr],
    [i, 1, rs],
    [i, 2, 2 * rs],
    [n, 1, fw],
    [t, 1, Ax],
    [t, 3, 3 * Ax],
    [e, 1, Om]
  ];
  function a(l, u, f) {
    const h = u < l;
    h && ([l, u] = [u, l]);
    const d = f && typeof f.range == "function" ? f : c(l, u, f), p = d ? d.range(l, +u + 1) : [];
    return h ? p.reverse() : p;
  }
  function c(l, u, f) {
    const h = Math.abs(u - l) / f, d = Wy(([, , g]) => g).right(o, h);
    if (d === o.length)
      return e.every(Rg(l / Om, u / Om, f));
    if (d === 0)
      return Np.every(Math.max(Rg(l, u, 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 [OG, c6] = a6(Ni, Of, Rc, f0, Nf, Tf), [FG, EG] = a6(Di, Bf, Lc, aa, Df, $f);
function Fm(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 Em(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 Sl(e, t, n) {
  return { y: e, m: t, d: n, H: 0, M: 0, S: 0, L: 0 };
}
function LG(e) {
  var t = e.dateTime, n = e.date, i = e.time, r = e.periods, s = e.days, o = e.shortDays, a = e.months, c = e.shortMonths, l = Il(r), u = Al(r), f = Il(s), h = Al(s), d = Il(o), p = Al(o), y = Il(a), g = Al(a), m = Il(c), b = Al(c), w = {
    a: L,
    A: k,
    b: U,
    B: C,
    c: null,
    d: Bx,
    e: Bx,
    f: rX,
    g: pX,
    G: mX,
    H: eX,
    I: nX,
    j: iX,
    L: l6,
    m: sX,
    M: oX,
    p: z,
    q: P,
    Q: Ex,
    s: Lx,
    S: aX,
    u: cX,
    U: lX,
    V: uX,
    w: fX,
    W: hX,
    x: null,
    X: null,
    y: dX,
    Y: yX,
    Z: gX,
    "%": Fx
  }, v = {
    a: G,
    A: K,
    b: tt,
    B: Z,
    c: null,
    d: Ox,
    e: Ox,
    f: _X,
    g: BX,
    G: FX,
    H: bX,
    I: wX,
    j: vX,
    L: f6,
    m: xX,
    M: SX,
    p: Y,
    q: X,
    Q: Ex,
    s: Lx,
    S: IX,
    u: AX,
    U: MX,
    V: $X,
    w: TX,
    W: DX,
    x: null,
    X: null,
    y: NX,
    Y: OX,
    Z: EX,
    "%": Fx
  }, _ = {
    a: D,
    A: M,
    b: B,
    B: R,
    c: S,
    d: Dx,
    e: Dx,
    f: KG,
    g: Tx,
    G: $x,
    H: Nx,
    I: Nx,
    j: GG,
    L: JG,
    m: WG,
    M: XG,
    p: A,
    q: YG,
    Q: QG,
    s: tX,
    S: HG,
    u: zG,
    U: PG,
    V: VG,
    w: UG,
    W: jG,
    x: $,
    X: T,
    y: Tx,
    Y: $x,
    Z: qG,
    "%": ZG
  };
  w.x = x(n, w), w.X = x(i, w), w.c = x(t, w), v.x = x(n, v), v.X = x(i, v), v.c = x(t, v);
  function x(j, J) {
    return function(et) {
      var V = [], Ft = -1, rt = 0, Vt = j.length, jt, Q, Zt;
      for (et instanceof Date || (et = /* @__PURE__ */ new Date(+et)); ++Ft < Vt; )
        j.charCodeAt(Ft) === 37 && (V.push(j.slice(rt, Ft)), (Q = Mx[jt = j.charAt(++Ft)]) != null ? jt = j.charAt(++Ft) : Q = jt === "e" ? " " : "0", (Zt = J[jt]) && (jt = Zt(et, Q)), V.push(jt), rt = Ft + 1);
      return V.push(j.slice(rt, Ft)), V.join("");
    };
  }
  function I(j, J) {
    return function(et) {
      var V = Sl(1900, void 0, 1), Ft = N(V, j, et += "", 0), rt, Vt;
      if (Ft != et.length)
        return null;
      if ("Q" in V)
        return new Date(V.Q);
      if ("s" in V)
        return new Date(V.s * 1e3 + ("L" in V ? V.L : 0));
      if (J && !("Z" in V) && (V.Z = 0), "p" in V && (V.H = V.H % 12 + V.p * 12), V.m === void 0 && (V.m = "q" in V ? V.q : 0), "V" in V) {
        if (V.V < 1 || V.V > 53)
          return null;
        "w" in V || (V.w = 1), "Z" in V ? (rt = Em(Sl(V.y, 0, 1)), Vt = rt.getUTCDay(), rt = Vt > 4 || Vt === 0 ? ju.ceil(rt) : ju(rt), rt = u0.offset(rt, (V.V - 1) * 7), V.y = rt.getUTCFullYear(), V.m = rt.getUTCMonth(), V.d = rt.getUTCDate() + (V.w + 6) % 7) : (rt = Fm(Sl(V.y, 0, 1)), Vt = rt.getDay(), rt = Vt > 4 || Vt === 0 ? Vu.ceil(rt) : Vu(rt), rt = aa.offset(rt, (V.V - 1) * 7), V.y = rt.getFullYear(), V.m = rt.getMonth(), V.d = rt.getDate() + (V.w + 6) % 7);
      } else
        ("W" in V || "U" in V) && ("w" in V || (V.w = "u" in V ? V.u % 7 : "W" in V ? 1 : 0), Vt = "Z" in V ? Em(Sl(V.y, 0, 1)).getUTCDay() : Fm(Sl(V.y, 0, 1)).getDay(), V.m = 0, V.d = "W" in V ? (V.w + 6) % 7 + V.W * 7 - (Vt + 5) % 7 : V.w + V.U * 7 - (Vt + 6) % 7);
      return "Z" in V ? (V.H += V.Z / 100 | 0, V.M += V.Z % 100, Em(V)) : Fm(V);
    };
  }
  function N(j, J, et, V) {
    for (var Ft = 0, rt = J.length, Vt = et.length, jt, Q; Ft < rt; ) {
      if (V >= Vt)
        return -1;
      if (jt = J.charCodeAt(Ft++), jt === 37) {
        if (jt = J.charAt(Ft++), Q = _[jt in Mx ? J.charAt(Ft++) : jt], !Q || (V = Q(j, et, V)) < 0)
          return -1;
      } else if (jt != et.charCodeAt(V++))
        return -1;
    }
    return V;
  }
  function A(j, J, et) {
    var V = l.exec(J.slice(et));
    return V ? (j.p = u.get(V[0].toLowerCase()), et + V[0].length) : -1;
  }
  function D(j, J, et) {
    var V = d.exec(J.slice(et));
    return V ? (j.w = p.get(V[0].toLowerCase()), et + V[0].length) : -1;
  }
  function M(j, J, et) {
    var V = f.exec(J.slice(et));
    return V ? (j.w = h.get(V[0].toLowerCase()), et + V[0].length) : -1;
  }
  function B(j, J, et) {
    var V = m.exec(J.slice(et));
    return V ? (j.m = b.get(V[0].toLowerCase()), et + V[0].length) : -1;
  }
  function R(j, J, et) {
    var V = y.exec(J.slice(et));
    return V ? (j.m = g.get(V[0].toLowerCase()), et + V[0].length) : -1;
  }
  function S(j, J, et) {
    return N(j, t, J, et);
  }
  function $(j, J, et) {
    return N(j, n, J, et);
  }
  function T(j, J, et) {
    return N(j, i, J, et);
  }
  function L(j) {
    return o[j.getDay()];
  }
  function k(j) {
    return s[j.getDay()];
  }
  function U(j) {
    return c[j.getMonth()];
  }
  function C(j) {
    return a[j.getMonth()];
  }
  function z(j) {
    return r[+(j.getHours() >= 12)];
  }
  function P(j) {
    return 1 + ~~(j.getMonth() / 3);
  }
  function G(j) {
    return o[j.getUTCDay()];
  }
  function K(j) {
    return s[j.getUTCDay()];
  }
  function tt(j) {
    return c[j.getUTCMonth()];
  }
  function Z(j) {
    return a[j.getUTCMonth()];
  }
  function Y(j) {
    return r[+(j.getUTCHours() >= 12)];
  }
  function X(j) {
    return 1 + ~~(j.getUTCMonth() / 3);
  }
  return {
    format: function(j) {
      var J = x(j += "", w);
      return J.toString = function() {
        return j;
      }, J;
    },
    parse: function(j) {
      var J = I(j += "", !1);
      return J.toString = function() {
        return j;
      }, J;
    },
    utcFormat: function(j) {
      var J = x(j += "", v);
      return J.toString = function() {
        return j;
      }, J;
    },
    utcParse: function(j) {
      var J = I(j += "", !0);
      return J.toString = function() {
        return j;
      }, J;
    }
  };
}
var Mx = { "-": "", _: " ", 0: "0" }, We = /^\s*\d+/, RG = /^%/, CG = /[\\^$*+?|[\]().{}]/g;
function Ht(e, t, n) {
  var i = e < 0 ? "-" : "", r = (i ? -e : e) + "", s = r.length;
  return i + (s < n ? new Array(n - s + 1).join(t) + r : r);
}
function kG(e) {
  return e.replace(CG, "\\$&");
}
function Il(e) {
  return new RegExp("^(?:" + e.map(kG).join("|") + ")", "i");
}
function Al(e) {
  return new Map(e.map((t, n) => [t.toLowerCase(), n]));
}
function UG(e, t, n) {
  var i = We.exec(t.slice(n, n + 1));
  return i ? (e.w = +i[0], n + i[0].length) : -1;
}
function zG(e, t, n) {
  var i = We.exec(t.slice(n, n + 1));
  return i ? (e.u = +i[0], n + i[0].length) : -1;
}
function PG(e, t, n) {
  var i = We.exec(t.slice(n, n + 2));
  return i ? (e.U = +i[0], n + i[0].length) : -1;
}
function VG(e, t, n) {
  var i = We.exec(t.slice(n, n + 2));
  return i ? (e.V = +i[0], n + i[0].length) : -1;
}
function jG(e, t, n) {
  var i = We.exec(t.slice(n, n + 2));
  return i ? (e.W = +i[0], n + i[0].length) : -1;
}
function $x(e, t, n) {
  var i = We.exec(t.slice(n, n + 4));
  return i ? (e.y = +i[0], n + i[0].length) : -1;
}
function Tx(e, t, n) {
  var i = We.exec(t.slice(n, n + 2));
  return i ? (e.y = +i[0] + (+i[0] > 68 ? 1900 : 2e3), n + i[0].length) : -1;
}
function qG(e, t, n) {
  var i = /^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n, n + 6));
  return i ? (e.Z = i[1] ? 0 : -(i[2] + (i[3] || "00")), n + i[0].length) : -1;
}
function YG(e, t, n) {
  var i = We.exec(t.slice(n, n + 1));
  return i ? (e.q = i[0] * 3 - 3, n + i[0].length) : -1;
}
function WG(e, t, n) {
  var i = We.exec(t.slice(n, n + 2));
  return i ? (e.m = i[0] - 1, n + i[0].length) : -1;
}
function Dx(e, t, n) {
  var i = We.exec(t.slice(n, n + 2));
  return i ? (e.d = +i[0], n + i[0].length) : -1;
}
function GG(e, t, n) {
  var i = We.exec(t.slice(n, n + 3));
  return i ? (e.m = 0, e.d = +i[0], n + i[0].length) : -1;
}
function Nx(e, t, n) {
  var i = We.exec(t.slice(n, n + 2));
  return i ? (e.H = +i[0], n + i[0].length) : -1;
}
function XG(e, t, n) {
  var i = We.exec(t.slice(n, n + 2));
  return i ? (e.M = +i[0], n + i[0].length) : -1;
}
function HG(e, t, n) {
  var i = We.exec(t.slice(n, n + 2));
  return i ? (e.S = +i[0], n + i[0].length) : -1;
}
function JG(e, t, n) {
  var i = We.exec(t.slice(n, n + 3));
  return i ? (e.L = +i[0], n + i[0].length) : -1;
}
function KG(e, t, n) {
  var i = We.exec(t.slice(n, n + 6));
  return i ? (e.L = Math.floor(i[0] / 1e3), n + i[0].length) : -1;
}
function ZG(e, t, n) {
  var i = RG.exec(t.slice(n, n + 1));
  return i ? n + i[0].length : -1;
}
function QG(e, t, n) {
  var i = We.exec(t.slice(n));
  return i ? (e.Q = +i[0], n + i[0].length) : -1;
}
function tX(e, t, n) {
  var i = We.exec(t.slice(n));
  return i ? (e.s = +i[0], n + i[0].length) : -1;
}
function Bx(e, t) {
  return Ht(e.getDate(), t, 2);
}
function eX(e, t) {
  return Ht(e.getHours(), t, 2);
}
function nX(e, t) {
  return Ht(e.getHours() % 12 || 12, t, 2);
}
function iX(e, t) {
  return Ht(1 + aa.count(Di(e), e), t, 3);
}
function l6(e, t) {
  return Ht(e.getMilliseconds(), t, 3);
}
function rX(e, t) {
  return l6(e, t) + "000";
}
function sX(e, t) {
  return Ht(e.getMonth() + 1, t, 2);
}
function oX(e, t) {
  return Ht(e.getMinutes(), t, 2);
}
function aX(e, t) {
  return Ht(e.getSeconds(), t, 2);
}
function cX(e) {
  var t = e.getDay();
  return t === 0 ? 7 : t;
}
function lX(e, t) {
  return Ht(Lc.count(Di(e) - 1, e), t, 2);
}
function u6(e) {
  var t = e.getDay();
  return t >= 4 || t === 0 ? na(e) : na.ceil(e);
}
function uX(e, t) {
  return e = u6(e), Ht(na.count(Di(e), e) + (Di(e).getDay() === 4), t, 2);
}
function fX(e) {
  return e.getDay();
}
function hX(e, t) {
  return Ht(Vu.count(Di(e) - 1, e), t, 2);
}
function dX(e, t) {
  return Ht(e.getFullYear() % 100, t, 2);
}
function pX(e, t) {
  return e = u6(e), Ht(e.getFullYear() % 100, t, 2);
}
function yX(e, t) {
  return Ht(e.getFullYear() % 1e4, t, 4);
}
function mX(e, t) {
  var n = e.getDay();
  return e = n >= 4 || n === 0 ? na(e) : na.ceil(e), Ht(e.getFullYear() % 1e4, t, 4);
}
function gX(e) {
  var t = e.getTimezoneOffset();
  return (t > 0 ? "-" : (t *= -1, "+")) + Ht(t / 60 | 0, "0", 2) + Ht(t % 60, "0", 2);
}
function Ox(e, t) {
  return Ht(e.getUTCDate(), t, 2);
}
function bX(e, t) {
  return Ht(e.getUTCHours(), t, 2);
}
function wX(e, t) {
  return Ht(e.getUTCHours() % 12 || 12, t, 2);
}
function vX(e, t) {
  return Ht(1 + u0.count(Ni(e), e), t, 3);
}
function f6(e, t) {
  return Ht(e.getUTCMilliseconds(), t, 3);
}
function _X(e, t) {
  return f6(e, t) + "000";
}
function xX(e, t) {
  return Ht(e.getUTCMonth() + 1, t, 2);
}
function SX(e, t) {
  return Ht(e.getUTCMinutes(), t, 2);
}
function IX(e, t) {
  return Ht(e.getUTCSeconds(), t, 2);
}
function AX(e) {
  var t = e.getUTCDay();
  return t === 0 ? 7 : t;
}
function MX(e, t) {
  return Ht(Rc.count(Ni(e) - 1, e), t, 2);
}
function h6(e) {
  var t = e.getUTCDay();
  return t >= 4 || t === 0 ? ia(e) : ia.ceil(e);
}
function $X(e, t) {
  return e = h6(e), Ht(ia.count(Ni(e), e) + (Ni(e).getUTCDay() === 4), t, 2);
}
function TX(e) {
  return e.getUTCDay();
}
function DX(e, t) {
  return Ht(ju.count(Ni(e) - 1, e), t, 2);
}
function NX(e, t) {
  return Ht(e.getUTCFullYear() % 100, t, 2);
}
function BX(e, t) {
  return e = h6(e), Ht(e.getUTCFullYear() % 100, t, 2);
}
function OX(e, t) {
  return Ht(e.getUTCFullYear() % 1e4, t, 4);
}
function FX(e, t) {
  var n = e.getUTCDay();
  return e = n >= 4 || n === 0 ? ia(e) : ia.ceil(e), Ht(e.getUTCFullYear() % 1e4, t, 4);
}
function EX() {
  return "+0000";
}
function Fx() {
  return "%";
}
function Ex(e) {
  return +e;
}
function Lx(e) {
  return Math.floor(+e / 1e3);
}
var xa, hw, Ff;
LX({
  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 LX(e) {
  return xa = LG(e), hw = xa.format, xa.parse, Ff = xa.utcFormat, xa.utcParse, xa;
}
function RX(e) {
  return new Date(e);
}
function CX(e) {
  return e instanceof Date ? +e : +/* @__PURE__ */ new Date(+e);
}
function dw(e, t, n, i, r, s, o, a, c, l) {
  var u = V$(), f = u.invert, h = u.domain, d = l(".%L"), p = l(":%S"), y = l("%I:%M"), g = l("%I %p"), m = l("%a %d"), b = l("%b %d"), w = l("%B"), v = l("%Y");
  function _(x) {
    return (c(x) < x ? d : a(x) < x ? p : o(x) < x ? y : s(x) < x ? g : i(x) < x ? r(x) < x ? m : b : n(x) < x ? w : v)(x);
  }
  return u.invert = function(x) {
    return new Date(f(x));
  }, u.domain = function(x) {
    return arguments.length ? h(Array.from(x, CX)) : h().map(RX);
  }, u.ticks = function(x) {
    var I = h();
    return e(I[0], I[I.length - 1], x ?? 10);
  }, u.tickFormat = function(x, I) {
    return I == null ? _ : l(I);
  }, u.nice = function(x) {
    var I = h();
    return (!x || typeof x.range != "function") && (x = t(I[0], I[I.length - 1], x ?? 10)), x ? h(q$(I, x)) : u;
  }, u.copy = function() {
    return Af(u, dw(e, t, n, i, r, s, o, a, c, l));
  }, u;
}
function kX() {
  return br.apply(dw(FG, EG, Di, Bf, Lc, aa, Df, $f, xi, hw).domain([new Date(2e3, 0, 1), new Date(2e3, 0, 2)]), arguments);
}
function UX() {
  return br.apply(dw(OG, c6, Ni, Of, Rc, u0, Nf, Tf, xi, Ff).domain([Date.UTC(2e3, 0, 1), Date.UTC(2e3, 0, 2)]), arguments);
}
function h0(e, t) {
  return t.domain(e.domain()).interpolator(e.interpolator()).clamp(e.clamp()).unknown(e.unknown());
}
function d0() {
  var e = 0, t = 0.5, n = 1, i = 1, r, s, o, a, c, l = ri, u, f = !1, h;
  function d(y) {
    return isNaN(y = +y) ? h : (y = 0.5 + ((y = +u(y)) - s) * (i * y < i * s ? a : c), l(f ? Math.max(0, Math.min(1, y)) : y));
  }
  d.domain = function(y) {
    return arguments.length ? ([e, t, n] = y, r = u(e = +e), s = u(t = +t), o = u(n = +n), a = r === s ? 0 : 0.5 / (s - r), c = s === o ? 0 : 0.5 / (o - s), i = s < r ? -1 : 1, d) : [e, t, n];
  }, d.clamp = function(y) {
    return arguments.length ? (f = !!y, d) : f;
  }, d.interpolator = function(y) {
    return arguments.length ? (l = y, d) : l;
  };
  function p(y) {
    return function(g) {
      var m, b, w;
      return arguments.length ? ([m, b, w] = g, l = e0(y, [m, b, w]), d) : [l(0), l(0.5), l(1)];
    };
  }
  return d.range = p(nl), d.rangeRound = p(Zb), d.unknown = function(y) {
    return arguments.length ? (h = y, d) : h;
  }, function(y) {
    return u = y, r = y(e), s = y(t), o = y(n), a = r === s ? 0 : 0.5 / (s - r), c = s === o ? 0 : 0.5 / (o - s), i = s < r ? -1 : 1, d;
  };
}
function d6() {
  var e = Mf(d0()(ri));
  return e.copy = function() {
    return h0(e, d6());
  }, o0.apply(e, arguments);
}
function p6() {
  var e = Y$(d0()).domain([0.1, 1, 10]);
  return e.copy = function() {
    return h0(e, p6()).base(e.base());
  }, o0.apply(e, arguments);
}
function y6() {
  var e = G$(d0());
  return e.copy = function() {
    return h0(e, y6()).constant(e.constant());
  }, o0.apply(e, arguments);
}
function m6() {
  var e = H$(d0());
  return e.copy = function() {
    return h0(e, m6()).exponent(e.exponent());
  }, o0.apply(e, arguments);
}
function Lt(e) {
  for (var t = e.length / 6 | 0, n = new Array(t), i = 0; i < t; )
    n[i] = "#" + e.slice(i * 6, ++i * 6);
  return n;
}
const zX = Lt("1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf"), PX = Lt("7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666"), VX = Lt("1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666"), jX = Lt("a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928"), qX = Lt("fbb4aeb3cde3ccebc5decbe4fed9a6ffffcce5d8bdfddaecf2f2f2"), YX = Lt("b3e2cdfdcdaccbd5e8f4cae4e6f5c9fff2aef1e2cccccccc"), WX = Lt("e41a1c377eb84daf4a984ea3ff7f00ffff33a65628f781bf999999"), GX = Lt("66c2a5fc8d628da0cbe78ac3a6d854ffd92fe5c494b3b3b3"), XX = Lt("8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f"), HX = Lt("4e79a7f28e2ce1575976b7b259a14fedc949af7aa1ff9da79c755fbab0ab"), le = (e) => QV(e[e.length - 1]);
var g6 = new Array(3).concat(
  "d8b365f5f5f55ab4ac",
  "a6611adfc27d80cdc1018571",
  "a6611adfc27df5f5f580cdc1018571",
  "8c510ad8b365f6e8c3c7eae55ab4ac01665e",
  "8c510ad8b365f6e8c3f5f5f5c7eae55ab4ac01665e",
  "8c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e",
  "8c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e",
  "5430058c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e003c30",
  "5430058c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e003c30"
).map(Lt);
const b6 = le(g6);
var w6 = new Array(3).concat(
  "af8dc3f7f7f77fbf7b",
  "7b3294c2a5cfa6dba0008837",
  "7b3294c2a5cff7f7f7a6dba0008837",
  "762a83af8dc3e7d4e8d9f0d37fbf7b1b7837",
  "762a83af8dc3e7d4e8f7f7f7d9f0d37fbf7b1b7837",
  "762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b7837",
  "762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b7837",
  "40004b762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b783700441b",
  "40004b762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b783700441b"
).map(Lt);
const v6 = le(w6);
var _6 = new Array(3).concat(
  "e9a3c9f7f7f7a1d76a",
  "d01c8bf1b6dab8e1864dac26",
  "d01c8bf1b6daf7f7f7b8e1864dac26",
  "c51b7de9a3c9fde0efe6f5d0a1d76a4d9221",
  "c51b7de9a3c9fde0eff7f7f7e6f5d0a1d76a4d9221",
  "c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221",
  "c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221",
  "8e0152c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221276419",
  "8e0152c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221276419"
).map(Lt);
const x6 = le(_6);
var S6 = new Array(3).concat(
  "998ec3f7f7f7f1a340",
  "5e3c99b2abd2fdb863e66101",
  "5e3c99b2abd2f7f7f7fdb863e66101",
  "542788998ec3d8daebfee0b6f1a340b35806",
  "542788998ec3d8daebf7f7f7fee0b6f1a340b35806",
  "5427888073acb2abd2d8daebfee0b6fdb863e08214b35806",
  "5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b35806",
  "2d004b5427888073acb2abd2d8daebfee0b6fdb863e08214b358067f3b08",
  "2d004b5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b358067f3b08"
).map(Lt);
const I6 = le(S6);
var x1 = new Array(3).concat(
  "ef8a62f7f7f767a9cf",
  "ca0020f4a58292c5de0571b0",
  "ca0020f4a582f7f7f792c5de0571b0",
  "b2182bef8a62fddbc7d1e5f067a9cf2166ac",
  "b2182bef8a62fddbc7f7f7f7d1e5f067a9cf2166ac",
  "b2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac",
  "b2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac",
  "67001fb2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac053061",
  "67001fb2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac053061"
).map(Lt);
const Bp = le(x1);
var A6 = new Array(3).concat(
  "ef8a62ffffff999999",
  "ca0020f4a582bababa404040",
  "ca0020f4a582ffffffbababa404040",
  "b2182bef8a62fddbc7e0e0e09999994d4d4d",
  "b2182bef8a62fddbc7ffffffe0e0e09999994d4d4d",
  "b2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d",
  "b2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d",
  "67001fb2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d1a1a1a",
  "67001fb2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d1a1a1a"
).map(Lt);
const M6 = le(A6);
var S1 = new Array(3).concat(
  "fc8d59ffffbf91bfdb",
  "d7191cfdae61abd9e92c7bb6",
  "d7191cfdae61ffffbfabd9e92c7bb6",
  "d73027fc8d59fee090e0f3f891bfdb4575b4",
  "d73027fc8d59fee090ffffbfe0f3f891bfdb4575b4",
  "d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4",
  "d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4",
  "a50026d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4313695",
  "a50026d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4313695"
).map(Lt);
const Op = le(S1);
var $6 = new Array(3).concat(
  "fc8d59ffffbf91cf60",
  "d7191cfdae61a6d96a1a9641",
  "d7191cfdae61ffffbfa6d96a1a9641",
  "d73027fc8d59fee08bd9ef8b91cf601a9850",
  "d73027fc8d59fee08bffffbfd9ef8b91cf601a9850",
  "d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850",
  "d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850",
  "a50026d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850006837",
  "a50026d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850006837"
).map(Lt);
const T6 = le($6);
var D6 = new Array(3).concat(
  "fc8d59ffffbf99d594",
  "d7191cfdae61abdda42b83ba",
  "d7191cfdae61ffffbfabdda42b83ba",
  "d53e4ffc8d59fee08be6f59899d5943288bd",
  "d53e4ffc8d59fee08bffffbfe6f59899d5943288bd",
  "d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd",
  "d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd",
  "9e0142d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd5e4fa2",
  "9e0142d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd5e4fa2"
).map(Lt);
const N6 = le(D6);
var B6 = new Array(3).concat(
  "e5f5f999d8c92ca25f",
  "edf8fbb2e2e266c2a4238b45",
  "edf8fbb2e2e266c2a42ca25f006d2c",
  "edf8fbccece699d8c966c2a42ca25f006d2c",
  "edf8fbccece699d8c966c2a441ae76238b45005824",
  "f7fcfde5f5f9ccece699d8c966c2a441ae76238b45005824",
  "f7fcfde5f5f9ccece699d8c966c2a441ae76238b45006d2c00441b"
).map(Lt);
const O6 = le(B6);
var F6 = new Array(3).concat(
  "e0ecf49ebcda8856a7",
  "edf8fbb3cde38c96c688419d",
  "edf8fbb3cde38c96c68856a7810f7c",
  "edf8fbbfd3e69ebcda8c96c68856a7810f7c",
  "edf8fbbfd3e69ebcda8c96c68c6bb188419d6e016b",
  "f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d6e016b",
  "f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d810f7c4d004b"
).map(Lt);
const E6 = le(F6);
var L6 = new Array(3).concat(
  "e0f3dba8ddb543a2ca",
  "f0f9e8bae4bc7bccc42b8cbe",
  "f0f9e8bae4bc7bccc443a2ca0868ac",
  "f0f9e8ccebc5a8ddb57bccc443a2ca0868ac",
  "f0f9e8ccebc5a8ddb57bccc44eb3d32b8cbe08589e",
  "f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe08589e",
  "f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe0868ac084081"
).map(Lt);
const R6 = le(L6);
var C6 = new Array(3).concat(
  "fee8c8fdbb84e34a33",
  "fef0d9fdcc8afc8d59d7301f",
  "fef0d9fdcc8afc8d59e34a33b30000",
  "fef0d9fdd49efdbb84fc8d59e34a33b30000",
  "fef0d9fdd49efdbb84fc8d59ef6548d7301f990000",
  "fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301f990000",
  "fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301fb300007f0000"
).map(Lt);
const k6 = le(C6);
var U6 = new Array(3).concat(
  "ece2f0a6bddb1c9099",
  "f6eff7bdc9e167a9cf02818a",
  "f6eff7bdc9e167a9cf1c9099016c59",
  "f6eff7d0d1e6a6bddb67a9cf1c9099016c59",
  "f6eff7d0d1e6a6bddb67a9cf3690c002818a016450",
  "fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016450",
  "fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016c59014636"
).map(Lt);
const z6 = le(U6);
var P6 = new Array(3).concat(
  "ece7f2a6bddb2b8cbe",
  "f1eef6bdc9e174a9cf0570b0",
  "f1eef6bdc9e174a9cf2b8cbe045a8d",
  "f1eef6d0d1e6a6bddb74a9cf2b8cbe045a8d",
  "f1eef6d0d1e6a6bddb74a9cf3690c00570b0034e7b",
  "fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0034e7b",
  "fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0045a8d023858"
).map(Lt);
const V6 = le(P6);
var j6 = new Array(3).concat(
  "e7e1efc994c7dd1c77",
  "f1eef6d7b5d8df65b0ce1256",
  "f1eef6d7b5d8df65b0dd1c77980043",
  "f1eef6d4b9dac994c7df65b0dd1c77980043",
  "f1eef6d4b9dac994c7df65b0e7298ace125691003f",
  "f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125691003f",
  "f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125698004367001f"
).map(Lt);
const q6 = le(j6);
var Y6 = new Array(3).concat(
  "fde0ddfa9fb5c51b8a",
  "feebe2fbb4b9f768a1ae017e",
  "feebe2fbb4b9f768a1c51b8a7a0177",
  "feebe2fcc5c0fa9fb5f768a1c51b8a7a0177",
  "feebe2fcc5c0fa9fb5f768a1dd3497ae017e7a0177",
  "fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a0177",
  "fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a017749006a"
).map(Lt);
const W6 = le(Y6);
var G6 = new Array(3).concat(
  "edf8b17fcdbb2c7fb8",
  "ffffcca1dab441b6c4225ea8",
  "ffffcca1dab441b6c42c7fb8253494",
  "ffffccc7e9b47fcdbb41b6c42c7fb8253494",
  "ffffccc7e9b47fcdbb41b6c41d91c0225ea80c2c84",
  "ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea80c2c84",
  "ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea8253494081d58"
).map(Lt);
const X6 = le(G6);
var H6 = new Array(3).concat(
  "f7fcb9addd8e31a354",
  "ffffccc2e69978c679238443",
  "ffffccc2e69978c67931a354006837",
  "ffffccd9f0a3addd8e78c67931a354006837",
  "ffffccd9f0a3addd8e78c67941ab5d238443005a32",
  "ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443005a32",
  "ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443006837004529"
).map(Lt);
const J6 = le(H6);
var K6 = new Array(3).concat(
  "fff7bcfec44fd95f0e",
  "ffffd4fed98efe9929cc4c02",
  "ffffd4fed98efe9929d95f0e993404",
  "ffffd4fee391fec44ffe9929d95f0e993404",
  "ffffd4fee391fec44ffe9929ec7014cc4c028c2d04",
  "ffffe5fff7bcfee391fec44ffe9929ec7014cc4c028c2d04",
  "ffffe5fff7bcfee391fec44ffe9929ec7014cc4c02993404662506"
).map(Lt);
const Z6 = le(K6);
var Q6 = new Array(3).concat(
  "ffeda0feb24cf03b20",
  "ffffb2fecc5cfd8d3ce31a1c",
  "ffffb2fecc5cfd8d3cf03b20bd0026",
  "ffffb2fed976feb24cfd8d3cf03b20bd0026",
  "ffffb2fed976feb24cfd8d3cfc4e2ae31a1cb10026",
  "ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cb10026",
  "ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cbd0026800026"
).map(Lt);
const tT = le(Q6);
var eT = new Array(3).concat(
  "deebf79ecae13182bd",
  "eff3ffbdd7e76baed62171b5",
  "eff3ffbdd7e76baed63182bd08519c",
  "eff3ffc6dbef9ecae16baed63182bd08519c",
  "eff3ffc6dbef9ecae16baed64292c62171b5084594",
  "f7fbffdeebf7c6dbef9ecae16baed64292c62171b5084594",
  "f7fbffdeebf7c6dbef9ecae16baed64292c62171b508519c08306b"
).map(Lt);
const nT = le(eT);
var iT = new Array(3).concat(
  "e5f5e0a1d99b31a354",
  "edf8e9bae4b374c476238b45",
  "edf8e9bae4b374c47631a354006d2c",
  "edf8e9c7e9c0a1d99b74c47631a354006d2c",
  "edf8e9c7e9c0a1d99b74c47641ab5d238b45005a32",
  "f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45005a32",
  "f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45006d2c00441b"
).map(Lt);
const rT = le(iT);
var sT = new Array(3).concat(
  "f0f0f0bdbdbd636363",
  "f7f7f7cccccc969696525252",
  "f7f7f7cccccc969696636363252525",
  "f7f7f7d9d9d9bdbdbd969696636363252525",
  "f7f7f7d9d9d9bdbdbd969696737373525252252525",
  "fffffff0f0f0d9d9d9bdbdbd969696737373525252252525",
  "fffffff0f0f0d9d9d9bdbdbd969696737373525252252525000000"
).map(Lt);
const oT = le(sT);
var aT = new Array(3).concat(
  "efedf5bcbddc756bb1",
  "f2f0f7cbc9e29e9ac86a51a3",
  "f2f0f7cbc9e29e9ac8756bb154278f",
  "f2f0f7dadaebbcbddc9e9ac8756bb154278f",
  "f2f0f7dadaebbcbddc9e9ac8807dba6a51a34a1486",
  "fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a34a1486",
  "fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a354278f3f007d"
).map(Lt);
const cT = le(aT);
var lT = new Array(3).concat(
  "fee0d2fc9272de2d26",
  "fee5d9fcae91fb6a4acb181d",
  "fee5d9fcae91fb6a4ade2d26a50f15",
  "fee5d9fcbba1fc9272fb6a4ade2d26a50f15",
  "fee5d9fcbba1fc9272fb6a4aef3b2ccb181d99000d",
  "fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181d99000d",
  "fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181da50f1567000d"
).map(Lt);
const uT = le(lT);
var fT = new Array(3).concat(
  "fee6cefdae6be6550d",
  "feeddefdbe85fd8d3cd94701",
  "feeddefdbe85fd8d3ce6550da63603",
  "feeddefdd0a2fdae6bfd8d3ce6550da63603",
  "feeddefdd0a2fdae6bfd8d3cf16913d948018c2d04",
  "fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d948018c2d04",
  "fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d94801a636037f2704"
).map(Lt);
const hT = le(fT);
function dT(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 pT = Qb(hr(300, 0.5, 0), hr(-240, 0.5, 1));
var yT = Qb(hr(-100, 0.75, 0.35), hr(80, 1.5, 0.8)), mT = Qb(hr(260, 0.75, 0.35), hr(80, 1.5, 0.8)), _h = hr();
function gT(e) {
  (e < 0 || e > 1) && (e -= Math.floor(e));
  var t = Math.abs(e - 0.5);
  return _h.h = 360 * e - 100, _h.s = 1.5 - 1.5 * t, _h.l = 0.8 - 0.9 * t, _h + "";
}
var xh = Pn(), JX = Math.PI / 3, KX = Math.PI * 2 / 3;
function bT(e) {
  var t;
  return e = (0.5 - e) * Math.PI, xh.r = 255 * (t = Math.sin(e)) * t, xh.g = 255 * (t = Math.sin(e + JX)) * t, xh.b = 255 * (t = Math.sin(e + KX)) * t, xh + "";
}
function wT(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 p0(e) {
  var t = e.length;
  return function(n) {
    return e[Math.max(0, Math.min(t - 1, Math.floor(n * t)))];
  };
}
const vT = p0(Lt("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725"));
var _T = p0(Lt("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf")), xT = p0(Lt("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4")), ST = p0(Lt("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921"));
function je(e) {
  return function() {
    return e;
  };
}
const IT = Math.cos, pw = Math.min, Fp = Math.sin, ze = Math.sqrt, Rx = 1e-12, Ep = Math.PI, y0 = 2 * Ep;
function AT(e) {
  let t = 3;
  return e.digits = function(n) {
    if (!arguments.length)
      return t;
    if (n == null)
      t = null;
    else {
      const i = Math.floor(n);
      if (!(i >= 0))
        throw new RangeError(`invalid digits: ${n}`);
      t = i;
    }
    return e;
  }, () => new Z3(t);
}
function MT(e) {
  return typeof e == "object" && "length" in e ? e : Array.from(e);
}
function $T(e) {
  this._context = e;
}
$T.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 Ef(e) {
  return new $T(e);
}
function TT(e) {
  return e[0];
}
function DT(e) {
  return e[1];
}
function NT(e, t) {
  var n = je(!0), i = null, r = Ef, s = null, o = AT(a);
  e = typeof e == "function" ? e : e === void 0 ? TT : je(e), t = typeof t == "function" ? t : t === void 0 ? DT : je(t);
  function a(c) {
    var l, u = (c = MT(c)).length, f, h = !1, d;
    for (i == null && (s = r(d = o())), l = 0; l <= u; ++l)
      !(l < u && n(f = c[l], l, c)) === h && ((h = !h) ? s.lineStart() : s.lineEnd()), h && s.point(+e(f, l, c), +t(f, l, c));
    if (d)
      return s = null, d + "" || null;
  }
  return a.x = function(c) {
    return arguments.length ? (e = typeof c == "function" ? c : je(+c), a) : e;
  }, a.y = function(c) {
    return arguments.length ? (t = typeof c == "function" ? c : je(+c), a) : t;
  }, a.defined = function(c) {
    return arguments.length ? (n = typeof c == "function" ? c : je(!!c), a) : n;
  }, a.curve = function(c) {
    return arguments.length ? (r = c, i != null && (s = r(i)), a) : r;
  }, a.context = function(c) {
    return arguments.length ? (c == null ? i = s = null : s = r(i = c), a) : i;
  }, a;
}
function yw(e, t, n) {
  var i = null, r = je(!0), s = null, o = Ef, a = null, c = AT(l);
  e = typeof e == "function" ? e : e === void 0 ? TT : je(+e), t = typeof t == "function" ? t : je(t === void 0 ? 0 : +t), n = typeof n == "function" ? n : n === void 0 ? DT : je(+n);
  function l(f) {
    var h, d, p, y = (f = MT(f)).length, g, m = !1, b, w = new Array(y), v = new Array(y);
    for (s == null && (a = o(b = c())), h = 0; h <= y; ++h) {
      if (!(h < y && r(g = f[h], h, f)) === m)
        if (m = !m)
          d = h, a.areaStart(), a.lineStart();
        else {
          for (a.lineEnd(), a.lineStart(), p = h - 1; p >= d; --p)
            a.point(w[p], v[p]);
          a.lineEnd(), a.areaEnd();
        }
      m && (w[h] = +e(g, h, f), v[h] = +t(g, h, f), a.point(i ? +i(g, h, f) : w[h], n ? +n(g, h, f) : v[h]));
    }
    if (b)
      return a = null, b + "" || null;
  }
  function u() {
    return NT().defined(r).curve(o).context(s);
  }
  return l.x = function(f) {
    return arguments.length ? (e = typeof f == "function" ? f : je(+f), i = null, l) : e;
  }, l.x0 = function(f) {
    return arguments.length ? (e = typeof f == "function" ? f : je(+f), l) : e;
  }, l.x1 = function(f) {
    return arguments.length ? (i = f == null ? null : typeof f == "function" ? f : je(+f), l) : i;
  }, l.y = function(f) {
    return arguments.length ? (t = typeof f == "function" ? f : je(+f), n = null, l) : t;
  }, l.y0 = function(f) {
    return arguments.length ? (t = typeof f == "function" ? f : je(+f), l) : t;
  }, l.y1 = function(f) {
    return arguments.length ? (n = f == null ? null : typeof f == "function" ? f : je(+f), l) : n;
  }, l.lineX0 = l.lineY0 = function() {
    return u().x(e).y(t);
  }, l.lineY1 = function() {
    return u().x(e).y(n);
  }, l.lineX1 = function() {
    return u().x(i).y(t);
  }, l.defined = function(f) {
    return arguments.length ? (r = typeof f == "function" ? f : je(!!f), l) : r;
  }, l.curve = function(f) {
    return arguments.length ? (o = f, s != null && (a = o(s)), l) : o;
  }, l.context = function(f) {
    return arguments.length ? (f == null ? s = a = null : a = o(s = f), l) : s;
  }, l;
}
class BT {
  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 ZX(e) {
  return new BT(e, !0);
}
function QX(e) {
  return new BT(e, !1);
}
const tH = ze(3), OT = {
  draw(e, t) {
    const n = ze(t + pw(t / 28, 0.75)) * 0.59436, i = n / 2, r = i * tH;
    e.moveTo(0, n), e.lineTo(0, -n), e.moveTo(-r, -i), e.lineTo(r, i), e.moveTo(-r, i), e.lineTo(r, -i);
  }
}, qu = {
  draw(e, t) {
    const n = ze(t / Ep);
    e.moveTo(n, 0), e.arc(0, 0, n, 0, y0);
  }
}, FT = {
  draw(e, t) {
    const n = ze(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();
  }
}, ET = ze(1 / 3), eH = ET * 2, LT = {
  draw(e, t) {
    const n = ze(t / eH), i = n * ET;
    e.moveTo(0, -n), e.lineTo(i, 0), e.lineTo(0, n), e.lineTo(-i, 0), e.closePath();
  }
}, RT = {
  draw(e, t) {
    const n = ze(t) * 0.62625;
    e.moveTo(0, -n), e.lineTo(n, 0), e.lineTo(0, n), e.lineTo(-n, 0), e.closePath();
  }
}, CT = {
  draw(e, t) {
    const n = ze(t - pw(t / 7, 2)) * 0.87559;
    e.moveTo(-n, 0), e.lineTo(n, 0), e.moveTo(0, n), e.lineTo(0, -n);
  }
}, kT = {
  draw(e, t) {
    const n = ze(t), i = -n / 2;
    e.rect(i, i, n, n);
  }
}, UT = {
  draw(e, t) {
    const n = ze(t) * 0.4431;
    e.moveTo(n, n), e.lineTo(n, -n), e.lineTo(-n, -n), e.lineTo(-n, n), e.closePath();
  }
}, nH = 0.8908130915292852, zT = Fp(Ep / 10) / Fp(7 * Ep / 10), iH = Fp(y0 / 10) * zT, rH = -IT(y0 / 10) * zT, PT = {
  draw(e, t) {
    const n = ze(t * nH), i = iH * n, r = rH * n;
    e.moveTo(0, -n), e.lineTo(i, r);
    for (let s = 1; s < 5; ++s) {
      const o = y0 * s / 5, a = IT(o), c = Fp(o);
      e.lineTo(c * n, -a * n), e.lineTo(a * i - c * r, c * i + a * r);
    }
    e.closePath();
  }
}, Lm = ze(3), VT = {
  draw(e, t) {
    const n = -ze(t / (Lm * 3));
    e.moveTo(0, n * 2), e.lineTo(-Lm * n, -n), e.lineTo(Lm * n, -n), e.closePath();
  }
}, sH = ze(3), jT = {
  draw(e, t) {
    const n = ze(t) * 0.6824, i = n / 2, r = n * sH / 2;
    e.moveTo(0, -n), e.lineTo(r, i), e.lineTo(-r, i), e.closePath();
  }
}, Yn = -0.5, Wn = ze(3) / 2, I1 = 1 / ze(12), oH = (I1 / 2 + 1) * 3, qT = {
  draw(e, t) {
    const n = ze(t / oH), i = n / 2, r = n * I1, s = i, o = n * I1 + n, a = -s, c = o;
    e.moveTo(i, r), e.lineTo(s, o), e.lineTo(a, c), e.lineTo(Yn * i - Wn * r, Wn * i + Yn * r), e.lineTo(Yn * s - Wn * o, Wn * s + Yn * o), e.lineTo(Yn * a - Wn * c, Wn * a + Yn * c), e.lineTo(Yn * i + Wn * r, Yn * r - Wn * i), e.lineTo(Yn * s + Wn * o, Yn * o - Wn * s), e.lineTo(Yn * a + Wn * c, Yn * c - Wn * a), e.closePath();
  }
}, YT = {
  draw(e, t) {
    const n = ze(t - pw(t / 6, 1.7)) * 0.6189;
    e.moveTo(-n, -n), e.lineTo(n, n), e.moveTo(-n, n), e.lineTo(n, -n);
  }
}, aH = [
  qu,
  FT,
  LT,
  kT,
  PT,
  VT,
  qT
], cH = [
  qu,
  CT,
  YT,
  jT,
  OT,
  UT,
  RT
];
function Gs() {
}
function Lp(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 m0(e) {
  this._context = e;
}
m0.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:
        Lp(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:
        Lp(this, e, t);
        break;
    }
    this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t;
  }
};
function lH(e) {
  return new m0(e);
}
function WT(e) {
  this._context = e;
}
WT.prototype = {
  areaStart: Gs,
  areaEnd: Gs,
  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:
        Lp(this, e, t);
        break;
    }
    this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t;
  }
};
function uH(e) {
  return new WT(e);
}
function GT(e) {
  this._context = e;
}
GT.prototype = {
  areaStart: function() {
    this._line = 0;
  },
  areaEnd: function() {
    this._line = NaN;
  },
  lineStart: function() {
    this._x0 = this._x1 = this._y0 = this._y1 = NaN, this._point = 0;
  },
  lineEnd: function() {
    (this._line || this._line !== 0 && this._point === 3) && this._context.closePath(), this._line = 1 - this._line;
  },
  point: function(e, t) {
    switch (e = +e, t = +t, this._point) {
      case 0:
        this._point = 1;
        break;
      case 1:
        this._point = 2;
        break;
      case 2:
        this._point = 3;
        var n = (this._x0 + 4 * this._x1 + e) / 6, i = (this._y0 + 4 * this._y1 + t) / 6;
        this._line ? this._context.lineTo(n, i) : this._context.moveTo(n, i);
        break;
      case 3:
        this._point = 4;
      default:
        Lp(this, e, t);
        break;
    }
    this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t;
  }
};
function fH(e) {
  return new GT(e);
}
function XT(e, t) {
  this._basis = new m0(e), this._beta = t;
}
XT.prototype = {
  lineStart: function() {
    this._x = [], this._y = [], this._basis.lineStart();
  },
  lineEnd: function() {
    var e = this._x, t = this._y, n = e.length - 1;
    if (n > 0)
      for (var i = e[0], r = t[0], s = e[n] - i, o = t[n] - r, a = -1, c; ++a <= n; )
        c = a / n, this._basis.point(
          this._beta * e[a] + (1 - this._beta) * (i + c * s),
          this._beta * t[a] + (1 - this._beta) * (r + c * o)
        );
    this._x = this._y = null, this._basis.lineEnd();
  },
  point: function(e, t) {
    this._x.push(+e), this._y.push(+t);
  }
};
const hH = function e(t) {
  function n(i) {
    return t === 1 ? new m0(i) : new XT(i, t);
  }
  return n.beta = function(i) {
    return e(+i);
  }, n;
}(0.85);
function Rp(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 mw(e, t) {
  this._context = e, this._k = (1 - t) / 6;
}
mw.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:
        Rp(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:
        Rp(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 dH = function e(t) {
  function n(i) {
    return new mw(i, t);
  }
  return n.tension = function(i) {
    return e(+i);
  }, n;
}(0);
function gw(e, t) {
  this._context = e, this._k = (1 - t) / 6;
}
gw.prototype = {
  areaStart: Gs,
  areaEnd: Gs,
  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:
        Rp(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 pH = function e(t) {
  function n(i) {
    return new gw(i, t);
  }
  return n.tension = function(i) {
    return e(+i);
  }, n;
}(0);
function bw(e, t) {
  this._context = e, this._k = (1 - t) / 6;
}
bw.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:
        Rp(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 yH = function e(t) {
  function n(i) {
    return new bw(i, t);
  }
  return n.tension = function(i) {
    return e(+i);
  }, n;
}(0);
function ww(e, t, n) {
  var i = e._x1, r = e._y1, s = e._x2, o = e._y2;
  if (e._l01_a > Rx) {
    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);
    i = (i * a - e._x0 * e._l12_2a + e._x2 * e._l01_2a) / c, r = (r * a - e._y0 * e._l12_2a + e._y2 * e._l01_2a) / c;
  }
  if (e._l23_a > Rx) {
    var l = 2 * e._l23_2a + 3 * e._l23_a * e._l12_a + e._l12_2a, u = 3 * e._l23_a * (e._l23_a + e._l12_a);
    s = (s * l + e._x1 * e._l23_2a - t * e._l12_2a) / u, o = (o * l + e._y1 * e._l23_2a - n * e._l12_2a) / u;
  }
  e._context.bezierCurveTo(i, r, s, o, e._x2, e._y2);
}
function HT(e, t) {
  this._context = e, this._alpha = t;
}
HT.prototype = {
  areaStart: function() {
    this._line = 0;
  },
  areaEnd: function() {
    this._line = NaN;
  },
  lineStart: function() {
    this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN, this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
  },
  lineEnd: function() {
    switch (this._point) {
      case 2:
        this._context.lineTo(this._x2, this._y2);
        break;
      case 3:
        this.point(this._x2, this._y2);
        break;
    }
    (this._line || this._line !== 0 && this._point === 1) && this._context.closePath(), this._line = 1 - this._line;
  },
  point: function(e, t) {
    if (e = +e, t = +t, this._point) {
      var n = this._x2 - e, i = this._y2 - t;
      this._l23_a = Math.sqrt(this._l23_2a = Math.pow(n * n + i * i, this._alpha));
    }
    switch (this._point) {
      case 0:
        this._point = 1, this._line ? this._context.lineTo(e, t) : this._context.moveTo(e, t);
        break;
      case 1:
        this._point = 2;
        break;
      case 2:
        this._point = 3;
      default:
        ww(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 mH = function e(t) {
  function n(i) {
    return t ? new HT(i, t) : new mw(i, 0);
  }
  return n.alpha = function(i) {
    return e(+i);
  }, n;
}(0.5);
function JT(e, t) {
  this._context = e, this._alpha = t;
}
JT.prototype = {
  areaStart: Gs,
  areaEnd: Gs,
  lineStart: function() {
    this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN, this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
  },
  lineEnd: function() {
    switch (this._point) {
      case 1: {
        this._context.moveTo(this._x3, this._y3), this._context.closePath();
        break;
      }
      case 2: {
        this._context.lineTo(this._x3, this._y3), this._context.closePath();
        break;
      }
      case 3: {
        this.point(this._x3, this._y3), this.point(this._x4, this._y4), this.point(this._x5, this._y5);
        break;
      }
    }
  },
  point: function(e, t) {
    if (e = +e, t = +t, this._point) {
      var n = this._x2 - e, i = this._y2 - t;
      this._l23_a = Math.sqrt(this._l23_2a = Math.pow(n * n + i * i, this._alpha));
    }
    switch (this._point) {
      case 0:
        this._point = 1, this._x3 = e, this._y3 = t;
        break;
      case 1:
        this._point = 2, this._context.moveTo(this._x4 = e, this._y4 = t);
        break;
      case 2:
        this._point = 3, this._x5 = e, this._y5 = t;
        break;
      default:
        ww(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 gH = function e(t) {
  function n(i) {
    return t ? new JT(i, t) : new gw(i, 0);
  }
  return n.alpha = function(i) {
    return e(+i);
  }, n;
}(0.5);
function KT(e, t) {
  this._context = e, this._alpha = t;
}
KT.prototype = {
  areaStart: function() {
    this._line = 0;
  },
  areaEnd: function() {
    this._line = NaN;
  },
  lineStart: function() {
    this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN, this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
  },
  lineEnd: function() {
    (this._line || this._line !== 0 && this._point === 3) && this._context.closePath(), this._line = 1 - this._line;
  },
  point: function(e, t) {
    if (e = +e, t = +t, this._point) {
      var n = this._x2 - e, i = this._y2 - t;
      this._l23_a = Math.sqrt(this._l23_2a = Math.pow(n * n + i * i, this._alpha));
    }
    switch (this._point) {
      case 0:
        this._point = 1;
        break;
      case 1:
        this._point = 2;
        break;
      case 2:
        this._point = 3, this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2);
        break;
      case 3:
        this._point = 4;
      default:
        ww(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 bH = function e(t) {
  function n(i) {
    return t ? new KT(i, t) : new bw(i, 0);
  }
  return n.alpha = function(i) {
    return e(+i);
  }, n;
}(0.5);
function ZT(e) {
  this._context = e;
}
ZT.prototype = {
  areaStart: Gs,
  areaEnd: Gs,
  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 wH(e) {
  return new ZT(e);
}
function Cx(e) {
  return e < 0 ? -1 : 1;
}
function kx(e, t, n) {
  var i = e._x1 - e._x0, r = t - e._x1, s = (e._y1 - e._y0) / (i || r < 0 && -0), o = (n - e._y1) / (r || i < 0 && -0), a = (s * r + o * i) / (i + r);
  return (Cx(s) + Cx(o)) * Math.min(Math.abs(s), Math.abs(o), 0.5 * Math.abs(a)) || 0;
}
function Ux(e, t) {
  var n = e._x1 - e._x0;
  return n ? (3 * (e._y1 - e._y0) / n - t) / 2 : t;
}
function Rm(e, t, n) {
  var i = e._x0, r = e._y0, s = e._x1, o = e._y1, a = (s - i) / 3;
  e._context.bezierCurveTo(i + a, r + a * t, s - a, o - a * n, s, o);
}
function Cp(e) {
  this._context = e;
}
Cp.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:
        Rm(this, this._t0, Ux(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, Rm(this, Ux(this, n = kx(this, e, t)), n);
          break;
        default:
          Rm(this, this._t0, n = kx(this, e, t));
          break;
      }
      this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t, this._t0 = n;
    }
  }
};
function QT(e) {
  this._context = new tD(e);
}
(QT.prototype = Object.create(Cp.prototype)).point = function(e, t) {
  Cp.prototype.point.call(this, t, e);
};
function tD(e) {
  this._context = e;
}
tD.prototype = {
  moveTo: function(e, t) {
    this._context.moveTo(t, e);
  },
  closePath: function() {
    this._context.closePath();
  },
  lineTo: function(e, t) {
    this._context.lineTo(t, e);
  },
  bezierCurveTo: function(e, t, n, i, r, s) {
    this._context.bezierCurveTo(t, e, i, n, s, r);
  }
};
function vH(e) {
  return new Cp(e);
}
function _H(e) {
  return new QT(e);
}
function eD(e) {
  this._context = e;
}
eD.prototype = {
  areaStart: function() {
    this._line = 0;
  },
  areaEnd: function() {
    this._line = NaN;
  },
  lineStart: function() {
    this._x = [], this._y = [];
  },
  lineEnd: function() {
    var e = this._x, t = this._y, n = e.length;
    if (n)
      if (this._line ? this._context.lineTo(e[0], t[0]) : this._context.moveTo(e[0], t[0]), n === 2)
        this._context.lineTo(e[1], t[1]);
      else
        for (var i = zx(e), r = zx(t), s = 0, o = 1; o < n; ++s, ++o)
          this._context.bezierCurveTo(i[0][s], r[0][s], i[1][s], r[1][s], e[o], t[o]);
    (this._line || this._line !== 0 && n === 1) && this._context.closePath(), this._line = 1 - this._line, this._x = this._y = null;
  },
  point: function(e, t) {
    this._x.push(+e), this._y.push(+t);
  }
};
function zx(e) {
  var t, n = e.length - 1, i, r = new Array(n), s = new Array(n), o = new Array(n);
  for (r[0] = 0, s[0] = 2, o[0] = e[0] + 2 * e[1], t = 1; t < n - 1; ++t)
    r[t] = 1, s[t] = 4, o[t] = 4 * e[t] + 2 * e[t + 1];
  for (r[n - 1] = 2, s[n - 1] = 7, o[n - 1] = 8 * e[n - 1] + e[n], t = 1; t < n; ++t)
    i = r[t] / s[t - 1], s[t] -= i, o[t] -= i * o[t - 1];
  for (r[n - 1] = o[n - 1] / s[n - 1], t = n - 2; t >= 0; --t)
    r[t] = (o[t] - r[t + 1]) / s[t];
  for (s[n - 1] = (e[n] + r[n - 1]) / 2, t = 0; t < n - 1; ++t)
    s[t] = 2 * e[t + 1] - r[t + 1];
  return [r, s];
}
function xH(e) {
  return new eD(e);
}
function g0(e, t) {
  this._context = e, this._t = t;
}
g0.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 SH(e) {
  return new g0(e, 0.5);
}
function IH(e) {
  return new g0(e, 0);
}
function AH(e) {
  return new g0(e, 1);
}
const Sh = (e) => () => e;
function MH(e, {
  sourceEvent: t,
  target: n,
  transform: i,
  dispatch: r
}) {
  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: i, enumerable: !0, configurable: !0 },
    _: { value: r }
  });
}
function ir(e, t, n) {
  this.k = e, this.x = t, this.y = n;
}
ir.prototype = {
  constructor: ir,
  scale: function(e) {
    return e === 1 ? this : new ir(this.k * e, this.x, this.y);
  },
  translate: function(e, t) {
    return e === 0 & t === 0 ? this : new ir(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 nD = new ir(1, 0, 0);
ir.prototype;
function Cm(e) {
  e.stopImmediatePropagation();
}
function Ml(e) {
  e.preventDefault(), e.stopImmediatePropagation();
}
function $H(e) {
  return (!e.ctrlKey || e.type === "wheel") && !e.button;
}
function TH() {
  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 Px() {
  return this.__zoom || nD;
}
function DH(e) {
  return -e.deltaY * (e.deltaMode === 1 ? 0.05 : e.deltaMode ? 1 : 2e-3) * (e.ctrlKey ? 10 : 1);
}
function NH() {
  return navigator.maxTouchPoints || "ontouchstart" in this;
}
function BH(e, t, n) {
  var i = e.invertX(t[0][0]) - n[0][0], r = 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(
    r > i ? (i + r) / 2 : Math.min(0, i) || Math.max(0, r),
    o > s ? (s + o) / 2 : Math.min(0, s) || Math.max(0, o)
  );
}
function OH() {
  var e = $H, t = TH, n = BH, i = DH, r = NH, s = [0, 1 / 0], o = [[-1 / 0, -1 / 0], [1 / 0, 1 / 0]], a = 250, c = pj, l = Jy("start", "zoom", "end"), u, f, h, d = 500, p = 150, y = 0, g = 10;
  function m(S) {
    S.property("__zoom", Px).on("wheel.zoom", N, { passive: !1 }).on("mousedown.zoom", A).on("dblclick.zoom", D).filter(r).on("touchstart.zoom", M).on("touchmove.zoom", B).on("touchend.zoom touchcancel.zoom", R).style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
  }
  m.transform = function(S, $, T, L) {
    var k = S.selection ? S.selection() : S;
    k.property("__zoom", Px), S !== k ? _(S, $, T, L) : k.interrupt().each(function() {
      x(this, arguments).event(L).start().zoom(null, typeof $ == "function" ? $.apply(this, arguments) : $).end();
    });
  }, m.scaleBy = function(S, $, T, L) {
    m.scaleTo(S, function() {
      var k = this.__zoom.k, U = typeof $ == "function" ? $.apply(this, arguments) : $;
      return k * U;
    }, T, L);
  }, m.scaleTo = function(S, $, T, L) {
    m.transform(S, function() {
      var k = t.apply(this, arguments), U = this.__zoom, C = T == null ? v(k) : typeof T == "function" ? T.apply(this, arguments) : T, z = U.invert(C), P = typeof $ == "function" ? $.apply(this, arguments) : $;
      return n(w(b(U, P), C, z), k, o);
    }, T, L);
  }, m.translateBy = function(S, $, T, L) {
    m.transform(S, function() {
      return n(this.__zoom.translate(
        typeof $ == "function" ? $.apply(this, arguments) : $,
        typeof T == "function" ? T.apply(this, arguments) : T
      ), t.apply(this, arguments), o);
    }, null, L);
  }, m.translateTo = function(S, $, T, L, k) {
    m.transform(S, function() {
      var U = t.apply(this, arguments), C = this.__zoom, z = L == null ? v(U) : typeof L == "function" ? L.apply(this, arguments) : L;
      return n(nD.translate(z[0], z[1]).scale(C.k).translate(
        typeof $ == "function" ? -$.apply(this, arguments) : -$,
        typeof T == "function" ? -T.apply(this, arguments) : -T
      ), U, o);
    }, L, k);
  };
  function b(S, $) {
    return $ = Math.max(s[0], Math.min(s[1], $)), $ === S.k ? S : new ir($, S.x, S.y);
  }
  function w(S, $, T) {
    var L = $[0] - T[0] * S.k, k = $[1] - T[1] * S.k;
    return L === S.x && k === S.y ? S : new ir(S.k, L, k);
  }
  function v(S) {
    return [(+S[0][0] + +S[1][0]) / 2, (+S[0][1] + +S[1][1]) / 2];
  }
  function _(S, $, T, L) {
    S.on("start.zoom", function() {
      x(this, arguments).event(L).start();
    }).on("interrupt.zoom end.zoom", function() {
      x(this, arguments).event(L).end();
    }).tween("zoom", function() {
      var k = this, U = arguments, C = x(k, U).event(L), z = t.apply(k, U), P = T == null ? v(z) : typeof T == "function" ? T.apply(k, U) : T, G = Math.max(z[1][0] - z[0][0], z[1][1] - z[0][1]), K = k.__zoom, tt = typeof $ == "function" ? $.apply(k, U) : $, Z = c(K.invert(P).concat(G / K.k), tt.invert(P).concat(G / tt.k));
      return function(Y) {
        if (Y === 1)
          Y = tt;
        else {
          var X = Z(Y), j = G / X[2];
          Y = new ir(j, P[0] - X[0] * j, P[1] - X[1] * j);
        }
        C.zoom(null, Y);
      };
    });
  }
  function x(S, $, T) {
    return !T && S.__zooming || new I(S, $);
  }
  function I(S, $) {
    this.that = S, this.args = $, this.active = 0, this.sourceEvent = null, this.extent = t.apply(S, $), this.taps = 0;
  }
  I.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, $) {
      return this.mouse && S !== "mouse" && (this.mouse[1] = $.invert(this.mouse[0])), this.touch0 && S !== "touch" && (this.touch0[1] = $.invert(this.touch0[0])), this.touch1 && S !== "touch" && (this.touch1[1] = $.invert(this.touch1[0])), this.that.__zoom = $, this.emit("zoom"), this;
    },
    end: function() {
      return --this.active === 0 && (delete this.that.__zooming, this.emit("end")), this;
    },
    emit: function(S) {
      var $ = ce(this.that).datum();
      l.call(
        S,
        this.that,
        new MH(S, {
          sourceEvent: this.sourceEvent,
          target: m,
          type: S,
          transform: this.that.__zoom,
          dispatch: l
        }),
        $
      );
    }
  };
  function N(S, ...$) {
    if (!e.apply(this, arguments))
      return;
    var T = x(this, $).event(S), L = this.__zoom, k = Math.max(s[0], Math.min(s[1], L.k * Math.pow(2, i.apply(this, arguments)))), U = yi(S);
    if (T.wheel)
      (T.mouse[0][0] !== U[0] || T.mouse[0][1] !== U[1]) && (T.mouse[1] = L.invert(T.mouse[0] = U)), clearTimeout(T.wheel);
    else {
      if (L.k === k)
        return;
      T.mouse = [U, L.invert(U)], hc(this), T.start();
    }
    Ml(S), T.wheel = setTimeout(C, p), T.zoom("mouse", n(w(b(L, k), T.mouse[0], T.mouse[1]), T.extent, o));
    function C() {
      T.wheel = null, T.end();
    }
  }
  function A(S, ...$) {
    if (h || !e.apply(this, arguments))
      return;
    var T = S.currentTarget, L = x(this, $, !0).event(S), k = ce(S.view).on("mousemove.zoom", P, !0).on("mouseup.zoom", G, !0), U = yi(S, T), C = S.clientX, z = S.clientY;
    M3(S.view), Cm(S), L.mouse = [U, this.__zoom.invert(U)], hc(this), L.start();
    function P(K) {
      if (Ml(K), !L.moved) {
        var tt = K.clientX - C, Z = K.clientY - z;
        L.moved = tt * tt + Z * Z > y;
      }
      L.event(K).zoom("mouse", n(w(L.that.__zoom, L.mouse[0] = yi(K, T), L.mouse[1]), L.extent, o));
    }
    function G(K) {
      k.on("mousemove.zoom mouseup.zoom", null), $3(K.view, L.moved), Ml(K), L.event(K).end();
    }
  }
  function D(S, ...$) {
    if (e.apply(this, arguments)) {
      var T = this.__zoom, L = yi(S.changedTouches ? S.changedTouches[0] : S, this), k = T.invert(L), U = T.k * (S.shiftKey ? 0.5 : 2), C = n(w(b(T, U), L, k), t.apply(this, $), o);
      Ml(S), a > 0 ? ce(this).transition().duration(a).call(_, C, L, S) : ce(this).call(m.transform, C, L, S);
    }
  }
  function M(S, ...$) {
    if (e.apply(this, arguments)) {
      var T = S.touches, L = T.length, k = x(this, $, S.changedTouches.length === L).event(S), U, C, z, P;
      for (Cm(S), C = 0; C < L; ++C)
        z = T[C], P = yi(z, this), P = [P, this.__zoom.invert(P), z.identifier], k.touch0 ? !k.touch1 && k.touch0[2] !== P[2] && (k.touch1 = P, k.taps = 0) : (k.touch0 = P, U = !0, k.taps = 1 + !!u);
      u && (u = clearTimeout(u)), U && (k.taps < 2 && (f = P[0], u = setTimeout(function() {
        u = null;
      }, d)), hc(this), k.start());
    }
  }
  function B(S, ...$) {
    if (this.__zooming) {
      var T = x(this, $).event(S), L = S.changedTouches, k = L.length, U, C, z, P;
      for (Ml(S), U = 0; U < k; ++U)
        C = L[U], z = yi(C, this), T.touch0 && T.touch0[2] === C.identifier ? T.touch0[0] = z : T.touch1 && T.touch1[2] === C.identifier && (T.touch1[0] = z);
      if (C = T.that.__zoom, T.touch1) {
        var G = T.touch0[0], K = T.touch0[1], tt = T.touch1[0], Z = T.touch1[1], Y = (Y = tt[0] - G[0]) * Y + (Y = tt[1] - G[1]) * Y, X = (X = Z[0] - K[0]) * X + (X = Z[1] - K[1]) * X;
        C = b(C, Math.sqrt(Y / X)), z = [(G[0] + tt[0]) / 2, (G[1] + tt[1]) / 2], P = [(K[0] + Z[0]) / 2, (K[1] + Z[1]) / 2];
      } else if (T.touch0)
        z = T.touch0[0], P = T.touch0[1];
      else
        return;
      T.zoom("touch", n(w(C, z, P), T.extent, o));
    }
  }
  function R(S, ...$) {
    if (this.__zooming) {
      var T = x(this, $).event(S), L = S.changedTouches, k = L.length, U, C;
      for (Cm(S), h && clearTimeout(h), h = setTimeout(function() {
        h = null;
      }, d), U = 0; U < k; ++U)
        C = L[U], T.touch0 && T.touch0[2] === C.identifier ? delete T.touch0 : T.touch1 && T.touch1[2] === C.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 && (C = yi(C, this), Math.hypot(f[0] - C[0], f[1] - C[1]) < g)) {
        var z = ce(this).on("dblclick.zoom");
        z && z.apply(this, arguments);
      }
    }
  }
  return m.wheelDelta = function(S) {
    return arguments.length ? (i = typeof S == "function" ? S : Sh(+S), m) : i;
  }, m.filter = function(S) {
    return arguments.length ? (e = typeof S == "function" ? S : Sh(!!S), m) : e;
  }, m.touchable = function(S) {
    return arguments.length ? (r = typeof S == "function" ? S : Sh(!!S), m) : r;
  }, m.extent = function(S) {
    return arguments.length ? (t = typeof S == "function" ? S : Sh([[+S[0][0], +S[0][1]], [+S[1][0], +S[1][1]]]), m) : t;
  }, m.scaleExtent = function(S) {
    return arguments.length ? (s[0] = +S[0], s[1] = +S[1], m) : [s[0], s[1]];
  }, m.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], m) : [[o[0][0], o[0][1]], [o[1][0], o[1][1]]];
  }, m.constrain = function(S) {
    return arguments.length ? (n = S, m) : n;
  }, m.duration = function(S) {
    return arguments.length ? (a = +S, m) : a;
  }, m.interpolate = function(S) {
    return arguments.length ? (c = S, m) : c;
  }, m.on = function() {
    var S = l.on.apply(l, arguments);
    return S === l ? m : S;
  }, m.clickDistance = function(S) {
    return arguments.length ? (y = (S = +S) * S, m) : Math.sqrt(y);
  }, m.tapDistance = function(S) {
    return arguments.length ? (g = +S, m) : g;
  }, m;
}
function dn(e) {
  return e != null && !Number.isNaN(e);
}
function li(e, t) {
  return +dn(t) - +dn(e) || me(e, t);
}
function kp(e, t) {
  return +dn(t) - +dn(e) || Ho(e, t);
}
function vw(e) {
  return e != null && `${e}` != "";
}
function Up(e) {
  return isFinite(e) ? e : NaN;
}
function Zr(e) {
  return e > 0 && isFinite(e) ? e : NaN;
}
function b0(e) {
  return e < 0 && isFinite(e) ? e : NaN;
}
function iD(e, t) {
  if (e instanceof Date || (e = /* @__PURE__ */ new Date(+e)), isNaN(e))
    return typeof t == "function" ? t(e) : t;
  const n = e.getUTCHours(), i = e.getUTCMinutes(), r = e.getUTCSeconds(), s = e.getUTCMilliseconds();
  return `${FH(e.getUTCFullYear())}-${zr(e.getUTCMonth() + 1, 2)}-${zr(e.getUTCDate(), 2)}${n || i || r || s ? `T${zr(n, 2)}:${zr(i, 2)}${r || s ? `:${zr(r, 2)}${s ? `.${zr(s, 3)}` : ""}` : ""}Z` : ""}`;
}
function FH(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 EH = /^(?:[-+]\d{2})?\d{4}(?:-\d{2}(?:-\d{2})?)?(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d{3})?)?(?:Z|[-+]\d{2}:?\d{2})?)?$/;
function _w(e, t) {
  return EH.test(e += "") ? new Date(e) : typeof t == "function" ? t(e) : t;
}
const Qa = 1e3, Fs = Qa * 60, Es = Fs * 60, dr = Es * 24, Wi = dr * 7, Vo = dr * 30, _s = dr * 365, km = [
  ["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", Qa],
  ["5 seconds", 5 * Qa],
  ["15 seconds", 15 * Qa],
  ["30 seconds", 30 * Qa],
  ["minute", Fs],
  ["5 minutes", 5 * Fs],
  ["15 minutes", 15 * Fs],
  ["30 minutes", 30 * Fs],
  ["hour", Es],
  ["3 hours", 3 * Es],
  ["6 hours", 6 * Es],
  ["12 hours", 12 * Es],
  ["day", dr],
  ["2 days", 2 * dr],
  ["week", Wi],
  ["2 weeks", 2 * Wi],
  // https://github.com/d3/d3-time/issues/46
  ["month", Vo],
  ["3 months", 3 * Vo],
  ["6 months", 6 * Vo],
  // https://github.com/d3/d3-time/issues/46
  ["year", _s],
  ["2 years", 2 * _s],
  ["5 years", 5 * _s],
  ["10 years", 10 * _s],
  ["20 years", 20 * _s],
  ["50 years", 50 * _s],
  ["100 years", 100 * _s]
  // TODO generalize to longer time scales
], xw = /* @__PURE__ */ new Map([
  ["second", Qa],
  ["minute", Fs],
  ["hour", Es],
  ["day", dr],
  ["monday", Wi],
  ["tuesday", Wi],
  ["wednesday", Wi],
  ["thursday", Wi],
  ["friday", Wi],
  ["saturday", Wi],
  ["sunday", Wi],
  ["week", Wi],
  ["month", Vo],
  ["year", _s]
]), rD = /* @__PURE__ */ new Map([
  ["second", xi],
  ["minute", $f],
  ["hour", Df],
  ["day", aa],
  // https://github.com/d3/d3-time/issues/62
  ["monday", Vu],
  ["tuesday", Q$],
  ["wednesday", t6],
  ["thursday", na],
  ["friday", e6],
  ["saturday", n6],
  ["sunday", Lc],
  ["week", Lc],
  ["month", Bf],
  ["year", Di]
]), Sw = /* @__PURE__ */ new Map([
  ["second", xi],
  ["minute", Tf],
  ["hour", Nf],
  ["day", f0],
  ["monday", ju],
  ["tuesday", i6],
  ["wednesday", r6],
  ["thursday", ia],
  ["friday", s6],
  ["saturday", o6],
  ["sunday", Rc],
  ["week", Rc],
  ["month", Of],
  ["year", Ni]
]), Lf = Symbol("intervalDuration"), w0 = Symbol("intervalType");
for (const [e, t] of rD)
  t[Lf] = xw.get(e), t[w0] = "time";
for (const [e, t] of Sw)
  t[Lf] = xw.get(e), t[w0] = "utc";
const Ql = [
  ["year", Ni, "utc"],
  ["month", Of, "utc"],
  ["day", f0, "utc", 6 * Vo],
  ["hour", Nf, "utc", 3 * dr],
  ["minute", Tf, "utc", 6 * Es],
  ["second", xi, "utc", 30 * Fs]
], cd = [
  ["year", Di, "time"],
  ["month", Bf, "time"],
  ["day", aa, "time", 6 * Vo],
  ["hour", Df, "time", 3 * dr],
  ["minute", $f, "time", 6 * Es],
  ["second", xi, "time", 30 * Fs]
], LH = [
  Ql[0],
  cd[0],
  Ql[1],
  cd[1],
  Ql[2],
  cd[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.
  ...Ql.slice(3)
];
function Iw(e) {
  let t = `${e}`.toLowerCase();
  t.endsWith("s") && (t = t.slice(0, -1));
  let n = 1;
  const i = /^(?:(\d+)\s+)/.exec(t);
  switch (i && (t = t.slice(i[0].length), n = +i[1]), t) {
    case "quarter":
      t = "month", n *= 3;
      break;
    case "half":
      t = "month", n *= 6;
      break;
  }
  let r = Sw.get(t);
  if (!r)
    throw new Error(`unknown interval: ${e}`);
  if (n > 1 && !r.every)
    throw new Error(`non-periodic interval: ${t}`);
  return [t, n];
}
function sD(e) {
  return oD(Iw(e), "time");
}
function Aw(e) {
  return oD(Iw(e), "utc");
}
function oD([e, t], n) {
  let i = (n === "time" ? rD : Sw).get(e);
  return t > 1 && (i = i.every(t), i[Lf] = xw.get(e) * t, i[w0] = n), i;
}
function Vx(e, t) {
  if (!(t > 1))
    return;
  const n = e[Lf];
  if (!km.some(([, r]) => r === n) || n % dr === 0 && dr < n && n < Vo)
    return;
  const [i] = km[Wy(([, r]) => Math.log(r)).center(km, Math.log(n * t))];
  return (e[w0] === "time" ? sD : Aw)(i);
}
function jx(e, t, n) {
  const i = t === "time" ? hw : Ff;
  if (n == null)
    return i(
      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 r = RH(n);
  switch (e) {
    case "millisecond":
      return Sa(i(".%L"), i(":%M:%S"), r);
    case "second":
      return Sa(i(":%S"), i("%-I:%M"), r);
    case "minute":
      return Sa(i("%-I:%M"), i("%p"), r);
    case "hour":
      return Sa(i("%-I %p"), i("%b %-d"), r);
    case "day":
      return Sa(i("%-d"), i("%b"), r);
    case "month":
      return Sa(i("%b"), i("%Y"), r);
    case "year":
      return i("%Y");
  }
  throw new Error("unable to format time ticks");
}
function RH(e) {
  return e === "left" || e === "right" ? (t, n) => `
${t}
${n}` : e === "top" ? (t, n) => `${n}
${t}` : (t, n) => `${t}
${n}`;
}
function CH(e) {
  return e === "time" ? cd : e === "utc" ? Ql : LH;
}
function kH(e, t, n) {
  const i = De(Vz(t, (r, s) => Math.abs(s - r)));
  if (i < 1e3)
    return jx("millisecond", "utc", n);
  for (const [r, s, o, a] of CH(e)) {
    if (i > a || r === "hour" && !i)
      break;
    if (t.every((c) => s.floor(c) >= c))
      return jx(r, o, n);
  }
}
function Sa(e, t, n) {
  return (i, r, s) => {
    const o = e(i, r), a = t(i, r), c = r - Uc(s);
    return r !== c && s[c] !== void 0 && a === t(s[c], c) ? o : n(o, a);
  };
}
const Cc = Object.getPrototypeOf(Uint8Array), UH = Object.prototype.toString, aD = Symbol("reindex");
function Pt(e, t, n) {
  const i = typeof t;
  return i === "string" ? qx(e, cD(t), n) : i === "function" ? qx(e, t, n) : i === "number" || t instanceof Date || i === "boolean" ? ye(e, jn(t), n) : typeof (t == null ? void 0 : t.transform) == "function" ? Yx(t.transform(e), n) : zH(Yx(t, n), e == null ? void 0 : e[aD]);
}
function zH(e, t) {
  return t ? _0(e, t) : e;
}
function qx(e, t, n) {
  return ye(e, (n == null ? void 0 : n.prototype) instanceof Cc ? PH(t) : t, n);
}
function Yx(e, t) {
  return t === void 0 ? Nn(e) : e instanceof t ? e : t.prototype instanceof Cc && !(e instanceof Cc) ? t.from(e, Tw) : t.from(e);
}
function PH(e) {
  return (t, n) => Tw(e(t, n));
}
const yu = [null], cD = (e) => (t) => t[e], vn = { transform: us }, Tt = { transform: (e) => e }, Mw = () => 1, VH = () => !0, tn = (e) => e == null ? e : `${e}`, qt = (e) => e == null ? e : +e, Rf = (e) => e ? e[0] : void 0, Yu = (e) => e ? e[1] : void 0, jH = (e) => e ? e[2] : void 0, jn = (e) => () => e;
function $w(e) {
  const t = +`${e}`.slice(1) / 100;
  return (n, i) => Ys(n, t, i);
}
function An(e) {
  return e instanceof Cc ? e : ye(e, Tw, Float64Array);
}
function Tw(e) {
  return e == null ? NaN : Number(e);
}
function qH(e) {
  return ye(e, lD);
}
function lD(e) {
  return e instanceof Date && !isNaN(e) ? e : typeof e == "string" ? _w(e) : e == null || isNaN(e = +e) ? void 0 : new Date(e);
}
function mn(e, t) {
  return e === void 0 && (e = t), e === null ? [void 0, "none"] : Cf(e) ? [void 0, e] : [e, void 0];
}
function Be(e, t) {
  return e === void 0 && (e = t), e === null || typeof e == "number" ? [void 0, e] : [e, void 0];
}
function uD(e, t, n) {
  if (e != null)
    return qn(e, t, n);
}
function qn(e, t, n) {
  const i = `${e}`.toLowerCase();
  if (!n.includes(i))
    throw new Error(`invalid ${t}: ${e}`);
  return i;
}
function Nn(e) {
  return e == null || e instanceof Array || e instanceof Cc ? e : Array.from(e);
}
function ye(e, t, n = Array) {
  return e == null ? e : e instanceof n ? e.map(t) : n.from(e, t);
}
function Wu(e, t = Array) {
  return e instanceof t ? e.slice() : t.from(e);
}
function fD({ x: e, x1: t, x2: n }) {
  return e !== void 0 || t !== void 0 || n !== void 0;
}
function hD({ y: e, y1: t, y2: n }) {
  return e !== void 0 || t !== void 0 || n !== void 0;
}
function v0(e) {
  return fD(e) || hD(e) || e.interval !== void 0;
}
function hi(e) {
  return (e == null ? void 0 : e.toString) === UH;
}
function jo(e) {
  return hi(e) && (e.type !== void 0 || e.domain !== void 0);
}
function Hi(e) {
  return hi(e) && typeof e.transform != "function";
}
function Xs(e) {
  return Hi(e) && e.value === void 0 && e.channel === void 0;
}
function dD(e, t, n, i = Tt) {
  return t === void 0 && n === void 0 ? (t = 0, n = e === void 0 ? i : e) : t === void 0 ? t = e === void 0 ? 0 : e : n === void 0 && (n = e === void 0 ? 0 : e), [t, n];
}
function ki(e, t) {
  return e === void 0 && t === void 0 ? [Rf, Yu] : [e, t];
}
function ao({ z: e, fill: t, stroke: n } = {}) {
  return e === void 0 && ([e] = mn(t)), e === void 0 && ([e] = mn(n)), e;
}
function us(e) {
  const t = e.length, n = new Uint32Array(t);
  for (let i = 0; i < t; ++i)
    n[i] = i;
  return n;
}
function _0(e, t) {
  return ye(t, (n) => e[n], e.constructor);
}
function Dw(e) {
  return e.length === 1 ? (t, n) => e(_0(n, t)) : e;
}
function qo(e, t, n) {
  return e.subarray ? e.subarray(t, n) : e.slice(t, n);
}
function Eo(e) {
  return e !== null && typeof e == "object" ? e.valueOf() : e;
}
function pD(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 Un(e) {
  let t;
  return [
    {
      transform: () => t,
      label: wr(e)
    },
    (n) => t = n
  ];
}
function xn(e) {
  return e == null ? [e] : Un(e);
}
function wr(e, t) {
  return typeof e == "string" ? e : e && e.label !== void 0 ? e.label : t;
}
function zp(e, t) {
  return {
    transform(n) {
      const i = e.transform(n), r = t.transform(n);
      return gn(i) || gn(r) ? ye(i, (s, o) => new Date((+i[o] + +r[o]) / 2)) : ye(i, (s, o) => (+i[o] + +r[o]) / 2, Float64Array);
    },
    label: e.label
  };
}
function Pp(e, t) {
  const n = yD(t == null ? void 0 : t.interval, t == null ? void 0 : t.type);
  return n ? ye(e, n) : e;
}
function yD(e, t) {
  const n = x0(e, t);
  return n && ((i) => dn(i) ? n.floor(i) : i);
}
function x0(e, t) {
  if (e != null) {
    if (typeof e == "number") {
      0 < e && e < 1 && Number.isInteger(1 / e) && (e = -1 / e);
      const n = Math.abs(e);
      return e < 0 ? {
        floor: (i) => Math.floor(i * n) / n,
        offset: (i) => (i * n + 1) / n,
        // note: no optional step for simplicity
        range: (i, r) => Cn(Math.ceil(i * n), r * n).map((s) => s / n)
      } : {
        floor: (i) => Math.floor(i / n) * n,
        offset: (i) => i + n,
        // note: no optional step for simplicity
        range: (i, r) => Cn(Math.ceil(i / n), r / n).map((s) => s * n)
      };
    }
    if (typeof e == "string")
      return (t === "time" ? sD : Aw)(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 sl(e, t) {
  if (e = x0(e, t), e && typeof e.range != "function")
    throw new Error("invalid interval: missing range method");
  return e;
}
function YH(e, t) {
  if (e = sl(e, t), e && typeof e.ceil != "function")
    throw new Error("invalid interval: missing ceil method");
  return e;
}
function WH(e) {
  return tc(e) && typeof (e == null ? void 0 : e.floor) == "function" && e.floor() instanceof Date;
}
function tc(e) {
  return typeof (e == null ? void 0 : e.range) == "function";
}
function ol(e) {
  return e === void 0 || Hi(e) ? e : { value: e };
}
function GH(e) {
  return e == null ? null : {
    transform: (t) => Pt(t, e, Float64Array),
    label: wr(e)
  };
}
function XH(e) {
  if (!fs(e))
    return !1;
  for (const t of e)
    if (t != null)
      return typeof t == "object" && "0" in t && "1" in t;
}
function fs(e) {
  return e && typeof e[Symbol.iterator] == "function";
}
function mD(e) {
  for (const t of e)
    if (t != null)
      return typeof t != "object" || t instanceof Date;
}
function Ae(e) {
  for (const t of e) {
    if (t == null)
      continue;
    const n = typeof t;
    return n === "string" || n === "boolean";
  }
}
function gn(e) {
  for (const t of e)
    if (t != null)
      return t instanceof Date;
}
function HH(e) {
  for (const t of e)
    if (t != null)
      return typeof t == "string" && isNaN(t) && _w(t);
}
function JH(e) {
  for (const t of e)
    if (t != null) {
      if (typeof t != "string")
        return !1;
      if (t.trim())
        return !isNaN(t);
    }
}
function ec(e) {
  for (const t of e)
    if (t != null)
      return typeof t == "number";
}
function Um(e, t) {
  let n;
  for (const i of e)
    if (i != null) {
      if (!t(i))
        return !1;
      n = !0;
    }
  return n;
}
const KH = 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 Cf(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.
  KH.has(e));
}
function ZH(e) {
  return typeof e == "number" && (0 <= e && e <= 1 || isNaN(e));
}
function we(e) {
  return e == null || kc(e);
}
function kc(e) {
  return /^\s*none\s*$/i.test(e);
}
function QH(e) {
  return /^\s*round\s*$/i.test(e);
}
function A1(e, t) {
  return uD(e, t, [
    "middle",
    "top-left",
    "top",
    "top-right",
    "right",
    "bottom-right",
    "bottom",
    "bottom-left",
    "left"
  ]);
}
function kf(e = "middle") {
  return A1(e, "frameAnchor");
}
function Uc(e) {
  if (e == null)
    return;
  const t = e[0], n = e[e.length - 1];
  return Ho(t, n);
}
function tJ(e = {}, ...t) {
  let n = e;
  for (const i of t)
    for (const r in i)
      if (n[r] === void 0) {
        const s = i[r];
        n === e ? n = { ...n, [r]: s } : n[r] = s;
      }
  return n;
}
function eJ(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: i } = n;
      if (i == null)
        throw new Error("missing name");
      const r = `${i}`;
      if (r === "__proto__")
        throw new Error(`illegal name: ${r}`);
      if (t.has(r))
        throw new Error(`duplicate name: ${r}`);
      return t.add(r), [i, n];
    })
  );
}
function Nw(e) {
  return fs(e) ? eJ(e) : e;
}
const rr = Symbol("position"), hs = Symbol("color"), Uf = Symbol("radius"), zf = Symbol("length"), Pf = Symbol("opacity"), S0 = Symbol("symbol"), gD = Symbol("projection"), Se = /* @__PURE__ */ new Map([
  ["x", rr],
  ["y", rr],
  ["fx", rr],
  ["fy", rr],
  ["r", Uf],
  ["color", hs],
  ["opacity", Pf],
  ["symbol", S0],
  ["length", zf],
  ["projection", gD]
]);
function nJ(e) {
  return e === rr || e === gD;
}
function iJ(e) {
  return e === rr || e === Uf || e === zf || e === Pf;
}
const bD = Math.sqrt(3), wD = 2 / bD, rJ = {
  draw(e, t) {
    const n = Math.sqrt(t / Math.PI), i = n * wD, r = i / 2;
    e.moveTo(0, i), e.lineTo(n, r), e.lineTo(n, -r), e.lineTo(0, -i), e.lineTo(-n, -r), e.lineTo(-n, r), e.closePath();
  }
}, Bw = /* @__PURE__ */ new Map([
  ["asterisk", OT],
  ["circle", qu],
  ["cross", FT],
  ["diamond", LT],
  ["diamond2", RT],
  ["hexagon", rJ],
  ["plus", CT],
  ["square", kT],
  ["square2", UT],
  ["star", PT],
  ["times", YT],
  ["triangle", VT],
  ["triangle2", jT],
  ["wye", qT]
]);
function Ow(e) {
  return e && typeof e.draw == "function";
}
function sJ(e) {
  return Ow(e) ? !0 : typeof e != "string" ? !1 : Bw.has(e.toLowerCase());
}
function Fw(e) {
  if (e == null || Ow(e))
    return e;
  const t = Bw.get(`${e}`.toLowerCase());
  if (t)
    return t;
  throw new Error(`invalid symbol: ${e}`);
}
function oJ(e) {
  if (e == null || Ow(e))
    return [void 0, e];
  if (typeof e == "string") {
    const t = Bw.get(`${e}`.toLowerCase());
    if (t)
      return [void 0, t];
  }
  return [e, void 0];
}
function vr({ filter: e, sort: t, reverse: n, transform: i, initializer: r, ...s } = {}, o) {
  if (i === void 0 && (e != null && (i = Ew(e)), t != null && !Xs(t) && (i = zm(i, Rw(t))), n && (i = zm(i, Lw))), o != null && r != null)
    throw new Error("transforms cannot be applied after initializers");
  return {
    ...s,
    ...(t === null || Xs(t)) && { sort: t },
    transform: zm(i, o)
  };
}
function Bn({ filter: e, sort: t, reverse: n, initializer: i, ...r } = {}, s) {
  return i === void 0 && (e != null && (i = Ew(e)), t != null && !Xs(t) && (i = Pm(i, Rw(t))), n && (i = Pm(i, Lw))), {
    ...r,
    ...(t === null || Xs(t)) && { sort: t },
    initializer: Pm(i, s)
  };
}
function zm(e, t) {
  return e == null ? t === null ? void 0 : t : t == null ? e === null ? void 0 : e : function(n, i, r) {
    return { data: n, facets: i } = e.call(this, n, i, r), t.call(this, Nn(n), i, r);
  };
}
function Pm(e, t) {
  return e == null ? t === null ? void 0 : t : t == null ? e === null ? void 0 : e : function(n, i, r, ...s) {
    let o, a, c, l, u, f;
    return { data: a = n, facets: c = i, channels: o } = e.call(this, n, i, r, ...s), { data: u = a, facets: f = c, channels: l } = t.call(this, a, c, { ...r, ...o }, ...s), { data: u, facets: f, channels: { ...o, ...l } };
  };
}
function I0(e, t) {
  return (e.initializer != null ? Bn : vr)(e, t);
}
function aJ(e, t) {
  return I0(t, Ew(e));
}
function Ew(e) {
  return (t, n) => {
    const i = Pt(t, e);
    return { data: t, facets: n.map((r) => r.filter((s) => i[s])) };
  };
}
function cJ({ sort: e, ...t } = {}) {
  return {
    ...I0(t, Lw),
    sort: Xs(e) ? e : null
  };
}
function Lw(e, t) {
  return { data: e, facets: t.map((n) => n.slice().reverse()) };
}
function lJ({ seed: e, sort: t, ...n } = {}) {
  return {
    ...I0(n, _D(e == null ? Math.random : If(e))),
    sort: Xs(t) ? t : null
  };
}
function vD(e, { sort: t, ...n } = {}) {
  return {
    ...(Hi(e) && e.channel !== void 0 ? Bn : I0)(n, Rw(e)),
    sort: Xs(t) ? t : null
  };
}
function Rw(e) {
  return (typeof e == "function" && e.length !== 1 ? uJ : _D)(e);
}
function uJ(e) {
  return (t, n) => {
    const i = (r, s) => e(t[r], t[s]);
    return { data: t, facets: n.map((r) => r.slice().sort(i)) };
  };
}
function _D(e) {
  let t, n;
  ({ channel: t, value: e, order: n } = { ...ol(e) });
  const i = t == null ? void 0 : t.startsWith("-");
  if (i && (t = t.slice(1)), n === void 0 && (n = i ? kp : li), typeof n != "function")
    switch (`${n}`.toLowerCase()) {
      case "ascending":
        n = li;
        break;
      case "descending":
        n = kp;
        break;
      default:
        throw new Error(`invalid order: ${n}`);
    }
  return (r, s, o) => {
    let a;
    if (t === void 0)
      a = Pt(r, 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 = (l, u) => n(a[l], a[u]);
    return { data: r, facets: s.map((l) => l.slice().sort(c)) };
  };
}
function Cw(e, t) {
  return A0(null, null, e, t);
}
function Gu(e = { y: "count" }, t = {}) {
  const { x: n = Tt } = t;
  if (n == null)
    throw new Error("missing channel: x");
  return A0(n, null, e, t);
}
function Xu(e = { x: "count" }, t = {}) {
  const { y: n = Tt } = t;
  if (n == null)
    throw new Error("missing channel: y");
  return A0(null, n, e, t);
}
function kw(e = { fill: "count" }, t = {}) {
  let { x: n, y: i } = t;
  if ([n, i] = ki(n, i), n == null)
    throw new Error("missing channel: x");
  if (i == null)
    throw new Error("missing channel: y");
  return A0(n, i, e, t);
}
function A0(e, t, {
  data: n = Vw,
  filter: i,
  sort: r,
  reverse: s,
  ...o
  // output channel definitions
} = {}, a = {}) {
  o = SD(o, a), n = MD(n, Tt), r = r == null ? void 0 : ID("sort", r, a), i = i == null ? void 0 : AD("filter", i, a);
  const [c, l] = xn(e), [u, f] = xn(t), {
    z: h,
    fill: d,
    stroke: p,
    x1: y,
    x2: g,
    // consumed if x is an output
    y1: m,
    y2: b,
    // consumed if y is an output
    ...w
  } = a, [v, _] = xn(h), [x] = mn(d), [I] = mn(p), [N, A] = xn(x), [D, M] = xn(I);
  return {
    ..."z" in a && { z: v || h },
    ..."fill" in a && { fill: N || d },
    ..."stroke" in a && { stroke: D || p },
    ...vr(w, (B, R, S) => {
      const $ = Pp(Pt(B, e), S == null ? void 0 : S.x), T = Pp(Pt(B, t), S == null ? void 0 : S.y), L = Pt(B, h), k = Pt(B, x), U = Pt(B, I), C = Pw(o, { z: L, fill: k, stroke: U }), z = [], P = [], G = $ && l([]), K = T && f([]), tt = L && _([]), Z = k && A([]), Y = U && M([]);
      let X = 0;
      for (const j of o)
        j.initialize(B);
      r && r.initialize(B), i && i.initialize(B);
      for (const j of R) {
        const J = [];
        for (const et of o)
          et.scope("facet", j);
        r && r.scope("facet", j), i && i.scope("facet", j);
        for (const [et, V] of dc(j, C))
          for (const [Ft, rt] of dc(V, T))
            for (const [Vt, jt] of dc(rt, $)) {
              const Q = { data: B };
              if ($ && (Q.x = Vt), T && (Q.y = Ft), !(i && !i.reduce(jt, Q))) {
                J.push(X++), P.push(n.reduceIndex(jt, B, Q)), $ && G.push(Vt), T && K.push(Ft), L && tt.push(C === L ? et : L[jt[0]]), k && Z.push(C === k ? et : k[jt[0]]), U && Y.push(C === U ? et : U[jt[0]]);
                for (const Zt of o)
                  Zt.reduce(jt, Q);
                r && r.reduce(jt, Q);
              }
            }
        z.push(J);
      }
      return $D(z, r, s), { data: P, facets: z };
    }),
    ...!Ls(o, "x") && (c ? { x: c } : { x1: y, x2: g }),
    ...!Ls(o, "y") && (u ? { y: u } : { y1: m, y2: b }),
    ...Object.fromEntries(o.map(({ name: B, output: R }) => [B, R]))
  };
}
function Ls(e, ...t) {
  for (const { name: n } of e)
    if (t.includes(n))
      return !0;
  return !1;
}
function xD(e, t, n = Uw) {
  const i = Object.entries(e);
  return t.title != null && e.title === void 0 && i.push(["title", mJ]), t.href != null && e.href === void 0 && i.push(["href", jw]), i.filter(([, r]) => r !== void 0).map(([r, s]) => s === null ? fJ(r) : n(r, s, t));
}
function Uw(e, t, n, i = zw) {
  let r;
  hi(t) && "reduce" in t && (r = t.scale, t = t.reduce);
  const s = i(e, t, n), [o, a] = Un(s.label);
  let c;
  return {
    name: e,
    output: r === void 0 ? o : { value: o, scale: r },
    initialize(l) {
      s.initialize(l), c = a([]);
    },
    scope(l, u) {
      s.scope(l, u);
    },
    reduce(l, u) {
      c.push(s.reduce(l, u));
    }
  };
}
function fJ(e) {
  return { name: e, initialize() {
  }, scope() {
  }, reduce() {
  } };
}
function zw(e, t, n, i = M0) {
  const r = pD(e, n), s = i(t, r);
  let o, a;
  return {
    label: wr(s === Vp ? null : r, s.label),
    initialize(c) {
      o = r === void 0 ? c : Pt(c, r), s.scope === "data" && (a = s.reduceIndex(us(c), o));
    },
    scope(c, l) {
      s.scope === c && (a = s.reduceIndex(l, o));
    },
    reduce(c, l) {
      return s.scope == null ? s.reduceIndex(c, o, l) : s.reduceIndex(c, o, a, l);
    }
  };
}
function dc(e, t) {
  return t ? Bu(
    ls(e, (n) => t[n]),
    Rf
  ) : [[, e]];
}
function M0(e, t, n = hJ) {
  if (e == null)
    return n(e);
  if (typeof e.reduceIndex == "function")
    return e;
  if (typeof e.reduce == "function" && hi(e))
    return pJ(e);
  if (typeof e == "function")
    return yJ(e);
  if (/^p\d{2}$/i.test(e))
    return Or($w(e));
  switch (`${e}`.toLowerCase()) {
    case "first":
      return jw;
    case "last":
      return gJ;
    case "identity":
      return Vw;
    case "count":
      return Vp;
    case "distinct":
      return bJ;
    case "sum":
      return t == null ? Vp : wJ;
    case "proportion":
      return Gx(t, "data");
    case "proportion-facet":
      return Gx(t, "facet");
    case "deviation":
      return Or(bf);
    case "min":
      return Or(Ye);
    case "min-index":
      return Or(kz);
    case "max":
      return Or(De);
    case "max-index":
      return Or(Cz);
    case "mean":
      return Wx(Hy);
    case "median":
      return Wx(Eu);
    case "variance":
      return Or(zb);
    case "mode":
      return Or(d3);
  }
  return n(e);
}
function hJ(e) {
  throw new Error(`invalid reduce: ${e}`);
}
function SD(e, t) {
  return xD(e, t, ID);
}
function ID(e, t, n) {
  return Uw(e, t, n, AD);
}
function AD(e, t, n) {
  return zw(e, t, n, MD);
}
function MD(e, t) {
  return M0(e, t, dJ);
}
function dJ(e) {
  switch (`${e}`.toLowerCase()) {
    case "x":
      return vJ;
    case "y":
      return _J;
  }
  throw new Error(`invalid group reduce: ${e}`);
}
function Pw(e, t) {
  for (const n in t) {
    const i = t[n];
    if (i !== void 0 && !e.some((r) => r.name === n))
      return i;
  }
}
function $D(e, t, n) {
  if (t) {
    const i = t.output.transform(), r = (s, o) => li(i[s], i[o]);
    e.forEach((s) => s.sort(r));
  }
  n && e.forEach((i) => i.reverse());
}
function pJ(e) {
  return console.warn("deprecated reduce interface; implement reduceIndex instead."), { ...e, reduceIndex: e.reduce.bind(e) };
}
function yJ(e) {
  return {
    reduceIndex(t, n, i) {
      return e(_0(n, t), i);
    }
  };
}
function Or(e) {
  return {
    reduceIndex(t, n) {
      return e(t, (i) => n[i]);
    }
  };
}
function Wx(e) {
  return {
    reduceIndex(t, n) {
      const i = e(t, (r) => n[r]);
      return gn(n) ? new Date(i) : i;
    }
  };
}
const Vw = {
  reduceIndex(e, t) {
    return _0(t, e);
  }
}, jw = {
  reduceIndex(e, t) {
    return t[e[0]];
  }
}, mJ = {
  reduceIndex(e, t) {
    const i = Bu(
      lc(
        e,
        (s) => s.length,
        (s) => t[s]
      ),
      Yu
    ), r = i.slice(-5).reverse();
    if (r.length < i.length) {
      const s = i.slice(0, -4);
      r[4] = [`… ${s.length.toLocaleString("en-US")} more`, fr(s, Yu)];
    }
    return r.map(([s, o]) => `${s} (${o.toLocaleString("en-US")})`).join(`
`);
  }
}, gJ = {
  reduceIndex(e, t) {
    return t[e[e.length - 1]];
  }
}, Vp = {
  label: "Frequency",
  reduceIndex(e) {
    return e.length;
  }
}, bJ = {
  label: "Distinct",
  reduceIndex(e, t) {
    const n = new tl();
    for (const i of e)
      n.add(t[i]);
    return n.size;
  }
}, wJ = Or(fr);
function Gx(e, t) {
  return e == null ? { scope: t, label: "Frequency", reduceIndex: (n, i, r = 1) => n.length / r } : { scope: t, reduceIndex: (n, i, r = 1) => fr(n, (s) => i[s]) / r };
}
const vJ = {
  reduceIndex(e, t, { x: n }) {
    return n;
  }
}, _J = {
  reduceIndex(e, t, { y: n }) {
    return n;
  }
};
function xJ(e) {
  if (typeof e != "function")
    throw new Error(`invalid test function: ${e}`);
  return {
    reduceIndex(t, n, { data: i }) {
      return n[t.find((r) => e(i[r], r, i))];
    }
  };
}
function Hu(e, { scale: t, type: n, value: i, filter: r, hint: s, label: o = wr(i) }, a) {
  return s === void 0 && typeof (i == null ? void 0 : i.transform) == "function" && (s = i.hint), DD(a, {
    scale: t,
    type: n,
    value: Pt(e, i),
    label: o,
    filter: r,
    hint: s
  });
}
function TD(e, t) {
  return Object.fromEntries(
    Object.entries(e).map(([n, i]) => [n, Hu(t, i, n)])
  );
}
function qw(e, t) {
  const n = Object.fromEntries(
    Object.entries(e).map(([i, { scale: r, value: s }]) => {
      const o = r == null ? null : t[r];
      return [i, o == null ? s : ye(s, o)];
    })
  );
  return n.channels = e, n;
}
function DD(e, t) {
  const { scale: n, value: i } = t;
  if (n === !0 || n === "auto")
    switch (e) {
      case "fill":
      case "stroke":
      case "color":
        t.scale = n !== !0 && Um(i, Cf) ? null : "color";
        break;
      case "fillOpacity":
      case "strokeOpacity":
      case "opacity":
        t.scale = n !== !0 && Um(i, ZH) ? null : "opacity";
        break;
      case "symbol":
        n !== !0 && Um(i, sJ) ? (t.scale = null, t.value = ye(i, Fw)) : t.scale = "symbol";
        break;
      default:
        t.scale = Se.has(e) ? e : null;
        break;
    }
  else if (n === !1)
    t.scale = null;
  else if (n != null && !Se.has(n))
    throw new Error(`unknown scale: ${n}`);
  return t;
}
function SJ(e, t, n, i, r) {
  const { order: s, reverse: o, reduce: a = !0, limit: c } = r;
  for (const l in r) {
    if (!Se.has(l))
      continue;
    let { value: u, order: f = s, reverse: h = o, reduce: d = a, limit: p = c } = ol(r[l]);
    const y = u == null ? void 0 : u.startsWith("-");
    if (y && (u = u.slice(1)), f = f === void 0 ? y !== (u === "width" || u === "height") ? BD : ND : MJ(f), d == null || d === !1)
      continue;
    const g = l === "fx" || l === "fy" ? AJ(t, i[l]) : IJ(n, l);
    if (!g)
      throw new Error(`missing channel for scale: ${l}`);
    const m = g.value, [b = 0, w = 1 / 0] = fs(p) ? p : p < 0 ? [p] : [0, p];
    if (u == null)
      g.domain = () => {
        let v = Array.from(new tl(m));
        return h && (v = v.reverse()), (b !== 0 || w !== 1 / 0) && (v = v.slice(b, w)), v;
      };
    else {
      const v = u === "data" ? e : u === "height" ? Xx(n, "y1", "y2") : u === "width" ? Xx(n, "x1", "x2") : M1(n, u, u === "y" ? "y2" : u === "x" ? "x2" : void 0), _ = M0(d === !0 ? "max" : d, v);
      g.domain = () => {
        let x = Oz(
          us(m),
          (I) => _.reduceIndex(I, v),
          (I) => m[I]
        );
        return f && x.sort(f), h && x.reverse(), (b !== 0 || w !== 1 / 0) && (x = x.slice(b, w)), x.map(Rf);
      };
    }
  }
}
function IJ(e, t) {
  for (const n in e) {
    const i = e[n];
    if (i.scale === t)
      return i;
  }
}
function AJ(e, t) {
  const n = e.original;
  if (n === e)
    return t;
  const i = t.value, r = t.value = [];
  for (let s = 0; s < n.length; ++s) {
    const o = i[n[s][0]];
    for (const a of e[s])
      r[a] = o;
  }
  return t;
}
function Xx(e, t, n) {
  const i = M1(e, t), r = M1(e, n);
  return ye(r, (s, o) => Math.abs(s - i[o]), Float64Array);
}
function M1(e, t, n) {
  let i = e[t];
  if (!i && n !== void 0 && (i = e[n]), i)
    return i.value;
  throw new Error(`missing channel: ${t}`);
}
function MJ(e) {
  if (e == null || typeof e == "function")
    return e;
  switch (`${e}`.toLowerCase()) {
    case "ascending":
      return ND;
    case "descending":
      return BD;
  }
  throw new Error(`invalid order: ${e}`);
}
function ND([e, t], [n, i]) {
  return li(t, i) || li(e, n);
}
function BD([e, t], [n, i]) {
  return kp(t, i) || li(e, n);
}
function $1(e, t) {
  let n = e[t];
  if (n) {
    for (; n.source; )
      n = n.source;
    return n.source === null ? null : n;
  }
}
function Yw(e) {
  let t, n;
  return (...i) => (((n == null ? void 0 : n.length) !== i.length || n.some((r, s) => r !== i[s])) && (n = i, t = e(...i)), t);
}
const $J = Yw((e) => new Intl.NumberFormat(e)), TJ = Yw((e, t) => new Intl.DateTimeFormat(e, { timeZone: "UTC", ...t && { month: t } })), DJ = Yw((e, t) => new Intl.DateTimeFormat(e, { timeZone: "UTC", ...t && { weekday: t } }));
function NJ(e = "en-US") {
  const t = $J(e);
  return (n) => n != null && !isNaN(n) ? t.format(n) : void 0;
}
function BJ(e = "en-US", t = "short") {
  const n = TJ(e, t);
  return (i) => i != null && !isNaN(i = +new Date(Date.UTC(2e3, +i))) ? n.format(i) : void 0;
}
function OJ(e = "en-US", t = "short") {
  const n = DJ(e, t);
  return (i) => i != null && !isNaN(i = +new Date(Date.UTC(2001, 0, +i))) ? n.format(i) : void 0;
}
function OD(e) {
  return iD(e, "Invalid Date");
}
function FJ(e = "en-US") {
  const t = NJ(e);
  return (n) => (n instanceof Date ? OD : typeof n == "number" ? t : tn)(n);
}
const ra = FJ();
let T1 = 0, D1;
function EJ() {
  const e = T1;
  return T1 = 0, D1 = void 0, e;
}
function Qr(e) {
  e !== D1 && (D1 = e, console.warn(e), ++T1);
}
const He = (typeof window < "u" ? window.devicePixelRatio > 1 : typeof it > "u") ? 0 : 0.5;
let LJ = 0;
function N1() {
  return `plot-clip-${++LJ}`;
}
function FD(e, {
  title: t,
  href: n,
  ariaLabel: i,
  ariaDescription: r,
  ariaHidden: s,
  target: o,
  fill: a,
  fillOpacity: c,
  stroke: l,
  strokeWidth: u,
  strokeOpacity: f,
  strokeLinejoin: h,
  strokeLinecap: d,
  strokeMiterlimit: p,
  strokeDasharray: y,
  strokeDashoffset: g,
  opacity: m,
  mixBlendMode: b,
  imageFilter: w,
  paintOrder: v,
  pointerEvents: _,
  shapeRendering: x,
  channels: I
}, {
  ariaLabel: N,
  fill: A = "currentColor",
  fillOpacity: D,
  stroke: M = "none",
  strokeOpacity: B,
  strokeWidth: R,
  strokeLinecap: S,
  strokeLinejoin: $,
  strokeMiterlimit: T,
  paintOrder: L
}) {
  A === null && (a = null, c = null), M === null && (l = null, f = null), we(A) ? !we(M) && (!we(a) || I != null && I.fill) && (M = "none") : we(M) && (!we(l) || I != null && I.stroke) && (A = "none");
  const [k, U] = mn(a, A), [C, z] = Be(c, D), [P, G] = mn(l, M), [K, tt] = Be(f, B), [Z, Y] = Be(m);
  kc(G) || (u === void 0 && (u = R), d === void 0 && (d = S), h === void 0 && (h = $), p === void 0 && !QH(h) && (p = T), !kc(U) && v === void 0 && (v = L));
  const [X, j] = Be(u);
  return A !== null && (e.fill = Me(U, "currentColor"), e.fillOpacity = $l(z, 1)), M !== null && (e.stroke = Me(G, "none"), e.strokeWidth = $l(j, 1), e.strokeOpacity = $l(tt, 1), e.strokeLinejoin = Me(h, "miter"), e.strokeLinecap = Me(d, "butt"), e.strokeMiterlimit = $l(p, 4), e.strokeDasharray = Me(y, "none"), e.strokeDashoffset = Me(g, "0")), e.target = tn(o), e.ariaLabel = tn(N), e.ariaDescription = tn(r), e.ariaHidden = tn(s), e.opacity = $l(Y, 1), e.mixBlendMode = Me(b, "normal"), e.imageFilter = Me(w, "none"), e.paintOrder = Me(v, "normal"), e.pointerEvents = Me(_, "auto"), e.shapeRendering = Me(x, "auto"), {
    title: { value: t, optional: !0, filter: null },
    href: { value: n, optional: !0, filter: null },
    ariaLabel: { value: i, optional: !0, filter: null },
    fill: { value: k, scale: "auto", optional: !0 },
    fillOpacity: { value: C, scale: "auto", optional: !0 },
    stroke: { value: P, scale: "auto", optional: !0 },
    strokeOpacity: { value: K, scale: "auto", optional: !0 },
    strokeWidth: { value: X, optional: !0 },
    opacity: { value: Z, scale: "auto", optional: !0 }
  };
}
function RJ(e, t) {
  t && e.filter((n) => vw(t[n])).append("title").call(kJ, t);
}
function CJ(e, t) {
  t && e.filter(([n]) => vw(t[n])).append("title").call(UJ, t);
}
function kJ(e, t) {
  t && e.text((n) => ra(t[n]));
}
function UJ(e, t) {
  t && e.text(([n]) => ra(t[n]));
}
function Pe(e, { target: t, tip: n }, {
  ariaLabel: i,
  title: r,
  fill: s,
  fillOpacity: o,
  stroke: a,
  strokeOpacity: c,
  strokeWidth: l,
  opacity: u,
  href: f
}) {
  i && yt(e, "aria-label", (h) => i[h]), s && yt(e, "fill", (h) => s[h]), o && yt(e, "fill-opacity", (h) => o[h]), a && yt(e, "stroke", (h) => a[h]), c && yt(e, "stroke-opacity", (h) => c[h]), l && yt(e, "stroke-width", (h) => l[h]), u && yt(e, "opacity", (h) => u[h]), f && RD(e, (h) => f[h], t), n || RJ(e, r);
}
function jp(e, { target: t, tip: n }, {
  ariaLabel: i,
  title: r,
  fill: s,
  fillOpacity: o,
  stroke: a,
  strokeOpacity: c,
  strokeWidth: l,
  opacity: u,
  href: f
}) {
  i && yt(e, "aria-label", ([h]) => i[h]), s && yt(e, "fill", ([h]) => s[h]), o && yt(e, "fill-opacity", ([h]) => o[h]), a && yt(e, "stroke", ([h]) => a[h]), c && yt(e, "stroke-opacity", ([h]) => c[h]), l && yt(e, "stroke-width", ([h]) => l[h]), u && yt(e, "opacity", ([h]) => u[h]), f && RD(e, ([h]) => f[h], t), n || CJ(e, r);
}
function zJ({
  ariaLabel: e,
  title: t,
  fill: n,
  fillOpacity: i,
  stroke: r,
  strokeOpacity: s,
  strokeWidth: o,
  opacity: a,
  href: c
}, { tip: l }) {
  return [e, l ? void 0 : t, n, i, r, s, o, a, c].filter((u) => u !== void 0);
}
function Ww(e, t, n) {
  const i = ls(e, (r) => t[r]);
  return n === void 0 && i.size > 1 + e.length >> 1 && Qr(
    "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."
  ), i.values();
}
function* ED(e, t, n, i) {
  const { z: r } = n, { z: s } = i, o = zJ(i, n), a = [...t, ...o];
  for (const c of s ? Ww(e, s, r) : [e]) {
    let l, u;
    t:
      for (const f of c) {
        for (const h of a)
          if (!dn(h[f])) {
            u && u.push(-1);
            continue t;
          }
        if (l === void 0) {
          u && (yield u), l = o.map((h) => Eo(h[f])), u = [f];
          continue;
        }
        u.push(f);
        for (let h = 0; h < o.length; ++h)
          if (Eo(o[h][f]) !== l[h]) {
            yield u, l = o.map((p) => Eo(p[f])), u = [f];
            continue t;
          }
      }
    u && (yield u);
  }
}
function LD(e) {
  return e === !0 ? e = "frame" : e === !1 ? e = null : e != null && (e = qn(e, "clip", ["frame", "sphere"])), e;
}
function PJ(e, t, n, i) {
  let r;
  const { clip: s = i.clip } = t;
  switch (s) {
    case "frame": {
      const { width: o, height: a, marginLeft: c, marginRight: l, marginTop: u, marginBottom: f } = n, h = N1();
      r = `url(#${h})`, e = Gt("svg:g", i).call(
        (d) => d.append("svg:clipPath").attr("id", h).append("rect").attr("x", c).attr("y", u).attr("width", o - l - c).attr("height", a - u - f)
      ).each(function() {
        this.appendChild(e.node()), e.node = () => this;
      });
      break;
    }
    case "sphere": {
      const { projection: o } = i;
      if (!o)
        throw new Error('the "sphere" clip option requires a projection');
      const a = N1();
      r = `url(#${a})`, e.append("clipPath").attr("id", a).append("path").attr("d", so(o)({ type: "Sphere" }));
      break;
    }
  }
  yt(e, "aria-label", t.ariaLabel), yt(e, "aria-description", t.ariaDescription), yt(e, "aria-hidden", t.ariaHidden), yt(e, "clip-path", r);
}
function ve(e, t, n, i) {
  PJ(e, t, n, i), yt(e, "fill", t.fill), yt(e, "fill-opacity", t.fillOpacity), yt(e, "stroke", t.stroke), yt(e, "stroke-width", t.strokeWidth), yt(e, "stroke-opacity", t.strokeOpacity), yt(e, "stroke-linejoin", t.strokeLinejoin), yt(e, "stroke-linecap", t.strokeLinecap), yt(e, "stroke-miterlimit", t.strokeMiterlimit), yt(e, "stroke-dasharray", t.strokeDasharray), yt(e, "stroke-dashoffset", t.strokeDashoffset), yt(e, "shape-rendering", t.shapeRendering), yt(e, "filter", t.imageFilter), yt(e, "paint-order", t.paintOrder);
  const { pointerEvents: r = i.pointerSticky === !1 ? "none" : void 0 } = t;
  yt(e, "pointer-events", r);
}
function be(e, t) {
  VJ(e, "mix-blend-mode", t.mixBlendMode), yt(e, "opacity", t.opacity);
}
function RD(e, t, n) {
  e.each(function(i) {
    const r = t(i);
    if (r != null) {
      const s = this.ownerDocument.createElementNS(Ko.svg, "a");
      s.setAttribute("fill", "inherit"), s.setAttributeNS(Ko.xlink, "href", r), n != null && s.setAttribute("target", n), this.parentNode.insertBefore(s, this).appendChild(this);
    }
  });
}
function yt(e, t, n) {
  n != null && e.attr(t, n);
}
function VJ(e, t, n) {
  n != null && e.style(t, n);
}
function ue(e, t, { x: n, y: i }, r = He, s = He) {
  r += t.dx, s += t.dy, n != null && n.bandwidth && (r += n.bandwidth() / 2), i != null && i.bandwidth && (s += i.bandwidth() / 2), (r || s) && e.attr("transform", `translate(${r},${s})`);
}
function Me(e, t) {
  if ((e = tn(e)) !== t)
    return e;
}
function $l(e, t) {
  if ((e = qt(e)) !== t)
    return e;
}
const jJ = /^-?([_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 Gw(e) {
  if (e === void 0)
    return "plot-d6a7b5";
  if (e = `${e}`, !jJ.test(e))
    throw new Error(`invalid class name: ${e}`);
  return e;
}
function Xw(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: i, marginRight: r, marginBottom: s, marginLeft: o }) {
  return [
    /left$/.test(e) ? o : /right$/.test(e) ? t - r : (o + t - r) / 2,
    /^top/.test(e) ? i : /^bottom/.test(e) ? n - s : (i + n - s) / 2
  ];
}
function $0(e = {}) {
  const { document: t = typeof window < "u" ? window.document : void 0, clip: n } = e;
  return { document: t, clip: LD(n) };
}
function Gt(e, { document: t }) {
  return ce(Zy(e).call(t.documentElement));
}
const CD = Math.PI, Ar = 2 * CD, Hx = 0.618;
function qJ({
  projection: e,
  inset: t = 0,
  insetTop: n = t,
  insetRight: i = t,
  insetBottom: r = t,
  insetLeft: s = t
} = {}, o) {
  if (e == null)
    return;
  if (typeof e.stream == "function")
    return e;
  let a, c, l = "frame";
  if (hi(e)) {
    let _;
    if ({
      type: e,
      domain: c,
      inset: _,
      insetTop: n = _ !== void 0 ? _ : n,
      insetRight: i = _ !== void 0 ? _ : i,
      insetBottom: r = _ !== void 0 ? _ : r,
      insetLeft: s = _ !== void 0 ? _ : s,
      clip: l = l,
      ...a
    } = e, e == null)
      return;
  }
  typeof e != "function" && ({ type: e } = kD(e));
  const { width: u, height: f, marginLeft: h, marginRight: d, marginTop: p, marginBottom: y } = o, g = u - h - d - s - i, m = f - p - y - n - r;
  if (e = e == null ? void 0 : e({ width: g, height: m, clip: l, ...a }), e == null)
    return;
  l = YJ(l, h, p, u - d, f - y);
  let b = h + s, w = p + n, v;
  if (c != null) {
    const [[_, x], [I, N]] = so(e).bounds(c), A = Math.min(g / (I - _), m / (N - x));
    A > 0 ? (b -= (A * (_ + I) - g) / 2, w -= (A * (x + N) - m) / 2, v = Object.assign(
      Ap({
        point(D, M) {
          this.stream.point(D * A + b, M * A + w);
        }
      }),
      { invert: ([D, M]) => [(D - b) / A, (M - w) / A] }
    )) : Qr("Warning: the projection could not be fit to the specified domain; using the default scale.");
  }
  return v ?? (v = b === 0 && w === 0 ? UD() : Object.assign(
    Ap({
      point(_, x) {
        this.stream.point(_ + b, x + w);
      }
    }),
    { invert: ([_, x]) => [_ - b, x - w] }
  )), {
    stream: (_) => e.stream(v.stream(l(_))),
    invert: (_) => e.invert(v.invert(_))
  };
}
function kD(e) {
  switch (`${e}`.toLowerCase()) {
    case "albers-usa":
      return di(vW, 0.7463, 0.4673);
    case "albers":
      return Ih($$, 0.7463, 0.4673);
    case "azimuthal-equal-area":
      return di(_W, 4, 4);
    case "azimuthal-equidistant":
      return di(xW, Ar, Ar);
    case "conic-conformal":
      return Ih(AW, Ar, Ar);
    case "conic-equal-area":
      return Ih(Mp, 6.1702, 2.9781);
    case "conic-equidistant":
      return Ih(TW, 7.312, 3.6282);
    case "equal-earth":
      return di(NW, 5.4133, 2.6347);
    case "equirectangular":
      return di(MW, Ar, CD);
    case "gnomonic":
      return di(BW, 3.4641, 3.4641);
    case "identity":
      return { type: UD };
    case "reflect-y":
      return { type: WJ };
    case "mercator":
      return di(SW, Ar, Ar);
    case "orthographic":
      return di(OW, 2, 2);
    case "stereographic":
      return di(FW, 2, 2);
    case "transverse-mercator":
      return di(EW, Ar, Ar);
    default:
      throw new Error(`unknown projection type: ${e}`);
  }
}
function YJ(e, t, n, i, r) {
  if (e === !1 || e == null || typeof e == "number")
    return (s) => s;
  switch (e === !0 && (e = "frame"), `${e}`.toLowerCase()) {
    case "frame":
      return f$(t, n, i, r);
    default:
      throw new Error(`unknown projection clip type: ${e}`);
  }
}
function di(e, t, n) {
  return {
    type: ({ width: i, height: r, rotate: s, precision: o = 0.15, clip: a }) => {
      var l, u, f;
      const c = e();
      return o != null && ((l = c.precision) == null || l.call(c, o)), s != null && ((u = c.rotate) == null || u.call(c, s)), typeof a == "number" && ((f = c.clipAngle) == null || f.call(c, a)), c.scale(Math.min(i / t, r / n)), c.translate([i / 2, r / 2]), c;
    },
    aspectRatio: n / t
  };
}
function Ih(e, t, n) {
  const { type: i, aspectRatio: r } = di(e, t, n);
  return {
    type: (s) => {
      const { parallels: o, domain: a, width: c, height: l } = s, u = i(s);
      return o != null && (u.parallels(o), a === void 0 && u.fitSize([c, l], { type: "Sphere" })), u;
    },
    aspectRatio: r
  };
}
const UD = jn({
  stream: (e) => e,
  invert: (e) => e
}), WJ = jn(
  Object.assign(
    Ap({
      point(e, t) {
        this.stream.point(e, -t);
      }
    }),
    { invert: ([e, t]) => [e, -t] }
  )
);
function zD(e, t, n, i) {
  const r = n[e], s = n[t], o = r.length, a = n[e] = new Float64Array(o).fill(NaN), c = n[t] = new Float64Array(o).fill(NaN);
  let l;
  const u = i.stream({
    point(f, h) {
      a[l] = f, c[l] = h;
    }
  });
  for (l = 0; l < o; ++l)
    u.point(r[l], s[l]);
}
function GJ({ projection: e } = {}) {
  return e == null ? !1 : typeof e.stream == "function" ? !0 : (hi(e) && (e = e.type), e != null);
}
function XJ(e) {
  if (typeof (e == null ? void 0 : e.stream) == "function")
    return Hx;
  if (hi(e) && (e = e.type), e != null) {
    if (typeof e != "function") {
      const { aspectRatio: t } = kD(e);
      if (t)
        return t;
    }
    return Hx;
  }
}
function T0(e, t, { projection: n }) {
  const { x: i, y: r } = e;
  let s = {};
  return i && (s.x = i), r && (s.y = r), s = qw(s, t), n && (i == null ? void 0 : i.scale) === "x" && (r == null ? void 0 : r.scale) === "y" && zD("x", "y", s, n), i && (s.x = An(s.x)), r && (s.y = An(s.y)), s;
}
function HJ(e) {
  const t = [], n = [], i = { scale: "x", value: t }, r = { 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)
    Ds(o, s);
  return [i, r];
}
const JJ = [
  "#4269d0",
  "#efb118",
  "#ff725c",
  "#6cc5b0",
  "#3ca951",
  "#ff8ab7",
  "#a463f2",
  "#97bbf5",
  "#9c6b4e",
  "#9498a0"
], PD = /* @__PURE__ */ new Map([
  ["accent", PX],
  ["category10", zX],
  ["dark2", VX],
  ["observable10", JJ],
  ["paired", jX],
  ["pastel1", qX],
  ["pastel2", YX],
  ["set1", WX],
  ["set2", GX],
  ["set3", XX],
  ["tableau10", HX]
]);
function KJ(e) {
  return e != null && PD.has(`${e}`.toLowerCase());
}
const Jx = new Map([
  ...PD,
  // diverging
  ["brbg", Mr(g6, b6)],
  ["prgn", Mr(w6, v6)],
  ["piyg", Mr(_6, x6)],
  ["puor", Mr(S6, I6)],
  ["rdbu", Mr(x1, Bp)],
  ["rdgy", Mr(A6, M6)],
  ["rdylbu", Mr(S1, Op)],
  ["rdylgn", Mr($6, T6)],
  ["spectral", Mr(D6, N6)],
  // reversed diverging (for temperature data)
  ["burd", Kx(x1, Bp)],
  ["buylrd", Kx(S1, Op)],
  // sequential (single-hue)
  ["blues", Ve(eT, nT)],
  ["greens", Ve(iT, rT)],
  ["greys", Ve(sT, oT)],
  ["oranges", Ve(fT, hT)],
  ["purples", Ve(aT, cT)],
  ["reds", Ve(lT, uT)],
  // sequential (multi-hue)
  ["turbo", $r(wT)],
  ["viridis", $r(vT)],
  ["magma", $r(_T)],
  ["inferno", $r(xT)],
  ["plasma", $r(ST)],
  ["cividis", $r(dT)],
  ["cubehelix", $r(pT)],
  ["warm", $r(yT)],
  ["cool", $r(mT)],
  ["bugn", Ve(B6, O6)],
  ["bupu", Ve(F6, E6)],
  ["gnbu", Ve(L6, R6)],
  ["orrd", Ve(C6, k6)],
  ["pubu", Ve(P6, V6)],
  ["pubugn", Ve(U6, z6)],
  ["purd", Ve(j6, q6)],
  ["rdpu", Ve(Y6, W6)],
  ["ylgn", Ve(H6, J6)],
  ["ylgnbu", Ve(G6, X6)],
  ["ylorbr", Ve(K6, Z6)],
  ["ylorrd", Ve(Q6, tT)],
  // cyclical
  ["rainbow", Zx(gT)],
  ["sinebow", Zx(bT)]
]);
function Ve(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 ? $i(t, n) : e[n]);
}
function Mr(e, t) {
  return ({ length: n }) => n === 2 ? [e[3][0], e[3][2]] : (n = Math.max(3, Math.floor(n)), n > 11 ? $i(t, n) : e[n]);
}
function Kx(e, t) {
  return ({ length: n }) => n === 2 ? [e[3][2], e[3][0]] : (n = Math.max(3, Math.floor(n)), n > 11 ? $i((i) => t(1 - i), n) : e[n].slice().reverse());
}
function $r(e) {
  return ({ length: t }) => $i(e, Math.max(2, Math.floor(t)));
}
function Zx(e) {
  return ({ length: t }) => $i(e, Math.floor(t) + 1).slice(0, -1);
}
function VD(e) {
  const t = `${e}`.toLowerCase();
  if (!Jx.has(t))
    throw new Error(`unknown ordinal scheme: ${t}`);
  return Jx.get(t);
}
function D0(e, t) {
  const n = VD(e), i = typeof n == "function" ? n({ length: t }) : n;
  return i.length !== t ? i.slice(0, t) : i;
}
function ZJ(e, t = "greys") {
  const n = /* @__PURE__ */ new Set(), [i, r] = D0(t, 2);
  for (const s of e)
    if (s != null)
      if (s === !0)
        n.add(r);
      else if (s === !1)
        n.add(i);
      else
        return;
  return [...n];
}
const Qx = /* @__PURE__ */ new Map([
  // diverging
  ["brbg", b6],
  ["prgn", v6],
  ["piyg", x6],
  ["puor", I6],
  ["rdbu", Bp],
  ["rdgy", M6],
  ["rdylbu", Op],
  ["rdylgn", T6],
  ["spectral", N6],
  // reversed diverging (for temperature data)
  ["burd", (e) => Bp(1 - e)],
  ["buylrd", (e) => Op(1 - e)],
  // sequential (single-hue)
  ["blues", nT],
  ["greens", rT],
  ["greys", oT],
  ["purples", cT],
  ["reds", uT],
  ["oranges", hT],
  // sequential (multi-hue)
  ["turbo", wT],
  ["viridis", vT],
  ["magma", _T],
  ["inferno", xT],
  ["plasma", ST],
  ["cividis", dT],
  ["cubehelix", pT],
  ["warm", yT],
  ["cool", mT],
  ["bugn", O6],
  ["bupu", E6],
  ["gnbu", R6],
  ["orrd", k6],
  ["pubugn", z6],
  ["pubu", V6],
  ["purd", q6],
  ["rdpu", W6],
  ["ylgnbu", X6],
  ["ylgn", J6],
  ["ylorbr", Z6],
  ["ylorrd", tT],
  // cyclical
  ["rainbow", gT],
  ["sinebow", bT]
]);
function Hw(e) {
  const t = `${e}`.toLowerCase();
  if (!Qx.has(t))
    throw new Error(`unknown quantitative scheme: ${t}`);
  return Qx.get(t);
}
const QJ = /* @__PURE__ */ new Set([
  "brbg",
  "prgn",
  "piyg",
  "puor",
  "rdbu",
  "rdgy",
  "rdylbu",
  "rdylgn",
  "spectral",
  "burd",
  "buylrd"
]);
function tK(e) {
  return e != null && QJ.has(`${e}`.toLowerCase());
}
const jD = (e) => (t) => e(1 - t), Vm = [0, 1], tS = /* @__PURE__ */ new Map([
  // numbers
  ["number", Qe],
  // color spaces
  ["rgb", Qo],
  ["hsl", mj],
  ["hcl", wj],
  ["lab", gj]
]);
function qD(e) {
  const t = `${e}`.toLowerCase();
  if (!tS.has(t))
    throw new Error(`unknown interpolator: ${t}`);
  return tS.get(t);
}
function Vf(e, t, n, {
  type: i,
  nice: r,
  clamp: s,
  zero: o,
  domain: a = WD(e, n),
  unknown: c,
  round: l,
  scheme: u,
  interval: f,
  range: h = Se.get(e) === Uf ? fK(n, a) : Se.get(e) === zf ? hK(n, a) : Se.get(e) === Pf ? Vm : void 0,
  interpolate: d = Se.get(e) === hs ? u == null && h !== void 0 ? Qo : Hw(u !== void 0 ? u : i === "cyclical" ? "rainbow" : "turbo") : l ? Zb : Qe,
  reverse: p
}) {
  if (f = sl(f, i), (i === "cyclical" || i === "sequential") && (i = "linear"), typeof d != "function" && (d = qD(d)), p = !!p, h !== void 0) {
    const y = (a = Nn(a)).length, g = (h = Nn(h)).length;
    if (y !== g) {
      if (d.length === 1)
        throw new Error("invalid piecewise interpolator");
      d = e0(d, h), h = void 0;
    }
  }
  if (d.length === 1 ? (p && (d = jD(d), p = !1), h === void 0 && (h = Float64Array.from(a, (y, g) => g / (a.length - 1)), h.length === 2 && (h = Vm)), t.interpolate((h === Vm ? jn : Kw)(d))) : t.interpolate(d), o) {
    const [y, g] = ke(a);
    (y > 0 || g < 0) && (a = Wu(a), Uc(a) !== Math.sign(y) ? a[a.length - 1] = 0 : a[0] = 0);
  }
  return p && (a = Zd(a)), t.domain(a).unknown(c), r && (t.nice(eK(r, i)), a = t.domain()), h !== void 0 && t.range(h), s && t.clamp(s), { type: i, domain: a, range: h, scale: t, interpolate: d, interval: f };
}
function eK(e, t) {
  return e === !0 ? void 0 : typeof e == "number" ? e : YH(e, t);
}
function nK(e, t, n) {
  return Vf(e, l0(), t, n);
}
function iK(e, t, n) {
  return YD(e, t, { ...n, exponent: 0.5 });
}
function YD(e, t, { exponent: n = 1, ...i }) {
  return Vf(e, J$().exponent(n), t, { ...i, type: "pow" });
}
function rK(e, t, { base: n = 10, domain: i = dK(t), ...r }) {
  return Vf(e, W$().base(n), t, { ...r, domain: i });
}
function sK(e, t, { constant: n = 1, ...i }) {
  return Vf(e, X$().constant(n), t, i);
}
function oK(e, t, {
  range: n,
  quantiles: i = n === void 0 ? 5 : (n = [...n]).length,
  // deprecated; use n instead
  n: r = i,
  scheme: s = "rdylbu",
  domain: o = pK(t),
  unknown: a,
  interpolate: c,
  reverse: l
}) {
  return n === void 0 && (n = c !== void 0 ? $i(c, r) : Se.get(e) === hs ? D0(s, r) : void 0), o.length > 0 && (o = K$(o, n === void 0 ? { length: r } : n).quantiles()), Jw(e, t, { domain: o, range: n, reverse: l, unknown: a });
}
function aK(e, t, {
  range: n,
  n: i = n === void 0 ? 5 : (n = [...n]).length,
  scheme: r = "rdylbu",
  domain: s = WD(e, t),
  unknown: o,
  interpolate: a,
  reverse: c
}) {
  const [l, u] = ke(s);
  let f;
  return n === void 0 ? (f = qs(l, u, i), f[0] <= l && f.splice(0, 1), f[f.length - 1] >= u && f.pop(), i = f.length + 1, n = a !== void 0 ? $i(a, i) : Se.get(e) === hs ? D0(r, i) : void 0) : (f = $i(Qe(l, u), i + 1).slice(1, -1), l instanceof Date && (f = f.map((h) => new Date(h)))), Uc(Nn(s)) < 0 && f.reverse(), Jw(e, t, { domain: f, range: n, reverse: c, unknown: o });
}
function Jw(e, t, {
  domain: n = [0],
  // explicit thresholds in ascending order
  unknown: i,
  scheme: r = "rdylbu",
  interpolate: s,
  range: o = s !== void 0 ? $i(s, n.length + 1) : Se.get(e) === hs ? D0(r, n.length + 1) : void 0,
  reverse: a
}) {
  n = Nn(n);
  const c = Uc(n);
  if (!isNaN(c) && !cK(n, c))
    throw new Error(`the ${e} scale has a non-monotonic domain`);
  return a && (o = Zd(o)), {
    type: "threshold",
    scale: Z$(c < 0 ? Zd(n) : n, o === void 0 ? [] : o).unknown(i),
    domain: n,
    range: o
  };
}
function cK(e, t) {
  for (let n = 1, i = e.length, r = e[0]; n < i; ++n) {
    const s = Ho(r, r = e[n]);
    if (s !== 0 && s !== t)
      return !1;
  }
  return !0;
}
function lK(e) {
  return { type: "identity", scale: iJ(Se.get(e)) ? j$() : (t) => t };
}
function Ju(e, t = Up) {
  return e.length ? [
    Ye(e, ({ value: n }) => n === void 0 ? n : Ye(n, t)),
    De(e, ({ value: n }) => n === void 0 ? n : De(n, t))
  ] : [0, 1];
}
function WD(e, t) {
  const n = Se.get(e);
  return (n === Uf || n === Pf || n === zf ? uK : Ju)(t);
}
function uK(e) {
  return [0, e.length ? De(e, ({ value: t }) => t === void 0 ? t : De(t, Up)) : 1];
}
function fK(e, t) {
  const n = e.find(({ radius: o }) => o !== void 0);
  if (n !== void 0)
    return [0, n.radius];
  const i = Ys(e, 0.5, ({ value: o }) => o === void 0 ? NaN : Ys(o, 0.25, Zr)), r = t.map((o) => 3 * Math.sqrt(o / i)), s = 30 / De(r);
  return s < 1 ? r.map((o) => o * s) : r;
}
function hK(e, t) {
  const n = Eu(e, ({ value: s }) => s === void 0 ? NaN : Eu(s, Math.abs)), i = t.map((s) => 12 * s / n), r = 60 / De(i);
  return r < 1 ? i.map((s) => s * r) : i;
}
function dK(e) {
  for (const { value: t } of e)
    if (t !== void 0)
      for (let n of t) {
        if (n > 0)
          return Ju(e, Zr);
        if (n < 0)
          return Ju(e, b0);
      }
  return [1, 10];
}
function pK(e) {
  const t = [];
  for (const { value: n } of e)
    if (n !== void 0)
      for (const i of n)
        t.push(i);
  return t;
}
function Kw(e) {
  return (t, n) => (i) => e(t + i * (n - t));
}
function N0(e, t, n, i, {
  type: r,
  nice: s,
  clamp: o,
  domain: a = Ju(i),
  unknown: c,
  pivot: l = 0,
  scheme: u,
  range: f,
  symmetric: h = !0,
  interpolate: d = Se.get(e) === hs ? u == null && f !== void 0 ? Qo : Hw(u !== void 0 ? u : "rdbu") : Qe,
  reverse: p
}) {
  l = +l, a = Nn(a);
  let [y, g] = a;
  if (a.length > 2 && Qr(`Warning: the diverging ${e} scale domain contains extra elements.`), Ho(y, g) < 0 && ([y, g] = [g, y], p = !p), y = Math.min(y, l), g = Math.max(g, l), typeof d != "function" && (d = qD(d)), f !== void 0 && (d = d.length === 1 ? Kw(d)(...f) : e0(d, f)), p && (d = jD(d)), h) {
    const m = n.apply(l), b = m - n.apply(y), w = n.apply(g) - m;
    b < w ? y = n.invert(m - w) : b > w && (g = n.invert(m + b));
  }
  return t.domain([y, l, g]).unknown(c).interpolator(d), o && t.clamp(o), s && t.nice(s), { type: r, domain: [y, g], pivot: l, interpolate: d, scale: t };
}
function yK(e, t, n) {
  return N0(e, d6(), wK, t, n);
}
function mK(e, t, n) {
  return GD(e, t, { ...n, exponent: 0.5 });
}
function GD(e, t, { exponent: n = 1, ...i }) {
  return N0(e, m6().exponent(n = +n), xK(n), t, {
    ...i,
    type: "diverging-pow"
  });
}
function gK(e, t, { base: n = 10, pivot: i = 1, domain: r = Ju(t, i < 0 ? b0 : Zr), ...s }) {
  return N0(e, p6().base(n = +n), vK, t, {
    domain: r,
    pivot: i,
    ...s
  });
}
function bK(e, t, { constant: n = 1, ...i }) {
  return N0(
    e,
    y6().constant(n = +n),
    SK(n),
    t,
    i
  );
}
const wK = {
  apply(e) {
    return e;
  },
  invert(e) {
    return e;
  }
}, vK = {
  apply: Math.log,
  invert: Math.exp
}, _K = {
  apply(e) {
    return Math.sign(e) * Math.sqrt(Math.abs(e));
  },
  invert(e) {
    return Math.sign(e) * (e * e);
  }
};
function xK(e) {
  return e === 0.5 ? _K : {
    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 SK(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 XD(e, t, n, i) {
  return Vf(e, t, n, i);
}
function IK(e, t, n) {
  return XD(e, kX(), t, n);
}
function AK(e, t, n) {
  return XD(e, UX(), t, n);
}
const jf = Symbol("ordinal");
function HD(e, t, n, { type: i, interval: r, domain: s, range: o, reverse: a, hint: c }) {
  return r = sl(r, i), s === void 0 && (s = KD(n, r, e)), (i === "categorical" || i === jf) && (i = "ordinal"), a && (s = Zd(s)), s = t.domain(s).domain(), o !== void 0 && (typeof o == "function" && (o = o(s)), t.range(o)), { type: i, domain: s, range: o, scale: t, hint: c, interval: r };
}
function MK(e, t, { type: n, interval: i, domain: r, range: s, scheme: o, unknown: a, ...c }) {
  i = sl(i, n), r === void 0 && (r = KD(t, i, e));
  let l;
  if (Se.get(e) === S0)
    l = DK(t), s = s === void 0 ? NK(l) : ye(s, Fw);
  else if (Se.get(e) === hs && (s === void 0 && (n === "ordinal" || n === jf) && (s = ZJ(r, 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 u = Hw(o), f = s[0], h = s[1] - s[0];
      s = ({ length: d }) => $i((p) => u(f + h * p), d);
    } else
      s = VD(o);
  if (a === w1)
    throw new Error(`implicit unknown on ${e} scale is not supported`);
  return HD(e, uw().unknown(a), t, { ...c, type: n, domain: r, range: s, hint: l });
}
function $K(e, t, { align: n = 0.5, padding: i = 0.5, ...r }) {
  return JD(wG().align(n).padding(i), t, r, e);
}
function TK(e, t, {
  align: n = 0.5,
  padding: i = 0.1,
  paddingInner: r = i,
  paddingOuter: s = e === "fx" || e === "fy" ? 0 : i,
  ...o
}) {
  return JD(
    a0().align(n).paddingInner(r).paddingOuter(s),
    t,
    o,
    e
  );
}
function JD(e, t, n, i) {
  let { round: r } = n;
  return r !== void 0 && e.round(r = !!r), e = HD(i, e, t, n), e.round = r, e;
}
function KD(e, t, n) {
  const i = new tl();
  for (const { value: r, domain: s } of e) {
    if (s !== void 0)
      return s();
    if (r !== void 0)
      for (const o of r)
        i.add(o);
  }
  if (t !== void 0) {
    const [r, s] = ke(i).map(t.floor, t);
    return t.range(r, t.offset(s));
  }
  if (i.size > 1e4 && Se.get(n) === rr)
    throw new Error(`implicit ordinal domain of ${n} scale has more than 10,000 values`);
  return Bu(i, li);
}
function eS(e, t) {
  let n;
  for (const { hint: i } of e) {
    const r = i == null ? void 0 : i[t];
    if (r !== void 0) {
      if (n === void 0)
        n = r;
      else if (n !== r)
        return;
    }
  }
  return n;
}
function DK(e) {
  return {
    fill: eS(e, "fill"),
    stroke: eS(e, "stroke")
  };
}
function NK(e) {
  return we(e.fill) ? cH : aH;
}
function B1(e, {
  label: t,
  inset: n = 0,
  insetTop: i = n,
  insetRight: r = n,
  insetBottom: s = n,
  insetLeft: o = n,
  round: a,
  nice: c,
  clamp: l,
  zero: u,
  align: f,
  padding: h,
  projection: d,
  facet: { label: p = t } = {},
  ...y
} = {}) {
  const g = {};
  for (const [m, b] of e) {
    const w = y[m], v = n8(m, b, {
      round: Se.get(m) === rr ? a : void 0,
      // only for position
      nice: c,
      clamp: l,
      zero: u,
      align: f,
      padding: h,
      projection: d,
      ...w
    });
    if (v) {
      let {
        label: _ = m === "fx" || m === "fy" ? p : t,
        percent: x,
        transform: I,
        inset: N,
        insetTop: A = N !== void 0 ? N : m === "y" ? i : 0,
        // not fy
        insetRight: D = N !== void 0 ? N : m === "x" ? r : 0,
        // not fx
        insetBottom: M = N !== void 0 ? N : m === "y" ? s : 0,
        // not fy
        insetLeft: B = N !== void 0 ? N : m === "x" ? o : 0
        // not fx
      } = w || {};
      if (I == null)
        I = void 0;
      else if (typeof I != "function")
        throw new Error("invalid scale transform; not a function");
      v.percent = !!x, v.label = _ === void 0 ? OK(b, v) : _, v.transform = I, m === "x" || m === "fx" ? (v.insetLeft = +B, v.insetRight = +D) : (m === "y" || m === "fy") && (v.insetTop = +A, v.insetBottom = +M), g[m] = v;
    }
  }
  return g;
}
function nS(e) {
  const t = {}, n = { scales: t };
  for (const [i, r] of Object.entries(e)) {
    const { scale: s, type: o, interval: a, label: c } = r;
    t[i] = r8(r), n[i] = s, s.type = o, a != null && (s.interval = a), c != null && (s.label = c);
  }
  return n;
}
function BK(e, t) {
  const { x: n, y: i, fx: r, fy: s } = e, o = r || s ? Zw(t) : t;
  r && iS(r, o), s && rS(s, o);
  const a = r || s ? QD(e, t) : t;
  n && iS(n, a), i && rS(i, a);
}
function OK(e = [], t) {
  let n;
  for (const { label: i } of e)
    if (i !== void 0) {
      if (n === void 0)
        n = i;
      else if (n !== i)
        return;
    }
  if (n !== void 0)
    return !ua(t) && t.percent && (n = `${n} (%)`), { inferred: !0, toString: () => n };
}
function ZD(e) {
  return Math.sign(Uc(e.domain())) * Math.sign(Uc(e.range()));
}
function Zw(e) {
  const {
    marginTop: t,
    marginRight: n,
    marginBottom: i,
    marginLeft: r,
    width: s,
    height: o,
    facet: {
      marginTop: a,
      marginRight: c,
      marginBottom: l,
      marginLeft: u
    }
  } = e;
  return {
    marginTop: Math.max(t, a),
    marginRight: Math.max(n, c),
    marginBottom: Math.max(i, l),
    marginLeft: Math.max(r, u),
    width: s,
    height: o
  };
}
function QD({ fx: e, fy: t }, n) {
  const { marginTop: i, marginRight: r, marginBottom: s, marginLeft: o, width: a, height: c } = Zw(n);
  return {
    marginTop: i,
    marginRight: r,
    marginBottom: s,
    marginLeft: o,
    width: e ? e.scale.bandwidth() + o + r : a,
    height: t ? t.scale.bandwidth() + i + s : c,
    facet: { width: a, height: c }
  };
}
function iS(e, t) {
  if (e.range === void 0) {
    const { insetLeft: n, insetRight: i } = e, { width: r, marginLeft: s = 0, marginRight: o = 0 } = t, a = s + n, c = r - o - i;
    e.range = [a, Math.max(a, c)], ua(e) || (e.range = e8(e)), e.scale.range(e.range);
  }
  t8(e);
}
function rS(e, t) {
  if (e.range === void 0) {
    const { insetTop: n, insetBottom: i } = e, { height: r, marginTop: s = 0, marginBottom: o = 0 } = t, a = s + n, c = r - o - i;
    e.range = [Math.max(a, c), a], ua(e) ? e.range.reverse() : e.range = e8(e), e.scale.range(e.range);
  }
  t8(e);
}
function t8(e) {
  e.round === void 0 && LK(e) && FK(e) <= 30 && e.scale.round(!0);
}
function FK({ scale: e }) {
  const t = e.domain().length, [n, i] = e.range(), r = e.paddingInner ? e.paddingInner() : 1, s = e.paddingOuter ? e.paddingOuter() : e.padding(), o = t - r, a = Math.abs(i - n) / Math.max(1, o + s * 2);
  return (a - Math.floor(a)) * o;
}
function e8(e) {
  const t = e.scale.domain().length + i8(e);
  if (!(t > 2))
    return e.range;
  const [n, i] = e.range;
  return Array.from({ length: t }, (r, s) => n + s / (t - 1) * (i - n));
}
function O1(e, t, n) {
  return n8(e, n === void 0 ? void 0 : [{ hint: n }], { ...t });
}
function n8(e, t = [], n = {}) {
  const i = EK(e, t, n);
  if (n.type === void 0 && n.domain === void 0 && n.range === void 0 && n.interval == null && e !== "fx" && e !== "fy" && ua({ type: i })) {
    const r = t.map(({ value: s }) => s).filter((s) => s !== void 0);
    r.some(gn) ? Qr(
      `Warning: some data associated with the ${e} scale are dates. Dates are typically associated with a "utc" or "time" scale rather than a "${Ia(
        i
      )}" 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 "${Ia(
        i
      )}".`
    ) : r.some(HH) ? Qr(
      `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 "${Ia(
        i
      )}" 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 "${Ia(
        i
      )}".`
    ) : r.some(JH) && Qr(
      `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 "${Ia(
        i
      )}" 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 "${Ia(
        i
      )}".`
    );
  }
  switch (n.type = i, i) {
    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 = Ah(t, n, An);
      break;
    case "identity":
      switch (Se.get(e)) {
        case rr:
          n = Ah(t, n, An);
          break;
        case S0:
          n = Ah(t, n, RK);
          break;
      }
      break;
    case "utc":
    case "time":
      n = Ah(t, n, qH);
      break;
  }
  switch (i) {
    case "diverging":
      return yK(e, t, n);
    case "diverging-sqrt":
      return mK(e, t, n);
    case "diverging-pow":
      return GD(e, t, n);
    case "diverging-log":
      return gK(e, t, n);
    case "diverging-symlog":
      return bK(e, t, n);
    case "categorical":
    case "ordinal":
    case jf:
      return MK(e, t, n);
    case "cyclical":
    case "sequential":
    case "linear":
      return nK(e, t, n);
    case "sqrt":
      return iK(e, t, n);
    case "threshold":
      return Jw(e, t, n);
    case "quantile":
      return oK(e, t, n);
    case "quantize":
      return aK(e, t, n);
    case "pow":
      return YD(e, t, n);
    case "log":
      return rK(e, t, n);
    case "symlog":
      return sK(e, t, n);
    case "utc":
      return AK(e, t, n);
    case "time":
      return IK(e, t, n);
    case "point":
      return $K(e, t, n);
    case "band":
      return TK(e, t, n);
    case "identity":
      return lK(e);
    case void 0:
      return;
    default:
      throw new Error(`unknown scale type: ${i}`);
  }
}
function Ia(e) {
  return typeof e == "symbol" ? e.description : e;
}
function sS(e) {
  return typeof e == "string" ? `${e}`.toLowerCase() : e;
}
const oS = { toString: () => "projection" };
function EK(e, t, { type: n, domain: i, range: r, scheme: s, pivot: o, projection: a }) {
  if (n = sS(n), e === "fx" || e === "fy")
    return "band";
  (e === "x" || e === "y") && a != null && (n = oS);
  for (const l of t) {
    const u = sS(l.type);
    if (u !== void 0) {
      if (n === void 0)
        n = u;
      else if (n !== u)
        throw new Error(`scale incompatible with channel: ${n} !== ${u}`);
    }
  }
  if (n === oS)
    return;
  if (n !== void 0)
    return n;
  if (i === void 0 && !t.some(({ value: l }) => l !== void 0))
    return;
  const c = Se.get(e);
  if (c === Uf)
    return "sqrt";
  if (c === Pf || c === zf)
    return "linear";
  if (c === S0)
    return "ordinal";
  if ((i || r || []).length > 2)
    return jm(c);
  if (i !== void 0) {
    if (Ae(i))
      return jm(c);
    if (gn(i))
      return "utc";
  } else {
    const l = t.map(({ value: u }) => u).filter((u) => u !== void 0);
    if (l.some(Ae))
      return jm(c);
    if (l.some(gn))
      return "utc";
  }
  if (c === hs) {
    if (o != null || tK(s))
      return "diverging";
    if (KJ(s))
      return "categorical";
  }
  return "linear";
}
function jm(e) {
  switch (e) {
    case rr:
      return "point";
    case hs:
      return jf;
    default:
      return "ordinal";
  }
}
function ua({ type: e }) {
  return e === "ordinal" || e === "point" || e === "band" || e === jf;
}
function i8({ type: e }) {
  return e === "threshold";
}
function LK({ type: e }) {
  return e === "point" || e === "band";
}
function oi(e) {
  if (e === void 0)
    return !0;
  const t = e.domain(), n = e(t[0]);
  for (let i = 1, r = t.length; i < r; ++i)
    if (e(t[i]) - n)
      return !1;
  return !0;
}
function Ah(e, { domain: t, ...n }, i) {
  var r;
  for (const s of e)
    s.value !== void 0 && (t === void 0 && (t = (r = s.value) == null ? void 0 : r.domain), s.value = i(s.value));
  return {
    domain: t === void 0 ? t : i(t),
    ...n
  };
}
function RK(e) {
  return ye(e, Fw);
}
function qp(e = {}) {
  let t;
  for (const n in e)
    if (Se.has(n) && jo(e[n])) {
      if (t !== void 0)
        throw new Error("ambiguous scale definition; multiple scales found");
      t = r8(O1(n, e[n]));
    }
  if (t === void 0)
    throw new Error("invalid scale definition; no scale found");
  return t;
}
function CK(e) {
  return (t) => {
    if (!Se.has(t = `${t}`))
      throw new Error(`unknown scale: ${t}`);
    return e[t];
  };
}
function r8({ scale: e, type: t, domain: n, range: i, interpolate: r, interval: s, transform: o, percent: a, pivot: c }) {
  if (t === "identity")
    return { type: "identity", apply: (u) => u, invert: (u) => u };
  const l = e.unknown ? e.unknown() : void 0;
  return {
    type: t,
    domain: Wu(n),
    // defensive copy
    ...i !== void 0 && { range: Wu(i) },
    // defensive copy
    ...o !== void 0 && { transform: o },
    ...a && { percent: a },
    // only exposed if truthy
    ...l !== void 0 && { unknown: l },
    ...s !== void 0 && { interval: s },
    // quantitative
    ...r !== void 0 && { interpolate: r },
    ...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: (u) => e(u),
    ...e.invert && { invert: (u) => e.invert(u) }
  };
}
function kK(e, t, n = {}) {
  let i = 0.5 - He, r = 0.5 + He, s = 0.5 + He, o = 0.5 - He;
  for (const { marginTop: y, marginRight: g, marginBottom: m, marginLeft: b } of t)
    y > i && (i = y), g > r && (r = g), m > s && (s = m), b > o && (o = b);
  let {
    margin: a,
    marginTop: c = a !== void 0 ? a : i,
    marginRight: l = a !== void 0 ? a : r,
    marginBottom: u = a !== void 0 ? a : s,
    marginLeft: f = a !== void 0 ? a : o
  } = n;
  c = +c, l = +l, u = +u, f = +f;
  let {
    width: h = 640,
    height: d = UK(e, n, {
      width: h,
      marginTopDefault: i,
      marginRightDefault: r,
      marginBottomDefault: s,
      marginLeftDefault: o
    }) + Math.max(0, c - i + u - s)
  } = n;
  h = +h, d = +d;
  const p = {
    width: h,
    height: d,
    marginTop: c,
    marginRight: l,
    marginBottom: u,
    marginLeft: f
  };
  if (e.fx || e.fy) {
    let {
      margin: y,
      marginTop: g = y !== void 0 ? y : c,
      marginRight: m = y !== void 0 ? y : l,
      marginBottom: b = y !== void 0 ? y : u,
      marginLeft: w = y !== void 0 ? y : f
    } = n.facet ?? {};
    g = +g, m = +m, b = +b, w = +w, p.facet = {
      marginTop: g,
      marginRight: m,
      marginBottom: b,
      marginLeft: w
    };
  }
  return p;
}
function UK({ x: e, y: t, fy: n, fx: i }, { projection: r, aspectRatio: s }, { width: o, marginTopDefault: a, marginRightDefault: c, marginBottomDefault: l, marginLeftDefault: u }) {
  const f = n ? n.scale.domain().length : 1, h = XJ(r);
  if (h) {
    const p = i ? i.scale.domain().length : 1, y = (1.1 * f - 0.1) / (1.1 * p - 0.1) * h, g = Math.max(0.1, Math.min(10, y));
    return Math.round((o - u - c) * g + a + l);
  }
  const d = t ? ua(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 = aS("y", t) / (aS("x", e) * s), y = i ? i.scale.bandwidth() : 1, g = n ? n.scale.bandwidth() : 1, m = y * (o - u - c) - e.insetLeft - e.insetRight;
    return (p * m + t.insetTop + t.insetBottom) / g + a + l;
  }
  return !!(t || n) * Math.max(1, Math.min(60, d * f)) * 20 + !!i * 30 + 60;
}
function aS(e, t) {
  if (!t)
    throw new Error(`aspectRatio requires ${e} scale`);
  const { type: n, domain: i } = t;
  let r;
  switch (n) {
    case "linear":
    case "utc":
    case "time":
      r = Number;
      break;
    case "pow": {
      const a = t.scale.exponent();
      r = (c) => Math.pow(c, a);
      break;
    }
    case "log":
      r = Math.log;
      break;
    case "point":
    case "band":
      return i.length;
    default:
      throw new Error(`unsupported ${e} scale for aspectRatio: ${n}`);
  }
  const [s, o] = ke(i);
  return Math.abs(r(o) - r(s));
}
function zK(e, t) {
  const { fx: n, fy: i } = B1(e, t), r = n == null ? void 0 : n.scale.domain(), s = i == null ? void 0 : i.scale.domain();
  return r && s ? Nz(r, s).map(([o, a], c) => ({ x: o, y: a, i: c })) : r ? r.map((o, a) => ({ x: o, i: a })) : s ? s.map((o, a) => ({ y: o, i: a })) : void 0;
}
function PK(e, { x: t, y: n }) {
  return t && (t = F1(t)), n && (n = F1(n)), e.filter(
    t && n ? (i) => t.has(i.x) && n.has(i.y) : t ? (i) => t.has(i.x) : (i) => n.has(i.y)
  ).sort(
    t && n ? (i, r) => t.get(i.x) - t.get(r.x) || n.get(i.y) - n.get(r.y) : t ? (i, r) => t.get(i.x) - t.get(r.x) : (i, r) => n.get(i.y) - n.get(r.y)
  );
}
function Qw(e, { fx: t, fy: n }) {
  const i = us(e), r = t == null ? void 0 : t.value, s = n == null ? void 0 : n.value;
  return t && n ? lc(
    i,
    (o) => (o.fx = r[o[0]], o.fy = s[o[0]], o),
    (o) => r[o],
    (o) => s[o]
  ) : t ? lc(
    i,
    (o) => (o.fx = r[o[0]], o),
    (o) => r[o]
  ) : lc(
    i,
    (o) => (o.fy = s[o[0]], o),
    (o) => s[o]
  );
}
function VK(e, t, { marginTop: n, marginLeft: i }) {
  return e && t ? ({ x: r, y: s }) => `translate(${e(r) - i},${t(s) - n})` : e ? ({ x: r }) => `translate(${e(r) - i},0)` : ({ y: r }) => `translate(0,${t(r) - n})`;
}
function jK(e) {
  const t = [], n = new Uint32Array(fr(e, (i) => i.length));
  for (const i of e) {
    let r = 0;
    for (const s of e)
      i !== s && (n.set(s, r), r += s.length);
    t.push(n.slice(0, r));
  }
  return t;
}
const qK = /* @__PURE__ */ new Map([
  ["top", qm],
  ["right", Gm],
  ["bottom", Ym],
  ["left", Wm],
  ["top-left", Mh(qm, Wm)],
  ["top-right", Mh(qm, Gm)],
  ["bottom-left", Mh(Ym, Wm)],
  ["bottom-right", Mh(Ym, Gm)],
  ["top-empty", GK],
  ["right-empty", JK],
  ["bottom-empty", XK],
  ["left-empty", HK],
  ["empty", KK]
]);
function YK(e) {
  if (e == null)
    return null;
  const t = qK.get(`${e}`.toLowerCase());
  if (t)
    return t;
  throw new Error(`invalid facet anchor: ${e}`);
}
const cS = /* @__PURE__ */ new WeakMap();
function F1(e) {
  let t = cS.get(e);
  return t || cS.set(e, t = new Jo(ye(e, (n, i) => [n, i]))), t;
}
function co(e, t) {
  return F1(e).get(t);
}
function WK(e, t, n) {
  return t = Eo(t), n = Eo(n), e.find((i) => Object.is(Eo(i.x), t) && Object.is(Eo(i.y), n));
}
function B0(e, t, n) {
  var i;
  return (i = WK(e, t, n)) == null ? void 0 : i.empty;
}
function qm(e, { y: t }, { y: n }) {
  return t ? co(t, n) === 0 : !0;
}
function Ym(e, { y: t }, { y: n }) {
  return t ? co(t, n) === t.length - 1 : !0;
}
function Wm(e, { x: t }, { x: n }) {
  return t ? co(t, n) === 0 : !0;
}
function Gm(e, { x: t }, { x: n }) {
  return t ? co(t, n) === t.length - 1 : !0;
}
function GK(e, { y: t }, { x: n, y: i, empty: r }) {
  if (r)
    return !1;
  if (!t)
    return;
  const s = co(t, i);
  if (s > 0)
    return B0(e, n, t[s - 1]);
}
function XK(e, { y: t }, { x: n, y: i, empty: r }) {
  if (r)
    return !1;
  if (!t)
    return;
  const s = co(t, i);
  if (s < t.length - 1)
    return B0(e, n, t[s + 1]);
}
function HK(e, { x: t }, { x: n, y: i, empty: r }) {
  if (r)
    return !1;
  if (!t)
    return;
  const s = co(t, n);
  if (s > 0)
    return B0(e, t[s - 1], i);
}
function JK(e, { x: t }, { x: n, y: i, empty: r }) {
  if (r)
    return !1;
  if (!t)
    return;
  const s = co(t, n);
  if (s < t.length - 1)
    return B0(e, t[s + 1], i);
}
function KK(e, t, { empty: n }) {
  return n;
}
function Mh(e, t) {
  return function() {
    return e.apply(null, arguments) && t.apply(null, arguments);
  };
}
function Xm(e, { channels: { fx: t, fy: n }, groups: i }) {
  return t && n ? e.map(({ x: r, y: s }) => {
    var o;
    return ((o = i.get(r)) == null ? void 0 : o.get(s)) ?? [];
  }) : t ? e.map(({ x: r }) => i.get(r) ?? []) : e.map(({ y: r }) => i.get(r) ?? []);
}
let fe = class {
  constructor(t, n = {}, i = {}, r) {
    const {
      facet: s = "auto",
      facetAnchor: o,
      fx: a,
      fy: c,
      sort: l,
      dx: u = 0,
      dy: f = 0,
      margin: h = 0,
      marginTop: d = h,
      marginRight: p = h,
      marginBottom: y = h,
      marginLeft: g = h,
      clip: m = r == null ? void 0 : r.clip,
      channels: b,
      tip: w,
      render: v
    } = i;
    if (this.data = t, this.sort = Xs(l) ? l : null, this.initializer = Bn(i).initializer, this.transform = this.initializer ? i.transform : vr(i).transform, s === null || s === !1 ? this.facet = null : (this.facet = qn(s === !0 ? "include" : s, "facet", ["auto", "include", "exclude", "super"]), this.fx = t === yu && typeof a == "string" ? [a] : a, this.fy = t === yu && typeof c == "string" ? [c] : c), this.facetAnchor = YK(o), n = Nw(n), b !== void 0 && (n = { ...ZK(b), ...n }), r !== void 0 && (n = { ...FD(this, i, r), ...n }), this.channels = Object.fromEntries(
      Object.entries(n).map(([_, x]) => {
        if (Hi(x.value)) {
          const { value: I, label: N = x.label, scale: A = x.scale } = x.value;
          x = { ...x, label: N, scale: A, value: I };
        }
        if (t === yu && typeof x.value == "string") {
          const { value: I } = x;
          x = { ...x, value: [I] };
        }
        return [_, x];
      }).filter(([_, { value: x, optional: I }]) => {
        if (x != null)
          return !0;
        if (I)
          return !1;
        throw new Error(`missing channel value: ${_}`);
      })
    ), this.dx = +u, this.dy = +f, this.marginTop = +d, this.marginRight = +p, this.marginBottom = +y, this.marginLeft = +g, this.clip = LD(m), this.tip = QK(w), this.facet === "super") {
      if (a || c)
        throw new Error("super-faceting cannot use fx or fy");
      for (const _ in this.channels) {
        const { scale: x } = n[_];
        if (!(x !== "x" && x !== "y"))
          throw new Error("super-faceting cannot use x or y");
      }
    }
    v != null && (this.render = Yp(v, this.render));
  }
  initialize(t, n, i) {
    let r = Nn(this.data);
    t === void 0 && r != null && (t = [us(r)]);
    const s = t;
    this.transform != null && ({ facets: t, data: r } = this.transform(r, t, i), r = Nn(r)), t !== void 0 && (t.original = s);
    const o = TD(this.channels, r);
    return this.sort != null && SJ(r, t, o, n, this.sort), { data: r, facets: t, channels: o };
  }
  filter(t, n, i) {
    for (const r in n) {
      const { filter: s = dn } = n[r];
      if (s !== null) {
        const o = i[r];
        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, i) {
    for (const r in t)
      if (t[r].scale === "x" && /^x|x$/.test(r)) {
        const s = r.replace(/^x|x$/, "y");
        s in t && t[s].scale === "y" && zD(r, s, n, i.projection);
      }
  }
  scale(t, n, i) {
    const r = qw(t, n);
    return i.projection && this.project(t, r, i), r;
  }
};
function ui(...e) {
  return e.plot = fe.prototype.plot, e;
}
function Yp(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, i, r, s, o, a) {
    return e.call(this, n, i, r, s, o, (c, l, u, f, h) => t.call(this, c, l, u, f, h, a));
  };
}
function ZK(e) {
  return Object.fromEntries(
    Object.entries(Nw(e)).map(([t, n]) => (n = typeof n == "string" ? { value: n, label: t } : ol(n), n.filter === void 0 && n.scale == null && (n = { ...n, filter: null }), [t, n]))
  );
}
function QK(e) {
  return e === !0 ? "xy" : e === !1 || e == null ? null : typeof e == "string" ? qn(e, "tip", ["x", "y", "xy"]) : e;
}
function fa(e, t) {
  return (e == null ? void 0 : e.tip) === !0 ? { ...e, tip: t } : hi(e == null ? void 0 : e.tip) && e.tip.pointer === void 0 ? { ...e, tip: { ...e.tip, pointer: t } } : e;
}
const lS = /* @__PURE__ */ new WeakMap();
function tv(e, t, { x: n, y: i, px: r, py: s, maxRadius: o = 40, channels: a, render: c, ...l } = {}) {
  return o = +o, r != null && (n ?? (n = null), a = { ...a, px: { value: r, scale: "x" } }), s != null && (i ?? (i = null), a = { ...a, py: { value: s, scale: "y" } }), {
    x: n,
    y: i,
    channels: a,
    ...l,
    // 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: Yp(function(u, f, h, d, p, y) {
      p = { ...p, pointerSticky: !1 };
      const g = p.ownerSVGElement, { data: m } = p.getMarkState(this);
      let b = lS.get(g);
      b || lS.set(g, b = { sticky: !1, roots: [], renders: [] });
      let w = b.renders.push(G) - 1;
      const { x: v, y: _, fx: x, fy: I } = f;
      let N = x ? x(u.fx) - d.marginLeft : 0, A = I ? I(u.fy) - d.marginTop : 0;
      v != null && v.bandwidth && (N += v.bandwidth() / 2), _ != null && _.bandwidth && (A += _.bandwidth() / 2);
      const D = u.fi != null;
      let M;
      if (D) {
        let Y = b.facetStates;
        Y || (b.facetStates = Y = /* @__PURE__ */ new Map()), M = Y.get(this), M || Y.set(this, M = /* @__PURE__ */ new Map());
      }
      const [B, R] = _r(this, d), { px: S, py: $ } = h, T = S ? (Y) => S[Y] : s8(h, B), L = $ ? (Y) => $[Y] : o8(h, R);
      let k, U, C, z;
      function P(Y, X) {
        if (D)
          if (z && (z = cancelAnimationFrame(z)), Y == null)
            M.delete(u.fi);
          else {
            M.set(u.fi, X), z = requestAnimationFrame(() => {
              z = null;
              for (const [j, J] of M)
                if (J < X || J === X && j < u.fi) {
                  Y = null;
                  break;
                }
              G(Y);
            });
            return;
          }
        G(Y);
      }
      function G(Y) {
        if (k === Y && C === b.sticky)
          return;
        k = Y, C = p.pointerSticky = b.sticky;
        const X = k == null ? [] : [k];
        D && (X.fx = u.fx, X.fy = u.fy, X.fi = u.fi);
        const j = y(X, f, h, d, p);
        if (U) {
          if (D) {
            const J = U.parentNode, et = U.getAttribute("transform"), V = j.getAttribute("transform");
            et ? j.setAttribute("transform", et) : j.removeAttribute("transform"), V ? J.setAttribute("transform", V) : J.removeAttribute("transform"), j.removeAttribute("aria-label"), j.removeAttribute("aria-description"), j.removeAttribute("aria-hidden");
          }
          U.replaceWith(j);
        }
        return b.roots[w] = U = j, k == null && (M == null ? void 0 : M.size) > 1 || p.dispatchValue(k == null ? null : m[k]), j;
      }
      function K(Y) {
        if (b.sticky || Y.pointerType === "mouse" && Y.buttons === 1)
          return;
        let [X, j] = yi(Y);
        X -= N, j -= A;
        const J = X < d.marginLeft || X > d.width - d.marginRight ? 1 : e, et = j < d.marginTop || j > d.height - d.marginBottom ? 1 : t;
        let V = null, Ft = o * o;
        for (const rt of u) {
          const Vt = J * (T(rt) - X), jt = et * (L(rt) - j), Q = Vt * Vt + jt * jt;
          Q <= Ft && (V = rt, Ft = Q);
        }
        if (V != null && (e !== 1 || t !== 1)) {
          const rt = T(V) - X, Vt = L(V) - j;
          Ft = rt * rt + Vt * Vt;
        }
        P(V, Ft);
      }
      function tt(Y) {
        Y.pointerType === "mouse" && k != null && (b.sticky && b.roots.some((X) => X == null ? void 0 : X.contains(Y.target)) || (b.sticky ? (b.sticky = !1, b.renders.forEach((X) => X(null))) : (b.sticky = !0, G(k)), Y.stopImmediatePropagation()));
      }
      function Z(Y) {
        Y.pointerType === "mouse" && (b.sticky || P(null));
      }
      return g.addEventListener("pointerenter", K), g.addEventListener("pointermove", K), g.addEventListener("pointerdown", tt), g.addEventListener("pointerleave", Z), G(null);
    }, c)
  };
}
function ev(e) {
  return tv(1, 1, e);
}
function nv(e) {
  return tv(1, 0.01, e);
}
function Wp(e) {
  return tv(0.01, 1, e);
}
function s8({ x1: e, x2: t, x: n = e }, i) {
  return e && t ? (r) => (e[r] + t[r]) / 2 : n ? (r) => n[r] : () => i;
}
function o8({ y1: e, y2: t, y: n = e }, i) {
  return e && t ? (r) => (e[r] + t[r]) / 2 : n ? (r) => n[r] : () => i;
}
function a8(e) {
  return ua(e) && e.interval === void 0 ? void 0 : "tabular-nums";
}
function tZ(e, t) {
  let {
    label: n = e.label,
    tickSize: i = 6,
    width: r = 240,
    height: s = 44 + i,
    marginTop: o = 18,
    marginRight: a = 0,
    marginBottom: c = 16 + i,
    marginLeft: l = 0,
    style: u,
    ticks: f = (r - l - a) / 64,
    tickFormat: h,
    fontVariant: d = a8(e),
    round: p = !0,
    opacity: y,
    className: g
  } = t;
  const m = $0(t);
  g = Gw(g), y = Be(y)[1], h === null && (h = () => null);
  const b = Gt("svg", m).attr("class", `${g}-ramp`).attr("font-family", "system-ui, sans-serif").attr("font-size", 10).attr("width", r).attr("height", s).attr("viewBox", `0 0 ${r} ${s}`).call(
    (B) => (
      // Warning: if you edit this, change defaultClassName.
      B.append("style").text(
        `:where(.${g}-ramp) {
  display: block;
  height: auto;
  height: intrinsic;
  max-width: 100%;
  overflow: visible;
}
:where(.${g}-ramp text) {
  white-space: pre;
}`
      )
    )
  ).call(Xw, u);
  let w = (B) => B.selectAll(".tick line").attr("y1", o + c - s), v;
  const _ = p ? (B, R) => B.rangeRound(R) : (B, R) => B.range(R), { type: x, domain: I, range: N, interpolate: A, scale: D, pivot: M } = e;
  if (A) {
    const B = N === void 0 ? A : e0(A.length === 1 ? Kw(A) : A, N);
    v = _(
      D.copy(),
      $i(
        Qe(l, r - a),
        Math.min(I.length + (M !== void 0), N === void 0 ? 1 / 0 : N.length)
      )
    );
    const R = 256, S = m.document.createElement("canvas");
    S.width = R, S.height = 1;
    const $ = S.getContext("2d");
    for (let T = 0, L = R - 1; T < R; ++T)
      $.fillStyle = B(T / L), $.fillRect(T, 0, 1, 1);
    b.append("image").attr("opacity", y).attr("x", l).attr("y", o).attr("width", r - l - a).attr("height", s - o - c).attr("preserveAspectRatio", "none").attr("xlink:href", S.toDataURL());
  } else if (x === "threshold") {
    const B = I, R = h === void 0 ? (S) => S : typeof h == "string" ? il(h) : h;
    v = _(l0().domain([-1, N.length - 1]), [l, r - a]), b.append("g").attr("fill-opacity", y).selectAll().data(N).enter().append("rect").attr("x", (S, $) => v($ - 1)).attr("y", o).attr("width", (S, $) => v($) - v($ - 1)).attr("height", s - o - c).attr("fill", (S) => S), f = ye(B, (S, $) => $), h = (S) => R(B[S], S);
  } else
    v = _(a0().domain(I), [l, r - a]), b.append("g").attr("fill-opacity", y).selectAll().data(I).enter().append("rect").attr("x", v).attr("y", o).attr("width", Math.max(0, v.bandwidth() - 1)).attr("height", s - o - c).attr("fill", D), w = () => {
    };
  return b.append("g").attr("transform", `translate(0,${s - c})`).call(
    Zz(v).ticks(Array.isArray(f) ? null : f, typeof h == "string" ? h : void 0).tickFormat(typeof h == "function" ? h : void 0).tickSize(i).tickValues(Array.isArray(f) ? f : null)
  ).attr("font-size", null).attr("font-family", null).attr("font-variant", Me(d, "normal")).call(w).call((B) => B.select(".domain").remove()), n !== void 0 && b.append("text").attr("x", l).attr("y", o - 6).attr("fill", "currentColor").attr("font-weight", "bold").text(n), b.node();
}
const Gp = Math.PI / 180;
function al(e, { marker: t, markerStart: n = t, markerMid: i = t, markerEnd: r = t } = {}) {
  e.markerStart = Hm(n), e.markerMid = Hm(i), e.markerEnd = Hm(r);
}
function Hm(e) {
  if (e == null || e === !1)
    return null;
  if (e === !0)
    return fS;
  if (typeof e == "function")
    return e;
  switch (`${e}`.toLowerCase()) {
    case "none":
      return null;
    case "arrow":
      return uS("auto");
    case "arrow-reverse":
      return uS("auto-start-reverse");
    case "dot":
      return eZ;
    case "circle":
    case "circle-fill":
      return fS;
    case "circle-stroke":
      return nZ;
    case "tick":
      return Jm("auto");
    case "tick-x":
      return Jm(90);
    case "tick-y":
      return Jm(0);
  }
  throw new Error(`invalid marker: ${e}`);
}
function uS(e) {
  return (t, n) => Gt("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((i) => i.append("path").attr("d", "M-1.5,-3l3,3l-3,3")).node();
}
function eZ(e, t) {
  return Gt("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 fS(e, t) {
  return Gt("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 nZ(e, t) {
  return Gt("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 Jm(e) {
  return (t, n) => Gt("svg:marker", n).attr("viewBox", "-3 -3 6 6").attr("markerWidth", 6).attr("markerHeight", 6).attr("orient", e).attr("stroke", t).call((i) => i.append("path").attr("d", "M0,-3v6")).node();
}
let iZ = 0;
function qf(e, t, { stroke: n }, i) {
  return c8(e, t, n && ((r) => n[r]), i);
}
function rZ(e, t, { stroke: n }, i) {
  return c8(e, t, n && (([r]) => n[r]), i);
}
function c8(e, { markerStart: t, markerMid: n, markerEnd: i, stroke: r }, s = () => r, o) {
  const a = /* @__PURE__ */ new Map();
  function c(l) {
    return function(u) {
      const f = s(u);
      let h = a.get(l);
      h || a.set(l, h = /* @__PURE__ */ new Map());
      let d = h.get(f);
      if (!d) {
        const p = this.parentNode.insertBefore(l(f, o), this), y = `plot-marker-${++iZ}`;
        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)), i && e.attr("marker-end", c(i));
}
function Yf({ inset: e, insetLeft: t, insetRight: n, ...i } = {}) {
  return [t, n] = l8(e, t, n), { inset: e, insetLeft: t, insetRight: n, ...i };
}
function Wf({ inset: e, insetTop: t, insetBottom: n, ...i } = {}) {
  return [t, n] = l8(e, t, n), { inset: e, insetTop: t, insetBottom: n, ...i };
}
function l8(e, t, n) {
  return e === void 0 && t === void 0 && n === void 0 ? He ? [1, 0] : [0.5, 0.5] : [t, n];
}
function u8(e, { interval: t }) {
  return e = { ...ol(e) }, e.interval = x0(e.interval === void 0 ? t : e.interval), e;
}
function O0(e, t, n, i) {
  const { [e]: r, [`${e}1`]: s, [`${e}2`]: o } = n, { value: a, interval: c } = u8(r, n);
  if (a == null || c == null && !i)
    return n;
  const l = wr(r);
  if (c == null) {
    let d;
    const p = { transform: (y) => d || (d = Pt(y, a)), label: l };
    return {
      ...n,
      [e]: void 0,
      [`${e}1`]: s === void 0 ? p : s,
      [`${e}2`]: o === void 0 && !(s === o && i) ? p : o
    };
  }
  let u, f;
  function h(d) {
    return f !== void 0 && d === u ? f : f = ye(Pt(u = d, a), (p) => c.floor(p));
  }
  return t({
    ...n,
    [e]: void 0,
    [`${e}1`]: s === void 0 ? { transform: h, label: l } : s,
    [`${e}2`]: o === void 0 ? { transform: (d) => h(d).map((p) => c.offset(p)), label: l } : o
  });
}
function f8(e, t, n) {
  const { [e]: i } = n, { value: r, interval: s } = u8(i, n);
  return r == null || s == null ? n : t({
    ...n,
    [e]: {
      label: wr(i),
      transform: (o) => {
        const a = ye(Pt(o, r), (l) => s.floor(l)), c = a.map((l) => s.offset(l));
        return a.map(
          gn(a) ? (l, u) => l == null || isNaN(l = +l) || (u = c[u], u == null) || isNaN(u = +u) ? void 0 : new Date((l + u) / 2) : (l, u) => l == null || (u = c[u], u == null) ? NaN : (+l + +u) / 2
        );
      }
    }
  });
}
function h8(e = {}) {
  return O0("x", Yf, e, !0);
}
function d8(e = {}) {
  return O0("y", Wf, e, !0);
}
function p8(e = {}) {
  return O0("x", Yf, e);
}
function y8(e = {}) {
  return O0("y", Wf, e);
}
function m8(e = {}) {
  return f8("x", Yf, e);
}
function g8(e = {}) {
  return f8("y", Wf, e);
}
const b8 = {
  ariaLabel: "rule",
  fill: null,
  stroke: "currentColor"
};
class w8 extends fe {
  constructor(t, n = {}) {
    const { x: i, y1: r, y2: s, inset: o = 0, insetTop: a = o, insetBottom: c = o } = n;
    super(
      t,
      {
        x: { value: i, scale: "x", optional: !0 },
        y1: { value: r, scale: "y", optional: !0 },
        y2: { value: s, scale: "y", optional: !0 }
      },
      fa(n, "x"),
      b8
    ), this.insetTop = qt(a), this.insetBottom = qt(c), al(this, n);
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = n, { x: c, y1: l, y2: u } = i, { width: f, height: h, marginTop: d, marginRight: p, marginLeft: y, marginBottom: g } = r, { insetTop: m, insetBottom: b } = this;
    return Gt("svg:g", s).call(ve, this, r, s).call(ue, this, { x: c && o }, He, 0).call(
      (w) => w.selectAll().data(t).enter().append("line").call(be, this).attr("x1", c ? (v) => c[v] : (y + f - p) / 2).attr("x2", c ? (v) => c[v] : (y + f - p) / 2).attr("y1", l && !oi(a) ? (v) => l[v] + m : d + m).attr(
        "y2",
        u && !oi(a) ? a.bandwidth ? (v) => u[v] + a.bandwidth() - b : (v) => u[v] - b : h - g - b
      ).call(Pe, this, i).call(qf, this, i, s)
    ).node();
  }
}
class v8 extends fe {
  constructor(t, n = {}) {
    const { x1: i, x2: r, y: s, inset: o = 0, insetRight: a = o, insetLeft: c = o } = n;
    super(
      t,
      {
        y: { value: s, scale: "y", optional: !0 },
        x1: { value: i, scale: "x", optional: !0 },
        x2: { value: r, scale: "x", optional: !0 }
      },
      fa(n, "y"),
      b8
    ), this.insetRight = qt(a), this.insetLeft = qt(c), al(this, n);
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = n, { y: c, x1: l, x2: u } = i, { width: f, height: h, marginTop: d, marginRight: p, marginLeft: y, marginBottom: g } = r, { insetLeft: m, insetRight: b } = this;
    return Gt("svg:g", s).call(ve, this, r, s).call(ue, this, { y: c && a }, 0, He).call(
      (w) => w.selectAll().data(t).enter().append("line").call(be, this).attr("x1", l && !oi(o) ? (v) => l[v] + m : y + m).attr(
        "x2",
        u && !oi(o) ? o.bandwidth ? (v) => u[v] + o.bandwidth() - b : (v) => u[v] - b : f - p - b
      ).attr("y1", c ? (v) => c[v] : (d + h - g) / 2).attr("y2", c ? (v) => c[v] : (d + h - g) / 2).call(Pe, this, i).call(qf, this, i, s)
    ).node();
  }
}
function Hs(e, t) {
  let { x: n = Tt, y: i, y1: r, y2: s, ...o } = y8(t);
  return [r, s] = _8(i, r, s), new w8(e, { ...o, x: n, y1: r, y2: s });
}
function Js(e, t) {
  let { y: n = Tt, x: i, x1: r, x2: s, ...o } = p8(t);
  return [r, s] = _8(i, r, s), new v8(e, { ...o, y: n, x1: r, x2: s });
}
function _8(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 F0(e, ...t) {
  let n = t.length;
  for (let i = 0, r = !0; i < n; ++i)
    typeof t[i] != "function" && (r && (e = e.slice(), r = !1), e.splice(i, 2, e[i] + t[i] + e[i + 1]), t.splice(i, 1), --i, --n);
  return (i) => {
    let r = e[0];
    for (let s = 0; s < n; ++s)
      r += t[s](i) + e[s + 1];
    return r;
  };
}
const sZ = {
  ariaLabel: "text",
  strokeLinejoin: "round",
  strokeWidth: 3,
  paintOrder: "stroke"
}, x8 = "­";
class E0 extends fe {
  constructor(t, n = {}) {
    const {
      x: i,
      y: r,
      text: s = fs(t) && mD(t) ? Tt : vn,
      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: l = 1,
      lineWidth: u = 1 / 0,
      textOverflow: f,
      monospace: h,
      fontFamily: d = h ? "ui-monospace, monospace" : void 0,
      fontSize: p,
      fontStyle: y,
      fontVariant: g,
      fontWeight: m,
      rotate: b
    } = n, [w, v] = Be(b, 0), [_, x] = lZ(p);
    if (super(
      t,
      {
        x: { value: i, scale: "x", optional: !0 },
        y: { value: r, scale: "y", optional: !0 },
        fontSize: { value: _, optional: !0 },
        rotate: { value: GH(w), optional: !0 },
        text: { value: s, filter: vw, optional: !0 }
      },
      n,
      sZ
    ), this.rotate = v, this.textAnchor = Me(a, "middle"), this.lineAnchor = qn(c, "lineAnchor", ["top", "middle", "bottom"]), this.lineHeight = +l, this.lineWidth = +u, this.textOverflow = S8(f), this.monospace = !!h, this.fontFamily = tn(d), this.fontSize = x, this.fontStyle = tn(y), this.fontVariant = tn(g), this.fontWeight = tn(m), this.frameAnchor = kf(o), !(this.lineWidth >= 0))
      throw new Error(`invalid lineWidth: ${u}`);
    this.splitLines = $8(this), this.clipLine = T8(this);
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = n, { x: c, y: l, rotate: u, text: f, title: h, fontSize: d } = i, { rotate: p } = this, [y, g] = _r(this, r);
    return Gt("svg:g", s).call(ve, this, r, s).call(M8, this, f, r).call(ue, this, { x: c && o, y: l && a }).call(
      (m) => m.selectAll().data(t).enter().append("text").call(be, this).call(oZ, this, f, h).attr(
        "transform",
        F0`translate(${c ? (b) => c[b] : y},${l ? (b) => l[b] : g})${u ? (b) => ` rotate(${u[b]})` : p ? ` rotate(${p})` : ""}`
      ).call(yt, "font-size", d && ((b) => d[b])).call(Pe, this, i)
    ).node();
  }
}
function S8(e) {
  return e == null ? null : qn(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 oZ(e, t, n, i) {
  if (!n)
    return;
  const { lineAnchor: r, lineHeight: s, textOverflow: o, splitLines: a, clipLine: c } = t;
  e.each(function(l) {
    const u = a(ra(n[l]) ?? "").map(c), f = u.length, h = r === "top" ? 0.71 : r === "bottom" ? 1 - f : (164 - f * 100) / 200;
    if (f > 1) {
      let d = 0;
      for (let p = 0; p < f; ++p) {
        if (++d, !u[p])
          continue;
        const y = this.ownerDocument.createElementNS(Ko.svg, "tspan");
        y.setAttribute("x", 0), p === d - 1 ? y.setAttribute("y", `${(h + p) * s}em`) : y.setAttribute("dy", `${d * s}em`), y.textContent = u[p], this.appendChild(y), d = 0;
      }
    } else
      h && this.setAttribute("y", `${h * s}em`), this.textContent = u[0];
    if (o && !i && u[0] !== n[l]) {
      const d = this.ownerDocument.createElementNS(Ko.svg, "title");
      d.textContent = n[l], this.appendChild(d);
    }
  });
}
function zc(e, { x: t, y: n, ...i } = {}) {
  return i.frameAnchor === void 0 && ([t, n] = ki(t, n)), new E0(e, { ...i, x: t, y: n });
}
function I8(e, { x: t = Tt, ...n } = {}) {
  return new E0(e, g8({ ...n, x: t }));
}
function A8(e, { y: t = Tt, ...n } = {}) {
  return new E0(e, m8({ ...n, y: t }));
}
function M8(e, t, n) {
  yt(e, "text-anchor", t.textAnchor), yt(e, "font-family", t.fontFamily), yt(e, "font-size", t.fontSize), yt(e, "font-style", t.fontStyle), yt(e, "font-variant", t.fontVariant === void 0 ? aZ(n) : t.fontVariant), yt(e, "font-weight", t.fontWeight);
}
function aZ(e) {
  return e && (ec(e) || gn(e)) ? "tabular-nums" : void 0;
}
const cZ = /* @__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 lZ(e) {
  return e == null || typeof e == "number" ? [void 0, e] : typeof e != "string" ? [e, void 0] : (e = e.trim().toLowerCase(), cZ.has(e) || /^[+-]?\d*\.?\d+(e[+-]?\d+)?(\w*|%)$/.test(e) ? [void 0, e] : [e, void 0]);
}
function uZ(e, t, n) {
  const i = [];
  let r, s = 0;
  for (const [o, a, c] of fZ(e)) {
    if (r === void 0 && (r = o), s > r && n(e, r, a) > t && (i.push(e.slice(r, s) + (e[s - 1] === x8 ? "-" : "")), r = o), c) {
      i.push(e.slice(r, a)), r = void 0;
      continue;
    }
    s = a;
  }
  return i;
}
function* fZ(e) {
  let t = 0, n = 0;
  const i = e.length;
  for (; n < i; ) {
    let r = 1;
    switch (e[n]) {
      case x8:
      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] === `
` && ++r;
      case `
`:
        yield [t, n, !0], n += r, t = n;
        break;
      default:
        ++n;
        break;
    }
  }
  yield [t, n, !0];
}
const hS = {
  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 iv(e, t = 0, n = e.length) {
  let i = 0;
  for (let r = t; r < n; r = cl(e, r))
    i += hS[e[r]] ?? (N8(e, r) ? 120 : hS.e);
  return i;
}
function rv(e, t = 0, n = e.length) {
  let i = 0;
  for (let r = t; r < n; r = cl(e, r))
    i += N8(e, r) ? 126 : 63;
  return i;
}
function $8({ monospace: e, lineWidth: t, textOverflow: n }) {
  if (n != null || t == 1 / 0)
    return (s) => s.split(/\r\n?|\n/g);
  const i = e ? rv : iv, r = t * 100;
  return (s) => uZ(s, r, i);
}
function T8({ monospace: e, lineWidth: t, textOverflow: n }) {
  if (n == null || t == 1 / 0)
    return (s) => s;
  const i = e ? rv : iv, r = t * 100;
  switch (n) {
    case "clip-start":
      return (s) => pS(s, r, i, "");
    case "clip-end":
      return (s) => dS(s, r, i, "");
    case "ellipsis-start":
      return (s) => pS(s, r, i, pc);
    case "ellipsis-middle":
      return (s) => hZ(s, r, i, pc);
    case "ellipsis-end":
      return (s) => dS(s, r, i, pc);
  }
}
const pc = "…";
function Pc(e, t, n, i) {
  const r = [];
  let s = 0;
  for (let o = 0, a = 0, c = e.length; o < c; o = a) {
    a = cl(e, o);
    const l = n(e, o, a);
    if (s + l > t) {
      for (s += i; s > t && o > 0; )
        a = o, o = r.pop(), s -= n(e, o, a);
      return [o, t - s];
    }
    s += l, r.push(o);
  }
  return [-1, 0];
}
function dS(e, t, n, i) {
  e = e.trim();
  const r = n(i), [s] = Pc(e, t, n, r);
  return s < 0 ? e : e.slice(0, s).trimEnd() + i;
}
function hZ(e, t, n, i) {
  e = e.trim();
  const r = n(e);
  if (r <= t)
    return e;
  const s = n(i) / 2, [o, a] = Pc(e, t / 2, n, s), [c] = Pc(e, r - t / 2 - a + s, n, -s);
  return c < 0 ? i : e.slice(0, o).trimEnd() + i + e.slice(cl(e, c)).trimStart();
}
function pS(e, t, n, i) {
  e = e.trim();
  const r = n(e);
  if (r <= t)
    return e;
  const s = n(i), [o] = Pc(e, r - t + s, n, -s);
  return o < 0 ? i : i + e.slice(cl(e, o)).trimStart();
}
const E1 = /[\p{Combining_Mark}\p{Emoji_Modifier}]+/uy, yS = new RegExp("\\p{Extended_Pictographic}", "uy");
function cl(e, t) {
  return t += dZ(e, t) ? 2 : 1, yZ(e, t) && (t = E1.lastIndex), pZ(e, t) ? cl(e, t + 1) : t;
}
function D8(e, t) {
  return e.charCodeAt(t) < 128;
}
function dZ(e, t) {
  const n = e.charCodeAt(t);
  if (n >= 55296 && n < 56320) {
    const i = e.charCodeAt(t + 1);
    return i >= 56320 && i < 57344;
  }
  return !1;
}
function pZ(e, t) {
  return e.charCodeAt(t) === 8205;
}
function yZ(e, t) {
  return D8(e, t) ? !1 : (E1.lastIndex = t, E1.test(e));
}
function N8(e, t) {
  return D8(e, t) ? !1 : (yS.lastIndex = t, yS.test(e));
}
const B8 = {
  ariaLabel: "vector",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1.5,
  strokeLinejoin: "round",
  strokeLinecap: "round"
}, O8 = 3.5, mZ = O8 * 5, F8 = {
  draw(e, t, n) {
    const i = t * n / mZ;
    e.moveTo(0, 0), e.lineTo(0, -t), e.moveTo(-i, i - t), e.lineTo(0, -t), e.lineTo(i, i - t);
  }
}, E8 = {
  draw(e, t, n) {
    e.moveTo(-n, 0), e.lineTo(0, -t), e.lineTo(n, 0);
  }
}, gZ = /* @__PURE__ */ new Map([
  ["arrow", F8],
  ["spike", E8]
]);
function bZ(e) {
  return e && typeof e.draw == "function";
}
function wZ(e) {
  if (bZ(e))
    return e;
  const t = gZ.get(`${e}`.toLowerCase());
  if (t)
    return t;
  throw new Error(`invalid shape: ${e}`);
}
let L0 = class extends fe {
  constructor(t, n = {}) {
    const { x: i, y: r, r: s = O8, length: o, rotate: a, shape: c = F8, anchor: l = "middle", frameAnchor: u } = n, [f, h] = Be(o, 12), [d, p] = Be(a, 0);
    super(
      t,
      {
        x: { value: i, scale: "x", optional: !0 },
        y: { value: r, scale: "y", optional: !0 },
        length: { value: f, scale: "length", optional: !0 },
        rotate: { value: d, optional: !0 }
      },
      n,
      B8
    ), this.r = +s, this.length = h, this.rotate = p, this.shape = wZ(c), this.anchor = qn(l, "anchor", ["start", "middle", "end"]), this.frameAnchor = kf(u);
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = n, { x: c, y: l, length: u, rotate: f } = i, { length: h, rotate: d, anchor: p, shape: y, r: g } = this, [m, b] = _r(this, r);
    return Gt("svg:g", s).call(ve, this, r, s).call(ue, this, { x: c && o, y: l && a }).call(
      (w) => w.selectAll().data(t).enter().append("path").call(be, this).attr(
        "transform",
        F0`translate(${c ? (v) => c[v] : m},${l ? (v) => l[v] : b})${f ? (v) => ` rotate(${f[v]})` : d ? ` rotate(${d})` : ""}${p === "start" ? "" : p === "end" ? u ? (v) => ` translate(0,${u[v]})` : ` translate(0,${h})` : u ? (v) => ` translate(0,${u[v] / 2})` : ` translate(0,${h / 2})`}`
      ).attr(
        "d",
        u ? (v) => {
          const _ = Gr();
          return y.draw(_, u[v], g), _;
        } : (() => {
          const v = Gr();
          return y.draw(v, h, g), v;
        })()
      ).call(Pe, this, i)
    ).node();
  }
};
function L8(e, t = {}) {
  let { x: n, y: i, ...r } = t;
  return t.frameAnchor === void 0 && ([n, i] = ki(n, i)), new L0(e, { ...r, x: n, y: i });
}
function R8(e, t = {}) {
  const { x: n = Tt, ...i } = t;
  return new L0(e, { ...i, x: n });
}
function C8(e, t = {}) {
  const { y: n = Tt, ...i } = t;
  return new L0(e, { ...i, y: n });
}
function vZ(e, t = {}) {
  const {
    shape: n = E8,
    stroke: i = B8.stroke,
    strokeWidth: r = 1,
    fill: s = i,
    fillOpacity: o = 0.3,
    anchor: a = "start",
    ...c
  } = t;
  return L8(e, { ...c, shape: n, stroke: i, strokeWidth: r, fill: s, fillOpacity: o, anchor: a });
}
function lo(e, t) {
  return arguments.length < 2 && !fs(e) && (t = e, e = null), t === void 0 && (t = {}), [e, t];
}
function R0({ anchor: e } = {}, t) {
  return e === void 0 ? t[0] : qn(e, "anchor", t);
}
function k8(e) {
  return R0(e, ["left", "right"]);
}
function U8(e) {
  return R0(e, ["right", "left"]);
}
function z8(e) {
  return R0(e, ["bottom", "top"]);
}
function P8(e) {
  return R0(e, ["top", "bottom"]);
}
function sv() {
  const [e, t] = lo(...arguments);
  return q8("y", k8(t), e, t);
}
function V8() {
  const [e, t] = lo(...arguments);
  return q8("fy", U8(t), e, t);
}
function ov() {
  const [e, t] = lo(...arguments);
  return Y8("x", z8(t), e, t);
}
function j8() {
  const [e, t] = lo(...arguments);
  return Y8("fx", P8(t), e, t);
}
function q8(e, t, n, {
  color: i = "currentColor",
  opacity: r = 1,
  stroke: s = i,
  strokeOpacity: o = r,
  strokeWidth: a = 1,
  fill: c = i,
  fillOpacity: l = r,
  textAnchor: u,
  textStroke: f,
  textStrokeOpacity: h,
  textStrokeWidth: d,
  tickSize: p = e === "y" ? 6 : 0,
  tickPadding: y,
  tickRotate: g,
  x: m,
  margin: b,
  marginTop: w = b === void 0 ? 20 : b,
  marginRight: v = b === void 0 ? t === "right" ? 40 : 0 : b,
  marginBottom: _ = b === void 0 ? 20 : b,
  marginLeft: x = b === void 0 ? t === "left" ? 40 : 0 : b,
  label: I,
  labelAnchor: N,
  labelArrow: A,
  labelOffset: D,
  ...M
}) {
  return p = qt(p), y = qt(y), g = qt(g), N !== void 0 && (N = qn(N, "labelAnchor", ["center", "top", "bottom"])), A = i4(A), ui(
    p && !we(s) ? _Z(e, t, n, {
      stroke: s,
      strokeOpacity: o,
      strokeWidth: a,
      tickSize: p,
      tickPadding: y,
      tickRotate: g,
      x: m,
      ...M
    }) : null,
    we(c) ? null : SZ(e, t, n, {
      fill: c,
      fillOpacity: l,
      stroke: f,
      strokeOpacity: h,
      strokeWidth: d,
      textAnchor: u,
      tickSize: p,
      tickPadding: y,
      tickRotate: g,
      x: m,
      marginTop: w,
      marginRight: v,
      marginBottom: _,
      marginLeft: x,
      ...M
    }),
    !we(c) && I !== null ? zc(
      [],
      Q8({ fill: c, fillOpacity: l, ...M }, function(B, R, S, $, T) {
        const L = $[e], { marginTop: k, marginRight: U, marginBottom: C, marginLeft: z } = e === "y" && T.inset || T, P = N ?? (L.bandwidth ? "center" : "top"), G = D ?? (t === "right" ? U : z) - 3;
        return P === "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 = P, this.frameAnchor = `${P}-${t}`, this.rotate = 0), this.dy = P === "top" ? 3 - k : P === "bottom" ? C - 3 : 0, this.dx = t === "right" ? G : -G, this.ariaLabel = `${e}-axis label`, {
          facets: [[0]],
          channels: { text: { value: [n4(e, L, { anchor: t, label: I, labelAnchor: P, labelArrow: A })] } }
        };
      })
    ) : null
  );
}
function Y8(e, t, n, {
  color: i = "currentColor",
  opacity: r = 1,
  stroke: s = i,
  strokeOpacity: o = r,
  strokeWidth: a = 1,
  fill: c = i,
  fillOpacity: l = r,
  textAnchor: u,
  textStroke: f,
  textStrokeOpacity: h,
  textStrokeWidth: d,
  tickSize: p = e === "x" ? 6 : 0,
  tickPadding: y,
  tickRotate: g,
  y: m,
  margin: b,
  marginTop: w = b === void 0 ? t === "top" ? 30 : 0 : b,
  marginRight: v = b === void 0 ? 20 : b,
  marginBottom: _ = b === void 0 ? t === "bottom" ? 30 : 0 : b,
  marginLeft: x = b === void 0 ? 20 : b,
  label: I,
  labelAnchor: N,
  labelArrow: A,
  labelOffset: D,
  ...M
}) {
  return p = qt(p), y = qt(y), g = qt(g), N !== void 0 && (N = qn(N, "labelAnchor", ["center", "left", "right"])), A = i4(A), ui(
    p && !we(s) ? xZ(e, t, n, {
      stroke: s,
      strokeOpacity: o,
      strokeWidth: a,
      tickSize: p,
      tickPadding: y,
      tickRotate: g,
      y: m,
      ...M
    }) : null,
    we(c) ? null : IZ(e, t, n, {
      fill: c,
      fillOpacity: l,
      stroke: f,
      strokeOpacity: h,
      strokeWidth: d,
      textAnchor: u,
      tickSize: p,
      tickPadding: y,
      tickRotate: g,
      y: m,
      marginTop: w,
      marginRight: v,
      marginBottom: _,
      marginLeft: x,
      ...M
    }),
    !we(c) && I !== null ? zc(
      [],
      Q8({ fill: c, fillOpacity: l, ...M }, function(B, R, S, $, T) {
        const L = $[e], { marginTop: k, marginRight: U, marginBottom: C, marginLeft: z } = e === "x" && T.inset || T, P = N ?? (L.bandwidth ? "center" : "right"), G = D ?? (t === "top" ? k : C) - 3;
        return P === "center" ? (this.frameAnchor = t, this.textAnchor = void 0) : (this.frameAnchor = `${t}-${P}`, this.textAnchor = P === "right" ? "end" : "start"), this.lineAnchor = t, this.dy = t === "top" ? -G : G, this.dx = P === "right" ? U - 3 : P === "left" ? 3 - z : 0, this.ariaLabel = `${e}-axis label`, {
          facets: [[0]],
          channels: { text: { value: [n4(e, L, { anchor: t, label: I, labelAnchor: P, labelArrow: A })] } }
        };
      })
    ) : null
  );
}
function _Z(e, t, n, {
  strokeWidth: i = 1,
  strokeLinecap: r = null,
  strokeLinejoin: s = null,
  facetAnchor: o = t + (e === "y" ? "-empty" : ""),
  frameAnchor: a = t,
  tickSize: c,
  inset: l = 0,
  insetLeft: u = l,
  insetRight: f = l,
  dx: h = 0,
  y: d = e === "y" ? void 0 : null,
  ...p
}) {
  return ll(C8, e, t, `${e}-axis tick`, n, {
    strokeWidth: i,
    strokeLinecap: r,
    strokeLinejoin: s,
    facetAnchor: o,
    frameAnchor: a,
    y: d,
    ...p,
    dx: t === "left" ? +h - He + +u : +h + He - f,
    anchor: "start",
    length: c,
    shape: t === "left" ? TZ : DZ
  });
}
function xZ(e, t, n, {
  strokeWidth: i = 1,
  strokeLinecap: r = null,
  strokeLinejoin: s = null,
  facetAnchor: o = t + (e === "x" ? "-empty" : ""),
  frameAnchor: a = t,
  tickSize: c,
  inset: l = 0,
  insetTop: u = l,
  insetBottom: f = l,
  dy: h = 0,
  x: d = e === "x" ? void 0 : null,
  ...p
}) {
  return ll(R8, e, t, `${e}-axis tick`, n, {
    strokeWidth: i,
    strokeLinejoin: s,
    strokeLinecap: r,
    facetAnchor: o,
    frameAnchor: a,
    x: d,
    ...p,
    dy: t === "bottom" ? +h - He - f : +h + He + +u,
    anchor: "start",
    length: c,
    shape: t === "bottom" ? MZ : $Z
  });
}
function SZ(e, t, n, {
  facetAnchor: i = t + (e === "y" ? "-empty" : ""),
  frameAnchor: r = t,
  tickSize: s,
  tickRotate: o = 0,
  tickPadding: a = Math.max(3, 9 - s) + (Math.abs(o) > 60 ? 4 * Math.cos(o * Gp) : 0),
  text: c,
  textAnchor: l = Math.abs(o) > 60 ? "middle" : t === "left" ? "end" : "start",
  lineAnchor: u = o > 60 ? "top" : o < -60 ? "bottom" : "middle",
  fontVariant: f,
  inset: h = 0,
  insetLeft: d = h,
  insetRight: p = h,
  dx: y = 0,
  y: g = e === "y" ? void 0 : null,
  ...m
}) {
  return ll(
    A8,
    e,
    t,
    `${e}-axis tick label`,
    n,
    {
      facetAnchor: i,
      frameAnchor: r,
      text: c,
      textAnchor: l,
      lineAnchor: u,
      fontVariant: f,
      rotate: o,
      y: g,
      ...m,
      dx: t === "left" ? +y - s - a + +d : +y + +s + +a - p
    },
    function(b, w, v, _, x) {
      f === void 0 && (this.fontVariant = e4(b)), c === void 0 && (x.text = t4(b, w, v, _, t));
    }
  );
}
function IZ(e, t, n, {
  facetAnchor: i = t + (e === "x" ? "-empty" : ""),
  frameAnchor: r = t,
  tickSize: s,
  tickRotate: o = 0,
  tickPadding: a = Math.max(3, 9 - s) + (Math.abs(o) >= 10 ? 4 * Math.cos(o * Gp) : 0),
  text: c,
  textAnchor: l = Math.abs(o) >= 10 ? o < 0 ^ t === "bottom" ? "start" : "end" : "middle",
  lineAnchor: u = Math.abs(o) >= 10 ? "middle" : t === "bottom" ? "top" : "bottom",
  fontVariant: f,
  inset: h = 0,
  insetTop: d = h,
  insetBottom: p = h,
  dy: y = 0,
  x: g = e === "x" ? void 0 : null,
  ...m
}) {
  return ll(
    I8,
    e,
    t,
    `${e}-axis tick label`,
    n,
    {
      facetAnchor: i,
      frameAnchor: r,
      text: c === void 0 ? null : c,
      textAnchor: l,
      lineAnchor: u,
      fontVariant: f,
      rotate: o,
      x: g,
      ...m,
      dy: t === "bottom" ? +y + +s + +a - p : +y - s - a + +d
    },
    function(b, w, v, _, x) {
      f === void 0 && (this.fontVariant = e4(b)), c === void 0 && (x.text = t4(b, w, v, _, t));
    }
  );
}
function W8() {
  const [e, t] = lo(...arguments);
  return J8("y", k8(t), e, t);
}
function G8() {
  const [e, t] = lo(...arguments);
  return J8("fy", U8(t), e, t);
}
function X8() {
  const [e, t] = lo(...arguments);
  return K8("x", z8(t), e, t);
}
function H8() {
  const [e, t] = lo(...arguments);
  return K8("fx", P8(t), e, t);
}
function J8(e, t, n, {
  y: i = e === "y" ? void 0 : null,
  x: r = null,
  x1: s = t === "left" ? r : null,
  x2: o = t === "right" ? r : null,
  ...a
}) {
  return ll(Js, e, t, `${e}-grid`, n, { y: i, x1: s, x2: o, ...Z8(a) });
}
function K8(e, t, n, {
  x: i = e === "x" ? void 0 : null,
  y: r = null,
  y1: s = t === "top" ? r : null,
  y2: o = t === "bottom" ? r : null,
  ...a
}) {
  return ll(Hs, e, t, `${e}-grid`, n, { x: i, y1: s, y2: o, ...Z8(a) });
}
function Z8({
  color: e = "currentColor",
  opacity: t = 0.1,
  stroke: n = e,
  strokeOpacity: i = t,
  strokeWidth: r = 1,
  ...s
}) {
  return { stroke: n, strokeOpacity: i, strokeWidth: r, ...s };
}
function Q8({
  fill: e,
  fillOpacity: t,
  fontFamily: n,
  fontSize: i,
  fontStyle: r,
  fontVariant: s,
  fontWeight: o,
  monospace: a,
  pointerEvents: c,
  shapeRendering: l,
  clip: u = !1
}, f) {
  return [, e] = mn(e), [, t] = Be(t), {
    facet: "super",
    x: null,
    y: null,
    fill: e,
    fillOpacity: t,
    fontFamily: n,
    fontSize: i,
    fontStyle: r,
    fontVariant: s,
    fontWeight: o,
    monospace: a,
    pointerEvents: c,
    shapeRendering: l,
    clip: u,
    initializer: f
  };
}
function ll(e, t, n, i, r, s, o) {
  let a;
  function c(f, h, d, p, y, g) {
    const m = f == null && (t === "fx" || t === "fy"), { [t]: b } = p;
    if (!b)
      throw new Error(`missing scale: ${t}`);
    const w = b.domain();
    let { interval: v, ticks: _, tickFormat: x, tickSpacing: I = t === "x" ? 80 : 35 } = s;
    if (typeof _ == "string" && r4(b) && (v = _, _ = void 0), _ === void 0 && (_ = sl(v, b.type) ?? AZ(b, I)), f == null) {
      if (fs(_))
        f = Nn(_);
      else if (tc(_))
        f = Km(_, ...ke(w));
      else if (b.interval) {
        let A = b.interval;
        if (b.ticks) {
          const [D, M] = ke(w), B = (M - D) / A[Lf];
          A = Vx(A, B / _) ?? A, f = Km(A, D, M);
        } else {
          f = w;
          const D = f.length;
          A = Vx(A, D / _) ?? A, A !== b.interval && (f = Km(A, ...ke(f)));
        }
        if (A === b.interval) {
          const D = Math.round(f.length / _);
          D > 1 && (f = f.filter((M, B) => B % D === 0));
        }
      } else
        b.ticks ? f = b.ticks(_) : f = w;
      if (!b.ticks && f.length && f !== w) {
        const A = new tl(w);
        f = f.filter((D) => A.has(D)), f.length || Qr(`Warning: the ${t}-axis ticks appear to not align with the scale domain, resulting in no ticks. Try different ticks?`);
      }
      t === "y" || t === "x" ? h = [us(f)] : a[t] = { scale: t, value: Tt };
    }
    o == null || o.call(this, b, f, _, x, a);
    const N = Object.fromEntries(
      Object.entries(a).map(([A, D]) => [A, { ...D, value: Pt(f, D.value) }])
    );
    return m && (h = g.filterFacets(f, N)), { data: f, facets: h, channels: N };
  }
  const l = Bn(s).initializer, u = e(r, Bn({ ...s, initializer: c }, l));
  return r == null ? (a = u.channels, u.channels = {}) : a = {}, u.ariaLabel = i, u.clip === void 0 && (u.clip = !1), u;
}
function AZ(e, t) {
  const [n, i] = ke(e.range());
  return (i - n) / t;
}
function t4(e, t, n, i, r) {
  return { value: av(e, t, n, i, r) };
}
function av(e, t, n, i, r) {
  return typeof i == "function" ? i : i === void 0 && t && gn(t) ? kH(e.type, t, r) ?? ra : e.tickFormat ? e.tickFormat(typeof n == "number" ? n : null, i) : i === void 0 ? ra : typeof i == "string" ? (gn(e.domain()) ? Ff : il)(i) : jn(i);
}
function Km(e, t, n) {
  return e.range(t, e.offset(e.floor(n)));
}
const MZ = {
  draw(e, t) {
    e.moveTo(0, 0), e.lineTo(0, t);
  }
}, $Z = {
  draw(e, t) {
    e.moveTo(0, 0), e.lineTo(0, -t);
  }
}, TZ = {
  draw(e, t) {
    e.moveTo(0, 0), e.lineTo(-t, 0);
  }
}, DZ = {
  draw(e, t) {
    e.moveTo(0, 0), e.lineTo(t, 0);
  }
};
function e4(e) {
  return e.bandwidth && !e.interval ? void 0 : "tabular-nums";
}
function n4(e, t, { anchor: n, label: i = t.label, labelAnchor: r, labelArrow: s } = {}) {
  if (!(i == null || i.inferred && r4(t) && /^(date|time|year)$/i.test(i))) {
    if (i = String(i), s === "auto" && (s = (!t.bandwidth || t.interval) && !/[↑↓→←]/.test(i)), !s)
      return i;
    if (s === !0) {
      const o = ZD(t);
      o && (s = /x$/.test(e) || r === "center" ? /x$/.test(e) === o < 0 ? "left" : "right" : o < 0 ? "up" : "down");
    }
    switch (s) {
      case "left":
        return `← ${i}`;
      case "right":
        return `${i} →`;
      case "up":
        return n === "right" ? `${i} ↑` : `↑ ${i}`;
      case "down":
        return n === "right" ? `${i} ↓` : `↓ ${i}`;
    }
    return i;
  }
}
function i4(e = "auto") {
  return we(e) ? !1 : typeof e == "boolean" ? e : qn(e, "labelArrow", ["auto", "up", "right", "down", "left"]);
}
function r4(e) {
  return gn(e.domain());
}
function mS(e, t) {
  if (t == null)
    return t;
  const n = e(t);
  if (!n)
    throw new Error(`scale not found: ${t}`);
  return n;
}
function NZ(e, { opacity: t, ...n } = {}) {
  if (!ua(e) && !i8(e))
    throw new Error(`swatches legend requires ordinal or threshold color scale (not ${e.type})`);
  return s4(
    e,
    n,
    (i, r, s, o) => i.append("svg").attr("width", s).attr("height", o).attr("fill", r.scale).attr("fill-opacity", Be(t)[1]).append("rect").attr("width", "100%").attr("height", "100%")
  );
}
function BZ(e, {
  fill: t = ((l) => (l = e.hint) == null ? void 0 : l.fill)() !== void 0 ? e.hint.fill : "none",
  fillOpacity: n = 1,
  stroke: i = ((u) => (u = e.hint) == null ? void 0 : u.stroke)() !== void 0 ? e.hint.stroke : we(t) ? "currentColor" : "none",
  strokeOpacity: r = 1,
  strokeWidth: s = 1.5,
  r: o = 4.5,
  ...a
} = {}, c) {
  const [f, h] = mn(t), [d, p] = mn(i), y = mS(c, f), g = mS(c, d), m = o * o * Math.PI;
  return n = Be(n)[1], r = Be(r)[1], s = Be(s)[1], s4(
    e,
    a,
    (b, w, v, _) => b.append("svg").attr("viewBox", "-8 -8 16 16").attr("width", v).attr("height", _).attr("fill", f === "color" ? (x) => y.scale(x) : h).attr("fill-opacity", n).attr("stroke", d === "color" ? (x) => g.scale(x) : p).attr("stroke-opacity", r).attr("stroke-width", s).append("path").attr("d", (x) => {
      const I = Gr();
      return e.scale(x).draw(I, m), I;
    })
  );
}
function s4(e, t = {}, n) {
  let {
    columns: i,
    tickFormat: r,
    fontVariant: s = a8(e),
    // TODO label,
    swatchSize: o = 15,
    swatchWidth: a = o,
    swatchHeight: c = o,
    marginLeft: l = 0,
    className: u,
    style: f,
    width: h
  } = t;
  const d = $0(t);
  u = Gw(u), r = av(e.scale, e.domain, void 0, r);
  const p = Gt("div", d).attr(
    "class",
    `${u}-swatches ${u}-swatches-${i != null ? "columns" : "wrap"}`
  );
  let y;
  return i != null ? (y = `:where(.${u}-swatches-columns .${u}-swatch) {
  display: flex;
  align-items: center;
  break-inside: avoid;
  padding-bottom: 1px;
}
:where(.${u}-swatches-columns .${u}-swatch::before) {
  flex-shrink: 0;
}
:where(.${u}-swatches-columns .${u}-swatch-label) {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}`, p.style("columns", i).selectAll().data(e.domain).enter().append("div").attr("class", `${u}-swatch`).call(n, e, a, c).call(
    (g) => g.append("div").attr("class", `${u}-swatch-label`).attr("title", r).text(r)
  )) : (y = `:where(.${u}-swatches-wrap) {
  display: flex;
  align-items: center;
  min-height: 33px;
  flex-wrap: wrap;
}
:where(.${u}-swatches-wrap .${u}-swatch) {
  display: inline-flex;
  align-items: center;
  margin-right: 1em;
}`, p.selectAll().data(e.domain).enter().append("span").attr("class", `${u}-swatch`).call(n, e, a, c).append(function() {
    return this.ownerDocument.createTextNode(r.apply(this, arguments));
  })), p.call(
    (g) => g.insert("style", "*").text(
      `:where(.${u}-swatches) {
  font-family: system-ui, sans-serif;
  font-size: 10px;
  margin-bottom: 0.5em;
}
:where(.${u}-swatch > svg) {
  margin-right: 0.5em;
  overflow: visible;
}
${y}`
    )
  ).style("margin-left", l ? `${+l}px` : null).style("width", h === void 0 ? null : `${+h}px`).style("font-variant", Me(s, "normal")).call(Xw, f).node();
}
const Xp = /* @__PURE__ */ new Map([
  ["symbol", BZ],
  ["color", o4],
  ["opacity", EZ]
]);
function OZ(e = {}) {
  for (const [t, n] of Xp) {
    const i = e[t];
    if (jo(i)) {
      const r = $0(e);
      let s;
      if (t === "symbol") {
        const { fill: o, stroke: a = o === void 0 && jo(e.color) ? "color" : void 0 } = e;
        s = { fill: o, stroke: a };
      }
      return n(
        O1(t, i, s),
        cv(r, i, e),
        (o) => jo(e[o]) ? O1(o, e[o]) : null
      );
    }
  }
  throw new Error("unknown legend type; no scale found");
}
function FZ(e, t, n = {}) {
  return (i, r) => {
    if (!Xp.has(i))
      throw new Error(`unknown legend type: ${i}`);
    if (i in e)
      return Xp.get(i)(e[i], cv(t, n[i], r), (s) => e[s]);
  };
}
function cv({ className: e, ...t }, { label: n, ticks: i, tickFormat: r } = {}, s) {
  return tJ(s, { className: e, ...t }, { label: n, ticks: i, tickFormat: r });
}
function o4(e, { legend: t = !0, ...n }) {
  if (t === !0 && (t = e.type === "ordinal" ? "swatches" : "ramp"), e.domain !== void 0)
    switch (`${t}`.toLowerCase()) {
      case "swatches":
        return NZ(e, n);
      case "ramp":
        return tZ(e, n);
      default:
        throw new Error(`unknown legend type: ${t}`);
    }
}
function EZ({ type: e, interpolate: t, ...n }, { legend: i = !0, color: r = Pn(0, 0, 0), ...s }) {
  if (!t)
    throw new Error(`${e} opacity scales are not supported`);
  if (i === !0 && (i = "ramp"), `${i}`.toLowerCase() !== "ramp")
    throw new Error(`${i} opacity legends are not supported`);
  return o4({ type: e, ...n, interpolate: LZ(r) }, { legend: i, ...s });
}
function LZ(e) {
  const { r: t, g: n, b: i } = Pn(e) || Pn(0, 0, 0);
  return (r) => `rgba(${t},${n},${i},${r})`;
}
function RZ(e, t, n) {
  const i = [];
  for (const [r, s] of Xp) {
    const o = n[r];
    if (o != null && o.legend && r in e) {
      const a = s(e[r], cv(t, e[r], o), (c) => e[c]);
      a != null && i.push(a);
    }
  }
  return i;
}
const CZ = {
  ariaLabel: "frame",
  fill: "none",
  stroke: "currentColor",
  clip: !1
}, kZ = {
  ariaLabel: "frame",
  fill: null,
  stroke: "currentColor",
  strokeLinecap: "square",
  clip: !1
};
class a4 extends fe {
  constructor(t = {}) {
    const {
      anchor: n = null,
      inset: i = 0,
      insetTop: r = i,
      insetRight: s = i,
      insetBottom: o = i,
      insetLeft: a = i,
      rx: c,
      ry: l
    } = t;
    super(yu, void 0, t, n == null ? CZ : kZ), this.anchor = uD(n, "anchor", ["top", "right", "bottom", "left"]), this.insetTop = qt(r), this.insetRight = qt(s), this.insetBottom = qt(o), this.insetLeft = qt(a), this.rx = qt(c), this.ry = qt(l);
  }
  render(t, n, i, r, s) {
    const { marginTop: o, marginRight: a, marginBottom: c, marginLeft: l, width: u, height: f } = r, { anchor: h, insetTop: d, insetRight: p, insetBottom: y, insetLeft: g, rx: m, ry: b } = this, w = l + g, v = u - a - p, _ = o + d, x = f - c - y;
    return Gt(h ? "svg:line" : "svg:rect", s).datum(0).call(ve, this, r, s).call(be, this).call(Pe, this, i).call(ue, this, {}).call(
      h === "left" ? (I) => I.attr("x1", w).attr("x2", w).attr("y1", _).attr("y2", x) : h === "right" ? (I) => I.attr("x1", v).attr("x2", v).attr("y1", _).attr("y2", x) : h === "top" ? (I) => I.attr("x1", w).attr("x2", v).attr("y1", _).attr("y2", _) : h === "bottom" ? (I) => I.attr("x1", w).attr("x2", v).attr("y1", x).attr("y2", x) : (I) => I.attr("x", w).attr("y", _).attr("width", v - w).attr("height", x - _).attr("rx", m).attr("ry", b)
    ).node();
  }
}
function lv(e) {
  return new a4(e);
}
const Zm = {
  ariaLabel: "tip",
  fill: "var(--plot-background)",
  stroke: "currentColor"
}, UZ = /* @__PURE__ */ new Set(["geometry", "href", "src", "ariaLabel", "scales"]);
class c4 extends fe {
  constructor(t, n = {}) {
    n.tip && (n = { ...n, tip: !1 }), n.title === void 0 && fs(t) && mD(t) && (n = { ...n, title: Tt });
    const {
      x: i,
      y: r,
      x1: s,
      x2: o,
      y1: a,
      y2: c,
      anchor: l,
      preferredAnchor: u = "bottom",
      monospace: f,
      fontFamily: h = f ? "ui-monospace, monospace" : void 0,
      fontSize: d,
      fontStyle: p,
      fontVariant: y,
      fontWeight: g,
      lineHeight: m = 1,
      lineWidth: b = 20,
      frameAnchor: w,
      format: v,
      textAnchor: _ = "start",
      textOverflow: x,
      textPadding: I = 8,
      title: N,
      pointerSize: A = 12,
      pathFilter: D = "drop-shadow(0 3px 4px rgba(0,0,0,0.2))"
    } = n;
    super(
      t,
      {
        x: { value: s != null && o != null ? null : i, scale: "x", optional: !0 },
        // ignore midpoint
        y: { value: a != null && c != null ? null : r, 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: N, optional: !0 }
        // filter: defined
      },
      n,
      Zm
    ), this.anchor = A1(l, "anchor"), this.preferredAnchor = A1(u, "preferredAnchor"), this.frameAnchor = kf(w), this.textAnchor = Me(_, "middle"), this.textPadding = +I, this.pointerSize = +A, this.pathFilter = tn(D), this.lineHeight = +m, this.lineWidth = +b, this.textOverflow = S8(x), this.monospace = !!f, this.fontFamily = tn(h), this.fontSize = qt(d), this.fontStyle = tn(p), this.fontVariant = tn(y), this.fontWeight = tn(g);
    for (const M in Zm)
      M in this.channels && (this[M] = Zm[M]);
    this.splitLines = $8(this), this.clipLine = T8(this), this.format = { ...v };
  }
  render(t, n, i, r, s) {
    const o = this, { x: a, y: c, fx: l, fy: u } = n, { ownerSVGElement: f, document: h } = s, { anchor: d, monospace: p, lineHeight: y, lineWidth: g } = this, { textPadding: m, pointerSize: b, pathFilter: w } = this, { marginTop: v, marginLeft: _ } = r, { x1: x, y1: I, x2: N, y2: A, x: D = x ?? N, y: M = I ?? A } = i, B = l ? l(t.fx) - _ : 0, R = u ? u(t.fy) - v : 0, [S, $] = _r(this, r), T = s8(i, S), L = o8(i, $), k = p ? rv : iv, U = k(pc);
    let C, z;
    "title" in i ? (C = i.channels, z = qZ) : (C = jZ.call(this, i, n), z = YZ);
    const P = Gt("svg:g", s).call(ve, this, r, s).call(M8, this).call(ue, this, { x: D && a, y: M && c }).call(
      (tt) => tt.selectAll().data(t).enter().append("g").attr("transform", (Z) => `translate(${Math.round(T(Z))},${Math.round(L(Z))})`).call(be, this).call((Z) => Z.append("path").attr("filter", w)).call(
        (Z) => Z.append("text").each(function(Y) {
          const X = ce(this);
          this.setAttribute("fill", "currentColor"), this.setAttribute("fill-opacity", 1), this.setAttribute("stroke", "none");
          const j = z.call(o, Y, t, C, n, i);
          if (typeof j == "string")
            for (const J of o.splitLines(j))
              G(X, { value: o.clipLine(J) });
          else {
            const J = /* @__PURE__ */ new Set();
            for (const et of j) {
              const { label: V = "" } = et;
              V && J.has(V) || (J.add(V), G(X, et));
            }
          }
        })
      )
    );
    function G(tt, { label: Z, value: Y, color: X, opacity: j }) {
      Z ?? (Z = ""), Y ?? (Y = "");
      const J = X != null || j != null;
      let et, V = g * 100;
      const [Ft] = Pc(Z, V, k, U);
      if (Ft >= 0)
        Z = Z.slice(0, Ft).trimEnd() + pc, et = Y.trim(), Y = "";
      else {
        (Z || !Y && !J) && (Y = " " + Y);
        const [Vt] = Pc(Y, V - k(Z), k, U);
        Vt >= 0 && (et = Y.trim(), Y = Y.slice(0, Vt).trimEnd() + pc);
      }
      const rt = tt.append("tspan").attr("x", 0).attr("dy", `${y}em`).text("​");
      Z && rt.append("tspan").attr("font-weight", "bold").text(Z), Y && rt.append(() => h.createTextNode(Y)), J && rt.append("tspan").text(" ■").attr("fill", X).attr("fill-opacity", j).style("user-select", "none"), et && rt.append("title").text(et);
    }
    function K() {
      const { width: tt, height: Z } = r.facet ?? r;
      P.selectChildren().each(function(Y) {
        let { x: X, width: j, height: J } = this.getBBox();
        j = Math.round(j), J = Math.round(J);
        let et = d;
        if (et === void 0) {
          const rt = T(Y) + B, Vt = L(Y) + R, jt = rt + j + b + m * 2 < tt, Q = rt - j - b - m * 2 > 0, Zt = Vt + J + b + m * 2 < Z, En = Vt - J - b - m * 2 > 0;
          et = jt && Q ? Zt && En ? o.preferredAnchor : En ? "bottom" : "top" : Zt && En ? jt ? "left" : "right" : (jt || Q) && (Zt || En) ? `${En ? "bottom" : "top"}-${jt ? "left" : "right"}` : o.preferredAnchor;
        }
        const V = this.firstChild, Ft = this.lastChild;
        if (V.setAttribute("d", VZ(et, b, m, j, J)), X)
          for (const rt of Ft.childNodes)
            rt.setAttribute("x", -X);
        Ft.setAttribute("y", `${+zZ(et, Ft.childNodes.length, y).toFixed(6)}em`), Ft.setAttribute("transform", `translate(${PZ(et, b, m, j, J)})`);
      }), P.attr("visibility", null);
    }
    return t.length && (P.attr("visibility", "hidden"), f.isConnected ? Promise.resolve().then(K) : typeof requestAnimationFrame < "u" && requestAnimationFrame(K)), P.node();
  }
}
function l4(e, { x: t, y: n, ...i } = {}) {
  return i.frameAnchor === void 0 && ([t, n] = ki(t, n)), new c4(e, { ...i, x: t, y: n });
}
function zZ(e, t, n) {
  return /^top(?:-|$)/.test(e) ? 0.94 - n : -0.29 - t * n;
}
function PZ(e, t, n, i, r) {
  switch (e) {
    case "middle":
      return [-i / 2, r / 2];
    case "top-left":
      return [n, t + n];
    case "top":
      return [-i / 2, t / 2 + n];
    case "top-right":
      return [-i - n, t + n];
    case "right":
      return [-t / 2 - i - n, r / 2];
    case "bottom-left":
      return [n, -t - n];
    case "bottom":
      return [-i / 2, -t / 2 - n];
    case "bottom-right":
      return [-i - n, -t - n];
    case "left":
      return [n + t / 2, r / 2];
  }
}
function VZ(e, t, n, i, r) {
  const s = i + n * 2, o = r + 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 jZ({ channels: e }, t) {
  var r, s;
  const n = {};
  let i = this.format;
  i = gS(i, e, "x"), i = gS(i, e, "y"), this.format = i;
  for (const o in i) {
    const a = i[o];
    if (!(a === null || a === !1))
      if (o === "fx" || o === "fy")
        n[o] = !0;
      else {
        const c = $1(e, o);
        c && (n[o] = c);
      }
  }
  for (const o in e) {
    if (o in n || o in i || UZ.has(o))
      continue;
    const a = $1(e, o);
    a && (n[o] = a);
  }
  this.facet && (t.fx && !("fx" in i) && (n.fx = !0), t.fy && !("fy" in i) && (n.fy = !0));
  for (const o in n) {
    const a = this.format[o];
    if (typeof a == "string") {
      const c = ((r = n[o]) == null ? void 0 : r.value) ?? ((s = t[o]) == null ? void 0 : s.domain()) ?? [];
      this.format[o] = (gn(c) ? Ff : il)(a);
    } else if (a === void 0 || a === !0) {
      const c = t[o];
      this.format[o] = c != null && c.bandwidth ? av(c, c.domain()) : ra;
    }
  }
  return n;
}
function gS(e, t, n) {
  if (!(n in e))
    return e;
  const i = `${n}1`, r = `${n}2`;
  if ((i in e || !(i in t)) && (r in e || !(r in t)))
    return e;
  const s = Object.entries(e), o = e[n];
  return s.splice(s.findIndex(([a]) => a === n) + 1, 0, [i, o], [r, o]), Object.fromEntries(s);
}
function qZ(e, t, { title: n }) {
  return ra(n.value[e], e);
}
function* YZ(e, t, n, i, r) {
  for (const s in n) {
    if (s === "fx" || s === "fy") {
      yield {
        label: Hp(i, 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: wS(i, n, "x"),
        value: bS(this.format.x2, n.x1, o, e)
      };
    else if (s === "y2" && "y1" in n)
      yield {
        label: wS(i, n, "y"),
        value: bS(this.format.y2, n.y1, o, e)
      };
    else {
      const a = o.value[e], c = o.scale;
      if (!dn(a) && c == null)
        continue;
      yield {
        label: Hp(i, n, s),
        value: this.format[s](a, e),
        color: c === "color" ? r[s][e] : null,
        opacity: c === "opacity" ? r[s][e] : null
      };
    }
  }
}
function bS(e, t, n, i) {
  var r;
  return (r = n.hint) != null && r.length ? `${e(n.value[i] - t.value[i], i)}` : `${e(t.value[i], i)}–${e(n.value[i], i)}`;
}
function wS(e, t, n) {
  const i = Hp(e, t, `${n}1`, n), r = Hp(e, t, `${n}2`, n);
  return i === r ? i : `${i}–${r}`;
}
function Hp(e, t, n, i = n) {
  const r = t[n], s = e[(r == null ? void 0 : r.scale) ?? n];
  return String((s == null ? void 0 : s.label) ?? (r == null ? void 0 : r.label) ?? i);
}
function uv(e = {}) {
  var U;
  const { facet: t, style: n, title: i, subtitle: r, caption: s, ariaLabel: o, ariaDescription: a } = e, c = Gw(e.className), l = e.marks === void 0 ? [] : _S(e.marks);
  l.push(...QZ(l));
  const u = KZ(t, e), f = /* @__PURE__ */ new Map();
  for (const C of l) {
    const z = xS(C, u, e);
    z && f.set(C, z);
  }
  const h = /* @__PURE__ */ new Map();
  u && Tl(h, [u], e), Tl(h, f, e);
  const d = _S(tQ(l, h, e));
  for (const C of d) {
    const z = xS(C, u, e);
    z && f.set(C, z);
  }
  l.unshift(...d);
  let p = zK(h, e);
  if (p !== void 0) {
    const C = u ? Xm(p, u) : void 0;
    for (const P of l) {
      if (P.facet === null || P.facet === "super")
        continue;
      const G = f.get(P);
      G !== void 0 && (G.facetsIndex = P.fx != null || P.fy != null ? Xm(p, G) : C);
    }
    const z = /* @__PURE__ */ new Set();
    for (const { facetsIndex: P } of f.values())
      P == null || P.forEach((G, K) => {
        (G == null ? void 0 : G.length) > 0 && z.add(K);
      });
    p.forEach(
      0 < z.size && z.size < p.length ? (P, G) => P.empty = !z.has(G) : (P) => P.empty = !1
    );
    for (const P of l)
      if (P.facet === "exclude") {
        const G = f.get(P);
        G !== void 0 && (G.facetsIndex = jK(G.facetsIndex));
      }
  }
  for (const C of Se.keys())
    jo(e[C]) && C !== "fx" && C !== "fy" && h.set(C, []);
  const y = /* @__PURE__ */ new Map();
  for (const C of l) {
    if (y.has(C))
      throw new Error("duplicate mark; each mark must be unique");
    const { facetsIndex: z, channels: P } = f.get(C) ?? {}, { data: G, facets: K, channels: tt } = C.initialize(z, P, e);
    fv(tt, e), y.set(C, { data: G, facets: K, channels: tt });
  }
  const g = B1(Tl(h, y, e), e), m = kK(g, l, e);
  BK(g, m);
  const b = nS(g), { fx: w, fy: v } = b, _ = w || v ? QD(g, m) : m, x = w || v ? aQ(b, m) : m, I = $0(e), N = I.document, A = Zy("svg").call(N.documentElement);
  let D = A;
  I.ownerSVGElement = A, I.className = c, I.projection = qJ(e, _), I.filterFacets = (C, z) => Xm(p, { channels: z, groups: Qw(C, z) }), I.getMarkState = (C) => {
    const z = y.get(C), P = f.get(C);
    return { ...z, channels: { ...z.channels, ...P == null ? void 0 : P.channels } };
  }, I.dispatchValue = (C) => {
    D.value !== C && (D.value = C, D.dispatchEvent(new Event("input", { bubbles: !0 })));
  };
  const M = /* @__PURE__ */ new Set();
  for (const [C, z] of y)
    if (C.initializer != null) {
      const P = C.facet === "super" ? x : _, G = C.initializer(z.data, z.facets, z.channels, b, P, I);
      if (G.data !== void 0 && (z.data = G.data), G.facets !== void 0 && (z.facets = G.facets), G.channels !== void 0) {
        const { fx: K, fy: tt, ...Z } = G.channels;
        JZ(Z), Object.assign(z.channels, Z);
        for (const Y of Object.values(Z)) {
          const { scale: X } = Y;
          X != null && !nJ(Se.get(X)) && (u4(Y, e), M.add(X));
        }
        (K != null || tt != null) && f.set(C, !0);
      }
    }
  if (M.size) {
    const C = /* @__PURE__ */ new Map();
    Tl(C, y, e, (K) => M.has(K)), Tl(h, y, e, (K) => M.has(K));
    const z = oQ(B1(C, e), g), { scales: P, ...G } = nS(z);
    Object.assign(g, z), Object.assign(b, G), Object.assign(b.scales, P);
  }
  let B, R;
  p !== void 0 && (B = { x: w == null ? void 0 : w.domain(), y: v == null ? void 0 : v.domain() }, p = PK(p, B), R = VK(w, v, m));
  for (const [C, z] of y)
    z.values = C.scale(z.channels, b, I);
  const { width: S, height: $ } = m;
  ce(A).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", $).attr("viewBox", `0 0 ${S} ${$}`).attr("aria-label", o).attr("aria-description", a).call(
    (C) => (
      // Warning: if you edit this, change defaultClassName.
      C.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(Xw, n);
  for (const C of l) {
    const { channels: z, values: P, facets: G } = y.get(C);
    if (p === void 0 || C.facet === "super") {
      let K = null;
      if (G && (K = G[0], K = C.filter(K, z, P), K.length === 0))
        continue;
      const tt = C.render(K, b, P, x, I);
      if (tt == null)
        continue;
      A.appendChild(tt);
    } else {
      let K;
      for (const tt of p) {
        if (!(((U = C.facetAnchor) == null ? void 0 : U.call(C, p, B, tt)) ?? !tt.empty))
          continue;
        let Z = null;
        if (G) {
          const X = f.has(C);
          if (Z = G[X ? tt.i : 0], Z = C.filter(Z, z, P), Z.length === 0)
            continue;
          !X && Z === G[0] && (Z = qo(Z)), Z.fx = tt.x, Z.fy = tt.y, Z.fi = tt.i;
        }
        const Y = C.render(Z, b, P, _, I);
        if (Y != null) {
          (K ?? (K = ce(A).append("g"))).append(() => Y).datum(tt);
          for (const X of ["aria-label", "aria-description", "aria-hidden", "transform"])
            Y.hasAttribute(X) && (K.attr(X, Y.getAttribute(X)), Y.removeAttribute(X));
        }
      }
      K == null || K.selectChildren().attr("transform", R);
    }
  }
  const T = RZ(g, I, e), { figure: L = i != null || r != null || s != null || T.length > 0 } = e;
  L && (D = N.createElement("figure"), D.className = `${c}-figure`, D.style.maxWidth = "initial", i != null && D.append(vS(N, i, "h2")), r != null && D.append(vS(N, r, "h3")), D.append(...T, A), s != null && D.append(WZ(N, s))), D.scale = CK(b.scales), D.legend = FZ(g, I, e), D.projection = I.projection;
  const k = EJ();
  return k > 0 && ce(A).append("text").attr("x", S).attr("y", 20).attr("dy", "-1em").attr("text-anchor", "end").attr("font-family", "initial").text("⚠️").append("title").text(`${k.toLocaleString("en-US")} warning${k === 1 ? "" : "s"}. Please check the console.`), D;
}
function vS(e, t, n) {
  if (t.ownerDocument)
    return t;
  const i = e.createElement(n);
  return i.append(t), i;
}
function WZ(e, t) {
  const n = e.createElement("figcaption");
  return n.append(t), n;
}
function GZ({ marks: e = [], ...t } = {}) {
  return uv({ ...t, marks: [...e, this] });
}
fe.prototype.plot = GZ;
function _S(e) {
  return e.flat(1 / 0).filter((t) => t != null).map(XZ);
}
function XZ(e) {
  return typeof e.render == "function" ? e : new HZ(e);
}
class HZ extends fe {
  constructor(t) {
    if (typeof t != "function")
      throw new TypeError("invalid mark; missing render function");
    super(), this.render = t;
  }
  render() {
  }
}
function fv(e, t) {
  for (const n in e)
    u4(e[n], t);
  return e;
}
function u4(e, t) {
  const { scale: n, transform: i = !0 } = e;
  if (n == null || !i)
    return;
  const {
    type: r,
    percent: s,
    interval: o,
    transform: a = s ? (c) => c * 100 : yD(o, r)
  } = t[n] ?? {};
  a != null && (e.value = ye(e.value, a), e.transform = !1);
}
function JZ(e) {
  for (const t in e)
    DD(t, e[t]);
}
function Tl(e, t, n, i = VH) {
  var r, s;
  for (const { channels: o } of t.values())
    for (const a in o) {
      const c = o[a], { scale: l } = c;
      if (l != null && i(l))
        if (l === "projection") {
          if (!GJ(n)) {
            const u = ((r = n.x) == null ? void 0 : r.domain) === void 0, f = ((s = n.y) == null ? void 0 : s.domain) === void 0;
            if (u || f) {
              const [h, d] = HJ(c);
              u && Qm(e, "x", h), f && Qm(e, "y", d);
            }
          }
        } else
          Qm(e, l, c);
    }
  return e;
}
function Qm(e, t, n) {
  const i = e.get(t);
  i !== void 0 ? i.push(n) : e.set(t, [n]);
}
function KZ(e, t) {
  if (e == null)
    return;
  const { x: n, y: i } = e;
  if (n == null && i == null)
    return;
  const r = Nn(e.data);
  if (r == null)
    throw new Error("missing facet data");
  const s = {};
  n != null && (s.fx = Hu(r, { value: n, scale: "fx" })), i != null && (s.fy = Hu(r, { value: i, scale: "fy" })), fv(s, t);
  const o = Qw(r, s);
  return { channels: s, groups: o, data: e.data };
}
function xS(e, t, n) {
  var c;
  if (e.facet === null || e.facet === "super")
    return;
  const { fx: i, fy: r } = e;
  if (i != null || r != null) {
    const l = Nn(e.data ?? i ?? r);
    if (l === void 0)
      throw new Error(`missing facet data in ${e.ariaLabel}`);
    if (l === null)
      return;
    const u = {};
    return i != null && (u.fx = Hu(l, { value: i, scale: "fx" })), r != null && (u.fy = Hu(l, { value: r, scale: "fy" })), fv(u, n), { channels: u, groups: Qw(l, u) };
  }
  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 = Nn(e.data)) == null ? void 0 : c.length) === a.length && Qr(
    `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 ZZ(e, t = {}) {
  return Bn({ ...t, x: null, y: null }, (n, i, r, s, o, a) => a.getMarkState(e));
}
function QZ(e) {
  const t = [];
  for (const n of e) {
    let i = n.tip;
    if (i) {
      i === !0 ? i = {} : typeof i == "string" && (i = { pointer: i });
      let { pointer: r, preferredAnchor: s } = i;
      r = /^x$/i.test(r) ? nv : /^y$/i.test(r) ? Wp : ev, i = r(ZZ(n, i)), i.title = null, s === void 0 && (i.preferredAnchor = r === Wp ? "left" : "bottom");
      const o = l4(n.data, i);
      o.facet = n.facet, o.facetAnchor = n.facetAnchor, t.push(o);
    }
  }
  return t;
}
function tQ(e, t, n) {
  let {
    projection: i,
    x: r = {},
    y: s = {},
    fx: o = {},
    fy: a = {},
    axis: c,
    grid: l,
    facet: u = {},
    facet: { axis: f = c, grid: h } = u,
    x: { axis: d = c, grid: p = d === null ? null : l } = r,
    y: { axis: y = c, grid: g = y === null ? null : l } = s,
    fx: { axis: m = f, grid: b = m === null ? null : h } = o,
    fy: { axis: w = f, grid: v = w === null ? null : h } = a
  } = n;
  (i || !jo(r) && !SS("x", e)) && (d = p = null), (i || !jo(s) && !SS("y", e)) && (y = g = null), t.has("fx") || (m = b = null), t.has("fy") || (w = v = null), d === void 0 && (d = !Dh(e, "x")), y === void 0 && (y = !Dh(e, "y")), m === void 0 && (m = !Dh(e, "fx")), w === void 0 && (w = !Dh(e, "fy")), d === !0 && (d = "bottom"), y === !0 && (y = "left"), m === !0 && (m = d === "top" || d === null ? "bottom" : "top"), w === !0 && (w = y === "right" || y === null ? "left" : "right");
  const _ = [];
  return Th(_, v, G8, a), $h(_, w, V8, "right", "left", u, a), Th(_, b, H8, o), $h(_, m, j8, "top", "bottom", u, o), Th(_, g, W8, s), $h(_, y, sv, "left", "right", n, s), Th(_, p, X8, r), $h(_, d, ov, "bottom", "top", n, r), _;
}
function $h(e, t, n, i, r, s, o) {
  if (!t)
    return;
  const a = eQ(t);
  o = nQ(a ? i : t, s, o);
  const { line: c } = o;
  (n === sv || n === ov) && c && !kc(c) && e.push(lv(iQ(o))), e.push(n(o)), a && e.push(n({ ...o, anchor: r, label: null }));
}
function Th(e, t, n, i) {
  !t || kc(t) || e.push(n(rQ(t, i)));
}
function eQ(e) {
  return /^\s*both\s*$/i.test(e);
}
function nQ(e, t, {
  line: n = t.line,
  ticks: i,
  tickSize: r,
  tickSpacing: s,
  tickPadding: o,
  tickFormat: a,
  tickRotate: c,
  fontVariant: l,
  ariaLabel: u,
  ariaDescription: f,
  label: h = t.label,
  labelAnchor: d,
  labelArrow: p = t.labelArrow,
  labelOffset: y
}) {
  return {
    anchor: e,
    line: n,
    ticks: i,
    tickSize: r,
    tickSpacing: s,
    tickPadding: o,
    tickFormat: a,
    tickRotate: c,
    fontVariant: l,
    ariaLabel: u,
    ariaDescription: f,
    label: h,
    labelAnchor: d,
    labelArrow: p,
    labelOffset: y
  };
}
function iQ(e) {
  const { anchor: t, line: n } = e;
  return { anchor: t, facetAnchor: t + "-empty", stroke: n === !0 ? void 0 : n };
}
function rQ(e, {
  stroke: t = Cf(e) ? e : void 0,
  ticks: n = sQ(e) ? e : void 0,
  tickSpacing: i,
  ariaLabel: r,
  ariaDescription: s
}) {
  return {
    stroke: t,
    ticks: n,
    tickSpacing: i,
    ariaLabel: r,
    ariaDescription: s
  };
}
function sQ(e) {
  switch (typeof e) {
    case "number":
      return !0;
    case "string":
      return !Cf(e);
  }
  return fs(e) || typeof (e == null ? void 0 : e.range) == "function";
}
function Dh(e, t) {
  const n = `${t}-axis `;
  return e.some((i) => {
    var r;
    return (r = i.ariaLabel) == null ? void 0 : r.startsWith(n);
  });
}
function SS(e, t) {
  for (const n of t)
    for (const i in n.channels) {
      const { scale: r } = n.channels[i];
      if (r === e || r === "projection")
        return !0;
    }
  return !1;
}
function oQ(e, t) {
  for (const n in e) {
    const i = e[n], r = t[n];
    i.label === void 0 && r && (i.label = r.label);
  }
  return e;
}
function aQ({ fx: e, fy: t }, n) {
  const { marginTop: i, marginRight: r, marginBottom: s, marginLeft: o, width: a, height: c } = Zw(n), l = e && IS(e), u = t && IS(t);
  return {
    marginTop: t ? u[0] : i,
    marginRight: e ? a - l[1] : r,
    marginBottom: t ? c - u[1] : s,
    marginLeft: e ? l[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 IS(e) {
  const t = e.domain();
  let n = e(t[0]), i = e(t[t.length - 1]);
  return i < n && ([n, i] = [i, n]), [n, i + e.bandwidth()];
}
const cQ = /* @__PURE__ */ new Map([
  ["basis", lH],
  ["basis-closed", uH],
  ["basis-open", fH],
  ["bundle", hH],
  ["bump-x", ZX],
  ["bump-y", QX],
  ["cardinal", dH],
  ["cardinal-closed", pH],
  ["cardinal-open", yH],
  ["catmull-rom", mH],
  ["catmull-rom-closed", gH],
  ["catmull-rom-open", bH],
  ["linear", Ef],
  ["linear-closed", wH],
  ["monotone-x", vH],
  ["monotone-y", _H],
  ["natural", xH],
  ["step", SH],
  ["step-after", AH],
  ["step-before", IH]
]);
function hv(e = Ef, t) {
  if (typeof e == "function")
    return e;
  const n = cQ.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 f4(e = Vc, t) {
  return typeof e != "function" && `${e}`.toLowerCase() === "auto" ? Vc : hv(e, t);
}
function Vc(e) {
  return Ef(e);
}
function Ns(e = { y: "count" }, t = {}) {
  [e, t] = mv(e, t);
  const { x: n, y: i } = t;
  return yv(Jp(n, t, Tt), null, null, i, e, Yf(t));
}
function Bs(e = { x: "count" }, t = {}) {
  [e, t] = mv(e, t);
  const { x: n, y: i } = t;
  return yv(null, Jp(i, t, Tt), n, null, e, Wf(t));
}
function No(e = { fill: "count" }, t = {}) {
  [e, t] = mv(e, t);
  const { x: n, y: i } = lQ(t);
  return yv(n, i, null, null, e, Yf(Wf(t)));
}
function h4(e, t, n = {}) {
  if ((n == null ? void 0 : n.interval) == null)
    return n;
  const { reduce: i = jw } = n, r = { filter: null };
  return n[t] != null && (r[t] = i), n[`${t}1`] != null && (r[`${t}1`] = i), n[`${t}2`] != null && (r[`${t}2`] = i), e(r, n);
}
function dv(e = {}) {
  return h4(Ns, "y", fa(e, "x"));
}
function pv(e = {}) {
  return h4(Bs, "x", fa(e, "y"));
}
function yv(e, t, n, i, {
  data: r = Vw,
  // TODO avoid materializing when unused?
  filter: s = Vp,
  // return only non-empty bins by default
  sort: o,
  reverse: a,
  ...c
  // output channel definitions
} = {}, l = {}) {
  e = AS(e), t = AS(t), c = uQ(c, l), r = m4(r, Tt), o = o == null ? void 0 : p4("sort", o, l), s = s == null ? void 0 : y4("filter", s, l), n != null && Ls(c, "x", "x1", "x2") && (n = null), i != null && Ls(c, "y", "y1", "y2") && (i = null);
  const [u, f] = xn(e), [h, d] = xn(e), [p, y] = xn(t), [g, m] = xn(t), [b, w] = n != null ? [n, "x"] : i != null ? [i, "y"] : [], [v, _] = xn(b), {
    x,
    y: I,
    z: N,
    fill: A,
    stroke: D,
    x1: M,
    x2: B,
    // consumed if x is an output
    y1: R,
    y2: S,
    // consumed if y is an output
    domain: $,
    cumulative: T,
    thresholds: L,
    interval: k,
    ...U
  } = l, [C, z] = xn(N), [P] = mn(A), [G] = mn(D), [K, tt] = xn(P), [Z, Y] = xn(G);
  return {
    ..."z" in l && { z: C || N },
    ..."fill" in l && { fill: K || A },
    ..."stroke" in l && { stroke: Z || D },
    ...vr(U, (X, j, J) => {
      const et = Pp(Pt(X, b), J == null ? void 0 : J[w]), V = Pt(X, N), Ft = Pt(X, P), rt = Pt(X, G), Vt = Pw(c, { z: V, fill: Ft, stroke: rt }), jt = [], Q = [], Zt = et && _([]), En = V && z([]), zi = Ft && tt([]), xC = rt && Y([]), x_ = e && f([]), SC = e && d([]), S_ = t && y([]), IC = t && m([]), AC = dQ(e, t, X);
      let MC = 0;
      for (const pa of c)
        pa.initialize(X);
      o && o.initialize(X), s && s.initialize(X);
      for (const pa of j) {
        const I_ = [];
        for (const gl of c)
          gl.scope("facet", pa);
        o && o.scope("facet", pa), s && s.scope("facet", pa);
        for (const [gl, $C] of dc(pa, Vt))
          for (const [TC, nh] of dc($C, et))
            for (const [Pi, po] of AC(nh))
              if (!(s && !s.reduce(Pi, po))) {
                I_.push(MC++), Q.push(r.reduceIndex(Pi, X, po)), et && Zt.push(TC), V && En.push(Vt === V ? gl : V[(Pi.length > 0 ? Pi : nh)[0]]), Ft && zi.push(Vt === Ft ? gl : Ft[(Pi.length > 0 ? Pi : nh)[0]]), rt && xC.push(Vt === rt ? gl : rt[(Pi.length > 0 ? Pi : nh)[0]]), x_ && (x_.push(po.x1), SC.push(po.x2)), S_ && (S_.push(po.y1), IC.push(po.y2));
                for (const DC of c)
                  DC.reduce(Pi, po);
                o && o.reduce(Pi);
              }
        jt.push(I_);
      }
      return $D(jt, o, a), { data: Q, facets: jt };
    }),
    ...!Ls(c, "x") && (u ? { x1: u, x2: h, x: zp(u, h) } : { x, x1: M, x2: B }),
    ...!Ls(c, "y") && (p ? { y1: p, y2: g, y: zp(p, g) } : { y: I, y1: R, y2: S }),
    ...v && { [w]: v },
    ...Object.fromEntries(c.map(({ name: X, output: j }) => [X, j]))
  };
}
function mv({ cumulative: e, domain: t, thresholds: n, interval: i, ...r }, s) {
  return [r, { cumulative: e, domain: t, thresholds: n, interval: i, ...s }];
}
function Jp(e, { cumulative: t, domain: n, thresholds: i, interval: r }, s) {
  return e = { ...ol(e) }, e.domain === void 0 && (e.domain = n), e.cumulative === void 0 && (e.cumulative = t), e.thresholds === void 0 && (e.thresholds = i), e.interval === void 0 && (e.interval = r), e.value === void 0 && (e.value = s), e.thresholds = d4(e.thresholds, e.interval), e;
}
function lQ(e) {
  let { x: t, y: n } = e;
  return t = Jp(t, e), n = Jp(n, e), [t.value, n.value] = ki(t.value, n.value), { x: t, y: n };
}
function AS(e) {
  if (e == null)
    return;
  const { value: t, cumulative: n, domain: i = ke, thresholds: r } = e, s = (o) => {
    let a = Pt(o, t), c;
    if (gn(a) || hQ(r)) {
      a = ye(a, lD, Float64Array);
      let [u, f] = typeof i == "function" ? i(a) : i, h = typeof r == "function" && !tc(r) ? r(a, u, f) : r;
      typeof h == "number" && (h = c6(u, f, h)), tc(h) && (i === ke && (u = h.floor(u), f = h.offset(h.floor(f))), h = h.range(u, h.offset(f))), c = h;
    } else {
      a = An(a);
      let [u, f] = typeof i == "function" ? i(a) : i, h = typeof r == "function" && !tc(r) ? r(a, u, f) : r;
      if (typeof h == "number")
        if (i === ke) {
          let d = Fu(u, f, h);
          if (isFinite(d))
            if (d > 0) {
              let p = Math.round(u / d), y = Math.round(f / d);
              p * d <= u || --p, y * d > f || ++y;
              let g = y - p + 1;
              h = new Float64Array(g);
              for (let m = 0; m < g; ++m)
                h[m] = (p + m) * d;
            } else if (d < 0) {
              d = -d;
              let p = Math.round(u * d), y = Math.round(f * d);
              p / d <= u || --p, y / d > f || ++y;
              let g = y - p + 1;
              h = new Float64Array(g);
              for (let m = 0; m < g; ++m)
                h[m] = (p + m) / d;
            } else
              h = [u];
          else
            h = [u];
        } else
          h = qs(u, f, h);
      else
        tc(h) && (i === ke && (u = h.floor(u), f = h.offset(h.floor(f))), h = h.range(u, h.offset(f)));
      c = h;
    }
    const l = [];
    if (c.length === 1)
      l.push([c[0], c[0]]);
    else
      for (let u = 1; u < c.length; ++u)
        l.push([c[u - 1], c[u]]);
    return l.bin = (n < 0 ? yQ : n > 0 ? pQ : gv)(l, c, a), l;
  };
  return s.label = wr(t), s;
}
function d4(e, t, n = MS) {
  if (e === void 0)
    return t === void 0 ? n : sl(t);
  if (typeof e == "string") {
    switch (e.toLowerCase()) {
      case "freedman-diaconis":
        return zz;
      case "scott":
        return f3;
      case "sturges":
        return qb;
      case "auto":
        return MS;
    }
    return Aw(e);
  }
  return e;
}
function uQ(e, t) {
  return xD(e, t, p4);
}
function p4(e, t, n) {
  return Uw(e, t, n, y4);
}
function y4(e, t, n) {
  return zw(e, t, n, m4);
}
function m4(e, t) {
  return M0(e, t, fQ);
}
function fQ(e) {
  switch (`${e}`.toLowerCase()) {
    case "x":
      return mQ;
    case "x1":
      return bQ;
    case "x2":
      return wQ;
    case "y":
      return gQ;
    case "y1":
      return vQ;
    case "y2":
      return _Q;
  }
  throw new Error(`invalid bin reduce: ${e}`);
}
function MS(e, t, n) {
  return Math.min(200, f3(e, t, n));
}
function hQ(e) {
  return WH(e) || fs(e) && gn(e);
}
function dQ(e, t, n) {
  const i = e == null ? void 0 : e(n), r = t == null ? void 0 : t(n);
  return i && r ? function* (s) {
    const o = i.bin(s);
    for (const [a, [c, l]] of i.entries()) {
      const u = r.bin(o[a]);
      for (const [f, [h, d]] of r.entries())
        yield [u[f], { data: n, x1: c, y1: h, x2: l, y2: d }];
    }
  } : i ? function* (s) {
    const o = i.bin(s);
    for (const [a, [c, l]] of i.entries())
      yield [o[a], { data: n, x1: c, x2: l }];
  } : function* (s) {
    const o = r.bin(s);
    for (const [a, [c, l]] of r.entries())
      yield [o[a], { data: n, y1: c, y2: l }];
  };
}
function gv(e, t, n) {
  return t = An(t), (i) => {
    var s;
    const r = e.map(() => []);
    for (const o of i)
      (s = r[Gy(t, n[o]) - 1]) == null || s.push(o);
    return r;
  };
}
function pQ(e, t, n) {
  const i = gv(e, t, n);
  return (r) => {
    const s = i(r);
    for (let o = 1, a = s.length; o < a; ++o) {
      const c = s[o - 1], l = s[o];
      for (const u of c)
        l.push(u);
    }
    return s;
  };
}
function yQ(e, t, n) {
  const i = gv(e, t, n);
  return (r) => {
    const s = i(r);
    for (let o = s.length - 2; o >= 0; --o) {
      const a = s[o + 1], c = s[o];
      for (const l of a)
        c.push(l);
    }
    return s;
  };
}
function g4(e, t) {
  const n = (+e + +t) / 2;
  return e instanceof Date ? new Date(n) : n;
}
const mQ = {
  reduceIndex(e, t, { x1: n, x2: i }) {
    return g4(n, i);
  }
}, gQ = {
  reduceIndex(e, t, { y1: n, y2: i }) {
    return g4(n, i);
  }
}, bQ = {
  reduceIndex(e, t, { x1: n }) {
    return n;
  }
}, wQ = {
  reduceIndex(e, t, { x2: n }) {
    return n;
  }
}, vQ = {
  reduceIndex(e, t, { y1: n }) {
    return n;
  }
}, _Q = {
  reduceIndex(e, t, { y2: n }) {
    return n;
  }
};
function bv(e = {}) {
  return fD(e) ? e : { ...e, x: Tt };
}
function wv(e = {}) {
  return hD(e) ? e : { ...e, y: Tt };
}
function xQ(e, t) {
  if (t.length === 1)
    return { data: e, facets: t };
  const n = e.length, i = new Uint8Array(n);
  let r = 0;
  for (const a of t)
    for (const c of a)
      i[c] && ++r, i[c] = 1;
  if (r === 0)
    return { data: e, facets: t };
  e = Wu(e);
  const s = e[aD] = new Uint32Array(n + r);
  t = t.map((a) => Wu(a, Uint32Array));
  let o = n;
  i.fill(0);
  for (const a of t)
    for (let c = 0, l = a.length; c < l; ++c) {
      const u = a[c];
      i[u] ? (a[c] = o, e[o] = e[u], s[o] = u, ++o) : s[u] = u, i[u] = 1;
    }
  return { data: e, facets: t };
}
function b4(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = ul(e));
  const { y1: n, y: i = n, x: r, ...s } = t, [o, a, c, l] = fl(i, r, "y", "x", e, s);
  return { ...o, y1: n, y: a, x1: c, x2: l, x: zp(c, l) };
}
function SQ(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = ul(e));
  const { y1: n, y: i = n, x: r } = t, [s, o, a] = fl(i, r, "y", "x", e, t);
  return { ...s, y1: n, y: o, x: a };
}
function IQ(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = ul(e));
  const { y1: n, y: i = n, x: r } = t, [s, o, , a] = fl(i, r, "y", "x", e, t);
  return { ...s, y1: n, y: o, x: a };
}
function w4(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = ul(e));
  const { x1: n, x: i = n, y: r, ...s } = t, [o, a, c, l] = fl(i, r, "x", "y", e, s);
  return { ...o, x1: n, x: a, y1: c, y2: l, y: zp(c, l) };
}
function AQ(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = ul(e));
  const { x1: n, x: i = n, y: r } = t, [s, o, a] = fl(i, r, "x", "y", e, t);
  return { ...s, x1: n, x: o, y: a };
}
function MQ(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = ul(e));
  const { x1: n, x: i = n, y: r } = t, [s, o, , a] = fl(i, r, "x", "y", e, t);
  return { ...s, x1: n, x: o, y: a };
}
function vv({ x: e, x1: t, x2: n, ...i } = {}) {
  return i = fa(i, "y"), t === void 0 && n === void 0 ? b4({ x: e, ...i }) : ([t, n] = dD(e, t, n), { ...i, x1: t, x2: n });
}
function _v({ y: e, y1: t, y2: n, ...i } = {}) {
  return i = fa(i, "x"), t === void 0 && n === void 0 ? w4({ y: e, ...i }) : ([t, n] = dD(e, t, n), { ...i, y1: t, y2: n });
}
function ul(e) {
  const { offset: t, order: n, reverse: i, ...r } = e;
  return [{ offset: t, order: n, reverse: i }, r];
}
const $Q = { length: !0 };
function fl(e, t = Mw, n, i, { offset: r, order: s, reverse: o }, a) {
  if (t === null)
    throw new Error(`stack requires ${i}`);
  const c = ao(a), [l, u] = xn(e), [f, h] = Un(t), [d, p] = Un(t);
  return f.hint = d.hint = $Q, r = TQ(r), s = BQ(s, r, i), [
    vr(a, (y, g, m) => {
      ({ data: y, facets: g } = xQ(y, g));
      const b = e == null ? void 0 : u(Pp(Pt(y, e), m == null ? void 0 : m[n])), w = Pt(y, t, Float64Array), v = Pt(y, c), _ = s && s(y, b, w, v), x = y.length, I = h(new Float64Array(x)), N = p(new Float64Array(x)), A = [];
      for (const D of g) {
        const M = b ? Array.from(ls(D, (B) => b[B]).values()) : [D];
        if (_)
          for (const B of M)
            B.sort(_);
        for (const B of M) {
          let R = 0, S = 0;
          o && B.reverse();
          for (const $ of B) {
            const T = w[$];
            T < 0 ? R = N[$] = (I[$] = R) + T : T > 0 ? S = N[$] = (I[$] = S) + T : N[$] = I[$] = S;
          }
        }
        A.push(M);
      }
      return r && r(A, I, N, v), { data: y, facets: g };
    }),
    l,
    f,
    d
  ];
}
function TQ(e) {
  if (e != null) {
    if (typeof e == "function")
      return e;
    switch (`${e}`.toLowerCase()) {
      case "expand":
      case "normalize":
        return DQ;
      case "center":
      case "silhouette":
        return NQ;
      case "wiggle":
        return _4;
    }
    throw new Error(`unknown offset: ${e}`);
  }
}
function v4(e, t) {
  let n = 0, i = 0;
  for (const r of e) {
    const s = t[r];
    s < n && (n = s), s > i && (i = s);
  }
  return [n, i];
}
function DQ(e, t, n) {
  for (const i of e)
    for (const r of i) {
      const [s, o] = v4(r, n);
      for (const a of r) {
        const c = 1 / (o - s || 1);
        t[a] = c * (t[a] - s), n[a] = c * (n[a] - s);
      }
    }
}
function NQ(e, t, n) {
  for (const i of e) {
    for (const r of i) {
      const [s, o] = v4(r, n);
      for (const a of r) {
        const c = (o + s) / 2;
        t[a] -= c, n[a] -= c;
      }
    }
    x4(i, t, n);
  }
  S4(e, t, n);
}
function _4(e, t, n, i) {
  for (const r of e) {
    const s = new Jo();
    let o = 0;
    for (const a of r) {
      let c = -1;
      const l = a.map((d) => Math.abs(n[d] - t[d])), u = a.map((d) => {
        c = i ? i[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, ...Bz(u)];
      for (const d of a)
        t[d] += o, n[d] += o;
      const h = fr(l);
      h && (o -= fr(l, (d, p) => (u[p] / 2 + f[p]) * d) / h);
    }
    x4(r, t, n);
  }
  S4(e, t, n);
}
function x4(e, t, n) {
  const i = Ye(e, (r) => Ye(r, (s) => t[s]));
  for (const r of e)
    for (const s of r)
      t[s] -= i, n[s] -= i;
}
function S4(e, t, n) {
  const i = e.length;
  if (i === 1)
    return;
  const r = e.map((a) => a.flat()), s = r.map((a) => (Ye(a, (c) => t[c]) + De(a, (c) => n[c])) / 2), o = Ye(s);
  for (let a = 0; a < i; a++) {
    const c = o - s[a];
    for (const l of r[a])
      t[l] += c, n[l] += c;
  }
}
function BQ(e, t, n) {
  if (e === void 0 && t === _4)
    return $S(li);
  if (e != null) {
    if (typeof e == "string") {
      const i = e.startsWith("-"), r = i ? kp : li;
      switch ((i ? e.slice(1) : e).toLowerCase()) {
        case "value":
        case n:
          return OQ(r);
        case "z":
          return FQ(r);
        case "sum":
          return EQ(r);
        case "appearance":
          return LQ(r);
        case "inside-out":
          return $S(r);
      }
      return TS(cD(e));
    }
    if (typeof e == "function")
      return (e.length === 1 ? TS : RQ)(e);
    if (Array.isArray(e))
      return CQ(e);
    throw new Error(`invalid order: ${e}`);
  }
}
function OQ(e) {
  return (t, n, i) => (r, s) => e(i[r], i[s]);
}
function FQ(e) {
  return (t, n, i, r) => (s, o) => e(r[s], r[o]);
}
function EQ(e) {
  return C0(
    e,
    (t, n, i, r) => jb(
      us(t),
      (s) => fr(s, (o) => i[o]),
      (s) => r[s]
    )
  );
}
function LQ(e) {
  return C0(
    e,
    (t, n, i, r) => jb(
      us(t),
      (s) => n[Yb(s, (o) => i[o])],
      (s) => r[s]
    )
  );
}
function $S(e) {
  return C0(e, (t, n, i, r) => {
    const s = us(t), o = jb(
      s,
      (f) => n[Yb(f, (h) => i[h])],
      (f) => r[f]
    ), a = lc(
      s,
      (f) => fr(f, (h) => i[h]),
      (f) => r[f]
    ), c = [], l = [];
    let u = 0;
    for (const f of o)
      u < 0 ? (u += a.get(f), c.push(f)) : (u -= a.get(f), l.push(f));
    return l.reverse().concat(c);
  });
}
function TS(e) {
  return (t) => {
    const n = Pt(t, e);
    return (i, r) => li(n[i], n[r]);
  };
}
function RQ(e) {
  return (t) => (n, i) => e(t[n], t[i]);
}
function CQ(e) {
  return C0(li, () => e);
}
function C0(e, t) {
  return (n, i, r, s) => {
    if (!s)
      throw new Error("missing channel: z");
    const o = new Jo(t(n, i, r, s).map((a, c) => [a, c]));
    return (a, c) => e(o.get(s[a]), o.get(s[c]));
  };
}
const kQ = {
  ariaLabel: "area",
  strokeWidth: 1,
  strokeLinecap: "round",
  strokeLinejoin: "round",
  strokeMiterlimit: 1
};
class k0 extends fe {
  constructor(t, n = {}) {
    const { x1: i, y1: r, x2: s, y2: o, z: a, curve: c, tension: l } = n;
    super(
      t,
      {
        x1: { value: i, scale: "x" },
        y1: { value: r, scale: "y" },
        x2: { value: s, scale: "x", optional: !0 },
        y2: { value: o, scale: "y", optional: !0 },
        z: { value: ao(n), optional: !0 }
      },
      n,
      kQ
    ), this.z = a, this.curve = hv(c, l);
  }
  filter(t) {
    return t;
  }
  render(t, n, i, r, s) {
    const { x1: o, y1: a, x2: c = o, y2: l = a } = i;
    return Gt("svg:g", s).call(ve, this, r, s).call(ue, this, n, 0, 0).call(
      (u) => u.selectAll().data(ED(t, [o, a, c, l], this, i)).enter().append("path").call(be, this).call(jp, this, i).attr(
        "d",
        yw().curve(this.curve).defined((f) => f >= 0).x0((f) => o[f]).y0((f) => a[f]).x1((f) => c[f]).y1((f) => l[f])
      )
    ).node();
  }
}
function L1(e, t) {
  return t === void 0 ? jc(e, { x: Rf, y: Yu }) : new k0(e, t);
}
function Ku(e, t) {
  const { y: n = vn, ...i } = pv(t);
  return new k0(e, vv(bv({ ...i, y1: n, y2: void 0 })));
}
function jc(e, t) {
  const { x: n = vn, ...i } = dv(t);
  return new k0(e, _v(wv({ ...i, x1: n, x2: void 0 })));
}
const UQ = {
  ariaLabel: "link",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1
};
class I4 extends fe {
  constructor(t, n = {}) {
    const { x1: i, y1: r, x2: s, y2: o, curve: a, tension: c } = n;
    super(
      t,
      {
        x1: { value: i, scale: "x" },
        y1: { value: r, scale: "y" },
        x2: { value: s, scale: "x", optional: !0 },
        y2: { value: o, scale: "y", optional: !0 }
      },
      n,
      UQ
    ), this.curve = f4(a, c), al(this, n);
  }
  project(t, n, i) {
    this.curve !== Vc && super.project(t, n, i);
  }
  render(t, n, i, r, s) {
    const { x1: o, y1: a, x2: c = o, y2: l = a } = i, { curve: u } = this;
    return Gt("svg:g", s).call(ve, this, r, s).call(ue, this, n).call(
      (f) => f.selectAll().data(t).enter().append("path").call(be, this).attr(
        "d",
        u === Vc && s.projection ? zQ(s.projection, o, a, c, l) : (h) => {
          const d = Gr(), p = u(d);
          return p.lineStart(), p.point(o[h], a[h]), p.point(c[h], l[h]), p.lineEnd(), d;
        }
      ).call(Pe, this, i).call(qf, this, i, s)
    ).node();
  }
}
function zQ(e, t, n, i, r) {
  const s = so(e);
  return t = An(t), n = An(n), i = An(i), r = An(r), (o) => s({
    type: "LineString",
    coordinates: [
      [t[o], n[o]],
      [i[o], r[o]]
    ]
  });
}
function A4(e, { x: t, x1: n, x2: i, y: r, y1: s, y2: o, ...a } = {}) {
  return [n, i] = Kp(t, n, i), [s, o] = Kp(r, s, o), new I4(e, { ...a, x1: n, x2: i, y1: s, y2: o });
}
function Kp(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 PQ = {
  ariaLabel: "arrow",
  fill: "none",
  stroke: "currentColor",
  strokeLinecap: "round",
  strokeMiterlimit: 1,
  strokeWidth: 1.5
};
class M4 extends fe {
  constructor(t, n = {}) {
    const {
      x1: i,
      y1: r,
      x2: s,
      y2: o,
      bend: a = 0,
      headAngle: c = 60,
      headLength: l = 8,
      // Disable the arrow with headLength = 0; or, use Plot.link.
      inset: u = 0,
      insetStart: f = u,
      insetEnd: h = u,
      sweep: d
    } = n;
    super(
      t,
      {
        x1: { value: i, scale: "x" },
        y1: { value: r, scale: "y" },
        x2: { value: s, scale: "x", optional: !0 },
        y2: { value: o, scale: "y", optional: !0 }
      },
      n,
      PQ
    ), this.bend = a === !0 ? 22.5 : Math.max(-90, Math.min(90, a)), this.headAngle = +c, this.headLength = +l, this.insetStart = +f, this.insetEnd = +h, this.sweep = VQ(d);
  }
  render(t, n, i, r, s) {
    const { x1: o, y1: a, x2: c = o, y2: l = a, SW: u } = i, { strokeWidth: f, bend: h, headAngle: d, headLength: p, insetStart: y, insetEnd: g } = this, m = u ? (v) => u[v] : jn(f === void 0 ? 1 : f), b = d * Gp / 2, w = p / 1.5;
    return Gt("svg:g", s).call(ve, this, r, s).call(ue, this, n).call(
      (v) => v.selectAll().data(t).enter().append("path").call(be, this).attr("d", (_) => {
        let x = o[_], I = a[_], N = c[_], A = l[_];
        const D = Math.hypot(N - x, A - I);
        if (D <= y + g)
          return null;
        let M = Math.atan2(A - I, N - x);
        const B = Math.min(w * m(_), D / 3), R = this.sweep(x, I, N, A) * h * Gp, S = Math.hypot(D / Math.tan(R), D) / 2;
        if (y || g)
          if (S < 1e5) {
            const K = Math.sign(R), [tt, Z] = jQ([x, I], [N, A], S, K);
            if (y && ([x, I] = DS([tt, Z, S], [x, I, y], -K * Math.sign(y))), g) {
              const [Y, X] = DS([tt, Z, S], [N, A, g], K * Math.sign(g));
              M += Math.atan2(X - Z, Y - tt) - Math.atan2(A - Z, N - tt), N = Y, A = X;
            }
          } else {
            const K = N - x, tt = A - I, Z = Math.hypot(K, tt);
            y && (x += K / Z * y, I += tt / Z * y), g && (N -= K / Z * g, A -= tt / Z * g);
          }
        const $ = M + R, T = $ + b, L = $ - b, k = N - B * Math.cos(T), U = A - B * Math.sin(T), C = N - B * Math.cos(L), z = A - B * Math.sin(L), P = S < 1e5 ? `A${S},${S} 0,0,${R > 0 ? 1 : 0} ` : "L", G = B ? `M${k},${U}L${N},${A}L${C},${z}` : "";
        return `M${x},${I}${P}${N},${A}${G}`;
      }).call(Pe, this, i)
    ).node();
  }
}
function VQ(e = 1) {
  if (typeof e == "number")
    return jn(Math.sign(e));
  if (typeof e == "function")
    return (t, n, i, r) => Math.sign(e(t, n, i, r));
  switch (qn(e, "sweep", ["+x", "-x", "+y", "-y"])) {
    case "+x":
      return (t, n, i) => me(t, i);
    case "-x":
      return (t, n, i) => Ho(t, i);
    case "+y":
      return (t, n, i, r) => me(n, r);
    case "-y":
      return (t, n, i, r) => Ho(n, r);
  }
}
function jQ([e, t], [n, i], r, s) {
  const o = n - e, a = i - t, c = Math.hypot(o, a), l = s * Math.sqrt(r * r - c * c / 4) / c;
  return [(e + n) / 2 - a * l, (t + i) / 2 + o * l];
}
function DS([e, t, n], [i, r, s], o) {
  const a = i - e, c = r - t, l = Math.hypot(a, c), u = (a * a + c * c - s * s + n * n) / (2 * l), f = o * Math.sqrt(n * n - u * u);
  return [e + (a * u + c * f) / l, t + (c * u - a * f) / l];
}
function qQ(e, { x: t, x1: n, x2: i, y: r, y1: s, y2: o, ...a } = {}) {
  return [n, i] = Kp(t, n, i), [s, o] = Kp(r, s, o), new M4(e, { ...a, x1: n, x2: i, y1: s, y2: o });
}
class xv extends fe {
  constructor(t, n, i = {}, r) {
    super(t, n, i, r);
    const { inset: s = 0, insetTop: o = s, insetRight: a = s, insetBottom: c = s, insetLeft: l = s, rx: u, ry: f } = i;
    this.insetTop = qt(o), this.insetRight = qt(a), this.insetBottom = qt(c), this.insetLeft = qt(l), this.rx = Me(u, "auto"), this.ry = Me(f, "auto");
  }
  render(t, n, i, r, s) {
    const { rx: o, ry: a } = this;
    return Gt("svg:g", s).call(ve, this, r, s).call(this._transform, this, n).call(
      (c) => c.selectAll().data(t).enter().append("rect").call(be, this).attr("x", this._x(n, i, r)).attr("width", this._width(n, i, r)).attr("y", this._y(n, i, r)).attr("height", this._height(n, i, r)).call(yt, "rx", o).call(yt, "ry", a).call(Pe, this, i)
    ).node();
  }
  _x(t, { x: n }, { marginLeft: i }) {
    const { insetLeft: r } = this;
    return n ? (s) => n[s] + r : i + r;
  }
  _y(t, { y: n }, { marginTop: i }) {
    const { insetTop: r } = this;
    return n ? (s) => n[s] + r : i + r;
  }
  _width({ x: t }, { x: n }, { marginRight: i, marginLeft: r, width: s }) {
    const { insetLeft: o, insetRight: a } = this, c = n && t ? t.bandwidth() : s - i - r;
    return Math.max(0, c - o - a);
  }
  _height({ y: t }, { y: n }, { marginTop: i, marginBottom: r, height: s }) {
    const { insetTop: o, insetBottom: a } = this, c = n && t ? t.bandwidth() : s - i - r;
    return Math.max(0, c - o - a);
  }
}
const $4 = {
  ariaLabel: "bar"
};
class T4 extends xv {
  constructor(t, n = {}) {
    const { x1: i, x2: r, y: s } = n;
    super(
      t,
      {
        x1: { value: i, scale: "x" },
        x2: { value: r, scale: "x" },
        y: { value: s, scale: "y", type: "band", optional: !0 }
      },
      n,
      $4
    );
  }
  _transform(t, n, { x: i }) {
    t.call(ue, n, { x: i }, 0, 0);
  }
  _x({ x: t }, { x1: n, x2: i }, { marginLeft: r }) {
    const { insetLeft: s } = this;
    return oi(t) ? r + s : (o) => Math.min(n[o], i[o]) + s;
  }
  _width({ x: t }, { x1: n, x2: i }, { marginRight: r, marginLeft: s, width: o }) {
    const { insetLeft: a, insetRight: c } = this;
    return oi(t) ? o - r - s - a - c : (l) => Math.max(0, Math.abs(i[l] - n[l]) - a - c);
  }
}
class D4 extends xv {
  constructor(t, n = {}) {
    const { x: i, y1: r, y2: s } = n;
    super(
      t,
      {
        y1: { value: r, scale: "y" },
        y2: { value: s, scale: "y" },
        x: { value: i, scale: "x", type: "band", optional: !0 }
      },
      n,
      $4
    );
  }
  _transform(t, n, { y: i }) {
    t.call(ue, n, { y: i }, 0, 0);
  }
  _y({ y: t }, { y1: n, y2: i }, { marginTop: r }) {
    const { insetTop: s } = this;
    return oi(t) ? r + s : (o) => Math.min(n[o], i[o]) + s;
  }
  _height({ y: t }, { y1: n, y2: i }, { marginTop: r, marginBottom: s, height: o }) {
    const { insetTop: a, insetBottom: c } = this;
    return oi(t) ? o - r - s - a - c : (l) => Math.max(0, Math.abs(i[l] - n[l]) - a - c);
  }
}
function Lo(e, t = {}) {
  return v0(t) || (t = { ...t, y: vn, x2: Tt }), new T4(e, vv(p8(bv(t))));
}
function Ro(e, t = {}) {
  return v0(t) || (t = { ...t, x: vn, y2: Tt }), new D4(e, _v(y8(wv(t))));
}
const YQ = {
  ariaLabel: "cell"
};
class U0 extends xv {
  constructor(t, { x: n, y: i, ...r } = {}) {
    super(
      t,
      {
        x: { value: n, scale: "x", type: "band", optional: !0 },
        y: { value: i, scale: "y", type: "band", optional: !0 }
      },
      r,
      YQ
    );
  }
  _transform(t, n) {
    t.call(ue, n, {}, 0, 0);
  }
}
function nc(e, { x: t, y: n, ...i } = {}) {
  return [t, n] = ki(t, n), new U0(e, { ...i, x: t, y: n });
}
function WQ(e, { x: t = vn, fill: n, stroke: i, ...r } = {}) {
  return n === void 0 && mn(i)[0] === void 0 && (n = Tt), new U0(e, { ...r, x: t, fill: n, stroke: i });
}
function GQ(e, { y: t = vn, fill: n, stroke: i, ...r } = {}) {
  return n === void 0 && mn(i)[0] === void 0 && (n = Tt), new U0(e, { ...r, y: t, fill: n, stroke: i });
}
const XQ = {
  ariaLabel: "dot",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1.5
};
function Sv(e) {
  return e.sort === void 0 && e.reverse === void 0 ? vD({ channel: "-r" }, e) : e;
}
class z0 extends fe {
  constructor(t, n = {}) {
    const { x: i, y: r, r: s, rotate: o, symbol: a = qu, frameAnchor: c } = n, [l, u] = Be(o, 0), [f, h] = oJ(a), [d, p] = Be(s, f == null ? 3 : 4.5);
    super(
      t,
      {
        x: { value: i, scale: "x", optional: !0 },
        y: { value: r, scale: "y", optional: !0 },
        r: { value: d, scale: "r", filter: Zr, optional: !0 },
        rotate: { value: l, optional: !0 },
        symbol: { value: f, scale: "auto", optional: !0 }
      },
      Sv(n),
      XQ
    ), this.r = p, this.rotate = u, this.symbol = h, this.frameAnchor = kf(c);
    const { channels: y } = this, { symbol: g } = y;
    if (g) {
      const { fill: m, stroke: b } = y;
      g.hint = {
        fill: m ? m.value === g.value ? "color" : "currentColor" : this.fill ?? "currentColor",
        stroke: b ? b.value === g.value ? "color" : "currentColor" : this.stroke ?? "none"
      };
    }
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = n, { x: c, y: l, r: u, rotate: f, symbol: h } = i, { r: d, rotate: p, symbol: y } = this, [g, m] = _r(this, r), b = y === qu, w = u ? void 0 : d * d * Math.PI;
    return b0(d) && (t = []), Gt("svg:g", s).call(ve, this, r, s).call(ue, this, { x: c && o, y: l && a }).call(
      (v) => v.selectAll().data(t).enter().append(b ? "circle" : "path").call(be, this).call(
        b ? (_) => {
          _.attr("cx", c ? (x) => c[x] : g).attr("cy", l ? (x) => l[x] : m).attr("r", u ? (x) => u[x] : d);
        } : (_) => {
          _.attr(
            "transform",
            F0`translate(${c ? (x) => c[x] : g},${l ? (x) => l[x] : m})${f ? (x) => ` rotate(${f[x]})` : p ? ` rotate(${p})` : ""}`
          ).attr(
            "d",
            u && h ? (x) => {
              const I = Gr();
              return h[x].draw(I, u[x] * u[x] * Math.PI), I;
            } : u ? (x) => {
              const I = Gr();
              return y.draw(I, u[x] * u[x] * Math.PI), I;
            } : h ? (x) => {
              const I = Gr();
              return h[x].draw(I, w), I;
            } : (() => {
              const x = Gr();
              return y.draw(x, w), x;
            })()
          );
        }
      ).call(Pe, this, i)
    ).node();
  }
}
function uo(e, { x: t, y: n, ...i } = {}) {
  return i.frameAnchor === void 0 && ([t, n] = ki(t, n)), new z0(e, { ...i, x: t, y: n });
}
function HQ(e, { x: t = Tt, ...n } = {}) {
  return new z0(e, g8({ ...n, x: t }));
}
function JQ(e, { y: t = Tt, ...n } = {}) {
  return new z0(e, m8({ ...n, y: t }));
}
function KQ(e, t) {
  return uo(e, { ...t, symbol: "circle" });
}
function ZQ(e, t) {
  return uo(e, { ...t, symbol: "hexagon" });
}
const QQ = {
  ariaLabel: "line",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1.5,
  strokeLinecap: "round",
  strokeLinejoin: "round",
  strokeMiterlimit: 1
};
class P0 extends fe {
  constructor(t, n = {}) {
    const { x: i, y: r, z: s, curve: o, tension: a } = n;
    super(
      t,
      {
        x: { value: i, scale: "x" },
        y: { value: r, scale: "y" },
        z: { value: ao(n), optional: !0 }
      },
      n,
      QQ
    ), this.z = s, this.curve = f4(o, a), al(this, n);
  }
  filter(t) {
    return t;
  }
  project(t, n, i) {
    this.curve !== Vc && super.project(t, n, i);
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = i, { curve: c } = this;
    return Gt("svg:g", s).call(ve, this, r, s).call(ue, this, n).call(
      (l) => l.selectAll().data(ED(t, [o, a], this, i)).enter().append("path").call(be, this).call(jp, this, i).call(rZ, this, i, s).attr(
        "d",
        c === Vc && s.projection ? ttt(s.projection, o, a) : NT().curve(c).defined((u) => u >= 0).x((u) => o[u]).y((u) => a[u])
      )
    ).node();
  }
}
function ttt(e, t, n) {
  const i = so(e);
  return t = An(t), n = An(n), (r) => {
    let s = [];
    const o = [s];
    for (const a of r)
      a === -1 ? (s = [], o.push(s)) : s.push([t[a], n[a]]);
    return i({ type: "MultiLineString", coordinates: o });
  };
}
function V0(e, { x: t, y: n, ...i } = {}) {
  return [t, n] = ki(t, n), new P0(e, { ...i, x: t, y: n });
}
function Zu(e, { x: t = Tt, y: n = vn, ...i } = {}) {
  return new P0(e, pv({ ...i, x: t, y: n }));
}
function Qu(e, { x: t = vn, y: n = Tt, ...i } = {}) {
  return new P0(e, dv({ ...i, x: t, y: n }));
}
const ett = {
  ariaLabel: "rect"
};
class j0 extends fe {
  constructor(t, n = {}) {
    const {
      x1: i,
      y1: r,
      x2: s,
      y2: o,
      inset: a = 0,
      insetTop: c = a,
      insetRight: l = a,
      insetBottom: u = a,
      insetLeft: f = a,
      rx: h,
      ry: d
    } = n;
    super(
      t,
      {
        x1: { value: i, scale: "x", type: i != null && s == null ? "band" : void 0, optional: !0 },
        y1: { value: r, scale: "y", type: r != null && o == null ? "band" : void 0, optional: !0 },
        x2: { value: s, scale: "x", optional: !0 },
        y2: { value: o, scale: "y", optional: !0 }
      },
      n,
      ett
    ), this.insetTop = qt(c), this.insetRight = qt(l), this.insetBottom = qt(u), this.insetLeft = qt(f), this.rx = Me(h, "auto"), this.ry = Me(d, "auto");
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = n, { x1: c, y1: l, x2: u, y2: f } = i, { marginTop: h, marginRight: d, marginBottom: p, marginLeft: y, width: g, height: m } = r, { projection: b } = s, { insetTop: w, insetRight: v, insetBottom: _, insetLeft: x, rx: I, ry: N } = this, A = (o != null && o.bandwidth ? o.bandwidth() : 0) - x - v, D = (a != null && a.bandwidth ? a.bandwidth() : 0) - w - _;
    return Gt("svg:g", s).call(ve, this, r, s).call(ue, this, {}, 0, 0).call(
      (M) => M.selectAll().data(t).enter().append("rect").call(be, this).attr(
        "x",
        c && (b || !oi(o)) ? u ? (B) => Math.min(c[B], u[B]) + x : (B) => c[B] + x : y + x
      ).attr(
        "y",
        l && (b || !oi(a)) ? f ? (B) => Math.min(l[B], f[B]) + w : (B) => l[B] + w : h + w
      ).attr(
        "width",
        c && (b || !oi(o)) ? u ? (B) => Math.max(0, Math.abs(u[B] - c[B]) + A) : A : g - d - y - v - x
      ).attr(
        "height",
        l && (b || !oi(a)) ? f ? (B) => Math.max(0, Math.abs(l[B] - f[B]) + D) : D : m - h - p - w - _
      ).call(yt, "rx", I).call(yt, "ry", N).call(Pe, this, i)
    ).node();
  }
}
function Iv(e, t) {
  return new j0(e, h8(d8(t)));
}
function Zp(e, t = {}) {
  return v0(t) || (t = { ...t, y: vn, x2: Tt, interval: 1 }), new j0(e, vv(d8(bv(t))));
}
function Qp(e, t = {}) {
  return v0(t) || (t = { ...t, x: vn, y2: Tt, interval: 1 }), new j0(e, _v(h8(wv(t))));
}
function N4(e, t) {
  t = itt(t);
  const { x: n, y: i, color: r, size: s } = t, o = Nh(e, n), a = Nh(e, i), c = Nh(e, r), l = Nh(e, s);
  let {
    fx: u,
    fy: f,
    x: { value: h, reduce: d, zero: p, ...y },
    y: { value: g, reduce: m, zero: b, ...w },
    color: { value: v, color: _, reduce: x },
    size: { value: I, reduce: N },
    // TODO constant radius?
    mark: A
  } = t;
  if (d === void 0 && (d = m == null && h == null && I == null && g != null ? "count" : null), m === void 0 && (m = d == null && g == null && I == null && h != null ? "count" : null), N === void 0 && I == null && x == null && d == null && m == null && (h == null || Ae(o)) && (g == null || Ae(a)) && (N = "count"), p === void 0 && (p = Bh(d) ? !0 : void 0), b === void 0 && (b = Bh(m) ? !0 : void 0), h == null && g == null)
    throw new Error("must specify x or y");
  if (d != null && g == null)
    throw new Error("reducing x requires y");
  if (m != null && h == null)
    throw new Error("reducing y requires x");
  A === void 0 && (A = I != null || N != null ? "dot" : Bh(d) || Bh(m) || x != null ? "bar" : h != null && g != null ? Ae(o) || Ae(a) || d == null && m == null && !Dl(o) && !Dl(a) ? "dot" : "line" : h != null || g != null ? "rule" : null);
  let D, M, B;
  switch (A) {
    case "dot":
      B = uo, M = "stroke";
      break;
    case "line":
      B = o && a || d != null || m != null ? b || m != null || o && Dl(o) ? Qu : p || d != null || a && Dl(a) ? Zu : V0 : o ? Zu : Qu, M = "stroke", BS(c) && (D = null);
      break;
    case "area":
      B = !(b || m != null) && (p || d != null || a && Dl(a)) ? Ku : jc, M = "fill", BS(c) && (D = null);
      break;
    case "rule":
      B = o ? Hs : Js, M = "stroke";
      break;
    case "bar":
      B = d != null ? Ae(a) ? NS(d) && o && Ae(o) ? nc : Lo : Zp : m != null ? Ae(o) ? NS(m) && a && Ae(a) ? nc : Ro : Qp : x != null || N != null ? o && Ae(o) && a && Ae(a) ? nc : o && Ae(o) ? Ro : a && Ae(a) ? Lo : Iv : o && ec(o) && !(a && ec(a)) ? Lo : a && ec(a) && !(o && ec(o)) ? Ro : nc, M = "fill";
      break;
    default:
      throw new Error(`invalid mark: ${A}`);
  }
  let R = {
    fx: u,
    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
    [M]: c ?? _,
    z: D,
    r: l ?? void 0,
    // treat null size as undefined for default constant radius
    tip: !0
  }, S, $ = { [M]: x ?? void 0, r: N ?? void 0 };
  if (d != null && m != null)
    throw new Error("cannot reduce both x and y");
  return m != null ? ($.y = m, S = Ae(o) ? Gu : Ns) : d != null ? ($.x = d, S = Ae(a) ? Xu : Bs) : (x != null || N != null) && (o && a ? S = Ae(o) && Ae(a) ? kw : Ae(o) ? Bs : Ae(a) ? Ns : No : o ? S = Ae(o) ? Gu : Ns : a && (S = Ae(a) ? Xu : Bs)), (S === No || S === Ns) && (R.x = { value: o, ...y }), (S === No || S === Bs) && (R.y = { value: a, ...w }), p === void 0 && (p = o && !(S === No || S === Ns) && (B === Lo || B === Ku || B === Zp || B === Js)), b === void 0 && (b = a && !(S === No || S === Bs) && (B === Ro || B === jc || B === Qp || B === Hs)), {
    fx: u ?? null,
    fy: f ?? null,
    x: {
      value: h ?? null,
      reduce: d ?? null,
      zero: !!p,
      ...y
    },
    y: {
      value: g ?? null,
      reduce: m ?? null,
      zero: !!b,
      ...w
    },
    color: {
      value: v ?? null,
      reduce: x ?? null,
      ..._ !== void 0 && { color: _ }
    },
    size: {
      value: I ?? null,
      reduce: N ?? null
    },
    mark: A,
    markImpl: OS[B],
    markOptions: R,
    transformImpl: OS[S],
    transformOptions: $,
    colorMode: M
  };
}
function ntt(e, t) {
  const n = N4(e, t), {
    fx: i,
    fy: r,
    x: { zero: s },
    y: { zero: o },
    markOptions: a,
    transformOptions: c,
    colorMode: l
  } = n, u = R1[n.markImpl], f = R1[n.transformImpl], h = i != null || r != null ? lv({ strokeOpacity: 0.1 }) : null, d = [s ? Hs([0]) : null, o ? Js([0]) : null], p = u(e, f ? f(c, a) : a);
  return l === "stroke" ? ui(h, d, p) : ui(h, p, d);
}
function Dl(e) {
  let t, n;
  for (const i of e) {
    if (i == null)
      continue;
    if (t === void 0) {
      t = i;
      continue;
    }
    const r = Math.sign(me(t, i));
    if (r) {
      if (n !== void 0 && r !== n)
        return !1;
      t = i, n = r;
    }
  }
  return !0;
}
function itt({ x: e, y: t, color: n, size: i, fx: r, fy: s, mark: o } = {}) {
  return Hi(e) || (e = Aa(e)), Hi(t) || (t = Aa(t)), Hi(n) || (n = Cf(n) ? { color: n } : Aa(n)), Hi(i) || (i = Aa(i)), Hi(r) && ({ value: r } = Aa(r)), Hi(s) && ({ value: s } = Aa(s)), o != null && (o = `${o}`.toLowerCase()), { x: e, y: t, color: n, size: i, fx: r, fy: s, mark: o };
}
function Nh(e, t) {
  const n = Pt(e, t.value);
  return n && (n.label = wr(t.value)), n;
}
function Aa(e) {
  return rtt(e) ? { reduce: e } : { value: e };
}
function Bh(e) {
  return /^(?:distinct|count|sum|proportion)$/i.test(e);
}
function NS(e) {
  return /^(?:first|last|mode)$/i.test(e);
}
function rtt(e) {
  if (e == null)
    return !1;
  if (typeof e.reduceIndex == "function" || typeof e.reduce == "function" && hi(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 BS(e) {
  return e ? new tl(e).size > e.length >> 1 : !1;
}
const R1 = {
  dot: uo,
  line: V0,
  lineX: Zu,
  lineY: Qu,
  areaX: Ku,
  areaY: jc,
  ruleX: Hs,
  ruleY: Js,
  barX: Lo,
  barY: Ro,
  rect: Iv,
  rectX: Zp,
  rectY: Qp,
  cell: nc,
  bin: No,
  binX: Ns,
  binY: Bs,
  group: kw,
  groupX: Gu,
  groupY: Xu
}, OS = Object.fromEntries(Object.entries(R1).map(([e, t]) => [t, e]));
function Av(e, t = {}) {
  let { x: n, x1: i, x2: r } = t;
  n === void 0 && i === void 0 && r === void 0 && (t = { ...t, x: n = Tt });
  const s = {};
  return n != null && (s.x = e), i != null && (s.x1 = e), r != null && (s.x2 = e), pr(s, t);
}
function Mv(e, t = {}) {
  let { y: n, y1: i, y2: r } = t;
  n === void 0 && i === void 0 && r === void 0 && (t = { ...t, y: n = Tt });
  const s = {};
  return n != null && (s.y = e), i != null && (s.y1 = e), r != null && (s.y2 = e), pr(s, t);
}
function pr(e = {}, t = {}) {
  const n = ao(t), i = Object.entries(e).map(([r, s]) => {
    const o = pD(r, t);
    if (o == null)
      throw new Error(`missing channel: ${r}`);
    const [a, c] = Un(o);
    return { key: r, input: o, output: a, setOutput: c, map: stt(s) };
  });
  return {
    ...vr(t, (r, s) => {
      const o = Pt(r, n), a = i.map(({ input: l }) => Pt(r, l)), c = i.map(({ setOutput: l }) => l(new Array(r.length)));
      for (const l of s)
        for (const u of o ? ls(l, (f) => o[f]).values() : [l])
          i.forEach(({ map: f }, h) => f.mapIndex(u, a[h], c[h]));
      return { data: r, facets: s };
    }),
    ...Object.fromEntries(i.map(({ key: r, output: s }) => [r, s]))
  };
}
function stt(e) {
  if (e == null)
    throw new Error("missing map");
  if (typeof e.mapIndex == "function")
    return e;
  if (typeof e.map == "function" && hi(e))
    return ott(e);
  if (typeof e == "function")
    return tg(Dw(e));
  switch (`${e}`.toLowerCase()) {
    case "cumsum":
      return ctt;
    case "rank":
      return tg((t, n) => p3(t, (i) => n[i]));
    case "quantile":
      return tg((t, n) => att(t, (i) => n[i]));
  }
  throw new Error(`invalid map: ${e}`);
}
function ott(e) {
  return console.warn("deprecated map interface; implement mapIndex instead."), { mapIndex: e.map.bind(e) };
}
function att(e, t) {
  const n = Xy(e, t) - 1;
  return p3(e, t).map((i) => i / n);
}
function tg(e) {
  return {
    mapIndex(t, n, i) {
      const r = e(t, n);
      if (r.length !== t.length)
        throw new Error("map function returned a mismatched length");
      for (let s = 0, o = t.length; s < o; ++s)
        i[t[s]] = r[s];
    }
  };
}
const ctt = {
  mapIndex(e, t, n) {
    let i = 0;
    for (const r of e)
      n[r] = i += t[r];
  }
};
function ltt(e = {}, t) {
  return arguments.length === 1 && (t = e), Av(q0(e), t);
}
function utt(e = {}, t) {
  return arguments.length === 1 && (t = e), Mv(q0(e), t);
}
function q0(e = {}) {
  typeof e == "number" && (e = { k: e });
  let { k: t, reduce: n, shift: i, anchor: r, strict: s } = e;
  if (r === void 0 && i !== void 0 && (r = htt(i), Qr(`Warning: the shift option is deprecated; please use anchor "${r}" instead.`)), !((t = Math.floor(t)) > 0))
    throw new Error(`invalid k: ${t}`);
  return dtt(n)(t, ftt(r, t), s);
}
function ftt(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 htt(e) {
  switch (`${e}`.toLowerCase()) {
    case "centered":
      return "middle";
    case "leading":
      return "start";
    case "trailing":
      return "end";
  }
  throw new Error(`invalid shift: ${e}`);
}
function dtt(e = "mean") {
  if (typeof e == "string") {
    if (/^p\d{2}$/i.test(e))
      return Oh($w(e));
    switch (e.toLowerCase()) {
      case "deviation":
        return Oh(bf);
      case "max":
        return Fh((t, n) => De(t, (i) => n[i]));
      case "mean":
        return ptt;
      case "median":
        return Oh(Eu);
      case "min":
        return Fh((t, n) => Ye(t, (i) => n[i]));
      case "mode":
        return Fh((t, n) => d3(t, (i) => n[i]));
      case "sum":
        return B4;
      case "variance":
        return Oh(zb);
      case "difference":
        return gtt;
      case "ratio":
        return btt;
      case "first":
        return wtt;
      case "last":
        return vtt;
    }
  }
  if (typeof e != "function")
    throw new Error(`invalid reduce: ${e}`);
  return Fh(Dw(e));
}
function Oh(e) {
  return (t, n, i) => i ? {
    mapIndex(r, s, o) {
      const a = (l) => s[l] == null ? NaN : +s[l];
      let c = 0;
      for (let l = 0; l < t - 1; ++l)
        isNaN(a(l)) && ++c;
      for (let l = 0, u = r.length - t + 1; l < u; ++l)
        isNaN(a(l + t - 1)) && ++c, o[r[l + n]] = c === 0 ? e(qo(r, l, l + t), a) : NaN, isNaN(a(l)) && --c;
    }
  } : {
    mapIndex(r, s, o) {
      const a = (c) => s[c] == null ? NaN : +s[c];
      for (let c = -n; c < 0; ++c)
        o[r[c + n]] = e(qo(r, 0, c + t), a);
      for (let c = 0, l = r.length - n; c < l; ++c)
        o[r[c + n]] = e(qo(r, c, c + t), a);
    }
  };
}
function Fh(e) {
  return (t, n, i) => i ? {
    mapIndex(r, s, o) {
      let a = 0;
      for (let c = 0; c < t - 1; ++c)
        a += dn(s[r[c]]);
      for (let c = 0, l = r.length - t + 1; c < l; ++c)
        a += dn(s[r[c + t - 1]]), a === t && (o[r[c + n]] = e(qo(r, c, c + t), s)), a -= dn(s[r[c]]);
    }
  } : {
    mapIndex(r, s, o) {
      for (let a = -n; a < 0; ++a)
        o[r[a + n]] = e(qo(r, 0, a + t), s);
      for (let a = 0, c = r.length - n; a < c; ++a)
        o[r[a + n]] = e(qo(r, a, a + t), s);
    }
  };
}
function B4(e, t, n) {
  return n ? {
    mapIndex(i, r, s) {
      let o = 0, a = 0;
      for (let c = 0; c < e - 1; ++c) {
        const l = r[i[c]];
        l === null || isNaN(l) ? ++o : a += +l;
      }
      for (let c = 0, l = i.length - e + 1; c < l; ++c) {
        const u = r[i[c]], f = r[i[c + e - 1]];
        f === null || isNaN(f) ? ++o : a += +f, s[i[c + t]] = o === 0 ? a : NaN, u === null || isNaN(u) ? --o : a -= +u;
      }
    }
  } : {
    mapIndex(i, r, s) {
      let o = 0;
      const a = i.length;
      for (let c = 0, l = Math.min(a, e - t - 1); c < l; ++c)
        o += +r[i[c]] || 0;
      for (let c = -t, l = a - t; c < l; ++c)
        o += +r[i[c + e - 1]] || 0, s[i[c + t]] = o, o -= +r[i[c]] || 0;
    }
  };
}
function ptt(e, t, n) {
  if (n) {
    const i = B4(e, t, n);
    return {
      mapIndex(r, s, o) {
        i.mapIndex(r, s, o);
        for (let a = 0, c = r.length - e + 1; a < c; ++a)
          o[r[a + t]] /= e;
      }
    };
  } else
    return {
      mapIndex(i, r, s) {
        let o = 0, a = 0;
        const c = i.length;
        for (let l = 0, u = Math.min(c, e - t - 1); l < u; ++l) {
          let f = r[i[l]];
          f !== null && !isNaN(f = +f) && (o += f, ++a);
        }
        for (let l = -t, u = c - t; l < u; ++l) {
          let f = r[i[l + e - 1]], h = r[i[l]];
          f !== null && !isNaN(f = +f) && (o += f, ++a), s[i[l + t]] = o / a, h !== null && !isNaN(h = +h) && (o -= h, --a);
        }
      }
    };
}
function ytt(e, t, n, i) {
  for (let r = n + i; n < r; ++n) {
    const s = e[t[n]];
    if (dn(s))
      return s;
  }
}
function mtt(e, t, n, i) {
  for (let r = n + i - 1; r >= n; --r) {
    const s = e[t[r]];
    if (dn(s))
      return s;
  }
}
function O4(e, t, n, i) {
  for (let r = n + i; n < r; ++n) {
    let s = e[t[n]];
    if (s !== null && !isNaN(s = +s))
      return s;
  }
}
function F4(e, t, n, i) {
  for (let r = n + i - 1; r >= n; --r) {
    let s = e[t[r]];
    if (s !== null && !isNaN(s = +s))
      return s;
  }
}
function gtt(e, t, n) {
  return n ? {
    mapIndex(i, r, s) {
      for (let o = 0, a = i.length - e; o < a; ++o) {
        const c = r[i[o]], l = r[i[o + e - 1]];
        s[i[o + t]] = c === null || l === null ? NaN : l - c;
      }
    }
  } : {
    mapIndex(i, r, s) {
      for (let o = -t, a = i.length - e + t + 1; o < a; ++o)
        s[i[o + t]] = F4(r, i, o, e) - O4(r, i, o, e);
    }
  };
}
function btt(e, t, n) {
  return n ? {
    mapIndex(i, r, s) {
      for (let o = 0, a = i.length - e; o < a; ++o) {
        const c = r[i[o]], l = r[i[o + e - 1]];
        s[i[o + t]] = c === null || l === null ? NaN : l / c;
      }
    }
  } : {
    mapIndex(i, r, s) {
      for (let o = -t, a = i.length - e + t + 1; o < a; ++o)
        s[i[o + t]] = F4(r, i, o, e) / O4(r, i, o, e);
    }
  };
}
function wtt(e, t, n) {
  return n ? {
    mapIndex(i, r, s) {
      for (let o = 0, a = i.length - e; o < a; ++o)
        s[i[o + t]] = r[i[o]];
    }
  } : {
    mapIndex(i, r, s) {
      for (let o = -t, a = i.length - e + t + 1; o < a; ++o)
        s[i[o + t]] = ytt(r, i, o, e);
    }
  };
}
function vtt(e, t, n) {
  return n ? {
    mapIndex(i, r, s) {
      for (let o = 0, a = i.length - e; o < a; ++o)
        s[i[o + t]] = r[i[o + e - 1]];
    }
  } : {
    mapIndex(i, r, s) {
      for (let o = -t, a = i.length - e + t + 1; o < a; ++o)
        s[i[o + t]] = mtt(r, i, o, e);
    }
  };
}
const ts = {
  n: 20,
  k: 2,
  color: "currentColor",
  opacity: 0.2,
  strict: !0,
  anchor: "end"
};
function _tt(e, {
  x: t = Tt,
  y: n,
  k: i = ts.k,
  color: r = ts.color,
  opacity: s = ts.opacity,
  fill: o = r,
  fillOpacity: a = s,
  stroke: c = r,
  strokeOpacity: l,
  strokeWidth: u,
  ...f
} = {}) {
  return ui(
    we(o) ? null : Ku(
      e,
      pr(
        { x1: Yo({ k: -i, ...f }), x2: Yo({ k: i, ...f }) },
        { x1: t, x2: t, y: n, fill: o, fillOpacity: a, ...f }
      )
    ),
    we(c) ? null : Zu(e, pr({ x: Yo(f) }, { x: t, y: n, stroke: c, strokeOpacity: l, strokeWidth: u, ...f }))
  );
}
function xtt(e, {
  x: t,
  y: n = Tt,
  k: i = ts.k,
  color: r = ts.color,
  opacity: s = ts.opacity,
  fill: o = r,
  fillOpacity: a = s,
  stroke: c = r,
  strokeOpacity: l,
  strokeWidth: u,
  ...f
} = {}) {
  return ui(
    we(o) ? null : jc(
      e,
      pr(
        { y1: Yo({ k: -i, ...f }), y2: Yo({ k: i, ...f }) },
        { x: t, y1: n, y2: n, fill: o, fillOpacity: a, ...f }
      )
    ),
    we(c) ? null : Qu(e, pr({ y: Yo(f) }, { x: t, y: n, stroke: c, strokeOpacity: l, strokeWidth: u, ...f }))
  );
}
function Yo({ n: e = ts.n, k: t = 0, strict: n = ts.strict, anchor: i = ts.anchor } = {}) {
  return q0({ k: e, reduce: (r) => Hy(r) + t * (bf(r) || 0), strict: n, anchor: i });
}
const Stt = {
  ariaLabel: "tick",
  fill: null,
  stroke: "currentColor"
};
class E4 extends fe {
  constructor(t, n, i) {
    super(t, n, i, Stt), al(this, i);
  }
  render(t, n, i, r, s) {
    return Gt("svg:g", s).call(ve, this, r, s).call(this._transform, this, n).call(
      (o) => o.selectAll().data(t).enter().append("line").call(be, this).attr("x1", this._x1(n, i, r)).attr("x2", this._x2(n, i, r)).attr("y1", this._y1(n, i, r)).attr("y2", this._y2(n, i, r)).call(Pe, this, i).call(qf, this, i, s)
    ).node();
  }
}
class L4 extends E4 {
  constructor(t, n = {}) {
    const { x: i, y: r, inset: s = 0, insetTop: o = s, insetBottom: a = s } = n;
    super(
      t,
      {
        x: { value: i, scale: "x" },
        y: { value: r, scale: "y", type: "band", optional: !0 }
      },
      n
    ), this.insetTop = qt(o), this.insetBottom = qt(a);
  }
  _transform(t, n, { x: i }) {
    t.call(ue, n, { x: i }, He, 0);
  }
  _x1(t, { x: n }) {
    return (i) => n[i];
  }
  _x2(t, { x: n }) {
    return (i) => n[i];
  }
  _y1({ y: t }, { y: n }, { marginTop: i }) {
    const { insetTop: r } = this;
    return n && t ? (s) => n[s] + r : i + r;
  }
  _y2({ y: t }, { y: n }, { height: i, marginBottom: r }) {
    const { insetBottom: s } = this;
    return n && t ? (o) => n[o] + t.bandwidth() - s : i - r - s;
  }
}
class R4 extends E4 {
  constructor(t, n = {}) {
    const { x: i, y: r, inset: s = 0, insetRight: o = s, insetLeft: a = s } = n;
    super(
      t,
      {
        y: { value: r, scale: "y" },
        x: { value: i, scale: "x", type: "band", optional: !0 }
      },
      n
    ), this.insetRight = qt(o), this.insetLeft = qt(a);
  }
  _transform(t, n, { y: i }) {
    t.call(ue, n, { y: i }, 0, He);
  }
  _x1({ x: t }, { x: n }, { marginLeft: i }) {
    const { insetLeft: r } = this;
    return n && t ? (s) => n[s] + r : i + r;
  }
  _x2({ x: t }, { x: n }, { width: i, marginRight: r }) {
    const { insetRight: s } = this;
    return n && t ? (o) => n[o] + t.bandwidth() - s : i - r - s;
  }
  _y1(t, { y: n }) {
    return (i) => n[i];
  }
  _y2(t, { y: n }) {
    return (i) => n[i];
  }
}
function C4(e, { x: t = Tt, ...n } = {}) {
  return new L4(e, { ...n, x: t });
}
function k4(e, { y: t = Tt, ...n } = {}) {
  return new R4(e, { ...n, y: t });
}
function Itt(e, {
  x: t = Tt,
  y: n = null,
  fill: i = "#ccc",
  fillOpacity: r,
  stroke: s = "currentColor",
  strokeOpacity: o,
  strokeWidth: a = 2,
  sort: c,
  ...l
} = {}) {
  const u = n != null ? Xu : Cw;
  return ui(
    Js(e, u({ x1: $v, x2: Tv }, { x: t, y: n, stroke: s, strokeOpacity: o, ...l })),
    Lo(e, u({ x1: "p25", x2: "p75" }, { x: t, y: n, fill: i, fillOpacity: r, ...l })),
    C4(e, u({ x: "p50" }, { x: t, y: n, stroke: s, strokeOpacity: o, strokeWidth: a, sort: c, ...l })),
    uo(e, pr({ x: U4 }, { x: t, y: n, z: n, stroke: s, strokeOpacity: o, ...l }))
  );
}
function Att(e, {
  y: t = Tt,
  x: n = null,
  fill: i = "#ccc",
  fillOpacity: r,
  stroke: s = "currentColor",
  strokeOpacity: o,
  strokeWidth: a = 2,
  sort: c,
  ...l
} = {}) {
  const u = n != null ? Gu : Cw;
  return ui(
    Hs(e, u({ y1: $v, y2: Tv }, { x: n, y: t, stroke: s, strokeOpacity: o, ...l })),
    Ro(e, u({ y1: "p25", y2: "p75" }, { x: n, y: t, fill: i, fillOpacity: r, ...l })),
    k4(e, u({ y: "p50" }, { x: n, y: t, stroke: s, strokeOpacity: o, strokeWidth: a, sort: c, ...l })),
    uo(e, pr({ y: U4 }, { x: n, y: t, z: n, stroke: s, strokeOpacity: o, ...l }))
  );
}
function U4(e) {
  const t = $v(e), n = Tv(e);
  return e.map((i) => i < t || i > n ? i : NaN);
}
function $v(e) {
  const t = z4(e) * 2.5 - P4(e) * 1.5;
  return Ye(e, (n) => n >= t ? n : NaN);
}
function Tv(e) {
  const t = P4(e) * 2.5 - z4(e) * 1.5;
  return De(e, (n) => n <= t ? n : NaN);
}
function z4(e) {
  return Ys(e, 0.25);
}
function P4(e) {
  return Ys(e, 0.75);
}
const Mtt = {
  ariaLabel: "raster",
  stroke: null,
  pixelSize: 1
};
function Ma(e, t) {
  const n = +e;
  if (isNaN(n))
    throw new Error(`invalid ${t}: ${e}`);
  return n;
}
function FS(e, t) {
  const n = Math.floor(e);
  if (isNaN(n))
    throw new Error(`invalid ${t}: ${e}`);
  return n;
}
class V4 extends fe {
  constructor(t, n, i = {}, r) {
    let {
      width: s,
      height: o,
      x: a,
      y: c,
      x1: l = a == null ? 0 : void 0,
      y1: u = c == null ? 0 : void 0,
      x2: f = a == null ? s : void 0,
      y2: h = c == null ? o : void 0,
      pixelSize: d = r.pixelSize,
      blur: p = 0,
      interpolate: y
    } = i;
    if (s != null && (s = FS(s, "width")), o != null && (o = FS(o, "height")), l != null && (l = Ma(l, "x1")), u != null && (u = Ma(u, "y1")), f != null && (f = Ma(f, "x2")), h != null && (h = Ma(h, "y2")), a == null && (l == null || f == null))
      throw new Error("missing x");
    if (c == null && (u == null || h == null))
      throw new Error("missing y");
    t != null && s != null && o != null && (a === void 0 && l != null && f != null && (a = Ltt(l, f, s)), c === void 0 && u != null && h != null && (c = Rtt(u, h, s, o))), super(
      t,
      {
        x: { value: a, scale: "x", optional: !0 },
        y: { value: c, scale: "y", optional: !0 },
        x1: { value: l == null ? null : [l], scale: "x", optional: !0, filter: null },
        y1: { value: u == null ? null : [u], 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
      },
      i,
      r
    ), this.width = s, this.height = o, this.pixelSize = Ma(d, "pixelSize"), this.blur = Ma(p, "blur"), this.interpolate = a == null || c == null ? null : Ttt(y);
  }
}
class j4 extends V4 {
  constructor(t, n = {}) {
    const { imageRendering: i } = n;
    if (t == null) {
      const { fill: r, fillOpacity: s } = n;
      Be(s)[0] !== void 0 && (n = C1("fillOpacity", n)), mn(r)[0] !== void 0 && (n = C1("fill", n));
    }
    super(t, void 0, n, Mtt), this.imageRendering = Me(i, "auto");
  }
  // Ignore the color scale, so the fill channel is returned unscaled.
  scale(t, { color: n, ...i }, r) {
    return super.scale(t, i, r);
  }
  render(t, n, i, r, s) {
    var $;
    const o = n[($ = i.channels.fill) == null ? void 0 : $.scale] ?? ((T) => T), { x: a, y: c } = i, { document: l } = s, [u, f, h, d] = Y4(i, r, s), p = h - u, y = d - f, { pixelSize: g, width: m = Math.round(Math.abs(p) / g), height: b = Math.round(Math.abs(y) / g) } = this, w = m * b;
    let { fill: v, fillOpacity: _ } = i, x = 0;
    if (this.interpolate) {
      const T = m / p, L = b / y, k = ye(a, (C) => (C - u) * T, Float64Array), U = ye(c, (C) => (C - f) * L, Float64Array);
      v && (v = this.interpolate(t, m, b, k, U, v)), _ && (_ = this.interpolate(t, m, b, k, U, _));
    } else
      this.data == null && t && (x = t.fi * w);
    const I = l.createElement("canvas");
    I.width = m, I.height = b;
    const N = I.getContext("2d"), A = N.createImageData(m, b), D = A.data;
    let { r: M, g: B, b: R } = Pn(this.fill) ?? { r: 0, g: 0, b: 0 }, S = (this.fillOpacity ?? 1) * 255;
    for (let T = 0; T < w; ++T) {
      const L = T << 2;
      if (v) {
        const k = o(v[T + x]);
        if (k == null) {
          D[L + 3] = 0;
          continue;
        }
        ({ r: M, g: B, b: R } = Pn(k));
      }
      _ && (S = _[T + x] * 255), D[L + 0] = M, D[L + 1] = B, D[L + 2] = R, D[L + 3] = S;
    }
    return this.blur > 0 && Sz(A, this.blur), N.putImageData(A, 0, 0), Gt("svg:g", s).call(ve, this, r, s).call(ue, this, n).call(
      (T) => T.append("image").attr("transform", `translate(${u},${f}) scale(${Math.sign(h - u)},${Math.sign(d - f)})`).attr("width", Math.abs(p)).attr("height", Math.abs(y)).attr("preserveAspectRatio", "none").call(yt, "image-rendering", this.imageRendering).call(be, this).attr("xlink:href", I.toDataURL())
    ).node();
  }
}
function q4(e, t, n) {
  arguments.length < 3 && (n = t, t = null);
  let { x: i, y: r, [e]: s, ...o } = n;
  return i === void 0 && r === void 0 && XH(t) && (i = Rf, r = Yu, s === void 0 && (s = jH)), [t, { ...o, x: i, y: r, [e]: s }];
}
function $tt() {
  const [e, t] = q4("fill", ...arguments);
  return new j4(
    e,
    e == null || t.fill !== void 0 || t.fillOpacity !== void 0 ? t : { ...t, fill: Tt }
  );
}
function Y4({ x1: e, y1: t, x2: n, y2: i }, r, { projection: s }) {
  const { width: o, height: a, marginTop: c, marginRight: l, marginBottom: u, marginLeft: f } = r;
  return [
    e && s == null ? e[0] : f,
    t && s == null ? t[0] : c,
    n && s == null ? n[0] : o - l,
    i && s == null ? i[0] : a - u
  ];
}
function W4({ x1: e, y1: t, x2: n, y2: i }, r, s, o) {
  const a = {};
  return e && (a.x1 = e), t && (a.y1 = t), n && (a.x2 = n), i && (a.y2 = i), Y4(qw(a, r), s, o);
}
function C1(e, t = {}) {
  const { [e]: n } = t;
  if (typeof n != "function")
    throw new Error(`invalid ${e}: not a function`);
  return Bn({ ...t, [e]: void 0 }, function(i, r, s, o, a, c) {
    const { x: l, y: u } = o;
    if (!l)
      throw new Error("missing scale: x");
    if (!u)
      throw new Error("missing scale: y");
    const [f, h, d, p] = W4(s, o, a, c), y = d - f, g = p - h, { pixelSize: m } = this, { width: b = Math.round(Math.abs(y) / m), height: w = Math.round(Math.abs(g) / m) } = t, v = new Array(b * w * (r ? r.length : 1)), _ = y / b, x = g / w;
    let I = 0;
    for (const N of r ?? [void 0])
      for (let A = 0.5; A < w; ++A)
        for (let D = 0.5; D < b; ++D, ++I)
          v[I] = n(l.invert(f + D * _), u.invert(h + A * x), N);
    return { data: v, facets: r, channels: { [e]: { value: v, scale: "auto" } } };
  });
}
function Ttt(e) {
  if (typeof e == "function")
    return e;
  if (e == null)
    return k1;
  switch (`${e}`.toLowerCase()) {
    case "none":
      return k1;
    case "nearest":
      return X4;
    case "barycentric":
      return G4();
    case "random-walk":
      return H4();
  }
  throw new Error(`invalid interpolate: ${e}`);
}
function k1(e, t, n, i, r, s) {
  const o = new Array(t * n);
  for (const a of e)
    i[a] < 0 || i[a] >= t || r[a] < 0 || r[a] >= n || (o[Math.floor(r[a]) * t + Math.floor(i[a])] = s[a]);
  return o;
}
function G4({ random: e = If(42) } = {}) {
  return (t, n, i, r, s, o) => {
    const { points: a, triangles: c, hull: l } = Ci.from(
      t,
      (d) => r[d],
      (d) => s[d]
    ), u = new o.constructor(n * i).fill(NaN), f = new Uint8Array(n * i), h = Ett(o, e);
    for (let d = 0; d < c.length; d += 3) {
      const p = c[d], y = c[d + 1], g = c[d + 2], m = a[2 * p], b = a[2 * y], w = a[2 * g], v = a[2 * p + 1], _ = a[2 * y + 1], x = a[2 * g + 1], I = Math.min(m, b, w), N = Math.max(m, b, w), A = Math.min(v, _, x), D = Math.max(v, _, x), M = (_ - x) * (m - w) + (v - x) * (w - b);
      if (!M)
        continue;
      const B = o[t[p]], R = o[t[y]], S = o[t[g]];
      for (let $ = Math.floor(I); $ < N; ++$)
        for (let T = Math.floor(A); T < D; ++T) {
          if ($ < 0 || $ >= n || T < 0 || T >= i)
            continue;
          const L = $ + 0.5, k = T + 0.5, U = ((_ - x) * (L - w) + (k - x) * (w - b)) / M;
          if (U < 0)
            continue;
          const C = ((x - v) * (L - w) + (k - x) * (m - w)) / M;
          if (C < 0)
            continue;
          const z = 1 - U - C;
          if (z < 0)
            continue;
          const P = $ + n * T;
          u[P] = h(B, U, R, C, S, z, $, T), f[P] = 1;
        }
    }
    return Dtt(u, f, r, s, o, n, i, l, t, h), u;
  };
}
function Dtt(e, t, n, i, r, s, o, a, c, l) {
  n = Float64Array.from(a, (d) => n[c[d]]), i = Float64Array.from(a, (d) => i[c[d]]), r = Array.from(a, (d) => r[c[d]]);
  const u = n.length, f = Array.from({ length: u }, (d, p) => Btt(p, n, i));
  let h = 0;
  for (let d = 0; d < o; ++d) {
    const p = d + 0.5;
    for (let y = 0; y < s; ++y) {
      const g = y + s * d;
      if (!t[g]) {
        const m = y + 0.5;
        for (let b = 0; b < u; ++b) {
          const w = (u + h + (b % 2 ? (b + 1) / 2 : -b / 2)) % u;
          if (f[w](m, p)) {
            const v = Ntt(n.at(w - 1), i.at(w - 1), n[w], i[w], m, p);
            e[g] = l(r.at(w - 1), v, r[w], 1 - v, r[w], 0, y, d), h = w;
            break;
          }
        }
      }
    }
  }
}
function Ntt(e, t, n, i, r, s) {
  const o = n - e, a = i - t, c = o * (n - r) + a * (i - s), l = o * (r - e) + a * (s - t);
  return c > 0 && l > 0 ? c / (c + l) : +(c > l);
}
function Nl(e, t, n, i) {
  return e * i - n * t;
}
function Btt(e, t, n) {
  const i = t.length, r = t.at(e - 2), s = n.at(e - 2), o = t.at(e - 1), a = n.at(e - 1), c = t[e], l = n[e], u = t.at(e + 1 - i), f = n.at(e + 1 - i), h = o - c, d = a - l, p = r - o, y = s - a, g = c - u, m = l - f, b = Math.hypot(h, d), w = Math.hypot(p, y), v = Math.hypot(g, m);
  return (_, x) => {
    const I = _ - o, N = x - a, A = _ - c, D = x - l;
    return Nl(I, N, A, D) > -1e-6 && Nl(I, N, h, d) * w - Nl(I, N, p, y) * b > -1e-6 && Nl(A, D, g, m) * b - Nl(A, D, h, d) * v <= 0;
  };
}
function X4(e, t, n, i, r, s) {
  const o = new s.constructor(t * n), a = Ci.from(
    e,
    (u) => i[u],
    (u) => r[u]
  );
  let c, l;
  for (let u = 0.5, f = 0; u < n; ++u) {
    l = c;
    for (let h = 0.5; h < t; ++h, ++f)
      l = a.find(h, u, l), h === 0.5 && (c = l), o[f] = s[e[l]];
  }
  return o;
}
function H4({ random: e = If(42), minDistance: t = 0.5, maxSteps: n = 2 } = {}) {
  return (i, r, s, o, a, c) => {
    const l = new c.constructor(r * s), u = Ci.from(
      i,
      (p) => o[p],
      (p) => a[p]
    );
    let f, h, d;
    for (let p = 0.5, y = 0; p < s; ++p) {
      h = f;
      for (let g = 0.5; g < r; ++g, ++y) {
        let m = g, b = p;
        d = h = u.find(m, b, h), g === 0.5 && (f = h);
        let w, v = 0;
        for (; (w = Math.hypot(o[i[d]] - m, a[i[d]] - b)) > t && v < n; ) {
          const _ = e(g, p, v) * 2 * Math.PI;
          m += Math.cos(_) * w, b += Math.sin(_) * w, d = u.find(m, b, d), ++v;
        }
        l[y] = c[i[d]];
      }
    }
    return l;
  };
}
function Ott(e, t, n, i, r, s) {
  return t * e + i * n + s * r;
}
function Ftt(e) {
  return (t, n, i, r, s, o, a, c) => {
    const l = e(a, c);
    return l < n ? t : l < n + r ? i : s;
  };
}
function Ett(e, t) {
  return ec(e) || gn(e) ? Ott : Ftt(t);
}
function Ltt(e, t, n) {
  return {
    transform(i) {
      const r = i.length, s = new Float64Array(r), o = (t - e) / n, a = e + o / 2;
      for (let c = 0; c < r; ++c)
        s[c] = c % n * o + a;
      return s;
    }
  };
}
function Rtt(e, t, n, i) {
  return {
    transform(r) {
      const s = r.length, o = new Float64Array(s), a = (t - e) / i, c = e + a / 2;
      for (let l = 0; l < s; ++l)
        o[l] = Math.floor(l / n) % i * a + c;
      return o;
    }
  };
}
const ES = {
  ariaLabel: "contour",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1,
  pixelSize: 2
};
class J4 extends V4 {
  constructor(t, { smooth: n = !0, value: i, ...r } = {}) {
    const s = FD({}, r, ES);
    if (i === void 0) {
      for (const a in s)
        if (s[a].value != null) {
          if (i !== void 0)
            throw new Error("ambiguous contour value");
          i = r[a], r[a] = "value";
        }
    }
    if (i != null) {
      const a = { transform: (c) => c.map((l) => l.value), label: wr(i) };
      for (const c in s)
        r[c] === "value" && (r[c] = a);
    }
    if (t == null) {
      if (i == null)
        throw new Error("missing contour value");
      r = C1("value", { value: i, ...r }), i = null;
    } else {
      let { interpolate: a } = r;
      i === void 0 && (i = Tt), a === void 0 && (r.interpolate = "nearest");
    }
    super(t, { value: { value: i, optional: !0 } }, Ctt(r), ES);
    const o = { geometry: { value: Tt } };
    for (const a in this.channels) {
      const c = this.channels[a], { scale: l } = c;
      l === "x" || l === "y" || a === "value" || (o[a] = c, delete this.channels[a]);
    }
    this.contourChannels = o, this.smooth = !!n;
  }
  filter(t, { x: n, y: i, value: r, ...s }, o) {
    return super.filter(t, s, o);
  }
  render(t, n, i, r, s) {
    const { geometry: o } = i, a = so();
    return Gt("svg:g", s).call(ve, this, r, s).call(ue, this, n).call((c) => {
      c.selectAll().data(t).enter().append("path").call(be, this).attr("d", (l) => a(o[l])).call(Pe, this, i);
    }).node();
  }
}
function Ctt({ thresholds: e, interval: t, ...n }) {
  return e = d4(e, t, qb), Bn(n, function(i, r, s, o, a, c) {
    const [l, u, f, h] = W4(s, o, a, c), d = f - l, p = h - u, { pixelSize: y, width: g = Math.round(Math.abs(d) / y), height: m = Math.round(Math.abs(p) / y) } = this, b = g / d, w = m / p, v = s.value.value, _ = [];
    if (this.interpolate) {
      const { x: D, y: M } = T0(s, o, c), B = ye(D, (T) => (T - l) * b, Float64Array), R = ye(M, (T) => (T - u) * w, Float64Array), S = [s.x, s.y, s.value], $ = [B, R, v];
      for (const T of r) {
        const L = this.filter(T, S, $);
        _.push(this.interpolate(L, g, m, B, R, v));
      }
    } else if (r) {
      const D = g * m, M = r.length;
      for (let B = 0; B < M; ++B)
        _.push(v.slice(B * D, B * D + D));
    } else
      _.push(v);
    if (this.blur > 0)
      for (const D of _)
        i3({ data: D, width: g, height: m }, this.blur);
    const x = ktt(e, v, ...ztt(_));
    if (x === null)
      throw new Error(`unsupported thresholds: ${e}`);
    const { contour: I } = sp().size([g, m]).smooth(this.smooth), N = [], A = [];
    for (const D of _)
      A.push(Cn(N.length, N.push(...ye(x, (M) => I(D, M)))));
    for (const { coordinates: D } of N)
      for (const M of D)
        for (const B of M)
          for (const R of B)
            R[0] = R[0] / b + l, R[1] = R[1] / w + u;
    return {
      data: N,
      facets: A,
      channels: TD(this.contourChannels, N)
    };
  });
}
function ktt(e, t, n, i) {
  if (typeof (e == null ? void 0 : e.range) == "function")
    return e.range(e.floor(n), i);
  if (typeof e == "function" && (e = e(t, n, i)), typeof e != "number")
    return Nn(e);
  const r = qs(...l3(n, i, e), e);
  for (; r[r.length - 1] >= i; )
    r.pop();
  for (; r[1] < n; )
    r.shift();
  return r;
}
function Utt() {
  return new J4(...q4("value", ...arguments));
}
function ztt(e) {
  return [Ye(e, (t) => Ye(t, LS)), De(e, (t) => De(t, LS))];
}
function LS(e) {
  return isFinite(e) ? e : NaN;
}
function Ptt(e, t) {
  return Dv(ev, e, t);
}
function Vtt(e, t = {}) {
  return Dv(nv, e, t);
}
function jtt(e, t = {}) {
  return Dv(Wp, e, t);
}
function Dv(e, t, n = {}) {
  const { x: i, y: r, maxRadius: s } = n, o = e({ px: i, py: r, maxRadius: s }), a = [];
  i != null && a.push(Hs(t, RS("x", { ...o, inset: -6 }, n))), r != null && a.push(Js(t, RS("y", { ...o, inset: -6 }, n))), i != null && a.push(zc(t, CS("x", { ...o, dy: 9, frameAnchor: "bottom", lineAnchor: "top" }, n))), r != null && a.push(zc(t, CS("y", { ...o, dx: -9, frameAnchor: "left", textAnchor: "end" }, n)));
  for (const c of a)
    c.ariaLabel = `crosshair ${c.ariaLabel}`;
  return ui(...a);
}
function K4(e, { channels: t, ...n }, { facet: i, facetAnchor: r, fx: s, fy: o, [e]: a, channels: c, transform: l, initializer: u }) {
  return {
    ...n,
    facet: i,
    facetAnchor: r,
    fx: s,
    fy: o,
    [e]: a,
    channels: { ...t, ...c },
    transform: l,
    initializer: qtt(e, u)
  };
}
function qtt(e, t) {
  return t == null ? t : function(n, i, { x: r, y: s, px: o, py: a, ...c }, ...l) {
    const { channels: { x: u, y: f, ...h } = {}, ...d } = t.call(this, n, i, { ...c, x: o, y: a }, ...l);
    return {
      channels: {
        ...h,
        ...u && { px: u, ...e === "x" && { x: u } },
        ...f && { py: f, ...e === "y" && { y: f } }
      },
      ...d
    };
  };
}
function RS(e, t, n) {
  const {
    color: i = "currentColor",
    opacity: r = 0.2,
    ruleStroke: s = i,
    ruleStrokeOpacity: o = r,
    ruleStrokeWidth: a
  } = n;
  return {
    ...K4(e, t, n),
    stroke: s,
    strokeOpacity: o,
    strokeWidth: a
  };
}
function CS(e, t, n) {
  const {
    color: i = "currentColor",
    textFill: r = i,
    textFillOpacity: s,
    textStroke: o = "var(--plot-background)",
    textStrokeOpacity: a,
    textStrokeWidth: c = 5
  } = n;
  return {
    ...K4(e, t, Ytt(e, n)),
    fill: r,
    fillOpacity: s,
    stroke: o,
    strokeOpacity: a,
    strokeWidth: c
  };
}
function Ytt(e, t) {
  return Bn(t, (n, i, r) => {
    var s;
    return { channels: { text: { value: (s = $1(r, e)) == null ? void 0 : s.value } } };
  });
}
const Wtt = {
  ariaLabel: "delaunay link",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1
}, Gtt = {
  ariaLabel: "delaunay mesh",
  fill: null,
  stroke: "currentColor",
  strokeOpacity: 0.2
}, Xtt = {
  ariaLabel: "hull",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1.5,
  strokeMiterlimit: 1
}, Htt = {
  ariaLabel: "voronoi",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1
}, Jtt = {
  ariaLabel: "voronoi mesh",
  fill: null,
  stroke: "currentColor",
  strokeOpacity: 0.2
};
class Ktt extends fe {
  constructor(t, n = {}) {
    const { x: i, y: r, z: s, curve: o, tension: a } = n;
    super(
      t,
      {
        x: { value: i, scale: "x", optional: !0 },
        y: { value: r, scale: "y", optional: !0 },
        z: { value: s, optional: !0 }
      },
      n,
      Wtt
    ), this.curve = hv(o, a), al(this, n);
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = n, { x: c, y: l, z: u } = i, { curve: f } = this, [h, d] = _r(this, r), p = c ? (b) => c[b] : jn(h), y = l ? (b) => l[b] : jn(d), g = this;
    function m(b) {
      let w = -1;
      const v = [], _ = {};
      for (const S in i)
        _[S] = [];
      const x = [], I = [], N = [], A = [];
      function D(S, $) {
        S = b[S], $ = b[$], v.push(++w), x[w] = p(S), N[w] = y(S), I[w] = p($), A[w] = y($);
        for (const T in i)
          _[T].push(i[T][$]);
      }
      const { halfedges: M, hull: B, triangles: R } = Ci.from(b, p, y);
      for (let S = 0; S < M.length; ++S) {
        const $ = M[S];
        $ > S && D(R[S], R[$]);
      }
      for (let S = 0; S < B.length; ++S)
        D(B[S], B[(S + 1) % B.length]);
      ce(this).selectAll().data(v).enter().append("path").call(be, g).attr("d", (S) => {
        const $ = Gr(), T = f($);
        return T.lineStart(), T.point(x[S], N[S]), T.point(I[S], A[S]), T.lineEnd(), $;
      }).call(Pe, g, _).call(qf, g, _, s);
    }
    return Gt("svg:g", s).call(ve, this, r, s).call(ue, this, { x: c && o, y: l && a }).call(
      u ? (b) => b.selectAll().data(ls(t, (w) => u[w]).values()).enter().append("g").each(m) : (b) => b.datum(t).each(m)
    ).node();
  }
}
class Nv extends fe {
  constructor(t, n = {}, i, r = ({ 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: r(n), optional: !0 }
      },
      n,
      i
    );
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = n, { x: c, y: l, z: u } = i, [f, h] = _r(this, r), d = c ? (m) => c[m] : jn(f), p = l ? (m) => l[m] : jn(h), y = this;
    function g(m) {
      const b = Ci.from(m, d, p);
      ce(this).append("path").datum(m[0]).call(be, y).attr("d", y._render(b, r)).call(Pe, y, i);
    }
    return Gt("svg:g", s).call(ve, this, r, s).call(ue, this, { x: c && o, y: l && a }).call(
      u ? (m) => m.selectAll().data(ls(t, (b) => u[b]).values()).enter().append("g").each(g) : (m) => m.datum(t).each(g)
    ).node();
  }
}
class Ztt extends Nv {
  constructor(t, n = {}) {
    super(t, n, Gtt), this.fill = "none";
  }
  _render(t) {
    return t.render();
  }
}
class Qtt extends Nv {
  constructor(t, n = {}) {
    super(t, n, Xtt, ao);
  }
  _render(t) {
    return t.renderHull();
  }
}
class tet extends fe {
  constructor(t, n = {}) {
    const { x: i, y: r, z: s } = n;
    super(
      t,
      {
        x: { value: i, scale: "x", optional: !0 },
        y: { value: r, scale: "y", optional: !0 },
        z: { value: s, optional: !0 }
      },
      n,
      Htt
    );
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = n, { x: c, y: l, z: u } = i, [f, h] = _r(this, r), d = c ? (m) => c[m] : jn(f), p = l ? (m) => l[m] : jn(h), y = this;
    function g(m) {
      const b = Ci.from(m, d, p), w = Z4(b, r);
      ce(this).selectAll().data(m).enter().append("path").call(be, y).attr("d", (v, _) => w.renderCell(_)).call(Pe, y, i);
    }
    return Gt("svg:g", s).call(ve, this, r, s).call(ue, this, { x: c && o, y: l && a }).call(
      u ? (m) => m.selectAll().data(ls(t, (b) => u[b]).values()).enter().append("g").each(g) : (m) => m.datum(t).each(g)
    ).node();
  }
}
class eet extends Nv {
  constructor(t, n) {
    super(t, n, Jtt), this.fill = "none";
  }
  _render(t, n) {
    return Z4(t, n).render();
  }
}
function Z4(e, t) {
  const { width: n, height: i, marginTop: r, marginRight: s, marginBottom: o, marginLeft: a } = t;
  return e.voronoi([a, r, n - s, i - o]);
}
function Gf(e, t, { x: n, y: i, ...r } = {}) {
  return [n, i] = ki(n, i), new e(t, { ...r, x: n, y: i });
}
function net(e, t) {
  return Gf(Ktt, e, t);
}
function iet(e, t) {
  return Gf(Ztt, e, t);
}
function ret(e, t) {
  return Gf(Qtt, e, t);
}
function set(e, t) {
  return Gf(tet, e, t);
}
function oet(e, t) {
  return Gf(eet, e, t);
}
const aet = {
  ariaLabel: "density",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1
};
class Q4 extends fe {
  constructor(t, { x: n, y: i, z: r, weight: s, fill: o, stroke: a, ...c } = {}) {
    const l = kS(o) && (o = "currentColor", !0), u = kS(a) && (a = "currentColor", !0);
    super(
      t,
      {
        x: { value: n, scale: "x", optional: !0 },
        y: { value: i, scale: "y", optional: !0 },
        z: { value: ao({ z: r, fill: o, stroke: a }), optional: !0 },
        weight: { value: s, optional: !0 }
      },
      fet({ ...c, fill: o, stroke: a }, l, u),
      aet
    ), l && (this.fill = void 0), u && (this.stroke = void 0), this.z = r;
  }
  filter(t) {
    return t;
  }
  render(t, n, i, r, s) {
    const { contours: o } = i, a = so();
    return Gt("svg:g", s).call(ve, this, r, s).call(ue, this, {}).call(
      (c) => c.selectAll().data(t).enter().append("path").call(be, this).call(Pe, this, i).attr("d", (l) => a(o[l]))
    ).node();
  }
}
function cet(e, { x: t, y: n, ...i } = {}) {
  return [t, n] = ki(t, n), new Q4(e, { ...i, x: t, y: n });
}
const uet = /* @__PURE__ */ new Set(["x", "y", "z", "weight"]);
function fet(e, t, n) {
  let { bandwidth: r, thresholds: s } = e;
  return r = r === void 0 ? 20 : +r, s = s === void 0 ? 20 : typeof (s == null ? void 0 : s[Symbol.iterator]) == "function" ? An(s) : +s, Bn(e, function(o, a, c, l, u, f) {
    var R;
    const h = c.weight ? An(c.weight.value) : null, d = (R = c.z) == null ? void 0 : R.value, { z: p } = this, [y, g] = _r(this, u), { width: m, height: b } = u, { x: w, y: v } = T0(c, l, f), _ = Object.fromEntries(
      Object.entries(c).filter(([S]) => !uet.has(S)).map(([S, $]) => [S, { ...$, value: [] }])
    ), x = t && [], I = n && [], N = rY().x(w ? (S) => w[S] : y).y(v ? (S) => v[S] : g).weight(h ? (S) => h[S] : 1).size([m, b]).bandwidth(r), A = [];
    for (const S of a) {
      const $ = [];
      A.push($);
      for (const T of d ? Ww(S, d, p) : [S]) {
        const L = N.contours(T);
        $.push([T, L]);
      }
    }
    let D = s;
    if (!(D instanceof Cc)) {
      let S = 0;
      for (const $ of A)
        for (const [, T] of $) {
          const L = T.max;
          L > S && (S = L);
        }
      D = Float64Array.from({ length: s - 1 }, ($, T) => S * 100 * (T + 1) / s);
    }
    const M = [], B = [];
    for (const S of A) {
      const $ = [];
      M.push($);
      for (const [T, L] of S)
        for (const k of D) {
          $.push(B.length), B.push(L(k / 100)), x && x.push(k), I && I.push(k);
          for (const U in _)
            _[U].value.push(c[U].value[T[0]]);
        }
    }
    return x && x.push(0), I && I.push(0), {
      data: o,
      facets: M,
      channels: {
        ..._,
        ...x && { fill: { value: x, scale: "color" } },
        ...I && { stroke: { value: I, scale: "color" } },
        contours: { value: B }
      }
    };
  });
}
function kS(e) {
  return /^density$/i.test(e);
}
function het(e, {
  x1: t,
  x2: n,
  y1: i,
  y2: r,
  x: s = t === void 0 && n === void 0 ? vn : void 0,
  y: o = i === void 0 && r === void 0 ? Tt : void 0,
  fill: a,
  // ignored
  positiveFill: c = "#3ca951",
  negativeFill: l = "#4269d0",
  fillOpacity: u = 1,
  positiveFillOpacity: f = u,
  negativeFillOpacity: h = u,
  stroke: d,
  strokeOpacity: p,
  z: y = mn(d)[0],
  clip: g,
  // optional additional clip for area
  tip: m,
  render: b,
  ...w
} = {}) {
  return [t, n] = US(s, t, n), [i, r] = US(o, i, r), t === n && i === r && (i = xs(0)), { tip: m } = fa({ tip: m }, "x"), ui(
    we(c) ? null : Object.assign(
      L1(e, {
        x1: t,
        x2: n,
        y1: i,
        y2: r,
        z: y,
        fill: c,
        fillOpacity: f,
        render: Yp(b, zS(!0)),
        clip: g,
        ...w
      }),
      { ariaLabel: "positive difference" }
    ),
    we(l) ? null : Object.assign(
      L1(e, {
        x1: t,
        x2: n,
        y1: i,
        y2: r,
        z: y,
        fill: l,
        fillOpacity: h,
        render: Yp(b, zS(!1)),
        clip: g,
        ...w
      }),
      { ariaLabel: "negative difference" }
    ),
    V0(e, {
      x: n,
      y: r,
      z: y,
      stroke: d,
      strokeOpacity: p,
      tip: m,
      clip: !0,
      ...w
    })
  );
}
function US(e, t, n) {
  return t === void 0 && n === void 0 ? t = n = xs(e) : t === void 0 ? (n = xs(n), t = e === void 0 ? n : xs(e)) : n === void 0 ? (t = xs(t), n = e === void 0 ? t : xs(e)) : (t = xs(t), n = xs(n)), [t, n];
}
function xs(e) {
  let t;
  const { value: n, label: i = wr(n) } = ol(e);
  return { transform: (r) => t || (t = Pt(r, n)), label: i };
}
function zS(e) {
  return (t, n, i, r, s, o) => {
    const { x1: a, x2: c } = i, { height: l } = r, u = new Float32Array(a.length), f = new Float32Array(c.length);
    (e === ZD(n.y) < 0 ? u : f).fill(l);
    const h = o(t, n, { ...i, x2: a, y2: f }, r, s), d = o(t, n, { ...i, x1: c, y1: u }, r, s), p = h.querySelector("g") ?? h, y = d.querySelector("g") ?? d;
    for (let g = 0; p.firstChild; g += 2) {
      const m = N1(), b = Gt("svg:clipPath", s).attr("id", m).node();
      b.appendChild(p.firstChild), y.childNodes[g].setAttribute("clip-path", `url(#${m})`), y.insertBefore(b, y.childNodes[g]);
    }
    return d;
  };
}
const det = {
  ariaLabel: "geo",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1,
  strokeLinecap: "round",
  strokeLinejoin: "round",
  strokeMiterlimit: 1
};
class tN extends fe {
  constructor(t, n = {}) {
    const [i, r] = Be(n.r, 3);
    super(
      t,
      {
        geometry: { value: n.geometry, scale: "projection" },
        r: { value: i, scale: "r", filter: Zr, optional: !0 }
      },
      Sv(n),
      det
    ), this.r = r;
  }
  render(t, n, i, r, s) {
    const { geometry: o, r: a } = i, c = so(s.projection ?? pet(n)), { r: l } = this;
    return b0(l) ? t = [] : l !== void 0 && c.pointRadius(l), Gt("svg:g", s).call(ve, this, r, s).call(ue, this, n).call((u) => {
      u.selectAll().data(t).enter().append("path").call(be, this).attr("d", a ? (f) => c.pointRadius(a[f])(o[f]) : (f) => c(o[f])).call(Pe, this, i);
    }).node();
  }
}
function pet({ x: e, y: t }) {
  if (e || t)
    return e ?? (e = (n) => n), t ?? (t = (n) => n), Ap({
      point(n, i) {
        this.stream.point(e(n), t(i));
      }
    });
}
function Bv(e, { geometry: t = Tt, ...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 tN(e, { geometry: t, ...n });
}
function yet({ strokeWidth: e = 1.5, ...t } = {}) {
  return Bv({ type: "Sphere" }, { strokeWidth: e, ...t });
}
function met({ strokeOpacity: e = 0.1, ...t } = {}) {
  return Bv(QY(), { strokeOpacity: e, ...t });
}
const mu = 0.5, gu = 0;
function get(e = { fill: "count" }, { binWidth: t, ...n } = {}) {
  const { z: i } = n;
  return t = t === void 0 ? 20 : qt(t), e = SD(e, n), Ls(e, "fill") && (n.channels = { ...n.channels, fill: { value: [] } }), n.symbol === void 0 && (n.symbol = "hexagon"), n.r === void 0 && !Ls(e, "r") && (n.r = t / 2), Bn(n, (r, s, o, a, c, l) => {
    let { x: u, y: f, z: h, fill: d, stroke: p, symbol: y } = o;
    if (u === void 0)
      throw new Error("missing channel: x");
    if (f === void 0)
      throw new Error("missing channel: y");
    ({ x: u, y: f } = T0(o, a, l)), h = h ? h.value : Pt(r, i), d = d == null ? void 0 : d.value, p = p == null ? void 0 : p.value, y = y == null ? void 0 : y.value;
    const g = Pw(e, { z: h, fill: d, stroke: p, symbol: y }), m = h && [], b = d && [], w = p && [], v = y && [], _ = [], x = [], I = [];
    let N = -1;
    for (const B of e)
      B.initialize(r);
    for (const B of s) {
      const R = [];
      for (const S of e)
        S.scope("facet", B);
      for (const [S, $] of dc(B, g))
        for (const { index: T, extent: L } of bet(r, $, u, f, t)) {
          R.push(++N), x.push(L.x), I.push(L.y), h && m.push(g === h ? S : h[T[0]]), d && b.push(g === d ? S : d[T[0]]), p && w.push(g === p ? S : p[T[0]]), y && v.push(g === y ? S : y[T[0]]);
          for (const k of e)
            k.reduce(T, L);
        }
      _.push(R);
    }
    const A = o.x.scale, D = o.y.scale, M = {
      x: { value: x, source: a[A] ? { value: ye(x, a[A].invert), scale: A } : null },
      y: { value: I, source: a[D] ? { value: ye(I, a[D].invert), scale: D } : null },
      ...h && { z: { value: m } },
      ...d && { fill: { value: b, scale: "auto" } },
      ...p && { stroke: { value: w, scale: "auto" } },
      ...y && { symbol: { value: v, scale: "auto" } },
      ...Object.fromEntries(
        e.map(({ name: B, output: R }) => [
          B,
          {
            scale: "auto",
            label: R.label,
            radius: B === "r" ? t / 2 : void 0,
            value: R.transform()
          }
        ])
      )
    };
    return { data: r, facets: _, channels: M };
  });
}
function bet(e, t, n, i, r) {
  const s = r * (1.5 / bD), o = /* @__PURE__ */ new Map();
  for (const a of t) {
    let c = n[a], l = i[a];
    if (isNaN(c) || isNaN(l))
      continue;
    let u = Math.round(l = (l - gu) / s), f = Math.round(c = (c - mu) / r - (u & 1) / 2), h = l - u;
    if (Math.abs(h) * 3 > 1) {
      let y = c - f, g = f + (c < f ? -1 : 1) / 2, m = u + (l < u ? -1 : 1), b = c - g, w = l - m;
      y * y + h * h > b * b + w * w && (f = g + (u & 1 ? 1 : -1) / 2, u = m);
    }
    const d = `${f},${u}`;
    let p = o.get(d);
    p === void 0 && (p = { index: [], extent: { data: e, x: (f + (u & 1) / 2) * r + mu, y: u * s + gu } }, o.set(d, p)), p.index.push(a);
  }
  return o.values();
}
const wet = {
  ariaLabel: "hexgrid",
  fill: "none",
  stroke: "currentColor",
  strokeOpacity: 0.1
};
function vet(e) {
  return new eN(e);
}
class eN extends fe {
  constructor({ binWidth: t = 20, clip: n = !0, ...i } = {}) {
    super(yu, void 0, { clip: n, ...i }, wet), this.binWidth = qt(t);
  }
  render(t, n, i, r, s) {
    const { binWidth: o } = this, { marginTop: a, marginRight: c, marginBottom: l, marginLeft: u, width: f, height: h } = r, d = u - mu, p = f - c - mu, y = a - gu, g = h - l - gu, m = o / 2, b = m * wD, w = b / 2, v = m * 2, _ = b * 1.5, x = Math.floor(d / v), I = Math.ceil(p / v), N = Math.floor((y + w) / _), A = Math.ceil((g - w) / _) + 1, D = `m0,${bs(-b)}l${bs(m)},${bs(w)}v${bs(b)}l${bs(-m)},${bs(w)}`;
    let M = D;
    for (let B = N; B < A; ++B)
      for (let R = x; R < I; ++R)
        M += `M${bs(R * v + (B & 1) * m)},${bs(B * _)}${D}`;
    return Gt("svg:g", s).datum(0).call(ve, this, r, s).call(ue, this, {}, He + mu, He + gu).call((B) => B.append("path").call(be, this).call(Pe, this, i).attr("d", M)).node();
  }
}
function bs(e) {
  return Math.round(e * 1e3) / 1e3;
}
const _et = {
  ariaLabel: "image",
  fill: null,
  stroke: null
};
function xet(e) {
  return /^\.*\//.test(e);
}
function Iet(e) {
  return /^(blob|data|file|http|https):/i.test(e);
}
function Aet(e) {
  return typeof e == "string" && (xet(e) || Iet(e)) ? [void 0, e] : [e, void 0];
}
class nN extends fe {
  constructor(t, n = {}) {
    let { x: i, y: r, r: s, width: o, height: a, rotate: c, src: l, preserveAspectRatio: u, 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] = Aet(l), [g, m] = Be(s), [b, w] = Be(o, m !== void 0 ? m * 2 : void 0), [v, _] = Be(a, m !== void 0 ? m * 2 : void 0), [x, I] = Be(c, 0);
    super(
      t,
      {
        x: { value: i, scale: "x", optional: !0 },
        y: { value: r, scale: "y", optional: !0 },
        r: { value: g, scale: "r", filter: Zr, optional: !0 },
        width: { value: b, filter: Zr, optional: !0 },
        height: { value: v, filter: Zr, optional: !0 },
        rotate: { value: x, optional: !0 },
        src: { value: p, optional: !0 }
      },
      Sv(n),
      _et
    ), this.src = y, this.width = w, this.rotate = I, this.height = _, this.r = m, this.preserveAspectRatio = Me(u, "xMidYMid"), this.crossOrigin = tn(f), this.frameAnchor = kf(h), this.imageRendering = Me(d, "auto");
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = n, { x: c, y: l, width: u, height: f, r: h, rotate: d, src: p } = i, { r: y, width: g, height: m, rotate: b } = this, [w, v] = _r(this, r);
    return Gt("svg:g", s).call(ve, this, r, s).call(ue, this, { x: c && o, y: l && a }).call(
      (_) => _.selectAll().data(t).enter().append("image").call(be, this).attr("x", PS(c, u, h, w, g, y)).attr("y", PS(l, f, h, v, m, y)).attr("width", u ? (x) => u[x] : g !== void 0 ? g : h ? (x) => h[x] * 2 : y * 2).attr("height", f ? (x) => f[x] : m !== void 0 ? m : h ? (x) => h[x] * 2 : y * 2).attr("transform", d ? (x) => `rotate(${d[x]})` : b ? `rotate(${b})` : null).attr("transform-origin", d || b ? F0`${c ? (x) => c[x] : w}px ${l ? (x) => l[x] : v}px` : null).call(yt, "href", p ? (x) => p[x] : this.src).call(yt, "preserveAspectRatio", this.preserveAspectRatio).call(yt, "crossorigin", this.crossOrigin).call(yt, "image-rendering", this.imageRendering).call(yt, "clip-path", h ? (x) => `circle(${h[x]}px)` : y !== void 0 ? `circle(${y}px)` : null).call(Pe, this, i)
    ).node();
  }
}
function PS(e, t, n, i, r, s) {
  return t && e ? (o) => e[o] - t[o] / 2 : t ? (o) => i - t[o] / 2 : e && r !== void 0 ? (o) => e[o] - r / 2 : r !== void 0 ? i - r / 2 : n && e ? (o) => e[o] - n[o] : n ? (o) => i - n[o] : e ? (o) => e[o] - s : i - s;
}
function Met(e, { x: t, y: n, ...i } = {}) {
  return i.frameAnchor === void 0 && ([t, n] = ki(t, n)), new nN(e, { ...i, x: t, y: n });
}
function $et(e, t, n) {
  var i = 1e-8, r = t - 1, s = n - 1, o = 0, a, c, l, u, f, h, d, p, y, g, m;
  if (e <= 0)
    return 0;
  if (e >= 1)
    return 1;
  for (t >= 1 && n >= 1 ? (l = e < 0.5 ? e : 1 - e, u = Math.sqrt(-2 * Math.log(l)), d = (2.30753 + u * 0.27061) / (1 + u * (0.99229 + u * 0.04481)) - u, e < 0.5 && (d = -d), p = (d * d - 3) / 6, y = 2 / (1 / (2 * t - 1) + 1 / (2 * n - 1)), g = 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 * g))) : (a = Math.log(t / (t + n)), c = Math.log(n / (t + n)), u = Math.exp(t * a) / t, f = Math.exp(n * c) / n, g = u + f, e < u / g ? d = Math.pow(t * g * e, 1 / t) : d = 1 - Math.pow(n * g * (1 - e), 1 / n)), m = -yc(t) - yc(n) + yc(t + n); o < 10; o++) {
    if (d === 0 || d === 1)
      return d;
    if (h = Tet(d, t, n) - e, u = Math.exp(r * Math.log(d) + s * Math.log(1 - d) + m), f = h / u, d -= u = f / (1 - 0.5 * Math.min(1, f * (r / d - s / (1 - d)))), d <= 0 && (d = 0.5 * (d + u)), d >= 1 && (d = 0.5 * (d + u + 1)), Math.abs(u) < i * d && o > 0)
      break;
  }
  return d;
}
function Tet(e, t, n) {
  var i = e === 0 || e === 1 ? 0 : Math.exp(yc(t + n) - yc(t) - yc(n) + t * Math.log(e) + n * Math.log(1 - e));
  return e < 0 || e > 1 ? !1 : e < (t + 1) / (t + n + 2) ? i * VS(e, t, n) / t : 1 - i * VS(1 - e, n, t) / n;
}
function VS(e, t, n) {
  var i = 1e-30, r = 1, s = t + n, o = t + 1, a = t - 1, c = 1, l = 1 - s * e / o, u, f, h, d;
  for (Math.abs(l) < i && (l = i), l = 1 / l, d = l; r <= 100 && (u = 2 * r, f = r * (n - r) * e / ((a + u) * (t + u)), l = 1 + f * l, Math.abs(l) < i && (l = i), c = 1 + f / c, Math.abs(c) < i && (c = i), l = 1 / l, d *= l * c, f = -(t + r) * (s + r) * e / ((t + u) * (o + u)), l = 1 + f * l, Math.abs(l) < i && (l = i), c = 1 + f / c, Math.abs(c) < i && (c = i), l = 1 / l, h = l * c, d *= h, !(Math.abs(h - 1) < 3e-7)); r++)
    ;
  return d;
}
function yc(e) {
  var t = 0, n = [
    76.18009172947146,
    -86.5053203294167,
    24.01409824083091,
    -1.231739572450155,
    0.001208650973866179,
    -5395239384953e-18
  ], i = 1.000000000190015, r, s, o;
  for (o = (s = r = e) + 5.5, o -= (r + 0.5) * Math.log(o); t < 6; t++)
    i += n[t] / ++s;
  return Math.log(2.506628274631 * i / r) - o;
}
function Det(e, t) {
  var n = $et(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 Net = {
  ariaLabel: "linear-regression",
  fill: "currentColor",
  fillOpacity: 0.1,
  stroke: "currentColor",
  strokeWidth: 1.5,
  strokeLinecap: "round",
  strokeLinejoin: "round",
  strokeMiterlimit: 1
};
class iN extends fe {
  constructor(t, n = {}) {
    const { x: i, y: r, z: s, ci: o = 0.95, precision: a = 4 } = n;
    if (super(
      t,
      {
        x: { value: i, scale: "x" },
        y: { value: r, scale: "y" },
        z: { value: ao(n), optional: !0 }
      },
      n,
      Net
    ), 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, i, r, s) {
    const { x: o, y: a, z: c } = i, { ci: l } = this;
    return Gt("svg:g", s).call(ve, this, r, s).call(ue, this, n).call(
      (u) => u.selectAll().data(c ? Ww(t, c, this.z) : [t]).enter().call(
        (f) => f.append("path").attr("fill", "none").call(be, this).call(jp, this, { ...i, fill: null, fillOpacity: null }).attr("d", (h) => this._renderLine(h, o, a)).call(
          l && !kc(this.fill) ? (h) => h.select(Bet).attr("stroke", "none").call(be, this).call(jp, this, {
            ...i,
            stroke: null,
            strokeOpacity: null,
            strokeWidth: null
          }).attr("d", (d) => this._renderBand(d, o, a)) : () => {
          }
        )
      )
    ).node();
  }
}
function Bet() {
  return this.parentNode.insertBefore(this.ownerDocument.createElementNS(Ko.svg, "path"), this);
}
class Oet extends iN {
  constructor(t, n) {
    super(t, n);
  }
  _renderBand(t, n, i) {
    const { ci: r, precision: s } = this, [o, a] = ke(t, (u) => i[u]), c = ty(t, i, n), l = rN(t, i, n, (1 - r) / 2, c);
    return yw().y((u) => u).x0((u) => l(u, -1)).x1((u) => l(u, 1))(Cn(o, a - s / 2, s).concat(a));
  }
  _renderLine(t, n, i) {
    const [r, s] = ke(t, (a) => i[a]), o = ty(t, i, n);
    return `M${o(r)},${r}L${o(s)},${s}`;
  }
}
class Fet extends iN {
  constructor(t, n) {
    super(t, n);
  }
  _renderBand(t, n, i) {
    const { ci: r, precision: s } = this, [o, a] = ke(t, (u) => n[u]), c = ty(t, n, i), l = rN(t, n, i, (1 - r) / 2, c);
    return yw().x((u) => u).y0((u) => l(u, -1)).y1((u) => l(u, 1))(Cn(o, a - s / 2, s).concat(a));
  }
  _renderLine(t, n, i) {
    const [r, s] = ke(t, (a) => n[a]), o = ty(t, n, i);
    return `M${r},${o(r)}L${s},${o(s)}`;
  }
}
function Eet(e, { y: t = vn, x: n = Tt, stroke: i, fill: r = we(i) ? "currentColor" : i, ...s } = {}) {
  return new Oet(e, pv({ ...s, x: n, y: t, fill: r, stroke: i }));
}
function Let(e, { x: t = vn, y: n = Tt, stroke: i, fill: r = we(i) ? "currentColor" : i, ...s } = {}) {
  return new Fet(e, dv({ ...s, x: t, y: n, fill: r, stroke: i }));
}
function ty(e, t, n) {
  let i = 0, r = 0, s = 0, o = 0;
  for (const u of e) {
    const f = t[u], h = n[u];
    i += f, r += h, s += f * h, o += f * f;
  }
  const a = e.length, c = (a * s - i * r) / (a * o - i * i), l = (r - c * i) / a;
  return (u) => c * u + l;
}
function rN(e, t, n, i, r) {
  const s = fr(e, (u) => t[u]) / e.length;
  let o = 0, a = 0;
  for (const u of e)
    o += (t[u] - s) ** 2, a += (n[u] - r(t[u])) ** 2;
  const c = Math.sqrt(a / (e.length - 2)), l = Det(i, e.length - 2);
  return (u, f) => {
    const h = r(u), d = c * Math.sqrt(1 / e.length + (u - s) ** 2 / o);
    return h + f * l * d;
  };
}
function U1({
  path: e = Tt,
  // the delimited path
  delimiter: t,
  // how the path is separated
  frameAnchor: n,
  treeLayout: i = Dp,
  treeSort: r,
  treeSeparation: s,
  treeAnchor: o,
  treeFilter: a,
  ...c
} = {}) {
  o = Ov(o), r = oN(r), a != null && (a = P1(a)), n === void 0 && (n = o.frameAnchor);
  const l = aN(t), u = pN(c, P1), [f, h] = Un(), [d, p] = Un();
  return {
    x: f,
    y: d,
    frameAnchor: n,
    ...vr(c, (y, g) => {
      const m = l(Pt(y, e)), b = h([]), w = p([]);
      let v = -1;
      const _ = [], x = [], I = z$().path((A) => m[A]), N = i();
      N.nodeSize && N.nodeSize([1, 1]), N.separation && s !== void 0 && N.separation(s ?? Mw);
      for (const A of u)
        A[ey] = A[hN]([]);
      for (const A of g) {
        const D = [], M = I(A.filter((B) => m[B] != null)).each((B) => B.data = y[B.data]);
        r != null && M.sort(r), N(M);
        for (const B of M.descendants())
          if (!(a != null && !a(B))) {
            D.push(++v), _[v] = B.data, o.position(B, v, b, w);
            for (const R of u)
              R[ey][v] = R[dN](B);
          }
        x.push(D);
      }
      return { data: _, facets: x };
    }),
    ...Object.fromEntries(u)
  };
}
function sN({
  path: e = Tt,
  // the delimited path
  delimiter: t,
  // how the path is separated
  curve: n = "bump-x",
  stroke: i = "#555",
  strokeWidth: r = 1.5,
  strokeOpacity: s = 0.5,
  treeLayout: o = Dp,
  treeSort: a,
  treeSeparation: c,
  treeAnchor: l,
  treeFilter: u,
  ...f
} = {}) {
  l = Ov(l), a = oN(a), u != null && (u = qS(u)), f = { curve: n, stroke: i, strokeWidth: r, strokeOpacity: s, ...f };
  const h = aN(t), d = pN(f, qS), [p, y] = Un(), [g, m] = Un(), [b, w] = Un(), [v, _] = Un();
  return {
    x1: p,
    x2: g,
    y1: b,
    y2: v,
    ...vr(f, (x, I) => {
      const N = h(Pt(x, e)), A = y([]), D = m([]), M = w([]), B = _([]);
      let R = -1;
      const S = [], $ = [], T = z$().path((k) => N[k]), L = o();
      L.nodeSize && L.nodeSize([1, 1]), L.separation && c !== void 0 && L.separation(c ?? Mw);
      for (const k of d)
        k[ey] = k[hN]([]);
      for (const k of I) {
        const U = [], C = T(k.filter((z) => N[z] != null)).each((z) => z.data = x[z.data]);
        a != null && C.sort(a), L(C);
        for (const { source: z, target: P } of C.links())
          if (!(u != null && !u(P, z))) {
            U.push(++R), S[R] = P.data, l.position(z, R, A, M), l.position(P, R, D, B);
            for (const G of d)
              G[ey][R] = G[dN](P, z);
          }
        $.push(U);
      }
      return { data: S, facets: $ };
    }),
    ...Object.fromEntries(d)
  };
}
function Ov(e = "left") {
  switch (`${e}`.trim().toLowerCase()) {
    case "left":
      return Ret;
    case "right":
      return Cet;
  }
  throw new Error(`invalid tree anchor: ${e}`);
}
const Ret = {
  frameAnchor: "left",
  dx: 6,
  position({ x: e, y: t }, n, i, r) {
    i[n] = t, r[n] = -e;
  }
}, Cet = {
  frameAnchor: "right",
  dx: -6,
  position({ x: e, y: t }, n, i, r) {
    i[n] = -t, r[n] = -e;
  }
};
function oN(e) {
  return e == null || typeof e == "function" ? e : `${e}`.trim().toLowerCase().startsWith("node:") ? jS(P1(e)) : jS(ket(e));
}
function jS(e) {
  return (t, n) => li(e(t), e(n));
}
function ket(e) {
  return (t) => {
    var n;
    return (n = t.data) == null ? void 0 : n[e];
  };
}
function aN(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((i) => Uet(i, t));
}
const z1 = 92, cN = 47;
function Uet(e, t) {
  if (t === z1)
    throw new Error("delimiter cannot be backslash");
  let n = !1;
  for (let i = 0, r = e.length; i < r; ++i) {
    switch (e.charCodeAt(i)) {
      case z1:
        if (!n) {
          n = !0;
          continue;
        }
        break;
      case t:
        n ? (e = e.slice(0, i - 1) + e.slice(i), --i, --r) : e = e.slice(0, i) + "/" + e.slice(i + 1);
        break;
      case cN:
        n ? (e = e.slice(0, i) + "\\\\" + e.slice(i), i += 2, r += 2) : (e = e.slice(0, i) + "\\" + e.slice(i), ++i, ++r);
        break;
    }
    n = !1;
  }
  return e;
}
function zet(e) {
  let t = !1;
  for (let n = 0, i = e.length; n < i; ++n) {
    switch (e.charCodeAt(n)) {
      case z1:
        if (!t) {
          t = !0;
          continue;
        }
      case cN:
        t && (e = e.slice(0, n - 1) + e.slice(n), --n, --i);
        break;
    }
    t = !1;
  }
  return e;
}
function lN(e) {
  return hi(e) && typeof e.node == "function";
}
function Pet(e) {
  return hi(e) && typeof e.link == "function";
}
function P1(e) {
  if (lN(e))
    return e.node;
  if (e = `${e}`.trim().toLowerCase(), !!e.startsWith("node:")) {
    switch (e) {
      case "node:name":
        return j1;
      case "node:path":
        return V1;
      case "node:internal":
        return uN;
      case "node:external":
        return fN;
      case "node:depth":
        return q1;
      case "node:height":
        return Y1;
    }
    throw new Error(`invalid node value: ${e}`);
  }
}
function qS(e) {
  if (lN(e))
    return e.node;
  if (Pet(e))
    return e.link;
  if (e = `${e}`.trim().toLowerCase(), !(!e.startsWith("node:") && !e.startsWith("parent:"))) {
    switch (e) {
      case "parent:name":
        return Eh(j1);
      case "parent:path":
        return Eh(V1);
      case "parent:depth":
        return Eh(q1);
      case "parent:height":
        return Eh(Y1);
      case "node:name":
        return j1;
      case "node:path":
        return V1;
      case "node:internal":
        return uN;
      case "node:external":
        return fN;
      case "node:depth":
        return q1;
      case "node:height":
        return Y1;
    }
    throw new Error(`invalid link value: ${e}`);
  }
}
function V1(e) {
  return e.id;
}
function j1(e) {
  return Vet(e.id);
}
function q1(e) {
  return e.depth;
}
function Y1(e) {
  return e.height;
}
function uN(e) {
  return !!e.children;
}
function fN(e) {
  return !e.children;
}
function Eh(e) {
  return (t, n) => n == null ? void 0 : e(n);
}
function Vet(e) {
  let t = e.length;
  for (; --t > 0 && !jet(e, t); )
    ;
  return zet(e.slice(t + 1));
}
function jet(e, t) {
  if (e[t] === "/") {
    let n = 0;
    for (; t > 0 && e[--t] === "\\"; )
      ++n;
    if (!(n & 1))
      return !0;
  }
  return !1;
}
const hN = 2, dN = 3, ey = 4;
function pN(e, t) {
  const n = [];
  for (const i in e) {
    const r = e[i], s = t(r);
    s !== void 0 && n.push([i, ...Un(r), s]);
  }
  return n;
}
function yN(e, {
  fill: t,
  stroke: n,
  strokeWidth: i,
  strokeOpacity: r,
  strokeLinejoin: s,
  strokeLinecap: o,
  strokeMiterlimit: a,
  strokeDasharray: c,
  strokeDashoffset: l,
  marker: u,
  markerStart: f = u,
  markerEnd: h = u,
  dot: d = we(f) && we(h),
  text: p = "node:name",
  textStroke: y = "var(--plot-background)",
  title: g = "node:path",
  dx: m,
  dy: b,
  textAnchor: w,
  treeLayout: v = Dp,
  textLayout: _ = v === Dp || v === C$ ? "mirrored" : "normal",
  tip: x,
  ...I
} = {}) {
  if (m === void 0 && (m = Ov(I.treeAnchor).dx), w !== void 0)
    throw new Error("textAnchor is not a configurable tree option");
  _ = qn(_, "textLayout", ["mirrored", "normal"]);
  function N(A) {
    return zc(
      e,
      U1({
        treeLayout: v,
        text: p,
        fill: t === void 0 ? "currentColor" : t,
        stroke: y,
        dx: m,
        dy: b,
        title: g,
        ...A,
        ...I
      })
    );
  }
  return ui(
    A4(
      e,
      sN({
        treeLayout: v,
        markerStart: f,
        markerEnd: h,
        stroke: n !== void 0 ? n : t === void 0 ? "node:internal" : t,
        strokeWidth: i,
        strokeOpacity: r,
        strokeLinejoin: s,
        strokeLinecap: o,
        strokeMiterlimit: a,
        strokeDasharray: c,
        strokeDashoffset: l,
        ...I
      })
    ),
    d ? uo(e, U1({ treeLayout: v, fill: t === void 0 ? "node:internal" : t, title: g, tip: x, ...I })) : null,
    p != null ? _ === "mirrored" ? [
      N({ textAnchor: "start", treeFilter: "node:external" }),
      N({ textAnchor: "end", treeFilter: "node:internal", dx: -m })
    ] : N() : null
  );
}
function qet(e, t) {
  return yN(e, { ...t, treeLayout: C$ });
}
function Yet({ geometry: e = Tt, ...t } = {}) {
  return Bn({ ...t, x: null, y: null }, (n, i, r, s, o, { projection: a }) => {
    const c = Pt(n, e), l = c.length, u = new Float64Array(l), f = new Float64Array(l), h = so(a);
    for (let d = 0; d < l; ++d)
      [u[d], f[d]] = h.centroid(c[d]);
    return {
      data: n,
      facets: i,
      channels: {
        x: { value: u, scale: a == null ? "x" : null, source: null },
        y: { value: f, scale: a == null ? "y" : null, source: null }
      }
    };
  });
}
function Wet({ geometry: e = Tt, ...t } = {}) {
  let n;
  return {
    ...t,
    x: { transform: (i) => Float64Array.from(n = Pt(Pt(i, e), PY), ([r]) => r) },
    y: { transform: () => Float64Array.from(n, ([, i]) => i) }
  };
}
function Get(e) {
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
function Xet(e, t, n, i, r) {
  for (var s = r + 1; i <= r; ) {
    var o = i + r >>> 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 Het(e, t, n, i, r) {
  for (var s = r + 1; i <= r; ) {
    var o = i + r >>> 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 Jet(e, t, n, i, r) {
  for (var s = i - 1; i <= r; ) {
    var o = i + r >>> 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 Ket(e, t, n, i, r) {
  for (var s = i - 1; i <= r; ) {
    var o = i + r >>> 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 Zet(e, t, n, i, r) {
  for (; i <= r; ) {
    var s = i + r >>> 1, o = e[s], a = n !== void 0 ? n(o, t) : o - t;
    if (a === 0)
      return s;
    a <= 0 ? i = s + 1 : r = s - 1;
  }
  return -1;
}
function Bl(e, t, n, i, r, s) {
  return typeof n == "function" ? s(e, t, n, i === void 0 ? 0 : i | 0, r === void 0 ? e.length - 1 : r | 0) : s(e, t, void 0, n === void 0 ? 0 : n | 0, i === void 0 ? e.length - 1 : i | 0);
}
var Qet = {
  ge: function(e, t, n, i, r) {
    return Bl(e, t, n, i, r, Xet);
  },
  gt: function(e, t, n, i, r) {
    return Bl(e, t, n, i, r, Het);
  },
  lt: function(e, t, n, i, r) {
    return Bl(e, t, n, i, r, Jet);
  },
  le: function(e, t, n, i, r) {
    return Bl(e, t, n, i, r, Ket);
  },
  eq: function(e, t, n, i, r) {
    return Bl(e, t, n, i, r, Zet);
  }
}, ny = Qet, ic = 0, Do = 1, ld = 2, tnt = nnt;
function Fv(e, t, n, i, r) {
  this.mid = e, this.left = t, this.right = n, this.leftPoints = i, this.rightPoints = r, this.count = (t ? t.count : 0) + (n ? n.count : 0) + i.length;
}
var Xf = Fv.prototype;
function eg(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 mN(e, t) {
  var n = qc(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 YS(e, t) {
  var n = e.intervals([]);
  n.push(t), mN(e, n);
}
function WS(e, t) {
  var n = e.intervals([]), i = n.indexOf(t);
  return i < 0 ? ic : (n.splice(i, 1), mN(e, n), Do);
}
Xf.intervals = function(e) {
  return e.push.apply(e, this.leftPoints), this.left && this.left.intervals(e), this.right && this.right.intervals(e), e;
};
Xf.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) ? YS(this, e) : this.left.insert(e) : this.left = qc([e]);
  else if (e[0] > this.mid)
    this.right ? 4 * (this.right.count + 1) > 3 * (t + 1) ? YS(this, e) : this.right.insert(e) : this.right = qc([e]);
  else {
    var n = ny.ge(this.leftPoints, e, Ev), i = ny.ge(this.rightPoints, e, Lv);
    this.leftPoints.splice(n, 0, e), this.rightPoints.splice(i, 0, e);
  }
};
Xf.remove = function(e) {
  var t = this.count - this.leftPoints;
  if (e[1] < this.mid) {
    if (!this.left)
      return ic;
    var n = this.right ? this.right.count : 0;
    if (4 * n > 3 * (t - 1))
      return WS(this, e);
    var i = this.left.remove(e);
    return i === ld ? (this.left = null, this.count -= 1, Do) : (i === Do && (this.count -= 1), i);
  } else if (e[0] > this.mid) {
    if (!this.right)
      return ic;
    var r = this.left ? this.left.count : 0;
    if (4 * r > 3 * (t - 1))
      return WS(this, e);
    var i = this.right.remove(e);
    return i === ld ? (this.right = null, this.count -= 1, Do) : (i === Do && (this.count -= 1), i);
  } else {
    if (this.count === 1)
      return this.leftPoints[0] === e ? ld : ic;
    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, i = this.right;
          s.count -= o.count, s.right = o.left, o.left = a, o.right = i;
        }
        eg(this, o), this.count = (this.left ? this.left.count : 0) + (this.right ? this.right.count : 0) + this.leftPoints.length;
      } else
        this.left ? eg(this, this.left) : eg(this, this.right);
      return Do;
    }
    for (var a = ny.ge(this.leftPoints, e, Ev); 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 i = ny.ge(this.rightPoints, e, Lv); i < this.rightPoints.length && this.rightPoints[i][1] === e[1]; ++i)
          if (this.rightPoints[i] === e)
            return this.rightPoints.splice(i, 1), Do;
      }
    return ic;
  }
};
function gN(e, t, n) {
  for (var i = 0; i < e.length && e[i][0] <= t; ++i) {
    var r = n(e[i]);
    if (r)
      return r;
  }
}
function bN(e, t, n) {
  for (var i = e.length - 1; i >= 0 && e[i][1] >= t; --i) {
    var r = n(e[i]);
    if (r)
      return r;
  }
}
function wN(e, t) {
  for (var n = 0; n < e.length; ++n) {
    var i = t(e[n]);
    if (i)
      return i;
  }
}
Xf.queryPoint = function(e, t) {
  if (e < this.mid) {
    if (this.left) {
      var n = this.left.queryPoint(e, t);
      if (n)
        return n;
    }
    return gN(this.leftPoints, e, t);
  } else if (e > this.mid) {
    if (this.right) {
      var n = this.right.queryPoint(e, t);
      if (n)
        return n;
    }
    return bN(this.rightPoints, e, t);
  } else
    return wN(this.leftPoints, t);
};
Xf.queryInterval = function(e, t, n) {
  if (e < this.mid && this.left) {
    var i = this.left.queryInterval(e, t, n);
    if (i)
      return i;
  }
  if (t > this.mid && this.right) {
    var i = this.right.queryInterval(e, t, n);
    if (i)
      return i;
  }
  return t < this.mid ? gN(this.leftPoints, t, n) : e > this.mid ? bN(this.rightPoints, e, n) : wN(this.leftPoints, n);
};
function ent(e, t) {
  return e - t;
}
function Ev(e, t) {
  var n = e[0] - t[0];
  return n || e[1] - t[1];
}
function Lv(e, t) {
  var n = e[1] - t[1];
  return n || e[0] - t[0];
}
function qc(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(ent);
  for (var i = t[t.length >> 1], r = [], s = [], o = [], n = 0; n < e.length; ++n) {
    var a = e[n];
    a[1] < i ? r.push(a) : i < a[0] ? s.push(a) : o.push(a);
  }
  var c = o, l = o.slice();
  return c.sort(Ev), l.sort(Lv), new Fv(
    i,
    qc(r),
    qc(s),
    c,
    l
  );
}
function W1(e) {
  this.root = e;
}
var hl = W1.prototype;
hl.insert = function(e) {
  this.root ? this.root.insert(e) : this.root = new Fv(e[0], null, null, [e], [e]);
};
hl.remove = function(e) {
  if (this.root) {
    var t = this.root.remove(e);
    return t === ld && (this.root = null), t !== ic;
  }
  return !1;
};
hl.queryPoint = function(e, t) {
  if (this.root)
    return this.root.queryPoint(e, t);
};
hl.queryInterval = function(e, t, n) {
  if (e <= t && this.root)
    return this.root.queryInterval(e, t, n);
};
Object.defineProperty(hl, "count", {
  get: function() {
    return this.root ? this.root.count : 0;
  }
});
Object.defineProperty(hl, "intervals", {
  get: function() {
    return this.root ? this.root.intervals([]) : [];
  }
});
function nnt(e) {
  return !e || e.length === 0 ? new W1(null) : new W1(qc(e));
}
const int = /* @__PURE__ */ Get(tnt), rnt = ({ marginLeft: e }) => [1, e], snt = ({ width: e, marginRight: t }) => [-1, e - t], ont = ({ width: e, marginLeft: t, marginRight: n }) => [0, (t + e - n) / 2], ant = ({ marginTop: e }) => [1, e], cnt = ({ height: e, marginBottom: t }) => [-1, e - t], lnt = ({ height: e, marginTop: t, marginBottom: n }) => [0, (t + e - n) / 2];
function vN(e) {
  return typeof e == "string" ? { anchor: e } : e;
}
function unt(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = _N(e));
  let { anchor: n = "left", padding: i = 1, r = t.r } = vN(e);
  switch (`${n}`.toLowerCase()) {
    case "left":
      n = rnt;
      break;
    case "right":
      n = snt;
      break;
    case "middle":
      n = ont;
      break;
    default:
      throw new Error(`unknown dodge anchor: ${n}`);
  }
  return xN("x", "y", n, qt(i), r, t);
}
function fnt(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = _N(e));
  let { anchor: n = "bottom", padding: i = 1, r = t.r } = vN(e);
  switch (`${n}`.toLowerCase()) {
    case "top":
      n = ant;
      break;
    case "bottom":
      n = cnt;
      break;
    case "middle":
      n = lnt;
      break;
    default:
      throw new Error(`unknown dodge anchor: ${n}`);
  }
  return xN("y", "x", n, qt(i), r, t);
}
function _N(e) {
  const { anchor: t, padding: n, ...i } = e, { r } = i;
  return [{ anchor: t, padding: n, r }, i];
}
function xN(e, t, n, i, r, s) {
  if (r != null && typeof r != "number") {
    let { channels: o, sort: a, reverse: c } = s;
    o = Nw(o), (o == null ? void 0 : o.r) === void 0 && (s = { ...s, channels: { ...o, r: { value: r, scale: "r" } } }), a === void 0 && c === void 0 && (s.sort = { channel: "-r" });
  }
  return Bn(s, function(o, a, c, l, u, f) {
    let { [t]: h, r: d } = c;
    if (!c[t])
      throw new Error(`missing channel: ${t}`);
    ({ [t]: h } = T0(c, l, f));
    const p = d ? void 0 : r !== void 0 ? qt(r) : this.r !== void 0 ? this.r : 3;
    d && (d = Pt(d.value, l[d.scale] || Tt, Float64Array));
    let [y, g] = n(u);
    const m = y ? dnt : hnt, b = new Float64Array(h.length), w = d ? (v) => d[v] : () => p;
    for (let v of a) {
      const _ = int();
      v = v.filter(d ? (I) => Up(h[I]) && Zr(d[I]) : (I) => Up(h[I]));
      const x = new Float64Array(2 * v.length + 2);
      for (const I of v) {
        const N = w(I), A = y ? N + i : 0, D = h[I] - N, M = h[I] + N;
        let B = 2;
        _.queryInterval(D - i, M + i, ([, , S]) => {
          const $ = b[S] - A, T = h[I] - h[S], L = i + (d ? d[I] + d[S] : 2 * p), k = Math.sqrt(L * L - T * T);
          x[B++] = $ - k, x[B++] = $ + k;
        });
        let R = x.slice(0, B);
        y && (R = R.filter((S) => S >= 0));
        t:
          for (const S of R.sort(m)) {
            for (let $ = 0; $ < B; $ += 2)
              if (x[$] + 1e-6 < S && S < x[$ + 1] - 1e-6)
                continue t;
            b[I] = S + A;
            break;
          }
        _.insert([D, M, I]);
      }
    }
    y || (y = 1);
    for (const v of a)
      for (const _ of v)
        b[_] = b[_] * y + g;
    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 hnt(e, t) {
  return Math.abs(e) - Math.abs(t);
}
function dnt(e, t) {
  return e - t;
}
function pnt(e, t) {
  return arguments.length === 1 && ({ basis: e, ...t } = e), Av(Rv(e), t);
}
function ynt(e, t) {
  return arguments.length === 1 && ({ basis: e, ...t } = e), Mv(Rv(e), t);
}
function Rv(e) {
  if (e === void 0)
    return GS;
  if (typeof e == "function")
    return Y0(Dw(e));
  if (/^p\d{2}$/i.test(e))
    return dl($w(e));
  switch (`${e}`.toLowerCase()) {
    case "deviation":
      return bnt;
    case "first":
      return GS;
    case "last":
      return gnt;
    case "max":
      return wnt;
    case "mean":
      return vnt;
    case "median":
      return _nt;
    case "min":
      return xnt;
    case "sum":
      return Snt;
    case "extent":
      return mnt;
  }
  throw new Error(`invalid basis: ${e}`);
}
function Y0(e) {
  return {
    mapIndex(t, n, i) {
      const r = +e(t, n);
      for (const s of t)
        i[s] = n[s] === null ? NaN : n[s] / r;
    }
  };
}
function dl(e) {
  return Y0((t, n) => e(t, (i) => n[i]));
}
const mnt = {
  mapIndex(e, t, n) {
    const [i, r] = ke(e, (o) => t[o]), s = r - i;
    for (const o of e)
      n[o] = t[o] === null ? NaN : (t[o] - i) / s;
  }
}, GS = Y0((e, t) => {
  for (let n = 0; n < e.length; ++n) {
    const i = t[e[n]];
    if (dn(i))
      return i;
  }
}), gnt = Y0((e, t) => {
  for (let n = e.length - 1; n >= 0; --n) {
    const i = t[e[n]];
    if (dn(i))
      return i;
  }
}), bnt = {
  mapIndex(e, t, n) {
    const i = Hy(e, (s) => t[s]), r = bf(e, (s) => t[s]);
    for (const s of e)
      n[s] = t[s] === null ? NaN : r ? (t[s] - i) / r : 0;
  }
}, wnt = dl(De), vnt = dl(Hy), _nt = dl(Eu), xnt = dl(Ye), Snt = dl(fr);
function Int(e, t) {
  return Ant("x", e, t);
}
function Ant(e, t, n = {}) {
  let i, r = 1;
  if (typeof t == "number")
    r = t, i = (l, u) => +l + u;
  else {
    if (typeof t == "string") {
      const l = t.startsWith("-") ? -1 : 1;
      [t, r] = Iw(t.replace(/^[+-]/, "")), r *= l;
    }
    t = x0(t), i = (l, u) => t.offset(l, u);
  }
  const s = `${e}1`, o = `${e}2`, a = pr(
    {
      [s]: (l) => l.map((u) => i(u, r)),
      [o]: (l) => l
    },
    n
  ), c = a[o].transform;
  return a[o].transform = () => {
    const l = c(), [u, f] = ke(l);
    return l.domain = r < 0 ? [u, i(f, r)] : [i(u, r), f], l;
  }, a;
}
function Mnt(e, t = {}) {
  if (typeof e == "string")
    switch (e.toLowerCase()) {
      case "first":
        return SN(t);
      case "last":
        return IN(t);
    }
  if (typeof e == "function")
    return Ks(null, e, t);
  let n, i;
  for (n in e) {
    if (i !== void 0)
      throw new Error("ambiguous selector; multiple inputs");
    i = $nt(e[n]);
  }
  if (i === void 0)
    throw new Error(`invalid selector: ${e}`);
  return Ks(n, i, t);
}
function $nt(e) {
  if (typeof e == "function")
    return e;
  switch (`${e}`.toLowerCase()) {
    case "min":
      return Cv;
    case "max":
      return kv;
  }
  throw new Error(`unknown selector: ${e}`);
}
function SN(e) {
  return Ks(null, Ont, e);
}
function IN(e) {
  return Ks(null, Fnt, e);
}
function Tnt(e) {
  return Ks("x", Cv, e);
}
function Dnt(e) {
  return Ks("y", Cv, e);
}
function Nnt(e) {
  return Ks("x", kv, e);
}
function Bnt(e) {
  return Ks("y", kv, e);
}
function* Ont(e) {
  yield e[0];
}
function* Fnt(e) {
  yield e[e.length - 1];
}
function* Cv(e, t) {
  yield qz(e, (n) => t[n]);
}
function* kv(e, t) {
  yield Yb(e, (n) => t[n]);
}
function Ks(e, t, n) {
  if (e != null) {
    if (n[e] == null)
      throw new Error(`missing channel: ${e}`);
    e = n[e];
  }
  const i = ao(n);
  return vr(n, (r, s) => {
    const o = Pt(r, i), a = Pt(r, e), c = [];
    for (const l of s) {
      const u = [];
      for (const f of o ? ls(l, (h) => o[h]).values() : [l])
        for (const h of t(f, a))
          u.push(h);
      c.push(u);
    }
    return { data: r, facets: c };
  });
}
const XS = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  Area: k0,
  Arrow: M4,
  BarX: T4,
  BarY: D4,
  Cell: U0,
  Contour: J4,
  Density: Q4,
  Dot: z0,
  Frame: a4,
  Geo: tN,
  Hexgrid: eN,
  Image: nN,
  Line: P0,
  Link: I4,
  Mark: fe,
  Raster: j4,
  Rect: j0,
  RuleX: w8,
  RuleY: v8,
  Text: E0,
  TickX: L4,
  TickY: R4,
  Tip: c4,
  Vector: L0,
  area: L1,
  areaX: Ku,
  areaY: jc,
  arrow: qQ,
  auto: ntt,
  autoSpec: N4,
  axisFx: j8,
  axisFy: V8,
  axisX: ov,
  axisY: sv,
  barX: Lo,
  barY: Ro,
  bin: No,
  binX: Ns,
  binY: Bs,
  bollinger: Yo,
  bollingerX: _tt,
  bollingerY: xtt,
  boxX: Itt,
  boxY: Att,
  cell: nc,
  cellX: WQ,
  cellY: GQ,
  centroid: Yet,
  circle: KQ,
  cluster: qet,
  column: Un,
  contour: Utt,
  crosshair: Ptt,
  crosshairX: Vtt,
  crosshairY: jtt,
  delaunayLink: net,
  delaunayMesh: iet,
  density: cet,
  differenceY: het,
  dodgeX: unt,
  dodgeY: fnt,
  dot: uo,
  dotX: HQ,
  dotY: JQ,
  filter: aJ,
  find: xJ,
  formatIsoDate: OD,
  formatMonth: BJ,
  formatWeekday: OJ,
  frame: lv,
  geo: Bv,
  geoCentroid: Wet,
  graticule: met,
  gridFx: H8,
  gridFy: G8,
  gridX: X8,
  gridY: W8,
  group: kw,
  groupX: Gu,
  groupY: Xu,
  groupZ: Cw,
  hexagon: ZQ,
  hexbin: get,
  hexgrid: vet,
  hull: ret,
  identity: Tt,
  image: Met,
  indexOf: vn,
  initializer: Bn,
  interpolateNearest: X4,
  interpolateNone: k1,
  interpolatorBarycentric: G4,
  interpolatorRandomWalk: H4,
  legend: OZ,
  line: V0,
  lineX: Zu,
  lineY: Qu,
  linearRegressionX: Eet,
  linearRegressionY: Let,
  link: A4,
  map: pr,
  mapX: Av,
  mapY: Mv,
  marks: ui,
  normalize: Rv,
  normalizeX: pnt,
  normalizeY: ynt,
  plot: uv,
  pointer: ev,
  pointerX: nv,
  pointerY: Wp,
  raster: $tt,
  rect: Iv,
  rectX: Zp,
  rectY: Qp,
  reverse: cJ,
  ruleX: Hs,
  ruleY: Js,
  scale: qp,
  select: Mnt,
  selectFirst: SN,
  selectLast: IN,
  selectMaxX: Nnt,
  selectMaxY: Bnt,
  selectMinX: Tnt,
  selectMinY: Dnt,
  shiftX: Int,
  shuffle: lJ,
  sort: vD,
  sphere: yet,
  spike: vZ,
  stackX: b4,
  stackX1: SQ,
  stackX2: IQ,
  stackY: w4,
  stackY1: AQ,
  stackY2: MQ,
  text: zc,
  textX: I8,
  textY: A8,
  tickX: C4,
  tickY: k4,
  tip: l4,
  transform: vr,
  tree: yN,
  treeLink: sN,
  treeNode: U1,
  valueof: Pt,
  vector: L8,
  vectorX: R8,
  vectorY: C8,
  voronoi: set,
  voronoiMesh: oet,
  window: q0,
  windowX: ltt,
  windowY: utt
}, Symbol.toStringTag, { value: "Module" })), Ent = /* @__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"],
  ["round", "round"],
  ["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"],
  ["xLabelOffset", "x.labelOffset"],
  ["xFontVariant", "x.fontVariant"],
  ["xAriaLabel", "x.ariaLabel"],
  ["xAriaDescription", "x.ariaDescription"],
  ["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"],
  ["yLabelOffset", "y.labelOffset"],
  ["yFontVariant", "y.fontVariant"],
  ["yAriaLabel", "y.ariaLabel"],
  ["yAriaDescription", "y.ariaDescription"],
  ["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"],
  ["fxNice", "fx.nice"],
  ["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"],
  ["fyNice", "fy.mice"],
  ["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"],
  ["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"],
  ["opacityReverse", "opacity.reverse"],
  ["opacityZero", "opacity.zero"],
  ["opacityTickFormat", "opacity.tickFormat"],
  ["opacityBase", "opacity.base"],
  ["opacityExponent", "opacity.exponent"],
  ["opacityConstant", "opacity.constant"],
  ["rScale", "r.type"],
  ["rDomain", "r.domain"],
  ["rRange", "r.range"],
  ["rClamp", "r.clamp"],
  ["rNice", "r.nice"],
  ["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"],
  ["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 Lnt(e, t, n) {
  for (let i = 0; i < t.length; ++i) {
    const r = t[i];
    i === t.length - 1 ? e[r] = n : e = e[r] || (e[r] = {});
  }
}
function Rnt(e, t, n) {
  for (const i in e) {
    const r = Ent.get(i);
    if (r == null)
      throw new Error(`Unrecognized plot attribute: ${i}`);
    const s = e[i];
    typeof s == "symbol" ? n.push(i) : s !== void 0 && Lnt(t, r.split("."), s);
  }
}
const Cnt = /* @__PURE__ */ new Set([
  "frame",
  "hexgrid",
  "sphere",
  "graticule"
]);
async function knt(e) {
  const t = { marks: [] }, n = [], { attributes: i, marks: r } = e;
  Rnt(i, t, n);
  const s = [];
  for (const a of r)
    for (const { type: c, data: l, options: u } of a.plotSpecs())
      Cnt.has(c) ? t.marks.push(XS[c](u)) : t.marks.push(XS[c](l, u)), s.push(a.index);
  znt(t, e);
  const o = uv(t);
  Pnt(o, s), Unt(e, o, i, n);
  for (const a of e.interactors)
    await a.init(o);
  return o;
}
function Unt(e, t, n, i) {
  i.forEach((r) => {
    const s = n[r];
    if (s === gf) {
      if (!r.endsWith("Domain"))
        throw new Error(`Unsupported fixed attribute: ${r}`);
      const o = r.slice(0, -6), a = t.scale(o);
      a != null && a.domain && e.setAttribute(r, n[`${o}Reverse`] ? a.domain.slice().reverse() : a.domain);
    } else
      throw new Error(`Unrecognized symbol: ${s}`);
  });
}
function znt(e, t) {
  const { marks: n } = t;
  Lh("x", e, n), Lh("y", e, n), Lh("fx", e, n), Lh("fy", e, n);
}
function Lh(e, t, n) {
  const i = t[e] || {};
  if (i.axis === null || i.label !== void 0)
    return;
  const r = n.map((l) => {
    var u;
    return (u = l.channelField(e)) == null ? void 0 : u.field;
  });
  if (r.every((l) => l == null))
    return;
  let s, o, a;
  for (let l = 0; l < r.length; ++l) {
    const { column: u, label: f } = r[l] || {};
    u === void 0 && f === void 0 || (s === void 0 && o === void 0 ? (s = u, o = f, a = Vnt(n[l].data, e) || "number") : o !== f ? o = void 0 : s !== u && (s = void 0));
  }
  let c = o || s;
  if (c !== void 0) {
    if ((a === "number" || a === "date") && (e === "x" || e === "y")) {
      i.percent && (c = `${c} (%)`);
      const l = (e === "x" ? 1 : -1) * (i.reverse ? -1 : 1);
      e === "x" || i.labelAnchor === "center" ? c = e === "x" == l < 0 ? `← ${c}` : `${c} →` : c = `${l < 0 ? "↑ " : "↓ "}${c}`;
    }
    t[e] = { ...i, label: c };
  }
}
function Pnt(e, t) {
  const n = e.querySelectorAll('g[aria-label="facet"]');
  if (n.length)
    for (const i of n)
      HS(i, t);
  else
    HS(e, t);
}
function HS(e, t) {
  let n = -1;
  for (const i of e.children) {
    const r = i.getAttribute("aria-label") || "";
    i.nodeName === "style" || r.includes("-axis") || r.includes("-grid") || i.setAttribute("data-index", t[++n]);
  }
}
function Vnt(e, t) {
  for (const n of e) {
    const i = n[t] ?? n[t + "1"] ?? n[t + "2"];
    if (i != null)
      return i instanceof Date ? "date" : typeof i;
  }
}
const jnt = {
  width: 640,
  marginLeft: 40,
  marginRight: 20,
  marginTop: 20,
  marginBottom: 30
};
class qnt {
  constructor(t) {
    this.attributes = { ...jnt }, 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 = wz();
  }
  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: i } = this.margins();
    let r = this.getAttribute("height");
    return r == null && t != null && (r = t, this.setAttribute("height", r, { silent: !0 })), r - n - i;
  }
  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 knt(this), n = this.legends.flatMap(({ legend: i, include: r }) => {
      const s = i.init(t);
      return r ? s : [];
    });
    this.element.replaceChildren(t, ...n), this.synch.resolve();
  }
  getAttribute(t) {
    return this.attributes[t];
  }
  setAttribute(t, n, i) {
    var r, s;
    return t3(this.attributes[t], n) ? (n === void 0 ? delete this.attributes[t] : this.attributes[t] = n, i != null && i.silent || (s = (r = this.listeners) == null ? void 0 : r.get(t)) == null || s.forEach((o) => o(t, n)), !0) : !1;
  }
  addAttributeListener(t, n) {
    const i = this.listeners || (this.listeners = /* @__PURE__ */ new Map());
    return i.has(t) || i.set(t, /* @__PURE__ */ new Set()), i.get(t).add(n), this;
  }
  removeAttributeListener(t, n) {
    var i, r;
    return (r = (i = this.listeners) == null ? void 0 : i.get(t)) == null ? void 0 : r.delete(n);
  }
  addParams(t, n) {
    const { params: i } = this;
    for (const r of n)
      i.has(r) ? i.get(r).push(t) : (i.set(r, [t]), r.addEventListener("value", () => Promise.allSettled(
        i.get(r).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 AN(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
  Ws(e) !== null);
}
const Ynt = /* @__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"
]);
function Wnt(e) {
  return Ynt.has(e);
}
const Gnt = /* @__PURE__ */ new Set([
  "asterisk",
  "circle",
  "cross",
  "diamond",
  "diamond2",
  "hexagon",
  "plus",
  "square",
  "square2",
  "star",
  "times",
  "triangle",
  "triangle2",
  "wye"
]);
function Xnt(e) {
  return Gnt.has(`${e}`.toLowerCase());
}
function MN(e) {
  return Ub(e) ? Hnt(e) : e;
}
function Hnt(e) {
  const { batches: t, numRows: n } = e;
  if (!n)
    return [];
  const i = Array.from({ length: n }, () => ({}));
  for (let r = 0, s = 0; s < t.length; ++s) {
    const o = t[s], { schema: a, numRows: c, numCols: l } = o;
    for (let u = 0; u < l; ++u) {
      const f = o.getChildAt(u), { name: h, type: d } = a.fields[u], p = ZM(d);
      for (let y = r, g = 0; g < c; ++g, ++y)
        i[y][h] = p(f.get(g));
    }
    r += c;
  }
  return i;
}
const $N = (e) => e === "stroke" || e === "fill", Jnt = (e) => e === "symbol", Knt = (e, t) => e !== "sort" && e !== "tip" && t != null && !Array.isArray(t), ng = (e, t) => ({
  channel: e,
  field: t,
  as: t instanceof Vs ? t.column : e
}), ig = (e, t) => ({ channel: e, value: t }), G1 = (e) => Array.isArray(e);
class ha extends cf {
  constructor(t, n, i, r = {}) {
    var l;
    super((l = n == null ? void 0 : n.options) == null ? void 0 : l.filterBy), this.type = t, this.reqs = r, this.source = n, G1(this.source) && (this.data = this.source);
    const s = this.channels = [], o = this.detail = /* @__PURE__ */ new Set(), a = this.params = /* @__PURE__ */ new Set(), c = (u, f) => {
      const h = typeof f;
      if (u === "channels")
        for (const d in f)
          o.add(d), c(d, f[d]);
      else if (h === "function" && f[e3]) {
        const d = f(this, u);
        for (const p in d)
          c(p, d[p]);
      } else if (h === "string")
        Wnt(u) || $N(u) && AN(f) || Jnt(u) && Xnt(f) ? s.push(ig(u, f)) : s.push(ng(u, Vy(f)));
      else if (Ac(f))
        if (Array.isArray(f.columns))
          s.push(ng(u, f)), a.add(f);
        else {
          const d = ig(u, f.value);
          s.push(d), f.addEventListener("value", (p) => (d.value = p, this.update()));
        }
      else
        h === "object" && Knt(u, f) ? s.push(ng(u, f)) : f !== void 0 && s.push(ig(u, f));
    };
    for (const u in i)
      c(u, i[u]);
  }
  setPlot(t, n) {
    var i;
    this.plot = t, this.index = n, t.addParams(this, this.params), (i = this.source) != null && i.table && this.queryPending();
  }
  hasOwnData() {
    return this.source == null || G1(this.source);
  }
  hasFieldInfo() {
    return !!this._fieldInfo;
  }
  channel(t) {
    return this.channels.find((n) => n.channel === t);
  }
  channelField(t, { exact: n } = {}) {
    const i = n ? this.channel(t) : this.channels.find((r) => r.channel.startsWith(t));
    return i != null && i.field ? i : null;
  }
  fields() {
    var s, o, a;
    if (this.hasOwnData())
      return null;
    const { source: { table: t }, channels: n, reqs: i } = this, r = /* @__PURE__ */ new Map();
    for (const { channel: c, field: l } of n) {
      if (!l)
        continue;
      const u = ((s = l.stats) == null ? void 0 : s.stats) || [], f = ((o = l.stats) == null ? void 0 : o.column) ?? l, h = r.get(f) ?? r.set(f, /* @__PURE__ */ new Set()).get(f);
      u.forEach((d) => h.add(d)), (a = i[c]) == null || a.forEach((d) => h.add(d));
    }
    return Array.from(r, ([c, l]) => ({ table: t, column: c, stats: l }));
  }
  fieldInfo(t) {
    var i;
    const n = Object.fromEntries(t.map((r) => [r.column, r]));
    for (const r of this.channels) {
      const { field: s } = r;
      s && Object.assign(r, n[((i = s.stats) == null ? void 0 : i.column) ?? s]);
    }
    return this._fieldInfo = !0, this;
  }
  query(t = []) {
    if (this.hasOwnData())
      return null;
    const { channels: n, source: { table: i } } = this;
    return TN(n, i).where(t);
  }
  queryPending() {
    return this.plot.pending(this), this;
  }
  queryResult(t) {
    return this.data = MN(t), this;
  }
  update() {
    return this.plot.update(this);
  }
  plotSpecs() {
    const { type: t, data: n, detail: i, channels: r } = this, s = {}, o = {};
    for (const a of r) {
      const c = i.has(a.channel) ? o : s;
      c[a.channel] = Rs(a);
    }
    return i.size && (s.channels = o), [{ type: t, data: n, options: s }];
  }
}
function Rs(e) {
  return Object.hasOwn(e, "value") ? e.value : $N(e.channel) ? { value: e.as, scale: "color" } : e.as;
}
function TN(e, t, n = []) {
  const i = Et.from({ source: t }), r = /* @__PURE__ */ new Set();
  let s = !1;
  for (const o of e) {
    const { channel: a, field: c, as: l } = o;
    if (!n.includes(a)) {
      if (a === "orderby")
        i.orderby(o.value);
      else if (c) {
        if (c.aggregate)
          s = !0;
        else {
          if (r.has(l))
            continue;
          r.add(l);
        }
        i.select({ [l]: c });
      }
    }
  }
  return s && i.groupby(Array.from(r)), i;
}
function iy(e, t) {
  const { plot: n } = e;
  let i = n.getAttribute(`${t}Scale`);
  if (!i) {
    const { type: s } = e.channelField(t);
    i = s === "date" ? "time" : "linear";
  }
  const r = { type: i };
  switch (i) {
    case "log":
      r.base = n.getAttribute(`${t}Base`) ?? 10;
      break;
    case "pow":
      r.exponent = n.getAttribute(`${t}Exponent`) ?? 1;
      break;
    case "symlog":
      r.constant = n.getAttribute(`${t}Constant`) ?? 1;
      break;
  }
  return GM(r);
}
function Zs(e, t, n, i, r = 1, s) {
  const { field: o } = e.channelField(t);
  s = s ?? o;
  const { type: a, apply: c, sqlApply: l } = iy(e, t), u = !!e.plot.getAttribute(`${t}Reverse`), [f, h] = i.map((b) => c(b)), d = l(s), p = a === "time" || a === "utc" ? d : s, y = h === f ? 0 : (n - r) / (h - f), g = y !== 1 ? ` * ${y}::DOUBLE` : "";
  return [u ? q`(${h} - ${d}::DOUBLE)${g}` : q`(${d}::DOUBLE - ${f})${g}`, p];
}
const DN = { x: ["min", "max"] }, NN = { y: ["min", "max"] }, BN = { ...DN, ...NN };
function ON(e, t, n, i, r) {
  const { plot: s } = e, o = s.getAttribute(i), a = s.getAttribute(r);
  if (Array.isArray(o) && !o[Mi])
    return o;
  {
    const { column: c, min: l, max: u } = e.channelField(n), f = FN(t, c) || (a ? l0().domain([l, u]).nice().domain() : [l, u]);
    return o !== gf && (f[Mi] = !0), s.setAttribute(i, f, { silent: !0 }), f;
  }
}
function Hf(e, t) {
  return ON(e, t, "x", "xDomain", "xNice");
}
function Jf(e, t) {
  return ON(e, t, "y", "yDomain", "yNice");
}
function FN(e, t) {
  if (!e)
    return;
  let n, i;
  const r = (s, o) => {
    if (s === "BETWEEN" && `${o.field}` === t) {
      const { range: a } = o;
      a && (n == null || a[0] < n) && (n = a[0]), a && (i == null || a[1] > i) && (i = a[1]);
    }
  };
  return Array.isArray(e) ? e.forEach((s) => {
    var o;
    return (o = s.visit) == null ? void 0 : o.call(s, r);
  }) : e.visit && e.visit(r), n != null && i != null && n !== i ? [n, i] : void 0;
}
class Znt extends ha {
  constructor(t, n, i) {
    const r = t.endsWith("X") ? "y" : t.endsWith("Y") ? "x" : null, s = r ? { [r]: ["min", "max"] } : void 0;
    super(t, n, i, s), this.dim = r;
  }
  query(t = []) {
    var y;
    const { plot: n, dim: i, source: r } = this, { optimize: s = !0 } = r.options || {}, o = super.query(t);
    if (!i)
      return o;
    const a = i === "x" ? "y" : "x", c = (y = this.channelField(a, { exact: !0 })) == null ? void 0 : y.as, { field: l, as: u, type: f, min: h, max: d } = this.channelField(i);
    if (s && (f === "date" || f === "number") && c) {
      const g = i === "x" ? n.innerWidth() : n.innerHeight(), [m, b] = FN(t, l) || [h, d], [w] = Zs(this, i, g, [m, b], 1, u), v = o.select().map((_) => _.as).filter((_) => _ !== u && _ !== c);
      return Qnt(o, w, u, c, v);
    } else
      return o.orderby(l);
  }
}
function Qnt(e, t, n, i, r = []) {
  const s = q`FLOOR(${t})::INTEGER`, o = (a) => Et.from(e).select(a).groupby(s, r);
  return Et.union(
    o([{ [n]: $c(n), [i]: Dg(i, n) }, ...r]),
    o([{ [n]: Mc(n), [i]: Ng(i, n) }, ...r]),
    o([{ [n]: Dg(n, i), [i]: $c(i) }, ...r]),
    o([{ [n]: Ng(n, i), [i]: Mc(i) }, ...r])
  ).orderby(r, n);
}
function EN(e, t = "density") {
  var n;
  return Ub(e) ? iz(e.getChild(t).type) : typeof ((n = e[0]) == null ? void 0 : n[t]) == "number" ? Float64Array : Array;
}
function tit(e, t, n = "density") {
  const i = new (EN(t))(e);
  if (Ub(t)) {
    const r = t.numRows;
    if (r === 0)
      return i;
    const s = Hd(t.getChild("index")), o = Hd(t.getChild(n));
    for (let a = 0; a < r; ++a)
      i[s[a]] = o[a];
  } else
    for (const r of t)
      i[r.index] = r[n];
  return i;
}
function eit(e, t, n, i, r = [], s) {
  const o = e * t, a = i.map((m) => EN(n, m)), c = i.length, l = (m) => {
    const b = {};
    return r.forEach((w, v) => b[w] = m[v]), i.forEach((w, v) => b[w] = new a[v](o)), b;
  }, u = {}, f = r.length ? null : u[[]] = l([]), h = r.length ? (m) => u[m] ?? (u[m] = l(m)) : () => f, d = n.numRows;
  if (d === 0)
    return Object.values(u);
  const p = Hd(n.getChild("index")), y = i.map((m) => Hd(n.getChild(m))), g = r.map((m) => n.getChild(m));
  if (s) {
    const m = p.map((w) => w % e), b = p.map((w) => Math.floor(w / e));
    if (r.length)
      for (let w = 0; w < d; ++w) {
        const v = g.map((x) => x.get(w)), _ = h(v);
        _.index || (_.index = []), _.index.push(w);
      }
    else
      f.index = p.map((w, v) => v);
    Object.values(u).forEach((w) => {
      for (let v = 0; v < c; ++v)
        s(w.index, e, t, m, b, y[v], w[i[v]]);
      delete w.index;
    });
  } else
    for (let m = 0; m < d; ++m) {
      const b = g.map((v) => v.get(m)), w = h(b);
      for (let v = 0; v < c; ++v)
        w[i[v]][p[m]] = y[v][m];
    }
  return Object.values(u);
}
function Uv(e, t) {
  let n = 0, i = 0;
  return e.forEach((r) => {
    const s = r[t], o = s.length;
    for (let a = 0; a < o; ++a) {
      const c = s[a];
      c < n && (n = c), c > i && (i = c);
    }
  }), n === 0 && i === 0 ? [0, 1] : [n, i];
}
function nit(e, t) {
  const n = new tl();
  return e.forEach((i) => {
    const r = i[t], s = r.length;
    for (let o = 0; o < s; ++o)
      n.add(r[o]);
  }), Array.from(n).sort(me);
}
function Kn(e, t, n, i) {
  ks(n) ? (i = i || (() => e.requestUpdate()), n.addEventListener("value", (r) => (e[t] = r, i())), e[t] = n.value) : e[t] = n;
}
function X1(e, t = !1) {
  const n = new Float64Array(5), i = new Float64Array(4);
  iit(n, i, e);
  const r = Float64Array.of(
    0,
    i[1] - n[1] * i[0],
    i[2] - n[2] * i[0],
    i[3] - n[3] * i[0],
    -n[4] * i[0]
  ), s = 1 + n[1] + n[2] + n[3] + n[4], o = (i[0] + i[1] + i[2] + i[3]) / s, a = (r[1] + r[2] + r[3] + r[4]) / s;
  return {
    sigma: e,
    negative: t,
    a: n,
    b_causal: i,
    b_anticausal: r,
    sum_causal: o,
    sum_anticausal: a
  };
}
function iit(e, t, n) {
  const r = 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, l = 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)
  ), u = n * 2.5066282746310007, f = Float64Array.of(r[0], r[1], 0, 0, 0, 0, 0, 0), h = Float64Array.of(1, 0, l[0], l[1], 0, 0, 0, 0, 0, 0);
  let d, p;
  for (p = 2; p < 8; p += 2) {
    for (f[p] = l[p] * f[p - 2] - l[p + 1] * f[p - 1], f[p + 1] = l[p] * f[p - 1] + l[p + 1] * f[p - 2], d = p - 2; d > 0; d -= 2)
      f[d] += l[p] * f[d - 2] - l[p + 1] * f[d - 1], f[d + 1] += l[p] * f[d - 1] + l[p + 1] * f[d - 2];
    for (d = 0; d <= p; d += 2)
      f[d] += r[p] * h[d] - r[p + 1] * h[d + 1], f[d + 1] += r[p] * h[d + 1] + r[p + 1] * h[d];
    for (h[p + 2] = l[p] * h[p] - l[p + 1] * h[p + 1], h[p + 3] = l[p] * h[p + 1] + l[p + 1] * h[p], d = p; d > 0; d -= 2)
      h[d] += l[p] * h[d - 2] - l[p + 1] * h[d - 1], h[d + 1] += l[p] * h[d - 1] + l[p + 1] * h[d - 2];
  }
  for (p = 0; p < 4; ++p)
    d = p << 1, t[p] = f[d] / u, e[p + 1] = h[d + 2];
}
function rit(e, t, n, [i, r]) {
  const s = new Float64Array(Math.max(i, r)), o = new Float64Array(Math.max(i, r)), a = new Float64Array(5), c = new Float64Array(n.length);
  for (let l = 0, u = 0; l < r; ++l, u += i) {
    const f = c.subarray(u);
    H1(e, n.subarray(u), i, 1, s, o, a, f);
  }
  for (let l = 0; l < i; ++l) {
    const u = c.subarray(l);
    H1(t, u, r, i, s, o, a, u);
  }
  return c;
}
function H1(e, t, n, i = 1, r = new Float64Array(n), s = new Float64Array(n), o = new Float64Array(5), a = r, c = sit) {
  const l = i * 2, u = i * 3, f = i * 4, h = i * n;
  let d, p;
  for (c(
    r,
    t,
    n,
    i,
    e.b_causal,
    3,
    e.a,
    4,
    e.sum_causal,
    o,
    e.sigma
  ), p = 4, d = f; p < n; ++p, d += i)
    r[p] = e.b_causal[0] * t[d] + e.b_causal[1] * t[d - i] + e.b_causal[2] * t[d - l] + e.b_causal[3] * t[d - u] - e.a[1] * r[p - 1] - e.a[2] * r[p - 2] - e.a[3] * r[p - 3] - e.a[4] * r[p - 4];
  for (c(
    s,
    t,
    n,
    -i,
    e.b_anticausal,
    4,
    e.a,
    4,
    e.sum_anticausal,
    o,
    e.sigma
  ), p = 4, d = h - i * 5; p < n; ++p, d -= i)
    s[p] = e.b_anticausal[1] * t[d + i] + e.b_anticausal[2] * t[d + l] + e.b_anticausal[3] * t[d + u] + 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 += i)
      a[d] = r[p] + s[n - p - 1];
  else
    for (p = 0, d = 0; p < n; ++p, d += i)
      a[d] = Math.max(0, r[p] + s[n - p - 1]);
  return a;
}
function sit(e, t, n, i, r, s, o, a, c, l, u, f = 0.5) {
  const h = Math.abs(i) * n, d = i < 0 ? h + i : 0;
  let p, y, g;
  for (y = 0; y <= a; ++y)
    for (l[y] = y <= s ? r[y] : 0, g = 1; g <= a && g <= y; ++g)
      l[y] -= o[g] * l[y - g];
  for (g = 0; g < a; ++g)
    for (e[g] = 0, y = 1; y <= g; ++y)
      p = d + i * y, p >= 0 && p < h && (e[g] += l[g - y] * t[p]);
  const m = t[d], b = Math.ceil(u * 10);
  for (y = 0; y < b; ++y) {
    for (g = 0; g < a; ++g)
      e[g] += l[g] * m;
    if (c -= Math.abs(l[0]), c <= f)
      break;
    for (l[a] = y + a <= s ? r[y + a] : 0, g = 1; g <= a; ++g)
      l[a] -= o[g] * l[a - g];
    for (g = 0; g < a; ++g)
      l[g] = l[g + 1];
  }
}
function oit({ random: e = If(42) } = {}) {
  return (t, n, i, r, s, o, a) => {
    const { points: c, triangles: l, hull: u } = Ci.from(t, (d) => r[d], (d) => s[d]), f = new Uint8Array(n * i), h = pit(o, e);
    for (let d = 0; d < l.length; d += 3) {
      const p = l[d], y = l[d + 1], g = l[d + 2], m = c[2 * p], b = c[2 * y], w = c[2 * g], v = c[2 * p + 1], _ = c[2 * y + 1], x = c[2 * g + 1], I = Math.min(m, b, w), N = Math.max(m, b, w), A = Math.min(v, _, x), D = Math.max(v, _, x), M = (_ - x) * (m - w) + (v - x) * (w - b);
      if (!M)
        continue;
      const B = o[t[p]], R = o[t[y]], S = o[t[g]];
      for (let $ = Math.floor(I); $ < N; ++$)
        for (let T = Math.floor(A); T < D; ++T) {
          if ($ < 0 || $ >= n || T < 0 || T >= i)
            continue;
          const L = $ + 0.5, k = T + 0.5, U = ((_ - x) * (L - w) + (k - x) * (w - b)) / M;
          if (U < 0)
            continue;
          const C = ((x - v) * (L - w) + (k - x) * (m - w)) / M;
          if (C < 0)
            continue;
          const z = 1 - U - C;
          if (z < 0)
            continue;
          const P = $ + n * T;
          a[P] = h(B, U, R, C, S, z, $, T), f[P] = 1;
        }
    }
    return ait(a, f, r, s, o, n, i, u, t, h), a;
  };
}
function ait(e, t, n, i, r, s, o, a, c, l) {
  n = Float64Array.from(a, (d) => n[c[d]]), i = Float64Array.from(a, (d) => i[c[d]]), r = Array.from(a, (d) => r[c[d]]);
  const u = n.length, f = Array.from({ length: u }, (d, p) => lit(p, n, i));
  let h = 0;
  for (let d = 0; d < o; ++d) {
    const p = d + 0.5;
    for (let y = 0; y < s; ++y) {
      const g = y + s * d;
      if (!t[g]) {
        const m = y + 0.5;
        for (let b = 0; b < u; ++b) {
          const w = (u + h + (b % 2 ? (b + 1) / 2 : -b / 2)) % u;
          if (f[w](m, p)) {
            const v = cit(n.at(w - 1), i.at(w - 1), n[w], i[w], m, p);
            e[g] = l(r.at(w - 1), v, r[w], 1 - v, r[w], 0, y, d), h = w;
            break;
          }
        }
      }
    }
  }
}
function cit(e, t, n, i, r, s) {
  const o = n - e, a = i - t, c = o * (n - r) + a * (i - s), l = o * (r - e) + a * (s - t);
  return c > 0 && l > 0 ? c / (c + l) : +(c > l);
}
function Ol(e, t, n, i) {
  return e * i - n * t;
}
function lit(e, t, n) {
  const i = t.length, r = t.at(e - 2), s = n.at(e - 2), o = t.at(e - 1), a = n.at(e - 1), c = t[e], l = n[e], u = t.at(e + 1 - i), f = n.at(e + 1 - i), h = o - c, d = a - l, p = r - o, y = s - a, g = c - u, m = l - f, b = Math.hypot(h, d), w = Math.hypot(p, y), v = Math.hypot(g, m);
  return (_, x) => {
    const I = _ - o, N = x - a, A = _ - c, D = x - l;
    return Ol(I, N, A, D) > -1e-6 && Ol(I, N, h, d) * w - Ol(I, N, p, y) * b > -1e-6 && Ol(A, D, g, m) * b - Ol(A, D, h, d) * v <= 0;
  };
}
function uit(e, t, n, i, r, s, o) {
  const a = Ci.from(e, (u) => i[u], (u) => r[u]);
  let c, l;
  for (let u = 0.5, f = 0; u < n; ++u) {
    l = c;
    for (let h = 0.5; h < t; ++h, ++f)
      l = a.find(h, u, l), h === 0.5 && (c = l), o[f] = s[e[l]];
  }
  return o;
}
function fit({ random: e = If(42), minDistance: t = 0.5, maxSteps: n = 2 } = {}) {
  return (i, r, s, o, a, c, l) => {
    const u = Ci.from(i, (p) => o[p], (p) => a[p]);
    let f, h, d;
    for (let p = 0.5, y = 0; p < s; ++p) {
      h = f;
      for (let g = 0.5; g < r; ++g, ++y) {
        let m = g, b = p;
        d = h = u.find(m, b, h), g === 0.5 && (f = h);
        let w, v = 0;
        for (; (w = Math.hypot(o[i[d]] - m, a[i[d]] - b)) > t && v < n; ) {
          const _ = e(g, p, v) * 2 * Math.PI;
          m += Math.cos(_) * w, b += Math.sin(_) * w, d = u.find(m, b, d), ++v;
        }
        l[y] = c[i[d]];
      }
    }
    return l;
  };
}
function hit(e, t, n, i, r, s) {
  return t * e + i * n + s * r;
}
function dit(e) {
  return (t, n, i, r, s, o, a, c) => {
    const l = e(a, c);
    return l < n ? t : l < n + r ? i : s;
  };
}
function pit(e, t) {
  return yit(e) || mit(e) ? hit : dit(t);
}
function yit(e) {
  for (const t of e)
    if (t != null)
      return typeof t == "number";
}
function mit(e) {
  for (const t of e)
    if (t != null)
      return t instanceof Date;
}
const Os = "density";
class W0 extends ha {
  constructor(t, n, i) {
    const {
      bandwidth: r = 0,
      interpolate: s = "none",
      pixelSize: o = 1,
      pad: a = 1,
      width: c,
      height: l,
      ...u
    } = i, f = git(u);
    super(t, n, u, BN), this.densityMap = f, Kn(this, "bandwidth", r, () => this.grids ? this.convolve().update() : null), Kn(this, "pixelSize", o), Kn(this, "interpolate", s), Kn(this, "pad", a), Kn(this, "width", c), Kn(this, "height", l);
  }
  setPlot(t, n) {
    const i = () => {
      this.hasFieldInfo() && this.requestUpdate();
    };
    return t.addAttributeListener("domainX", i), t.addAttributeListener("domainY", i), super.setPlot(t, n);
  }
  get filterIndexable() {
    const t = this.plot.getAttribute("xDomain"), n = this.plot.getAttribute("yDomain");
    return t && n && !t[Mi] && !n[Mi];
  }
  query(t = []) {
    const { interpolate: n, pad: i, channels: r, densityMap: s, source: o } = this, [a, c] = this.extentX = Hf(this, t), [l, u] = this.extentY = Jf(this, t), [f, h] = this.bins = this.binDimensions(this), [d, p] = Zs(this, "x", f, [a, c], i), [y, g] = Zs(this, "y", h, [l, u], i), m = i ? [Tn(p, [+a, +c]), Tn(g, [+l, +u])] : [Nu(+a, p), Du(p, +c), Nu(+l, g), Du(g, +u)], b = Et.from(o.table).where(t.concat(m)), w = this.groupby = [], v = {};
    for (const x of r)
      if (Object.hasOwn(x, "field")) {
        const { as: I, channel: N, field: A } = x;
        A.aggregate ? (v[N] = A, s[N] = !0) : N === "weight" ? v[Os] = oa(A) : N !== "x" && N !== "y" && (b.select({ [I]: A }), w.push(I));
      }
    const _ = this.aggr = Object.keys(v);
    if (v.density && _.length > 1)
      throw new Error("Weight option can not be used with custom aggregates.");
    if (_.length || (_.push(Os), v.density = ko()), n === "linear") {
      if (_.length > 1)
        throw new Error("Linear binning not applicable to multiple aggregates.");
      if (!v.density)
        throw new Error("Linear binning not applicable to custom aggregates.");
      return vit(b, d, y, v[Os], f, w);
    } else
      return wit(b, d, y, v, f, w);
  }
  binDimensions() {
    const { plot: t, pixelSize: n, width: i, height: r } = this;
    return [
      i ?? Math.round(t.innerWidth() / n),
      r ?? Math.round(t.innerHeight() / n)
    ];
  }
  queryResult(t) {
    const [n, i] = this.bins, r = bit(this.interpolate);
    return this.grids = eit(n, i, t, this.aggr, this.groupby, r), this.convolve();
  }
  convolve() {
    const { aggr: t, bandwidth: n, bins: i, grids: r, plot: s } = this;
    if (this.kde = this.grids, n > 0) {
      const o = t.length === 1 ? t[0] : t.includes(Os) ? Os : null;
      if (!o)
        return console.warn("No compatible grid found for smoothing."), this;
      const a = s.innerWidth(), c = s.innerHeight(), [l, u] = i, f = r.some((p) => p[o].some((y) => y < 0)), h = X1(n * (l - 1) / a, f), d = X1(n * (u - 1) / c, f);
      this.kde = this.grids.map((p) => {
        const y = rit(h, d, p[o], i);
        return { ...p, [o]: y };
      });
    }
    return this;
  }
  plotSpecs() {
    throw new Error("Unimplemented. Use a Grid2D mark subclass.");
  }
}
function git(e) {
  const t = {};
  for (const n in e)
    e[n] === "density" && (delete e[n], t[n] = !0);
  return t;
}
function bit(e = "none") {
  if (typeof e == "function")
    return e;
  switch (`${e}`.toLowerCase()) {
    case "none":
    case "linear":
      return;
    case "nearest":
      return uit;
    case "barycentric":
      return oit();
    case "random-walk":
      return fit();
  }
  throw new Error(`invalid interpolate: ${e}`);
}
function wit(e, t, n, i, r, s) {
  return e.select({
    index: q`FLOOR(${t})::INTEGER + FLOOR(${n})::INTEGER * ${r}`,
    ...i
  }).groupby("index", s);
}
function vit(e, t, n, i, r, s) {
  const o = i != null && i.column ? `* ${i.column}` : "", a = (h, d) => e.clone().select({ xp: t, yp: n, i: h, w: d }), c = a(
    q`FLOOR(xp)::INTEGER + FLOOR(yp)::INTEGER * ${r}`,
    q`(FLOOR(xp)::INTEGER + 1 - xp) * (FLOOR(yp)::INTEGER + 1 - yp)${o}`
  ), l = a(
    q`FLOOR(xp)::INTEGER + (FLOOR(yp)::INTEGER + 1) * ${r}`,
    q`(FLOOR(xp)::INTEGER + 1 - xp) * (yp - FLOOR(yp)::INTEGER)${o}`
  ), u = a(
    q`FLOOR(xp)::INTEGER + 1 + FLOOR(yp)::INTEGER * ${r}`,
    q`(xp - FLOOR(xp)::INTEGER) * (FLOOR(yp)::INTEGER + 1 - yp)${o}`
  ), f = a(
    q`FLOOR(xp)::INTEGER + 1 + (FLOOR(yp)::INTEGER + 1) * ${r}`,
    q`(xp - FLOOR(xp)::INTEGER) * (yp - FLOOR(yp)::INTEGER)${o}`
  );
  return Et.from(Et.unionAll(c, l, u, f)).select({ index: "i", density: oa("w") }, s).groupby("index", s).having(Eb("density", 0));
}
class _it extends W0 {
  constructor(t, n) {
    const { thresholds: i = 10, ...r } = n;
    super("geo", t, {
      bandwidth: 20,
      interpolate: "linear",
      pixelSize: 2,
      ...r
    }), Kn(this, "thresholds", i, () => this.grids ? this.contours().update() : null);
  }
  convolve() {
    return super.convolve().contours();
  }
  contours() {
    const { bins: t, densityMap: n, kde: i, thresholds: r, plot: s } = this;
    let o = r;
    if (!Array.isArray(o)) {
      const [, v] = Uv(i, "density");
      o = Array.from({ length: o - 1 }, (_, x) => v * (x + 1) / o);
    }
    (n.fill || n.stroke) && this.plot.getAttribute("colorScale") !== "log" && this.plot.setAttribute("colorZero", !0);
    const [a, c] = t, [l, u] = s.getAttribute("xDomain"), [f, h] = s.getAttribute("yDomain"), d = (u - l) / a, p = (h - f) / c, y = +l, g = +f, m = (v) => y + v * d, b = (v) => g + v * p, w = sp().size(t);
    return this.data = i.flatMap((v) => o.map((_) => Object.assign(
      xit(w.contour(v.density, _), m, b),
      { ...v, density: _ }
    ))), this;
  }
  plotSpecs() {
    const { type: t, channels: n, densityMap: i, data: r } = this, s = {};
    for (const o of n) {
      const { channel: a } = o;
      a !== "x" && a !== "y" && (s[a] = Rs(o));
    }
    return i.fill && (s.fill = "density"), i.stroke && (s.stroke = "density"), [{ type: t, data: r, options: s }];
  }
}
function xit(e, t, n) {
  function i(o) {
    o.forEach(r);
  }
  function r(o) {
    o.forEach(s);
  }
  function s(o) {
    o[0] = t(o[0]), o[1] = n(o[1]);
  }
  return e.coordinates.forEach(i), e;
}
function LN(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 Sit(e = 1) {
  const t = 255 * e | 0;
  return (n, i, r) => {
    for (let s = 0, o = 0; s < r; ++s)
      for (let a = 0; a < i; ++a, o += 4)
        n[o + 3] = t;
  };
}
function Iit(e) {
  const { apply: t } = e;
  return (n, i, r, s) => {
    for (let o = 0, a = 0; o < r; ++o)
      for (let c = 0, l = (r - o - 1) * i; c < i; ++c, a += 4)
        n[a + 3] = 255 * t(s[c + l]) | 0;
  };
}
function Ait(e = {}) {
  const { r: t = 0, g: n = 0, b: i = 0, opacity: r = 1 } = typeof e == "string" ? Pn(e) : e, s = new Uint8ClampedArray([t, n, i, 255 * r | 0]);
  return (o, a, c) => {
    for (let l = 0, u = 0; l < c; ++l)
      for (let f = 0; f < a; ++f, u += 4)
        o[u + 0] = s[0], o[u + 1] = s[1], o[u + 2] = s[2], o[u + 3] = s[3];
  };
}
function Mit(e) {
  const { domain: t, range: n } = e, i = /* @__PURE__ */ Object.create(null), r = 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: l, g: u, b: f, opacity: h = 1 } = typeof c == "string" ? Pn(c) : c, d = a << 2;
    r[d + 0] = l, r[d + 1] = u, r[d + 2] = f, r[d + 3] = 255 * h | 0, i[t[a]] = d;
  }
  return (a, c, l, u) => {
    if (u.map)
      for (let f = 0, h = 0; f < l; ++f)
        for (let d = 0, p = (l - f - 1) * c; d < c; ++d, h += 4) {
          const y = i[u[d + p]];
          a[h + 0] = r[y + 0], a[h + 1] = r[y + 1], a[h + 2] = r[y + 2], a[h + 3] = r[y + 3];
        }
    else {
      const f = i[u];
      for (let h = 0, d = 0; h < l; ++h)
        for (let p = 0; p < c; ++p, d += 4)
          a[d + 0] = r[f + 0], a[d + 1] = r[f + 1], a[d + 2] = r[f + 2], a[d + 3] = r[f + 3];
    }
  };
}
function $it(e, t, n) {
  const { interpolate: i } = t, r = new Uint8ClampedArray(4 * e), s = e - 1;
  for (let o = 0; o <= s; ++o) {
    const a = i(o / s), { r: c, g: l, b: u, opacity: f = 1 } = typeof a == "string" ? Pn(a) : a, h = o << 2;
    r[h + 0] = c, r[h + 1] = l, r[h + 2] = u, r[h + 3] = 255 * f | 0;
  }
  return (o, a, c, l) => {
    for (let u = 0, f = 0; u < c; ++u)
      for (let h = 0, d = (c - u - 1) * a; h < a; ++h, f += 4) {
        const p = s * n(l[h + d]) << 2;
        o[f + 0] = r[p + 0], o[f + 1] = r[p + 1], o[f + 2] = r[p + 2], o[f + 3] = r[p + 3];
      }
  };
}
class zv extends W0 {
  constructor(t, n) {
    super("image", t, n);
  }
  setPlot(t, n) {
    const i = () => {
      this.hasFieldInfo() && this.rasterize();
    };
    t.addAttributeListener("schemeColor", i), super.setPlot(t, n);
  }
  convolve() {
    return super.convolve().rasterize();
  }
  rasterize() {
    const { bins: t, kde: n } = this, [i, r] = t, { canvas: s, ctx: o, img: a } = Oit(this, i, r), { alpha: c, alphaProp: l, color: u, colorProp: f } = RN(this);
    return this.data = n.map((h) => (u == null || u(a.data, i, r, h[f]), c == null || c(a.data, i, r, h[l]), o.putImageData(a, 0, 0), { src: s.toDataURL() })), this;
  }
  plotSpecs() {
    var s;
    const { type: t, plot: n, data: i } = this, r = {
      src: "src",
      width: n.innerWidth(),
      height: n.innerHeight(),
      preserveAspectRatio: "none",
      imageRendering: (s = this.channel("imageRendering")) == null ? void 0 : s.value,
      frameAnchor: "middle"
    };
    return [{ type: t, data: i, options: r }];
  }
}
class Tit extends zv {
  constructor(t, n) {
    super(t, {
      bandwidth: 20,
      interpolate: "linear",
      pixelSize: 2,
      ...n
    });
  }
}
function RN(e) {
  const { aggr: t, densityMap: n, groupby: i, plot: r } = e, s = t.includes(Os), 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 (i.includes(c == null ? void 0 : c.as))
    throw new Error("Raster fillOpacity must be an aggregate or constant.");
  const l = n.fill || t.includes("fill") ? "grid" : i.includes(a == null ? void 0 : a.as) ? "group" : AN(a == null ? void 0 : a.value) ? a.value : s && r.getAttribute("colorScheme") ? "grid" : void 0, u = n.fillOpacity || t.includes("fillOpacity") ? "grid" : typeof (c == null ? void 0 : c.value) == "number" ? c.value : s && l !== "grid" ? "grid" : void 0;
  if (l !== "grid" && u !== "grid")
    throw new Error("Raster mark missing density values.");
  const f = (a == null ? void 0 : a.as) ?? (l === "grid" ? Os : null), h = (c == null ? void 0 : c.as) ?? (u === "grid" ? Os : null), d = l !== "grid" && l !== "group" ? Ait(l) : Nit(e, f), p = u !== "grid" ? Sit(u) : Dit(e, h);
  return { alphaProp: h, colorProp: f, alpha: p, color: d };
}
function Dit(e, t) {
  const { plot: n, kde: i } = e, r = n.getAttribute("opacityDomain"), s = r === gf, o = r == null ? void 0 : r[Mi], a = !s && !o && r || Uv(i, t);
  (s || o) && (o && (a[Mi] = !0), n.setAttribute("colorDomain", a));
  const c = qp({
    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 Iit(c);
}
function Nit(e, t) {
  var f;
  const { plot: n, kde: i } = e, r = !((f = i[0][t]) != null && f.map), s = r || Array.isArray(i[0][t]), o = n.getAttribute("colorDomain"), a = o === gf, c = o == null ? void 0 : o[Mi], l = !a && !c && o || (r ? i.map((h) => h[t]).sort(me) : s ? nit(i, t) : Uv(i, t));
  (a || c) && (c && (l[Mi] = !0), n.setAttribute("colorDomain", l));
  const u = qp({
    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 (s)
    return Mit(u);
  {
    const h = qp({
      x: {
        type: Bit(u.type),
        domain: u.domain,
        reverse: u.reverse,
        range: [0, 1],
        clamp: u.clamp,
        base: u.base,
        exponent: u.exponent,
        constant: u.constant
      }
    });
    return $it(1024, u, h.apply);
  }
}
function Bit(e) {
  return e.endsWith("symlog") ? "symlog" : e.endsWith("log") ? "log" : e.endsWith("pow") ? "pow" : e.endsWith("sqrt") ? "sqrt" : e === "diverging" ? "linear" : e;
}
function Oit(e, t, n) {
  if (!e.image || e.image.w !== t || e.image.h !== n) {
    const i = LN(t, n), r = i.getContext("2d", { willReadFrequently: !0 }), s = r.getImageData(0, 0, t, n);
    e.image = { canvas: i, ctx: r, img: s, w: t, h: n };
  }
  return e.image;
}
class Fit extends zv {
  constructor(t, n) {
    const { normalize: i = !0, ...r } = n;
    super(t, r), Kn(this, "normalize", i);
  }
  query(t = []) {
    const { channels: n, normalize: i, source: r, binPad: s } = this, [o, a] = this.bins = this.binDimensions(this), [c] = Zs(this, "x", o, Hf(this, t), s), [l] = Zs(this, "y", a, Jf(this, t), s), u = Et.from(r.table).where(Eit(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" ? (u.select({ [p]: y }), h.push("z")) : p !== "x" && p !== "y" && (u.select({ [p]: y }), f.push(p));
      }
    return Lit(u, c, l, h, o, a, f, i);
  }
}
function Eit(e, t) {
  if (Array.isArray(t) && !t.length)
    return t;
  const { column: n } = e.channelField("x"), { column: i } = e.channelField("y"), r = (o) => {
    const a = `${o.field}`;
    return o.op !== "BETWEEN" || a !== n && a !== i;
  }, s = (o) => o.op === "AND" ? js(o.children.filter((a) => r(a))) : o;
  return Array.isArray(t) ? t.filter((o) => r(o)).map((o) => s(o)) : s(t);
}
function Lit(e, t, n, i, r, s, o = [], a = !0) {
  e.select({
    x: q`FLOOR(${t})::INTEGER`,
    y: q`FLOOR(${n})::INTEGER`
  });
  const c = o.concat(i), l = c.length ? `PARTITION BY ${c.join(", ")} ` : "", u = Et.from(e).select(c, {
    x0: "x",
    y0: "y",
    dx: q`(lead(x) OVER sw - x)`,
    dy: q`(lead(y) OVER sw - y)`
  }).window({ sw: q`${l}ORDER BY x ASC` }).qualify(js(
    q`(x0 < ${r} OR x0 + dx < ${r})`,
    q`(y0 < ${s} OR y0 + dy < ${s})`,
    q`(x0 > 0 OR x0 + dx > 0)`,
    q`(y0 > 0 OR y0 + dy > 0)`
  )), f = Et.select({ x: q`GREATEST(MAX(ABS(dx)), MAX(ABS(dy)))` }).from("pairs"), h = Et.select({ i: q`UNNEST(range((${f})))::INTEGER` }), d = Et.unionAll(
    Et.select(c, {
      x: q`x0 + i`,
      y: q`y0 + ROUND(i * dy / dx::FLOAT)::INTEGER`
    }).from("pairs", "indices").where(q`ABS(dy) <= ABS(dx) AND i < ABS(dx)`),
    Et.select(c, {
      x: q`x0 + ROUND(SIGN(dy) * i * dx / dy::FLOAT)::INTEGER`,
      y: q`y0 + SIGN(dy) * i`
    }).from("pairs", "indices").where(q`ABS(dy) > ABS(dx) AND i < ABS(dy)`),
    Et.select(c, { x: "x0", y: "y0" }).from("pairs").where(Fb("dx"))
  ), p = ["x"].concat(c).join(", "), y = Et.from("raster").select(
    c,
    "x",
    "y",
    a ? { w: q`1.0 / COUNT(*) OVER (PARTITION BY ${p})` } : null
  ).where(js(Tn("x", [0, r], !0), Tn("y", [0, s], !0)));
  return Et.with({ pairs: u, indices: h, raster: d, points: y }).from("points").select(o, {
    index: q`x + y * ${r}::INTEGER`,
    density: a ? oa("w") : ko()
  }).groupby("index", o);
}
class CN extends ha {
  constructor(t, n, i) {
    const { bins: r = 1024, bandwidth: s = 20, ...o } = i, a = t.endsWith("X") ? "y" : "x";
    super(t, n, o, a === "x" ? DN : NN), this.dim = a, Kn(this, "bins", r), Kn(this, "bandwidth", s, () => this.grid ? this.convolve().update() : null);
  }
  get filterIndexable() {
    const t = this.dim === "x" ? "xDomain" : "yDomain", n = this.plot.getAttribute(t);
    return n && !n[Mi];
  }
  query(t = []) {
    if (this.hasOwnData())
      throw new Error("Density1DMark requires a data source");
    const { bins: n, channels: i, dim: r, source: { table: s } } = this, o = this.extent = (r === "x" ? Hf : Jf)(this, t), [a, c] = Zs(this, r, n, o), l = TN(i, s, [r]).where(t.concat(Tn(c, o))), u = this.channelField("weight") ? "weight" : null;
    return Rit(l, a, u);
  }
  queryResult(t) {
    return this.grid = tit(this.bins, t), this.convolve();
  }
  convolve() {
    const { bins: t, bandwidth: n, dim: i, grid: r, plot: s, extent: [o, a] } = this, c = r.some((b) => b < 0), l = i === "x" ? s.innerWidth() : s.innerHeight(), u = X1(n * (t - 1) / l, c), f = H1(u, r, t), h = this.data = [], d = i === "x" ? "y" : "x", p = this.channelField(i).as, y = +o, g = (a - y) / (t - 1), m = 1 / g;
    for (let b = 0; b < t; ++b)
      h.push({
        [p]: y + b * g,
        [d]: f[b] * m
      });
    return this;
  }
  plotSpecs() {
    const { type: t, data: n, channels: i, dim: r } = this, s = r === "x" ? { y: "y" } : { x: "x" };
    for (const o of i)
      s[o.channel] = Rs(o);
    return [{ type: t, data: n, options: s }];
  }
}
function Rit(e, t, n) {
  const i = n ? `* ${n}` : "", r = e.clone().select({
    p: t,
    i: q`FLOOR(p)::INTEGER`,
    w: q`(FLOOR(p) + 1 - p)${i}`
  }), s = e.clone().select({
    p: t,
    i: q`FLOOR(p)::INTEGER + 1`,
    w: q`(p - FLOOR(p))${i}`
  });
  return Et.from(Et.unionAll(r, s)).select({ index: "i", density: oa("w") }).groupby("index").having(jM("density", 0));
}
class Cit extends W0 {
  constructor(t, n) {
    const { type: i = "dot", ...r } = n;
    super(i, t, {
      bandwidth: 20,
      interpolate: "linear",
      pad: 0,
      pixelSize: 2,
      ...r
    });
  }
  convolve() {
    super.convolve();
    const { bins: t, pad: n, extentX: i, extentY: r } = this, [s, o] = t, a = iy(this, "x"), c = iy(this, "y"), [l, u] = i.map((g) => a.apply(g)), [f, h] = r.map((g) => c.apply(g)), d = (u - l) / (s - n), p = (h - f) / (o - n), y = n ? 0 : 0.5;
    return this.data = kit(
      this.kde,
      t,
      l,
      f,
      d,
      p,
      a.invert,
      c.invert,
      y
    ), this;
  }
  plotSpecs() {
    const { type: t, channels: n, densityMap: i, data: r } = this, s = {};
    for (const o of n) {
      const { channel: a } = o;
      s[a] = a === "x" || a === "y" ? a : Rs(o);
    }
    for (const o in i)
      i[o] && (s[o] = "density");
    return [{ type: t, data: r, options: s }];
  }
}
function kit(e, t, n, i, r, s, o, a, c) {
  const l = 1 / (r * s), [u, f] = t, h = [];
  for (const d of e) {
    const p = d.density;
    for (let y = 0, g = 0; g < f; ++g)
      for (let m = 0; m < u; ++m, ++y)
        h.push({
          ...d,
          x: o(n + (m + c) * r),
          y: a(i + (g + c) * s),
          density: p[y] * l
        });
  }
  return h;
}
const Uit = "geom";
class zit extends ha {
  constructor(t, n = {}, i) {
    !G1(t) && !(n != null && n.geometry) && (n.geometry = WM(Uit)), super("geo", t, n, i);
  }
  queryResult(t) {
    var i;
    super.queryResult(t);
    const n = (i = this.channelField("geometry")) == null ? void 0 : i.as;
    return n && this.data && this.data.forEach((r) => {
      typeof r[n] == "string" && (r[n] = JSON.parse(r[n]));
    }), this;
  }
}
class Pit extends ha {
  constructor(t, n) {
    const { type: i = "hexagon", binWidth: r = 20, ...s } = n;
    super(i, t, { r: r / 2, clip: !0, ...s }, BN), this.binWidth = r;
  }
  get filterIndexable() {
    const t = this.plot.getAttribute("xDomain"), n = this.plot.getAttribute("yDomain");
    return t && n && !t[Mi] && !n[Mi];
  }
  query(t = []) {
    if (this.hasOwnData())
      return null;
    const { plot: n, binWidth: i, channels: r, source: s } = this, [o, a] = Hf(this, t), [c, l] = Jf(this, t), u = 0.5 - n.getAttribute("marginLeft"), f = 0 - n.getAttribute("marginTop"), h = `${i}::DOUBLE`, d = `${i * (1.5 / Math.sqrt(3))}::DOUBLE`, p = `${n.innerWidth() / (a - o)}::DOUBLE`, y = `${n.innerHeight() / (l - c)}::DOUBLE`;
    let g, m;
    const b = /* @__PURE__ */ new Set(), w = {};
    for (const N of r)
      N.channel === "orderby" ? v.orderby(N.value) : N.channel === "x" ? g = N : N.channel === "y" ? m = N : Object.hasOwn(N, "field") && (w[N.as] = N.field, N.field.aggregate && N.field.columns.forEach((A) => b.add(A)));
    const v = Et.select({
      [g.as]: q`${o}::DOUBLE + ((x + 0.5 * (y & 1)) * ${h} + ${u})::DOUBLE / ${p}`,
      [m.as]: q`${l}::DOUBLE - (y * ${d} + ${f})::DOUBLE / ${y}`,
      ...w
    }).groupby("x", "y"), _ = `${p} * (${g.field} - ${o}::DOUBLE)`, x = `${y} * (${l}::DOUBLE - ${m.field})`, I = Et.select({
      py: q`(${x} - ${f}) / ${d}`,
      pj: q`ROUND(py)::INTEGER`,
      px: q`(${_} - ${u}) / ${h} - 0.5 * (pj & 1)`,
      pi: q`ROUND(px)::INTEGER`,
      tt: q`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: q`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: q`CASE WHEN tt THEN (pj + CASE WHEN py < pj THEN -1 ELSE 1 END)::INTEGER ELSE pj END`
    }).select(Array.from(b)).from(s.table).where(Tu(g.field), Tu(m.field), t);
    return v.from(I);
  }
}
class Vit extends W0 {
  constructor(t, n) {
    const { origin: i = [0, 0], dim: r = "xy", ...s } = n;
    super("image", t, s), this.origin = i, this.tileX = r.toLowerCase().includes("x"), this.tileY = r.toLowerCase().includes("y");
  }
  setPlot(t, n) {
    const i = () => {
      this.hasFieldInfo() && this.rasterize();
    };
    t.addAttributeListener("schemeColor", i), super.setPlot(t, n);
  }
  requestQuery() {
    return this.requestTiles();
  }
  query(t = []) {
    return this._filter = t, null;
  }
  tileQuery(t) {
    const { binType: n, binPad: i, channels: r, densityMap: s, source: o } = this, [[a, c], [l, u]] = t, [f, h] = this.bins, [d, p] = Zs(this, "x", f, [a, c], i), [y, g] = Zs(this, "y", h, [l, u], i), m = i ? [Tn(p, [+a, +c]), Tn(g, [+l, +u])] : [Nu(+a, p), Du(p, +c), Nu(+l, g), Du(g, +u)], b = Et.from(o.table).where(m), w = this.groupby = [], v = {};
    for (const x of r)
      if (Object.hasOwn(x, "field")) {
        const { as: I, channel: N, field: A } = x;
        A.aggregate ? (v[N] = A, s[N] = !0) : N === "weight" ? v.density = oa(A) : N !== "x" && N !== "y" && (b.select({ [I]: A }), w.push(I));
      }
    const _ = this.aggr = Object.keys(v);
    if (v.density && _.length > 1)
      throw new Error("Weight option can not be used with custom aggregates.");
    if (_.length || (_.push("density"), v.density = ko()), n === "linear") {
      if (_.length > 1)
        throw new Error("Linear binning not applicable to multiple aggregates.");
      if (!v.density)
        throw new Error("Linear binning not applicable to custom aggregates.");
      return Git(b, d, y, v.density, f, w);
    } else
      return Wit(b, d, y, v, f, w);
  }
  async requestTiles() {
    const t = Yr();
    this.prefetch && t.cancel(this.prefetch);
    const { binPad: n, tileX: i, tileY: r, origin: [s, o] } = this, [a, c] = this.bins = this.binDimensions(this), [l, u] = Hf(this, this._filter), [f, h] = Jf(this, this._filter), d = u - l, p = h - f, y = Math.floor((l - s) * (a - n) / d), g = Math.floor((f - o) * (c - n) / p), m = (D, M) => [
      [s + D * d, s + (D + 1) * d],
      [o + M * p, o + (M + 1) * p]
    ], b = Math.floor((l - s) / d), w = i ? JS((u - s) / d) : b, v = Math.floor((f - o) / p), _ = r ? JS((h - o) / p) : v, x = [];
    for (let D = b; D <= w; ++D)
      for (let M = v; M <= _; ++M)
        x.push([D, M]);
    const I = x.map(
      ([D, M]) => t.query(this.tileQuery(m(D, M)))
    ), N = [];
    if (i)
      for (let D = v; D <= _; ++D)
        N.push([w + 1, D]), N.push([b - 1, D]);
    if (r) {
      const D = i ? b - 1 : b, M = i ? w + 1 : w;
      for (let B = D; B <= M; ++B)
        N.push([B, _ + 1]), N.push([B, v - 1]);
    }
    this.prefetch = N.map(
      ([D, M]) => t.prefetch(this.tileQuery(m(D, M)))
    );
    const A = await Promise.all(I);
    this.grids = [{ density: jit(a, c, y, g, x, A) }], this.convolve().update();
  }
  convolve() {
    return super.convolve().rasterize();
  }
  rasterize() {
    const { bins: t, kde: n } = this, [i, r] = t, { canvas: s, ctx: o, img: a } = Yit(this, i, r), { alpha: c, alphaProp: l, color: u, colorProp: f } = RN(this);
    return this.data = n.map((h) => (u == null || u(a.data, i, r, h[f]), c == null || c(a.data, i, r, h[l]), o.putImageData(a, 0, 0), { src: s.toDataURL() })), this;
  }
  plotSpecs() {
    var s;
    const { type: t, data: n, plot: i } = this, r = {
      src: "src",
      width: i.innerWidth(),
      height: i.innerHeight(),
      preserveAspectRatio: "none",
      imageRendering: (s = this.channel("imageRendering")) == null ? void 0 : s.value,
      frameAnchor: "middle"
    };
    return [{ type: t, data: n, options: r }];
  }
}
function jit(e, t, n, i, r, s) {
  const o = new Float64Array(e * t);
  return s.forEach((a, c) => {
    const [l, u] = r[c], f = l * e - n, h = u * t - i;
    qit(e, t, o, a, f, h);
  }), o;
}
function qit(e, t, n, i, r, s) {
  const o = i.numRows;
  if (o === 0)
    return;
  const a = i.getChild("index").toArray(), c = i.getChild("density").toArray();
  for (let l = 0; l < o; ++l) {
    const u = a[l], f = r + u % e, h = s + Math.floor(u / e);
    0 <= f && f < e && 0 <= h && h < t && (n[f + h * e] = c[l]);
  }
}
function Yit(e, t, n) {
  if (!e.image || e.image.w !== t || e.image.h !== n) {
    const i = LN(t, n), r = i.getContext("2d", { willReadFrequently: !0 }), s = r.getImageData(0, 0, t, n);
    e.image = { canvas: i, ctx: r, img: s, w: t, h: n };
  }
  return e.image;
}
function Wit(e, t, n, i, r, s) {
  return e.select({
    index: q`FLOOR(${t})::INTEGER + FLOOR(${n})::INTEGER * ${r}`,
    ...i
  }).groupby("index", s);
}
function Git(e, t, n, i, r, s) {
  const o = i.column ? `* ${i.column}` : "", a = (h, d) => e.clone().select({ xp: t, yp: n, i: h, w: d }), c = a(
    q`FLOOR(xp)::INTEGER + FLOOR(yp)::INTEGER * ${r}`,
    q`(FLOOR(xp)::INTEGER + 1 - xp) * (FLOOR(yp)::INTEGER + 1 - yp)${o}`
  ), l = a(
    q`FLOOR(xp)::INTEGER + (FLOOR(yp)::INTEGER + 1) * ${r}`,
    q`(FLOOR(xp)::INTEGER + 1 - xp) * (yp - FLOOR(yp)::INTEGER)${o}`
  ), u = a(
    q`FLOOR(xp)::INTEGER + 1 + FLOOR(yp)::INTEGER * ${r}`,
    q`(xp - FLOOR(xp)::INTEGER) * (FLOOR(yp)::INTEGER + 1 - yp)${o}`
  ), f = a(
    q`FLOOR(xp)::INTEGER + 1 + (FLOOR(yp)::INTEGER + 1) * ${r}`,
    q`(xp - FLOOR(xp)::INTEGER) * (yp - FLOOR(yp)::INTEGER)${o}`
  );
  return Et.from(Et.unionAll(c, l, u, f)).select({ index: "i", density: oa("w") }, s).groupby("index", s).having(Eb("density", 0));
}
function JS(e) {
  const t = Math.floor(e);
  return t === e ? t - 1 : t;
}
function Xit(e, t, n) {
  var i = 1e-8, r = t - 1, s = n - 1, o = 0, a, c, l, u, f, h, d, p, y, g, m;
  if (e <= 0)
    return 0;
  if (e >= 1)
    return 1;
  for (t >= 1 && n >= 1 ? (l = e < 0.5 ? e : 1 - e, u = Math.sqrt(-2 * Math.log(l)), d = (2.30753 + u * 0.27061) / (1 + u * (0.99229 + u * 0.04481)) - u, e < 0.5 && (d = -d), p = (d * d - 3) / 6, y = 2 / (1 / (2 * t - 1) + 1 / (2 * n - 1)), g = 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 * g))) : (a = Math.log(t / (t + n)), c = Math.log(n / (t + n)), u = Math.exp(t * a) / t, f = Math.exp(n * c) / n, g = u + f, e < u / g ? d = Math.pow(t * g * e, 1 / t) : d = 1 - Math.pow(n * g * (1 - e), 1 / n)), m = -mc(t) - mc(n) + mc(t + n); o < 10; o++) {
    if (d === 0 || d === 1)
      return d;
    if (h = Hit(d, t, n) - e, u = Math.exp(r * Math.log(d) + s * Math.log(1 - d) + m), f = h / u, d -= u = f / (1 - 0.5 * Math.min(1, f * (r / d - s / (1 - d)))), d <= 0 && (d = 0.5 * (d + u)), d >= 1 && (d = 0.5 * (d + u + 1)), Math.abs(u) < i * d && o > 0)
      break;
  }
  return d;
}
function Hit(e, t, n) {
  var i = e === 0 || e === 1 ? 0 : Math.exp(mc(t + n) - mc(t) - mc(n) + t * Math.log(e) + n * Math.log(1 - e));
  return e < 0 || e > 1 ? !1 : e < (t + 1) / (t + n + 2) ? i * KS(e, t, n) / t : 1 - i * KS(1 - e, n, t) / n;
}
function KS(e, t, n) {
  var i = 1e-30, r = 1, s = t + n, o = t + 1, a = t - 1, c = 1, l = 1 - s * e / o, u, f, h, d;
  for (Math.abs(l) < i && (l = i), l = 1 / l, d = l; r <= 100 && (u = 2 * r, f = r * (n - r) * e / ((a + u) * (t + u)), l = 1 + f * l, Math.abs(l) < i && (l = i), c = 1 + f / c, Math.abs(c) < i && (c = i), l = 1 / l, d *= l * c, f = -(t + r) * (s + r) * e / ((t + u) * (o + u)), l = 1 + f * l, Math.abs(l) < i && (l = i), c = 1 + f / c, Math.abs(c) < i && (c = i), l = 1 / l, h = l * c, d *= h, !(Math.abs(h - 1) < 3e-7)); r++)
    ;
  return d;
}
function mc(e) {
  var t = 0, n = [
    76.18009172947146,
    -86.5053203294167,
    24.01409824083091,
    -1.231739572450155,
    0.001208650973866179,
    -5395239384953e-18
  ], i = 1.000000000190015, r, s, o;
  for (o = (s = r = e) + 5.5, o -= (r + 0.5) * Math.log(o); t < 6; t++)
    i += n[t] / ++s;
  return Math.log(2.506628274631 * i / r) - o;
}
function Jit(e, t) {
  var n = Xit(2 * Math.min(e, 1 - e), 0.5 * t, 0.5);
  return n = Math.sqrt(t * (1 - n) / n), e > 0.5 ? n : -n;
}
class Kit extends ha {
  constructor(t, n) {
    const { ci: i = 0.95, precision: r = 4, ...s } = n;
    super("line", t, s);
    const o = () => this.modelFit ? this.confidenceBand().update() : null;
    Kn(this, "ci", i, o), Kn(this, "precision", r, o);
  }
  query(t = []) {
    const n = this.channelField("x").as, i = this.channelField("y").as, r = Array.from(new Set(
      ["stroke", "z", "fx", "fy"].flatMap((s) => {
        var o;
        return ((o = this.channelField(s)) == null ? void 0 : o.as) || [];
      })
    ));
    return Et.from(super.query(t)).select({
      intercept: Q9(i, n),
      slope: tU(i, n),
      n: eU(i, n),
      ssy: nU(i, n),
      ssx: iU(i, n),
      xm: rU(i, n),
      x0: Bg($c(n).where(Tu(i))),
      x1: Bg(Mc(n).where(Tu(i)))
    }).select(r).groupby(r);
  }
  queryResult(t) {
    return this.modelFit = MN(t), this.lineData = this.modelFit.flatMap((n) => Zit(n)), this.confidenceBand();
  }
  confidenceBand() {
    const { ci: t, modelFit: n, precision: i, plot: r } = this, s = r.innerWidth();
    return this.areaData = t ? n.flatMap((o) => Qit(t, i, o, s)) : null, this;
  }
  plotSpecs() {
    const { lineData: t, areaData: n, channels: i, ci: r } = this, s = { x: "x", y: "y" }, o = { x: "x", y1: "y1", y2: "y2", fillOpacity: 0.1 };
    for (const a of i)
      switch (a.channel) {
        case "x":
        case "y":
        case "fill":
          break;
        case "stroke":
          s.stroke = o.fill = Rs(a);
          break;
        case "strokeOpacity":
          s.strokeOpacity = Rs(a);
          break;
        case "fillOpacity":
          o.fillOpacity = Rs(a);
          break;
        default:
          s[a.channel] = o[a.channel] = Rs(a);
          break;
      }
    return [
      ...r ? [{ type: "areaY", data: n, options: o }] : [],
      { type: "line", data: t, options: s }
    ];
  }
}
function Zit(e) {
  const { x0: t, x1: n, xm: i, intercept: r, slope: s, n: o, ssx: a, ssy: c, ...l } = e;
  return [
    { x: t, y: r + t * s, ...l },
    { x: n, y: r + n * s, ...l }
  ];
}
function Qit(e, t, n, i) {
  const { x0: r, x1: s, xm: o, intercept: a, slope: c, n: l, ssx: u, ssy: f, ...h } = n, d = t * (s - r) / i, p = Jit((1 - e) / 2, l - 2) * Math.sqrt(f / (l - 2));
  return Cn(r, s - d / 2, d).concat(s).map((y) => {
    const g = a + y * c, m = p * Math.sqrt(1 / l + (y - o) ** 2 / u);
    return { x: y, y1: g - m, y2: g + m, ...h };
  });
}
function trt(e) {
  const t = e.toLowerCase(), n = e.length;
  let i = "";
  for (let r = 0; r < n; ++r)
    i += (e[r] !== t[r] ? "-" : "") + t[r];
  return i;
}
function Pv(e) {
  const t = {};
  for (const n in e)
    t[trt(n)] = e[n];
  return t;
}
function ert(e) {
  const { channels: t } = e, n = /* @__PURE__ */ new Set();
  let i = !1, r = !1;
  for (const s of t) {
    const { channel: o, field: a, as: c } = s;
    if (o === "orderby")
      i = !0;
    else if (a)
      if (a.aggregate)
        r = !0;
      else {
        if (n.has(c))
          continue;
        n.add(c);
      }
  }
  return !i && r && n.size && e.channels.push({ channel: "orderby", value: Array.from(n) }), e;
}
class nrt {
  constructor(t, {
    selection: n,
    channels: i = {}
  }) {
    this.mark = ert(t), this.selection = n;
    const r = Object.entries(Pv(i));
    this.channels = r.length ? r : [["opacity", 0.2]], this.selection.addEventListener("value", OI(() => this.update()));
  }
  init(t) {
    this.svg = t;
    const n = this.values = [], i = this.mark.index, r = this.nodes = t.querySelectorAll(`[data-index="${i}"] > *`), { channels: s } = this;
    for (let o = 0; o < r.length; ++o) {
      const a = r[o];
      n.push(s.map((c) => a.getAttribute(c[0])));
    }
    return this.update();
  }
  async update() {
    const { svg: t, nodes: n, channels: i, values: r, mark: s, selection: o } = this;
    if (!t)
      return;
    const a = await irt(s, o);
    for (let c = 0; c < n.length; ++c) {
      const l = n[c], u = r[c], f = a(l.__data__);
      for (let h = 0; h < i.length; ++h) {
        const [d, p] = i[h];
        l.setAttribute(d, f ? u[h] : p);
      }
    }
  }
}
async function irt(e, t) {
  var l, u;
  const n = t == null ? void 0 : t.predicate(e);
  if (!n || n.length === 0)
    return () => !0;
  const i = (l = e.filterBy) == null ? void 0 : l.predicate(e, !0), r = { __: js(n) }, s = e.query(i), o = s.groupby().length ? s.select(r) : s.$select(r), a = await e.coordinator.query(o), c = (u = a.getChild) == null ? void 0 : u.call(a, "__");
  return a.numRows || a.length ? c ? (f) => c.get(f) : (f) => a[f].__ : () => !1;
}
function Vv(e) {
  const t = e.on;
  let n = !0;
  function i(r) {
    n = !1, r(), n = !0;
  }
  return e.reset = (...r) => {
    i(() => e.clear(...r));
  }, e.moveSilent = (...r) => {
    i(() => e.move(...r));
  }, e.on = (...r) => {
    if (r.length > 1 && r[1]) {
      const s = r[1];
      r[1] = (...o) => n && s(...o);
    }
    return t(...r);
  }, e;
}
function rrt() {
  return Vv(Vq());
}
function srt() {
  return Vv(zq());
}
function ort() {
  return Vv(Pq());
}
const ZS = 1e-12;
function J1(e, t) {
  return e === t || e && t && Math.abs(e[0] - t[0]) < ZS && Math.abs(e[1] - t[1]) < ZS || !1;
}
function Yc(e, t) {
  var i;
  const n = (i = e.channelField(t)) == null ? void 0 : i.field;
  return (n == null ? void 0 : n.basis) || n;
}
function K1(e, t, n = 1) {
  return t.invert(n * Math.floor(e / n));
}
function kN() {
  const e = this, t = e.getScreenCTM;
  let n;
  e.getScreenCTM = () => e.isConnected ? n = t.call(e) : n;
}
class UN {
  constructor(t, {
    channel: n,
    selection: i,
    field: r,
    pixelSize: s = 1,
    peers: o = !0,
    brush: a
  }) {
    this.mark = t, this.channel = n, this.pixelSize = s || 1, this.selection = i, this.peers = o, this.field = r || Yc(t, n), this.style = a && Pv(a), this.brush = n === "y" ? ort() : srt(), 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((i) => K1(i, this.scale, this.pixelSize)).sort((i, r) => i - r)), J1(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: i, field: r, scale: s } = this;
    return {
      source: this,
      schema: { type: "interval", pixelSize: i, scales: [s] },
      clients: this.peers ? n.plot.markSet : (/* @__PURE__ */ new Set()).add(n),
      value: t,
      predicate: t ? Tn(r, t) : null
    };
  }
  init(t) {
    var l;
    const { brush: n, channel: i, style: r } = this;
    this.scale = t.scale(i);
    const s = t.scale("x").range, o = t.scale("y").range;
    n.extent([[Ye(s), Ye(o)], [De(s), De(o)]]);
    const a = ce(t).selectAll('g[aria-label="facet"]'), c = a.size() ? a : ce(t);
    if (this.g = c.append("g").attr("class", `interval-${i}`).each(kN).call(n).call(n.moveSilent, (l = this.value) == null ? void 0 : l.map(this.scale.apply)), r) {
      const u = this.g.selectAll("rect.selection");
      for (const f in r)
        u.attr(f, r[f]);
    }
    t.addEventListener("pointerenter", () => this.activate());
  }
}
const Rh = (e, t) => e - t;
class art {
  constructor(t, {
    selection: n,
    xfield: i,
    yfield: r,
    pixelSize: s = 1,
    peers: o = !0,
    brush: a
  }) {
    this.mark = t, this.pixelSize = s || 1, this.selection = n, this.peers = o, this.xfield = i || Yc(t, "x"), this.yfield = r || Yc(t, "y"), this.style = a && Pv(a), this.brush = rrt(), 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: i, xscale: r, yscale: s } = this;
    let o, a;
    if (t) {
      const [c, l] = t;
      o = [c[0], l[0]].map((u) => K1(u, r, i)).sort(Rh), a = [c[1], l[1]].map((u) => K1(u, s, i)).sort(Rh);
    }
    (!J1(o, n == null ? void 0 : n[0]) || !J1(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: i, xfield: r, yfield: s, xscale: o, yscale: a } = this;
    return {
      source: this,
      schema: { type: "interval", pixelSize: i, scales: [o, a] },
      clients: this.peers ? n.plot.markSet : (/* @__PURE__ */ new Set()).add(n),
      value: t,
      predicate: t ? js(Tn(r, t[0]), Tn(s, t[1])) : null
    };
  }
  init(t) {
    const { brush: n, style: i } = this, r = this.xscale = t.scale("x"), s = this.yscale = t.scale("y"), o = r.range, a = s.range;
    n.extent([[Ye(o), Ye(a)], [De(o), De(a)]]);
    const c = ce(t).selectAll('g[aria-label="facet"]'), l = c.size() ? c : ce(t);
    if (this.g = l.append("g").attr("class", "interval-xy").each(kN).call(n), i) {
      const u = this.g.selectAll("rect.selection");
      for (const f in i)
        u.attr(f, i[f]);
    }
    if (this.value) {
      const [u, f] = this.value[0].map(r.apply).sort(Rh), [h, d] = this.value[1].map(s.apply).sort(Rh);
      this.g.call(n.moveSilent, [[u, h], [f, d]]);
    }
    t.addEventListener("pointerenter", () => this.activate());
  }
}
class zN {
  constructor(t, {
    selection: n,
    channel: i,
    field: r
  }) {
    this.mark = t, this.selection = n, this.clients = (/* @__PURE__ */ new Set()).add(t), this.channel = i, this.field = r || Yc(t, [i]);
  }
  clause(t) {
    const { clients: n, field: i } = this, r = t ? qy(i, Qc(t)) : null;
    return {
      source: this,
      schema: { type: "point" },
      clients: n,
      value: t,
      predicate: r
    };
  }
  init(t) {
    const n = this, { mark: i, channel: r, selection: s } = this, { data: o } = i, a = i.channelField(r).as, c = ce(t).selectAll('g[aria-label="facet"]'), l = c.size() ? c : ce(t), u = t.scale(r), f = !Xo(s);
    l.on("pointerdown pointermove", function(h) {
      const [d, p] = yi(h, this), y = crt(o, a, u.invert(r === "x" ? d : p));
      s.update(f ? y : n.clause(y));
    }), !f && t.addEventListener("pointerenter", () => {
      this.selection.activate(this.clause(0));
    });
  }
}
function crt(e, t, n) {
  let i = 1 / 0, r;
  return e.forEach((s) => {
    const o = Math.abs(s[t] - n);
    o < i && (i = o, r = s[t]);
  }), r;
}
const QS = (e, t) => e - t;
class lrt {
  constructor(t, {
    x: n = new Jd(),
    y: i = new Jd(),
    xfield: r,
    yfield: s,
    zoom: o = !0,
    panx: a = !0,
    pany: c = !0
  }) {
    this.mark = t, this.xsel = n, this.ysel = i, this.xfield = r || Yc(t, "x"), this.yfield = s || Yc(t, "y"), this.zoom = rg(o, [0, 1 / 0], [1, 1]), this.panx = this.xsel && a, this.pany = this.ysel && c;
    const { plot: l } = t;
    a && this.xsel.addEventListener("value", (u) => {
      l.setAttribute("xDomain", u) && l.update();
    }), c && this.ysel.addEventListener("value", (u) => {
      l.setAttribute("yDomain", u) && l.update();
    });
  }
  publish(t) {
    if (this.panx) {
      const n = urt(t, this.xscale);
      this.xsel.update(this.clause(n, this.xfield, this.xscale));
    }
    if (this.pany) {
      const n = frt(t, this.yscale);
      this.ysel.update(this.clause(n, this.yfield, this.yscale));
    }
  }
  clause(t, n, i) {
    return {
      source: this,
      schema: { type: "interval", scales: [i] },
      clients: this.mark.plot.markSet,
      value: t,
      predicate: t ? Tn(n, t) : null
    };
  }
  init(t) {
    if (this.svg = t, this.initialized)
      return;
    this.initialized = !0;
    const { panx: n, pany: i, mark: { plot: { element: r } }, xsel: s, ysel: o } = this;
    this.xscale = t.scale("x"), this.yscale = t.scale("y");
    const a = this.xscale.range.slice().sort(QS), c = this.yscale.range.slice().sort(QS), l = rg(n, [-1 / 0, 1 / 0], a), u = rg(i, [-1 / 0, 1 / 0], c), f = OH().extent([[a[0], c[0]], [a[1], c[1]]]).scaleExtent(this.zoom).translateExtent([[l[0], u[0]], [l[1], u[1]]]).on("start", () => {
      this.xscale = this.svg.scale("x"), this.yscale = this.svg.scale("y");
    }).on("end", () => r.__zoom = new ir(1, 0, 0)).on("zoom", ({ transform: h }) => this.publish(h));
    if (ce(r).call(f), n || i) {
      let h = !1;
      r.addEventListener("mouseenter", () => {
        if (!h) {
          if (h = !0, n) {
            const { xscale: d, xfield: p } = this;
            s.activate(this.clause(d.domain, p, d));
          }
          if (i) {
            const { yscale: d, yfield: p } = this;
            o.activate(this.clause(d.domain, p, d));
          }
        }
      }), r.addEventListener("mouseleave", () => h = !1);
    }
  }
}
function rg(e, t, n) {
  return e ? Array.isArray(e) ? e : t : n;
}
function urt(e, t) {
  return t.range.map(e.invertX, e).map(t.invert, t);
}
function frt(e, t) {
  return t.range.map(e.invertY, e).map(t.invert, t);
}
class PN {
  constructor(t, {
    selection: n,
    channels: i,
    peers: r = !0
  }) {
    this.value = null, this.mark = t, this.selection = n, this.peers = r, this.channels = i.map((s) => {
      var a;
      const o = s === "color" ? ["fill", "stroke"] : s === "x" ? ["x", "x1", "x2"] : s === "y" ? ["y", "y1", "y2"] : [s];
      for (let c = 0; c < o.length; ++c) {
        const l = t.channelField(o[c]);
        if (l)
          return {
            field: ((a = l.field) == null ? void 0 : a.basis) || l.field,
            as: l.as
          };
      }
      throw new Error(`Missing channel: ${s}`);
    });
  }
  clause(t) {
    const { channels: n, mark: i } = this;
    let r = null;
    if (t) {
      const s = t.map((o) => {
        const a = o.map((c, l) => qM(n[l].field, Qc(c)));
        return a.length > 1 ? js(a) : a[0];
      });
      r = s.length > 1 ? Ob(s) : s[0];
    }
    return {
      source: this,
      schema: { type: "point" },
      clients: this.peers ? i.plot.markSet : (/* @__PURE__ */ new Set()).add(i),
      value: t,
      predicate: r
    };
  }
  init(t, n, i) {
    const { mark: r, channels: s, selection: o } = this, { data: a } = r;
    i = i || ((l) => {
      const u = a[l.__data__];
      return s.map((f) => u[f.as]);
    }), n = n || `[data-index="${r.index}"]`;
    const c = new Set(t.querySelectorAll(n));
    t.addEventListener("pointerdown", (l) => {
      const u = o.single ? o.value : this.value, f = l.target;
      let h = null;
      if (hrt(c, f)) {
        const d = i(f);
        l.shiftKey && (u != null && u.length) ? (h = u.filter((p) => Z1(p, d)), h.length === u.length && h.push(d)) : (u == null ? void 0 : u.length) === 1 && !Z1(u[0], d) ? h = null : h = [d];
      }
      this.value = h, drt(u, h) && o.update(this.clause(h));
    }), t.addEventListener("pointerenter", () => {
      this.selection.activate(this.clause([this.channels.map(() => 0)]));
    });
  }
}
function hrt(e, t) {
  var n;
  return e.has(t) || e.has(t.parentNode) || e.has((n = t.parentNode) == null ? void 0 : n.parentNode);
}
function drt(e, t) {
  return e == null || t == null ? e != null || t != null : e.length !== t.length || e.some((n, i) => Z1(n, t[i]));
}
function Z1(e, t) {
  const n = e.length;
  if (t.length !== n)
    return !0;
  for (let i = 0; i < n; ++i)
    if (e[i] !== t[i])
      return !0;
  return !1;
}
class tI {
  constructor(t, n) {
    const { as: i, ...r } = n;
    this.channel = t, this.options = { label: null, ...r }, this.selection = i, this.element = document.createElement("div"), this.element.setAttribute("class", "legend"), this.element.value = this;
  }
  setPlot(t) {
    const { channel: n, selection: i } = this, r = prt(t, n);
    this.selection && r && (this.handler = new PN(r, { selection: i, channels: [n] }), this.selection.addEventListener("value", () => this.update()));
  }
  init(t) {
    const { channel: n, options: i, handler: r } = this, o = t.scale(n).type === "ordinal" ? i : { marginTop: 1, tickSize: 2, height: 28, ...i };
    return this.legend = t.legend(n, o), r && (r.init(this.legend, ":scope > div", (a) => [a.__data__]), this.update()), this.element.replaceChildren(this.legend), this.element;
  }
  update() {
    if (!this.legend)
      return;
    const { value: t } = this.selection, n = t && t.length ? new Set(t.map((r) => r[0])) : null, i = this.legend.querySelectorAll(":scope > div");
    for (const r of i) {
      const s = n ? n.has(r.__data__) : !0;
      r.style.opacity = s ? 1 : 0.2;
    }
  }
}
function prt({ marks: e }, t) {
  const n = t === "color" ? ["fill", "stroke"] : t === "opacity" ? ["opacity", "fillOpacity", "strokeOpacity"] : null;
  if (n == null)
    return null;
  for (let i = e.length - 1; i > -1; --i)
    for (const r of n)
      if (e[i].channelField(r, { exact: !0 }))
        return e[i];
  return null;
}
const yrt = /* @__PURE__ */ new Set(["rectY-x", "rectX-y", "rect-x", "rect-y"]);
function mrt(e, t = { steps: 25 }) {
  const n = (i, r) => yrt.has(`${i.type}-${r}`) ? {
    [`${r}1`]: sg(i, r, e, t),
    [`${r}2`]: sg(i, r, e, { ...t, offset: 1 })
  } : {
    [r]: sg(i, r, e, t)
  };
  return n[e3] = !0, n;
}
function sg(e, t, n, i) {
  return {
    column: n,
    label: n,
    get stats() {
      return { column: n, stats: ["min", "max"] };
    },
    get columns() {
      return [n];
    },
    get basis() {
      return n;
    },
    toString() {
      const { apply: r, sqlApply: s, sqlInvert: o } = iy(e, t), { min: a, max: c } = e.channelField(t), l = grt(r(a), r(c), i), u = s(n), f = l.min === 0 ? u : `(${u} - ${l.min})`, h = `${(l.max - l.min) / l.steps}::DOUBLE`, d = i.offset ? `${i.offset} + ` : "", p = `${l.min} + ${h} * (${d}FLOOR(${f} / ${h}))`;
      return `${o(p)}`;
    }
  };
}
function grt(e, t, n) {
  let { steps: i = 25, minstep: r = 0, nice: s = !0 } = n;
  if (s !== !1) {
    const o = t - e, a = i, c = Math.LN10, l = Math.ceil(Math.log(a) / c);
    let u = Math.max(
      r,
      Math.pow(10, Math.round(Math.log(o) / c) - l)
    );
    for (; Math.ceil(o / u) > a; )
      u *= 10;
    const f = [5, 2];
    let h;
    for (let y = 0, g = f.length; y < g; ++y)
      h = u / f[y], h >= r && o / h <= a && (u = h);
    h = Math.log(u);
    const d = h >= 0 ? 0 : ~~(-h / c) + 1, p = Math.pow(10, -d - 1);
    h = Math.floor(e / u + p) * u, e = e < h ? h - u : h, t = Math.ceil(t / u) * u, i = Math.round((t - e) / u);
  }
  return { min: e, max: t, steps: i };
}
const brt = (e) => e && typeof e == "object" && !Array.isArray(e);
class wrt extends cf {
  constructor({
    element: t,
    filterBy: n,
    from: i,
    column: r,
    label: s = r,
    format: o = (u) => u,
    // TODO
    options: a,
    value: c,
    as: l
  } = {}) {
    var f, h, d, p;
    super(n), this.from = i, this.column = r, this.selection = l, this.format = o, this.element = t ?? document.createElement("div"), this.element.setAttribute("class", "input"), this.element.value = this;
    const u = document.createElement("label");
    u.innerText = s || r, this.element.appendChild(u), this.select = document.createElement("select"), a && (this.data = a.map((y) => brt(y) ? y : { value: y }), this.update()), c = c ?? ((f = this.selection) == null ? void 0 : f.value) ?? ((d = (h = this.data) == null ? void 0 : h[0]) == null ? void 0 : d.value), ((p = this.selection) == null ? void 0 : p.value) === void 0 && this.publish(c), this.element.appendChild(this.select), this.selection && (this.select.addEventListener("input", () => {
      this.publish(this.selectedValue() ?? null);
    }), Xo(this.selection) || this.selection.addEventListener("value", (y) => {
      y !== this.select.value && this.selectedValue(y);
    }));
  }
  selectedValue(t) {
    var n;
    if (arguments.length === 0) {
      const i = this.select.selectedIndex;
      return this.data[i].value;
    } else {
      const i = (n = this.data) == null ? void 0 : n.findIndex((r) => r.value === t);
      i >= 0 ? this.select.selectedIndex = i : this.select.value = String(t);
    }
  }
  reset() {
    this.select.selectedIndex = this.from ? 0 : -1;
  }
  publish(t) {
    const { selection: n, column: i } = this;
    Xo(n) ? n.update({
      source: this,
      schema: { type: "point" },
      value: t,
      predicate: t !== "" && t !== void 0 ? qy(i, Qc(t)) : null
    }) : ks(n) && n.update(t);
  }
  query(t = []) {
    const { from: n, column: i } = this;
    return n ? Et.from(n).select({ value: i }).distinct().where(t).orderby(i) : null;
  }
  queryResult(t) {
    return this.data = [{ value: "", label: "All" }, ...t], this;
  }
  update() {
    var r;
    const { data: t, format: n, select: i } = this;
    i.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);
    }
    return this.selection && this.selectedValue(((r = this.selection) == null ? void 0 : r.value) ?? ""), this;
  }
}
const vrt = { contains: _9, prefix: x9, suffix: S9, regexp: v9 };
let _rt = 0;
class xrt extends cf {
  constructor({
    element: t,
    filterBy: n,
    from: i,
    column: r,
    label: s,
    type: o = "contains",
    as: a
  } = {}) {
    if (super(n), this.id = "search_" + ++_rt, this.type = o, this.from = i, this.column = r, this.selection = a, this.element = t ?? document.createElement("div"), this.element.setAttribute("class", "input"), this.element.value = this, s) {
      const c = document.createElement("label");
      c.setAttribute("for", this.id), c.innerText = s, this.element.appendChild(c);
    }
    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);
    }), Xo(this.selection) || this.selection.addEventListener("value", (c) => {
      c !== this.searchbox.value && (this.searchbox.value = c);
    }));
  }
  reset() {
    this.searchbox.value = "";
  }
  publish(t) {
    const { selection: n, column: i, type: r } = this;
    Xo(n) ? n.update({
      source: this,
      schema: { type: r },
      value: t,
      predicate: t ? vrt[r](i, Qc(t)) : null
    }) : ks(n) && n.update(t);
  }
  query(t = []) {
    const { from: n, column: i } = this;
    return n ? Et.from(n).select({ list: i }).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 i of this.data) {
      const r = document.createElement("option");
      r.setAttribute("value", i.list), t.append(r);
    }
    return this.datalist && this.datalist.remove(), this.element.appendChild(this.datalist = t), this.searchbox.setAttribute("list", n), this;
  }
}
let Srt = 0;
class Irt extends cf {
  constructor({
    element: t,
    filterBy: n,
    as: i,
    min: r,
    max: s,
    step: o,
    from: a,
    column: c,
    label: l = c,
    value: u = i == null ? void 0 : i.value,
    width: f
  } = {}) {
    var h;
    if (super(n), this.id = "slider_" + ++Srt, this.from = a, this.column = c || "value", this.selection = i, this.min = r, this.max = s, this.step = o, this.element = t || document.createElement("div"), this.element.setAttribute("class", "input"), this.element.value = this, l) {
      const d = document.createElement("label");
      d.setAttribute("for", this.id), d.innerText = l, this.element.appendChild(d);
    }
    this.slider = document.createElement("input"), this.slider.setAttribute("id", this.id), this.slider.setAttribute("type", "range"), f != null && (this.slider.style.width = `${+f}px`), r != null && this.slider.setAttribute("min", r), s != null && this.slider.setAttribute("max", s), o != null && this.slider.setAttribute("step", o), u != null && (this.slider.setAttribute("value", u), ((h = this.selection) == null ? void 0 : h.value) === void 0 && this.publish(u)), this.element.appendChild(this.slider), this.selection && (this.slider.addEventListener("input", () => {
      this.publish(+this.slider.value);
    }), Xo(this.selection) || this.selection.addEventListener("value", (d) => {
      d !== +this.slider.value && (this.slider.value = d);
    }));
  }
  query(t = []) {
    const { from: n, column: i } = this;
    return !n || this.min != null && this.max != null ? null : Et.select({ min: $c(i), max: Mc(i) }).from(n).where(t);
  }
  queryResult(t) {
    const { min: n, max: i } = Array.from(t)[0];
    return this.min == null && this.slider.setAttribute("min", n), this.max == null && this.slider.setAttribute("max", i), this.step == null && this.slider.setAttribute("step", (i - n) / 500), this;
  }
  publish(t) {
    const { selection: n, column: i } = this;
    Xo(n) ? n.update({
      source: this,
      schema: { type: "point" },
      value: t,
      predicate: qy(i, Qc(t))
    }) : ks(this.selection) && n.update(t);
  }
}
const VN = qv((e) => {
  const t = jv(e);
  return (n) => n == null ? "" : typeof n == "number" ? t(n) : n instanceof Date ? jN(n) : `${n}`;
}), jv = qv((e) => (t) => t === 0 ? "0" : t.toLocaleString(e));
VN();
jv();
function jN(e) {
  return iD(e, "Invalid Date");
}
function qv(e) {
  let t = qv, n;
  return (i = "en") => i === t ? n : n = e(t = i);
}
let Art = -1, Mrt = class extends cf {
  constructor({
    element: t,
    filterBy: n,
    from: i,
    columns: r = ["*"],
    align: s = {},
    format: o,
    width: a,
    maxWidth: c,
    height: l = 500,
    rowBatch: u = 100
  } = {}) {
    super(n), this.id = `table-${++Art}`, this.from = i, this.columns = r, this.format = o, this.align = s, this.widths = typeof a == "object" ? a : {}, this.offset = 0, this.limit = +u, this.pending = !1, this.sortHeader = null, this.sortColumn = null, this.sortDesc = !1, this.element = t || document.createElement("div"), this.element.setAttribute("id", this.id), this.element.value = this, typeof a == "number" && (this.element.style.width = `${a}px`), c && (this.element.style.maxWidth = `${c}px`), this.element.style.maxHeight = `${l}px`, this.element.style.overflow = "auto";
    let f = -1;
    this.element.addEventListener("scroll", (h) => {
      const { pending: d, loaded: p } = this, { scrollHeight: y, scrollTop: g, clientHeight: m } = h.target, b = g < f;
      f = g, !(b || d || p) && y - g < 2 * m && (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.style = document.createElement("style"), this.element.appendChild(this.style);
  }
  requestData(t = 0) {
    var i;
    this.offset = t;
    const n = this.query((i = this.filterBy) == null ? void 0 : i.predicate(this));
    this.requestQuery(n), Yr().prefetch(n.clone().offset(t + this.limit));
  }
  fields() {
    return this.columns.map((t) => Vy(this.from, t));
  }
  fieldInfo(t) {
    this.schema = t;
    const n = this.head;
    n.innerHTML = "";
    const i = document.createElement("tr");
    for (const { column: r } of t) {
      const s = document.createElement("th");
      s.addEventListener("click", (o) => this.sort(o, r)), s.appendChild(document.createElement("span")), s.appendChild(document.createTextNode(r)), i.appendChild(s);
    }
    return n.appendChild(i), this.formats = $rt(this.format, t), this.style.innerText = Nrt(
      this.id,
      Trt(this.align, t),
      Drt(this.widths, t)
    ), this;
  }
  query(t = []) {
    const { from: n, limit: i, offset: r, schema: s, sortColumn: o, sortDesc: a } = this;
    return Et.from(n).select(s.map((c) => c.column)).where(t).orderby(o ? a ? p9(o) : o : []).limit(i).offset(r);
  }
  queryResult(t) {
    return this.pending || (this.loaded = !1, this.body.replaceChildren()), this.data = t, this;
  }
  update() {
    const { body: t, formats: n, data: i, schema: r, limit: s } = this, o = r.length;
    let a = 0;
    for (const c of i) {
      ++a;
      const l = document.createElement("tr");
      for (let u = 0; u < o; ++u) {
        const f = c[r[u].column], h = document.createElement("td");
        h.innerText = f == null ? "" : n[u](f), l.appendChild(h);
      }
      t.appendChild(l);
    }
    return a < 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 i = t.currentTarget, r = this.sortHeader;
    r === i && t.metaKey ? (r.firstChild.textContent = "", this.sortHeader = null, this.sortColumn = null) : (r && (r.firstChild.textContent = ""), this.sortHeader = i, i.firstChild.textContent = this.sortDesc ? "▾" : "▴"), this.requestData();
  }
};
function $rt(e = {}, t, n) {
  return t.map(({ column: i, type: r }) => {
    if (i in e)
      return e[i];
    switch (r) {
      case "number":
        return jv(n);
      case "date":
        return jN;
      default:
        return VN(n);
    }
  });
}
function Trt(e = {}, t) {
  return t.map(({ column: n, type: i }) => n in e ? e[n] : i === "number" ? "right" : "left");
}
function Drt(e = {}, t) {
  return t.map(({ column: n }) => e[n]);
}
function Nrt(e, t, n) {
  const i = [];
  return t.forEach((r, s) => {
    const o = +n[s];
    if (r !== "left" || o) {
      const a = r !== "left" ? `text-align:${r};` : "", c = o ? `width:${o}px;max-width:${o}px;` : "";
      i.push(`#${e} tr>:nth-child(${s + 1}) {${a}${c}}`);
    }
  }), i.join(" ");
}
function qN(e, ...t) {
  var i;
  const n = ((i = e == null ? void 0 : e.context) == null ? void 0 : i.coordinator) ?? Yr();
  for (const r of t)
    n.connect(r);
}
function G0(e, t, n) {
  const i = new t(n);
  return qN(e, i), i.element;
}
function Brt(e) {
  return G0(this, wrt, e);
}
function Ort(e) {
  return G0(this, xrt, e);
}
function Frt(e) {
  return G0(this, Irt, e);
}
function Ert(e) {
  return G0(this, Mrt, e);
}
function YN({ direction: e = "vertical", wrap: t = !1 }, n) {
  const i = document.createElement("div");
  return i.style.display = "flex", i.style.flexDirection = e === "vertical" ? "column" : "row", i.style.flexWrap = t ? t === !0 ? "wrap" : t : "nowrap", i.style.justifyContent = "flex-start", i.style.alignItems = "flex-start", n.forEach((r) => i.appendChild(r)), i.value = { element: i }, i;
}
function Lrt(...e) {
  return YN({ direction: "vertical" }, e.flat());
}
function Rrt(...e) {
  return YN({ direction: "horizontal" }, e.flat());
}
function WN({ dim: e = "width", size: t = 10 }) {
  const n = document.createElement("span");
  n.style.display = "inline-block", n.style[e] = Number.isNaN(+t) ? t : `${t}px`;
  const i = { element: n };
  return n.value = i, n;
}
function Crt(e) {
  return WN({ dim: "height", size: e });
}
function krt(e) {
  return WN({ dim: "width", size: e });
}
class GN extends Map {
  request(t, n) {
    if (this.has(t))
      n(this.get(t));
    else {
      const i = this.waiting || (this.waiting = /* @__PURE__ */ new Map()), r = i.get(t) || [];
      i.set(t, r.concat(n));
    }
  }
  set(t, n) {
    this.has(t) && console.warn(`Overwriting named plot "${t}".`);
    const { waiting: i } = this;
    return i != null && i.has(t) && (i.get(t).forEach((r) => r(n)), i.delete(t)), super.set(t, n);
  }
}
const Yv = new GN();
function Urt(e, t, n) {
  var r;
  (((r = e == null ? void 0 : e.context) == null ? void 0 : r.namedPlots) ?? Yv).request(t, n);
}
function zrt(e, t, n) {
  var r;
  (((r = e == null ? void 0 : e.context) == null ? void 0 : r.namedPlots) ?? Yv).set(t, n);
}
function XN(e) {
  return (t) => zrt(this, e, t);
}
function HN(e, t, n) {
  ks(n) ? (n.addEventListener("value", (i) => {
    e.setAttribute(t, i), e.update();
  }), n.value !== void 0 && e.setAttribute(t, n.value)) : e.setAttribute(t, n);
}
function Prt(e, t) {
  return (n) => {
    HN(n, e, t);
  };
}
function Wv(e) {
  return (t) => {
    for (const [n, i] of Object.entries(e))
      HN(t, n, i);
  };
}
function JN(e) {
  const { top: t, bottom: n, left: i, right: r } = e, s = {};
  return t !== void 0 && (s.marginTop = t), n !== void 0 && (s.marginBottom = n), i !== void 0 && (s.marginLeft = i), r !== void 0 && (s.marginRight = r), Wv(s);
}
function KN(e) {
  return Wv({
    marginTop: e,
    marginBottom: e,
    marginLeft: e,
    marginRight: e
  });
}
function ZN(e) {
  return Wv({ xDomain: e, yDomain: e });
}
const O = (e) => (t) => Prt(e, t), QN = O("style"), tB = O("width"), eB = O("height"), nB = O("marginLeft"), iB = O("marginRight"), rB = O("marginTop"), sB = O("marginBottom"), oB = O("align"), aB = O("aspectRatio"), cB = O("axis"), lB = O("inset"), uB = O("grid"), fB = O("label"), hB = O("padding"), dB = O("round"), pB = O("xScale"), yB = O("xDomain"), mB = O("xRange"), gB = O("xNice"), bB = O("xInset"), wB = O("xInsetLeft"), vB = O("xInsetRight"), _B = O("xClamp"), xB = O("xRound"), SB = O("xAlign"), IB = O("xPadding"), AB = O("xPaddingInner"), MB = O("xPaddingOuter"), $B = O("xAxis"), TB = O("xTicks"), DB = O("xTickSize"), NB = O("xTickSpacing"), BB = O("xTickPadding"), OB = O("xTickFormat"), FB = O("xTickRotate"), EB = O("xGrid"), LB = O("xLine"), RB = O("xLabel"), CB = O("xLabelAnchor"), kB = O("xLabelOffset"), UB = O("xFontVariant"), zB = O("xAriaLabel"), PB = O("xAriaDescription"), VB = O("xReverse"), jB = O("xZero"), qB = O("xBase"), YB = O("xExponent"), WB = O("xConstant"), GB = O("yScale"), XB = O("yDomain"), HB = O("yRange"), JB = O("yNice"), KB = O("yInset"), ZB = O("yInsetTop"), QB = O("yInsetBottom"), tO = O("yClamp"), eO = O("yRound"), nO = O("yAlign"), iO = O("yPadding"), rO = O("yPaddingInner"), sO = O("yPaddingOuter"), oO = O("yAxis"), aO = O("yTicks"), cO = O("yTickSize"), lO = O("yTickSpacing"), uO = O("yTickPadding"), fO = O("yTickFormat"), hO = O("yTickRotate"), dO = O("yGrid"), pO = O("yLine"), yO = O("yLabel"), mO = O("yLabelAnchor"), gO = O("yLabelOffset"), bO = O("yFontVariant"), wO = O("yAriaLabel"), vO = O("yAriaDescription"), _O = O("yReverse"), xO = O("yZero"), SO = O("yBase"), IO = O("yExponent"), AO = O("yConstant"), MO = O("facetMargin"), $O = O("facetMarginTop"), TO = O("facetMarginBottom"), DO = O("facetMarginLeft"), NO = O("facetMarginRight"), BO = O("facetGrid"), OO = O("facetLabel"), FO = O("fxDomain"), EO = O("fxRange"), LO = O("fxNice"), RO = O("fxInset"), CO = O("fxInsetLeft"), kO = O("fxInsetRight"), UO = O("fxRound"), zO = O("fxAlign"), PO = O("fxPadding"), VO = O("fxPaddingInner"), jO = O("fxPaddingOuter"), qO = O("fxAxis"), YO = O("fxTicks"), WO = O("fxTickSize"), GO = O("fxTickSpacing"), XO = O("fxTickPadding"), HO = O("fxTickFormat"), JO = O("fxTickRotate"), KO = O("fxGrid"), ZO = O("fxLine"), QO = O("fxLabel"), tF = O("fxLabelAnchor"), eF = O("fxLabelOffset"), nF = O("fxFontVariant"), iF = O("fxAriaLabel"), rF = O("fxAriaDescription"), sF = O("fxReverse"), oF = O("fyDomain"), aF = O("fyRange"), cF = O("fyNice"), lF = O("fyInset"), uF = O("fyInsetTop"), fF = O("fyInsetBottom"), hF = O("fyRound"), dF = O("fyAlign"), pF = O("fyPadding"), yF = O("fyPaddingInner"), mF = O("fyPaddingOuter"), gF = O("fyAxis"), bF = O("fyTicks"), wF = O("fyTickSize"), vF = O("fyTickSpacing"), _F = O("fyTickPadding"), xF = O("fyTickFormat"), SF = O("fyTickRotate"), IF = O("fyGrid"), AF = O("fyLine"), MF = O("fyLabel"), $F = O("fyLabelAnchor"), TF = O("fyLabelOffset"), DF = O("fyFontVariant"), NF = O("fyAriaLabel"), BF = O("fyAriaDescription"), OF = O("fyReverse"), FF = O("colorScale"), EF = O("colorDomain"), LF = O("colorRange"), RF = O("colorClamp"), CF = O("colorN"), kF = O("colorNice"), UF = O("colorScheme"), zF = O("colorInterpolate"), PF = O("colorPivot"), VF = O("colorSymmetric"), jF = O("colorLabel"), qF = O("colorReverse"), YF = O("colorZero"), WF = O("colorTickFormat"), GF = O("colorBase"), XF = O("colorExponent"), HF = O("colorConstant"), JF = O("opacityScale"), KF = O("opacityDomain"), ZF = O("opacityRange"), QF = O("opacityClamp"), tE = O("opacityNice"), eE = O("opacityLabel"), nE = O("opacityReverse"), iE = O("opacityZero"), rE = O("opacityTickFormat"), sE = O("opacityBase"), oE = O("opacityExponent"), aE = O("opacityConstant"), cE = O("rScale"), lE = O("rDomain"), uE = O("rRange"), fE = O("rClamp"), hE = O("rNice"), dE = O("rZero"), pE = O("rBase"), yE = O("rExponent"), mE = O("rConstant"), gE = O("lengthScale"), bE = O("lengthDomain"), wE = O("lengthRange"), vE = O("lengthClamp"), _E = O("lengthNice"), xE = O("lengthZero"), SE = O("lengthBase"), IE = O("lengthExponent"), AE = O("lengthConstant"), ME = O("projectionType"), $E = O("projectionParallels"), TE = O("projectionPrecision"), DE = O("projectionRotate"), NE = O("projectionDomain"), BE = O("projectionInset"), OE = O("projectionInsetLeft"), FE = O("projectionInsetRight"), EE = O("projectionInsetTop"), LE = O("projectionInsetBottom"), RE = O("projectionClip"), Vrt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  align: oB,
  aspectRatio: aB,
  axis: cB,
  colorBase: GF,
  colorClamp: RF,
  colorConstant: HF,
  colorDomain: EF,
  colorExponent: XF,
  colorInterpolate: zF,
  colorLabel: jF,
  colorN: CF,
  colorNice: kF,
  colorPivot: PF,
  colorRange: LF,
  colorReverse: qF,
  colorScale: FF,
  colorScheme: UF,
  colorSymmetric: VF,
  colorTickFormat: WF,
  colorZero: YF,
  facetGrid: BO,
  facetLabel: OO,
  facetMargin: MO,
  facetMarginBottom: TO,
  facetMarginLeft: DO,
  facetMarginRight: NO,
  facetMarginTop: $O,
  fxAlign: zO,
  fxAriaDescription: rF,
  fxAriaLabel: iF,
  fxAxis: qO,
  fxDomain: FO,
  fxFontVariant: nF,
  fxGrid: KO,
  fxInset: RO,
  fxInsetLeft: CO,
  fxInsetRight: kO,
  fxLabel: QO,
  fxLabelAnchor: tF,
  fxLabelOffset: eF,
  fxLine: ZO,
  fxNice: LO,
  fxPadding: PO,
  fxPaddingInner: VO,
  fxPaddingOuter: jO,
  fxRange: EO,
  fxReverse: sF,
  fxRound: UO,
  fxTickFormat: HO,
  fxTickPadding: XO,
  fxTickRotate: JO,
  fxTickSize: WO,
  fxTickSpacing: GO,
  fxTicks: YO,
  fyAlign: dF,
  fyAriaDescription: BF,
  fyAriaLabel: NF,
  fyAxis: gF,
  fyDomain: oF,
  fyFontVariant: DF,
  fyGrid: IF,
  fyInset: lF,
  fyInsetBottom: fF,
  fyInsetTop: uF,
  fyLabel: MF,
  fyLabelAnchor: $F,
  fyLabelOffset: TF,
  fyLine: AF,
  fyNice: cF,
  fyPadding: pF,
  fyPaddingInner: yF,
  fyPaddingOuter: mF,
  fyRange: aF,
  fyReverse: OF,
  fyRound: hF,
  fyTickFormat: xF,
  fyTickPadding: _F,
  fyTickRotate: SF,
  fyTickSize: wF,
  fyTickSpacing: vF,
  fyTicks: bF,
  grid: uB,
  height: eB,
  inset: lB,
  label: fB,
  lengthBase: SE,
  lengthClamp: vE,
  lengthConstant: AE,
  lengthDomain: bE,
  lengthExponent: IE,
  lengthNice: _E,
  lengthRange: wE,
  lengthScale: gE,
  lengthZero: xE,
  margin: KN,
  marginBottom: sB,
  marginLeft: nB,
  marginRight: iB,
  marginTop: rB,
  margins: JN,
  name: XN,
  opacityBase: sE,
  opacityClamp: QF,
  opacityConstant: aE,
  opacityDomain: KF,
  opacityExponent: oE,
  opacityLabel: eE,
  opacityNice: tE,
  opacityRange: ZF,
  opacityReverse: nE,
  opacityScale: JF,
  opacityTickFormat: rE,
  opacityZero: iE,
  padding: hB,
  projectionClip: RE,
  projectionDomain: NE,
  projectionInset: BE,
  projectionInsetBottom: LE,
  projectionInsetLeft: OE,
  projectionInsetRight: FE,
  projectionInsetTop: EE,
  projectionParallels: $E,
  projectionPrecision: TE,
  projectionRotate: DE,
  projectionType: ME,
  rBase: pE,
  rClamp: fE,
  rConstant: mE,
  rDomain: lE,
  rExponent: yE,
  rNice: hE,
  rRange: uE,
  rScale: cE,
  rZero: dE,
  round: dB,
  style: QN,
  width: tB,
  xAlign: SB,
  xAriaDescription: PB,
  xAriaLabel: zB,
  xAxis: $B,
  xBase: qB,
  xClamp: _B,
  xConstant: WB,
  xDomain: yB,
  xExponent: YB,
  xFontVariant: UB,
  xGrid: EB,
  xInset: bB,
  xInsetLeft: wB,
  xInsetRight: vB,
  xLabel: RB,
  xLabelAnchor: CB,
  xLabelOffset: kB,
  xLine: LB,
  xNice: gB,
  xPadding: IB,
  xPaddingInner: AB,
  xPaddingOuter: MB,
  xRange: mB,
  xReverse: VB,
  xRound: xB,
  xScale: pB,
  xTickFormat: OB,
  xTickPadding: BB,
  xTickRotate: FB,
  xTickSize: DB,
  xTickSpacing: NB,
  xTicks: TB,
  xZero: jB,
  xyDomain: ZN,
  yAlign: nO,
  yAriaDescription: vO,
  yAriaLabel: wO,
  yAxis: oO,
  yBase: SO,
  yClamp: tO,
  yConstant: AO,
  yDomain: XB,
  yExponent: IO,
  yFontVariant: bO,
  yGrid: dO,
  yInset: KB,
  yInsetBottom: QB,
  yInsetTop: ZB,
  yLabel: yO,
  yLabelAnchor: mO,
  yLabelOffset: gO,
  yLine: pO,
  yNice: JB,
  yPadding: iO,
  yPaddingInner: rO,
  yPaddingOuter: sO,
  yRange: HB,
  yReverse: _O,
  yRound: eO,
  yScale: GB,
  yTickFormat: fO,
  yTickPadding: uO,
  yTickRotate: hO,
  yTickSize: cO,
  yTickSpacing: lO,
  yTicks: aO,
  yZero: xO
}, Symbol.toStringTag, { value: "Module" }));
function jrt(e, t) {
  return { table: e, options: t };
}
const qrt = /* @__PURE__ */ new Set([
  "frame",
  "axisX",
  "axisY",
  "axisFx",
  "axisFy",
  "gridX",
  "gridY",
  "gridFx",
  "gridFy",
  "hexgrid",
  "graticule",
  "sphere"
]);
function St(e, t, n = {}) {
  arguments.length === 2 && !Array.isArray(t) && (n = t, t = qrt.has(e) ? null : [{}]);
  const i = e.startsWith("area") || e.startsWith("line") ? Znt : ha;
  return Gv(i, e, t, n);
}
function Gv(e, t, n, i) {
  return (r) => {
    r.addMark(new e(t, n, i));
  };
}
function ds(e, t, n) {
  return (i) => {
    i.addMark(new e(t, n));
  };
}
const CE = (...e) => St("area", ...e), kE = (...e) => St("areaX", ...e), UE = (...e) => St("areaY", ...e), zE = (...e) => St("line", ...e), PE = (...e) => St("lineX", ...e), VE = (...e) => St("lineY", ...e), jE = (...e) => St("barX", ...e), qE = (...e) => St("barY", ...e), YE = (...e) => St("cell", ...e), WE = (...e) => St("cellX", ...e), GE = (...e) => St("cellY", ...e), XE = (...e) => St("rect", ...e), HE = (...e) => St("rectX", ...e), JE = (...e) => St("rectY", ...e), KE = (...e) => St("dot", ...e), ZE = (...e) => St("dotX", ...e), QE = (...e) => St("dotY", ...e), t5 = (...e) => St("circle", ...e), e5 = (...e) => St("hexagon", ...e), n5 = (...e) => St("text", ...e), i5 = (...e) => St("textX", ...e), r5 = (...e) => St("textY", ...e), s5 = (...e) => St("ruleX", ...e), o5 = (...e) => St("ruleY", ...e), a5 = (...e) => St("tickX", ...e), c5 = (...e) => St("tickY", ...e), l5 = (...e) => St("vector", ...e), u5 = (...e) => St("vectoX", ...e), f5 = (...e) => St("vectorY", ...e), h5 = (...e) => St("spike", ...e), d5 = (...e) => St("image", ...e), p5 = (...e) => Gv(CN, "areaX", ...e), y5 = (...e) => Gv(CN, "areaY", ...e), m5 = (...e) => ds(Cit, ...e), g5 = (...e) => ds(Fit, ...e), b5 = (...e) => ds(_it, ...e), w5 = (...e) => ds(Tit, ...e), v5 = (...e) => ds(zv, ...e), _5 = (...e) => ds(Vit, ...e), x5 = (...e) => ds(Pit, ...e), S5 = (...e) => St("hexgrid", ...e), I5 = (...e) => ds(Kit, ...e), A5 = (...e) => St("voronoi", ...e), M5 = (...e) => St("voronoiMesh", ...e), $5 = (...e) => St("delaunayLink", ...e), T5 = (...e) => St("delaunayMesh", ...e), D5 = (...e) => St("hull", ...e), N5 = (...e) => St("arrow", ...e), B5 = (...e) => St("link", ...e), O5 = (...e) => St("frame", ...e), F5 = (...e) => St("axisX", ...e), E5 = (...e) => St("axisY", ...e), L5 = (...e) => St("axisFx", ...e), R5 = (...e) => St("axisFy", ...e), C5 = (...e) => St("gridX", ...e), k5 = (...e) => St("gridY", ...e), U5 = (...e) => St("gridFx", ...e), z5 = (...e) => St("gridFy", ...e), P5 = (...e) => ds(zit, ...e), V5 = (...e) => St("sphere", ...e), j5 = (...e) => St("graticule", ...e), Yrt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  area: CE,
  areaX: kE,
  areaY: UE,
  arrow: N5,
  axisFx: L5,
  axisFy: R5,
  axisX: F5,
  axisY: E5,
  barX: jE,
  barY: qE,
  cell: YE,
  cellX: WE,
  cellY: GE,
  circle: t5,
  contour: b5,
  delaunayLink: $5,
  delaunayMesh: T5,
  denseLine: g5,
  density: m5,
  densityX: p5,
  densityY: y5,
  dot: KE,
  dotX: ZE,
  dotY: QE,
  frame: O5,
  geo: P5,
  graticule: j5,
  gridFx: U5,
  gridFy: z5,
  gridX: C5,
  gridY: k5,
  heatmap: w5,
  hexagon: e5,
  hexbin: x5,
  hexgrid: S5,
  hull: D5,
  image: d5,
  line: zE,
  lineX: PE,
  lineY: VE,
  link: B5,
  raster: v5,
  rasterTile: _5,
  rect: XE,
  rectX: HE,
  rectY: JE,
  regressionY: I5,
  ruleX: s5,
  ruleY: o5,
  sphere: V5,
  spike: h5,
  text: n5,
  textX: i5,
  textY: r5,
  tickX: a5,
  tickY: c5,
  vector: l5,
  vectorX: u5,
  vectorY: f5,
  voronoi: A5,
  voronoiMesh: M5
}, Symbol.toStringTag, { value: "Module" }));
function fo(e, t) {
  return (n) => {
    const i = n.marks[n.marks.length - 1];
    n.addInteractor(new e(i, t));
  };
}
function q5({ by: e, ...t }) {
  return fo(nrt, { selection: e, channels: t });
}
function Kf({ as: e, ...t }) {
  return fo(PN, { ...t, selection: e });
}
function Y5(e) {
  return Kf({ ...e, channels: ["x"] });
}
function W5(e) {
  return Kf({ ...e, channels: ["y"] });
}
function G5(e) {
  return Kf({ ...e, channels: ["color"] });
}
function X5({ as: e, ...t }) {
  return fo(zN, { ...t, selection: e, channel: "x" });
}
function H5({ as: e, ...t }) {
  return fo(zN, { ...t, selection: e, channel: "y" });
}
function J5({ as: e, ...t }) {
  return fo(UN, { ...t, selection: e, channel: "x" });
}
function K5({ as: e, ...t }) {
  return fo(UN, { ...t, selection: e, channel: "y" });
}
function Z5({ as: e, ...t }) {
  return fo(art, { ...t, selection: e });
}
function pl(e) {
  return fo(lrt, e);
}
function Q5(e = {}) {
  return pl({ ...e, zoom: !1 });
}
function tL(e = {}) {
  return pl({ ...e, zoom: !1, pany: !1 });
}
function eL(e = {}) {
  return pl({ ...e, zoom: !1, panx: !1 });
}
function nL(e = {}) {
  return pl(e);
}
function iL(e = {}) {
  return pl({ ...e, pany: !1 });
}
function rL(e = {}) {
  return pl({ ...e, panx: !1 });
}
const Wrt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  highlight: q5,
  intervalX: J5,
  intervalXY: Z5,
  intervalY: K5,
  nearestX: X5,
  nearestY: H5,
  pan: Q5,
  panX: tL,
  panY: eL,
  panZoom: nL,
  panZoomX: iL,
  panZoomY: rL,
  toggle: Kf,
  toggleColor: G5,
  toggleX: Y5,
  toggleY: W5
}, Symbol.toStringTag, { value: "Module" }));
function Xv(e, t = {}) {
  if (t.for) {
    const { for: n, ...i } = t, r = new tI(e, i), s = typeof n, o = (a) => a.addLegend(r, !1);
    return s === "string" ? Urt(this, n, o) : n.value && o(n.value), r.element;
  } else
    return (n) => n.addLegend(new tI(e, t));
}
function sL(e) {
  return Xv.call(this, "color", e);
}
function oL(e) {
  return Xv.call(this, "opacity", e);
}
function aL(e) {
  return Xv.call(this, "symbol", e);
}
const Grt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  colorLegend: sL,
  opacityLegend: oL,
  symbolLegend: aL
}, Symbol.toStringTag, { value: "Module" }));
function Xrt(...e) {
  const t = new qnt();
  return e.flat().forEach((n) => n(t)), qN(this, ...t.marks), t.element;
}
const Hrt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  Fixed: gf,
  Param: Uo,
  Query: Et,
  Selection: Jd,
  agg: L9,
  align: oB,
  and: js,
  area: CE,
  areaX: kE,
  areaY: UE,
  argmax: Ng,
  argmin: Dg,
  arrayAgg: cU,
  arrow: N5,
  aspectRatio: aB,
  avg: k9,
  axis: cB,
  axisFx: L5,
  axisFy: R5,
  axisX: F5,
  axisY: E5,
  barX: jE,
  barY: qE,
  bin: mrt,
  cast: Lb,
  castDouble: Bg,
  castInteger: lU,
  cell: YE,
  cellX: WE,
  cellY: GE,
  centroid: Rb,
  centroidX: mU,
  centroidY: gU,
  circle: t5,
  colorBase: GF,
  colorClamp: RF,
  colorConstant: HF,
  colorDomain: EF,
  colorExponent: XF,
  colorInterpolate: zF,
  colorLabel: jF,
  colorLegend: sL,
  colorN: CF,
  colorNice: kF,
  colorPivot: PF,
  colorRange: LF,
  colorReverse: qF,
  colorScale: FF,
  colorScheme: UF,
  colorSymmetric: VF,
  colorTickFormat: WF,
  colorZero: YF,
  column: Vy,
  contour: b5,
  coordinator: Yr,
  corr: K9,
  count: ko,
  covarPop: Z9,
  create: mf,
  cume_dist: T9,
  dateDay: dU,
  dateMonth: fU,
  dateMonthDay: hU,
  delaunayLink: $5,
  delaunayMesh: T5,
  denseLine: g5,
  dense_rank: M9,
  density: m5,
  densityX: p5,
  densityY: y5,
  dot: KE,
  dotX: ZE,
  dotY: QE,
  entropy: X9,
  eq: qy,
  facetGrid: BO,
  facetLabel: OO,
  facetMargin: MO,
  facetMarginBottom: TO,
  facetMarginLeft: DO,
  facetMarginRight: NO,
  facetMarginTop: $O,
  first: sU,
  first_value: O9,
  frame: O5,
  from: jrt,
  fxAlign: zO,
  fxAriaDescription: rF,
  fxAriaLabel: iF,
  fxAxis: qO,
  fxDomain: FO,
  fxFontVariant: nF,
  fxGrid: KO,
  fxInset: RO,
  fxInsetLeft: CO,
  fxInsetRight: kO,
  fxLabel: QO,
  fxLabelAnchor: tF,
  fxLabelOffset: eF,
  fxLine: ZO,
  fxNice: LO,
  fxPadding: PO,
  fxPaddingInner: VO,
  fxPaddingOuter: jO,
  fxRange: EO,
  fxReverse: sF,
  fxRound: UO,
  fxTickFormat: HO,
  fxTickPadding: XO,
  fxTickRotate: JO,
  fxTickSize: WO,
  fxTickSpacing: GO,
  fxTicks: YO,
  fyAlign: dF,
  fyAriaDescription: BF,
  fyAriaLabel: NF,
  fyAxis: gF,
  fyDomain: oF,
  fyFontVariant: DF,
  fyGrid: IF,
  fyInset: lF,
  fyInsetBottom: fF,
  fyInsetTop: uF,
  fyLabel: MF,
  fyLabelAnchor: $F,
  fyLabelOffset: TF,
  fyLine: AF,
  fyNice: cF,
  fyPadding: pF,
  fyPaddingInner: yF,
  fyPaddingOuter: mF,
  fyRange: aF,
  fyReverse: OF,
  fyRound: hF,
  fyTickFormat: xF,
  fyTickPadding: _F,
  fyTickRotate: SF,
  fyTickSize: wF,
  fyTickSpacing: vF,
  fyTicks: bF,
  geo: P5,
  geojson: WM,
  graticule: j5,
  grid: uB,
  gridFx: U5,
  gridFy: z5,
  gridX: C5,
  gridY: k5,
  gt: jM,
  gte: g9,
  hconcat: Rrt,
  heatmap: w5,
  height: eB,
  hexagon: e5,
  hexbin: x5,
  hexgrid: S5,
  highlight: q5,
  hspace: krt,
  hull: D5,
  image: d5,
  inset: lB,
  intervalX: J5,
  intervalXY: Z5,
  intervalY: K5,
  isBetween: Tn,
  isDistinct: b9,
  isNotBetween: w9,
  isNotDistinct: qM,
  isNotNull: Tu,
  isNull: Fb,
  kurtosis: G9,
  label: fB,
  lag: N9,
  last: oU,
  last_value: F9,
  lead: B9,
  lengthBase: SE,
  lengthClamp: vE,
  lengthConstant: AE,
  lengthDomain: bE,
  lengthExponent: IE,
  lengthNice: _E,
  lengthRange: wE,
  lengthScale: gE,
  lengthZero: xE,
  line: zE,
  lineX: PE,
  lineY: VE,
  link: B5,
  literal: Qc,
  loadCSV: $U,
  loadExtension: XM,
  loadJSON: TU,
  loadObjects: BU,
  loadParquet: DU,
  loadSpatial: NU,
  lt: Du,
  lte: Nu,
  mad: U9,
  margin: KN,
  marginBottom: sB,
  marginLeft: nB,
  marginRight: iB,
  marginTop: rB,
  margins: JN,
  max: Mc,
  median: P9,
  menu: Brt,
  min: $c,
  mode: j9,
  name: XN,
  nearestX: X5,
  nearestY: H5,
  neq: Eb,
  not: m9,
  nth_value: E9,
  ntile: D9,
  opacityBase: sE,
  opacityClamp: QF,
  opacityConstant: aE,
  opacityDomain: KF,
  opacityExponent: oE,
  opacityLabel: eE,
  opacityLegend: oL,
  opacityNice: tE,
  opacityRange: ZF,
  opacityReverse: nE,
  opacityScale: JF,
  opacityTickFormat: rE,
  opacityZero: iE,
  or: Ob,
  padding: hB,
  pan: Q5,
  panX: tL,
  panY: eL,
  panZoom: nL,
  panZoomX: iL,
  panZoomY: rL,
  percent_rank: $9,
  plot: Xrt,
  product: z9,
  projectionClip: RE,
  projectionDomain: NE,
  projectionInset: BE,
  projectionInsetBottom: LE,
  projectionInsetLeft: OE,
  projectionInsetRight: FE,
  projectionInsetTop: EE,
  projectionParallels: $E,
  projectionPrecision: TE,
  projectionRotate: DE,
  projectionType: ME,
  quantile: V9,
  rBase: pE,
  rClamp: fE,
  rConstant: mE,
  rDomain: lE,
  rExponent: yE,
  rNice: hE,
  rRange: uE,
  rScale: cE,
  rZero: dE,
  rank: A9,
  raster: v5,
  rasterTile: _5,
  rect: XE,
  rectX: HE,
  rectY: JE,
  regressionY: I5,
  round: dB,
  row_number: I9,
  ruleX: s5,
  ruleY: o5,
  search: Ort,
  skewness: W9,
  slider: Frt,
  sphere: V5,
  spike: h5,
  sql: q,
  stddev: Y9,
  stddevPop: J9,
  stringAgg: aU,
  style: QN,
  sum: oa,
  symbolLegend: aL,
  table: Ert,
  text: n5,
  textX: i5,
  textY: r5,
  tickX: a5,
  tickY: c5,
  toggle: Kf,
  toggleColor: G5,
  toggleX: Y5,
  toggleY: W5,
  varPop: H9,
  variance: q9,
  vconcat: Lrt,
  vector: l5,
  vectorX: u5,
  vectorY: f5,
  voronoi: A5,
  voronoiMesh: M5,
  vspace: Crt,
  width: tB,
  xAlign: SB,
  xAriaDescription: PB,
  xAriaLabel: zB,
  xAxis: $B,
  xBase: qB,
  xClamp: _B,
  xConstant: WB,
  xDomain: yB,
  xExponent: YB,
  xFontVariant: UB,
  xGrid: EB,
  xInset: bB,
  xInsetLeft: wB,
  xInsetRight: vB,
  xLabel: RB,
  xLabelAnchor: CB,
  xLabelOffset: kB,
  xLine: LB,
  xNice: gB,
  xPadding: IB,
  xPaddingInner: AB,
  xPaddingOuter: MB,
  xRange: mB,
  xReverse: VB,
  xRound: xB,
  xScale: pB,
  xTickFormat: OB,
  xTickPadding: BB,
  xTickRotate: FB,
  xTickSize: DB,
  xTickSpacing: NB,
  xTicks: TB,
  xZero: jB,
  xyDomain: ZN,
  yAlign: nO,
  yAriaDescription: vO,
  yAriaLabel: wO,
  yAxis: oO,
  yBase: SO,
  yClamp: tO,
  yConstant: AO,
  yDomain: XB,
  yExponent: IO,
  yFontVariant: bO,
  yGrid: dO,
  yInset: KB,
  yInsetBottom: QB,
  yInsetTop: ZB,
  yLabel: yO,
  yLabelAnchor: mO,
  yLabelOffset: gO,
  yLine: pO,
  yNice: JB,
  yPadding: iO,
  yPaddingInner: rO,
  yPaddingOuter: sO,
  yRange: HB,
  yReverse: _O,
  yRound: eO,
  yScale: GB,
  yTickFormat: fO,
  yTickPadding: uO,
  yTickRotate: hO,
  yTickSize: cO,
  yTickSpacing: lO,
  yTicks: aO,
  yZero: xO
}, Symbol.toStringTag, { value: "Module" }));
function Jrt({
  coordinator: e = Yr(),
  namedPlots: t = new GN(),
  extensions: n = null,
  ...i
} = {}) {
  return {
    ...Hrt,
    ...n,
    context: {
      coordinator: e,
      namedPlots: t,
      ...i
    }
  };
}
const Krt = "spec", cL = "literal", Zrt = "options", Qrt = "selection", tst = "paramref", est = "param", lL = "select", Q1 = "value", nst = "crossfilter", uL = "intersect", ist = "union", rst = "single", sst = "data", ost = "expression", gc = "sql", Wo = "agg", Hv = "input", ry = "hconcat", sy = "vconcat", oy = "hspace", ay = "vspace", fL = "mark", eI = "from", cy = "plot", Jv = "legend", ast = "attribute", cst = "transform", lst = "interactor", ud = "Fixed";
class Oe {
  constructor(t, n = null) {
    this.type = t, this.children = n;
  }
  instantiate() {
    throw Error("instantiate not implemented");
  }
  codegen() {
    return Error("codegen not implemented");
  }
  toJSON() {
    return Error("toJSON not implemented");
  }
}
class ust extends Oe {
  constructor(t, n, i, r, s, o) {
    super(Krt, [t]), this.root = t, this.meta = n, this.config = i, this.data = r, this.params = s, this.plotDefaults = o;
  }
  toJSON() {
    const { root: t, meta: n, config: i, plotDefaults: r } = this, s = new Map(Object.entries(this.data)), o = new Map(Object.entries(this.params)), a = {};
    if (n && (a.meta = { ...n }), i && (a.config = { ...i }), s != null && s.size) {
      const c = a.data = {};
      for (const [l, u] of s)
        c[l] = u.toJSON();
    }
    if (o != null && o.size) {
      const c = a.params = {};
      for (const [l, u] of o)
        c[l] = u.toJSON();
    }
    if (r != null && r.length) {
      const c = a.plotDefaults = {};
      for (const l of r)
        Object.assign(c, l.toJSON());
    }
    return Object.assign(a, t.toJSON());
  }
}
function fst(e) {
  const t = typeof e;
  return t === "object" ? e == null ? void 0 : e.param : t === "string" ? hst(e) : null;
}
function hst(e) {
  return (e == null ? void 0 : e[0]) === "$" ? e.slice(1) : null;
}
function nI(e) {
  return `$${e}`;
}
function dst(e) {
  return [e].flat();
}
function Go(e) {
  return Array.isArray(e);
}
function hL(e) {
  return e !== null && typeof e == "object" && !Go(e);
}
function bu(e) {
  return typeof e == "string";
}
function dL(e, t) {
  throw Object.assign(Error(e), { data: t });
}
function ps(e, t) {
  const n = {};
  for (const i in e)
    n[i] = t.maybeSelection(e[i]);
  return new X0(n);
}
class X0 extends Oe {
  constructor(t) {
    super(Zrt), this.options = t;
  }
  filter(t) {
    const n = Object.fromEntries(
      Object.entries(this.options).filter(([i, r]) => t(i, r))
    );
    return new X0(n);
  }
  instantiate(t) {
    const { options: n } = this, i = {};
    for (const r in n)
      i[r] = n[r].instantiate(t);
    return i;
  }
  codegen(t) {
    const { options: n } = this, i = [];
    for (const r in n)
      i.push(`${r}: ${n[r].codegen(t)}`);
    return i.length ? `{${t.maybeLineWrap(i)}}` : "";
  }
  toJSON() {
    const { options: t } = this, n = {};
    for (const i in t)
      n[i] = t[i].toJSON();
    return n;
  }
}
const pL = "table", yL = "parquet", mL = "csv", Kv = "json", Zv = "spatial", iI = /* @__PURE__ */ new Map([
  [pL, yst],
  [yL, mst],
  [mL, gst],
  [Kv, bst],
  [Zv, wst]
]);
function pst(e, t, n) {
  if (t = vst(t), iI.has(t.type))
    return iI.get(t.type)(e, t, n);
  n.error("Unrecognized data format type.", t);
}
function yst(e, t, n) {
  const { query: i, type: r, ...s } = t;
  return new Ast(e, i, ps(s, n));
}
function mst(e, t, n) {
  const { file: i, type: r, ...s } = t;
  return new $st(e, i, ps(s, n));
}
function gst(e, t, n) {
  const { file: i, type: r, ...s } = t;
  return new Tst(e, i, ps(s, n));
}
function bst(e, t, n) {
  const { data: i, file: r, type: s, ...o } = t, a = ps(o, n);
  return i ? new Nst(e, i, a) : new Dst(e, r, a);
}
function wst(e, t, n) {
  const { file: i, type: r, ...s } = t;
  return new Mst(e, i, ps(s, n));
}
function vst(e) {
  return Go(e) && (e = { type: "json", data: e }), bu(e) && (e = { type: "table", query: e }), { ...e, type: _st(e) };
}
function _st(e) {
  return e.type || xst(e.file) || "table";
}
function xst(e) {
  const t = e == null ? void 0 : e.lastIndexOf(".");
  return t > 0 ? e.slice(t + 1) : null;
}
function rI(e, t) {
  return t ? new URL(e, t).toString() : e;
}
function Sst(e, t) {
  const n = e == null ? void 0 : e.codegen(t);
  return n ? `, ${n}` : "";
}
class Ist extends Oe {
  constructor(t, n) {
    super(sst), this.name = t, this.format = n;
  }
}
class Qv extends Ist {
  constructor(t, n) {
    super(t, n);
  }
  instantiateQuery(t) {
    t.error("instantiateQuery not implemented");
  }
  codegenQuery(t) {
    t.error("codegenQuery not implemented");
  }
  instantiate(t) {
    const n = this.instantiateQuery(t);
    if (n)
      return n;
  }
  codegen(t) {
    const n = this.codegenQuery(t);
    if (n)
      return n;
  }
}
class Ast extends Qv {
  constructor(t, n, i) {
    super(t, pL), this.query = n == null ? void 0 : n.trim(), this.options = i;
  }
  instantiateQuery(t) {
    const { name: n, query: i, options: r } = this;
    if (i)
      return t.api.create(n, i, r.instantiate(t));
  }
  codegenQuery(t) {
    const { name: n, query: i, options: r } = this;
    if (i)
      return `\`${mf(n, i, r.instantiate(t))}\``;
  }
  toJSON() {
    const { format: t, query: n, options: i } = this;
    return { type: t, query: n, ...i.toJSON() };
  }
}
class H0 extends Qv {
  constructor(t, n, i, r, s) {
    super(t, n), this.file = r, this.method = i, this.options = s;
  }
  instantiateQuery(t) {
    const { name: n, method: i, file: r, options: s } = this, o = rI(r, t.baseURL), a = s == null ? void 0 : s.instantiate(t);
    return t.api[i](n, o, a);
  }
  codegenQuery(t) {
    const { name: n, method: i, file: r, options: s } = this, o = rI(r, t.baseURL), a = Sst(s, t);
    return `${t.ns()}${i}("${n}", "${o}"${a})`;
  }
  toJSON() {
    const { format: t, file: n, options: i } = this;
    return { type: t, file: n, ...i.toJSON() };
  }
}
class Mst extends H0 {
  constructor(t, n, i) {
    super(t, Zv, "loadSpatial", n, i);
  }
}
class $st extends H0 {
  constructor(t, n, i) {
    super(t, yL, "loadParquet", n, i);
  }
}
class Tst extends H0 {
  constructor(t, n, i) {
    super(t, mL, "loadCSV", n, i);
  }
}
class Dst extends H0 {
  constructor(t, n, i) {
    super(t, Kv, "loadJSON", n, i);
  }
}
class Nst extends Qv {
  constructor(t, n, i) {
    super(t, Kv), this.data = n, this.options = i;
  }
  instantiateQuery(t) {
    const { name: n, data: i, options: r } = this;
    return t.api.loadObjects(n, i, r.instantiate(t));
  }
  codegenQuery(t) {
    const { name: n, data: i, options: r } = this, s = r ? "," + r.codegen(t) : "", o = `[
    ` + i.map((a) => JSON.stringify(a)).join(`,
    `) + `
  ]`;
    return `${t.ns()}loadObjects("${n}", ${o}${s})`;
  }
  toJSON() {
    const { format: t, data: n, options: i } = this;
    return { type: t, data: n, ...i.toJSON() };
  }
}
function Bst(e) {
  var i;
  const t = (i = e.config) == null ? void 0 : i.extensions, n = new Set(t ? dst(t) : []);
  for (const r of Object.values(e.data))
    r.format === Zv && n.add("spatial");
  return n;
}
async function Ost(e, t) {
  const { data: n, params: i, plotDefaults: r } = e, s = new Fst({ plotDefaults: r, ...t }), o = [], a = Bst(e);
  o.push(...Array.from(a).map((c) => XM(c)));
  for (const c of Object.values(n)) {
    const l = c.instantiate(s);
    l && o.push(l);
  }
  o.length > 0 && await s.coordinator.exec(o);
  for (const [c, l] of Object.entries(i)) {
    const u = l.instantiate(s);
    s.activeParams.set(c, u);
  }
  return {
    element: e.root.instantiate(s),
    params: s.activeParams
  };
}
class Fst {
  constructor({
    api: t = Jrt(),
    plotDefaults: n = [],
    activeParams: i = /* @__PURE__ */ new Map(),
    baseURL: r = null
  } = {}) {
    this.api = t, this.plotDefaults = n, this.activeParams = i, this.baseURL = r, this.coordinator = t.context.coordinator;
  }
  error(t, n) {
    dL(t, n);
  }
}
class gL extends Oe {
  constructor(t) {
    super(cL), this.value = t;
  }
  instantiate() {
    return this.value;
  }
  codegen(t) {
    return t.stringify(this.value);
  }
  toJSON() {
    return this.value;
  }
}
class bL extends Oe {
  constructor(t = uL, n) {
    super(Qrt), this.select = t, this.cross = n;
  }
  instantiate(t) {
    const { select: n, cross: i } = this;
    return t.api.Selection[n]({ cross: i });
  }
  codegen(t) {
    const { select: n, cross: i } = this, r = i != null ? `{ cross: ${i} }` : "";
    return `${t.ns()}Selection.${n}(${r})`;
  }
  toJSON() {
    const { select: t, cross: n } = this;
    return { select: t, cross: n };
  }
}
const Est = /* @__PURE__ */ new Set([Q1, rst, nst, uL, ist]);
function Lst(e, t) {
  const n = hL(e) ? e : { value: e }, { select: i = Q1, cross: r, date: s, value: o } = n;
  return Est.has(i) || t.error(`Unrecognized param type: ${i}`, n), i !== Q1 ? new bL(i, r) : Go(o) ? new tb(o.map((a) => t.maybeParam(a))) : new tb(o, s);
}
class tb extends Oe {
  constructor(t, n) {
    super(est), this.value = t, this.date = n;
  }
  instantiate(t) {
    const { date: n, value: i } = this, { Param: r } = t.api;
    return Go(i) ? r.array(i.map((s) => s.instantiate(t))) : r.value(_w(n, i));
  }
  codegen(t) {
    const { value: n, date: i } = this, r = `${t.ns()}Param.`;
    return Go(n) ? `${r}array([${n.map((s) => s.codegen(t)).join(", ")}])` : i ? `${r}value(new Date(${JSON.stringify(i)}))` : `${r}value(${JSON.stringify(n)})`;
  }
  toJSON() {
    const { date: t, value: n } = this;
    return Go(n) ? n.map((i) => i.toJSON()) : t ? { date: t } : n;
  }
}
class Rst extends Oe {
  constructor(t) {
    super(tst), this.name = t;
  }
  instantiate(t) {
    var n;
    return (n = t.activeParams) == null ? void 0 : n.get(this.name);
  }
  codegen() {
    return nI(this.name);
  }
  toJSON() {
    return nI(this.name);
  }
}
function wL(e, t, n) {
  var i, r;
  return (r = (i = n.plot) == null ? void 0 : i.attributes) != null && r.has(e) || n.error(`Unrecognized attribute: ${e}`), new Cst(
    e,
    t === ud ? new kst() : n.maybeParam(t)
  );
}
class Cst extends Oe {
  constructor(t, n) {
    super(ast), this.name = t, this.value = n;
  }
  instantiate(t) {
    const { name: n, value: i } = this, r = t.api[n];
    return r(i.instantiate(t));
  }
  codegen(t) {
    const { name: n, value: i } = this;
    return `${t.tab()}${t.ns()}${n}(${i.codegen(t)})`;
  }
  toJSON() {
    const { name: t, value: n } = this;
    return { [t]: n.toJSON() };
  }
}
class kst extends Oe {
  constructor() {
    super(cL), this.value = ud;
  }
  instantiate(t) {
    return t.api[ud];
  }
  codegen(t) {
    return `${t.ns()}${ud}`;
  }
  toJSON() {
    return this.value;
  }
}
function Ust(e, t) {
  const n = e[ry].map((i) => t.parseComponent(i));
  return new zst(n);
}
class zst extends Oe {
  constructor(t) {
    super(ry, t);
  }
  instantiate(t) {
    return t.api[ry](this.children.map((n) => n.instantiate(t)));
  }
  codegen(t) {
    t.indent();
    const n = this.children.map((i) => i.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 Pst(e) {
  return new Vst(e[oy]);
}
class Vst extends Oe {
  constructor(t) {
    super(oy), this.value = t;
  }
  instantiate(t) {
    return t.api[oy](this.value);
  }
  codegen(t) {
    return `${t.tab()}${t.ns()}${this.type}(${this.value})`;
  }
  toJSON() {
    return { [this.type]: this.value };
  }
}
function jst(e, t) {
  var r;
  const { [Hv]: n, ...i } = e;
  return (r = t.inputs) != null && r.has(n) || t.error(`Unrecognized input type: ${n}`, e), new qst(n, ps(i, t));
}
class qst extends Oe {
  constructor(t, n) {
    super(Hv), this.name = t, this.options = n;
  }
  instantiate(t) {
    const n = t.api[this.name];
    return n(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: i } = this;
    return { [t]: n, ...i.toJSON() };
  }
}
function vL(e, t) {
  var s, o;
  const { [Jv]: n, ...i } = e, r = `${n}Legend`;
  return (o = (s = t.plot) == null ? void 0 : s.legends) != null && o.has(r) || t.error(`Unrecognized legend type: ${n}`, e), new Yst(r, n, ps(i, t));
}
class Yst extends Oe {
  constructor(t, n, i) {
    super(Jv), this.key = t, this.name = n, this.options = i;
  }
  instantiate(t) {
    const n = t.api[this.key];
    return n(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: i } = this;
    return { [t]: n, ...i.toJSON() };
  }
}
function Wst(e, t) {
  var r, s;
  const { [lL]: n, ...i } = e;
  return (s = (r = t.plot) == null ? void 0 : r.interactors) != null && s.has(n) || t.error(`Unrecognized interactor type: ${n}`, e), new Gst(n, ps(i, t));
}
class Gst extends Oe {
  constructor(t, n) {
    super(lst), this.name = t, this.options = n;
  }
  instantiate(t) {
    const n = t.api[this.name];
    return n(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 { [lL]: t, ...n.toJSON() };
  }
}
function Xst(e, t) {
  const { label: n } = e, i = e[gc] ? gc : e[Wo] ? Wo : t.error("Unrecognized expression type", e), r = e[i], s = r.split(/(\\'|\\"|"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|\$\w+)/g), o = [""], a = [];
  for (let c = 0, l = 0; c < s.length; ++c) {
    const u = s[c];
    u.startsWith("$") ? (a[l] = t.maybeParam(u), o[++l] = "") : o[l] += u;
  }
  return new Hst(r, o, a, n, i === Wo);
}
class Hst extends Oe {
  constructor(t, n, i, r, s) {
    super(ost), this.value = t, this.spans = n, this.params = i, this.label = r, this.aggregate = s;
  }
  instantiate(t) {
    const { spans: n, params: i, label: r, aggregate: s } = this, o = t.api[s ? Wo : gc], a = i.map((c) => c.instantiate(t));
    return o(n, ...a).annotate({ label: r });
  }
  codegen(t) {
    const { spans: n, params: i, label: r, aggregate: s } = this, o = s ? Wo : gc;
    let a = "";
    const c = i.length;
    for (let l = 0; l < c; ++l)
      a += n[l] + "${" + i[l].codegen(t) + "}";
    return a += n[c], `${t.ns()}${o}\`${a}\`` + (r ? `.annotate({ label: ${JSON.stringify(r)} })` : "");
  }
  toJSON() {
    return { [this.aggregate ? Wo : gc]: this.value };
  }
}
function Jst(e, t) {
  if (!e)
    return null;
  if (Go(e))
    return new gL(e);
  const { from: n, ...i } = e;
  return new Kst(n, ps(i, t));
}
class Kst extends Oe {
  constructor(t, n) {
    super(eI), this.table = t, this.options = n;
  }
  instantiate(t) {
    const { table: n, options: i } = this;
    return t.api[eI](n, i.instantiate(t));
  }
  codegen(t) {
    const { type: n, table: i, options: r } = this, s = r.codegen(t);
    return `${t.ns()}${n}("${i}"${s ? ", " + s : ""})`;
  }
  toJSON() {
    const { type: t, table: n, options: i } = this;
    return { [t]: n, ...i.toJSON() };
  }
}
function og(e) {
  return e == null ? [] : [e].flat();
}
function Zst(e, t) {
  let n;
  for (const s in e)
    t.transforms.has(s) && (n = s);
  if (!n)
    return;
  const i = n === "count" || n == null ? [] : og(e[n]), r = {
    distinct: e.distinct,
    orderby: og(e.orderby).map((s) => t.maybeParam(s)),
    partitionby: og(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 Qst(n, i, r);
}
class Qst extends Oe {
  constructor(t, n, i) {
    super(cst), this.name = t, this.args = n, this.options = i;
  }
  instantiate(t) {
    const { name: n, args: i, options: r } = this, { distinct: s, orderby: o, partitionby: a, rows: c, range: l } = r, u = t.api[n];
    let f = u(...i);
    return s && (f = f.distinct()), o.length && (f = f.orderby(o.map((h) => h.instantiate(t)))), a.length && (f = f.partitionby(a.map((h) => h.instantiate(t)))), c != null ? f = f.rows(c.instantiate(t)) : l != null && (f = f.range(l.instantiate(t))), f;
  }
  codegen(t) {
    const { name: n, args: i, options: r } = this, { distinct: s, orderby: o, partitionby: a, rows: c, range: l } = r;
    let u = `${t.ns()}${n}(` + i.map((f) => JSON.stringify(f)).join(", ") + ")";
    if (s && (u += ".distinct()"), o.length) {
      const f = o.map((h) => h.codegen(t));
      u += `.orderby(${f.join(", ")})`;
    }
    if (a.length) {
      const f = a.map((h) => h.codegen(t));
      u += `.partitionby(${f.join(", ")})`;
    }
    return c ? u += `.rows(${c.codegen(t)})` : l && (u += `.range(${l.codegen(t)})`), u;
  }
  toJSON() {
    const { name: t, args: n, options: i } = this, { distinct: r, orderby: s, partitionby: o, rows: a, range: c } = i, l = { [t]: ag(n) };
    return r && (l.distinct = !0), s.length && (l.orderby = ag(s.map((u) => u.toJSON()))), o.length && (l.partitionby = ag(o.map((u) => u.toJSON()))), a ? l.rows = a.toJSON() : c && (l.range = c.toJSON()), l;
  }
}
function ag(e) {
  return e.length === 0 ? "" : e.length === 1 ? e[0] : e;
}
function tot(e, t) {
  if (hL(e))
    return e[gc] || e[Wo] ? Xst(e, t) : Zst(e, t);
}
function eot(e, t) {
  var a, c;
  const { mark: n, data: i, ...r } = e;
  (c = (a = t.plot) == null ? void 0 : a.marks) != null && c.has(n) || t.error(`Unrecognized mark type: ${n}`, e);
  const s = Jst(i, t), o = {};
  for (const l in r) {
    const u = r[l];
    o[l] = tot(u, t) || t.maybeParam(u);
  }
  return new not(n, s, new X0(o));
}
class not extends Oe {
  constructor(t, n, i) {
    super(fL), this.name = t, this.data = n, this.options = i;
  }
  instantiate(t) {
    const { name: n, data: i, options: r } = this, s = t.api[n], o = r.instantiate(t);
    return i ? s(i.instantiate(t), o) : s(o);
  }
  codegen(t) {
    const { name: n, data: i, options: r } = this, s = i ? i.codegen(t) : "", o = r.codegen(t);
    let a;
    if (s && o) {
      t.indent();
      const c = r.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: i, options: r } = this;
    return {
      [t]: n,
      ...i ? { data: i.toJSON() } : {},
      ...r.toJSON()
    };
  }
}
function iot(e, t) {
  return _L({ plot: [e] }, t);
}
function _L(e, t) {
  const { [cy]: n, ...i } = e, r = Object.entries(i).map(([o, a]) => wL(o, a, t)), s = n.map((o) => bu(o.mark) ? eot(o, t) : bu(o.legend) ? vL(o, t) : bu(o.select) ? Wst(o, t) : t.error("Invalid plot entry.", o));
  return new rot(s, r);
}
class rot extends Oe {
  constructor(t, n) {
    super(cy, t), this.attributes = n;
  }
  instantiate(t) {
    const n = [
      ...t.plotDefaults || [],
      ...this.attributes || []
    ];
    return t.api[cy](
      this.children.map((i) => i.instantiate(t)),
      n.map((i) => i.instantiate(t))
    );
  }
  codegen(t) {
    var o;
    const { type: n, children: i, attributes: r } = this;
    t.indent();
    const s = [
      ...i.map((a) => a.codegen(t)),
      ...(o = t.plotDefaults) != null && o.length ? [`${t.tab()}...defaultAttributes`] : [],
      ...r.map((a) => a.codegen(t))
    ].join(`,
`);
    return t.undent(), `${t.tab()}${t.ns()}${n}(
${s}
${t.tab()})`;
  }
  toJSON() {
    const { type: t, children: n, attributes: i } = this, r = { [t]: n.map((s) => s.toJSON()) };
    for (const s of i)
      Object.assign(r, s.toJSON());
    return r;
  }
}
function sot(e, t) {
  const n = e[sy].map((i) => t.parseComponent(i));
  return new oot(n);
}
class oot extends Oe {
  constructor(t) {
    super(sy, t);
  }
  instantiate(t) {
    return t.api[sy](this.children.map((n) => n.instantiate(t)));
  }
  codegen(t) {
    t.indent();
    const n = this.children.map((i) => i.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 aot(e) {
  return new cot(e[ay]);
}
class cot extends Oe {
  constructor(t) {
    super(ay), this.value = t;
  }
  instantiate(t) {
    return t.api[ay](this.value);
  }
  codegen(t) {
    return `${t.tab()}${t.ns()}${this.type}(${this.value})`;
  }
  toJSON() {
    return { [this.type]: this.value };
  }
}
function lot(e = []) {
  return new Map([
    [cy, _L],
    [fL, iot],
    [Jv, vL],
    [Hv, jst],
    [ry, Ust],
    [sy, sot],
    [oy, Pst],
    [ay, aot],
    ...e
  ]);
}
function uot(e = []) {
  return /* @__PURE__ */ new Set([
    "menu",
    "search",
    "slider",
    "table",
    ...e
  ]);
}
function fot({
  attributes: e = hot(),
  interactors: t = dot(),
  legends: n = pot(),
  marks: i = yot()
} = {}) {
  return { attributes: e, interactors: t, legends: n, marks: i };
}
function hot(e = []) {
  return /* @__PURE__ */ new Set([
    ...Object.keys(Vrt),
    ...e
  ]);
}
function dot(e = []) {
  return /* @__PURE__ */ new Set([
    ...Object.keys(Wrt),
    ...e
  ]);
}
function pot(e = []) {
  return /* @__PURE__ */ new Set([
    ...Object.keys(Grt),
    ...e
  ]);
}
function yot(e = []) {
  return /* @__PURE__ */ new Set([
    ...Object.keys(Yrt),
    ...e
  ]);
}
function mot(e = []) {
  return /* @__PURE__ */ new Set([
    "argmin",
    "argmax",
    "avg",
    "bin",
    "centroid",
    "centroidX",
    "centroidY",
    "count",
    "dateMonth",
    "dateMonthDay",
    "dateDay",
    "first",
    "geojson",
    "last",
    "max",
    "median",
    "min",
    "mode",
    "product",
    "quantile",
    "sum",
    "row_number",
    "rank",
    "dense_rank",
    "percent_rank",
    "cume_dist",
    "ntile",
    "lag",
    "lead",
    "first_value",
    "last_value",
    "nth_value",
    ...e
  ]);
}
function got(e, t) {
  return e = bu(e) ? JSON.parse(e) : e, new bot(t).parse(e);
}
class bot {
  constructor({
    components: t = lot(),
    transforms: n = mot(),
    inputs: i = uot(),
    plot: r = fot(),
    params: s = [],
    datasets: o = []
  } = {}) {
    this.components = t, this.transforms = n, this.inputs = i, this.plot = r, this.params = new Map(s), this.datasets = new Map(o);
  }
  parse(t) {
    const {
      meta: n,
      config: i,
      data: r = {},
      params: s,
      plotDefaults: o = {},
      ...a
    } = t;
    for (const c in r)
      this.datasets.set(c, pst(c, r[c], this));
    this.plotDefaults = Object.entries(o).map(([c, l]) => wL(c, l, this));
    for (const c in s)
      this.params.set(c, Lst(s[c], this));
    return new ust(
      this.parseComponent(a),
      n ? { ...n } : void 0,
      i ? { ...i } : void 0,
      Object.fromEntries(this.datasets),
      Object.fromEntries(this.params),
      this.plotDefaults
    );
  }
  parseComponent(t) {
    for (const [n, i] of this.components)
      if (t[n] != null)
        return i(t, this);
    this.error("Invalid specification.", t);
  }
  maybeParam(t, n = () => new tb()) {
    const { params: i } = this, r = fst(t);
    if (r) {
      if (!i.has(r)) {
        const s = n();
        i.set(r, s);
      }
      return new Rst(r);
    }
    return new gL(t);
  }
  maybeSelection(t) {
    return this.maybeParam(t, () => new bL());
  }
  error(t, n) {
    dL(t, n);
  }
}
const wot = new TextDecoder("utf-8"), eb = (e) => wot.decode(e), vot = new TextEncoder(), t_ = (e) => vot.encode(e), _ot = (e) => typeof e == "number", xot = (e) => typeof e == "boolean", an = (e) => typeof e == "function", Bi = (e) => e != null && Object(e) === e, tf = (e) => Bi(e) && an(e.then), J0 = (e) => Bi(e) && an(e[Symbol.iterator]), e_ = (e) => Bi(e) && an(e[Symbol.asyncIterator]), nb = (e) => Bi(e) && Bi(e.schema), xL = (e) => Bi(e) && "done" in e && "value" in e, SL = (e) => Bi(e) && an(e.stat) && _ot(e.fd), IL = (e) => Bi(e) && n_(e.body), AL = (e) => "_getDOMStream" in e && "_getNodeStream" in e, n_ = (e) => Bi(e) && an(e.cancel) && an(e.getReader) && !AL(e), ML = (e) => Bi(e) && an(e.read) && an(e.pipe) && xot(e.readable) && !AL(e), Sot = (e) => Bi(e) && an(e.clear) && an(e.bytes) && an(e.position) && an(e.setPosition) && an(e.capacity) && an(e.getBufferIdentifier) && an(e.createLong), i_ = typeof SharedArrayBuffer < "u" ? SharedArrayBuffer : ArrayBuffer;
function Iot(e) {
  const t = e[0] ? [e[0]] : [];
  let n, i, r, s;
  for (let o, a, c = 0, l = 0, u = e.length; ++c < u; ) {
    if (o = t[l], a = e[c], !o || !a || o.buffer !== a.buffer || a.byteOffset < o.byteOffset) {
      a && (t[++l] = a);
      continue;
    }
    if ({ byteOffset: n, byteLength: r } = o, { byteOffset: i, byteLength: s } = a, n + r < i || i + s < n) {
      a && (t[++l] = a);
      continue;
    }
    t[l] = new Uint8Array(o.buffer, n, i - n + s);
  }
  return t;
}
function sI(e, t, n = 0, i = t.byteLength) {
  const r = e.byteLength, s = new Uint8Array(e.buffer, e.byteOffset, r), o = new Uint8Array(t.buffer, t.byteOffset, Math.min(i, r));
  return s.set(o, n), e;
}
function yr(e, t) {
  const n = Iot(e), i = n.reduce((u, f) => u + f.byteLength, 0);
  let r, s, o, a = 0, c = -1;
  const l = Math.min(t || Number.POSITIVE_INFINITY, i);
  for (const u = n.length; ++c < u; ) {
    if (r = n[c], s = r.subarray(0, Math.min(r.length, l - a)), l <= a + s.length) {
      s.length < r.length ? n[c] = r.subarray(s.length) : s.length === r.length && c++, o ? sI(o, s, a) : o = s;
      break;
    }
    sI(o || (o = new Uint8Array(l)), s, a), a += s.length;
  }
  return [o || new Uint8Array(0), n.slice(c), i - (o ? o.byteLength : 0)];
}
function se(e, t) {
  let n = xL(t) ? t.value : t;
  return n instanceof e ? e === Uint8Array ? new e(n.buffer, n.byteOffset, n.byteLength) : n : n ? (typeof n == "string" && (n = t_(n)), n instanceof ArrayBuffer ? new e(n) : n instanceof i_ ? new e(n) : Sot(n) ? se(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 Fl = (e) => se(Int32Array, e), oI = (e) => se(BigInt64Array, e), Wt = (e) => se(Uint8Array, e), ib = (e) => (e.next(), e);
function* Aot(e, t) {
  const n = function* (r) {
    yield r;
  }, i = typeof t == "string" || ArrayBuffer.isView(t) || t instanceof ArrayBuffer || t instanceof i_ ? n(t) : J0(t) ? t : n(t);
  return yield* ib(function* (r) {
    let s = null;
    do
      s = r.next(yield se(e, s));
    while (!s.done);
  }(i[Symbol.iterator]())), new e();
}
const Mot = (e) => Aot(Uint8Array, e);
function $L(e, t) {
  return Re(this, arguments, function* () {
    if (tf(t))
      return yield H(yield H(yield* Cs(ai($L(e, yield H(t))))));
    const i = function(o) {
      return Re(this, arguments, function* () {
        yield yield H(yield H(o));
      });
    }, r = function(o) {
      return Re(this, arguments, function* () {
        yield H(yield* Cs(ai(ib(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 i_ ? i(t) : J0(t) ? r(t) : e_(t) ? t : i(t);
    return yield H(
      // otherwise if AsyncIterable, use it
      yield* Cs(ai(ib(function(o) {
        return Re(this, arguments, function* () {
          let a = null;
          do
            a = yield H(o.next(yield yield H(se(e, a))));
          while (!a.done);
        });
      }(s[Symbol.asyncIterator]()))))
    ), yield H(new e());
  });
}
const $ot = (e) => $L(Uint8Array, e);
function Tot(e, t) {
  let n = 0;
  const i = e.length;
  if (i !== t.length)
    return !1;
  if (i > 0)
    do
      if (e[n] !== t[n])
        return !1;
    while (++n < i);
  return !0;
}
const Jn = {
  fromIterable(e) {
    return Ch(Dot(e));
  },
  fromAsyncIterable(e) {
    return Ch(Not(e));
  },
  fromDOMStream(e) {
    return Ch(Bot(e));
  },
  fromNodeStream(e) {
    return Ch(Fot(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');
  }
}, Ch = (e) => (e.next(), e);
function* Dot(e) {
  let t, n = !1, i = [], r, s, o, a = 0;
  function c() {
    return s === "peek" ? yr(i, o)[0] : ([r, i, a] = yr(i, o), r);
  }
  ({ cmd: s, size: o } = (yield null) || { cmd: "read", size: 0 });
  const l = Mot(e)[Symbol.iterator]();
  try {
    do
      if ({ done: t, value: r } = Number.isNaN(o - a) ? l.next() : l.next(o - a), !t && r.byteLength > 0 && (i.push(r), a += r.byteLength), t || o <= a)
        do
          ({ cmd: s, size: o } = yield c());
        while (o < a);
    while (!t);
  } catch (u) {
    (n = !0) && typeof l.throw == "function" && l.throw(u);
  } finally {
    n === !1 && typeof l.return == "function" && l.return(null);
  }
  return null;
}
function Not(e) {
  return Re(this, arguments, function* () {
    let n, i = !1, r = [], s, o, a, c = 0;
    function l() {
      return o === "peek" ? yr(r, a)[0] : ([s, r, c] = yr(r, a), s);
    }
    ({ cmd: o, size: a } = (yield yield H(null)) || { cmd: "read", size: 0 });
    const u = $ot(e)[Symbol.asyncIterator]();
    try {
      do
        if ({ done: n, value: s } = Number.isNaN(a - c) ? yield H(u.next()) : yield H(u.next(a - c)), !n && s.byteLength > 0 && (r.push(s), c += s.byteLength), n || a <= c)
          do
            ({ cmd: o, size: a } = yield yield H(l()));
          while (a < c);
      while (!n);
    } catch (f) {
      (i = !0) && typeof u.throw == "function" && (yield H(u.throw(f)));
    } finally {
      i === !1 && typeof u.return == "function" && (yield H(u.return(new Uint8Array(0))));
    }
    return yield H(null);
  });
}
function Bot(e) {
  return Re(this, arguments, function* () {
    let n = !1, i = !1, r = [], s, o, a, c = 0;
    function l() {
      return o === "peek" ? yr(r, a)[0] : ([s, r, c] = yr(r, a), s);
    }
    ({ cmd: o, size: a } = (yield yield H(null)) || { cmd: "read", size: 0 });
    const u = new Oot(e);
    try {
      do
        if ({ done: n, value: s } = Number.isNaN(a - c) ? yield H(u.read()) : yield H(u.read(a - c)), !n && s.byteLength > 0 && (r.push(Wt(s)), c += s.byteLength), n || a <= c)
          do
            ({ cmd: o, size: a } = yield yield H(l()));
          while (a < c);
      while (!n);
    } catch (f) {
      (i = !0) && (yield H(u.cancel(f)));
    } finally {
      i === !1 ? yield H(u.cancel()) : e.locked && u.releaseLock();
    }
    return yield H(null);
  });
}
class Oot {
  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 W(this, void 0, void 0, function* () {
      const { reader: n, source: i } = this;
      n && (yield n.cancel(t).catch(() => {
      })), i && i.locked && this.releaseLock();
    });
  }
  read(t) {
    return W(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 = Wt(n)), n;
    });
  }
}
const cg = (e, t) => {
  const n = (r) => i([t, r]);
  let i;
  return [t, n, new Promise((r) => (i = r) && e.once(t, n))];
};
function Fot(e) {
  return Re(this, arguments, function* () {
    const n = [];
    let i = "error", r = !1, s = null, o, a, c = 0, l = [], u;
    function f() {
      return o === "peek" ? yr(l, a)[0] : ([u, l, c] = yr(l, a), u);
    }
    if ({ cmd: o, size: a } = (yield yield H(null)) || { cmd: "read", size: 0 }, e.isTTY)
      return yield yield H(new Uint8Array(0)), yield H(null);
    try {
      n[0] = cg(e, "end"), n[1] = cg(e, "error");
      do {
        if (n[2] = cg(e, "readable"), [i, s] = yield H(Promise.race(n.map((d) => d[2]))), i === "error")
          break;
        if ((r = i === "end") || (Number.isFinite(a - c) ? (u = Wt(e.read(a - c)), u.byteLength < a - c && (u = Wt(e.read()))) : u = Wt(e.read()), u.byteLength > 0 && (l.push(u), c += u.byteLength)), r || a <= c)
          do
            ({ cmd: o, size: a } = yield yield H(f()));
          while (a < c);
      } while (!r);
    } finally {
      yield H(h(n, i === "error" ? s : null));
    }
    return yield H(null);
    function h(d, p) {
      return u = l = null, new Promise((y, g) => {
        for (const [m, b] of d)
          e.off(m, b);
        try {
          const m = e.destroy;
          m && m.call(e, p), p = void 0;
        } catch (m) {
          p = m || p;
        } finally {
          p != null ? g(p) : y();
        }
      });
    }
  });
}
var Le;
(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";
})(Le || (Le = {}));
var On;
(function(e) {
  e[e.Sparse = 0] = "Sparse", e[e.Dense = 1] = "Dense";
})(On || (On = {}));
var rn;
(function(e) {
  e[e.HALF = 0] = "HALF", e[e.SINGLE = 1] = "SINGLE", e[e.DOUBLE = 2] = "DOUBLE";
})(rn || (rn = {}));
var Oi;
(function(e) {
  e[e.DAY = 0] = "DAY", e[e.MILLISECOND = 1] = "MILLISECOND";
})(Oi || (Oi = {}));
var bt;
(function(e) {
  e[e.SECOND = 0] = "SECOND", e[e.MILLISECOND = 1] = "MILLISECOND", e[e.MICROSECOND = 2] = "MICROSECOND", e[e.NANOSECOND = 3] = "NANOSECOND";
})(bt || (bt = {}));
var mr;
(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";
})(mr || (mr = {}));
var ly;
(function(e) {
  e[e.BUFFER = 0] = "BUFFER";
})(ly || (ly = {}));
var uy;
(function(e) {
  e[e.LZ4_FRAME = 0] = "LZ4_FRAME", e[e.ZSTD = 1] = "ZSTD";
})(uy || (uy = {}));
class $s {
  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 $s()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsBodyCompression(t, n) {
    return t.setPosition(t.position() + nt), (n || new $s()).__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) : uy.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) : ly.BUFFER;
  }
  static startBodyCompression(t) {
    t.startObject(2);
  }
  static addCodec(t, n) {
    t.addFieldInt8(0, n, uy.LZ4_FRAME);
  }
  static addMethod(t, n) {
    t.addFieldInt8(1, n, ly.BUFFER);
  }
  static endBodyCompression(t) {
    return t.endObject();
  }
  static createBodyCompression(t, n, i) {
    return $s.startBodyCompression(t), $s.addCodec(t, n), $s.addMethod(t, i), $s.endBodyCompression(t);
  }
}
class TL {
  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, i) {
    return t.prep(8, 16), t.writeInt64(BigInt(i ?? 0)), t.writeInt64(BigInt(n ?? 0)), t.offset();
  }
}
let DL = 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, i) {
    return t.prep(8, 16), t.writeInt64(BigInt(i ?? 0)), t.writeInt64(BigInt(n ?? 0)), t.offset();
  }
}, Cr = class rb {
  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 rb()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsRecordBatch(t, n) {
    return t.setPosition(t.position() + nt), (n || new rb()).__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 i = this.bb.__offset(this.bb_pos, 6);
    return i ? (n || new DL()).__init(this.bb.__vector(this.bb_pos + i) + 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 i = this.bb.__offset(this.bb_pos, 8);
    return i ? (n || new TL()).__init(this.bb.__vector(this.bb_pos + i) + 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 $s()).__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();
  }
}, Pa = class sb {
  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 sb()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDictionaryBatch(t, n) {
    return t.setPosition(t.position() + nt), (n || new sb()).__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 Wc;
(function(e) {
  e[e.Little = 0] = "Little", e[e.Big = 1] = "Big";
})(Wc || (Wc = {}));
var fy;
(function(e) {
  e[e.DenseArray = 0] = "DenseArray";
})(fy || (fy = {}));
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() + nt), (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, i) {
    return Rn.startInt(t), Rn.addBitWidth(t, n), Rn.addIsSigned(t, i), 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() + nt), (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) : fy.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, fy.DenseArray);
  }
  static endDictionaryEncoding(t) {
    return t.endObject();
  }
}
class Ce {
  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 Ce()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsKeyValue(t, n) {
    return t.setPosition(t.position() + nt), (n || new Ce()).__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, i) {
    return Ce.startKeyValue(t), Ce.addKey(t, n), Ce.addValue(t, i), Ce.endKeyValue(t);
  }
}
let aI = class tu {
  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 tu()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsBinary(t, n) {
    return t.setPosition(t.position() + nt), (n || new tu()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startBinary(t) {
    t.startObject(0);
  }
  static endBinary(t) {
    return t.endObject();
  }
  static createBinary(t) {
    return tu.startBinary(t), tu.endBinary(t);
  }
}, cI = class eu {
  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 eu()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsBool(t, n) {
    return t.setPosition(t.position() + nt), (n || new eu()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startBool(t) {
    t.startObject(0);
  }
  static endBool(t) {
    return t.endObject();
  }
  static createBool(t) {
    return eu.startBool(t), eu.endBool(t);
  }
}, fd = class Va {
  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 Va()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDate(t, n) {
    return t.setPosition(t.position() + nt), (n || new Va()).__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) : Oi.MILLISECOND;
  }
  static startDate(t) {
    t.startObject(1);
  }
  static addUnit(t, n) {
    t.addFieldInt16(0, n, Oi.MILLISECOND);
  }
  static endDate(t) {
    return t.endObject();
  }
  static createDate(t, n) {
    return Va.startDate(t), Va.addUnit(t, n), Va.endDate(t);
  }
}, ja = class Ss {
  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 Ss()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDecimal(t, n) {
    return t.setPosition(t.position() + nt), (n || new Ss()).__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, i, r) {
    return Ss.startDecimal(t), Ss.addPrecision(t, n), Ss.addScale(t, i), Ss.addBitWidth(t, r), Ss.endDecimal(t);
  }
}, hd = class qa {
  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 qa()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDuration(t, n) {
    return t.setPosition(t.position() + nt), (n || new qa()).__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) : bt.MILLISECOND;
  }
  static startDuration(t) {
    t.startObject(1);
  }
  static addUnit(t, n) {
    t.addFieldInt16(0, n, bt.MILLISECOND);
  }
  static endDuration(t) {
    return t.endObject();
  }
  static createDuration(t, n) {
    return qa.startDuration(t), qa.addUnit(t, n), qa.endDuration(t);
  }
}, dd = class Ya {
  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 Ya()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFixedSizeBinary(t, n) {
    return t.setPosition(t.position() + nt), (n || new Ya()).__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 Ya.startFixedSizeBinary(t), Ya.addByteWidth(t, n), Ya.endFixedSizeBinary(t);
  }
}, pd = class Wa {
  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 Wa()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFixedSizeList(t, n) {
    return t.setPosition(t.position() + nt), (n || new Wa()).__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 Wa.startFixedSizeList(t), Wa.addListSize(t, n), Wa.endFixedSizeList(t);
  }
};
class tr {
  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 tr()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFloatingPoint(t, n) {
    return t.setPosition(t.position() + nt), (n || new tr()).__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) : rn.HALF;
  }
  static startFloatingPoint(t) {
    t.startObject(1);
  }
  static addPrecision(t, n) {
    t.addFieldInt16(0, n, rn.HALF);
  }
  static endFloatingPoint(t) {
    return t.endObject();
  }
  static createFloatingPoint(t, n) {
    return tr.startFloatingPoint(t), tr.addPrecision(t, n), tr.endFloatingPoint(t);
  }
}
class er {
  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 er()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsInterval(t, n) {
    return t.setPosition(t.position() + nt), (n || new er()).__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) : mr.YEAR_MONTH;
  }
  static startInterval(t) {
    t.startObject(1);
  }
  static addUnit(t, n) {
    t.addFieldInt16(0, n, mr.YEAR_MONTH);
  }
  static endInterval(t) {
    return t.endObject();
  }
  static createInterval(t, n) {
    return er.startInterval(t), er.addUnit(t, n), er.endInterval(t);
  }
}
let lI = class nu {
  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 nu()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsLargeBinary(t, n) {
    return t.setPosition(t.position() + nt), (n || new nu()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startLargeBinary(t) {
    t.startObject(0);
  }
  static endLargeBinary(t) {
    return t.endObject();
  }
  static createLargeBinary(t) {
    return nu.startLargeBinary(t), nu.endLargeBinary(t);
  }
}, uI = class iu {
  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 iu()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsLargeUtf8(t, n) {
    return t.setPosition(t.position() + nt), (n || new iu()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startLargeUtf8(t) {
    t.startObject(0);
  }
  static endLargeUtf8(t) {
    return t.endObject();
  }
  static createLargeUtf8(t) {
    return iu.startLargeUtf8(t), iu.endLargeUtf8(t);
  }
}, fI = class ru {
  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 ru()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsList(t, n) {
    return t.setPosition(t.position() + nt), (n || new ru()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startList(t) {
    t.startObject(0);
  }
  static endList(t) {
    return t.endObject();
  }
  static createList(t) {
    return ru.startList(t), ru.endList(t);
  }
}, yd = class Ga {
  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 Ga()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsMap(t, n) {
    return t.setPosition(t.position() + nt), (n || new Ga()).__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 Ga.startMap(t), Ga.addKeysSorted(t, n), Ga.endMap(t);
  }
}, hI = class su {
  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 su()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsNull(t, n) {
    return t.setPosition(t.position() + nt), (n || new su()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startNull(t) {
    t.startObject(0);
  }
  static endNull(t) {
    return t.endObject();
  }
  static createNull(t) {
    return su.startNull(t), su.endNull(t);
  }
};
class Co {
  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 Co()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsStruct_(t, n) {
    return t.setPosition(t.position() + nt), (n || new Co()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startStruct_(t) {
    t.startObject(0);
  }
  static endStruct_(t) {
    return t.endObject();
  }
  static createStruct_(t) {
    return Co.startStruct_(t), Co.endStruct_(t);
  }
}
class Zn {
  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 Zn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsTime(t, n) {
    return t.setPosition(t.position() + nt), (n || new Zn()).__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) : bt.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, bt.MILLISECOND);
  }
  static addBitWidth(t, n) {
    t.addFieldInt32(1, n, 32);
  }
  static endTime(t) {
    return t.endObject();
  }
  static createTime(t, n, i) {
    return Zn.startTime(t), Zn.addUnit(t, n), Zn.addBitWidth(t, i), Zn.endTime(t);
  }
}
class Qn {
  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 Qn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsTimestamp(t, n) {
    return t.setPosition(t.position() + nt), (n || new Qn()).__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) : bt.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, bt.SECOND);
  }
  static addTimezone(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static endTimestamp(t) {
    return t.endObject();
  }
  static createTimestamp(t, n, i) {
    return Qn.startTimestamp(t), Qn.addUnit(t, n), Qn.addTimezone(t, i), Qn.endTimestamp(t);
  }
}
class In {
  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 In()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsUnion(t, n) {
    return t.setPosition(t.position() + nt), (n || new In()).__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) : On.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, On.Sparse);
  }
  static addTypeIds(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static createTypeIdsVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let i = n.length - 1; i >= 0; i--)
      t.addInt32(n[i]);
    return t.endVector();
  }
  static startTypeIdsVector(t, n) {
    t.startVector(4, n, 4);
  }
  static endUnion(t) {
    return t.endObject();
  }
  static createUnion(t, n, i) {
    return In.startUnion(t), In.addMode(t, n), In.addTypeIds(t, i), In.endUnion(t);
  }
}
let dI = class ou {
  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 ou()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsUtf8(t, n) {
    return t.setPosition(t.position() + nt), (n || new ou()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startUtf8(t) {
    t.startObject(0);
  }
  static endUtf8(t) {
    return t.endObject();
  }
  static createUtf8(t) {
    return ou.startUtf8(t), ou.endUtf8(t);
  }
};
var pe;
(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";
})(pe || (pe = {}));
let Xn = class md {
  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 md()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsField(t, n) {
    return t.setPosition(t.position() + nt), (n || new md()).__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) : pe.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 i = this.bb.__offset(this.bb_pos, 14);
    return i ? (n || new md()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + i) + 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 i = this.bb.__offset(this.bb_pos, 16);
    return i ? (n || new Ce()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + i) + 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, pe.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 i = n.length - 1; i >= 0; i--)
      t.addOffset(n[i]);
    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 i = n.length - 1; i >= 0; i--)
      t.addOffset(n[i]);
    return t.endVector();
  }
  static startCustomMetadataVector(t, n) {
    t.startVector(4, n, 4);
  }
  static endField(t) {
    return t.endObject();
  }
}, Gi = 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() + nt), (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) : Wc.Little;
  }
  fields(t, n) {
    const i = this.bb.__offset(this.bb_pos, 6);
    return i ? (n || new Xn()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + i) + 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 i = this.bb.__offset(this.bb_pos, 8);
    return i ? (n || new Ce()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + i) + 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, Wc.Little);
  }
  static addFields(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static createFieldsVector(t, n) {
    t.startVector(4, n.length, 4);
    for (let i = n.length - 1; i >= 0; i--)
      t.addOffset(n[i]);
    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 i = n.length - 1; i >= 0; i--)
      t.addOffset(n[i]);
    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 i = n.length - 1; i >= 0; i--)
      t.addInt64(n[i]);
    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, i, r, s) {
    return Fr.startSchema(t), Fr.addEndianness(t, n), Fr.addFields(t, i), Fr.addCustomMetadata(t, r), Fr.addFeatures(t, s), Fr.endSchema(t);
  }
};
var te;
(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";
})(te || (te = {}));
var E;
(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";
})(E || (E = {}));
var kr;
(function(e) {
  e[e.OFFSET = 0] = "OFFSET", e[e.DATA = 1] = "DATA", e[e.VALIDITY = 2] = "VALIDITY", e[e.TYPE = 3] = "TYPE";
})(kr || (kr = {}));
const Eot = void 0;
function ef(e) {
  if (e === null)
    return "null";
  if (e === Eot)
    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) => ef(t))}]` : `[${e}]` : ArrayBuffer.isView(e) ? `[${e}]` : JSON.stringify(e, (t, n) => typeof n == "bigint" ? `${n}` : n);
}
const Lot = Symbol.for("isArrowBigNum");
function Ui(e, ...t) {
  return t.length === 0 ? Object.setPrototypeOf(se(this.TypedArray, e), this.constructor.prototype) : Object.setPrototypeOf(new this.TypedArray(e, ...t), this.constructor.prototype);
}
Ui.prototype[Lot] = !0;
Ui.prototype.toJSON = function() {
  return `"${rf(this)}"`;
};
Ui.prototype.valueOf = function() {
  return NL(this);
};
Ui.prototype.toString = function() {
  return rf(this);
};
Ui.prototype[Symbol.toPrimitive] = function(e = "default") {
  switch (e) {
    case "number":
      return NL(this);
    case "string":
      return rf(this);
    case "default":
      return Rot(this);
  }
  return rf(this);
};
function bc(...e) {
  return Ui.apply(this, e);
}
function wc(...e) {
  return Ui.apply(this, e);
}
function nf(...e) {
  return Ui.apply(this, e);
}
Object.setPrototypeOf(bc.prototype, Object.create(Int32Array.prototype));
Object.setPrototypeOf(wc.prototype, Object.create(Uint32Array.prototype));
Object.setPrototypeOf(nf.prototype, Object.create(Uint32Array.prototype));
Object.assign(bc.prototype, Ui.prototype, { constructor: bc, signed: !0, TypedArray: Int32Array, BigIntArray: BigInt64Array });
Object.assign(wc.prototype, Ui.prototype, { constructor: wc, signed: !1, TypedArray: Uint32Array, BigIntArray: BigUint64Array });
Object.assign(nf.prototype, Ui.prototype, { constructor: nf, signed: !0, TypedArray: Uint32Array, BigIntArray: BigUint64Array });
function NL(e) {
  const { buffer: t, byteOffset: n, length: i, signed: r } = e, s = new BigUint64Array(t, n, i), o = r && s.at(-1) & BigInt(1) << BigInt(63);
  let a = BigInt(o ? 1 : 0), c = BigInt(0);
  if (o) {
    for (const l of s)
      a += ~l * (BigInt(1) << BigInt(32) * c++);
    a *= BigInt(-1);
  } else
    for (const l of s)
      a += l * (BigInt(1) << BigInt(32) * c++);
  return a;
}
const rf = (e) => {
  if (e.byteLength === 8)
    return `${new e.BigIntArray(e.buffer, e.byteOffset, 1)[0]}`;
  if (!e.signed)
    return lg(e);
  let t = new Uint16Array(e.buffer, e.byteOffset, e.byteLength / 2);
  if (new Int16Array([t.at(-1)])[0] >= 0)
    return lg(e);
  t = t.slice();
  let i = 1;
  for (let s = 0; s < t.length; s++) {
    const o = t[s], a = ~o + i;
    t[s] = a, i &= o === 0 ? 1 : 0;
  }
  return `-${lg(t)}`;
}, Rot = (e) => e.byteLength === 8 ? new e.BigIntArray(e.buffer, e.byteOffset, 1)[0] : rf(e);
function lg(e) {
  let t = "";
  const n = new Uint32Array(2);
  let i = new Uint16Array(e.buffer, e.byteOffset, e.byteLength / 2);
  const r = new Uint32Array((i = new Uint16Array(i).reverse()).buffer);
  let s = -1;
  const o = i.length - 1;
  do {
    for (n[0] = i[s = 0]; s < o; )
      i[s++] = n[1] = n[0] / 10, n[0] = (n[0] - n[1] * 10 << 16) + i[s];
    i[s] = n[1] = n[0] / 10, n[0] = n[0] - n[1] * 10, t = `${n[0]}${t}`;
  } while (r[0] || r[1] || r[2] || r[3]);
  return t ?? "0";
}
class r_ {
  /** @nocollapse */
  static new(t, n) {
    switch (n) {
      case !0:
        return new bc(t);
      case !1:
        return new wc(t);
    }
    switch (t.constructor) {
      case Int8Array:
      case Int16Array:
      case Int32Array:
      case BigInt64Array:
        return new bc(t);
    }
    return t.byteLength === 16 ? new nf(t) : new wc(t);
  }
  /** @nocollapse */
  static signed(t) {
    return new bc(t);
  }
  /** @nocollapse */
  static unsigned(t) {
    return new wc(t);
  }
  /** @nocollapse */
  static decimal(t) {
    return new nf(t);
  }
  constructor(t, n) {
    return r_.new(t, n);
  }
}
function bn(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);
}
var BL, OL, FL, EL, LL, RL, CL, kL, UL, zL, PL, VL, jL, qL, YL, WL, GL, XL, HL, JL, KL, ZL;
class st {
  /** @nocollapse */
  static isNull(t) {
    return (t == null ? void 0 : t.typeId) === E.Null;
  }
  /** @nocollapse */
  static isInt(t) {
    return (t == null ? void 0 : t.typeId) === E.Int;
  }
  /** @nocollapse */
  static isFloat(t) {
    return (t == null ? void 0 : t.typeId) === E.Float;
  }
  /** @nocollapse */
  static isBinary(t) {
    return (t == null ? void 0 : t.typeId) === E.Binary;
  }
  /** @nocollapse */
  static isLargeBinary(t) {
    return (t == null ? void 0 : t.typeId) === E.LargeBinary;
  }
  /** @nocollapse */
  static isUtf8(t) {
    return (t == null ? void 0 : t.typeId) === E.Utf8;
  }
  /** @nocollapse */
  static isLargeUtf8(t) {
    return (t == null ? void 0 : t.typeId) === E.LargeUtf8;
  }
  /** @nocollapse */
  static isBool(t) {
    return (t == null ? void 0 : t.typeId) === E.Bool;
  }
  /** @nocollapse */
  static isDecimal(t) {
    return (t == null ? void 0 : t.typeId) === E.Decimal;
  }
  /** @nocollapse */
  static isDate(t) {
    return (t == null ? void 0 : t.typeId) === E.Date;
  }
  /** @nocollapse */
  static isTime(t) {
    return (t == null ? void 0 : t.typeId) === E.Time;
  }
  /** @nocollapse */
  static isTimestamp(t) {
    return (t == null ? void 0 : t.typeId) === E.Timestamp;
  }
  /** @nocollapse */
  static isInterval(t) {
    return (t == null ? void 0 : t.typeId) === E.Interval;
  }
  /** @nocollapse */
  static isDuration(t) {
    return (t == null ? void 0 : t.typeId) === E.Duration;
  }
  /** @nocollapse */
  static isList(t) {
    return (t == null ? void 0 : t.typeId) === E.List;
  }
  /** @nocollapse */
  static isStruct(t) {
    return (t == null ? void 0 : t.typeId) === E.Struct;
  }
  /** @nocollapse */
  static isUnion(t) {
    return (t == null ? void 0 : t.typeId) === E.Union;
  }
  /** @nocollapse */
  static isFixedSizeBinary(t) {
    return (t == null ? void 0 : t.typeId) === E.FixedSizeBinary;
  }
  /** @nocollapse */
  static isFixedSizeList(t) {
    return (t == null ? void 0 : t.typeId) === E.FixedSizeList;
  }
  /** @nocollapse */
  static isMap(t) {
    return (t == null ? void 0 : t.typeId) === E.Map;
  }
  /** @nocollapse */
  static isDictionary(t) {
    return (t == null ? void 0 : t.typeId) === E.Dictionary;
  }
  /** @nocollapse */
  static isDenseUnion(t) {
    return st.isUnion(t) && t.mode === On.Dense;
  }
  /** @nocollapse */
  static isSparseUnion(t) {
    return st.isUnion(t) && t.mode === On.Sparse;
  }
  constructor(t) {
    this.typeId = t;
  }
}
BL = Symbol.toStringTag;
st[BL] = ((e) => (e.children = null, e.ArrayType = Array, e.OffsetArrayType = Int32Array, e[Symbol.toStringTag] = "DataType"))(st.prototype);
class Qs extends st {
  constructor() {
    super(E.Null);
  }
  toString() {
    return "Null";
  }
}
OL = Symbol.toStringTag;
Qs[OL] = ((e) => e[Symbol.toStringTag] = "Null")(Qs.prototype);
class to extends st {
  constructor(t, n) {
    super(E.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}`;
  }
}
FL = Symbol.toStringTag;
to[FL] = ((e) => (e.isSigned = null, e.bitWidth = null, e[Symbol.toStringTag] = "Int"))(to.prototype);
class sf extends to {
  constructor() {
    super(!0, 32);
  }
  get ArrayType() {
    return Int32Array;
  }
}
Object.defineProperty(sf.prototype, "ArrayType", { value: Int32Array });
class of extends st {
  constructor(t) {
    super(E.Float), this.precision = t;
  }
  get ArrayType() {
    switch (this.precision) {
      case rn.HALF:
        return Uint16Array;
      case rn.SINGLE:
        return Float32Array;
      case rn.DOUBLE:
        return Float64Array;
    }
    throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);
  }
  toString() {
    return `Float${this.precision << 5 || 16}`;
  }
}
EL = Symbol.toStringTag;
of[EL] = ((e) => (e.precision = null, e[Symbol.toStringTag] = "Float"))(of.prototype);
class hy extends st {
  constructor() {
    super(E.Binary);
  }
  toString() {
    return "Binary";
  }
}
LL = Symbol.toStringTag;
hy[LL] = ((e) => (e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "Binary"))(hy.prototype);
class dy extends st {
  constructor() {
    super(E.LargeBinary);
  }
  toString() {
    return "LargeBinary";
  }
}
RL = Symbol.toStringTag;
dy[RL] = ((e) => (e.ArrayType = Uint8Array, e.OffsetArrayType = BigInt64Array, e[Symbol.toStringTag] = "LargeBinary"))(dy.prototype);
class py extends st {
  constructor() {
    super(E.Utf8);
  }
  toString() {
    return "Utf8";
  }
}
CL = Symbol.toStringTag;
py[CL] = ((e) => (e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "Utf8"))(py.prototype);
class yy extends st {
  constructor() {
    super(E.LargeUtf8);
  }
  toString() {
    return "LargeUtf8";
  }
}
kL = Symbol.toStringTag;
yy[kL] = ((e) => (e.ArrayType = Uint8Array, e.OffsetArrayType = BigInt64Array, e[Symbol.toStringTag] = "LargeUtf8"))(yy.prototype);
class my extends st {
  constructor() {
    super(E.Bool);
  }
  toString() {
    return "Bool";
  }
}
UL = Symbol.toStringTag;
my[UL] = ((e) => (e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "Bool"))(my.prototype);
class gy extends st {
  constructor(t, n, i = 128) {
    super(E.Decimal), this.scale = t, this.precision = n, this.bitWidth = i;
  }
  toString() {
    return `Decimal[${this.precision}e${this.scale > 0 ? "+" : ""}${this.scale}]`;
  }
}
zL = Symbol.toStringTag;
gy[zL] = ((e) => (e.scale = null, e.precision = null, e.ArrayType = Uint32Array, e[Symbol.toStringTag] = "Decimal"))(gy.prototype);
class by extends st {
  constructor(t) {
    super(E.Date), this.unit = t;
  }
  toString() {
    return `Date${(this.unit + 1) * 32}<${Oi[this.unit]}>`;
  }
}
PL = Symbol.toStringTag;
by[PL] = ((e) => (e.unit = null, e.ArrayType = Int32Array, e[Symbol.toStringTag] = "Date"))(by.prototype);
class af extends st {
  constructor(t, n) {
    super(E.Time), this.unit = t, this.bitWidth = n;
  }
  toString() {
    return `Time${this.bitWidth}<${bt[this.unit]}>`;
  }
  get ArrayType() {
    switch (this.bitWidth) {
      case 32:
        return Int32Array;
      case 64:
        return BigInt64Array;
    }
    throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);
  }
}
VL = Symbol.toStringTag;
af[VL] = ((e) => (e.unit = null, e.bitWidth = null, e[Symbol.toStringTag] = "Time"))(af.prototype);
class wy extends st {
  constructor(t, n) {
    super(E.Timestamp), this.unit = t, this.timezone = n;
  }
  toString() {
    return `Timestamp<${bt[this.unit]}${this.timezone ? `, ${this.timezone}` : ""}>`;
  }
}
jL = Symbol.toStringTag;
wy[jL] = ((e) => (e.unit = null, e.timezone = null, e.ArrayType = Int32Array, e[Symbol.toStringTag] = "Timestamp"))(wy.prototype);
class vy extends st {
  constructor(t) {
    super(E.Interval), this.unit = t;
  }
  toString() {
    return `Interval<${mr[this.unit]}>`;
  }
}
qL = Symbol.toStringTag;
vy[qL] = ((e) => (e.unit = null, e.ArrayType = Int32Array, e[Symbol.toStringTag] = "Interval"))(vy.prototype);
class _y extends st {
  constructor(t) {
    super(E.Duration), this.unit = t;
  }
  toString() {
    return `Duration<${bt[this.unit]}>`;
  }
}
YL = Symbol.toStringTag;
_y[YL] = ((e) => (e.unit = null, e.ArrayType = BigInt64Array, e[Symbol.toStringTag] = "Duration"))(_y.prototype);
class xy extends st {
  constructor(t) {
    super(E.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;
  }
}
WL = Symbol.toStringTag;
xy[WL] = ((e) => (e.children = null, e[Symbol.toStringTag] = "List"))(xy.prototype);
class hn extends st {
  constructor(t) {
    super(E.Struct), this.children = t;
  }
  toString() {
    return `Struct<{${this.children.map((t) => `${t.name}:${t.type}`).join(", ")}}>`;
  }
}
GL = Symbol.toStringTag;
hn[GL] = ((e) => (e.children = null, e[Symbol.toStringTag] = "Struct"))(hn.prototype);
class Sy extends st {
  constructor(t, n, i) {
    super(E.Union), this.mode = t, this.children = i, this.typeIds = n = Int32Array.from(n), this.typeIdToChildIndex = n.reduce((r, s, o) => (r[s] = o) && r || r, /* @__PURE__ */ Object.create(null));
  }
  toString() {
    return `${this[Symbol.toStringTag]}<${this.children.map((t) => `${t.type}`).join(" | ")}>`;
  }
}
XL = Symbol.toStringTag;
Sy[XL] = ((e) => (e.mode = null, e.typeIds = null, e.children = null, e.typeIdToChildIndex = null, e.ArrayType = Int8Array, e[Symbol.toStringTag] = "Union"))(Sy.prototype);
class Iy extends st {
  constructor(t) {
    super(E.FixedSizeBinary), this.byteWidth = t;
  }
  toString() {
    return `FixedSizeBinary[${this.byteWidth}]`;
  }
}
HL = Symbol.toStringTag;
Iy[HL] = ((e) => (e.byteWidth = null, e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "FixedSizeBinary"))(Iy.prototype);
class Ay extends st {
  constructor(t, n) {
    super(E.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}>`;
  }
}
JL = Symbol.toStringTag;
Ay[JL] = ((e) => (e.children = null, e.listSize = null, e[Symbol.toStringTag] = "FixedSizeList"))(Ay.prototype);
class My extends st {
  constructor(t, n = !1) {
    var i, r, s;
    if (super(E.Map), this.children = [t], this.keysSorted = n, t && (t.name = "entries", !((i = t == null ? void 0 : t.type) === null || i === void 0) && i.children)) {
      const o = (r = t == null ? void 0 : t.type) === null || r === void 0 ? void 0 : r.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(", ")}}>`;
  }
}
KL = Symbol.toStringTag;
My[KL] = ((e) => (e.children = null, e.keysSorted = null, e[Symbol.toStringTag] = "Map_"))(My.prototype);
const Cot = /* @__PURE__ */ ((e) => () => ++e)(-1);
class Gc extends st {
  constructor(t, n, i, r) {
    super(E.Dictionary), this.indices = n, this.dictionary = t, this.isOrdered = r || !1, this.id = i == null ? Cot() : bn(i);
  }
  get children() {
    return this.dictionary.children;
  }
  get valueType() {
    return this.dictionary;
  }
  get ArrayType() {
    return this.dictionary.ArrayType;
  }
  toString() {
    return `Dictionary<${this.indices}, ${this.dictionary}>`;
  }
}
ZL = Symbol.toStringTag;
Gc[ZL] = ((e) => (e.id = null, e.indices = null, e.isOrdered = null, e.dictionary = null, e[Symbol.toStringTag] = "Dictionary"))(Gc.prototype);
function Ur(e) {
  const t = e;
  switch (e.typeId) {
    case E.Decimal:
      return e.bitWidth / 32;
    case E.Timestamp:
      return 2;
    case E.Date:
      return 1 + t.unit;
    case E.Interval:
      return 1 + t.unit;
    case E.FixedSizeList:
      return t.listSize;
    case E.FixedSizeBinary:
      return t.byteWidth;
    default:
      return 1;
  }
}
class zt {
  visitMany(t, ...n) {
    return t.map((i, r) => this.visit(i, ...n.map((s) => s[r])));
  }
  visit(...t) {
    return this.getVisitFn(t[0], !1).apply(this, t);
  }
  getVisitFn(t, n = !0) {
    return kot(this, t, n);
  }
  getVisitFnByTypeId(t, n = !0) {
    return Xa(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 kot(e, t, n = !0) {
  return typeof t == "number" ? Xa(e, t, n) : typeof t == "string" && t in E ? Xa(e, E[t], n) : t && t instanceof st ? Xa(e, pI(t), n) : t != null && t.type && t.type instanceof st ? Xa(e, pI(t.type), n) : Xa(e, E.NONE, n);
}
function Xa(e, t, n = !0) {
  let i = null;
  switch (t) {
    case E.Null:
      i = e.visitNull;
      break;
    case E.Bool:
      i = e.visitBool;
      break;
    case E.Int:
      i = e.visitInt;
      break;
    case E.Int8:
      i = e.visitInt8 || e.visitInt;
      break;
    case E.Int16:
      i = e.visitInt16 || e.visitInt;
      break;
    case E.Int32:
      i = e.visitInt32 || e.visitInt;
      break;
    case E.Int64:
      i = e.visitInt64 || e.visitInt;
      break;
    case E.Uint8:
      i = e.visitUint8 || e.visitInt;
      break;
    case E.Uint16:
      i = e.visitUint16 || e.visitInt;
      break;
    case E.Uint32:
      i = e.visitUint32 || e.visitInt;
      break;
    case E.Uint64:
      i = e.visitUint64 || e.visitInt;
      break;
    case E.Float:
      i = e.visitFloat;
      break;
    case E.Float16:
      i = e.visitFloat16 || e.visitFloat;
      break;
    case E.Float32:
      i = e.visitFloat32 || e.visitFloat;
      break;
    case E.Float64:
      i = e.visitFloat64 || e.visitFloat;
      break;
    case E.Utf8:
      i = e.visitUtf8;
      break;
    case E.LargeUtf8:
      i = e.visitLargeUtf8;
      break;
    case E.Binary:
      i = e.visitBinary;
      break;
    case E.LargeBinary:
      i = e.visitLargeBinary;
      break;
    case E.FixedSizeBinary:
      i = e.visitFixedSizeBinary;
      break;
    case E.Date:
      i = e.visitDate;
      break;
    case E.DateDay:
      i = e.visitDateDay || e.visitDate;
      break;
    case E.DateMillisecond:
      i = e.visitDateMillisecond || e.visitDate;
      break;
    case E.Timestamp:
      i = e.visitTimestamp;
      break;
    case E.TimestampSecond:
      i = e.visitTimestampSecond || e.visitTimestamp;
      break;
    case E.TimestampMillisecond:
      i = e.visitTimestampMillisecond || e.visitTimestamp;
      break;
    case E.TimestampMicrosecond:
      i = e.visitTimestampMicrosecond || e.visitTimestamp;
      break;
    case E.TimestampNanosecond:
      i = e.visitTimestampNanosecond || e.visitTimestamp;
      break;
    case E.Time:
      i = e.visitTime;
      break;
    case E.TimeSecond:
      i = e.visitTimeSecond || e.visitTime;
      break;
    case E.TimeMillisecond:
      i = e.visitTimeMillisecond || e.visitTime;
      break;
    case E.TimeMicrosecond:
      i = e.visitTimeMicrosecond || e.visitTime;
      break;
    case E.TimeNanosecond:
      i = e.visitTimeNanosecond || e.visitTime;
      break;
    case E.Decimal:
      i = e.visitDecimal;
      break;
    case E.List:
      i = e.visitList;
      break;
    case E.Struct:
      i = e.visitStruct;
      break;
    case E.Union:
      i = e.visitUnion;
      break;
    case E.DenseUnion:
      i = e.visitDenseUnion || e.visitUnion;
      break;
    case E.SparseUnion:
      i = e.visitSparseUnion || e.visitUnion;
      break;
    case E.Dictionary:
      i = e.visitDictionary;
      break;
    case E.Interval:
      i = e.visitInterval;
      break;
    case E.IntervalDayTime:
      i = e.visitIntervalDayTime || e.visitInterval;
      break;
    case E.IntervalYearMonth:
      i = e.visitIntervalYearMonth || e.visitInterval;
      break;
    case E.Duration:
      i = e.visitDuration;
      break;
    case E.DurationSecond:
      i = e.visitDurationSecond || e.visitDuration;
      break;
    case E.DurationMillisecond:
      i = e.visitDurationMillisecond || e.visitDuration;
      break;
    case E.DurationMicrosecond:
      i = e.visitDurationMicrosecond || e.visitDuration;
      break;
    case E.DurationNanosecond:
      i = e.visitDurationNanosecond || e.visitDuration;
      break;
    case E.FixedSizeList:
      i = e.visitFixedSizeList;
      break;
    case E.Map:
      i = e.visitMap;
      break;
  }
  if (typeof i == "function")
    return i;
  if (!n)
    return () => null;
  throw new Error(`Unrecognized type '${E[t]}'`);
}
function pI(e) {
  switch (e.typeId) {
    case E.Null:
      return E.Null;
    case E.Int: {
      const { bitWidth: t, isSigned: n } = e;
      switch (t) {
        case 8:
          return n ? E.Int8 : E.Uint8;
        case 16:
          return n ? E.Int16 : E.Uint16;
        case 32:
          return n ? E.Int32 : E.Uint32;
        case 64:
          return n ? E.Int64 : E.Uint64;
      }
      return E.Int;
    }
    case E.Float:
      switch (e.precision) {
        case rn.HALF:
          return E.Float16;
        case rn.SINGLE:
          return E.Float32;
        case rn.DOUBLE:
          return E.Float64;
      }
      return E.Float;
    case E.Binary:
      return E.Binary;
    case E.LargeBinary:
      return E.LargeBinary;
    case E.Utf8:
      return E.Utf8;
    case E.LargeUtf8:
      return E.LargeUtf8;
    case E.Bool:
      return E.Bool;
    case E.Decimal:
      return E.Decimal;
    case E.Time:
      switch (e.unit) {
        case bt.SECOND:
          return E.TimeSecond;
        case bt.MILLISECOND:
          return E.TimeMillisecond;
        case bt.MICROSECOND:
          return E.TimeMicrosecond;
        case bt.NANOSECOND:
          return E.TimeNanosecond;
      }
      return E.Time;
    case E.Timestamp:
      switch (e.unit) {
        case bt.SECOND:
          return E.TimestampSecond;
        case bt.MILLISECOND:
          return E.TimestampMillisecond;
        case bt.MICROSECOND:
          return E.TimestampMicrosecond;
        case bt.NANOSECOND:
          return E.TimestampNanosecond;
      }
      return E.Timestamp;
    case E.Date:
      switch (e.unit) {
        case Oi.DAY:
          return E.DateDay;
        case Oi.MILLISECOND:
          return E.DateMillisecond;
      }
      return E.Date;
    case E.Interval:
      switch (e.unit) {
        case mr.DAY_TIME:
          return E.IntervalDayTime;
        case mr.YEAR_MONTH:
          return E.IntervalYearMonth;
      }
      return E.Interval;
    case E.Duration:
      switch (e.unit) {
        case bt.SECOND:
          return E.DurationSecond;
        case bt.MILLISECOND:
          return E.DurationMillisecond;
        case bt.MICROSECOND:
          return E.DurationMicrosecond;
        case bt.NANOSECOND:
          return E.DurationNanosecond;
      }
      return E.Duration;
    case E.Map:
      return E.Map;
    case E.List:
      return E.List;
    case E.Struct:
      return E.Struct;
    case E.Union:
      switch (e.mode) {
        case On.Dense:
          return E.DenseUnion;
        case On.Sparse:
          return E.SparseUnion;
      }
      return E.Union;
    case E.FixedSizeBinary:
      return E.FixedSizeBinary;
    case E.FixedSizeList:
      return E.FixedSizeList;
    case E.Dictionary:
      return E.Dictionary;
  }
  throw new Error(`Unrecognized type '${E[e.typeId]}'`);
}
zt.prototype.visitInt8 = null;
zt.prototype.visitInt16 = null;
zt.prototype.visitInt32 = null;
zt.prototype.visitInt64 = null;
zt.prototype.visitUint8 = null;
zt.prototype.visitUint16 = null;
zt.prototype.visitUint32 = null;
zt.prototype.visitUint64 = null;
zt.prototype.visitFloat16 = null;
zt.prototype.visitFloat32 = null;
zt.prototype.visitFloat64 = null;
zt.prototype.visitDateDay = null;
zt.prototype.visitDateMillisecond = null;
zt.prototype.visitTimestampSecond = null;
zt.prototype.visitTimestampMillisecond = null;
zt.prototype.visitTimestampMicrosecond = null;
zt.prototype.visitTimestampNanosecond = null;
zt.prototype.visitTimeSecond = null;
zt.prototype.visitTimeMillisecond = null;
zt.prototype.visitTimeMicrosecond = null;
zt.prototype.visitTimeNanosecond = null;
zt.prototype.visitDenseUnion = null;
zt.prototype.visitSparseUnion = null;
zt.prototype.visitIntervalDayTime = null;
zt.prototype.visitIntervalYearMonth = null;
zt.prototype.visitDuration = null;
zt.prototype.visitDurationSecond = null;
zt.prototype.visitDurationMillisecond = null;
zt.prototype.visitDurationMicrosecond = null;
zt.prototype.visitDurationNanosecond = null;
const QL = new Float64Array(1), $a = new Uint32Array(QL.buffer);
function tR(e) {
  const t = (e & 31744) >> 10, n = (e & 1023) / 1024, i = Math.pow(-1, (e & 32768) >> 15);
  switch (t) {
    case 31:
      return i * (n ? Number.NaN : 1 / 0);
    case 0:
      return i * (n ? 6103515625e-14 * n : 0);
  }
  return i * Math.pow(2, t - 15) * (1 + n);
}
function Uot(e) {
  if (e !== e)
    return 32256;
  QL[0] = e;
  const t = ($a[1] & 2147483648) >> 16 & 65535;
  let n = $a[1] & 2146435072, i = 0;
  return n >= 1089470464 ? $a[0] > 0 ? n = 31744 : (n = (n & 2080374784) >> 16, i = ($a[1] & 1048575) >> 10) : n <= 1056964608 ? (i = 1048576 + ($a[1] & 1048575), i = 1048576 + (i << (n >> 20) - 998) >> 21, n = 0) : (n = n - 1056964608 >> 10, i = ($a[1] & 1048575) + 512 >> 10), t | n | i & 65535;
}
class It extends zt {
}
function Nt(e) {
  return (t, n, i) => {
    if (t.setValid(n, i != null))
      return e(t, n, i);
  };
}
const zot = (e, t, n) => {
  e[t] = Math.trunc(n / 864e5);
}, s_ = (e, t, n) => {
  e[t] = Math.trunc(n % 4294967296), e[t + 1] = Math.trunc(n / 4294967296);
}, Pot = (e, t, n) => {
  e[t] = Math.trunc(n * 1e3 % 4294967296), e[t + 1] = Math.trunc(n * 1e3 / 4294967296);
}, Vot = (e, t, n) => {
  e[t] = Math.trunc(n * 1e6 % 4294967296), e[t + 1] = Math.trunc(n * 1e6 / 4294967296);
}, eR = (e, t, n, i) => {
  if (n + 1 < t.length) {
    const r = bn(t[n]), s = bn(t[n + 1]);
    e.set(i.subarray(0, s - r), r);
  }
}, jot = ({ offset: e, values: t }, n, i) => {
  const r = e + n;
  i ? t[r >> 3] |= 1 << r % 8 : t[r >> 3] &= ~(1 << r % 8);
}, ys = ({ values: e }, t, n) => {
  e[t] = n;
}, o_ = ({ values: e }, t, n) => {
  e[t] = n;
}, nR = ({ values: e }, t, n) => {
  e[t] = Uot(n);
}, qot = (e, t, n) => {
  switch (e.type.precision) {
    case rn.HALF:
      return nR(e, t, n);
    case rn.SINGLE:
    case rn.DOUBLE:
      return o_(e, t, n);
  }
}, iR = ({ values: e }, t, n) => {
  zot(e, t, n.valueOf());
}, rR = ({ values: e }, t, n) => {
  s_(e, t * 2, n.valueOf());
}, Yot = ({ stride: e, values: t }, n, i) => {
  t.set(i.subarray(0, e), e * n);
}, sR = ({ values: e, valueOffsets: t }, n, i) => eR(e, t, n, i), oR = ({ values: e, valueOffsets: t }, n, i) => eR(e, t, n, t_(i)), Wot = (e, t, n) => {
  e.type.unit === Oi.DAY ? iR(e, t, n) : rR(e, t, n);
}, aR = ({ values: e }, t, n) => s_(e, t * 2, n / 1e3), cR = ({ values: e }, t, n) => s_(e, t * 2, n), lR = ({ values: e }, t, n) => Pot(e, t * 2, n), uR = ({ values: e }, t, n) => Vot(e, t * 2, n), Got = (e, t, n) => {
  switch (e.type.unit) {
    case bt.SECOND:
      return aR(e, t, n);
    case bt.MILLISECOND:
      return cR(e, t, n);
    case bt.MICROSECOND:
      return lR(e, t, n);
    case bt.NANOSECOND:
      return uR(e, t, n);
  }
}, fR = ({ values: e }, t, n) => {
  e[t] = n;
}, hR = ({ values: e }, t, n) => {
  e[t] = n;
}, dR = ({ values: e }, t, n) => {
  e[t] = n;
}, pR = ({ values: e }, t, n) => {
  e[t] = n;
}, Xot = (e, t, n) => {
  switch (e.type.unit) {
    case bt.SECOND:
      return fR(e, t, n);
    case bt.MILLISECOND:
      return hR(e, t, n);
    case bt.MICROSECOND:
      return dR(e, t, n);
    case bt.NANOSECOND:
      return pR(e, t, n);
  }
}, Hot = ({ values: e, stride: t }, n, i) => {
  e.set(i.subarray(0, t), t * n);
}, Jot = (e, t, n) => {
  const i = e.children[0], r = e.valueOffsets, s = fi.getVisitFn(i);
  if (Array.isArray(n))
    for (let o = -1, a = r[t], c = r[t + 1]; a < c; )
      s(i, a++, n[++o]);
  else
    for (let o = -1, a = r[t], c = r[t + 1]; a < c; )
      s(i, a++, n.get(++o));
}, Kot = (e, t, n) => {
  const i = e.children[0], { valueOffsets: r } = e, s = fi.getVisitFn(i);
  let { [t]: o, [t + 1]: a } = r;
  const c = n instanceof Map ? n.entries() : Object.entries(n);
  for (const l of c)
    if (s(i, o, l), ++o >= a)
      break;
}, Zot = (e, t) => (n, i, r, s) => i && n(i, e, t[s]), Qot = (e, t) => (n, i, r, s) => i && n(i, e, t.get(s)), tat = (e, t) => (n, i, r, s) => i && n(i, e, t.get(r.name)), eat = (e, t) => (n, i, r, s) => i && n(i, e, t[r.name]), nat = (e, t, n) => {
  const i = e.type.children.map((s) => fi.getVisitFn(s.type)), r = n instanceof Map ? tat(t, n) : n instanceof ae ? Qot(t, n) : Array.isArray(n) ? Zot(t, n) : eat(t, n);
  e.type.children.forEach((s, o) => r(i[o], e.children[o], s, o));
}, iat = (e, t, n) => {
  e.type.mode === On.Dense ? yR(e, t, n) : mR(e, t, n);
}, yR = (e, t, n) => {
  const i = e.type.typeIdToChildIndex[e.typeIds[t]], r = e.children[i];
  fi.visit(r, e.valueOffsets[t], n);
}, mR = (e, t, n) => {
  const i = e.type.typeIdToChildIndex[e.typeIds[t]], r = e.children[i];
  fi.visit(r, t, n);
}, rat = (e, t, n) => {
  var i;
  (i = e.dictionary) === null || i === void 0 || i.set(e.values[t], n);
}, sat = (e, t, n) => {
  e.type.unit === mr.DAY_TIME ? gR(e, t, n) : bR(e, t, n);
}, gR = ({ values: e }, t, n) => {
  e.set(n.subarray(0, 2), 2 * t);
}, bR = ({ values: e }, t, n) => {
  e[t] = n[0] * 12 + n[1] % 12;
}, wR = ({ values: e }, t, n) => {
  e[t] = n;
}, vR = ({ values: e }, t, n) => {
  e[t] = n;
}, _R = ({ values: e }, t, n) => {
  e[t] = n;
}, xR = ({ values: e }, t, n) => {
  e[t] = n;
}, oat = (e, t, n) => {
  switch (e.type.unit) {
    case bt.SECOND:
      return wR(e, t, n);
    case bt.MILLISECOND:
      return vR(e, t, n);
    case bt.MICROSECOND:
      return _R(e, t, n);
    case bt.NANOSECOND:
      return xR(e, t, n);
  }
}, aat = (e, t, n) => {
  const { stride: i } = e, r = e.children[0], s = fi.getVisitFn(r);
  if (Array.isArray(n))
    for (let o = -1, a = t * i; ++o < i; )
      s(r, a + o, n[o]);
  else
    for (let o = -1, a = t * i; ++o < i; )
      s(r, a + o, n.get(o));
};
It.prototype.visitBool = Nt(jot);
It.prototype.visitInt = Nt(ys);
It.prototype.visitInt8 = Nt(ys);
It.prototype.visitInt16 = Nt(ys);
It.prototype.visitInt32 = Nt(ys);
It.prototype.visitInt64 = Nt(ys);
It.prototype.visitUint8 = Nt(ys);
It.prototype.visitUint16 = Nt(ys);
It.prototype.visitUint32 = Nt(ys);
It.prototype.visitUint64 = Nt(ys);
It.prototype.visitFloat = Nt(qot);
It.prototype.visitFloat16 = Nt(nR);
It.prototype.visitFloat32 = Nt(o_);
It.prototype.visitFloat64 = Nt(o_);
It.prototype.visitUtf8 = Nt(oR);
It.prototype.visitLargeUtf8 = Nt(oR);
It.prototype.visitBinary = Nt(sR);
It.prototype.visitLargeBinary = Nt(sR);
It.prototype.visitFixedSizeBinary = Nt(Yot);
It.prototype.visitDate = Nt(Wot);
It.prototype.visitDateDay = Nt(iR);
It.prototype.visitDateMillisecond = Nt(rR);
It.prototype.visitTimestamp = Nt(Got);
It.prototype.visitTimestampSecond = Nt(aR);
It.prototype.visitTimestampMillisecond = Nt(cR);
It.prototype.visitTimestampMicrosecond = Nt(lR);
It.prototype.visitTimestampNanosecond = Nt(uR);
It.prototype.visitTime = Nt(Xot);
It.prototype.visitTimeSecond = Nt(fR);
It.prototype.visitTimeMillisecond = Nt(hR);
It.prototype.visitTimeMicrosecond = Nt(dR);
It.prototype.visitTimeNanosecond = Nt(pR);
It.prototype.visitDecimal = Nt(Hot);
It.prototype.visitList = Nt(Jot);
It.prototype.visitStruct = Nt(nat);
It.prototype.visitUnion = Nt(iat);
It.prototype.visitDenseUnion = Nt(yR);
It.prototype.visitSparseUnion = Nt(mR);
It.prototype.visitDictionary = Nt(rat);
It.prototype.visitInterval = Nt(sat);
It.prototype.visitIntervalDayTime = Nt(gR);
It.prototype.visitIntervalYearMonth = Nt(bR);
It.prototype.visitDuration = Nt(oat);
It.prototype.visitDurationSecond = Nt(wR);
It.prototype.visitDurationMillisecond = Nt(vR);
It.prototype.visitDurationMicrosecond = Nt(_R);
It.prototype.visitDurationNanosecond = Nt(xR);
It.prototype.visitFixedSizeList = Nt(aat);
It.prototype.visitMap = Nt(Kot);
const fi = new It(), mi = Symbol.for("parent"), vc = Symbol.for("rowIndex");
class a_ {
  constructor(t, n) {
    return this[mi] = t, this[vc] = n, new Proxy(this, new lat());
  }
  toArray() {
    return Object.values(this.toJSON());
  }
  toJSON() {
    const t = this[vc], n = this[mi], i = n.type.children, r = {};
    for (let s = -1, o = i.length; ++s < o; )
      r[i[s].name] = Fn.visit(n.children[s], t);
    return r;
  }
  toString() {
    return `{${[...this].map(([t, n]) => `${ef(t)}: ${ef(n)}`).join(", ")}}`;
  }
  [Symbol.for("nodejs.util.inspect.custom")]() {
    return this.toString();
  }
  [Symbol.iterator]() {
    return new cat(this[mi], this[vc]);
  }
}
class cat {
  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,
        Fn.visit(this.children[t], this.rowIndex)
      ]
    }) : { done: !0, value: null };
  }
}
Object.defineProperties(a_.prototype, {
  [Symbol.toStringTag]: { enumerable: !1, configurable: !1, value: "Row" },
  [mi]: { writable: !0, enumerable: !1, configurable: !1, value: null },
  [vc]: { writable: !0, enumerable: !1, configurable: !1, value: -1 }
});
class lat {
  isExtensible() {
    return !1;
  }
  deleteProperty() {
    return !1;
  }
  preventExtensions() {
    return !0;
  }
  ownKeys(t) {
    return t[mi].type.children.map((n) => n.name);
  }
  has(t, n) {
    return t[mi].type.children.findIndex((i) => i.name === n) !== -1;
  }
  getOwnPropertyDescriptor(t, n) {
    if (t[mi].type.children.findIndex((i) => i.name === n) !== -1)
      return { writable: !0, enumerable: !0, configurable: !0 };
  }
  get(t, n) {
    if (Reflect.has(t, n))
      return t[n];
    const i = t[mi].type.children.findIndex((r) => r.name === n);
    if (i !== -1) {
      const r = Fn.visit(t[mi].children[i], t[vc]);
      return Reflect.set(t, n, r), r;
    }
  }
  set(t, n, i) {
    const r = t[mi].type.children.findIndex((s) => s.name === n);
    return r !== -1 ? (fi.visit(t[mi].children[r], t[vc], i), Reflect.set(t, n, i)) : Reflect.has(t, n) || typeof n == "symbol" ? Reflect.set(t, n, i) : !1;
  }
}
class ft extends zt {
}
function At(e) {
  return (t, n) => t.getValid(n) ? e(t, n) : null;
}
const uat = (e, t) => 864e5 * e[t], c_ = (e, t) => 4294967296 * e[t + 1] + (e[t] >>> 0), fat = (e, t) => 4294967296 * (e[t + 1] / 1e3) + (e[t] >>> 0) / 1e3, hat = (e, t) => 4294967296 * (e[t + 1] / 1e6) + (e[t] >>> 0) / 1e6, SR = (e) => new Date(e), dat = (e, t) => SR(uat(e, t)), pat = (e, t) => SR(c_(e, t)), yat = (e, t) => null, IR = (e, t, n) => {
  if (n + 1 >= t.length)
    return null;
  const i = bn(t[n]), r = bn(t[n + 1]);
  return e.subarray(i, r);
}, mat = ({ offset: e, values: t }, n) => {
  const i = e + n;
  return (t[i >> 3] & 1 << i % 8) !== 0;
}, AR = ({ values: e }, t) => dat(e, t), MR = ({ values: e }, t) => pat(e, t * 2), ho = ({ stride: e, values: t }, n) => t[e * n], gat = ({ stride: e, values: t }, n) => tR(t[e * n]), $R = ({ values: e }, t) => e[t], bat = ({ stride: e, values: t }, n) => t.subarray(e * n, e * (n + 1)), TR = ({ values: e, valueOffsets: t }, n) => IR(e, t, n), DR = ({ values: e, valueOffsets: t }, n) => {
  const i = IR(e, t, n);
  return i !== null ? eb(i) : null;
}, wat = ({ values: e }, t) => e[t], vat = ({ type: e, values: t }, n) => e.precision !== rn.HALF ? t[n] : tR(t[n]), _at = (e, t) => e.type.unit === Oi.DAY ? AR(e, t) : MR(e, t), NR = ({ values: e }, t) => 1e3 * c_(e, t * 2), BR = ({ values: e }, t) => c_(e, t * 2), OR = ({ values: e }, t) => fat(e, t * 2), FR = ({ values: e }, t) => hat(e, t * 2), xat = (e, t) => {
  switch (e.type.unit) {
    case bt.SECOND:
      return NR(e, t);
    case bt.MILLISECOND:
      return BR(e, t);
    case bt.MICROSECOND:
      return OR(e, t);
    case bt.NANOSECOND:
      return FR(e, t);
  }
}, ER = ({ values: e }, t) => e[t], LR = ({ values: e }, t) => e[t], RR = ({ values: e }, t) => e[t], CR = ({ values: e }, t) => e[t], Sat = (e, t) => {
  switch (e.type.unit) {
    case bt.SECOND:
      return ER(e, t);
    case bt.MILLISECOND:
      return LR(e, t);
    case bt.MICROSECOND:
      return RR(e, t);
    case bt.NANOSECOND:
      return CR(e, t);
  }
}, Iat = ({ values: e, stride: t }, n) => r_.decimal(e.subarray(t * n, t * (n + 1))), Aat = (e, t) => {
  const { valueOffsets: n, stride: i, children: r } = e, { [t * i]: s, [t * i + 1]: o } = n, c = r[0].slice(s, o - s);
  return new ae([c]);
}, Mat = (e, t) => {
  const { valueOffsets: n, children: i } = e, { [t]: r, [t + 1]: s } = n, o = i[0];
  return new l_(o.slice(r, s - r));
}, $at = (e, t) => new a_(e, t), Tat = (e, t) => e.type.mode === On.Dense ? kR(e, t) : UR(e, t), kR = (e, t) => {
  const n = e.type.typeIdToChildIndex[e.typeIds[t]], i = e.children[n];
  return Fn.visit(i, e.valueOffsets[t]);
}, UR = (e, t) => {
  const n = e.type.typeIdToChildIndex[e.typeIds[t]], i = e.children[n];
  return Fn.visit(i, t);
}, Dat = (e, t) => {
  var n;
  return (n = e.dictionary) === null || n === void 0 ? void 0 : n.get(e.values[t]);
}, Nat = (e, t) => e.type.unit === mr.DAY_TIME ? zR(e, t) : PR(e, t), zR = ({ values: e }, t) => e.subarray(2 * t, 2 * (t + 1)), PR = ({ values: e }, t) => {
  const n = e[t], i = new Int32Array(2);
  return i[0] = Math.trunc(n / 12), i[1] = Math.trunc(n % 12), i;
}, VR = ({ values: e }, t) => e[t], jR = ({ values: e }, t) => e[t], qR = ({ values: e }, t) => e[t], YR = ({ values: e }, t) => e[t], Bat = (e, t) => {
  switch (e.type.unit) {
    case bt.SECOND:
      return VR(e, t);
    case bt.MILLISECOND:
      return jR(e, t);
    case bt.MICROSECOND:
      return qR(e, t);
    case bt.NANOSECOND:
      return YR(e, t);
  }
}, Oat = (e, t) => {
  const { stride: n, children: i } = e, s = i[0].slice(t * n, n);
  return new ae([s]);
};
ft.prototype.visitNull = At(yat);
ft.prototype.visitBool = At(mat);
ft.prototype.visitInt = At(wat);
ft.prototype.visitInt8 = At(ho);
ft.prototype.visitInt16 = At(ho);
ft.prototype.visitInt32 = At(ho);
ft.prototype.visitInt64 = At($R);
ft.prototype.visitUint8 = At(ho);
ft.prototype.visitUint16 = At(ho);
ft.prototype.visitUint32 = At(ho);
ft.prototype.visitUint64 = At($R);
ft.prototype.visitFloat = At(vat);
ft.prototype.visitFloat16 = At(gat);
ft.prototype.visitFloat32 = At(ho);
ft.prototype.visitFloat64 = At(ho);
ft.prototype.visitUtf8 = At(DR);
ft.prototype.visitLargeUtf8 = At(DR);
ft.prototype.visitBinary = At(TR);
ft.prototype.visitLargeBinary = At(TR);
ft.prototype.visitFixedSizeBinary = At(bat);
ft.prototype.visitDate = At(_at);
ft.prototype.visitDateDay = At(AR);
ft.prototype.visitDateMillisecond = At(MR);
ft.prototype.visitTimestamp = At(xat);
ft.prototype.visitTimestampSecond = At(NR);
ft.prototype.visitTimestampMillisecond = At(BR);
ft.prototype.visitTimestampMicrosecond = At(OR);
ft.prototype.visitTimestampNanosecond = At(FR);
ft.prototype.visitTime = At(Sat);
ft.prototype.visitTimeSecond = At(ER);
ft.prototype.visitTimeMillisecond = At(LR);
ft.prototype.visitTimeMicrosecond = At(RR);
ft.prototype.visitTimeNanosecond = At(CR);
ft.prototype.visitDecimal = At(Iat);
ft.prototype.visitList = At(Aat);
ft.prototype.visitStruct = At($at);
ft.prototype.visitUnion = At(Tat);
ft.prototype.visitDenseUnion = At(kR);
ft.prototype.visitSparseUnion = At(UR);
ft.prototype.visitDictionary = At(Dat);
ft.prototype.visitInterval = At(Nat);
ft.prototype.visitIntervalDayTime = At(zR);
ft.prototype.visitIntervalYearMonth = At(PR);
ft.prototype.visitDuration = At(Bat);
ft.prototype.visitDurationSecond = At(VR);
ft.prototype.visitDurationMillisecond = At(jR);
ft.prototype.visitDurationMicrosecond = At(qR);
ft.prototype.visitDurationNanosecond = At(YR);
ft.prototype.visitFixedSizeList = At(Oat);
ft.prototype.visitMap = At(Mat);
const Fn = new ft(), nr = Symbol.for("keys"), _c = Symbol.for("vals");
class l_ {
  constructor(t) {
    return this[nr] = new ae([t.children[0]]).memoize(), this[_c] = t.children[1], new Proxy(this, new Eat());
  }
  [Symbol.iterator]() {
    return new Fat(this[nr], this[_c]);
  }
  get size() {
    return this[nr].length;
  }
  toArray() {
    return Object.values(this.toJSON());
  }
  toJSON() {
    const t = this[nr], n = this[_c], i = {};
    for (let r = -1, s = t.length; ++r < s; )
      i[t.get(r)] = Fn.visit(n, r);
    return i;
  }
  toString() {
    return `{${[...this].map(([t, n]) => `${ef(t)}: ${ef(n)}`).join(", ")}}`;
  }
  [Symbol.for("nodejs.util.inspect.custom")]() {
    return this.toString();
  }
}
class Fat {
  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),
        Fn.visit(this.vals, t)
      ]
    });
  }
}
class Eat {
  isExtensible() {
    return !1;
  }
  deleteProperty() {
    return !1;
  }
  preventExtensions() {
    return !0;
  }
  ownKeys(t) {
    return t[nr].toArray().map(String);
  }
  has(t, n) {
    return t[nr].includes(n);
  }
  getOwnPropertyDescriptor(t, n) {
    if (t[nr].indexOf(n) !== -1)
      return { writable: !0, enumerable: !0, configurable: !0 };
  }
  get(t, n) {
    if (Reflect.has(t, n))
      return t[n];
    const i = t[nr].indexOf(n);
    if (i !== -1) {
      const r = Fn.visit(Reflect.get(t, _c), i);
      return Reflect.set(t, n, r), r;
    }
  }
  set(t, n, i) {
    const r = t[nr].indexOf(n);
    return r !== -1 ? (fi.visit(Reflect.get(t, _c), r, i), Reflect.set(t, n, i)) : Reflect.has(t, n) ? Reflect.set(t, n, i) : !1;
  }
}
Object.defineProperties(l_.prototype, {
  [Symbol.toStringTag]: { enumerable: !1, configurable: !1, value: "Row" },
  [nr]: { writable: !0, enumerable: !1, configurable: !1, value: null },
  [_c]: { writable: !0, enumerable: !1, configurable: !1, value: null }
});
let yI;
function WR(e, t, n, i) {
  const { length: r = 0 } = e;
  let s = typeof t != "number" ? 0 : t, o = typeof n != "number" ? r : n;
  return s < 0 && (s = (s % r + r) % r), o < 0 && (o = (o % r + r) % r), o < s && (yI = s, s = o, o = yI), o > r && (o = r), i ? i(e, s, o) : [s, o];
}
const mI = (e) => e !== e;
function yl(e) {
  if (typeof e !== "object" || e === null)
    return mI(e) ? mI : (n) => n === e;
  if (e instanceof Date) {
    const n = e.valueOf();
    return (i) => i instanceof Date ? i.valueOf() === n : !1;
  }
  return ArrayBuffer.isView(e) ? (n) => n ? Tot(e, n) : !1 : e instanceof Map ? Rat(e) : Array.isArray(e) ? Lat(e) : e instanceof ae ? Cat(e) : kat(e, !0);
}
function Lat(e) {
  const t = [];
  for (let n = -1, i = e.length; ++n < i; )
    t[n] = yl(e[n]);
  return K0(t);
}
function Rat(e) {
  let t = -1;
  const n = [];
  for (const i of e.values())
    n[++t] = yl(i);
  return K0(n);
}
function Cat(e) {
  const t = [];
  for (let n = -1, i = e.length; ++n < i; )
    t[n] = yl(e.get(n));
  return K0(t);
}
function kat(e, t = !1) {
  const n = Object.keys(e);
  if (!t && n.length === 0)
    return () => !1;
  const i = [];
  for (let r = -1, s = n.length; ++r < s; )
    i[r] = yl(e[n[r]]);
  return K0(i, n);
}
function K0(e, t) {
  return (n) => {
    if (!n || typeof n != "object")
      return !1;
    switch (n.constructor) {
      case Array:
        return Uat(e, n);
      case Map:
        return gI(e, n, n.keys());
      case l_:
      case a_:
      case Object:
      case void 0:
        return gI(e, n, t || Object.keys(n));
    }
    return n instanceof ae ? zat(e, n) : !1;
  };
}
function Uat(e, t) {
  const n = e.length;
  if (t.length !== n)
    return !1;
  for (let i = -1; ++i < n; )
    if (!e[i](t[i]))
      return !1;
  return !0;
}
function zat(e, t) {
  const n = e.length;
  if (t.length !== n)
    return !1;
  for (let i = -1; ++i < n; )
    if (!e[i](t.get(i)))
      return !1;
  return !0;
}
function gI(e, t, n) {
  const i = n[Symbol.iterator](), r = 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(), l = i.next(), u = r.next();
  for (; o < a && !l.done && !u.done && !c.done && !(l.value !== u.value || !e[o](c.value)); ++o, l = i.next(), u = r.next(), c = s.next())
    ;
  return o === a && l.done && u.done && c.done ? !0 : (i.return && i.return(), r.return && r.return(), s.return && s.return(), !1);
}
function GR(e, t, n, i) {
  return (n & 1 << i) !== 0;
}
function Pat(e, t, n, i) {
  return (n & 1 << i) >> i;
}
function bI(e, t, n) {
  const i = n.byteLength + 7 & -8;
  if (e > 0 || n.byteLength < i) {
    const r = new Uint8Array(i);
    return r.set(e % 8 === 0 ? n.subarray(e >> 3) : (
      // Otherwise iterate each bit from the offset and return a new one
      ob(new u_(n, e, t, null, GR)).subarray(0, i)
    )), r;
  }
  return n;
}
function ob(e) {
  const t = [];
  let n = 0, i = 0, r = 0;
  for (const o of e)
    o && (r |= 1 << i), ++i === 8 && (t[n++] = r, r = i = 0);
  (n === 0 || i > 0) && (t[n++] = r);
  const s = new Uint8Array(t.length + 7 & -8);
  return s.set(t), s;
}
class u_ {
  constructor(t, n, i, r, s) {
    this.bytes = t, this.length = i, this.context = r, 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 ab(e, t, n) {
  if (n - t <= 0)
    return 0;
  if (n - t < 8) {
    let s = 0;
    for (const o of new u_(e, t, n - t, e, Pat))
      s += o;
    return s;
  }
  const i = n >> 3 << 3, r = 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
    ab(e, t, r) + // Get the popcnt of bits between the right hand side, and the next lowest multiple of 8
    ab(e, i, n) + // Get the popcnt of all bits between the left and right hand sides' multiples of 8
    Vat(e, r >> 3, i - r >> 3)
  );
}
function Vat(e, t, n) {
  let i = 0, r = Math.trunc(t);
  const s = new DataView(e.buffer, e.byteOffset, e.byteLength), o = n === void 0 ? e.byteLength : r + n;
  for (; o - r >= 4; )
    i += ug(s.getUint32(r)), r += 4;
  for (; o - r >= 2; )
    i += ug(s.getUint16(r)), r += 2;
  for (; o - r >= 1; )
    i += ug(s.getUint8(r)), r += 1;
  return i;
}
function ug(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 jat = -1;
class ne {
  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 st.isSparseUnion(t) ? this.children.some((n) => n.nullable) : st.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: i, nullBitmap: r, typeIds: s } = this;
    return n && (t += n.byteLength), i && (t += i.byteLength), r && (t += r.byteLength), s && (t += s.byteLength), this.children.reduce((o, a) => o + a.byteLength, t);
  }
  get nullCount() {
    if (st.isUnion(this.type))
      return this.children.reduce((i, r) => i + r.nullCount, 0);
    let t = this._nullCount, n;
    return t <= jat && (n = this.nullBitmap) && (this._nullCount = t = this.length - ab(n, this.offset, this.offset + this.length)), t;
  }
  constructor(t, n, i, r, 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(i || 0, 0)), this._nullCount = Math.floor(Math.max(r || 0, -1));
    let c;
    s instanceof ne ? (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 (st.isUnion(n)) {
      const i = n, r = this.children[i.typeIdToChildIndex[this.typeIds[t]]], s = i.mode === On.Dense ? this.valueOffsets[t] : t;
      return r.getValid(s);
    }
    if (this.nullable && this.nullCount > 0) {
      const i = this.offset + t;
      return (this.nullBitmap[i >> 3] & 1 << i % 8) !== 0;
    }
    return !0;
  }
  setValid(t, n) {
    let i;
    const { type: r } = this;
    if (st.isUnion(r)) {
      const s = r, o = this.children[s.typeIdToChildIndex[this.typeIds[t]]], a = s.mode === On.Dense ? this.valueOffsets[t] : t;
      i = o.getValid(a), o.setValid(a, n);
    } else {
      let { nullBitmap: s } = this;
      const { offset: o, length: a } = this, c = o + t, l = 1 << c % 8, u = c >> 3;
      (!s || s.byteLength <= u) && (s = new Uint8Array((o + a + 63 & -64) >> 3).fill(255), this.nullCount > 0 && s.set(bI(o, a, this.nullBitmap), 0), Object.assign(this, { nullBitmap: s, _nullCount: -1 }));
      const f = s[u];
      i = (f & l) !== 0, n ? s[u] = f | l : s[u] = f & ~l;
    }
    return i !== !!n && (this._nullCount = this.nullCount + (n ? -1 : 1)), n;
  }
  clone(t = this.type, n = this.offset, i = this.length, r = this._nullCount, s = this, o = this.children) {
    return new ne(t, n, i, r, s, o, this.dictionary);
  }
  slice(t, n) {
    const { stride: i, typeId: r, children: s } = this, o = +(this._nullCount === 0) - 1, a = r === 16 ? i : 1, c = this._sliceBuffers(t, n, i, r);
    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 === E.Null)
      return this.clone(this.type, 0, t, 0);
    const { length: n, nullCount: i } = this, r = new Uint8Array((t + 63 & -64) >> 3).fill(255, 0, n >> 3);
    r[n >> 3] = (1 << n - (n & -8)) - 1, i > 0 && r.set(bI(this.offset, n, this.nullBitmap), 0);
    const s = this.buffers;
    return s[kr.VALIDITY] = r, this.clone(this.type, 0, t, i + (t - n), s);
  }
  _sliceBuffers(t, n, i, r) {
    let s;
    const { buffers: o } = this;
    return (s = o[kr.TYPE]) && (o[kr.TYPE] = s.subarray(t, t + n)), (s = o[kr.OFFSET]) && (o[kr.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[kr.DATA]) && (o[kr.DATA] = r === 6 ? s : s.subarray(i * t, i * (t + n))), o;
  }
  _sliceChildren(t, n, i) {
    return t.map((r) => r.slice(n, i));
  }
}
ne.prototype.children = Object.freeze([]);
class wu extends zt {
  visit(t) {
    return this.getVisitFn(t.type).call(this, t);
  }
  visitNull(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["length"]: r = 0 } = t;
    return new ne(n, i, r, r);
  }
  visitBool(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Wt(t.nullBitmap), s = se(n.ArrayType, t.data), { ["length"]: o = s.length >> 3, ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new ne(n, i, o, a, [void 0, s, r]);
  }
  visitInt(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Wt(t.nullBitmap), s = se(n.ArrayType, t.data), { ["length"]: o = s.length, ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new ne(n, i, o, a, [void 0, s, r]);
  }
  visitFloat(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Wt(t.nullBitmap), s = se(n.ArrayType, t.data), { ["length"]: o = s.length, ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new ne(n, i, o, a, [void 0, s, r]);
  }
  visitUtf8(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Wt(t.data), s = Wt(t.nullBitmap), o = Fl(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new ne(n, i, a, c, [o, r, s]);
  }
  visitLargeUtf8(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Wt(t.data), s = Wt(t.nullBitmap), o = oI(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new ne(n, i, a, c, [o, r, s]);
  }
  visitBinary(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Wt(t.data), s = Wt(t.nullBitmap), o = Fl(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new ne(n, i, a, c, [o, r, s]);
  }
  visitLargeBinary(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Wt(t.data), s = Wt(t.nullBitmap), o = oI(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new ne(n, i, a, c, [o, r, s]);
  }
  visitFixedSizeBinary(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Wt(t.nullBitmap), s = se(n.ArrayType, t.data), { ["length"]: o = s.length / Ur(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new ne(n, i, o, a, [void 0, s, r]);
  }
  visitDate(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Wt(t.nullBitmap), s = se(n.ArrayType, t.data), { ["length"]: o = s.length / Ur(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new ne(n, i, o, a, [void 0, s, r]);
  }
  visitTimestamp(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Wt(t.nullBitmap), s = se(n.ArrayType, t.data), { ["length"]: o = s.length / Ur(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new ne(n, i, o, a, [void 0, s, r]);
  }
  visitTime(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Wt(t.nullBitmap), s = se(n.ArrayType, t.data), { ["length"]: o = s.length / Ur(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new ne(n, i, o, a, [void 0, s, r]);
  }
  visitDecimal(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Wt(t.nullBitmap), s = se(n.ArrayType, t.data), { ["length"]: o = s.length / Ur(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new ne(n, i, o, a, [void 0, s, r]);
  }
  visitList(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["child"]: r } = t, s = Wt(t.nullBitmap), o = Fl(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new ne(n, i, a, c, [o, void 0, s], [r]);
  }
  visitStruct(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["children"]: r = [] } = t, s = Wt(t.nullBitmap), { length: o = r.reduce((c, { length: l }) => Math.max(c, l), 0), nullCount: a = t.nullBitmap ? -1 : 0 } = t;
    return new ne(n, i, o, a, [void 0, void 0, s], r);
  }
  visitUnion(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["children"]: r = [] } = t, s = se(n.ArrayType, t.typeIds), { ["length"]: o = s.length, ["nullCount"]: a = -1 } = t;
    if (st.isSparseUnion(n))
      return new ne(n, i, o, a, [void 0, void 0, void 0, s], r);
    const c = Fl(t.valueOffsets);
    return new ne(n, i, o, a, [c, void 0, void 0, s], r);
  }
  visitDictionary(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Wt(t.nullBitmap), s = se(n.indices.ArrayType, t.data), { ["dictionary"]: o = new ae([new wu().visit({ type: n.dictionary })]) } = t, { ["length"]: a = s.length, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new ne(n, i, a, c, [void 0, s, r], [], o);
  }
  visitInterval(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Wt(t.nullBitmap), s = se(n.ArrayType, t.data), { ["length"]: o = s.length / Ur(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new ne(n, i, o, a, [void 0, s, r]);
  }
  visitDuration(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Wt(t.nullBitmap), s = se(n.ArrayType, t.data), { ["length"]: o = s.length, ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new ne(n, i, o, a, [void 0, s, r]);
  }
  visitFixedSizeList(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["child"]: r = new wu().visit({ type: n.valueType }) } = t, s = Wt(t.nullBitmap), { ["length"]: o = r.length / Ur(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new ne(n, i, o, a, [void 0, void 0, s], [r]);
  }
  visitMap(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["child"]: r = new wu().visit({ type: n.childType }) } = t, s = Wt(t.nullBitmap), o = Fl(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new ne(n, i, a, c, [o, void 0, s], [r]);
  }
}
const qat = new wu();
function Ct(e) {
  return qat.visit(e);
}
class wI {
  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 Yat(e) {
  return e.some((t) => t.nullable);
}
function XR(e) {
  return e.reduce((t, n) => t + n.nullCount, 0);
}
function HR(e) {
  return e.reduce((t, n, i) => (t[i + 1] = t[i] + n.length, t), new Uint32Array(e.length + 1));
}
function JR(e, t, n, i) {
  const r = [];
  for (let s = -1, o = e.length; ++s < o; ) {
    const a = e[s], c = t[s], { length: l } = a;
    if (c >= i)
      break;
    if (n >= c + l)
      continue;
    if (c >= n && c + l <= i) {
      r.push(a);
      continue;
    }
    const u = Math.max(0, n - c), f = Math.min(i - c, l);
    r.push(a.slice(u, f - u));
  }
  return r.length === 0 && r.push(e[0].slice(0, 0)), r;
}
function f_(e, t, n, i) {
  let r = 0, s = 0, o = t.length - 1;
  do {
    if (r >= o - 1)
      return n < t[o] ? i(e, r, n - t[r]) : null;
    s = r + Math.trunc((o - r) * 0.5), n < t[s] ? o = s : r = s;
  } while (r < o);
}
function h_(e, t) {
  return e.getValid(t);
}
function $y(e) {
  function t(n, i, r) {
    return e(n[i], r);
  }
  return function(n) {
    const i = this.data;
    return f_(i, this._offsets, n, t);
  };
}
function KR(e) {
  let t;
  function n(i, r, s) {
    return e(i[r], s, t);
  }
  return function(i, r) {
    const s = this.data;
    t = r;
    const o = f_(s, this._offsets, i, n);
    return t = void 0, o;
  };
}
function ZR(e) {
  let t;
  function n(i, r, s) {
    let o = s, a = 0, c = 0;
    for (let l = r - 1, u = i.length; ++l < u; ) {
      const f = i[l];
      if (~(a = e(f, t, o)))
        return c + a;
      o = 0, c += f.length;
    }
    return -1;
  }
  return function(i, r) {
    t = i;
    const s = this.data, o = typeof r != "number" ? n(s, 0, 0) : f_(s, this._offsets, r, n);
    return t = void 0, o;
  };
}
class ht extends zt {
}
function Wat(e, t) {
  return t === null && e.length > 0 ? 0 : -1;
}
function Gat(e, t) {
  const { nullBitmap: n } = e;
  if (!n || e.nullCount <= 0)
    return -1;
  let i = 0;
  for (const r of new u_(n, e.offset + (t || 0), e.length, n, GR)) {
    if (!r)
      return i;
    ++i;
  }
  return -1;
}
function Ot(e, t, n) {
  if (t === void 0)
    return -1;
  if (t === null)
    switch (e.typeId) {
      case E.Union:
        break;
      case E.Dictionary:
        break;
      default:
        return Gat(e, n);
    }
  const i = Fn.getVisitFn(e), r = yl(t);
  for (let s = (n || 0) - 1, o = e.length; ++s < o; )
    if (r(i(e, s)))
      return s;
  return -1;
}
function QR(e, t, n) {
  const i = Fn.getVisitFn(e), r = yl(t);
  for (let s = (n || 0) - 1, o = e.length; ++s < o; )
    if (r(i(e, s)))
      return s;
  return -1;
}
ht.prototype.visitNull = Wat;
ht.prototype.visitBool = Ot;
ht.prototype.visitInt = Ot;
ht.prototype.visitInt8 = Ot;
ht.prototype.visitInt16 = Ot;
ht.prototype.visitInt32 = Ot;
ht.prototype.visitInt64 = Ot;
ht.prototype.visitUint8 = Ot;
ht.prototype.visitUint16 = Ot;
ht.prototype.visitUint32 = Ot;
ht.prototype.visitUint64 = Ot;
ht.prototype.visitFloat = Ot;
ht.prototype.visitFloat16 = Ot;
ht.prototype.visitFloat32 = Ot;
ht.prototype.visitFloat64 = Ot;
ht.prototype.visitUtf8 = Ot;
ht.prototype.visitLargeUtf8 = Ot;
ht.prototype.visitBinary = Ot;
ht.prototype.visitLargeBinary = Ot;
ht.prototype.visitFixedSizeBinary = Ot;
ht.prototype.visitDate = Ot;
ht.prototype.visitDateDay = Ot;
ht.prototype.visitDateMillisecond = Ot;
ht.prototype.visitTimestamp = Ot;
ht.prototype.visitTimestampSecond = Ot;
ht.prototype.visitTimestampMillisecond = Ot;
ht.prototype.visitTimestampMicrosecond = Ot;
ht.prototype.visitTimestampNanosecond = Ot;
ht.prototype.visitTime = Ot;
ht.prototype.visitTimeSecond = Ot;
ht.prototype.visitTimeMillisecond = Ot;
ht.prototype.visitTimeMicrosecond = Ot;
ht.prototype.visitTimeNanosecond = Ot;
ht.prototype.visitDecimal = Ot;
ht.prototype.visitList = Ot;
ht.prototype.visitStruct = Ot;
ht.prototype.visitUnion = Ot;
ht.prototype.visitDenseUnion = QR;
ht.prototype.visitSparseUnion = QR;
ht.prototype.visitDictionary = Ot;
ht.prototype.visitInterval = Ot;
ht.prototype.visitIntervalDayTime = Ot;
ht.prototype.visitIntervalYearMonth = Ot;
ht.prototype.visitDuration = Ot;
ht.prototype.visitDurationSecond = Ot;
ht.prototype.visitDurationMillisecond = Ot;
ht.prototype.visitDurationMicrosecond = Ot;
ht.prototype.visitDurationNanosecond = Ot;
ht.prototype.visitFixedSizeList = Ot;
ht.prototype.visitMap = Ot;
const Ty = new ht();
class dt extends zt {
}
function Mt(e) {
  const { type: t } = e;
  if (e.nullCount === 0 && e.stride === 1 && (t.typeId === E.Timestamp || t instanceof to && t.bitWidth !== 64 || t instanceof af && t.bitWidth !== 64 || t instanceof of && t.precision !== rn.HALF))
    return new wI(e.data.length, (i) => {
      const r = e.data[i];
      return r.values.subarray(0, r.length)[Symbol.iterator]();
    });
  let n = 0;
  return new wI(e.data.length, (i) => {
    const s = e.data[i].length, o = e.slice(n, n + s);
    return n += s, new Xat(o);
  });
}
class Xat {
  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;
  }
}
dt.prototype.visitNull = Mt;
dt.prototype.visitBool = Mt;
dt.prototype.visitInt = Mt;
dt.prototype.visitInt8 = Mt;
dt.prototype.visitInt16 = Mt;
dt.prototype.visitInt32 = Mt;
dt.prototype.visitInt64 = Mt;
dt.prototype.visitUint8 = Mt;
dt.prototype.visitUint16 = Mt;
dt.prototype.visitUint32 = Mt;
dt.prototype.visitUint64 = Mt;
dt.prototype.visitFloat = Mt;
dt.prototype.visitFloat16 = Mt;
dt.prototype.visitFloat32 = Mt;
dt.prototype.visitFloat64 = Mt;
dt.prototype.visitUtf8 = Mt;
dt.prototype.visitLargeUtf8 = Mt;
dt.prototype.visitBinary = Mt;
dt.prototype.visitLargeBinary = Mt;
dt.prototype.visitFixedSizeBinary = Mt;
dt.prototype.visitDate = Mt;
dt.prototype.visitDateDay = Mt;
dt.prototype.visitDateMillisecond = Mt;
dt.prototype.visitTimestamp = Mt;
dt.prototype.visitTimestampSecond = Mt;
dt.prototype.visitTimestampMillisecond = Mt;
dt.prototype.visitTimestampMicrosecond = Mt;
dt.prototype.visitTimestampNanosecond = Mt;
dt.prototype.visitTime = Mt;
dt.prototype.visitTimeSecond = Mt;
dt.prototype.visitTimeMillisecond = Mt;
dt.prototype.visitTimeMicrosecond = Mt;
dt.prototype.visitTimeNanosecond = Mt;
dt.prototype.visitDecimal = Mt;
dt.prototype.visitList = Mt;
dt.prototype.visitStruct = Mt;
dt.prototype.visitUnion = Mt;
dt.prototype.visitDenseUnion = Mt;
dt.prototype.visitSparseUnion = Mt;
dt.prototype.visitDictionary = Mt;
dt.prototype.visitInterval = Mt;
dt.prototype.visitIntervalDayTime = Mt;
dt.prototype.visitIntervalYearMonth = Mt;
dt.prototype.visitDuration = Mt;
dt.prototype.visitDurationSecond = Mt;
dt.prototype.visitDurationMillisecond = Mt;
dt.prototype.visitDurationMicrosecond = Mt;
dt.prototype.visitDurationNanosecond = Mt;
dt.prototype.visitFixedSizeList = Mt;
dt.prototype.visitMap = Mt;
const d_ = new dt();
var tC;
const eC = {}, nC = {};
class ae {
  constructor(t) {
    var n, i, r;
    const s = t[0] instanceof ae ? t.flatMap((a) => a.data) : t;
    if (s.length === 0 || s.some((a) => !(a instanceof ne)))
      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: l } = eC[o.typeId], u = s[0];
        this.isValid = (f) => h_(u, f), this.get = (f) => a(u, f), this.set = (f, h) => c(u, f, h), this.indexOf = (f) => l(u, f), this._offsets = [0, u.length];
        break;
      }
      default:
        Object.setPrototypeOf(this, nC[o.typeId]), this._offsets = HR(s);
        break;
    }
    this.data = s, this.type = o, this.stride = Ur(o), this.numChildren = (r = (i = o.children) === null || i === void 0 ? void 0 : i.length) !== null && r !== void 0 ? r : 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 Yat(this.data);
  }
  /**
   * The number of null elements in this Vector.
   */
  get nullCount() {
    return XR(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 `${E[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;
  }
  /**
   * 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 d_.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 ae(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 ae(WR(this, t, n, ({ data: i, _offsets: r }, s, o) => JR(i, r, 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: i, stride: r, ArrayType: s } = this;
    switch (t.typeId) {
      case E.Int:
      case E.Float:
      case E.Decimal:
      case E.Time:
      case E.Timestamp:
        switch (n.length) {
          case 0:
            return new s();
          case 1:
            return n[0].values.subarray(0, i * r);
          default:
            return n.reduce((o, { values: a, length: c }) => (o.array.set(a.subarray(0, c * r), o.offset), o.offset += c * r, o), { array: new s(i * r), 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((i) => i.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 ae(this.data.map(({ children: n }) => n[t])) : null;
  }
  get isMemoized() {
    return st.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 (st.isDictionary(this.type)) {
      const t = new Dy(this.data[0].dictionary), n = this.data.map((i) => {
        const r = i.clone();
        return r.dictionary = t, r;
      });
      return new ae(n);
    }
    return new Dy(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 (st.isDictionary(this.type) && this.isMemoized) {
      const t = this.data[0].dictionary.unmemoize(), n = this.data.map((i) => {
        const r = i.clone();
        return r.dictionary = t, r;
      });
      return new ae(n);
    }
    return this;
  }
}
tC = Symbol.toStringTag;
ae[tC] = ((e) => {
  e.type = st.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(E).map((n) => E[n]).filter((n) => typeof n == "number" && n !== E.NONE);
  for (const n of t) {
    const i = Fn.getVisitFnByTypeId(n), r = fi.getVisitFnByTypeId(n), s = Ty.getVisitFnByTypeId(n);
    eC[n] = { get: i, set: r, indexOf: s }, nC[n] = Object.create(e, {
      isValid: { value: $y(h_) },
      get: { value: $y(Fn.getVisitFnByTypeId(n)) },
      set: { value: KR(fi.getVisitFnByTypeId(n)) },
      indexOf: { value: ZR(Ty.getVisitFnByTypeId(n)) }
    });
  }
  return "Vector";
})(ae.prototype);
class Dy extends ae {
  constructor(t) {
    super(t.data);
    const n = this.get, i = this.set, r = 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) {
        i.call(this, o, a), s[o] = a;
      }
    }), Object.defineProperty(this, "slice", {
      value: (o, a) => new Dy(r.call(this, o, a))
    }), Object.defineProperty(this, "isMemoized", { value: !0 }), Object.defineProperty(this, "unmemoize", {
      value: () => new ae(this.data)
    }), Object.defineProperty(this, "memoize", {
      value: () => this
    });
  }
}
class cb {
  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, i, r) {
    return t.prep(8, 24), t.writeInt64(BigInt(r ?? 0)), t.pad(4), t.writeInt32(i), t.writeInt64(BigInt(n ?? 0)), t.offset();
  }
}
class Ln {
  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 Ln()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFooter(t, n) {
    return t.setPosition(t.position() + nt), (n || new Ln()).__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) : Le.V1;
  }
  schema(t) {
    const n = this.bb.__offset(this.bb_pos, 6);
    return n ? (t || new Gi()).__init(this.bb.__indirect(this.bb_pos + n), this.bb) : null;
  }
  dictionaries(t, n) {
    const i = this.bb.__offset(this.bb_pos, 8);
    return i ? (n || new cb()).__init(this.bb.__vector(this.bb_pos + i) + 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 i = this.bb.__offset(this.bb_pos, 10);
    return i ? (n || new cb()).__init(this.bb.__vector(this.bb_pos + i) + 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 i = this.bb.__offset(this.bb_pos, 12);
    return i ? (n || new Ce()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + i) + 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, Le.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 i = n.length - 1; i >= 0; i--)
      t.addOffset(n[i]);
    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 ee {
  constructor(t = [], n, i, r = Le.V5) {
    this.fields = t || [], this.metadata = n || /* @__PURE__ */ new Map(), i || (i = lb(t)), this.dictionaries = i, this.metadataVersion = r;
  }
  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), i = this.fields.filter((r) => n.has(r.name));
    return new ee(i, 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((i) => this.fields[i]).filter(Boolean);
    return new ee(n, this.metadata);
  }
  assign(...t) {
    const n = t[0] instanceof ee ? t[0] : Array.isArray(t[0]) ? new ee(t[0]) : new ee(t), i = [...this.fields], r = kh(kh(/* @__PURE__ */ new Map(), this.metadata), n.metadata), s = n.fields.filter((a) => {
      const c = i.findIndex((l) => l.name === a.name);
      return ~c ? (i[c] = a.clone({
        metadata: kh(kh(/* @__PURE__ */ new Map(), i[c].metadata), a.metadata)
      })) && !1 : !0;
    }), o = lb(s, /* @__PURE__ */ new Map());
    return new ee([...i, ...s], r, new Map([...this.dictionaries, ...o]));
  }
}
ee.prototype.fields = null;
ee.prototype.metadata = null;
ee.prototype.dictionaries = null;
class ge {
  /** @nocollapse */
  static new(...t) {
    let [n, i, r, s] = t;
    return t[0] && typeof t[0] == "object" && ({ name: n } = t[0], i === void 0 && (i = t[0].type), r === void 0 && (r = t[0].nullable), s === void 0 && (s = t[0].metadata)), new ge(`${n}`, i, r, s);
  }
  constructor(t, n, i = !1, r) {
    this.name = t, this.type = n, this.nullable = i, this.metadata = r || /* @__PURE__ */ new Map();
  }
  get typeId() {
    return this.type.typeId;
  }
  get [Symbol.toStringTag]() {
    return "Field";
  }
  toString() {
    return `${this.name}: ${this.type}`;
  }
  clone(...t) {
    let [n, i, r, s] = t;
    return !t[0] || typeof t[0] != "object" ? [n = this.name, i = this.type, r = this.nullable, s = this.metadata] = t : { name: n = this.name, type: i = this.type, nullable: r = this.nullable, metadata: s = this.metadata } = t[0], ge.new(n, i, r, s);
  }
}
ge.prototype.type = null;
ge.prototype.name = null;
ge.prototype.nullable = null;
ge.prototype.metadata = null;
function kh(e, t) {
  return new Map([...e || /* @__PURE__ */ new Map(), ...t || /* @__PURE__ */ new Map()]);
}
function lb(e, t = /* @__PURE__ */ new Map()) {
  for (let n = -1, i = e.length; ++n < i; ) {
    const s = e[n].type;
    if (st.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 && lb(s.children, t);
  }
  return t;
}
var Hat = ky, Jat = ur;
class p_ {
  /** @nocollapse */
  static decode(t) {
    t = new Jat(Wt(t));
    const n = Ln.getRootAsFooter(t), i = ee.decode(n.schema(), /* @__PURE__ */ new Map(), n.version());
    return new Kat(i, n);
  }
  /** @nocollapse */
  static encode(t) {
    const n = new Hat(), i = ee.encode(n, t.schema);
    Ln.startRecordBatchesVector(n, t.numRecordBatches);
    for (const o of [...t.recordBatches()].slice().reverse())
      Xc.encode(n, o);
    const r = n.endVector();
    Ln.startDictionariesVector(n, t.numDictionaries);
    for (const o of [...t.dictionaryBatches()].slice().reverse())
      Xc.encode(n, o);
    const s = n.endVector();
    return Ln.startFooter(n), Ln.addSchema(n, i), Ln.addVersion(n, Le.V5), Ln.addRecordBatches(n, r), Ln.addDictionaries(n, s), Ln.finishFooterBuffer(n, Ln.endFooter(n)), n.asUint8Array();
  }
  get numRecordBatches() {
    return this._recordBatches.length;
  }
  get numDictionaries() {
    return this._dictionaryBatches.length;
  }
  constructor(t, n = Le.V5, i, r) {
    this.schema = t, this.version = n, i && (this._recordBatches = i), r && (this._dictionaryBatches = r);
  }
  *recordBatches() {
    for (let t, n = -1, i = this.numRecordBatches; ++n < i; )
      (t = this.getRecordBatch(n)) && (yield t);
  }
  *dictionaryBatches() {
    for (let t, n = -1, i = this.numDictionaries; ++n < i; )
      (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 Kat extends p_ {
  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 Xc.decode(n);
    }
    return null;
  }
  getDictionaryBatch(t) {
    if (t >= 0 && t < this.numDictionaries) {
      const n = this._footer.dictionaries(t);
      if (n)
        return Xc.decode(n);
    }
    return null;
  }
}
class Xc {
  /** @nocollapse */
  static decode(t) {
    return new Xc(t.metaDataLength(), t.bodyLength(), t.offset());
  }
  /** @nocollapse */
  static encode(t, n) {
    const { metaDataLength: i } = n, r = BigInt(n.offset), s = BigInt(n.bodyLength);
    return cb.createBlock(t, r, i, s);
  }
  constructor(t, n, i) {
    this.metaDataLength = t, this.offset = bn(i), this.bodyLength = bn(n);
  }
}
const Ie = Object.freeze({ done: !0, value: void 0 });
class vI {
  constructor(t) {
    this._json = t;
  }
  get schema() {
    return this._json.schema;
  }
  get batches() {
    return this._json.batches || [];
  }
  get dictionaries() {
    return this._json.dictionaries || [];
  }
}
class iC {
  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 Zat extends iC {
  constructor() {
    super(), this._values = [], this.resolvers = [], this._closedPromise = new Promise((t) => this._closedPromiseResolve = t);
  }
  get closed() {
    return this._closedPromise;
  }
  cancel(t) {
    return W(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(Ie);
      this._closedPromiseResolve(), this._closedPromiseResolve = void 0;
    }
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  toDOMStream(t) {
    return Jn.toDOMStream(this._closedPromiseResolve || this._error ? this : this._values, t);
  }
  toNodeStream(t) {
    return Jn.toNodeStream(this._closedPromiseResolve || this._error ? this : this._values, t);
  }
  throw(t) {
    return W(this, void 0, void 0, function* () {
      return yield this.abort(t), Ie;
    });
  }
  return(t) {
    return W(this, void 0, void 0, function* () {
      return yield this.close(), Ie;
    });
  }
  read(t) {
    return W(this, void 0, void 0, function* () {
      return (yield this.next(t, "read")).value;
    });
  }
  peek(t) {
    return W(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, i) => {
      this.resolvers.push({ resolve: n, reject: i });
    }) : Promise.resolve(Ie);
  }
  _ensureOpen() {
    if (this._closedPromiseResolve)
      return !0;
    throw new Error("AsyncQueue is closed");
  }
}
class Qat extends Zat {
  write(t) {
    if ((t = Wt(t)).byteLength > 0)
      return super.write(t);
  }
  toString(t = !1) {
    return t ? eb(this.toUint8Array(!0)) : this.toUint8Array(!1).then(eb);
  }
  toUint8Array(t = !1) {
    return t ? yr(this._values)[0] : W(this, void 0, void 0, function* () {
      var n, i, r, s;
      const o = [];
      let a = 0;
      try {
        for (var c = !0, l = ai(this), u; u = yield l.next(), n = u.done, !n; c = !0) {
          s = u.value, c = !1;
          const f = s;
          o.push(f), a += f.byteLength;
        }
      } catch (f) {
        i = { error: f };
      } finally {
        try {
          !c && !n && (r = l.return) && (yield r.call(l));
        } finally {
          if (i)
            throw i.error;
        }
      }
      return yr(o, a)[0];
    });
  }
}
class Ny {
  constructor(t) {
    t && (this.source = new tct(Jn.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 Hc {
  constructor(t) {
    t instanceof Hc ? this.source = t.source : t instanceof Qat ? this.source = new go(Jn.fromAsyncIterable(t)) : ML(t) ? this.source = new go(Jn.fromNodeStream(t)) : n_(t) ? this.source = new go(Jn.fromDOMStream(t)) : IL(t) ? this.source = new go(Jn.fromDOMStream(t.body)) : J0(t) ? this.source = new go(Jn.fromIterable(t)) : tf(t) ? this.source = new go(Jn.fromAsyncIterable(t)) : e_(t) && (this.source = new go(Jn.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 tct {
  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) || Ie);
  }
  return(t) {
    return Object.create(this.source.return && this.source.return(t) || Ie);
  }
}
class go {
  constructor(t) {
    this.source = t, this._closedPromise = new Promise((n) => this._closedPromiseResolve = n);
  }
  cancel(t) {
    return W(this, void 0, void 0, function* () {
      yield this.return(t);
    });
  }
  get closed() {
    return this._closedPromise;
  }
  read(t) {
    return W(this, void 0, void 0, function* () {
      return (yield this.next(t, "read")).value;
    });
  }
  peek(t) {
    return W(this, void 0, void 0, function* () {
      return (yield this.next(t, "peek")).value;
    });
  }
  next(t, n = "read") {
    return W(this, void 0, void 0, function* () {
      return yield this.source.next({ cmd: n, size: t });
    });
  }
  throw(t) {
    return W(this, void 0, void 0, function* () {
      const n = this.source.throw && (yield this.source.throw(t)) || Ie;
      return this._closedPromiseResolve && this._closedPromiseResolve(), this._closedPromiseResolve = void 0, Object.create(n);
    });
  }
  return(t) {
    return W(this, void 0, void 0, function* () {
      const n = this.source.return && (yield this.source.return(t)) || Ie;
      return this._closedPromiseResolve && this._closedPromiseResolve(), this._closedPromiseResolve = void 0, Object.create(n);
    });
  }
}
class _I extends Ny {
  constructor(t, n) {
    super(), this.position = 0, this.buffer = Wt(t), this.size = n === void 0 ? this.buffer.byteLength : n;
  }
  readInt32(t) {
    const { buffer: n, byteOffset: i } = this.readAt(t, 4);
    return new DataView(n, i).getInt32(0, !0);
  }
  seek(t) {
    return this.position = Math.min(t, this.size), t < this.size;
  }
  read(t) {
    const { buffer: n, size: i, position: r } = this;
    return n && r < i ? (typeof t != "number" && (t = Number.POSITIVE_INFINITY), this.position = Math.min(i, r + Math.min(i - r, t)), n.subarray(r, this.position)) : null;
  }
  readAt(t, n) {
    const i = this.buffer, r = Math.min(this.size, t + n);
    return i ? i.subarray(t, r) : 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 By extends Hc {
  constructor(t, n) {
    super(), this.position = 0, this._handle = t, typeof n == "number" ? this.size = n : this._pending = W(this, void 0, void 0, function* () {
      this.size = (yield t.stat()).size, delete this._pending;
    });
  }
  readInt32(t) {
    return W(this, void 0, void 0, function* () {
      const { buffer: n, byteOffset: i } = yield this.readAt(t, 4);
      return new DataView(n, i).getInt32(0, !0);
    });
  }
  seek(t) {
    return W(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 W(this, void 0, void 0, function* () {
      this._pending && (yield this._pending);
      const { _handle: n, size: i, position: r } = this;
      if (n && r < i) {
        typeof t != "number" && (t = Number.POSITIVE_INFINITY);
        let s = r, o = 0, a = 0;
        const c = Math.min(i, s + Math.min(i - s, t)), l = new Uint8Array(Math.max(0, (this.position = c) - s));
        for (; (s += a) < c && (o += a) < l.byteLength; )
          ({ bytesRead: a } = yield n.read(l, o, l.byteLength - o, s));
        return l;
      }
      return null;
    });
  }
  readAt(t, n) {
    return W(this, void 0, void 0, function* () {
      this._pending && (yield this._pending);
      const { _handle: i, size: r } = this;
      if (i && t + n < r) {
        const s = Math.min(r, t + n), o = new Uint8Array(s - t);
        return (yield i.read(o, 0, n, t)).buffer;
      }
      return new Uint8Array(n);
    });
  }
  close() {
    return W(this, void 0, void 0, function* () {
      const t = this._handle;
      this._handle = null, t && (yield t.close());
    });
  }
  throw(t) {
    return W(this, void 0, void 0, function* () {
      return yield this.close(), { done: !0, value: t };
    });
  }
  return(t) {
    return W(this, void 0, void 0, function* () {
      return yield this.close(), { done: !0, value: t };
    });
  }
}
const ect = 65536;
function rc(e) {
  return e < 0 && (e = 4294967295 + e + 1), `0x${e.toString(16)}`;
}
const Jc = 8, y_ = [
  1,
  10,
  100,
  1e3,
  1e4,
  1e5,
  1e6,
  1e7,
  1e8
];
class rC {
  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
    ]), i = new Uint32Array([
      t.buffer[1] >>> 16,
      t.buffer[1] & 65535,
      t.buffer[0] >>> 16,
      t.buffer[0] & 65535
    ]);
    let r = n[3] * i[3];
    this.buffer[0] = r & 65535;
    let s = r >>> 16;
    return r = n[2] * i[3], s += r, r = n[3] * i[2] >>> 0, s += r, this.buffer[0] += s << 16, this.buffer[1] = s >>> 0 < r ? ect : 0, this.buffer[1] += s >>> 16, this.buffer[1] += n[1] * i[3] + n[2] * i[2] + n[3] * i[1], this.buffer[1] += n[0] * i[3] + n[1] * i[2] + n[2] * i[1] + n[3] * i[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 `${rc(this.buffer[1])} ${rc(this.buffer[0])}`;
  }
}
class ie extends rC {
  times(t) {
    return this._times(t), this;
  }
  plus(t) {
    return this._plus(t), this;
  }
  /** @nocollapse */
  static from(t, n = new Uint32Array(2)) {
    return ie.fromString(typeof t == "string" ? t : t.toString(), n);
  }
  /** @nocollapse */
  static fromNumber(t, n = new Uint32Array(2)) {
    return ie.fromString(t.toString(), n);
  }
  /** @nocollapse */
  static fromString(t, n = new Uint32Array(2)) {
    const i = t.length, r = new ie(n);
    for (let s = 0; s < i; ) {
      const o = Jc < i - s ? Jc : i - s, a = new ie(new Uint32Array([Number.parseInt(t.slice(s, s + o), 10), 0])), c = new ie(new Uint32Array([y_[o], 0]));
      r.times(c), r.plus(a), s += o;
    }
    return r;
  }
  /** @nocollapse */
  static convertArray(t) {
    const n = new Uint32Array(t.length * 2);
    for (let i = -1, r = t.length; ++i < r; )
      ie.from(t[i], new Uint32Array(n.buffer, n.byteOffset + 2 * i * 4, 2));
    return n;
  }
  /** @nocollapse */
  static multiply(t, n) {
    return new ie(new Uint32Array(t.buffer)).times(n);
  }
  /** @nocollapse */
  static add(t, n) {
    return new ie(new Uint32Array(t.buffer)).plus(n);
  }
}
class Sn extends rC {
  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, i = t.buffer[1] << 0;
    return n < i || n === i && this.buffer[0] < t.buffer[0];
  }
  /** @nocollapse */
  static from(t, n = new Uint32Array(2)) {
    return Sn.fromString(typeof t == "string" ? t : t.toString(), n);
  }
  /** @nocollapse */
  static fromNumber(t, n = new Uint32Array(2)) {
    return Sn.fromString(t.toString(), n);
  }
  /** @nocollapse */
  static fromString(t, n = new Uint32Array(2)) {
    const i = t.startsWith("-"), r = t.length, s = new Sn(n);
    for (let o = i ? 1 : 0; o < r; ) {
      const a = Jc < r - o ? Jc : r - o, c = new Sn(new Uint32Array([Number.parseInt(t.slice(o, o + a), 10), 0])), l = new Sn(new Uint32Array([y_[a], 0]));
      s.times(l), s.plus(c), o += a;
    }
    return i ? s.negate() : s;
  }
  /** @nocollapse */
  static convertArray(t) {
    const n = new Uint32Array(t.length * 2);
    for (let i = -1, r = t.length; ++i < r; )
      Sn.from(t[i], new Uint32Array(n.buffer, n.byteOffset + 2 * i * 4, 2));
    return n;
  }
  /** @nocollapse */
  static multiply(t, n) {
    return new Sn(new Uint32Array(t.buffer)).times(n);
  }
  /** @nocollapse */
  static add(t, n) {
    return new Sn(new Uint32Array(t.buffer)).plus(n);
  }
}
class Xi {
  constructor(t) {
    this.buffer = t;
  }
  high() {
    return new Sn(new Uint32Array(this.buffer.buffer, this.buffer.byteOffset + 8, 2));
  }
  low() {
    return new Sn(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 ie(new Uint32Array([this.buffer[3], 0])), i = new ie(new Uint32Array([this.buffer[2], 0])), r = new ie(new Uint32Array([this.buffer[1], 0])), s = new ie(new Uint32Array([this.buffer[0], 0])), o = new ie(new Uint32Array([t.buffer[3], 0])), a = new ie(new Uint32Array([t.buffer[2], 0])), c = new ie(new Uint32Array([t.buffer[1], 0])), l = new ie(new Uint32Array([t.buffer[0], 0]));
    let u = ie.multiply(s, l);
    this.buffer[0] = u.low();
    const f = new ie(new Uint32Array([u.high(), 0]));
    return u = ie.multiply(r, l), f.plus(u), u = ie.multiply(s, c), f.plus(u), this.buffer[1] = f.low(), this.buffer[3] = f.lessThan(u) ? 1 : 0, this.buffer[2] = f.high(), new ie(new Uint32Array(this.buffer.buffer, this.buffer.byteOffset + 8, 2)).plus(ie.multiply(i, l)).plus(ie.multiply(r, c)).plus(ie.multiply(s, a)), this.buffer[3] += ie.multiply(n, l).plus(ie.multiply(i, c)).plus(ie.multiply(r, a)).plus(ie.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 `${rc(this.buffer[3])} ${rc(this.buffer[2])} ${rc(this.buffer[1])} ${rc(this.buffer[0])}`;
  }
  /** @nocollapse */
  static multiply(t, n) {
    return new Xi(new Uint32Array(t.buffer)).times(n);
  }
  /** @nocollapse */
  static add(t, n) {
    return new Xi(new Uint32Array(t.buffer)).plus(n);
  }
  /** @nocollapse */
  static from(t, n = new Uint32Array(4)) {
    return Xi.fromString(typeof t == "string" ? t : t.toString(), n);
  }
  /** @nocollapse */
  static fromNumber(t, n = new Uint32Array(4)) {
    return Xi.fromString(t.toString(), n);
  }
  /** @nocollapse */
  static fromString(t, n = new Uint32Array(4)) {
    const i = t.startsWith("-"), r = t.length, s = new Xi(n);
    for (let o = i ? 1 : 0; o < r; ) {
      const a = Jc < r - o ? Jc : r - o, c = new Xi(new Uint32Array([Number.parseInt(t.slice(o, o + a), 10), 0, 0, 0])), l = new Xi(new Uint32Array([y_[a], 0, 0, 0]));
      s.times(l), s.plus(c), o += a;
    }
    return i ? s.negate() : s;
  }
  /** @nocollapse */
  static convertArray(t) {
    const n = new Uint32Array(t.length * 4);
    for (let i = -1, r = t.length; ++i < r; )
      Xi.from(t[i], new Uint32Array(n.buffer, n.byteOffset + 4 * 4 * i, 4));
    return n;
  }
}
class sC extends zt {
  constructor(t, n, i, r, s = Le.V5) {
    super(), this.nodesIndex = -1, this.buffersIndex = -1, this.bytes = t, this.nodes = n, this.buffers = i, this.dictionaries = r, this.metadataVersion = s;
  }
  visit(t) {
    return super.visit(t instanceof ge ? t.type : t);
  }
  visitNull(t, { length: n } = this.nextFieldNode()) {
    return Ct({ type: t, length: n });
  }
  visitBool(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitInt(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitFloat(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitUtf8(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), valueOffsets: this.readOffsets(t), data: this.readData(t) });
  }
  visitLargeUtf8(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), valueOffsets: this.readOffsets(t), data: this.readData(t) });
  }
  visitBinary(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), valueOffsets: this.readOffsets(t), data: this.readData(t) });
  }
  visitLargeBinary(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), valueOffsets: this.readOffsets(t), data: this.readData(t) });
  }
  visitFixedSizeBinary(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitDate(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitTimestamp(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitTime(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitDecimal(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitList(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), valueOffsets: this.readOffsets(t), child: this.visit(t.children[0]) });
  }
  visitStruct(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), children: this.visitMany(t.children) });
  }
  visitUnion(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return this.metadataVersion < Le.V5 && this.readNullBitmap(t, i), t.mode === On.Sparse ? this.visitSparseUnion(t, { length: n, nullCount: i }) : this.visitDenseUnion(t, { length: n, nullCount: i });
  }
  visitDenseUnion(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, typeIds: this.readTypeIds(t), valueOffsets: this.readOffsets(t), children: this.visitMany(t.children) });
  }
  visitSparseUnion(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, typeIds: this.readTypeIds(t), children: this.visitMany(t.children) });
  }
  visitDictionary(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t.indices), dictionary: this.readDictionary(t) });
  }
  visitInterval(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitDuration(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitFixedSizeList(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), child: this.visit(t.children[0]) });
  }
  visitMap(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Ct({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), 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, i = this.nextBufferRange()) {
    return n > 0 && this.readData(t, i) || new Uint8Array(0);
  }
  readOffsets(t, n) {
    return this.readData(t, n);
  }
  readTypeIds(t, n) {
    return this.readData(t, n);
  }
  readData(t, { length: n, offset: i } = this.nextBufferRange()) {
    return this.bytes.subarray(i, i + n);
  }
  readDictionary(t) {
    return this.dictionaries.get(t.id);
  }
}
class nct extends sC {
  constructor(t, n, i, r, s) {
    super(new Uint8Array(0), n, i, r, s), this.sources = t;
  }
  readNullBitmap(t, n, { offset: i } = this.nextBufferRange()) {
    return n <= 0 ? new Uint8Array(0) : ob(this.sources[i]);
  }
  readOffsets(t, { offset: n } = this.nextBufferRange()) {
    return se(Uint8Array, se(t.OffsetArrayType, this.sources[n]));
  }
  readTypeIds(t, { offset: n } = this.nextBufferRange()) {
    return se(Uint8Array, se(t.ArrayType, this.sources[n]));
  }
  readData(t, { offset: n } = this.nextBufferRange()) {
    const { sources: i } = this;
    return st.isTimestamp(t) || (st.isInt(t) || st.isTime(t)) && t.bitWidth === 64 || st.isDuration(t) || st.isDate(t) && t.unit === Oi.MILLISECOND ? se(Uint8Array, Sn.convertArray(i[n])) : st.isDecimal(t) ? se(Uint8Array, Xi.convertArray(i[n])) : st.isBinary(t) || st.isLargeBinary(t) || st.isFixedSizeBinary(t) ? ict(i[n]) : st.isBool(t) ? ob(i[n]) : st.isUtf8(t) || st.isLargeUtf8(t) ? t_(i[n].join("")) : se(Uint8Array, se(t.ArrayType, i[n].map((r) => +r)));
  }
}
function ict(e) {
  const t = e.join(""), n = new Uint8Array(t.length / 2);
  for (let i = 0; i < t.length; i += 2)
    n[i >> 1] = Number.parseInt(t.slice(i, i + 2), 16);
  return n;
}
class pt extends zt {
  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((i, r) => this.compareFields(i, n[r]));
  }
  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 _n(e, t) {
  return t instanceof e.constructor;
}
function da(e, t) {
  return e === t || _n(e, t);
}
function ms(e, t) {
  return e === t || _n(e, t) && e.bitWidth === t.bitWidth && e.isSigned === t.isSigned;
}
function Z0(e, t) {
  return e === t || _n(e, t) && e.precision === t.precision;
}
function rct(e, t) {
  return e === t || _n(e, t) && e.byteWidth === t.byteWidth;
}
function m_(e, t) {
  return e === t || _n(e, t) && e.unit === t.unit;
}
function Zf(e, t) {
  return e === t || _n(e, t) && e.unit === t.unit && e.timezone === t.timezone;
}
function Qf(e, t) {
  return e === t || _n(e, t) && e.unit === t.unit && e.bitWidth === t.bitWidth;
}
function sct(e, t) {
  return e === t || _n(e, t) && e.children.length === t.children.length && eo.compareManyFields(e.children, t.children);
}
function oct(e, t) {
  return e === t || _n(e, t) && e.children.length === t.children.length && eo.compareManyFields(e.children, t.children);
}
function g_(e, t) {
  return e === t || _n(e, t) && e.mode === t.mode && e.typeIds.every((n, i) => n === t.typeIds[i]) && eo.compareManyFields(e.children, t.children);
}
function act(e, t) {
  return e === t || _n(e, t) && e.id === t.id && e.isOrdered === t.isOrdered && eo.visit(e.indices, t.indices) && eo.visit(e.dictionary, t.dictionary);
}
function b_(e, t) {
  return e === t || _n(e, t) && e.unit === t.unit;
}
function th(e, t) {
  return e === t || _n(e, t) && e.unit === t.unit;
}
function cct(e, t) {
  return e === t || _n(e, t) && e.listSize === t.listSize && e.children.length === t.children.length && eo.compareManyFields(e.children, t.children);
}
function lct(e, t) {
  return e === t || _n(e, t) && e.keysSorted === t.keysSorted && e.children.length === t.children.length && eo.compareManyFields(e.children, t.children);
}
pt.prototype.visitNull = da;
pt.prototype.visitBool = da;
pt.prototype.visitInt = ms;
pt.prototype.visitInt8 = ms;
pt.prototype.visitInt16 = ms;
pt.prototype.visitInt32 = ms;
pt.prototype.visitInt64 = ms;
pt.prototype.visitUint8 = ms;
pt.prototype.visitUint16 = ms;
pt.prototype.visitUint32 = ms;
pt.prototype.visitUint64 = ms;
pt.prototype.visitFloat = Z0;
pt.prototype.visitFloat16 = Z0;
pt.prototype.visitFloat32 = Z0;
pt.prototype.visitFloat64 = Z0;
pt.prototype.visitUtf8 = da;
pt.prototype.visitLargeUtf8 = da;
pt.prototype.visitBinary = da;
pt.prototype.visitLargeBinary = da;
pt.prototype.visitFixedSizeBinary = rct;
pt.prototype.visitDate = m_;
pt.prototype.visitDateDay = m_;
pt.prototype.visitDateMillisecond = m_;
pt.prototype.visitTimestamp = Zf;
pt.prototype.visitTimestampSecond = Zf;
pt.prototype.visitTimestampMillisecond = Zf;
pt.prototype.visitTimestampMicrosecond = Zf;
pt.prototype.visitTimestampNanosecond = Zf;
pt.prototype.visitTime = Qf;
pt.prototype.visitTimeSecond = Qf;
pt.prototype.visitTimeMillisecond = Qf;
pt.prototype.visitTimeMicrosecond = Qf;
pt.prototype.visitTimeNanosecond = Qf;
pt.prototype.visitDecimal = da;
pt.prototype.visitList = sct;
pt.prototype.visitStruct = oct;
pt.prototype.visitUnion = g_;
pt.prototype.visitDenseUnion = g_;
pt.prototype.visitSparseUnion = g_;
pt.prototype.visitDictionary = act;
pt.prototype.visitInterval = b_;
pt.prototype.visitIntervalDayTime = b_;
pt.prototype.visitIntervalYearMonth = b_;
pt.prototype.visitDuration = th;
pt.prototype.visitDurationSecond = th;
pt.prototype.visitDurationMillisecond = th;
pt.prototype.visitDurationMicrosecond = th;
pt.prototype.visitDurationNanosecond = th;
pt.prototype.visitFixedSizeList = cct;
pt.prototype.visitMap = lct;
const eo = new pt();
function uct(e, t) {
  return eo.compareSchemas(e, t);
}
function fg(e, t) {
  return fct(e, t.map((n) => n.data.concat()));
}
function fct(e, t) {
  const n = [...e.fields], i = [], r = { numBatches: t.reduce((f, h) => Math.max(f, h.length), 0) };
  let s = 0, o = 0, a = -1;
  const c = t.length;
  let l, u = [];
  for (; r.numBatches-- > 0; ) {
    for (o = Number.POSITIVE_INFINITY, a = -1; ++a < c; )
      u[a] = l = t[a].shift(), o = Math.min(o, l ? l.length : o);
    Number.isFinite(o) && (u = hct(n, o, u, t, r), o > 0 && (i[s++] = Ct({
      type: new hn(n),
      length: o,
      nullCount: 0,
      children: u.slice()
    })));
  }
  return [
    e = e.assign(n),
    i.map((f) => new bi(e, f))
  ];
}
function hct(e, t, n, i, r) {
  var s;
  const o = (t + 63 & -64) >> 3;
  for (let a = -1, c = i.length; ++a < c; ) {
    const l = n[a], u = l == null ? void 0 : l.length;
    if (u >= t)
      u === t ? n[a] = l : (n[a] = l.slice(0, t), r.numBatches = Math.max(r.numBatches, i[a].unshift(l.slice(t, u - t))));
    else {
      const f = e[a];
      e[a] = f.clone({ nullable: !0 }), n[a] = (s = l == null ? void 0 : l._changeLengthAndBackfillNullBitmap(t)) !== null && s !== void 0 ? s : Ct({
        type: f.type,
        length: t,
        nullCount: t,
        nullBitmap: new Uint8Array(o)
      });
    }
  }
  return n;
}
var oC;
class ti {
  constructor(...t) {
    var n, i;
    if (t.length === 0)
      return this.batches = [], this.schema = new ee([]), this._offsets = [0], this;
    let r, s;
    t[0] instanceof ee && (r = t.shift()), t.at(-1) instanceof Uint32Array && (s = t.pop());
    const o = (c) => {
      if (c) {
        if (c instanceof bi)
          return [c];
        if (c instanceof ti)
          return c.batches;
        if (c instanceof ne) {
          if (c.type instanceof hn)
            return [new bi(new ee(c.type.children), c)];
        } else {
          if (Array.isArray(c))
            return c.flatMap((l) => o(l));
          if (typeof c[Symbol.iterator] == "function")
            return [...c].flatMap((l) => o(l));
          if (typeof c == "object") {
            const l = Object.keys(c), u = l.map((d) => new ae([c[d]])), f = r ?? new ee(l.map((d, p) => new ge(String(d), u[p].type, u[p].nullable))), [, h] = fg(f, u);
            return h.length === 0 ? [new bi(c)] : h;
          }
        }
      }
      return [];
    }, a = t.flatMap((c) => o(c));
    if (r = (i = r ?? ((n = a[0]) === null || n === void 0 ? void 0 : n.schema)) !== null && i !== void 0 ? i : new ee([]), !(r instanceof ee))
      throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");
    for (const c of a) {
      if (!(c instanceof bi))
        throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");
      if (!uct(r, c.schema))
        throw new TypeError("Table and inner RecordBatch schemas must be equivalent.");
    }
    this.schema = r, this.batches = a, this._offsets = s ?? HR(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 = XR(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;
  }
  /**
   * 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 ? d_.visit(new ae(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, i = this.data.concat(t.flatMap(({ data: r }) => r));
    return new ti(n, i.map((r) => new bi(n, r)));
  }
  /**
   * 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 i = this.schema;
    [t, n] = WR({ length: this.numRows }, t, n);
    const r = JR(this.data, this._offsets, t, n);
    return new ti(i, r.map((s) => new bi(i, 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((i) => i.children[t]);
      if (n.length === 0) {
        const { type: i } = this.schema.fields[t], r = Ct({ type: i, length: 0, nullCount: 0 });
        n.push(r._changeLengthAndBackfillNullBitmap(this.numRows));
      }
      return new ae(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 i;
    return this.setChildAt((i = this.schema.fields) === null || i === void 0 ? void 0 : i.findIndex((r) => r.name === t), n);
  }
  setChildAt(t, n) {
    let i = this.schema, r = [...this.batches];
    if (t > -1 && t < this.numCols) {
      n || (n = new ae([Ct({ type: new Qs(), length: this.numRows })]));
      const s = i.fields.slice(), o = s[t].clone({ type: n.type }), a = this.schema.fields.map((c, l) => this.getChildAt(l));
      [s[t], a[t]] = [o, n], [i, r] = fg(i, a);
    }
    return new ti(i, r);
  }
  /**
   * 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((i, r, s) => i.set(r.name, s), /* @__PURE__ */ new Map());
    return this.selectAt(t.map((i) => n.get(i)).filter((i) => i > -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), i = this.batches.map((r) => r.selectAt(t));
    return new ti(n, i);
  }
  assign(t) {
    const n = this.schema.fields, [i, r] = t.schema.fields.reduce((a, c, l) => {
      const [u, f] = a, h = n.findIndex((d) => d.name === c.name);
      return ~h ? f[h] = l : u.push(l), a;
    }, [[], []]), s = this.schema.assign(t.schema), o = [
      ...n.map((a, c) => [c, r[c]]).map(([a, c]) => c === void 0 ? this.getChildAt(a) : t.getChildAt(c)),
      ...i.map((a) => t.getChildAt(a))
    ].filter(Boolean);
    return new ti(...fg(s, o));
  }
}
oC = Symbol.toStringTag;
ti[oC] = ((e) => (e.schema = null, e.batches = [], e._offsets = new Uint32Array([0]), e._nullCount = -1, e[Symbol.isConcatSpreadable] = !0, e.isValid = $y(h_), e.get = $y(Fn.getVisitFn(E.Struct)), e.set = KR(fi.getVisitFn(E.Struct)), e.indexOf = ZR(Ty.getVisitFn(E.Struct)), "Table"))(ti.prototype);
var aC;
let bi = class au {
  constructor(...t) {
    switch (t.length) {
      case 2: {
        if ([this.schema] = t, !(this.schema instanceof ee))
          throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");
        if ([
          ,
          this.data = Ct({
            nullCount: 0,
            type: new hn(this.schema.fields),
            children: this.schema.fields.map((n) => Ct({ type: n.type, nullCount: 0 }))
          })
        ] = t, !(this.data instanceof ne))
          throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");
        [this.schema, this.data] = xI(this.schema, this.data.children);
        break;
      }
      case 1: {
        const [n] = t, { fields: i, children: r, length: s } = Object.keys(n).reduce((c, l, u) => (c.children[u] = n[l], c.length = Math.max(c.length, n[l].length), c.fields[u] = ge.new({ name: l, type: n[l].type, nullable: !0 }), c), {
          length: 0,
          fields: new Array(),
          children: new Array()
        }), o = new ee(i), a = Ct({ type: new hn(i), length: s, children: r, nullCount: 0 });
        [this.schema, this.data] = xI(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 = cC(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 element 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 element to read.
   */
  get(t) {
    return Fn.visit(this.data, t);
  }
  /**
   * Set a row by position.
   * @param index The index of the element to write.
   * @param value The value to set.
   */
  set(t, n) {
    return fi.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 Ty.visit(this.data, t, n);
  }
  /**
   * Iterator for rows in this RecordBatch.
   */
  [Symbol.iterator]() {
    return d_.visit(new ae([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 ti(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 element at the index 'end'.
   */
  slice(t, n) {
    const [i] = new ae([this.data]).slice(t, n).data;
    return new au(this.schema, i);
  }
  /**
   * 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((i) => i.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 ae([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 i;
    return this.setChildAt((i = this.schema.fields) === null || i === void 0 ? void 0 : i.findIndex((r) => r.name === t), n);
  }
  setChildAt(t, n) {
    let i = this.schema, r = this.data;
    if (t > -1 && t < this.numCols) {
      n || (n = new ae([Ct({ type: new Qs(), length: this.numRows })]));
      const s = i.fields.slice(), o = r.children.slice(), a = s[t].clone({ type: n.type });
      [s[t], o[t]] = [a, n.data[0]], i = new ee(s, new Map(this.schema.metadata)), r = Ct({ type: new hn(s), children: o });
    }
    return new au(i, r);
  }
  /**
   * 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), i = new hn(n.fields), r = [];
    for (const s of t) {
      const o = this.schema.fields.findIndex((a) => a.name === s);
      ~o && (r[o] = this.data.children[o]);
    }
    return new au(n, Ct({ type: i, length: this.numRows, children: r }));
  }
  /**
   * 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), i = t.map((s) => this.data.children[s]).filter(Boolean), r = Ct({ type: new hn(n.fields), length: this.numRows, children: i });
    return new au(n, r);
  }
};
aC = Symbol.toStringTag;
bi[aC] = ((e) => (e._nullCount = -1, e[Symbol.isConcatSpreadable] = !0, "RecordBatch"))(bi.prototype);
function xI(e, t, n = t.reduce((i, r) => Math.max(i, r.length), 0)) {
  var i;
  const r = [...e.fields], s = [...t], o = (n + 63 & -64) >> 3;
  for (const [a, c] of e.fields.entries()) {
    const l = t[a];
    (!l || l.length !== n) && (r[a] = c.clone({ nullable: !0 }), s[a] = (i = l == null ? void 0 : l._changeLengthAndBackfillNullBitmap(n)) !== null && i !== void 0 ? i : Ct({
      type: c.type,
      length: n,
      nullCount: n,
      nullBitmap: new Uint8Array(o)
    }));
  }
  return [
    e.assign(r),
    Ct({ type: new hn(r), length: n, children: s })
  ];
}
function cC(e, t, n = /* @__PURE__ */ new Map()) {
  var i, r;
  if (((i = e == null ? void 0 : e.length) !== null && i !== void 0 ? i : 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 l of [c, ...((r = c == null ? void 0 : c.dictionary) === null || r === void 0 ? void 0 : r.data) || []])
        cC(a.children, l == null ? void 0 : l.children, n);
      if (st.isDictionary(a)) {
        const { id: l } = a;
        if (!n.has(l))
          c != null && c.dictionary && n.set(l, c.dictionary);
        else if (n.get(l) !== c.dictionary)
          throw new Error("Cannot create Schema containing two different dictionaries with the same Id");
      }
    }
  return n;
}
class lC extends bi {
  constructor(t) {
    const n = t.fields.map((r) => Ct({ type: r.type })), i = Ct({ type: new hn(t.fields), nullCount: 0, children: n });
    super(t, i);
  }
}
let ws = class qi {
  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 qi()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsMessage(t, n) {
    return t.setPosition(t.position() + nt), (n || new qi()).__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) : Le.V1;
  }
  headerType() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? this.bb.readUint8(this.bb_pos + t) : te.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 i = this.bb.__offset(this.bb_pos, 12);
    return i ? (n || new Ce()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + i) + 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, Le.V1);
  }
  static addHeaderType(t, n) {
    t.addFieldInt8(1, n, te.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 i = n.length - 1; i >= 0; i--)
      t.addOffset(n[i]);
    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, i, r, s, o) {
    return qi.startMessage(t), qi.addVersion(t, n), qi.addHeaderType(t, i), qi.addHeader(t, r), qi.addBodyLength(t, s), qi.addCustomMetadata(t, o), qi.endMessage(t);
  }
};
class dct extends zt {
  visit(t, n) {
    return t == null || n == null ? void 0 : super.visit(t, n);
  }
  visitNull(t, n) {
    return hI.startNull(n), hI.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 tr.startFloatingPoint(n), tr.addPrecision(n, t.precision), tr.endFloatingPoint(n);
  }
  visitBinary(t, n) {
    return aI.startBinary(n), aI.endBinary(n);
  }
  visitLargeBinary(t, n) {
    return lI.startLargeBinary(n), lI.endLargeBinary(n);
  }
  visitBool(t, n) {
    return cI.startBool(n), cI.endBool(n);
  }
  visitUtf8(t, n) {
    return dI.startUtf8(n), dI.endUtf8(n);
  }
  visitLargeUtf8(t, n) {
    return uI.startLargeUtf8(n), uI.endLargeUtf8(n);
  }
  visitDecimal(t, n) {
    return ja.startDecimal(n), ja.addScale(n, t.scale), ja.addPrecision(n, t.precision), ja.addBitWidth(n, t.bitWidth), ja.endDecimal(n);
  }
  visitDate(t, n) {
    return fd.startDate(n), fd.addUnit(n, t.unit), fd.endDate(n);
  }
  visitTime(t, n) {
    return Zn.startTime(n), Zn.addUnit(n, t.unit), Zn.addBitWidth(n, t.bitWidth), Zn.endTime(n);
  }
  visitTimestamp(t, n) {
    const i = t.timezone && n.createString(t.timezone) || void 0;
    return Qn.startTimestamp(n), Qn.addUnit(n, t.unit), i !== void 0 && Qn.addTimezone(n, i), Qn.endTimestamp(n);
  }
  visitInterval(t, n) {
    return er.startInterval(n), er.addUnit(n, t.unit), er.endInterval(n);
  }
  visitDuration(t, n) {
    return hd.startDuration(n), hd.addUnit(n, t.unit), hd.endDuration(n);
  }
  visitList(t, n) {
    return fI.startList(n), fI.endList(n);
  }
  visitStruct(t, n) {
    return Co.startStruct_(n), Co.endStruct_(n);
  }
  visitUnion(t, n) {
    In.startTypeIdsVector(n, t.typeIds.length);
    const i = In.createTypeIdsVector(n, t.typeIds);
    return In.startUnion(n), In.addMode(n, t.mode), In.addTypeIds(n, i), In.endUnion(n);
  }
  visitDictionary(t, n) {
    const i = this.visit(t.indices, n);
    return jr.startDictionaryEncoding(n), jr.addId(n, BigInt(t.id)), jr.addIsOrdered(n, t.isOrdered), i !== void 0 && jr.addIndexType(n, i), jr.endDictionaryEncoding(n);
  }
  visitFixedSizeBinary(t, n) {
    return dd.startFixedSizeBinary(n), dd.addByteWidth(n, t.byteWidth), dd.endFixedSizeBinary(n);
  }
  visitFixedSizeList(t, n) {
    return pd.startFixedSizeList(n), pd.addListSize(n, t.listSize), pd.endFixedSizeList(n);
  }
  visitMap(t, n) {
    return yd.startMap(n), yd.addKeysSorted(n, t.keysSorted), yd.endMap(n);
  }
}
const hg = new dct();
function pct(e, t = /* @__PURE__ */ new Map()) {
  return new ee(mct(e, t), gd(e.metadata), t);
}
function uC(e) {
  return new Fi(e.count, fC(e.columns), hC(e.columns));
}
function yct(e) {
  return new ss(uC(e.data), e.id, e.isDelta);
}
function mct(e, t) {
  return (e.fields || []).filter(Boolean).map((n) => ge.fromJSON(n, t));
}
function SI(e, t) {
  return (e.children || []).filter(Boolean).map((n) => ge.fromJSON(n, t));
}
function fC(e) {
  return (e || []).reduce((t, n) => [
    ...t,
    new ml(n.count, gct(n.VALIDITY)),
    ...fC(n.children)
  ], []);
}
function hC(e, t = []) {
  for (let n = -1, i = (e || []).length; ++n < i; ) {
    const r = e[n];
    r.VALIDITY && t.push(new Jr(t.length, r.VALIDITY.length)), r.TYPE_ID && t.push(new Jr(t.length, r.TYPE_ID.length)), r.OFFSET && t.push(new Jr(t.length, r.OFFSET.length)), r.DATA && t.push(new Jr(t.length, r.DATA.length)), t = hC(r.children, t);
  }
  return t;
}
function gct(e) {
  return (e || []).reduce((t, n) => t + +(n === 0), 0);
}
function bct(e, t) {
  let n, i, r, s, o, a;
  return !t || !(s = e.dictionary) ? (o = AI(e, SI(e, t)), r = new ge(e.name, o, e.nullable, gd(e.metadata))) : t.has(n = s.id) ? (i = (i = s.indexType) ? II(i) : new sf(), a = new Gc(t.get(n), i, n, s.isOrdered), r = new ge(e.name, a, e.nullable, gd(e.metadata))) : (i = (i = s.indexType) ? II(i) : new sf(), t.set(n, o = AI(e, SI(e, t))), a = new Gc(o, i, n, s.isOrdered), r = new ge(e.name, a, e.nullable, gd(e.metadata))), r || null;
}
function gd(e = []) {
  return new Map(e.map(({ key: t, value: n }) => [t, n]));
}
function II(e) {
  return new to(e.isSigned, e.bitWidth);
}
function AI(e, t) {
  const n = e.type.name;
  switch (n) {
    case "NONE":
      return new Qs();
    case "null":
      return new Qs();
    case "binary":
      return new hy();
    case "largebinary":
      return new dy();
    case "utf8":
      return new py();
    case "largeutf8":
      return new yy();
    case "bool":
      return new my();
    case "list":
      return new xy((t || [])[0]);
    case "struct":
      return new hn(t || []);
    case "struct_":
      return new hn(t || []);
  }
  switch (n) {
    case "int": {
      const i = e.type;
      return new to(i.isSigned, i.bitWidth);
    }
    case "floatingpoint": {
      const i = e.type;
      return new of(rn[i.precision]);
    }
    case "decimal": {
      const i = e.type;
      return new gy(i.scale, i.precision, i.bitWidth);
    }
    case "date": {
      const i = e.type;
      return new by(Oi[i.unit]);
    }
    case "time": {
      const i = e.type;
      return new af(bt[i.unit], i.bitWidth);
    }
    case "timestamp": {
      const i = e.type;
      return new wy(bt[i.unit], i.timezone);
    }
    case "interval": {
      const i = e.type;
      return new vy(mr[i.unit]);
    }
    case "duration": {
      const i = e.type;
      return new _y(bt[i.unit]);
    }
    case "union": {
      const i = e.type, [r, ...s] = (i.mode + "").toLowerCase(), o = r.toUpperCase() + s.join("");
      return new Sy(On[o], i.typeIds || [], t || []);
    }
    case "fixedsizebinary": {
      const i = e.type;
      return new Iy(i.byteWidth);
    }
    case "fixedsizelist": {
      const i = e.type;
      return new Ay(i.listSize, (t || [])[0]);
    }
    case "map": {
      const i = e.type;
      return new My((t || [])[0], i.keysSorted);
    }
  }
  throw new Error(`Unrecognized type: "${n}"`);
}
var wct = ky, vct = ur;
class vi {
  /** @nocollapse */
  static fromJSON(t, n) {
    const i = new vi(0, Le.V5, n);
    return i._createHeader = _ct(t, n), i;
  }
  /** @nocollapse */
  static decode(t) {
    t = new vct(Wt(t));
    const n = ws.getRootAsMessage(t), i = n.bodyLength(), r = n.version(), s = n.headerType(), o = new vi(i, r, s);
    return o._createHeader = xct(n, s), o;
  }
  /** @nocollapse */
  static encode(t) {
    const n = new wct();
    let i = -1;
    return t.isSchema() ? i = ee.encode(n, t.header()) : t.isRecordBatch() ? i = Fi.encode(n, t.header()) : t.isDictionaryBatch() && (i = ss.encode(n, t.header())), ws.startMessage(n), ws.addVersion(n, Le.V5), ws.addHeader(n, i), ws.addHeaderType(n, t.headerType), ws.addBodyLength(n, BigInt(t.bodyLength)), ws.finishMessageBuffer(n, ws.endMessage(n)), n.asUint8Array();
  }
  /** @nocollapse */
  static from(t, n = 0) {
    if (t instanceof ee)
      return new vi(0, Le.V5, te.Schema, t);
    if (t instanceof Fi)
      return new vi(n, Le.V5, te.RecordBatch, t);
    if (t instanceof ss)
      return new vi(n, Le.V5, te.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 === te.Schema;
  }
  isRecordBatch() {
    return this.headerType === te.RecordBatch;
  }
  isDictionaryBatch() {
    return this.headerType === te.DictionaryBatch;
  }
  constructor(t, n, i, r) {
    this._version = n, this._headerType = i, this.body = new Uint8Array(0), r && (this._createHeader = () => r), this._bodyLength = bn(t);
  }
}
class Fi {
  get nodes() {
    return this._nodes;
  }
  get length() {
    return this._length;
  }
  get buffers() {
    return this._buffers;
  }
  constructor(t, n, i) {
    this._nodes = n, this._buffers = i, this._length = bn(t);
  }
}
class ss {
  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, i = !1) {
    this._data = t, this._isDelta = i, this._id = bn(n);
  }
}
class Jr {
  constructor(t, n) {
    this.offset = bn(t), this.length = bn(n);
  }
}
class ml {
  constructor(t, n) {
    this.length = bn(t), this.nullCount = bn(n);
  }
}
function _ct(e, t) {
  return () => {
    switch (t) {
      case te.Schema:
        return ee.fromJSON(e);
      case te.RecordBatch:
        return Fi.fromJSON(e);
      case te.DictionaryBatch:
        return ss.fromJSON(e);
    }
    throw new Error(`Unrecognized Message type: { name: ${te[t]}, type: ${t} }`);
  };
}
function xct(e, t) {
  return () => {
    switch (t) {
      case te.Schema:
        return ee.decode(e.header(new Gi()), /* @__PURE__ */ new Map(), e.version());
      case te.RecordBatch:
        return Fi.decode(e.header(new Cr()), e.version());
      case te.DictionaryBatch:
        return ss.decode(e.header(new Pa()), e.version());
    }
    throw new Error(`Unrecognized Message type: { name: ${te[t]}, type: ${t} }`);
  };
}
ge.encode = Fct;
ge.decode = Bct;
ge.fromJSON = bct;
ee.encode = Oct;
ee.decode = Sct;
ee.fromJSON = pct;
Fi.encode = Ect;
Fi.decode = Ict;
Fi.fromJSON = uC;
ss.encode = Lct;
ss.decode = Act;
ss.fromJSON = yct;
ml.encode = Rct;
ml.decode = $ct;
Jr.encode = Cct;
Jr.decode = Mct;
function Sct(e, t = /* @__PURE__ */ new Map(), n = Le.V5) {
  const i = Nct(e, t);
  return new ee(i, bd(e), t, n);
}
function Ict(e, t = Le.V5) {
  if (e.compression() !== null)
    throw new Error("Record batch compression not implemented");
  return new Fi(e.length(), Tct(e), Dct(e, t));
}
function Act(e, t = Le.V5) {
  return new ss(Fi.decode(e.data(), t), e.id(), e.isDelta());
}
function Mct(e) {
  return new Jr(e.offset(), e.length());
}
function $ct(e) {
  return new ml(e.length(), e.nullCount());
}
function Tct(e) {
  const t = [];
  for (let n, i = -1, r = -1, s = e.nodesLength(); ++i < s; )
    (n = e.nodes(i)) && (t[++r] = ml.decode(n));
  return t;
}
function Dct(e, t) {
  const n = [];
  for (let i, r = -1, s = -1, o = e.buffersLength(); ++r < o; )
    (i = e.buffers(r)) && (t < Le.V4 && (i.bb_pos += 8 * (r + 1)), n[++s] = Jr.decode(i));
  return n;
}
function Nct(e, t) {
  const n = [];
  for (let i, r = -1, s = -1, o = e.fieldsLength(); ++r < o; )
    (i = e.fields(r)) && (n[++s] = ge.decode(i, t));
  return n;
}
function MI(e, t) {
  const n = [];
  for (let i, r = -1, s = -1, o = e.childrenLength(); ++r < o; )
    (i = e.children(r)) && (n[++s] = ge.decode(i, t));
  return n;
}
function Bct(e, t) {
  let n, i, r, s, o, a;
  return !t || !(a = e.dictionary()) ? (r = TI(e, MI(e, t)), i = new ge(e.name(), r, e.nullable(), bd(e))) : t.has(n = bn(a.id())) ? (s = (s = a.indexType()) ? $I(s) : new sf(), o = new Gc(t.get(n), s, n, a.isOrdered()), i = new ge(e.name(), o, e.nullable(), bd(e))) : (s = (s = a.indexType()) ? $I(s) : new sf(), t.set(n, r = TI(e, MI(e, t))), o = new Gc(r, s, n, a.isOrdered()), i = new ge(e.name(), o, e.nullable(), bd(e))), i || null;
}
function bd(e) {
  const t = /* @__PURE__ */ new Map();
  if (e)
    for (let n, i, r = -1, s = Math.trunc(e.customMetadataLength()); ++r < s; )
      (n = e.customMetadata(r)) && (i = n.key()) != null && t.set(i, n.value());
  return t;
}
function $I(e) {
  return new to(e.isSigned(), e.bitWidth());
}
function TI(e, t) {
  const n = e.typeType();
  switch (n) {
    case pe.NONE:
      return new Qs();
    case pe.Null:
      return new Qs();
    case pe.Binary:
      return new hy();
    case pe.LargeBinary:
      return new dy();
    case pe.Utf8:
      return new py();
    case pe.LargeUtf8:
      return new yy();
    case pe.Bool:
      return new my();
    case pe.List:
      return new xy((t || [])[0]);
    case pe.Struct_:
      return new hn(t || []);
  }
  switch (n) {
    case pe.Int: {
      const i = e.type(new Rn());
      return new to(i.isSigned(), i.bitWidth());
    }
    case pe.FloatingPoint: {
      const i = e.type(new tr());
      return new of(i.precision());
    }
    case pe.Decimal: {
      const i = e.type(new ja());
      return new gy(i.scale(), i.precision(), i.bitWidth());
    }
    case pe.Date: {
      const i = e.type(new fd());
      return new by(i.unit());
    }
    case pe.Time: {
      const i = e.type(new Zn());
      return new af(i.unit(), i.bitWidth());
    }
    case pe.Timestamp: {
      const i = e.type(new Qn());
      return new wy(i.unit(), i.timezone());
    }
    case pe.Interval: {
      const i = e.type(new er());
      return new vy(i.unit());
    }
    case pe.Duration: {
      const i = e.type(new hd());
      return new _y(i.unit());
    }
    case pe.Union: {
      const i = e.type(new In());
      return new Sy(i.mode(), i.typeIdsArray() || [], t || []);
    }
    case pe.FixedSizeBinary: {
      const i = e.type(new dd());
      return new Iy(i.byteWidth());
    }
    case pe.FixedSizeList: {
      const i = e.type(new pd());
      return new Ay(i.listSize(), (t || [])[0]);
    }
    case pe.Map: {
      const i = e.type(new yd());
      return new My((t || [])[0], i.keysSorted());
    }
  }
  throw new Error(`Unrecognized type: "${pe[n]}" (${n})`);
}
function Oct(e, t) {
  const n = t.fields.map((s) => ge.encode(e, s));
  Gi.startFieldsVector(e, n.length);
  const i = Gi.createFieldsVector(e, n), r = t.metadata && t.metadata.size > 0 ? Gi.createCustomMetadataVector(e, [...t.metadata].map(([s, o]) => {
    const a = e.createString(`${s}`), c = e.createString(`${o}`);
    return Ce.startKeyValue(e), Ce.addKey(e, a), Ce.addValue(e, c), Ce.endKeyValue(e);
  })) : -1;
  return Gi.startSchema(e), Gi.addFields(e, i), Gi.addEndianness(e, kct ? Wc.Little : Wc.Big), r !== -1 && Gi.addCustomMetadata(e, r), Gi.endSchema(e);
}
function Fct(e, t) {
  let n = -1, i = -1, r = -1;
  const s = t.type;
  let o = t.typeId;
  st.isDictionary(s) ? (o = s.dictionary.typeId, r = hg.visit(s, e), i = hg.visit(s.dictionary, e)) : i = hg.visit(s, e);
  const a = (s.children || []).map((u) => ge.encode(e, u)), c = Xn.createChildrenVector(e, a), l = t.metadata && t.metadata.size > 0 ? Xn.createCustomMetadataVector(e, [...t.metadata].map(([u, f]) => {
    const h = e.createString(`${u}`), d = e.createString(`${f}`);
    return Ce.startKeyValue(e), Ce.addKey(e, h), Ce.addValue(e, d), Ce.endKeyValue(e);
  })) : -1;
  return t.name && (n = e.createString(t.name)), Xn.startField(e), Xn.addType(e, i), Xn.addTypeType(e, o), Xn.addChildren(e, c), Xn.addNullable(e, !!t.nullable), n !== -1 && Xn.addName(e, n), r !== -1 && Xn.addDictionary(e, r), l !== -1 && Xn.addCustomMetadata(e, l), Xn.endField(e);
}
function Ect(e, t) {
  const n = t.nodes || [], i = t.buffers || [];
  Cr.startNodesVector(e, n.length);
  for (const o of n.slice().reverse())
    ml.encode(e, o);
  const r = e.endVector();
  Cr.startBuffersVector(e, i.length);
  for (const o of i.slice().reverse())
    Jr.encode(e, o);
  const s = e.endVector();
  return Cr.startRecordBatch(e), Cr.addLength(e, BigInt(t.length)), Cr.addNodes(e, r), Cr.addBuffers(e, s), Cr.endRecordBatch(e);
}
function Lct(e, t) {
  const n = Fi.encode(e, t.data);
  return Pa.startDictionaryBatch(e), Pa.addId(e, BigInt(t.id)), Pa.addIsDelta(e, t.isDelta), Pa.addData(e, n), Pa.endDictionaryBatch(e);
}
function Rct(e, t) {
  return DL.createFieldNode(e, BigInt(t.length), BigInt(t.nullCount));
}
function Cct(e, t) {
  return TL.createBuffer(e, BigInt(t.offset), BigInt(t.length));
}
const kct = (() => {
  const e = new ArrayBuffer(2);
  return new DataView(e).setInt16(
    0,
    256,
    !0
    /* littleEndian */
  ), new Int16Array(e)[0] === 256;
})(), w_ = (e) => `Expected ${te[e]} Message in stream, but was null or length 0.`, v_ = (e) => `Header pointer of flatbuffer-encoded ${te[e]} Message is null or length 0.`, dC = (e, t) => `Expected to read ${e} metadata bytes, but only read ${t}.`, pC = (e, t) => `Expected to read ${e} bytes for message body, but only read ${t}.`;
class yC {
  constructor(t) {
    this.source = t instanceof Ny ? t : new Ny(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 ? Ie : 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(w_(t));
    return n.value;
  }
  readMessageBody(t) {
    if (t <= 0)
      return new Uint8Array(0);
    const n = Wt(this.source.read(t));
    if (n.byteLength < t)
      throw new Error(pC(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 = te.Schema, i = this.readMessage(n), r = i == null ? void 0 : i.header();
    if (t && !r)
      throw new Error(v_(n));
    return r;
  }
  readMetadataLength() {
    const t = this.source.read(Q0), n = t && new ur(t), i = (n == null ? void 0 : n.readInt32(0)) || 0;
    return { done: i === 0, value: i };
  }
  readMetadata(t) {
    const n = this.source.read(t);
    if (!n)
      return Ie;
    if (n.byteLength < t)
      throw new Error(dC(t, n.byteLength));
    return { done: !1, value: vi.decode(n) };
  }
}
class Uct {
  constructor(t, n) {
    this.source = t instanceof Hc ? t : SL(t) ? new By(t, n) : new Hc(t);
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  next() {
    return W(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 ? Ie : t;
    });
  }
  throw(t) {
    return W(this, void 0, void 0, function* () {
      return yield this.source.throw(t);
    });
  }
  return(t) {
    return W(this, void 0, void 0, function* () {
      return yield this.source.return(t);
    });
  }
  readMessage(t) {
    return W(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(w_(t));
      return n.value;
    });
  }
  readMessageBody(t) {
    return W(this, void 0, void 0, function* () {
      if (t <= 0)
        return new Uint8Array(0);
      const n = Wt(yield this.source.read(t));
      if (n.byteLength < t)
        throw new Error(pC(t, n.byteLength));
      return (
        /* 1. */
        n.byteOffset % 8 === 0 && /* 2. */
        n.byteOffset + n.byteLength <= n.buffer.byteLength ? n : n.slice()
      );
    });
  }
  readSchema(t = !1) {
    return W(this, void 0, void 0, function* () {
      const n = te.Schema, i = yield this.readMessage(n), r = i == null ? void 0 : i.header();
      if (t && !r)
        throw new Error(v_(n));
      return r;
    });
  }
  readMetadataLength() {
    return W(this, void 0, void 0, function* () {
      const t = yield this.source.read(Q0), n = t && new ur(t), i = (n == null ? void 0 : n.readInt32(0)) || 0;
      return { done: i === 0, value: i };
    });
  }
  readMetadata(t) {
    return W(this, void 0, void 0, function* () {
      const n = yield this.source.read(t);
      if (!n)
        return Ie;
      if (n.byteLength < t)
        throw new Error(dC(t, n.byteLength));
      return { done: !1, value: vi.decode(n) };
    });
  }
}
class zct extends yC {
  constructor(t) {
    super(new Uint8Array(0)), this._schema = !1, this._body = [], this._batchIndex = 0, this._dictionaryIndex = 0, this._json = t instanceof vI ? t : new vI(t);
  }
  next() {
    const { _json: t } = this;
    if (!this._schema)
      return this._schema = !0, { done: !1, value: vi.fromJSON(t.schema, te.Schema) };
    if (this._dictionaryIndex < t.dictionaries.length) {
      const n = t.dictionaries[this._dictionaryIndex++];
      return this._body = n.data.columns, { done: !1, value: vi.fromJSON(n, te.DictionaryBatch) };
    }
    if (this._batchIndex < t.batches.length) {
      const n = t.batches[this._batchIndex++];
      return this._body = n.columns, { done: !1, value: vi.fromJSON(n, te.RecordBatch) };
    }
    return this._body = [], Ie;
  }
  readMessageBody(t) {
    return n(this._body);
    function n(i) {
      return (i || []).reduce((r, s) => [
        ...r,
        ...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(w_(t));
    return n.value;
  }
  readSchema() {
    const t = te.Schema, n = this.readMessage(t), i = n == null ? void 0 : n.header();
    if (!n || !i)
      throw new Error(v_(t));
    return i;
  }
}
const Q0 = 4, ub = "ARROW1", Oy = new Uint8Array(ub.length);
for (let e = 0; e < ub.length; e += 1)
  Oy[e] = ub.codePointAt(e);
function __(e, t = 0) {
  for (let n = -1, i = Oy.length; ++n < i; )
    if (Oy[n] !== e[t + n])
      return !1;
  return !0;
}
const eh = Oy.length, mC = eh + Q0, Pct = eh * 2 + Q0;
class es extends iC {
  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 tf(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 Jn.toDOMStream(this.isSync() ? { [Symbol.iterator]: () => this } : { [Symbol.asyncIterator]: () => this });
  }
  toNodeStream() {
    return Jn.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 es ? t : nb(t) ? Yct(t) : SL(t) ? Xct(t) : tf(t) ? W(this, void 0, void 0, function* () {
      return yield es.from(yield t);
    }) : IL(t) || n_(t) || ML(t) || e_(t) ? Gct(new Hc(t)) : Wct(new Ny(t));
  }
  /** @nocollapse */
  static readAll(t) {
    return t instanceof es ? t.isSync() ? DI(t) : NI(t) : nb(t) || ArrayBuffer.isView(t) || J0(t) || xL(t) ? DI(t) : NI(t);
  }
}
class Fy extends es {
  constructor(t) {
    super(t), this._impl = t;
  }
  readAll() {
    return [...this];
  }
  [Symbol.iterator]() {
    return this._impl[Symbol.iterator]();
  }
  [Symbol.asyncIterator]() {
    return Re(this, arguments, function* () {
      yield H(yield* Cs(ai(this[Symbol.iterator]())));
    });
  }
}
class Ey extends es {
  constructor(t) {
    super(t), this._impl = t;
  }
  readAll() {
    var t, n, i, r;
    return W(this, void 0, void 0, function* () {
      const s = new Array();
      try {
        for (var o = !0, a = ai(this), c; c = yield a.next(), t = c.done, !t; o = !0) {
          r = c.value, o = !1;
          const l = r;
          s.push(l);
        }
      } catch (l) {
        n = { error: l };
      } finally {
        try {
          !o && !t && (i = a.return) && (yield i.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 gC extends Fy {
  constructor(t) {
    super(t), this._impl = t;
  }
}
class Vct extends Ey {
  constructor(t) {
    super(t), this._impl = t;
  }
}
class bC {
  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 i = this._loadVectors(t, n, this.schema.fields), r = Ct({ type: new hn(this.schema.fields), length: t.length, children: i });
    return new bi(this.schema, r);
  }
  _loadDictionaryBatch(t, n) {
    const { id: i, isDelta: r } = t, { dictionaries: s, schema: o } = this, a = s.get(i);
    if (r || !a) {
      const c = o.dictionaries.get(i), l = this._loadVectors(t.data, n, [c]);
      return (a && r ? a.concat(new ae(l)) : new ae(l)).memoize();
    }
    return a.memoize();
  }
  _loadVectors(t, n, i) {
    return new sC(n, t.nodes, t.buffers, this.dictionaries, this.schema.metadataVersion).visitMany(i);
  }
}
class Ly extends bC {
  constructor(t, n) {
    super(n), this._reader = nb(t) ? new zct(this._handle = t) : new yC(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 = vC(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) : Ie;
  }
  return(t) {
    return !this.closed && this.autoDestroy && (this.closed = !0) ? this.reset()._reader.return(t) : Ie;
  }
  next() {
    if (this.closed)
      return Ie;
    let t;
    const { _reader: n } = this;
    for (; t = this._readNextMessageAndValidate(); )
      if (t.isSchema())
        this.reset(t.header());
      else if (t.isRecordBatch()) {
        this._recordBatchIndex++;
        const i = t.header(), r = n.readMessageBody(t.bodyLength);
        return { done: !1, value: this._loadRecordBatch(i, r) };
      } else if (t.isDictionaryBatch()) {
        this._dictionaryIndex++;
        const i = t.header(), r = n.readMessageBody(t.bodyLength), s = this._loadDictionaryBatch(i, r);
        this.dictionaries.set(i.id, s);
      }
    return this.schema && this._recordBatchIndex === 0 ? (this._recordBatchIndex++, { done: !1, value: new lC(this.schema) }) : this.return();
  }
  _readNextMessageAndValidate(t) {
    return this._reader.readMessage(t);
  }
}
class Ry extends bC {
  constructor(t, n) {
    super(n), this._reader = new Uct(this._handle = t);
  }
  isAsync() {
    return !0;
  }
  isStream() {
    return !0;
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  cancel() {
    return W(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 W(this, void 0, void 0, function* () {
      return this.closed || (this.autoDestroy = vC(this, t), this.schema || (this.schema = yield this._reader.readSchema()) || (yield this.cancel())), this;
    });
  }
  throw(t) {
    return W(this, void 0, void 0, function* () {
      return !this.closed && this.autoDestroy && (this.closed = !0) ? yield this.reset()._reader.throw(t) : Ie;
    });
  }
  return(t) {
    return W(this, void 0, void 0, function* () {
      return !this.closed && this.autoDestroy && (this.closed = !0) ? yield this.reset()._reader.return(t) : Ie;
    });
  }
  next() {
    return W(this, void 0, void 0, function* () {
      if (this.closed)
        return Ie;
      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 i = t.header(), r = yield n.readMessageBody(t.bodyLength);
          return { done: !1, value: this._loadRecordBatch(i, r) };
        } else if (t.isDictionaryBatch()) {
          this._dictionaryIndex++;
          const i = t.header(), r = yield n.readMessageBody(t.bodyLength), s = this._loadDictionaryBatch(i, r);
          this.dictionaries.set(i.id, s);
        }
      return this.schema && this._recordBatchIndex === 0 ? (this._recordBatchIndex++, { done: !1, value: new lC(this.schema) }) : yield this.return();
    });
  }
  _readNextMessageAndValidate(t) {
    return W(this, void 0, void 0, function* () {
      return yield this._reader.readMessage(t);
    });
  }
}
class wC extends Ly {
  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 _I ? t : new _I(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 i = (n = this._footer) === null || n === void 0 ? void 0 : n.getRecordBatch(t);
    if (i && this._handle.seek(i.offset)) {
      const r = this._reader.readMessage(te.RecordBatch);
      if (r != null && r.isRecordBatch()) {
        const s = r.header(), o = this._reader.readMessageBody(r.bodyLength);
        return this._loadRecordBatch(s, o);
      }
    }
    return null;
  }
  _readDictionaryBatch(t) {
    var n;
    const i = (n = this._footer) === null || n === void 0 ? void 0 : n.getDictionaryBatch(t);
    if (i && this._handle.seek(i.offset)) {
      const r = this._reader.readMessage(te.DictionaryBatch);
      if (r != null && r.isDictionaryBatch()) {
        const s = r.header(), o = this._reader.readMessageBody(r.bodyLength), a = this._loadDictionaryBatch(s, o);
        this.dictionaries.set(s.id, a);
      }
    }
  }
  _readFooter() {
    const { _handle: t } = this, n = t.size - mC, i = t.readInt32(n), r = t.readAt(n - i, i);
    return p_.decode(r);
  }
  _readNextMessageAndValidate(t) {
    var n;
    if (this._footer || this.open(), this._footer && this._recordBatchIndex < this.numRecordBatches) {
      const i = (n = this._footer) === null || n === void 0 ? void 0 : n.getRecordBatch(this._recordBatchIndex);
      if (i && this._handle.seek(i.offset))
        return this._reader.readMessage(t);
    }
    return null;
  }
}
class jct extends Ry {
  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 i = typeof n[0] != "number" ? n.shift() : void 0, r = n[0] instanceof Map ? n.shift() : void 0;
    super(t instanceof By ? t : new By(t, i), r);
  }
  isFile() {
    return !0;
  }
  isAsync() {
    return !0;
  }
  open(t) {
    const n = Object.create(null, {
      open: { get: () => super.open }
    });
    return W(this, void 0, void 0, function* () {
      if (!this.closed && !this._footer) {
        this.schema = (this._footer = yield this._readFooter()).schema;
        for (const i of this._footer.dictionaryBatches())
          i && (yield this._readDictionaryBatch(this._dictionaryIndex++));
      }
      return yield n.open.call(this, t);
    });
  }
  readRecordBatch(t) {
    var n;
    return W(this, void 0, void 0, function* () {
      if (this.closed)
        return null;
      this._footer || (yield this.open());
      const i = (n = this._footer) === null || n === void 0 ? void 0 : n.getRecordBatch(t);
      if (i && (yield this._handle.seek(i.offset))) {
        const r = yield this._reader.readMessage(te.RecordBatch);
        if (r != null && r.isRecordBatch()) {
          const s = r.header(), o = yield this._reader.readMessageBody(r.bodyLength);
          return this._loadRecordBatch(s, o);
        }
      }
      return null;
    });
  }
  _readDictionaryBatch(t) {
    var n;
    return W(this, void 0, void 0, function* () {
      const i = (n = this._footer) === null || n === void 0 ? void 0 : n.getDictionaryBatch(t);
      if (i && (yield this._handle.seek(i.offset))) {
        const r = yield this._reader.readMessage(te.DictionaryBatch);
        if (r != null && r.isDictionaryBatch()) {
          const s = r.header(), o = yield this._reader.readMessageBody(r.bodyLength), a = this._loadDictionaryBatch(s, o);
          this.dictionaries.set(s.id, a);
        }
      }
    });
  }
  _readFooter() {
    return W(this, void 0, void 0, function* () {
      const { _handle: t } = this;
      t._pending && (yield t._pending);
      const n = t.size - mC, i = yield t.readInt32(n), r = yield t.readAt(n - i, i);
      return p_.decode(r);
    });
  }
  _readNextMessageAndValidate(t) {
    return W(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 qct extends Ly {
  constructor(t, n) {
    super(t, n);
  }
  _loadVectors(t, n, i) {
    return new nct(n, t.nodes, t.buffers, this.dictionaries, this.schema.metadataVersion).visitMany(i);
  }
}
function vC(e, t) {
  return t && typeof t.autoDestroy == "boolean" ? t.autoDestroy : e.autoDestroy;
}
function* DI(e) {
  const t = es.from(e);
  try {
    if (!t.open({ autoDestroy: !1 }).closed)
      do
        yield t;
      while (!t.reset().open().closed);
  } finally {
    t.cancel();
  }
}
function NI(e) {
  return Re(this, arguments, function* () {
    const n = yield H(es.from(e));
    try {
      if (!(yield H(n.open({ autoDestroy: !1 }))).closed)
        do
          yield yield H(n);
        while (!(yield H(n.reset().open())).closed);
    } finally {
      yield H(n.cancel());
    }
  });
}
function Yct(e) {
  return new Fy(new qct(e));
}
function Wct(e) {
  const t = e.peek(eh + 7 & -8);
  return t && t.byteLength >= 4 ? __(t) ? new gC(new wC(e.read())) : new Fy(new Ly(e)) : new Fy(new Ly(function* () {
  }()));
}
function Gct(e) {
  return W(this, void 0, void 0, function* () {
    const t = yield e.peek(eh + 7 & -8);
    return t && t.byteLength >= 4 ? __(t) ? new gC(new wC(yield e.read())) : new Ey(new Ry(e)) : new Ey(new Ry(function() {
      return Re(this, arguments, function* () {
      });
    }()));
  });
}
function Xct(e) {
  return W(this, void 0, void 0, function* () {
    const { size: t } = yield e.stat(), n = new By(e, t);
    return t >= Pct && __(yield n.readAt(0, eh + 7 & -8)) ? new Vct(new jct(n)) : new Ey(new Ry(n));
  });
}
function _C(e) {
  const t = es.from(e);
  return tf(t) ? t.then((n) => _C(n)) : t.isAsync() ? t.readAll().then((n) => new ti(n)) : new ti(t.readAll());
}
let Uh;
const Hct = new Uint8Array(16);
function Jct() {
  if (!Uh && (Uh = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !Uh))
    throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
  return Uh(Hct);
}
const Ge = [];
for (let e = 0; e < 256; ++e)
  Ge.push((e + 256).toString(16).slice(1));
function Kct(e, t = 0) {
  return Ge[e[t + 0]] + Ge[e[t + 1]] + Ge[e[t + 2]] + Ge[e[t + 3]] + "-" + Ge[e[t + 4]] + Ge[e[t + 5]] + "-" + Ge[e[t + 6]] + Ge[e[t + 7]] + "-" + Ge[e[t + 8]] + Ge[e[t + 9]] + "-" + Ge[e[t + 10]] + Ge[e[t + 11]] + Ge[e[t + 12]] + Ge[e[t + 13]] + Ge[e[t + 14]] + Ge[e[t + 15]];
}
const Zct = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), BI = {
  randomUUID: Zct
};
function Qct(e, t, n) {
  if (BI.randomUUID && !t && !e)
    return BI.randomUUID();
  e = e || {};
  const i = e.random || (e.rng || Jct)();
  if (i[6] = i[6] & 15 | 64, i[8] = i[8] & 63 | 128, t) {
    n = n || 0;
    for (let r = 0; r < 16; ++r)
      t[n + r] = i[r];
    return t;
  }
  return Kct(i);
}
const $ut = {
  /** @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"), i = Yr().logger(), r = /* @__PURE__ */ new Map();
    function s(u, f, h) {
      const d = Qct();
      r.set(d, {
        query: u,
        startTime: performance.now(),
        resolve: f,
        reject: h
      }), e.model.send({ ...u, uuid: d });
    }
    const o = {
      query(u) {
        return new Promise((f, h) => s(u, f, h));
      }
    };
    function a() {
      Yr().clear(), Yv.clear();
    }
    async function c() {
      const u = t();
      a(), i.log("Setting spec:", u);
      const f = await tlt(u);
      e.el.replaceChildren(f.element);
      const h = {};
      for (const [d, p] of f.params)
        h[d] = {
          value: p.value,
          ...p.predicate ? { predicate: String(p.predicate()) } : {}
        }, p.addEventListener("value", (y) => {
          h[d] = { value: y, 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 l() {
      const u = { temp: n() };
      Yr().configure({ indexes: u });
    }
    return e.model.on("change:temp_indexes", () => l()), e.model.on("msg:custom", (u, f) => {
      i.group(`query ${u.uuid}`), i.log("received message", u, f);
      const h = r.get(u.uuid);
      if (r.delete(u.uuid), i.log(h.query.sql, (performance.now() - h.startTime).toFixed(1)), u.error)
        h.reject(u.error), i.error(u.error);
      else
        switch (u.type) {
          case "arrow": {
            const d = _C(f[0].buffer);
            i.log("table", d), h.resolve(d);
            break;
          }
          case "json": {
            i.log("json", u.result), h.resolve(u.result);
            break;
          }
          default: {
            h.resolve({});
            break;
          }
        }
      i.groupEnd("query");
    }), Yr().databaseConnector(o), l(), c(), () => {
      a();
    };
  }
};
function tlt(e) {
  const t = got(e);
  return Ost(t);
}
export {
  $ut as default
};
