function Y(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 Dw(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 G(e) {
  return this instanceof G ? (this.v = e, this) : new G(e);
}
function Fe(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, m) {
        s.push([h, d, p, m]) > 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 G ? 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 Bs(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: G(e[r](o)), done: !1 } : s ? s(o) : o;
    } : s;
  }
}
function Qn(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 Dw == "function" ? Dw(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 xF = new TextDecoder("utf-8"), Om = (e) => xF.decode(e), SF = new TextEncoder(), I1 = (e) => SF.encode(e), [zu, ast] = (() => {
  const e = () => {
    throw new Error("BigInt64Array is not available in this environment");
  };
  class t {
    static get BYTES_PER_ELEMENT() {
      return 8;
    }
    static of() {
      throw e();
    }
    static from() {
      throw e();
    }
    constructor() {
      throw e();
    }
  }
  return typeof BigInt64Array < "u" ? [BigInt64Array, !0] : [t, !1];
})(), [Pu, cst] = (() => {
  const e = () => {
    throw new Error("BigUint64Array is not available in this environment");
  };
  class t {
    static get BYTES_PER_ELEMENT() {
      return 8;
    }
    static of() {
      throw e();
    }
    static from() {
      throw e();
    }
    constructor() {
      throw e();
    }
  }
  return typeof BigUint64Array < "u" ? [BigUint64Array, !0] : [t, !1];
})(), IF = (e) => typeof e == "number", AF = (e) => typeof e == "boolean", tn = (e) => typeof e == "function", mi = (e) => e != null && Object(e) === e, ou = (e) => mi(e) && tn(e.then), ry = (e) => mi(e) && tn(e[Symbol.iterator]), A1 = (e) => mi(e) && tn(e[Symbol.asyncIterator]), Lm = (e) => mi(e) && mi(e.schema), AS = (e) => mi(e) && "done" in e && "value" in e, MS = (e) => mi(e) && tn(e.stat) && IF(e.fd), $S = (e) => mi(e) && M1(e.body), TS = (e) => "_getDOMStream" in e && "_getNodeStream" in e, M1 = (e) => mi(e) && tn(e.cancel) && tn(e.getReader) && !TS(e), BS = (e) => mi(e) && tn(e.read) && tn(e.pipe) && AF(e.readable) && !TS(e), MF = (e) => mi(e) && tn(e.clear) && tn(e.bytes) && tn(e.position) && tn(e.setPosition) && tn(e.capacity) && tn(e.getBufferIdentifier) && tn(e.createLong), $1 = typeof SharedArrayBuffer < "u" ? SharedArrayBuffer : ArrayBuffer;
function $F(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 Ew(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 ir(e, t) {
  const n = $F(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 ? Ew(o, s, a) : o = s;
      break;
    }
    Ew(o || (o = new Uint8Array(l)), s, a), a += s.length;
  }
  return [o || new Uint8Array(0), n.slice(c), i - (o ? o.byteLength : 0)];
}
function ne(e, t) {
  let n = AS(t) ? t.value : t;
  return n instanceof e ? e === Uint8Array ? new e(n.buffer, n.byteOffset, n.byteLength) : n : n ? (typeof n == "string" && (n = I1(n)), n instanceof ArrayBuffer ? new e(n) : n instanceof $1 ? new e(n) : MF(n) ? ne(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 hl = (e) => ne(Int32Array, e), Xt = (e) => ne(Uint8Array, e), Rm = (e) => (e.next(), e);
function* TF(e, t) {
  const n = function* (r) {
    yield r;
  }, i = typeof t == "string" || ArrayBuffer.isView(t) || t instanceof ArrayBuffer || t instanceof $1 ? n(t) : ry(t) ? t : n(t);
  return yield* Rm(function* (r) {
    let s = null;
    do
      s = r.next(yield ne(e, s));
    while (!s.done);
  }(i[Symbol.iterator]())), new e();
}
const BF = (e) => TF(Uint8Array, e);
function NS(e, t) {
  return Fe(this, arguments, function* () {
    if (ou(t))
      return yield G(yield G(yield* Bs(Qn(NS(e, yield G(t))))));
    const i = function(o) {
      return Fe(this, arguments, function* () {
        yield yield G(yield G(o));
      });
    }, r = function(o) {
      return Fe(this, arguments, function* () {
        yield G(yield* Bs(Qn(Rm(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 $1 ? i(t) : ry(t) ? r(t) : A1(t) ? t : i(t);
    return yield G(
      // otherwise if AsyncIterable, use it
      yield* Bs(Qn(Rm(function(o) {
        return Fe(this, arguments, function* () {
          let a = null;
          do
            a = yield G(o.next(yield yield G(ne(e, a))));
          while (!a.done);
        });
      }(s[Symbol.asyncIterator]()))))
    ), yield G(new e());
  });
}
const NF = (e) => NS(Uint8Array, e);
function FF(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 Un = {
  fromIterable(e) {
    return Ff(DF(e));
  },
  fromAsyncIterable(e) {
    return Ff(EF(e));
  },
  fromDOMStream(e) {
    return Ff(OF(e));
  },
  fromNodeStream(e) {
    return Ff(RF(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');
  }
}, Ff = (e) => (e.next(), e);
function* DF(e) {
  let t, n = !1, i = [], r, s, o, a = 0;
  function c() {
    return s === "peek" ? ir(i, o)[0] : ([r, i, a] = ir(i, o), r);
  }
  ({ cmd: s, size: o } = yield null);
  const l = BF(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 EF(e) {
  return Fe(this, arguments, function* () {
    let n, i = !1, r = [], s, o, a, c = 0;
    function l() {
      return o === "peek" ? ir(r, a)[0] : ([s, r, c] = ir(r, a), s);
    }
    ({ cmd: o, size: a } = yield yield G(null));
    const u = NF(e)[Symbol.asyncIterator]();
    try {
      do
        if ({ done: n, value: s } = Number.isNaN(a - c) ? yield G(u.next()) : yield G(u.next(a - c)), !n && s.byteLength > 0 && (r.push(s), c += s.byteLength), n || a <= c)
          do
            ({ cmd: o, size: a } = yield yield G(l()));
          while (a < c);
      while (!n);
    } catch (f) {
      (i = !0) && typeof u.throw == "function" && (yield G(u.throw(f)));
    } finally {
      i === !1 && typeof u.return == "function" && (yield G(u.return(new Uint8Array(0))));
    }
    return yield G(null);
  });
}
function OF(e) {
  return Fe(this, arguments, function* () {
    let n = !1, i = !1, r = [], s, o, a, c = 0;
    function l() {
      return o === "peek" ? ir(r, a)[0] : ([s, r, c] = ir(r, a), s);
    }
    ({ cmd: o, size: a } = yield yield G(null));
    const u = new LF(e);
    try {
      do
        if ({ done: n, value: s } = Number.isNaN(a - c) ? yield G(u.read()) : yield G(u.read(a - c)), !n && s.byteLength > 0 && (r.push(Xt(s)), c += s.byteLength), n || a <= c)
          do
            ({ cmd: o, size: a } = yield yield G(l()));
          while (a < c);
      while (!n);
    } catch (f) {
      (i = !0) && (yield G(u.cancel(f)));
    } finally {
      i === !1 ? yield G(u.cancel()) : e.locked && u.releaseLock();
    }
    return yield G(null);
  });
}
let LF = 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 Y(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 Y(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 = Xt(n)), n;
    });
  }
};
const I0 = (e, t) => {
  const n = (r) => i([t, r]);
  let i;
  return [t, n, new Promise((r) => (i = r) && e.once(t, n))];
};
function RF(e) {
  return Fe(this, arguments, function* () {
    const n = [];
    let i = "error", r = !1, s = null, o, a, c = 0, l = [], u;
    function f() {
      return o === "peek" ? ir(l, a)[0] : ([u, l, c] = ir(l, a), u);
    }
    if ({ cmd: o, size: a } = yield yield G(null), e.isTTY)
      return yield yield G(new Uint8Array(0)), yield G(null);
    try {
      n[0] = I0(e, "end"), n[1] = I0(e, "error");
      do {
        if (n[2] = I0(e, "readable"), [i, s] = yield G(Promise.race(n.map((d) => d[2]))), i === "error")
          break;
        if ((r = i === "end") || (Number.isFinite(a - c) ? (u = Xt(e.read(a - c)), u.byteLength < a - c && (u = Xt(e.read()))) : u = Xt(e.read()), u.byteLength > 0 && (l.push(u), c += u.byteLength)), r || a <= c)
          do
            ({ cmd: o, size: a } = yield yield G(f()));
          while (a < c);
      } while (!r);
    } finally {
      yield G(h(n, i === "error" ? s : null));
    }
    return yield G(null);
    function h(d, p) {
      return u = l = null, new Promise((m, g) => {
        for (const [y, b] of d)
          e.off(y, b);
        try {
          const y = e.destroy;
          y && y.call(e, p), p = void 0;
        } catch (y) {
          p = y || p;
        } finally {
          p != null ? g(p) : m();
        }
      });
    }
  });
}
var Yn;
(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";
})(Yn || (Yn = {}));
var gi;
(function(e) {
  e[e.Sparse = 0] = "Sparse", e[e.Dense = 1] = "Dense";
})(gi || (gi = {}));
var yn;
(function(e) {
  e[e.HALF = 0] = "HALF", e[e.SINGLE = 1] = "SINGLE", e[e.DOUBLE = 2] = "DOUBLE";
})(yn || (yn = {}));
var Kr;
(function(e) {
  e[e.DAY = 0] = "DAY", e[e.MILLISECOND = 1] = "MILLISECOND";
})(Kr || (Kr = {}));
var jt;
(function(e) {
  e[e.SECOND = 0] = "SECOND", e[e.MILLISECOND = 1] = "MILLISECOND", e[e.MICROSECOND = 2] = "MICROSECOND", e[e.NANOSECOND = 3] = "NANOSECOND";
})(jt || (jt = {}));
var Es;
(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";
})(Es || (Es = {}));
var Jt;
(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";
})(Jt || (Jt = {}));
var R;
(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.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";
})(R || (R = {}));
var Tr;
(function(e) {
  e[e.OFFSET = 0] = "OFFSET", e[e.DATA = 1] = "DATA", e[e.VALIDITY = 2] = "VALIDITY", e[e.TYPE = 3] = "TYPE";
})(Tr || (Tr = {}));
const CF = void 0;
function au(e) {
  if (e === null)
    return "null";
  if (e === CF)
    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 zu || e instanceof Pu ? `[${[...e].map((t) => au(t))}]` : `[${e}]` : ArrayBuffer.isView(e) ? `[${e}]` : JSON.stringify(e, (t, n) => typeof n == "bigint" ? `${n}` : n);
}
const kF = Symbol.for("isArrowBigNum");
function Ti(e, ...t) {
  return t.length === 0 ? Object.setPrototypeOf(ne(this.TypedArray, e), this.constructor.prototype) : Object.setPrototypeOf(new this.TypedArray(e, ...t), this.constructor.prototype);
}
Ti.prototype[kF] = !0;
Ti.prototype.toJSON = function() {
  return `"${zh(this)}"`;
};
Ti.prototype.valueOf = function() {
  return FS(this);
};
Ti.prototype.toString = function() {
  return zh(this);
};
Ti.prototype[Symbol.toPrimitive] = function(e = "default") {
  switch (e) {
    case "number":
      return FS(this);
    case "string":
      return zh(this);
    case "default":
      return UF(this);
  }
  return zh(this);
};
function ja(...e) {
  return Ti.apply(this, e);
}
function Ya(...e) {
  return Ti.apply(this, e);
}
function cu(...e) {
  return Ti.apply(this, e);
}
Object.setPrototypeOf(ja.prototype, Object.create(Int32Array.prototype));
Object.setPrototypeOf(Ya.prototype, Object.create(Uint32Array.prototype));
Object.setPrototypeOf(cu.prototype, Object.create(Uint32Array.prototype));
Object.assign(ja.prototype, Ti.prototype, { constructor: ja, signed: !0, TypedArray: Int32Array, BigIntArray: zu });
Object.assign(Ya.prototype, Ti.prototype, { constructor: Ya, signed: !1, TypedArray: Uint32Array, BigIntArray: Pu });
Object.assign(cu.prototype, Ti.prototype, { constructor: cu, signed: !0, TypedArray: Uint32Array, BigIntArray: Pu });
function FS(e) {
  const { buffer: t, byteOffset: n, length: i, signed: r } = e, s = new Pu(t, n, i), o = r && s[s.length - 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 zh = (e) => e.byteLength === 8 ? `${new e.BigIntArray(e.buffer, e.byteOffset, 1)[0]}` : DS(e), UF = (e) => e.byteLength === 8 ? new e.BigIntArray(e.buffer, e.byteOffset, 1)[0] : DS(e);
function DS(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 zF = class ES {
  /** @nocollapse */
  static new(t, n) {
    switch (n) {
      case !0:
        return new ja(t);
      case !1:
        return new Ya(t);
    }
    switch (t.constructor) {
      case Int8Array:
      case Int16Array:
      case Int32Array:
      case zu:
        return new ja(t);
    }
    return t.byteLength === 16 ? new cu(t) : new Ya(t);
  }
  /** @nocollapse */
  static signed(t) {
    return new ja(t);
  }
  /** @nocollapse */
  static unsigned(t) {
    return new Ya(t);
  }
  /** @nocollapse */
  static decimal(t) {
    return new cu(t);
  }
  constructor(t, n) {
    return ES.new(t, n);
  }
};
function bi(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 OS, LS, RS, CS, kS, US, zS, PS, VS, jS, YS, qS, WS, GS, XS, HS, KS, ZS, JS;
let Nt = class Cm {
  /** @nocollapse */
  static isNull(t) {
    return (t == null ? void 0 : t.typeId) === R.Null;
  }
  /** @nocollapse */
  static isInt(t) {
    return (t == null ? void 0 : t.typeId) === R.Int;
  }
  /** @nocollapse */
  static isFloat(t) {
    return (t == null ? void 0 : t.typeId) === R.Float;
  }
  /** @nocollapse */
  static isBinary(t) {
    return (t == null ? void 0 : t.typeId) === R.Binary;
  }
  /** @nocollapse */
  static isUtf8(t) {
    return (t == null ? void 0 : t.typeId) === R.Utf8;
  }
  /** @nocollapse */
  static isBool(t) {
    return (t == null ? void 0 : t.typeId) === R.Bool;
  }
  /** @nocollapse */
  static isDecimal(t) {
    return (t == null ? void 0 : t.typeId) === R.Decimal;
  }
  /** @nocollapse */
  static isDate(t) {
    return (t == null ? void 0 : t.typeId) === R.Date;
  }
  /** @nocollapse */
  static isTime(t) {
    return (t == null ? void 0 : t.typeId) === R.Time;
  }
  /** @nocollapse */
  static isTimestamp(t) {
    return (t == null ? void 0 : t.typeId) === R.Timestamp;
  }
  /** @nocollapse */
  static isInterval(t) {
    return (t == null ? void 0 : t.typeId) === R.Interval;
  }
  /** @nocollapse */
  static isList(t) {
    return (t == null ? void 0 : t.typeId) === R.List;
  }
  /** @nocollapse */
  static isStruct(t) {
    return (t == null ? void 0 : t.typeId) === R.Struct;
  }
  /** @nocollapse */
  static isUnion(t) {
    return (t == null ? void 0 : t.typeId) === R.Union;
  }
  /** @nocollapse */
  static isFixedSizeBinary(t) {
    return (t == null ? void 0 : t.typeId) === R.FixedSizeBinary;
  }
  /** @nocollapse */
  static isFixedSizeList(t) {
    return (t == null ? void 0 : t.typeId) === R.FixedSizeList;
  }
  /** @nocollapse */
  static isMap(t) {
    return (t == null ? void 0 : t.typeId) === R.Map;
  }
  /** @nocollapse */
  static isDictionary(t) {
    return (t == null ? void 0 : t.typeId) === R.Dictionary;
  }
  /** @nocollapse */
  static isDenseUnion(t) {
    return Cm.isUnion(t) && t.mode === gi.Dense;
  }
  /** @nocollapse */
  static isSparseUnion(t) {
    return Cm.isUnion(t) && t.mode === gi.Sparse;
  }
  get typeId() {
    return R.NONE;
  }
};
OS = Symbol.toStringTag;
Nt[OS] = ((e) => (e.children = null, e.ArrayType = Array, e[Symbol.toStringTag] = "DataType"))(Nt.prototype);
let Os = class extends Nt {
  toString() {
    return "Null";
  }
  get typeId() {
    return R.Null;
  }
};
LS = Symbol.toStringTag;
Os[LS] = ((e) => e[Symbol.toStringTag] = "Null")(Os.prototype);
let Ls = class extends Nt {
  constructor(t, n) {
    super(), this.isSigned = t, this.bitWidth = n;
  }
  get typeId() {
    return R.Int;
  }
  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 ? zu : Pu;
    }
    throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);
  }
  toString() {
    return `${this.isSigned ? "I" : "Ui"}nt${this.bitWidth}`;
  }
};
RS = Symbol.toStringTag;
Ls[RS] = ((e) => (e.isSigned = null, e.bitWidth = null, e[Symbol.toStringTag] = "Int"))(Ls.prototype);
let lu = class extends Ls {
  constructor() {
    super(!0, 32);
  }
  get ArrayType() {
    return Int32Array;
  }
};
Object.defineProperty(lu.prototype, "ArrayType", { value: Int32Array });
let uu = class extends Nt {
  constructor(t) {
    super(), this.precision = t;
  }
  get typeId() {
    return R.Float;
  }
  get ArrayType() {
    switch (this.precision) {
      case yn.HALF:
        return Uint16Array;
      case yn.SINGLE:
        return Float32Array;
      case yn.DOUBLE:
        return Float64Array;
    }
    throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);
  }
  toString() {
    return `Float${this.precision << 5 || 16}`;
  }
};
CS = Symbol.toStringTag;
uu[CS] = ((e) => (e.precision = null, e[Symbol.toStringTag] = "Float"))(uu.prototype);
let Ph = class extends Nt {
  constructor() {
    super();
  }
  get typeId() {
    return R.Binary;
  }
  toString() {
    return "Binary";
  }
};
kS = Symbol.toStringTag;
Ph[kS] = ((e) => (e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "Binary"))(Ph.prototype);
let Vh = class extends Nt {
  constructor() {
    super();
  }
  get typeId() {
    return R.Utf8;
  }
  toString() {
    return "Utf8";
  }
};
US = Symbol.toStringTag;
Vh[US] = ((e) => (e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "Utf8"))(Vh.prototype);
let jh = class extends Nt {
  constructor() {
    super();
  }
  get typeId() {
    return R.Bool;
  }
  toString() {
    return "Bool";
  }
};
zS = Symbol.toStringTag;
jh[zS] = ((e) => (e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "Bool"))(jh.prototype);
let Yh = class extends Nt {
  constructor(t, n, i = 128) {
    super(), this.scale = t, this.precision = n, this.bitWidth = i;
  }
  get typeId() {
    return R.Decimal;
  }
  toString() {
    return `Decimal[${this.precision}e${this.scale > 0 ? "+" : ""}${this.scale}]`;
  }
};
PS = Symbol.toStringTag;
Yh[PS] = ((e) => (e.scale = null, e.precision = null, e.ArrayType = Uint32Array, e[Symbol.toStringTag] = "Decimal"))(Yh.prototype);
let qh = class extends Nt {
  constructor(t) {
    super(), this.unit = t;
  }
  get typeId() {
    return R.Date;
  }
  toString() {
    return `Date${(this.unit + 1) * 32}<${Kr[this.unit]}>`;
  }
};
VS = Symbol.toStringTag;
qh[VS] = ((e) => (e.unit = null, e.ArrayType = Int32Array, e[Symbol.toStringTag] = "Date"))(qh.prototype);
let fu = class extends Nt {
  constructor(t, n) {
    super(), this.unit = t, this.bitWidth = n;
  }
  get typeId() {
    return R.Time;
  }
  toString() {
    return `Time${this.bitWidth}<${jt[this.unit]}>`;
  }
  get ArrayType() {
    switch (this.bitWidth) {
      case 32:
        return Int32Array;
      case 64:
        return zu;
    }
    throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);
  }
};
jS = Symbol.toStringTag;
fu[jS] = ((e) => (e.unit = null, e.bitWidth = null, e[Symbol.toStringTag] = "Time"))(fu.prototype);
let Wh = class extends Nt {
  constructor(t, n) {
    super(), this.unit = t, this.timezone = n;
  }
  get typeId() {
    return R.Timestamp;
  }
  toString() {
    return `Timestamp<${jt[this.unit]}${this.timezone ? `, ${this.timezone}` : ""}>`;
  }
};
YS = Symbol.toStringTag;
Wh[YS] = ((e) => (e.unit = null, e.timezone = null, e.ArrayType = Int32Array, e[Symbol.toStringTag] = "Timestamp"))(Wh.prototype);
let Gh = class extends Nt {
  constructor(t) {
    super(), this.unit = t;
  }
  get typeId() {
    return R.Interval;
  }
  toString() {
    return `Interval<${Es[this.unit]}>`;
  }
};
qS = Symbol.toStringTag;
Gh[qS] = ((e) => (e.unit = null, e.ArrayType = Int32Array, e[Symbol.toStringTag] = "Interval"))(Gh.prototype);
let Xh = class extends Nt {
  constructor(t) {
    super(), this.children = [t];
  }
  get typeId() {
    return R.List;
  }
  toString() {
    return `List<${this.valueType}>`;
  }
  get valueType() {
    return this.children[0].type;
  }
  get valueField() {
    return this.children[0];
  }
  get ArrayType() {
    return this.valueType.ArrayType;
  }
};
WS = Symbol.toStringTag;
Xh[WS] = ((e) => (e.children = null, e[Symbol.toStringTag] = "List"))(Xh.prototype);
let on = class extends Nt {
  constructor(t) {
    super(), this.children = t;
  }
  get typeId() {
    return R.Struct;
  }
  toString() {
    return `Struct<{${this.children.map((t) => `${t.name}:${t.type}`).join(", ")}}>`;
  }
};
GS = Symbol.toStringTag;
on[GS] = ((e) => (e.children = null, e[Symbol.toStringTag] = "Struct"))(on.prototype);
let Hh = class extends Nt {
  constructor(t, n, i) {
    super(), 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));
  }
  get typeId() {
    return R.Union;
  }
  toString() {
    return `${this[Symbol.toStringTag]}<${this.children.map((t) => `${t.type}`).join(" | ")}>`;
  }
};
XS = Symbol.toStringTag;
Hh[XS] = ((e) => (e.mode = null, e.typeIds = null, e.children = null, e.typeIdToChildIndex = null, e.ArrayType = Int8Array, e[Symbol.toStringTag] = "Union"))(Hh.prototype);
let Kh = class extends Nt {
  constructor(t) {
    super(), this.byteWidth = t;
  }
  get typeId() {
    return R.FixedSizeBinary;
  }
  toString() {
    return `FixedSizeBinary[${this.byteWidth}]`;
  }
};
HS = Symbol.toStringTag;
Kh[HS] = ((e) => (e.byteWidth = null, e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "FixedSizeBinary"))(Kh.prototype);
let Zh = class extends Nt {
  constructor(t, n) {
    super(), this.listSize = t, this.children = [n];
  }
  get typeId() {
    return R.FixedSizeList;
  }
  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}>`;
  }
};
KS = Symbol.toStringTag;
Zh[KS] = ((e) => (e.children = null, e.listSize = null, e[Symbol.toStringTag] = "FixedSizeList"))(Zh.prototype);
let Jh = class extends Nt {
  constructor(t, n = !1) {
    super(), this.children = [t], this.keysSorted = n;
  }
  get typeId() {
    return R.Map;
  }
  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(", ")}}>`;
  }
};
ZS = Symbol.toStringTag;
Jh[ZS] = ((e) => (e.children = null, e.keysSorted = null, e[Symbol.toStringTag] = "Map_"))(Jh.prototype);
const PF = ((e) => () => ++e)(-1);
let uc = class extends Nt {
  constructor(t, n, i, r) {
    super(), this.indices = n, this.dictionary = t, this.isOrdered = r || !1, this.id = i == null ? PF() : bi(i);
  }
  get typeId() {
    return R.Dictionary;
  }
  get children() {
    return this.dictionary.children;
  }
  get valueType() {
    return this.dictionary;
  }
  get ArrayType() {
    return this.dictionary.ArrayType;
  }
  toString() {
    return `Dictionary<${this.indices}, ${this.dictionary}>`;
  }
};
JS = Symbol.toStringTag;
uc[JS] = ((e) => (e.id = null, e.indices = null, e.isOrdered = null, e.dictionary = null, e[Symbol.toStringTag] = "Dictionary"))(uc.prototype);
function Br(e) {
  const t = e;
  switch (e.typeId) {
    case R.Decimal:
      return e.bitWidth / 32;
    case R.Timestamp:
      return 2;
    case R.Date:
      return 1 + t.unit;
    case R.Interval:
      return 1 + t.unit;
    case R.FixedSizeList:
      return t.listSize;
    case R.FixedSizeBinary:
      return t.byteWidth;
    default:
      return 1;
  }
}
let kt = 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 VF(this, t, n);
  }
  getVisitFnByTypeId(t, n = !0) {
    return va(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;
  }
  visitBinary(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;
  }
  visitFixedSizeList(t, ...n) {
    return null;
  }
  visitMap(t, ...n) {
    return null;
  }
};
function VF(e, t, n = !0) {
  return typeof t == "number" ? va(e, t, n) : typeof t == "string" && t in R ? va(e, R[t], n) : t && t instanceof Nt ? va(e, Ow(t), n) : t != null && t.type && t.type instanceof Nt ? va(e, Ow(t.type), n) : va(e, R.NONE, n);
}
function va(e, t, n = !0) {
  let i = null;
  switch (t) {
    case R.Null:
      i = e.visitNull;
      break;
    case R.Bool:
      i = e.visitBool;
      break;
    case R.Int:
      i = e.visitInt;
      break;
    case R.Int8:
      i = e.visitInt8 || e.visitInt;
      break;
    case R.Int16:
      i = e.visitInt16 || e.visitInt;
      break;
    case R.Int32:
      i = e.visitInt32 || e.visitInt;
      break;
    case R.Int64:
      i = e.visitInt64 || e.visitInt;
      break;
    case R.Uint8:
      i = e.visitUint8 || e.visitInt;
      break;
    case R.Uint16:
      i = e.visitUint16 || e.visitInt;
      break;
    case R.Uint32:
      i = e.visitUint32 || e.visitInt;
      break;
    case R.Uint64:
      i = e.visitUint64 || e.visitInt;
      break;
    case R.Float:
      i = e.visitFloat;
      break;
    case R.Float16:
      i = e.visitFloat16 || e.visitFloat;
      break;
    case R.Float32:
      i = e.visitFloat32 || e.visitFloat;
      break;
    case R.Float64:
      i = e.visitFloat64 || e.visitFloat;
      break;
    case R.Utf8:
      i = e.visitUtf8;
      break;
    case R.Binary:
      i = e.visitBinary;
      break;
    case R.FixedSizeBinary:
      i = e.visitFixedSizeBinary;
      break;
    case R.Date:
      i = e.visitDate;
      break;
    case R.DateDay:
      i = e.visitDateDay || e.visitDate;
      break;
    case R.DateMillisecond:
      i = e.visitDateMillisecond || e.visitDate;
      break;
    case R.Timestamp:
      i = e.visitTimestamp;
      break;
    case R.TimestampSecond:
      i = e.visitTimestampSecond || e.visitTimestamp;
      break;
    case R.TimestampMillisecond:
      i = e.visitTimestampMillisecond || e.visitTimestamp;
      break;
    case R.TimestampMicrosecond:
      i = e.visitTimestampMicrosecond || e.visitTimestamp;
      break;
    case R.TimestampNanosecond:
      i = e.visitTimestampNanosecond || e.visitTimestamp;
      break;
    case R.Time:
      i = e.visitTime;
      break;
    case R.TimeSecond:
      i = e.visitTimeSecond || e.visitTime;
      break;
    case R.TimeMillisecond:
      i = e.visitTimeMillisecond || e.visitTime;
      break;
    case R.TimeMicrosecond:
      i = e.visitTimeMicrosecond || e.visitTime;
      break;
    case R.TimeNanosecond:
      i = e.visitTimeNanosecond || e.visitTime;
      break;
    case R.Decimal:
      i = e.visitDecimal;
      break;
    case R.List:
      i = e.visitList;
      break;
    case R.Struct:
      i = e.visitStruct;
      break;
    case R.Union:
      i = e.visitUnion;
      break;
    case R.DenseUnion:
      i = e.visitDenseUnion || e.visitUnion;
      break;
    case R.SparseUnion:
      i = e.visitSparseUnion || e.visitUnion;
      break;
    case R.Dictionary:
      i = e.visitDictionary;
      break;
    case R.Interval:
      i = e.visitInterval;
      break;
    case R.IntervalDayTime:
      i = e.visitIntervalDayTime || e.visitInterval;
      break;
    case R.IntervalYearMonth:
      i = e.visitIntervalYearMonth || e.visitInterval;
      break;
    case R.FixedSizeList:
      i = e.visitFixedSizeList;
      break;
    case R.Map:
      i = e.visitMap;
      break;
  }
  if (typeof i == "function")
    return i;
  if (!n)
    return () => null;
  throw new Error(`Unrecognized type '${R[t]}'`);
}
function Ow(e) {
  switch (e.typeId) {
    case R.Null:
      return R.Null;
    case R.Int: {
      const { bitWidth: t, isSigned: n } = e;
      switch (t) {
        case 8:
          return n ? R.Int8 : R.Uint8;
        case 16:
          return n ? R.Int16 : R.Uint16;
        case 32:
          return n ? R.Int32 : R.Uint32;
        case 64:
          return n ? R.Int64 : R.Uint64;
      }
      return R.Int;
    }
    case R.Float:
      switch (e.precision) {
        case yn.HALF:
          return R.Float16;
        case yn.SINGLE:
          return R.Float32;
        case yn.DOUBLE:
          return R.Float64;
      }
      return R.Float;
    case R.Binary:
      return R.Binary;
    case R.Utf8:
      return R.Utf8;
    case R.Bool:
      return R.Bool;
    case R.Decimal:
      return R.Decimal;
    case R.Time:
      switch (e.unit) {
        case jt.SECOND:
          return R.TimeSecond;
        case jt.MILLISECOND:
          return R.TimeMillisecond;
        case jt.MICROSECOND:
          return R.TimeMicrosecond;
        case jt.NANOSECOND:
          return R.TimeNanosecond;
      }
      return R.Time;
    case R.Timestamp:
      switch (e.unit) {
        case jt.SECOND:
          return R.TimestampSecond;
        case jt.MILLISECOND:
          return R.TimestampMillisecond;
        case jt.MICROSECOND:
          return R.TimestampMicrosecond;
        case jt.NANOSECOND:
          return R.TimestampNanosecond;
      }
      return R.Timestamp;
    case R.Date:
      switch (e.unit) {
        case Kr.DAY:
          return R.DateDay;
        case Kr.MILLISECOND:
          return R.DateMillisecond;
      }
      return R.Date;
    case R.Interval:
      switch (e.unit) {
        case Es.DAY_TIME:
          return R.IntervalDayTime;
        case Es.YEAR_MONTH:
          return R.IntervalYearMonth;
      }
      return R.Interval;
    case R.Map:
      return R.Map;
    case R.List:
      return R.List;
    case R.Struct:
      return R.Struct;
    case R.Union:
      switch (e.mode) {
        case gi.Dense:
          return R.DenseUnion;
        case gi.Sparse:
          return R.SparseUnion;
      }
      return R.Union;
    case R.FixedSizeBinary:
      return R.FixedSizeBinary;
    case R.FixedSizeList:
      return R.FixedSizeList;
    case R.Dictionary:
      return R.Dictionary;
  }
  throw new Error(`Unrecognized type '${R[e.typeId]}'`);
}
kt.prototype.visitInt8 = null;
kt.prototype.visitInt16 = null;
kt.prototype.visitInt32 = null;
kt.prototype.visitInt64 = null;
kt.prototype.visitUint8 = null;
kt.prototype.visitUint16 = null;
kt.prototype.visitUint32 = null;
kt.prototype.visitUint64 = null;
kt.prototype.visitFloat16 = null;
kt.prototype.visitFloat32 = null;
kt.prototype.visitFloat64 = null;
kt.prototype.visitDateDay = null;
kt.prototype.visitDateMillisecond = null;
kt.prototype.visitTimestampSecond = null;
kt.prototype.visitTimestampMillisecond = null;
kt.prototype.visitTimestampMicrosecond = null;
kt.prototype.visitTimestampNanosecond = null;
kt.prototype.visitTimeSecond = null;
kt.prototype.visitTimeMillisecond = null;
kt.prototype.visitTimeMicrosecond = null;
kt.prototype.visitTimeNanosecond = null;
kt.prototype.visitDenseUnion = null;
kt.prototype.visitSparseUnion = null;
kt.prototype.visitIntervalDayTime = null;
kt.prototype.visitIntervalYearMonth = null;
const QS = new Float64Array(1), ca = new Uint32Array(QS.buffer);
function tI(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 jF(e) {
  if (e !== e)
    return 32256;
  QS[0] = e;
  const t = (ca[1] & 2147483648) >> 16 & 65535;
  let n = ca[1] & 2146435072, i = 0;
  return n >= 1089470464 ? ca[0] > 0 ? n = 31744 : (n = (n & 2080374784) >> 16, i = (ca[1] & 1048575) >> 10) : n <= 1056964608 ? (i = 1048576 + (ca[1] & 1048575), i = 1048576 + (i << (n >> 20) - 998) >> 21, n = 0) : (n = n - 1056964608 >> 10, i = (ca[1] & 1048575) + 512 >> 10), t | n | i & 65535;
}
let bt = class extends kt {
};
function At(e) {
  return (t, n, i) => {
    if (t.setValid(n, i != null))
      return e(t, n, i);
  };
}
const YF = (e, t, n) => {
  e[t] = Math.trunc(n / 864e5);
}, T1 = (e, t, n) => {
  e[t] = Math.trunc(n % 4294967296), e[t + 1] = Math.trunc(n / 4294967296);
}, qF = (e, t, n) => {
  e[t] = Math.trunc(n * 1e3 % 4294967296), e[t + 1] = Math.trunc(n * 1e3 / 4294967296);
}, WF = (e, t, n) => {
  e[t] = Math.trunc(n * 1e6 % 4294967296), e[t + 1] = Math.trunc(n * 1e6 / 4294967296);
}, eI = (e, t, n, i) => {
  if (n + 1 < t.length) {
    const { [n]: r, [n + 1]: s } = t;
    e.set(i.subarray(0, s - r), r);
  }
}, GF = ({ offset: e, values: t }, n, i) => {
  const r = e + n;
  i ? t[r >> 3] |= 1 << r % 8 : t[r >> 3] &= ~(1 << r % 8);
}, rs = ({ values: e }, t, n) => {
  e[t] = n;
}, B1 = ({ values: e }, t, n) => {
  e[t] = n;
}, nI = ({ values: e }, t, n) => {
  e[t] = jF(n);
}, XF = (e, t, n) => {
  switch (e.type.precision) {
    case yn.HALF:
      return nI(e, t, n);
    case yn.SINGLE:
    case yn.DOUBLE:
      return B1(e, t, n);
  }
}, iI = ({ values: e }, t, n) => {
  YF(e, t, n.valueOf());
}, rI = ({ values: e }, t, n) => {
  T1(e, t * 2, n.valueOf());
}, HF = ({ stride: e, values: t }, n, i) => {
  t.set(i.subarray(0, e), e * n);
}, KF = ({ values: e, valueOffsets: t }, n, i) => eI(e, t, n, i), ZF = ({ values: e, valueOffsets: t }, n, i) => {
  eI(e, t, n, I1(i));
}, JF = (e, t, n) => {
  e.type.unit === Kr.DAY ? iI(e, t, n) : rI(e, t, n);
}, sI = ({ values: e }, t, n) => T1(e, t * 2, n / 1e3), oI = ({ values: e }, t, n) => T1(e, t * 2, n), aI = ({ values: e }, t, n) => qF(e, t * 2, n), cI = ({ values: e }, t, n) => WF(e, t * 2, n), QF = (e, t, n) => {
  switch (e.type.unit) {
    case jt.SECOND:
      return sI(e, t, n);
    case jt.MILLISECOND:
      return oI(e, t, n);
    case jt.MICROSECOND:
      return aI(e, t, n);
    case jt.NANOSECOND:
      return cI(e, t, n);
  }
}, lI = ({ values: e }, t, n) => {
  e[t] = n;
}, uI = ({ values: e }, t, n) => {
  e[t] = n;
}, fI = ({ values: e }, t, n) => {
  e[t] = n;
}, hI = ({ values: e }, t, n) => {
  e[t] = n;
}, tD = (e, t, n) => {
  switch (e.type.unit) {
    case jt.SECOND:
      return lI(e, t, n);
    case jt.MILLISECOND:
      return uI(e, t, n);
    case jt.MICROSECOND:
      return fI(e, t, n);
    case jt.NANOSECOND:
      return hI(e, t, n);
  }
}, eD = ({ values: e, stride: t }, n, i) => {
  e.set(i.subarray(0, t), t * n);
}, nD = (e, t, n) => {
  const i = e.children[0], r = e.valueOffsets, s = ti.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));
}, iD = (e, t, n) => {
  const i = e.children[0], { valueOffsets: r } = e, s = ti.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;
}, rD = (e, t) => (n, i, r, s) => i && n(i, e, t[s]), sD = (e, t) => (n, i, r, s) => i && n(i, e, t.get(s)), oD = (e, t) => (n, i, r, s) => i && n(i, e, t.get(r.name)), aD = (e, t) => (n, i, r, s) => i && n(i, e, t[r.name]), cD = (e, t, n) => {
  const i = e.type.children.map((s) => ti.getVisitFn(s.type)), r = n instanceof Map ? oD(t, n) : n instanceof $e ? sD(t, n) : Array.isArray(n) ? rD(t, n) : aD(t, n);
  e.type.children.forEach((s, o) => r(i[o], e.children[o], s, o));
}, lD = (e, t, n) => {
  e.type.mode === gi.Dense ? dI(e, t, n) : pI(e, t, n);
}, dI = (e, t, n) => {
  const i = e.type.typeIdToChildIndex[e.typeIds[t]], r = e.children[i];
  ti.visit(r, e.valueOffsets[t], n);
}, pI = (e, t, n) => {
  const i = e.type.typeIdToChildIndex[e.typeIds[t]], r = e.children[i];
  ti.visit(r, t, n);
}, uD = (e, t, n) => {
  var i;
  (i = e.dictionary) === null || i === void 0 || i.set(e.values[t], n);
}, fD = (e, t, n) => {
  e.type.unit === Es.DAY_TIME ? yI(e, t, n) : mI(e, t, n);
}, yI = ({ values: e }, t, n) => {
  e.set(n.subarray(0, 2), 2 * t);
}, mI = ({ values: e }, t, n) => {
  e[t] = n[0] * 12 + n[1] % 12;
}, hD = (e, t, n) => {
  const { stride: i } = e, r = e.children[0], s = ti.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));
};
bt.prototype.visitBool = At(GF);
bt.prototype.visitInt = At(rs);
bt.prototype.visitInt8 = At(rs);
bt.prototype.visitInt16 = At(rs);
bt.prototype.visitInt32 = At(rs);
bt.prototype.visitInt64 = At(rs);
bt.prototype.visitUint8 = At(rs);
bt.prototype.visitUint16 = At(rs);
bt.prototype.visitUint32 = At(rs);
bt.prototype.visitUint64 = At(rs);
bt.prototype.visitFloat = At(XF);
bt.prototype.visitFloat16 = At(nI);
bt.prototype.visitFloat32 = At(B1);
bt.prototype.visitFloat64 = At(B1);
bt.prototype.visitUtf8 = At(ZF);
bt.prototype.visitBinary = At(KF);
bt.prototype.visitFixedSizeBinary = At(HF);
bt.prototype.visitDate = At(JF);
bt.prototype.visitDateDay = At(iI);
bt.prototype.visitDateMillisecond = At(rI);
bt.prototype.visitTimestamp = At(QF);
bt.prototype.visitTimestampSecond = At(sI);
bt.prototype.visitTimestampMillisecond = At(oI);
bt.prototype.visitTimestampMicrosecond = At(aI);
bt.prototype.visitTimestampNanosecond = At(cI);
bt.prototype.visitTime = At(tD);
bt.prototype.visitTimeSecond = At(lI);
bt.prototype.visitTimeMillisecond = At(uI);
bt.prototype.visitTimeMicrosecond = At(fI);
bt.prototype.visitTimeNanosecond = At(hI);
bt.prototype.visitDecimal = At(eD);
bt.prototype.visitList = At(nD);
bt.prototype.visitStruct = At(cD);
bt.prototype.visitUnion = At(lD);
bt.prototype.visitDenseUnion = At(dI);
bt.prototype.visitSparseUnion = At(pI);
bt.prototype.visitDictionary = At(uD);
bt.prototype.visitInterval = At(fD);
bt.prototype.visitIntervalDayTime = At(yI);
bt.prototype.visitIntervalYearMonth = At(mI);
bt.prototype.visitFixedSizeList = At(hD);
bt.prototype.visitMap = At(iD);
const ti = new bt(), ai = Symbol.for("parent"), qa = Symbol.for("rowIndex");
let N1 = class {
  constructor(t, n) {
    return this[ai] = t, this[qa] = n, new Proxy(this, new pD());
  }
  toArray() {
    return Object.values(this.toJSON());
  }
  toJSON() {
    const t = this[qa], n = this[ai], i = n.type.children, r = {};
    for (let s = -1, o = i.length; ++s < o; )
      r[i[s].name] = gn.visit(n.children[s], t);
    return r;
  }
  toString() {
    return `{${[...this].map(([t, n]) => `${au(t)}: ${au(n)}`).join(", ")}}`;
  }
  [Symbol.for("nodejs.util.inspect.custom")]() {
    return this.toString();
  }
  [Symbol.iterator]() {
    return new dD(this[ai], this[qa]);
  }
}, dD = 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,
        gn.visit(this.children[t], this.rowIndex)
      ]
    }) : { done: !0, value: null };
  }
};
Object.defineProperties(N1.prototype, {
  [Symbol.toStringTag]: { enumerable: !1, configurable: !1, value: "Row" },
  [ai]: { writable: !0, enumerable: !1, configurable: !1, value: null },
  [qa]: { writable: !0, enumerable: !1, configurable: !1, value: -1 }
});
let pD = class {
  isExtensible() {
    return !1;
  }
  deleteProperty() {
    return !1;
  }
  preventExtensions() {
    return !0;
  }
  ownKeys(t) {
    return t[ai].type.children.map((n) => n.name);
  }
  has(t, n) {
    return t[ai].type.children.findIndex((i) => i.name === n) !== -1;
  }
  getOwnPropertyDescriptor(t, n) {
    if (t[ai].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[ai].type.children.findIndex((r) => r.name === n);
    if (i !== -1) {
      const r = gn.visit(t[ai].children[i], t[qa]);
      return Reflect.set(t, n, r), r;
    }
  }
  set(t, n, i) {
    const r = t[ai].type.children.findIndex((s) => s.name === n);
    return r !== -1 ? (ti.visit(t[ai].children[r], t[qa], i), Reflect.set(t, n, i)) : Reflect.has(t, n) || typeof n == "symbol" ? Reflect.set(t, n, i) : !1;
  }
}, ut = class extends kt {
};
function _t(e) {
  return (t, n) => t.getValid(n) ? e(t, n) : null;
}
const yD = (e, t) => 864e5 * e[t], F1 = (e, t) => 4294967296 * e[t + 1] + (e[t] >>> 0), mD = (e, t) => 4294967296 * (e[t + 1] / 1e3) + (e[t] >>> 0) / 1e3, gD = (e, t) => 4294967296 * (e[t + 1] / 1e6) + (e[t] >>> 0) / 1e6, gI = (e) => new Date(e), bD = (e, t) => gI(yD(e, t)), _D = (e, t) => gI(F1(e, t)), wD = (e, t) => null, bI = (e, t, n) => {
  if (n + 1 >= t.length)
    return null;
  const i = t[n], r = t[n + 1];
  return e.subarray(i, r);
}, vD = ({ offset: e, values: t }, n) => {
  const i = e + n;
  return (t[i >> 3] & 1 << i % 8) !== 0;
}, _I = ({ values: e }, t) => bD(e, t), wI = ({ values: e }, t) => _D(e, t * 2), Ks = ({ stride: e, values: t }, n) => t[e * n], xD = ({ stride: e, values: t }, n) => tI(t[e * n]), vI = ({ values: e }, t) => e[t], SD = ({ stride: e, values: t }, n) => t.subarray(e * n, e * (n + 1)), ID = ({ values: e, valueOffsets: t }, n) => bI(e, t, n), AD = ({ values: e, valueOffsets: t }, n) => {
  const i = bI(e, t, n);
  return i !== null ? Om(i) : null;
}, MD = ({ values: e }, t) => e[t], $D = ({ type: e, values: t }, n) => e.precision !== yn.HALF ? t[n] : tI(t[n]), TD = (e, t) => e.type.unit === Kr.DAY ? _I(e, t) : wI(e, t), xI = ({ values: e }, t) => 1e3 * F1(e, t * 2), SI = ({ values: e }, t) => F1(e, t * 2), II = ({ values: e }, t) => mD(e, t * 2), AI = ({ values: e }, t) => gD(e, t * 2), BD = (e, t) => {
  switch (e.type.unit) {
    case jt.SECOND:
      return xI(e, t);
    case jt.MILLISECOND:
      return SI(e, t);
    case jt.MICROSECOND:
      return II(e, t);
    case jt.NANOSECOND:
      return AI(e, t);
  }
}, MI = ({ values: e }, t) => e[t], $I = ({ values: e }, t) => e[t], TI = ({ values: e }, t) => e[t], BI = ({ values: e }, t) => e[t], ND = (e, t) => {
  switch (e.type.unit) {
    case jt.SECOND:
      return MI(e, t);
    case jt.MILLISECOND:
      return $I(e, t);
    case jt.MICROSECOND:
      return TI(e, t);
    case jt.NANOSECOND:
      return BI(e, t);
  }
}, FD = ({ values: e, stride: t }, n) => zF.decimal(e.subarray(t * n, t * (n + 1))), DD = (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 $e([c]);
}, ED = (e, t) => {
  const { valueOffsets: n, children: i } = e, { [t]: r, [t + 1]: s } = n, o = i[0];
  return new D1(o.slice(r, s - r));
}, OD = (e, t) => new N1(e, t), LD = (e, t) => e.type.mode === gi.Dense ? NI(e, t) : FI(e, t), NI = (e, t) => {
  const n = e.type.typeIdToChildIndex[e.typeIds[t]], i = e.children[n];
  return gn.visit(i, e.valueOffsets[t]);
}, FI = (e, t) => {
  const n = e.type.typeIdToChildIndex[e.typeIds[t]], i = e.children[n];
  return gn.visit(i, t);
}, RD = (e, t) => {
  var n;
  return (n = e.dictionary) === null || n === void 0 ? void 0 : n.get(e.values[t]);
}, CD = (e, t) => e.type.unit === Es.DAY_TIME ? DI(e, t) : EI(e, t), DI = ({ values: e }, t) => e.subarray(2 * t, 2 * (t + 1)), EI = ({ 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;
}, kD = (e, t) => {
  const { stride: n, children: i } = e, s = i[0].slice(t * n, n);
  return new $e([s]);
};
ut.prototype.visitNull = _t(wD);
ut.prototype.visitBool = _t(vD);
ut.prototype.visitInt = _t(MD);
ut.prototype.visitInt8 = _t(Ks);
ut.prototype.visitInt16 = _t(Ks);
ut.prototype.visitInt32 = _t(Ks);
ut.prototype.visitInt64 = _t(vI);
ut.prototype.visitUint8 = _t(Ks);
ut.prototype.visitUint16 = _t(Ks);
ut.prototype.visitUint32 = _t(Ks);
ut.prototype.visitUint64 = _t(vI);
ut.prototype.visitFloat = _t($D);
ut.prototype.visitFloat16 = _t(xD);
ut.prototype.visitFloat32 = _t(Ks);
ut.prototype.visitFloat64 = _t(Ks);
ut.prototype.visitUtf8 = _t(AD);
ut.prototype.visitBinary = _t(ID);
ut.prototype.visitFixedSizeBinary = _t(SD);
ut.prototype.visitDate = _t(TD);
ut.prototype.visitDateDay = _t(_I);
ut.prototype.visitDateMillisecond = _t(wI);
ut.prototype.visitTimestamp = _t(BD);
ut.prototype.visitTimestampSecond = _t(xI);
ut.prototype.visitTimestampMillisecond = _t(SI);
ut.prototype.visitTimestampMicrosecond = _t(II);
ut.prototype.visitTimestampNanosecond = _t(AI);
ut.prototype.visitTime = _t(ND);
ut.prototype.visitTimeSecond = _t(MI);
ut.prototype.visitTimeMillisecond = _t($I);
ut.prototype.visitTimeMicrosecond = _t(TI);
ut.prototype.visitTimeNanosecond = _t(BI);
ut.prototype.visitDecimal = _t(FD);
ut.prototype.visitList = _t(DD);
ut.prototype.visitStruct = _t(OD);
ut.prototype.visitUnion = _t(LD);
ut.prototype.visitDenseUnion = _t(NI);
ut.prototype.visitSparseUnion = _t(FI);
ut.prototype.visitDictionary = _t(RD);
ut.prototype.visitInterval = _t(CD);
ut.prototype.visitIntervalDayTime = _t(DI);
ut.prototype.visitIntervalYearMonth = _t(EI);
ut.prototype.visitFixedSizeList = _t(kD);
ut.prototype.visitMap = _t(ED);
const gn = new ut(), Vi = Symbol.for("keys"), Wa = Symbol.for("vals");
let D1 = class {
  constructor(t) {
    return this[Vi] = new $e([t.children[0]]).memoize(), this[Wa] = t.children[1], new Proxy(this, new zD());
  }
  [Symbol.iterator]() {
    return new UD(this[Vi], this[Wa]);
  }
  get size() {
    return this[Vi].length;
  }
  toArray() {
    return Object.values(this.toJSON());
  }
  toJSON() {
    const t = this[Vi], n = this[Wa], i = {};
    for (let r = -1, s = t.length; ++r < s; )
      i[t.get(r)] = gn.visit(n, r);
    return i;
  }
  toString() {
    return `{${[...this].map(([t, n]) => `${au(t)}: ${au(n)}`).join(", ")}}`;
  }
  [Symbol.for("nodejs.util.inspect.custom")]() {
    return this.toString();
  }
}, UD = 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),
        gn.visit(this.vals, t)
      ]
    });
  }
}, zD = class {
  isExtensible() {
    return !1;
  }
  deleteProperty() {
    return !1;
  }
  preventExtensions() {
    return !0;
  }
  ownKeys(t) {
    return t[Vi].toArray().map(String);
  }
  has(t, n) {
    return t[Vi].includes(n);
  }
  getOwnPropertyDescriptor(t, n) {
    if (t[Vi].indexOf(n) !== -1)
      return { writable: !0, enumerable: !0, configurable: !0 };
  }
  get(t, n) {
    if (Reflect.has(t, n))
      return t[n];
    const i = t[Vi].indexOf(n);
    if (i !== -1) {
      const r = gn.visit(Reflect.get(t, Wa), i);
      return Reflect.set(t, n, r), r;
    }
  }
  set(t, n, i) {
    const r = t[Vi].indexOf(n);
    return r !== -1 ? (ti.visit(Reflect.get(t, Wa), r, i), Reflect.set(t, n, i)) : Reflect.has(t, n) ? Reflect.set(t, n, i) : !1;
  }
};
Object.defineProperties(D1.prototype, {
  [Symbol.toStringTag]: { enumerable: !1, configurable: !1, value: "Row" },
  [Vi]: { writable: !0, enumerable: !1, configurable: !1, value: null },
  [Wa]: { writable: !0, enumerable: !1, configurable: !1, value: null }
});
let Lw;
function OI(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 && (Lw = s, s = o, o = Lw), o > r && (o = r), i ? i(e, s, o) : [s, o];
}
const Rw = (e) => e !== e;
function qc(e) {
  if (typeof e !== "object" || e === null)
    return Rw(e) ? Rw : (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 ? FF(e, n) : !1 : e instanceof Map ? VD(e) : Array.isArray(e) ? PD(e) : e instanceof $e ? jD(e) : YD(e, !0);
}
function PD(e) {
  const t = [];
  for (let n = -1, i = e.length; ++n < i; )
    t[n] = qc(e[n]);
  return sy(t);
}
function VD(e) {
  let t = -1;
  const n = [];
  for (const i of e.values())
    n[++t] = qc(i);
  return sy(n);
}
function jD(e) {
  const t = [];
  for (let n = -1, i = e.length; ++n < i; )
    t[n] = qc(e.get(n));
  return sy(t);
}
function YD(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] = qc(e[n[r]]);
  return sy(i, n);
}
function sy(e, t) {
  return (n) => {
    if (!n || typeof n != "object")
      return !1;
    switch (n.constructor) {
      case Array:
        return qD(e, n);
      case Map:
        return Cw(e, n, n.keys());
      case D1:
      case N1:
      case Object:
      case void 0:
        return Cw(e, n, t || Object.keys(n));
    }
    return n instanceof $e ? WD(e, n) : !1;
  };
}
function qD(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 WD(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 Cw(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 LI(e, t, n, i) {
  return (n & 1 << i) !== 0;
}
function GD(e, t, n, i) {
  return (n & 1 << i) >> i;
}
function XD(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
      km(new E1(n, e, t, null, LI)).subarray(0, i)
    )), r;
  }
  return n;
}
function km(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 E1 = 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 Um(e, t, n) {
  if (n - t <= 0)
    return 0;
  if (n - t < 8) {
    let s = 0;
    for (const o of new E1(e, t, n - t, e, GD))
      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
    Um(e, t, r) + // Get the popcnt of bits between the right hand side, and the next lowest multiple of 8
    Um(e, i, n) + // Get the popcnt of all bits between the left and right hand sides' multiples of 8
    HD(e, r >> 3, i - r >> 3)
  );
}
function HD(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 += A0(s.getUint32(r)), r += 4;
  for (; o - r >= 2; )
    i += A0(s.getUint16(r)), r += 2;
  for (; o - r >= 1; )
    i += A0(s.getUint8(r)), r += 1;
  return i;
}
function A0(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 KD = -1;
let me = class zm {
  get typeId() {
    return this.type.typeId;
  }
  get ArrayType() {
    return this.type.ArrayType;
  }
  get buffers() {
    return [this.valueOffsets, this.values, this.nullBitmap, this.typeIds];
  }
  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() {
    let t = this._nullCount, n;
    return t <= KD && (n = this.nullBitmap) && (this._nullCount = t = this.length - Um(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 zm ? (this.stride = s.stride, this.values = s.values, this.typeIds = s.typeIds, this.nullBitmap = s.nullBitmap, this.valueOffsets = s.valueOffsets) : (this.stride = Br(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))), this.nullable = this._nullCount !== 0 && this.nullBitmap && this.nullBitmap.byteLength > 0;
  }
  getValid(t) {
    if (this.nullable && this.nullCount > 0) {
      const n = this.offset + t;
      return (this.nullBitmap[n >> 3] & 1 << n % 8) !== 0;
    }
    return !0;
  }
  setValid(t, n) {
    if (!this.nullable)
      return n;
    if (!this.nullBitmap || this.nullBitmap.byteLength <= t >> 3) {
      const { nullBitmap: c } = this._changeLengthAndBackfillNullBitmap(this.length);
      Object.assign(this, { nullBitmap: c, _nullCount: 0 });
    }
    const { nullBitmap: i, offset: r } = this, s = r + t >> 3, o = (r + t) % 8, a = i[s] >> o & 1;
    return n ? a === 0 && (i[s] |= 1 << o, this._nullCount = this.nullCount + 1) : a === 1 && (i[s] &= ~(1 << o), this._nullCount = this.nullCount - 1), n;
  }
  clone(t = this.type, n = this.offset, i = this.length, r = this._nullCount, s = this, o = this.children) {
    return new zm(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 === R.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(XD(this.offset, n, this.nullBitmap), 0);
    const s = this.buffers;
    return s[Tr.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[Tr.TYPE]) && (o[Tr.TYPE] = s.subarray(t, t + n)), (s = o[Tr.OFFSET]) && (o[Tr.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[Tr.DATA]) && (o[Tr.DATA] = r === 6 ? s : s.subarray(i * t, i * (t + n))), o;
  }
  _sliceChildren(t, n, i) {
    return t.map((r) => r.slice(n, i));
  }
};
me.prototype.children = Object.freeze([]);
let ZD = class ph extends kt {
  visit(t) {
    return this.getVisitFn(t.type).call(this, t);
  }
  visitNull(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["length"]: r = 0 } = t;
    return new me(n, i, r, 0);
  }
  visitBool(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Xt(t.nullBitmap), s = ne(n.ArrayType, t.data), { ["length"]: o = s.length >> 3, ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new me(n, i, o, a, [void 0, s, r]);
  }
  visitInt(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Xt(t.nullBitmap), s = ne(n.ArrayType, t.data), { ["length"]: o = s.length, ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new me(n, i, o, a, [void 0, s, r]);
  }
  visitFloat(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Xt(t.nullBitmap), s = ne(n.ArrayType, t.data), { ["length"]: o = s.length, ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new me(n, i, o, a, [void 0, s, r]);
  }
  visitUtf8(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Xt(t.data), s = Xt(t.nullBitmap), o = hl(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new me(n, i, a, c, [o, r, s]);
  }
  visitBinary(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Xt(t.data), s = Xt(t.nullBitmap), o = hl(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new me(n, i, a, c, [o, r, s]);
  }
  visitFixedSizeBinary(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Xt(t.nullBitmap), s = ne(n.ArrayType, t.data), { ["length"]: o = s.length / Br(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new me(n, i, o, a, [void 0, s, r]);
  }
  visitDate(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Xt(t.nullBitmap), s = ne(n.ArrayType, t.data), { ["length"]: o = s.length / Br(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new me(n, i, o, a, [void 0, s, r]);
  }
  visitTimestamp(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Xt(t.nullBitmap), s = ne(n.ArrayType, t.data), { ["length"]: o = s.length / Br(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new me(n, i, o, a, [void 0, s, r]);
  }
  visitTime(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Xt(t.nullBitmap), s = ne(n.ArrayType, t.data), { ["length"]: o = s.length / Br(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new me(n, i, o, a, [void 0, s, r]);
  }
  visitDecimal(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Xt(t.nullBitmap), s = ne(n.ArrayType, t.data), { ["length"]: o = s.length / Br(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new me(n, i, o, a, [void 0, s, r]);
  }
  visitList(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["child"]: r } = t, s = Xt(t.nullBitmap), o = hl(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new me(n, i, a, c, [o, void 0, s], [r]);
  }
  visitStruct(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["children"]: r = [] } = t, s = Xt(t.nullBitmap), { length: o = r.reduce((c, { length: l }) => Math.max(c, l), 0), nullCount: a = t.nullBitmap ? -1 : 0 } = t;
    return new me(n, i, o, a, [void 0, void 0, s], r);
  }
  visitUnion(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["children"]: r = [] } = t, s = Xt(t.nullBitmap), o = ne(n.ArrayType, t.typeIds), { ["length"]: a = o.length, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    if (Nt.isSparseUnion(n))
      return new me(n, i, a, c, [void 0, void 0, s, o], r);
    const l = hl(t.valueOffsets);
    return new me(n, i, a, c, [l, void 0, s, o], r);
  }
  visitDictionary(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Xt(t.nullBitmap), s = ne(n.indices.ArrayType, t.data), { ["dictionary"]: o = new $e([new ph().visit({ type: n.dictionary })]) } = t, { ["length"]: a = s.length, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new me(n, i, a, c, [void 0, s, r], [], o);
  }
  visitInterval(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Xt(t.nullBitmap), s = ne(n.ArrayType, t.data), { ["length"]: o = s.length / Br(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new me(n, i, o, a, [void 0, s, r]);
  }
  visitFixedSizeList(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["child"]: r = new ph().visit({ type: n.valueType }) } = t, s = Xt(t.nullBitmap), { ["length"]: o = r.length / Br(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new me(n, i, o, a, [void 0, void 0, s], [r]);
  }
  visitMap(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["child"]: r = new ph().visit({ type: n.childType }) } = t, s = Xt(t.nullBitmap), o = hl(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new me(n, i, a, c, [o, void 0, s], [r]);
  }
};
function Lt(e) {
  return new ZD().visit(e);
}
let kw = 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 RI(e) {
  return e.reduce((t, n) => t + n.nullCount, 0);
}
function CI(e) {
  return e.reduce((t, n, i) => (t[i + 1] = t[i] + n.length, t), new Uint32Array(e.length + 1));
}
function kI(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 O1(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 L1(e, t) {
  return e.getValid(t);
}
function Ga(e) {
  function t(n, i, r) {
    return e(n[i], r);
  }
  return function(n) {
    const i = this.data;
    return O1(i, this._offsets, n, t);
  };
}
function UI(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 = O1(s, this._offsets, i, n);
    return t = void 0, o;
  };
}
function zI(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) : O1(s, this._offsets, r, n);
    return t = void 0, o;
  };
}
let ft = class extends kt {
};
function JD(e, t) {
  return t === null && e.length > 0 ? 0 : -1;
}
function QD(e, t) {
  const { nullBitmap: n } = e;
  if (!n || e.nullCount <= 0)
    return -1;
  let i = 0;
  for (const r of new E1(n, e.offset + (t || 0), e.length, n, LI)) {
    if (!r)
      return i;
    ++i;
  }
  return -1;
}
function Tt(e, t, n) {
  if (t === void 0)
    return -1;
  if (t === null)
    return QD(e, n);
  const i = gn.getVisitFn(e), r = qc(t);
  for (let s = (n || 0) - 1, o = e.length; ++s < o; )
    if (r(i(e, s)))
      return s;
  return -1;
}
function PI(e, t, n) {
  const i = gn.getVisitFn(e), r = qc(t);
  for (let s = (n || 0) - 1, o = e.length; ++s < o; )
    if (r(i(e, s)))
      return s;
  return -1;
}
ft.prototype.visitNull = JD;
ft.prototype.visitBool = Tt;
ft.prototype.visitInt = Tt;
ft.prototype.visitInt8 = Tt;
ft.prototype.visitInt16 = Tt;
ft.prototype.visitInt32 = Tt;
ft.prototype.visitInt64 = Tt;
ft.prototype.visitUint8 = Tt;
ft.prototype.visitUint16 = Tt;
ft.prototype.visitUint32 = Tt;
ft.prototype.visitUint64 = Tt;
ft.prototype.visitFloat = Tt;
ft.prototype.visitFloat16 = Tt;
ft.prototype.visitFloat32 = Tt;
ft.prototype.visitFloat64 = Tt;
ft.prototype.visitUtf8 = Tt;
ft.prototype.visitBinary = Tt;
ft.prototype.visitFixedSizeBinary = Tt;
ft.prototype.visitDate = Tt;
ft.prototype.visitDateDay = Tt;
ft.prototype.visitDateMillisecond = Tt;
ft.prototype.visitTimestamp = Tt;
ft.prototype.visitTimestampSecond = Tt;
ft.prototype.visitTimestampMillisecond = Tt;
ft.prototype.visitTimestampMicrosecond = Tt;
ft.prototype.visitTimestampNanosecond = Tt;
ft.prototype.visitTime = Tt;
ft.prototype.visitTimeSecond = Tt;
ft.prototype.visitTimeMillisecond = Tt;
ft.prototype.visitTimeMicrosecond = Tt;
ft.prototype.visitTimeNanosecond = Tt;
ft.prototype.visitDecimal = Tt;
ft.prototype.visitList = Tt;
ft.prototype.visitStruct = Tt;
ft.prototype.visitUnion = Tt;
ft.prototype.visitDenseUnion = PI;
ft.prototype.visitSparseUnion = PI;
ft.prototype.visitDictionary = Tt;
ft.prototype.visitInterval = Tt;
ft.prototype.visitIntervalDayTime = Tt;
ft.prototype.visitIntervalYearMonth = Tt;
ft.prototype.visitFixedSizeList = Tt;
ft.prototype.visitMap = Tt;
const Qh = new ft();
let ht = class extends kt {
};
function wt(e) {
  const { type: t } = e;
  if (e.nullCount === 0 && e.stride === 1 && (t.typeId === R.Timestamp || t instanceof Ls && t.bitWidth !== 64 || t instanceof fu && t.bitWidth !== 64 || t instanceof uu && t.precision !== yn.HALF))
    return new kw(e.data.length, (i) => {
      const r = e.data[i];
      return r.values.subarray(0, r.length)[Symbol.iterator]();
    });
  let n = 0;
  return new kw(e.data.length, (i) => {
    const s = e.data[i].length, o = e.slice(n, n + s);
    return n += s, new tE(o);
  });
}
let tE = 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;
  }
};
ht.prototype.visitNull = wt;
ht.prototype.visitBool = wt;
ht.prototype.visitInt = wt;
ht.prototype.visitInt8 = wt;
ht.prototype.visitInt16 = wt;
ht.prototype.visitInt32 = wt;
ht.prototype.visitInt64 = wt;
ht.prototype.visitUint8 = wt;
ht.prototype.visitUint16 = wt;
ht.prototype.visitUint32 = wt;
ht.prototype.visitUint64 = wt;
ht.prototype.visitFloat = wt;
ht.prototype.visitFloat16 = wt;
ht.prototype.visitFloat32 = wt;
ht.prototype.visitFloat64 = wt;
ht.prototype.visitUtf8 = wt;
ht.prototype.visitBinary = wt;
ht.prototype.visitFixedSizeBinary = wt;
ht.prototype.visitDate = wt;
ht.prototype.visitDateDay = wt;
ht.prototype.visitDateMillisecond = wt;
ht.prototype.visitTimestamp = wt;
ht.prototype.visitTimestampSecond = wt;
ht.prototype.visitTimestampMillisecond = wt;
ht.prototype.visitTimestampMicrosecond = wt;
ht.prototype.visitTimestampNanosecond = wt;
ht.prototype.visitTime = wt;
ht.prototype.visitTimeSecond = wt;
ht.prototype.visitTimeMillisecond = wt;
ht.prototype.visitTimeMicrosecond = wt;
ht.prototype.visitTimeNanosecond = wt;
ht.prototype.visitDecimal = wt;
ht.prototype.visitList = wt;
ht.prototype.visitStruct = wt;
ht.prototype.visitUnion = wt;
ht.prototype.visitDenseUnion = wt;
ht.prototype.visitSparseUnion = wt;
ht.prototype.visitDictionary = wt;
ht.prototype.visitInterval = wt;
ht.prototype.visitIntervalDayTime = wt;
ht.prototype.visitIntervalYearMonth = wt;
ht.prototype.visitFixedSizeList = wt;
ht.prototype.visitMap = wt;
const R1 = new ht(), eE = (e, t) => e + t;
let Zs = class extends kt {
  visitNull(t, n) {
    return 0;
  }
  visitInt(t, n) {
    return t.type.bitWidth / 8;
  }
  visitFloat(t, n) {
    return t.type.ArrayType.BYTES_PER_ELEMENT;
  }
  visitBool(t, n) {
    return 1 / 8;
  }
  visitDecimal(t, n) {
    return t.type.bitWidth / 8;
  }
  visitDate(t, n) {
    return (t.type.unit + 1) * 4;
  }
  visitTime(t, n) {
    return t.type.bitWidth / 8;
  }
  visitTimestamp(t, n) {
    return t.type.unit === jt.SECOND ? 4 : 8;
  }
  visitInterval(t, n) {
    return (t.type.unit + 1) * 4;
  }
  visitStruct(t, n) {
    return t.children.reduce((i, r) => i + rr.visit(r, n), 0);
  }
  visitFixedSizeBinary(t, n) {
    return t.type.byteWidth;
  }
  visitMap(t, n) {
    return 8 + t.children.reduce((i, r) => i + rr.visit(r, n), 0);
  }
  visitDictionary(t, n) {
    var i;
    return t.type.indices.bitWidth / 8 + (((i = t.dictionary) === null || i === void 0 ? void 0 : i.getByteLength(t.values[n])) || 0);
  }
};
const nE = ({ valueOffsets: e }, t) => 8 + (e[t + 1] - e[t]), iE = ({ valueOffsets: e }, t) => 8 + (e[t + 1] - e[t]), rE = ({ valueOffsets: e, stride: t, children: n }, i) => {
  const r = n[0], { [i * t]: s } = e, { [i * t + 1]: o } = e, a = rr.getVisitFn(r.type), c = r.slice(s, o - s);
  let l = 8;
  for (let u = -1, f = o - s; ++u < f; )
    l += a(c, u);
  return l;
}, sE = ({ stride: e, children: t }, n) => {
  const i = t[0], r = i.slice(n * e, e), s = rr.getVisitFn(i.type);
  let o = 0;
  for (let a = -1, c = r.length; ++a < c; )
    o += s(r, a);
  return o;
}, oE = (e, t) => e.type.mode === gi.Dense ? VI(e, t) : jI(e, t), VI = ({ type: e, children: t, typeIds: n, valueOffsets: i }, r) => {
  const s = e.typeIdToChildIndex[n[r]];
  return 8 + rr.visit(t[s], i[r]);
}, jI = ({ children: e }, t) => 4 + rr.visitMany(e, e.map(() => t)).reduce(eE, 0);
Zs.prototype.visitUtf8 = nE;
Zs.prototype.visitBinary = iE;
Zs.prototype.visitList = rE;
Zs.prototype.visitFixedSizeList = sE;
Zs.prototype.visitUnion = oE;
Zs.prototype.visitDenseUnion = VI;
Zs.prototype.visitSparseUnion = jI;
const rr = new Zs();
var YI;
const qI = {}, WI = {};
let $e = class mo {
  constructor(t) {
    var n, i, r;
    const s = t[0] instanceof mo ? t.flatMap((a) => a.data) : t;
    if (s.length === 0 || s.some((a) => !(a instanceof me)))
      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, byteLength: u } = qI[o.typeId], f = s[0];
        this.isValid = (h) => L1(f, h), this.get = (h) => a(f, h), this.set = (h, d) => c(f, h, d), this.indexOf = (h) => l(f, h), this.getByteLength = (h) => u(f, h), this._offsets = [0, f.length];
        break;
      }
      default:
        Object.setPrototypeOf(this, WI[o.typeId]), this._offsets = CI(s);
        break;
    }
    this.data = s, this.type = o, this.stride = Br(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[this._offsets.length - 1];
  }
  /**
   * The aggregate size (in bytes) of this Vector's buffers and/or child Vectors.
   */
  get byteLength() {
    return this._byteLength === -1 && (this._byteLength = this.data.reduce((t, n) => t + n.byteLength, 0)), this._byteLength;
  }
  /**
   * The number of null elements in this Vector.
   */
  get nullCount() {
    return this._nullCount === -1 && (this._nullCount = RI(this.data)), this._nullCount;
  }
  /**
   * The Array or TypedAray 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 `${R[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) > 0;
  }
  /**
   * Get the size in bytes of an element by index.
   * @param index The index at which to get the byteLength.
   */
  // @ts-ignore
  getByteLength(t) {
    return 0;
  }
  /**
   * Iterator for the Vector's elements.
   */
  [Symbol.iterator]() {
    return R1.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 mo(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 mo(OI(this, t, n, ({ data: i, _offsets: r }, s, o) => kI(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 R.Int:
      case R.Float:
      case R.Decimal:
      case R.Time:
      case R.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 mo(this.data.map(({ children: n }) => n[t])) : null;
  }
  get isMemoized() {
    return Nt.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
   * Uft8. The memoization creates a cache of the size of the Vector and
   * therfore increases memory usage.
   *
   * @returns A new vector that memoizes calls to {@link get}.
   */
  memoize() {
    if (Nt.isDictionary(this.type)) {
      const t = new Uw(this.data[0].dictionary), n = this.data.map((i) => {
        const r = i.clone();
        return r.dictionary = t, r;
      });
      return new mo(n);
    }
    return new Uw(this);
  }
  /**
   * Returns a vector without memoization of the {@link get} method. If this
   * vector is not memoized, this method returns this vector.
   *
   * @returns A a vector without memoization.
   */
  unmemoize() {
    if (Nt.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 mo(n);
    }
    return this;
  }
};
YI = Symbol.toStringTag;
$e[YI] = ((e) => {
  e.type = Nt.prototype, e.data = [], e.length = 0, e.stride = 1, e.numChildren = 0, e._nullCount = -1, e._byteLength = -1, e._offsets = new Uint32Array([0]), e[Symbol.isConcatSpreadable] = !0;
  const t = Object.keys(R).map((n) => R[n]).filter((n) => typeof n == "number" && n !== R.NONE);
  for (const n of t) {
    const i = gn.getVisitFnByTypeId(n), r = ti.getVisitFnByTypeId(n), s = Qh.getVisitFnByTypeId(n), o = rr.getVisitFnByTypeId(n);
    qI[n] = { get: i, set: r, indexOf: s, byteLength: o }, WI[n] = Object.create(e, {
      isValid: { value: Ga(L1) },
      get: { value: Ga(gn.getVisitFnByTypeId(n)) },
      set: { value: UI(ti.getVisitFnByTypeId(n)) },
      indexOf: { value: zI(Qh.getVisitFnByTypeId(n)) },
      getByteLength: { value: Ga(rr.getVisitFnByTypeId(n)) }
    });
  }
  return "Vector";
})($e.prototype);
let Uw = class GI extends $e {
  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 GI(r.call(this, o, a))
    }), Object.defineProperty(this, "isMemoized", { value: !0 }), Object.defineProperty(this, "unmemoize", {
      value: () => new $e(this.data)
    }), Object.defineProperty(this, "memoize", {
      value: () => this
    });
  }
}, Pm = 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();
  }
};
const M0 = 2, ji = 4, Lr = 4, se = 4, ms = new Int32Array(2), zw = new Float32Array(ms.buffer), Pw = new Float64Array(ms.buffer), Df = new Uint16Array(new Uint8Array([1, 0]).buffer)[0] === 1;
var Vm;
(function(e) {
  e[e.UTF8_BYTES = 1] = "UTF8_BYTES", e[e.UTF16_STRING = 2] = "UTF16_STRING";
})(Vm || (Vm = {}));
let fc = class XI {
  /**
   * 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 XI(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 ms[0] = this.readInt32(t), zw[0];
  }
  readFloat64(t) {
    return ms[Df ? 0 : 1] = this.readInt32(t), ms[Df ? 1 : 0] = this.readInt32(t + 4), Pw[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) {
    zw[0] = n, this.writeInt32(t, ms[0]);
  }
  writeFloat64(t, n) {
    Pw[0] = n, this.writeInt32(t, ms[Df ? 0 : 1]), this.writeInt32(t + 4, ms[Df ? 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 + Lr)
      throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");
    let t = "";
    for (let n = 0; n < Lr; 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 === Vm.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 != Lr)
      throw new Error("FlatBuffers: file identifier must be length " + Lr);
    for (let n = 0; n < Lr; 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;
  }
}, HI = class KI {
  /**
   * 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 = fc.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 = KI.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 Error("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 Error("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 = fc.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) * M0;
    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 = M0; l < s; l += M0)
            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 ? se : 0;
    if (n) {
      const s = n;
      if (this.prep(this.minalign, ji + Lr + r), s.length != Lr)
        throw new Error("FlatBuffers: file identifier must be length " + Lr);
      for (let o = Lr - 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 Error("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 Error("FlatBuffers: Argument for createObjectOffsetList cannot contain null.");
    }
    return n;
  }
  createStructOffsetList(t, n) {
    return n(this, t.length), this.createObjectOffsetList(t.slice().reverse()), this.endVector();
  }
}, Gn = class go {
  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 go()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsKeyValue(t, n) {
    return t.setPosition(t.position() + se), (n || new go()).__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 go.startKeyValue(t), go.addKey(t, n), go.addValue(t, i), go.endKeyValue(t);
  }
};
var hc;
(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";
})(hc || (hc = {}));
var dc;
(function(e) {
  e[e.Little = 0] = "Little", e[e.Big = 1] = "Big";
})(dc || (dc = {}));
var td;
(function(e) {
  e[e.DenseArray = 0] = "DenseArray";
})(td || (td = {}));
let Ca = class bo {
  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 bo()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsInt(t, n) {
    return t.setPosition(t.position() + se), (n || new bo()).__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 bo.startInt(t), bo.addBitWidth(t, n), bo.addIsSigned(t, i), bo.endInt(t);
  }
}, xa = class jm {
  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 jm()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDictionaryEncoding(t, n) {
    return t.setPosition(t.position() + se), (n || new jm()).__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 Ca()).__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) : td.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, td.DenseArray);
  }
  static endDictionaryEncoding(t) {
    return t.endObject();
  }
}, Vw = class Tl {
  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 Tl()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsBinary(t, n) {
    return t.setPosition(t.position() + se), (n || new Tl()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startBinary(t) {
    t.startObject(0);
  }
  static endBinary(t) {
    return t.endObject();
  }
  static createBinary(t) {
    return Tl.startBinary(t), Tl.endBinary(t);
  }
}, jw = class Bl {
  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 Bl()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsBool(t, n) {
    return t.setPosition(t.position() + se), (n || new Bl()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startBool(t) {
    t.startObject(0);
  }
  static endBool(t) {
    return t.endObject();
  }
  static createBool(t) {
    return Bl.startBool(t), Bl.endBool(t);
  }
};
var ed;
(function(e) {
  e[e.DAY = 0] = "DAY", e[e.MILLISECOND = 1] = "MILLISECOND";
})(ed || (ed = {}));
let yh = class Sa {
  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 Sa()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDate(t, n) {
    return t.setPosition(t.position() + se), (n || new Sa()).__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) : ed.MILLISECOND;
  }
  static startDate(t) {
    t.startObject(1);
  }
  static addUnit(t, n) {
    t.addFieldInt16(0, n, ed.MILLISECOND);
  }
  static endDate(t) {
    return t.endObject();
  }
  static createDate(t, n) {
    return Sa.startDate(t), Sa.addUnit(t, n), Sa.endDate(t);
  }
}, Ia = class ys {
  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 ys()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDecimal(t, n) {
    return t.setPosition(t.position() + se), (n || new ys()).__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 ys.startDecimal(t), ys.addPrecision(t, n), ys.addScale(t, i), ys.addBitWidth(t, r), ys.endDecimal(t);
  }
};
var pc;
(function(e) {
  e[e.SECOND = 0] = "SECOND", e[e.MILLISECOND = 1] = "MILLISECOND", e[e.MICROSECOND = 2] = "MICROSECOND", e[e.NANOSECOND = 3] = "NANOSECOND";
})(pc || (pc = {}));
let mh = class Aa {
  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 Aa()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFixedSizeBinary(t, n) {
    return t.setPosition(t.position() + se), (n || new Aa()).__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 Aa.startFixedSizeBinary(t), Aa.addByteWidth(t, n), Aa.endFixedSizeBinary(t);
  }
}, gh = class Ma {
  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 Ma()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFixedSizeList(t, n) {
    return t.setPosition(t.position() + se), (n || new Ma()).__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 Ma.startFixedSizeList(t), Ma.addListSize(t, n), Ma.endFixedSizeList(t);
  }
};
var nd;
(function(e) {
  e[e.HALF = 0] = "HALF", e[e.SINGLE = 1] = "SINGLE", e[e.DOUBLE = 2] = "DOUBLE";
})(nd || (nd = {}));
let bh = class $a {
  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 $a()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFloatingPoint(t, n) {
    return t.setPosition(t.position() + se), (n || new $a()).__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) : nd.HALF;
  }
  static startFloatingPoint(t) {
    t.startObject(1);
  }
  static addPrecision(t, n) {
    t.addFieldInt16(0, n, nd.HALF);
  }
  static endFloatingPoint(t) {
    return t.endObject();
  }
  static createFloatingPoint(t, n) {
    return $a.startFloatingPoint(t), $a.addPrecision(t, n), $a.endFloatingPoint(t);
  }
};
var id;
(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";
})(id || (id = {}));
let _h = class Ta {
  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 Ta()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsInterval(t, n) {
    return t.setPosition(t.position() + se), (n || new Ta()).__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) : id.YEAR_MONTH;
  }
  static startInterval(t) {
    t.startObject(1);
  }
  static addUnit(t, n) {
    t.addFieldInt16(0, n, id.YEAR_MONTH);
  }
  static endInterval(t) {
    return t.endObject();
  }
  static createInterval(t, n) {
    return Ta.startInterval(t), Ta.addUnit(t, n), Ta.endInterval(t);
  }
}, Yw = class Nl {
  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 Nl()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsList(t, n) {
    return t.setPosition(t.position() + se), (n || new Nl()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startList(t) {
    t.startObject(0);
  }
  static endList(t) {
    return t.endObject();
  }
  static createList(t) {
    return Nl.startList(t), Nl.endList(t);
  }
}, wh = class Ba {
  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 Ba()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsMap(t, n) {
    return t.setPosition(t.position() + se), (n || new Ba()).__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 Ba.startMap(t), Ba.addKeysSorted(t, n), Ba.endMap(t);
  }
}, qw = class Fl {
  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 Fl()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsNull(t, n) {
    return t.setPosition(t.position() + se), (n || new Fl()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startNull(t) {
    t.startObject(0);
  }
  static endNull(t) {
    return t.endObject();
  }
  static createNull(t) {
    return Fl.startNull(t), Fl.endNull(t);
  }
}, Ww = class Dl {
  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 Dl()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsStruct_(t, n) {
    return t.setPosition(t.position() + se), (n || new Dl()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startStruct_(t) {
    t.startObject(0);
  }
  static endStruct_(t) {
    return t.endObject();
  }
  static createStruct_(t) {
    return Dl.startStruct_(t), Dl.endStruct_(t);
  }
}, El = 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() + se), (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) : pc.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, pc.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);
  }
}, Ol = class wo {
  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 wo()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsTimestamp(t, n) {
    return t.setPosition(t.position() + se), (n || new wo()).__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) : pc.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, pc.SECOND);
  }
  static addTimezone(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static endTimestamp(t) {
    return t.endObject();
  }
  static createTimestamp(t, n, i) {
    return wo.startTimestamp(t), wo.addUnit(t, n), wo.addTimezone(t, i), wo.endTimestamp(t);
  }
};
var rd;
(function(e) {
  e[e.Sparse = 0] = "Sparse", e[e.Dense = 1] = "Dense";
})(rd || (rd = {}));
let vo = class xo {
  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 xo()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsUnion(t, n) {
    return t.setPosition(t.position() + se), (n || new xo()).__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) : rd.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, rd.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 xo.startUnion(t), xo.addMode(t, n), xo.addTypeIds(t, i), xo.endUnion(t);
  }
}, Gw = class Ll {
  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 Ll()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsUtf8(t, n) {
    return t.setPosition(t.position() + se), (n || new Ll()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startUtf8(t) {
    t.startObject(0);
  }
  static endUtf8(t) {
    return t.endObject();
  }
  static createUtf8(t) {
    return Ll.startUtf8(t), Ll.endUtf8(t);
  }
};
var ge;
(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";
})(ge || (ge = {}));
let Cn = class vh {
  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 vh()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsField(t, n) {
    return t.setPosition(t.position() + se), (n || new vh()).__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) : ge.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 xa()).__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 vh()).__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 Gn()).__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, ge.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();
  }
}, ki = class xr {
  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 xr()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsSchema(t, n) {
    return t.setPosition(t.position() + se), (n || new xr()).__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) : dc.Little;
  }
  fields(t, n) {
    const i = this.bb.__offset(this.bb_pos, 6);
    return i ? (n || new Cn()).__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 Gn()).__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, dc.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 xr.startSchema(t), xr.addEndianness(t, n), xr.addFields(t, i), xr.addCustomMetadata(t, r), xr.addFeatures(t, s), xr.endSchema(t);
  }
}, Li = class Ym {
  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 Ym()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFooter(t, n) {
    return t.setPosition(t.position() + se), (n || new Ym()).__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) : hc.V1;
  }
  schema(t) {
    const n = this.bb.__offset(this.bb_pos, 6);
    return n ? (t || new ki()).__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 Pm()).__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 Pm()).__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 Gn()).__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, hc.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 So {
  constructor(t = [], n, i) {
    this.fields = t || [], this.metadata = n || /* @__PURE__ */ new Map(), i || (i = Wm(t)), this.dictionaries = i;
  }
  get [Symbol.toStringTag]() {
    return "Schema";
  }
  get names() {
    return this.fields.map((t) => t.name);
  }
  toString() {
    return `Schema<{ ${this.fields.map((t, n) => `${n}: ${t}`).join(", ")} }>`;
  }
  /**
   * Construct a new Schema containing only specified fields.
   *
   * @param fieldNames Names of fields to keep.
   * @returns A new Schema of fields matching the specified names.
   */
  select(t) {
    const n = new Set(t), i = this.fields.filter((r) => n.has(r.name));
    return new So(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 So(n, this.metadata);
  }
  assign(...t) {
    const n = t[0] instanceof So ? t[0] : Array.isArray(t[0]) ? new So(t[0]) : new So(t), i = [...this.fields], r = Ef(Ef(/* @__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: Ef(Ef(/* @__PURE__ */ new Map(), i[c].metadata), a.metadata)
      })) && !1 : !0;
    }), o = Wm(s, /* @__PURE__ */ new Map());
    return new So([...i, ...s], r, new Map([...this.dictionaries, ...o]));
  }
};
_e.prototype.fields = null;
_e.prototype.metadata = null;
_e.prototype.dictionaries = null;
let Me = class qm {
  /** @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 qm(`${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], qm.new(n, i, r, s);
  }
};
Me.prototype.type = null;
Me.prototype.name = null;
Me.prototype.nullable = null;
Me.prototype.metadata = null;
function Ef(e, t) {
  return new Map([...e || /* @__PURE__ */ new Map(), ...t || /* @__PURE__ */ new Map()]);
}
function Wm(e, t = /* @__PURE__ */ new Map()) {
  for (let n = -1, i = e.length; ++n < i; ) {
    const s = e[n].type;
    if (Nt.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 && Wm(s.children, t);
  }
  return t;
}
var aE = HI, cE = fc;
let C1 = class {
  /** @nocollapse */
  static decode(t) {
    t = new cE(Xt(t));
    const n = Li.getRootAsFooter(t), i = _e.decode(n.schema());
    return new lE(i, n);
  }
  /** @nocollapse */
  static encode(t) {
    const n = new aE(), i = _e.encode(n, t.schema);
    Li.startRecordBatchesVector(n, t.numRecordBatches);
    for (const o of [...t.recordBatches()].slice().reverse())
      sd.encode(n, o);
    const r = n.endVector();
    Li.startDictionariesVector(n, t.numDictionaries);
    for (const o of [...t.dictionaryBatches()].slice().reverse())
      sd.encode(n, o);
    const s = n.endVector();
    return Li.startFooter(n), Li.addSchema(n, i), Li.addVersion(n, Yn.V4), Li.addRecordBatches(n, r), Li.addDictionaries(n, s), Li.finishFooterBuffer(n, Li.endFooter(n)), n.asUint8Array();
  }
  get numRecordBatches() {
    return this._recordBatches.length;
  }
  get numDictionaries() {
    return this._dictionaryBatches.length;
  }
  constructor(t, n = Yn.V4, 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;
  }
}, lE = class extends C1 {
  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 sd.decode(n);
    }
    return null;
  }
  getDictionaryBatch(t) {
    if (t >= 0 && t < this.numDictionaries) {
      const n = this._footer.dictionaries(t);
      if (n)
        return sd.decode(n);
    }
    return null;
  }
}, sd = class ZI {
  /** @nocollapse */
  static decode(t) {
    return new ZI(t.metaDataLength(), t.bodyLength(), t.offset());
  }
  /** @nocollapse */
  static encode(t, n) {
    const { metaDataLength: i } = n, r = BigInt(n.offset), s = BigInt(n.bodyLength);
    return Pm.createBlock(t, r, i, s);
  }
  constructor(t, n, i) {
    this.metaDataLength = t, this.offset = bi(i), this.bodyLength = bi(n);
  }
};
const we = Object.freeze({ done: !0, value: void 0 });
let Xw = class {
  constructor(t) {
    this._json = t;
  }
  get schema() {
    return this._json.schema;
  }
  get batches() {
    return this._json.batches || [];
  }
  get dictionaries() {
    return this._json.dictionaries || [];
  }
}, JI = 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());
  }
}, uE = class extends JI {
  constructor() {
    super(), this._values = [], this.resolvers = [], this._closedPromise = new Promise((t) => this._closedPromiseResolve = t);
  }
  get closed() {
    return this._closedPromise;
  }
  cancel(t) {
    return Y(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(we);
      this._closedPromiseResolve(), this._closedPromiseResolve = void 0;
    }
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  toDOMStream(t) {
    return Un.toDOMStream(this._closedPromiseResolve || this._error ? this : this._values, t);
  }
  toNodeStream(t) {
    return Un.toNodeStream(this._closedPromiseResolve || this._error ? this : this._values, t);
  }
  throw(t) {
    return Y(this, void 0, void 0, function* () {
      return yield this.abort(t), we;
    });
  }
  return(t) {
    return Y(this, void 0, void 0, function* () {
      return yield this.close(), we;
    });
  }
  read(t) {
    return Y(this, void 0, void 0, function* () {
      return (yield this.next(t, "read")).value;
    });
  }
  peek(t) {
    return Y(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(we);
  }
  _ensureOpen() {
    if (this._closedPromiseResolve)
      return !0;
    throw new Error("AsyncQueue is closed");
  }
}, fE = class extends uE {
  write(t) {
    if ((t = Xt(t)).byteLength > 0)
      return super.write(t);
  }
  toString(t = !1) {
    return t ? Om(this.toUint8Array(!0)) : this.toUint8Array(!1).then(Om);
  }
  toUint8Array(t = !1) {
    return t ? ir(this._values)[0] : (() => Y(this, void 0, void 0, function* () {
      var n, i, r, s;
      const o = [];
      let a = 0;
      try {
        for (var c = !0, l = Qn(this), u; u = yield l.next(), n = u.done, !n; ) {
          s = u.value, c = !1;
          try {
            const f = s;
            o.push(f), a += f.byteLength;
          } finally {
            c = !0;
          }
        }
      } catch (f) {
        i = { error: f };
      } finally {
        try {
          !c && !n && (r = l.return) && (yield r.call(l));
        } finally {
          if (i)
            throw i.error;
        }
      }
      return ir(o, a)[0];
    }))();
  }
}, od = class {
  constructor(t) {
    t && (this.source = new hE(Un.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);
  }
}, ad = class QI {
  constructor(t) {
    t instanceof QI ? this.source = t.source : t instanceof fE ? this.source = new fo(Un.fromAsyncIterable(t)) : BS(t) ? this.source = new fo(Un.fromNodeStream(t)) : M1(t) ? this.source = new fo(Un.fromDOMStream(t)) : $S(t) ? this.source = new fo(Un.fromDOMStream(t.body)) : ry(t) ? this.source = new fo(Un.fromIterable(t)) : ou(t) ? this.source = new fo(Un.fromAsyncIterable(t)) : A1(t) && (this.source = new fo(Un.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);
  }
}, hE = 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) || we);
  }
  return(t) {
    return Object.create(this.source.return && this.source.return(t) || we);
  }
}, fo = class {
  constructor(t) {
    this.source = t, this._closedPromise = new Promise((n) => this._closedPromiseResolve = n);
  }
  cancel(t) {
    return Y(this, void 0, void 0, function* () {
      yield this.return(t);
    });
  }
  get closed() {
    return this._closedPromise;
  }
  read(t) {
    return Y(this, void 0, void 0, function* () {
      return (yield this.next(t, "read")).value;
    });
  }
  peek(t) {
    return Y(this, void 0, void 0, function* () {
      return (yield this.next(t, "peek")).value;
    });
  }
  next(t, n = "read") {
    return Y(this, void 0, void 0, function* () {
      return yield this.source.next({ cmd: n, size: t });
    });
  }
  throw(t) {
    return Y(this, void 0, void 0, function* () {
      const n = this.source.throw && (yield this.source.throw(t)) || we;
      return this._closedPromiseResolve && this._closedPromiseResolve(), this._closedPromiseResolve = void 0, Object.create(n);
    });
  }
  return(t) {
    return Y(this, void 0, void 0, function* () {
      const n = this.source.return && (yield this.source.return(t)) || we;
      return this._closedPromiseResolve && this._closedPromiseResolve(), this._closedPromiseResolve = void 0, Object.create(n);
    });
  }
}, Hw = class extends od {
  constructor(t, n) {
    super(), this.position = 0, this.buffer = Xt(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 };
  }
}, cd = class extends ad {
  constructor(t, n) {
    super(), this.position = 0, this._handle = t, typeof n == "number" ? this.size = n : this._pending = (() => Y(this, void 0, void 0, function* () {
      this.size = (yield t.stat()).size, delete this._pending;
    }))();
  }
  readInt32(t) {
    return Y(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 Y(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 Y(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 Y(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 Y(this, void 0, void 0, function* () {
      const t = this._handle;
      this._handle = null, t && (yield t.close());
    });
  }
  throw(t) {
    return Y(this, void 0, void 0, function* () {
      return yield this.close(), { done: !0, value: t };
    });
  }
  return(t) {
    return Y(this, void 0, void 0, function* () {
      return yield this.close(), { done: !0, value: t };
    });
  }
};
const dE = 65536;
function ka(e) {
  return e < 0 && (e = 4294967295 + e + 1), `0x${e.toString(16)}`;
}
const yc = 8, k1 = [
  1,
  10,
  100,
  1e3,
  1e4,
  1e5,
  1e6,
  1e7,
  1e8
];
let t3 = 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 ? dE : 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 `${ka(this.buffer[1])} ${ka(this.buffer[0])}`;
  }
}, Ne = class Sr extends t3 {
  times(t) {
    return this._times(t), this;
  }
  plus(t) {
    return this._plus(t), this;
  }
  /** @nocollapse */
  static from(t, n = new Uint32Array(2)) {
    return Sr.fromString(typeof t == "string" ? t : t.toString(), n);
  }
  /** @nocollapse */
  static fromNumber(t, n = new Uint32Array(2)) {
    return Sr.fromString(t.toString(), n);
  }
  /** @nocollapse */
  static fromString(t, n = new Uint32Array(2)) {
    const i = t.length, r = new Sr(n);
    for (let s = 0; s < i; ) {
      const o = yc < i - s ? yc : i - s, a = new Sr(new Uint32Array([Number.parseInt(t.slice(s, s + o), 10), 0])), c = new Sr(new Uint32Array([k1[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; )
      Sr.from(t[i], new Uint32Array(n.buffer, n.byteOffset + 2 * i * 4, 2));
    return n;
  }
  /** @nocollapse */
  static multiply(t, n) {
    return new Sr(new Uint32Array(t.buffer)).times(n);
  }
  /** @nocollapse */
  static add(t, n) {
    return new Sr(new Uint32Array(t.buffer)).plus(n);
  }
}, Gl = class Ir extends t3 {
  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 Ir.fromString(typeof t == "string" ? t : t.toString(), n);
  }
  /** @nocollapse */
  static fromNumber(t, n = new Uint32Array(2)) {
    return Ir.fromString(t.toString(), n);
  }
  /** @nocollapse */
  static fromString(t, n = new Uint32Array(2)) {
    const i = t.startsWith("-"), r = t.length, s = new Ir(n);
    for (let o = i ? 1 : 0; o < r; ) {
      const a = yc < r - o ? yc : r - o, c = new Ir(new Uint32Array([Number.parseInt(t.slice(o, o + a), 10), 0])), l = new Ir(new Uint32Array([k1[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; )
      Ir.from(t[i], new Uint32Array(n.buffer, n.byteOffset + 2 * i * 4, 2));
    return n;
  }
  /** @nocollapse */
  static multiply(t, n) {
    return new Ir(new Uint32Array(t.buffer)).times(n);
  }
  /** @nocollapse */
  static add(t, n) {
    return new Ir(new Uint32Array(t.buffer)).plus(n);
  }
}, pE = class Ar {
  constructor(t) {
    this.buffer = t;
  }
  high() {
    return new Gl(new Uint32Array(this.buffer.buffer, this.buffer.byteOffset + 8, 2));
  }
  low() {
    return new Gl(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 Ne(new Uint32Array([this.buffer[3], 0])), i = new Ne(new Uint32Array([this.buffer[2], 0])), r = new Ne(new Uint32Array([this.buffer[1], 0])), s = new Ne(new Uint32Array([this.buffer[0], 0])), o = new Ne(new Uint32Array([t.buffer[3], 0])), a = new Ne(new Uint32Array([t.buffer[2], 0])), c = new Ne(new Uint32Array([t.buffer[1], 0])), l = new Ne(new Uint32Array([t.buffer[0], 0]));
    let u = Ne.multiply(s, l);
    this.buffer[0] = u.low();
    const f = new Ne(new Uint32Array([u.high(), 0]));
    return u = Ne.multiply(r, l), f.plus(u), u = Ne.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 Ne(new Uint32Array(this.buffer.buffer, this.buffer.byteOffset + 8, 2)).plus(Ne.multiply(i, l)).plus(Ne.multiply(r, c)).plus(Ne.multiply(s, a)), this.buffer[3] += Ne.multiply(n, l).plus(Ne.multiply(i, c)).plus(Ne.multiply(r, a)).plus(Ne.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 `${ka(this.buffer[3])} ${ka(this.buffer[2])} ${ka(this.buffer[1])} ${ka(this.buffer[0])}`;
  }
  /** @nocollapse */
  static multiply(t, n) {
    return new Ar(new Uint32Array(t.buffer)).times(n);
  }
  /** @nocollapse */
  static add(t, n) {
    return new Ar(new Uint32Array(t.buffer)).plus(n);
  }
  /** @nocollapse */
  static from(t, n = new Uint32Array(4)) {
    return Ar.fromString(typeof t == "string" ? t : t.toString(), n);
  }
  /** @nocollapse */
  static fromNumber(t, n = new Uint32Array(4)) {
    return Ar.fromString(t.toString(), n);
  }
  /** @nocollapse */
  static fromString(t, n = new Uint32Array(4)) {
    const i = t.startsWith("-"), r = t.length, s = new Ar(n);
    for (let o = i ? 1 : 0; o < r; ) {
      const a = yc < r - o ? yc : r - o, c = new Ar(new Uint32Array([Number.parseInt(t.slice(o, o + a), 10), 0, 0, 0])), l = new Ar(new Uint32Array([k1[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; )
      Ar.from(t[i], new Uint32Array(n.buffer, n.byteOffset + 4 * 4 * i, 4));
    return n;
  }
}, e3 = class extends kt {
  constructor(t, n, i, r) {
    super(), this.nodesIndex = -1, this.buffersIndex = -1, this.bytes = t, this.nodes = n, this.buffers = i, this.dictionaries = r;
  }
  visit(t) {
    return super.visit(t instanceof Me ? t.type : t);
  }
  visitNull(t, { length: n } = this.nextFieldNode()) {
    return Lt({ type: t, length: n });
  }
  visitBool(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Lt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitInt(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Lt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitFloat(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Lt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitUtf8(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Lt({ 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 Lt({ 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 Lt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitDate(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Lt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitTimestamp(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Lt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitTime(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Lt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitDecimal(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Lt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitList(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Lt({ 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 Lt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), children: this.visitMany(t.children) });
  }
  visitUnion(t) {
    return t.mode === gi.Sparse ? this.visitSparseUnion(t) : this.visitDenseUnion(t);
  }
  visitDenseUnion(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Lt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), typeIds: this.readTypeIds(t), valueOffsets: this.readOffsets(t), children: this.visitMany(t.children) });
  }
  visitSparseUnion(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Lt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), typeIds: this.readTypeIds(t), children: this.visitMany(t.children) });
  }
  visitDictionary(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Lt({ 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 Lt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, i), data: this.readData(t) });
  }
  visitFixedSizeList(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Lt({ 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 Lt({ 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);
  }
}, yE = class extends e3 {
  constructor(t, n, i, r) {
    super(new Uint8Array(0), n, i, r), this.sources = t;
  }
  readNullBitmap(t, n, { offset: i } = this.nextBufferRange()) {
    return n <= 0 ? new Uint8Array(0) : km(this.sources[i]);
  }
  readOffsets(t, { offset: n } = this.nextBufferRange()) {
    return ne(Uint8Array, ne(Int32Array, this.sources[n]));
  }
  readTypeIds(t, { offset: n } = this.nextBufferRange()) {
    return ne(Uint8Array, ne(t.ArrayType, this.sources[n]));
  }
  readData(t, { offset: n } = this.nextBufferRange()) {
    const { sources: i } = this;
    return Nt.isTimestamp(t) || (Nt.isInt(t) || Nt.isTime(t)) && t.bitWidth === 64 || Nt.isDate(t) && t.unit === Kr.MILLISECOND ? ne(Uint8Array, Gl.convertArray(i[n])) : Nt.isDecimal(t) ? ne(Uint8Array, pE.convertArray(i[n])) : Nt.isBinary(t) || Nt.isFixedSizeBinary(t) ? mE(i[n]) : Nt.isBool(t) ? km(i[n]) : Nt.isUtf8(t) ? I1(i[n].join("")) : ne(Uint8Array, ne(t.ArrayType, i[n].map((r) => +r)));
  }
};
function mE(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 dt = class extends kt {
  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 Sn(e, t) {
  return t instanceof e.constructor;
}
function Vu(e, t) {
  return e === t || Sn(e, t);
}
function ss(e, t) {
  return e === t || Sn(e, t) && e.bitWidth === t.bitWidth && e.isSigned === t.isSigned;
}
function oy(e, t) {
  return e === t || Sn(e, t) && e.precision === t.precision;
}
function gE(e, t) {
  return e === t || Sn(e, t) && e.byteWidth === t.byteWidth;
}
function U1(e, t) {
  return e === t || Sn(e, t) && e.unit === t.unit;
}
function ju(e, t) {
  return e === t || Sn(e, t) && e.unit === t.unit && e.timezone === t.timezone;
}
function Yu(e, t) {
  return e === t || Sn(e, t) && e.unit === t.unit && e.bitWidth === t.bitWidth;
}
function bE(e, t) {
  return e === t || Sn(e, t) && e.children.length === t.children.length && Rs.compareManyFields(e.children, t.children);
}
function _E(e, t) {
  return e === t || Sn(e, t) && e.children.length === t.children.length && Rs.compareManyFields(e.children, t.children);
}
function z1(e, t) {
  return e === t || Sn(e, t) && e.mode === t.mode && e.typeIds.every((n, i) => n === t.typeIds[i]) && Rs.compareManyFields(e.children, t.children);
}
function wE(e, t) {
  return e === t || Sn(e, t) && e.id === t.id && e.isOrdered === t.isOrdered && Rs.visit(e.indices, t.indices) && Rs.visit(e.dictionary, t.dictionary);
}
function P1(e, t) {
  return e === t || Sn(e, t) && e.unit === t.unit;
}
function vE(e, t) {
  return e === t || Sn(e, t) && e.listSize === t.listSize && e.children.length === t.children.length && Rs.compareManyFields(e.children, t.children);
}
function xE(e, t) {
  return e === t || Sn(e, t) && e.keysSorted === t.keysSorted && e.children.length === t.children.length && Rs.compareManyFields(e.children, t.children);
}
dt.prototype.visitNull = Vu;
dt.prototype.visitBool = Vu;
dt.prototype.visitInt = ss;
dt.prototype.visitInt8 = ss;
dt.prototype.visitInt16 = ss;
dt.prototype.visitInt32 = ss;
dt.prototype.visitInt64 = ss;
dt.prototype.visitUint8 = ss;
dt.prototype.visitUint16 = ss;
dt.prototype.visitUint32 = ss;
dt.prototype.visitUint64 = ss;
dt.prototype.visitFloat = oy;
dt.prototype.visitFloat16 = oy;
dt.prototype.visitFloat32 = oy;
dt.prototype.visitFloat64 = oy;
dt.prototype.visitUtf8 = Vu;
dt.prototype.visitBinary = Vu;
dt.prototype.visitFixedSizeBinary = gE;
dt.prototype.visitDate = U1;
dt.prototype.visitDateDay = U1;
dt.prototype.visitDateMillisecond = U1;
dt.prototype.visitTimestamp = ju;
dt.prototype.visitTimestampSecond = ju;
dt.prototype.visitTimestampMillisecond = ju;
dt.prototype.visitTimestampMicrosecond = ju;
dt.prototype.visitTimestampNanosecond = ju;
dt.prototype.visitTime = Yu;
dt.prototype.visitTimeSecond = Yu;
dt.prototype.visitTimeMillisecond = Yu;
dt.prototype.visitTimeMicrosecond = Yu;
dt.prototype.visitTimeNanosecond = Yu;
dt.prototype.visitDecimal = Vu;
dt.prototype.visitList = bE;
dt.prototype.visitStruct = _E;
dt.prototype.visitUnion = z1;
dt.prototype.visitDenseUnion = z1;
dt.prototype.visitSparseUnion = z1;
dt.prototype.visitDictionary = wE;
dt.prototype.visitInterval = P1;
dt.prototype.visitIntervalDayTime = P1;
dt.prototype.visitIntervalYearMonth = P1;
dt.prototype.visitFixedSizeList = vE;
dt.prototype.visitMap = xE;
const Rs = new dt();
function SE(e, t) {
  return Rs.compareSchemas(e, t);
}
function $0(e, t) {
  return IE(e, t.map((n) => n.data.concat()));
}
function IE(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 = AE(n, o, u, t, r), o > 0 && (i[s++] = Lt({
      type: new on(n),
      length: o,
      nullCount: 0,
      children: u.slice()
    })));
  }
  return [
    e = e.assign(n),
    i.map((f) => new ui(e, f))
  ];
}
function AE(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 : Lt({
        type: f.type,
        length: t,
        nullCount: t,
        nullBitmap: new Uint8Array(o)
      });
    }
  }
  return n;
}
var n3;
let hu = class Io {
  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[t.length - 1] instanceof Uint32Array && (s = t.pop());
    const o = (c) => {
      if (c) {
        if (c instanceof ui)
          return [c];
        if (c instanceof Io)
          return c.batches;
        if (c instanceof me) {
          if (c.type instanceof on)
            return [new ui(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 $e([c[d]])), f = new _e(l.map((d, p) => new Me(String(d), u[p].type))), [, h] = $0(f, u);
            return h.length === 0 ? [new ui(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 ui))
        throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");
      if (!SE(r, c.schema))
        throw new TypeError("Table and inner RecordBatch schemas must be equivalent.");
    }
    this.schema = r, this.batches = a, this._offsets = s ?? CI(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 = RI(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;
  }
  /**
   * Get the size in bytes of an element by index.
   * @param index The index at which to get the byteLength.
   */
  // @ts-ignore
  getByteLength(t) {
    return 0;
  }
  /**
   * Iterator for rows in this Table.
   */
  [Symbol.iterator]() {
    return this.batches.length > 0 ? R1.visit(new $e(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 Io(n, i.map((r) => new ui(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] = OI({ length: this.numRows }, t, n);
    const r = kI(this.data, this._offsets, t, n);
    return new Io(i, r.map((s) => new ui(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 = Lt({ type: i, length: 0, nullCount: 0 });
        n.push(r._changeLengthAndBackfillNullBitmap(this.numRows));
      }
      return new $e(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 $e([Lt({ type: new Os(), 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] = $0(i, a);
    }
    return new Io(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 Io(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 Io(...$0(s, o));
  }
};
n3 = Symbol.toStringTag;
hu[n3] = ((e) => (e.schema = null, e.batches = [], e._offsets = new Uint32Array([0]), e._nullCount = -1, e[Symbol.isConcatSpreadable] = !0, e.isValid = Ga(L1), e.get = Ga(gn.getVisitFn(R.Struct)), e.set = UI(ti.getVisitFn(R.Struct)), e.indexOf = zI(Qh.getVisitFn(R.Struct)), e.getByteLength = Ga(rr.getVisitFn(R.Struct)), "Table"))(hu.prototype);
var i3;
let ui = class Rl {
  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 = Lt({
            nullCount: 0,
            type: new on(this.schema.fields),
            children: this.schema.fields.map((n) => Lt({ type: n.type, nullCount: 0 }))
          })
        ] = t, !(this.data instanceof me))
          throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");
        [this.schema, this.data] = Kw(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] = Me.new({ name: l, type: n[l].type, nullable: !0 }), c), {
          length: 0,
          fields: new Array(),
          children: new Array()
        }), o = new _e(i), a = Lt({ type: new on(i), length: s, children: r, nullCount: 0 });
        [this.schema, this.data] = Kw(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 = r3(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 gn.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 ti.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 Qh.visit(this.data, t, n);
  }
  /**
   * Get the size (in bytes) of a row by index.
   * @param index The row index for which to compute the byteLength.
   */
  getByteLength(t) {
    return rr.visit(this.data, t);
  }
  /**
   * Iterator for rows in this RecordBatch.
   */
  [Symbol.iterator]() {
    return R1.visit(new $e([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 hu(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 $e([this.data]).slice(t, n).data;
    return new Rl(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 $e([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 $e([Lt({ type: new Os(), 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 = Lt({ type: new on(s), children: o });
    }
    return new Rl(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 on(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 Rl(n, Lt({ 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 = Lt({ type: new on(n.fields), length: this.numRows, children: i });
    return new Rl(n, r);
  }
};
i3 = Symbol.toStringTag;
ui[i3] = ((e) => (e._nullCount = -1, e[Symbol.isConcatSpreadable] = !0, "RecordBatch"))(ui.prototype);
function Kw(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 : Lt({
      type: c.type,
      length: n,
      nullCount: n,
      nullBitmap: new Uint8Array(o)
    }));
  }
  return [
    e.assign(r),
    Lt({ type: new on(r), length: n, children: s })
  ];
}
function r3(e, t, n = /* @__PURE__ */ new Map()) {
  for (let i = -1, r = e.length; ++i < r; ) {
    const o = e[i].type, a = t[i];
    if (Nt.isDictionary(o)) {
      if (!n.has(o.id))
        a.dictionary && n.set(o.id, a.dictionary);
      else if (n.get(o.id) !== a.dictionary)
        throw new Error("Cannot create Schema containing two different dictionaries with the same Id");
    }
    o.children && o.children.length > 0 && r3(o.children, a.children, n);
  }
  return n;
}
let s3 = class extends ui {
  constructor(t) {
    const n = t.fields.map((r) => Lt({ type: r.type })), i = Lt({ type: new on(t.fields), nullCount: 0, children: n });
    super(t, i);
  }
};
var ld;
(function(e) {
  e[e.BUFFER = 0] = "BUFFER";
})(ld || (ld = {}));
var ud;
(function(e) {
  e[e.LZ4_FRAME = 0] = "LZ4_FRAME", e[e.ZSTD = 1] = "ZSTD";
})(ud || (ud = {}));
let ME = class Ao {
  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 Ao()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsBodyCompression(t, n) {
    return t.setPosition(t.position() + se), (n || new Ao()).__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) : ud.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) : ld.BUFFER;
  }
  static startBodyCompression(t) {
    t.startObject(2);
  }
  static addCodec(t, n) {
    t.addFieldInt8(0, n, ud.LZ4_FRAME);
  }
  static addMethod(t, n) {
    t.addFieldInt8(1, n, ld.BUFFER);
  }
  static endBodyCompression(t) {
    return t.endObject();
  }
  static createBodyCompression(t, n, i) {
    return Ao.startBodyCompression(t), Ao.addCodec(t, n), Ao.addMethod(t, i), Ao.endBodyCompression(t);
  }
}, o3 = 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();
  }
}, a3 = 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();
  }
}, Nr = class Gm {
  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 Gm()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsRecordBatch(t, n) {
    return t.setPosition(t.position() + se), (n || new Gm()).__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 a3()).__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 o3()).__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 ME()).__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();
  }
}, Na = class Xm {
  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 Xm()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDictionaryBatch(t, n) {
    return t.setPosition(t.position() + se), (n || new Xm()).__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 Nr()).__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 fd;
(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";
})(fd || (fd = {}));
let hs = class Ri {
  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 Ri()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsMessage(t, n) {
    return t.setPosition(t.position() + se), (n || new Ri()).__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) : hc.V1;
  }
  headerType() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? this.bb.readUint8(this.bb_pos + t) : fd.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 Gn()).__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, hc.V1);
  }
  static addHeaderType(t, n) {
    t.addFieldInt8(1, n, fd.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 Ri.startMessage(t), Ri.addVersion(t, n), Ri.addHeaderType(t, i), Ri.addHeader(t, r), Ri.addBodyLength(t, s), Ri.addCustomMetadata(t, o), Ri.endMessage(t);
  }
}, $E = class extends kt {
  visit(t, n) {
    return t == null || n == null ? void 0 : super.visit(t, n);
  }
  visitNull(t, n) {
    return qw.startNull(n), qw.endNull(n);
  }
  visitInt(t, n) {
    return Ca.startInt(n), Ca.addBitWidth(n, t.bitWidth), Ca.addIsSigned(n, t.isSigned), Ca.endInt(n);
  }
  visitFloat(t, n) {
    return bh.startFloatingPoint(n), bh.addPrecision(n, t.precision), bh.endFloatingPoint(n);
  }
  visitBinary(t, n) {
    return Vw.startBinary(n), Vw.endBinary(n);
  }
  visitBool(t, n) {
    return jw.startBool(n), jw.endBool(n);
  }
  visitUtf8(t, n) {
    return Gw.startUtf8(n), Gw.endUtf8(n);
  }
  visitDecimal(t, n) {
    return Ia.startDecimal(n), Ia.addScale(n, t.scale), Ia.addPrecision(n, t.precision), Ia.addBitWidth(n, t.bitWidth), Ia.endDecimal(n);
  }
  visitDate(t, n) {
    return yh.startDate(n), yh.addUnit(n, t.unit), yh.endDate(n);
  }
  visitTime(t, n) {
    return El.startTime(n), El.addUnit(n, t.unit), El.addBitWidth(n, t.bitWidth), El.endTime(n);
  }
  visitTimestamp(t, n) {
    const i = t.timezone && n.createString(t.timezone) || void 0;
    return Ol.startTimestamp(n), Ol.addUnit(n, t.unit), i !== void 0 && Ol.addTimezone(n, i), Ol.endTimestamp(n);
  }
  visitInterval(t, n) {
    return _h.startInterval(n), _h.addUnit(n, t.unit), _h.endInterval(n);
  }
  visitList(t, n) {
    return Yw.startList(n), Yw.endList(n);
  }
  visitStruct(t, n) {
    return Ww.startStruct_(n), Ww.endStruct_(n);
  }
  visitUnion(t, n) {
    vo.startTypeIdsVector(n, t.typeIds.length);
    const i = vo.createTypeIdsVector(n, t.typeIds);
    return vo.startUnion(n), vo.addMode(n, t.mode), vo.addTypeIds(n, i), vo.endUnion(n);
  }
  visitDictionary(t, n) {
    const i = this.visit(t.indices, n);
    return xa.startDictionaryEncoding(n), xa.addId(n, BigInt(t.id)), xa.addIsOrdered(n, t.isOrdered), i !== void 0 && xa.addIndexType(n, i), xa.endDictionaryEncoding(n);
  }
  visitFixedSizeBinary(t, n) {
    return mh.startFixedSizeBinary(n), mh.addByteWidth(n, t.byteWidth), mh.endFixedSizeBinary(n);
  }
  visitFixedSizeList(t, n) {
    return gh.startFixedSizeList(n), gh.addListSize(n, t.listSize), gh.endFixedSizeList(n);
  }
  visitMap(t, n) {
    return wh.startMap(n), wh.addKeysSorted(n, t.keysSorted), wh.endMap(n);
  }
};
const T0 = new $E();
function TE(e, t = /* @__PURE__ */ new Map()) {
  return new _e(NE(e, t), xh(e.customMetadata), t);
}
function c3(e) {
  return new _i(e.count, l3(e.columns), u3(e.columns));
}
function BE(e) {
  return new Zr(c3(e.data), e.id, e.isDelta);
}
function NE(e, t) {
  return (e.fields || []).filter(Boolean).map((n) => Me.fromJSON(n, t));
}
function Zw(e, t) {
  return (e.children || []).filter(Boolean).map((n) => Me.fromJSON(n, t));
}
function l3(e) {
  return (e || []).reduce((t, n) => [
    ...t,
    new Wc(n.count, FE(n.VALIDITY)),
    ...l3(n.children)
  ], []);
}
function u3(e, t = []) {
  for (let n = -1, i = (e || []).length; ++n < i; ) {
    const r = e[n];
    r.VALIDITY && t.push(new kr(t.length, r.VALIDITY.length)), r.TYPE && t.push(new kr(t.length, r.TYPE.length)), r.OFFSET && t.push(new kr(t.length, r.OFFSET.length)), r.DATA && t.push(new kr(t.length, r.DATA.length)), t = u3(r.children, t);
  }
  return t;
}
function FE(e) {
  return (e || []).reduce((t, n) => t + +(n === 0), 0);
}
function DE(e, t) {
  let n, i, r, s, o, a;
  return !t || !(s = e.dictionary) ? (o = Qw(e, Zw(e, t)), r = new Me(e.name, o, e.nullable, xh(e.customMetadata))) : t.has(n = s.id) ? (i = (i = s.indexType) ? Jw(i) : new lu(), a = new uc(t.get(n), i, n, s.isOrdered), r = new Me(e.name, a, e.nullable, xh(e.customMetadata))) : (i = (i = s.indexType) ? Jw(i) : new lu(), t.set(n, o = Qw(e, Zw(e, t))), a = new uc(o, i, n, s.isOrdered), r = new Me(e.name, a, e.nullable, xh(e.customMetadata))), r || null;
}
function xh(e) {
  return new Map(Object.entries(e || {}));
}
function Jw(e) {
  return new Ls(e.isSigned, e.bitWidth);
}
function Qw(e, t) {
  const n = e.type.name;
  switch (n) {
    case "NONE":
      return new Os();
    case "null":
      return new Os();
    case "binary":
      return new Ph();
    case "utf8":
      return new Vh();
    case "bool":
      return new jh();
    case "list":
      return new Xh((t || [])[0]);
    case "struct":
      return new on(t || []);
    case "struct_":
      return new on(t || []);
  }
  switch (n) {
    case "int": {
      const i = e.type;
      return new Ls(i.isSigned, i.bitWidth);
    }
    case "floatingpoint": {
      const i = e.type;
      return new uu(yn[i.precision]);
    }
    case "decimal": {
      const i = e.type;
      return new Yh(i.scale, i.precision, i.bitWidth);
    }
    case "date": {
      const i = e.type;
      return new qh(Kr[i.unit]);
    }
    case "time": {
      const i = e.type;
      return new fu(jt[i.unit], i.bitWidth);
    }
    case "timestamp": {
      const i = e.type;
      return new Wh(jt[i.unit], i.timezone);
    }
    case "interval": {
      const i = e.type;
      return new Gh(Es[i.unit]);
    }
    case "union": {
      const i = e.type;
      return new Hh(gi[i.mode], i.typeIds || [], t || []);
    }
    case "fixedsizebinary": {
      const i = e.type;
      return new Kh(i.byteWidth);
    }
    case "fixedsizelist": {
      const i = e.type;
      return new Zh(i.listSize, (t || [])[0]);
    }
    case "map": {
      const i = e.type;
      return new Jh((t || [])[0], i.keysSorted);
    }
  }
  throw new Error(`Unrecognized type: "${n}"`);
}
var EE = HI, OE = fc;
let Xl = class Fa {
  /** @nocollapse */
  static fromJSON(t, n) {
    const i = new Fa(0, Yn.V4, n);
    return i._createHeader = LE(t, n), i;
  }
  /** @nocollapse */
  static decode(t) {
    t = new OE(Xt(t));
    const n = hs.getRootAsMessage(t), i = n.bodyLength(), r = n.version(), s = n.headerType(), o = new Fa(i, r, s);
    return o._createHeader = RE(n, s), o;
  }
  /** @nocollapse */
  static encode(t) {
    const n = new EE();
    let i = -1;
    return t.isSchema() ? i = _e.encode(n, t.header()) : t.isRecordBatch() ? i = _i.encode(n, t.header()) : t.isDictionaryBatch() && (i = Zr.encode(n, t.header())), hs.startMessage(n), hs.addVersion(n, Yn.V4), hs.addHeader(n, i), hs.addHeaderType(n, t.headerType), hs.addBodyLength(n, BigInt(t.bodyLength)), hs.finishMessageBuffer(n, hs.endMessage(n)), n.asUint8Array();
  }
  /** @nocollapse */
  static from(t, n = 0) {
    if (t instanceof _e)
      return new Fa(0, Yn.V4, Jt.Schema, t);
    if (t instanceof _i)
      return new Fa(n, Yn.V4, Jt.RecordBatch, t);
    if (t instanceof Zr)
      return new Fa(n, Yn.V4, Jt.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 === Jt.Schema;
  }
  isRecordBatch() {
    return this.headerType === Jt.RecordBatch;
  }
  isDictionaryBatch() {
    return this.headerType === Jt.DictionaryBatch;
  }
  constructor(t, n, i, r) {
    this._version = n, this._headerType = i, this.body = new Uint8Array(0), r && (this._createHeader = () => r), this._bodyLength = bi(t);
  }
}, _i = 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 = bi(t);
  }
}, Zr = 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 = bi(n);
  }
}, kr = class {
  constructor(t, n) {
    this.offset = bi(t), this.length = bi(n);
  }
}, Wc = class {
  constructor(t, n) {
    this.length = bi(t), this.nullCount = bi(n);
  }
};
function LE(e, t) {
  return () => {
    switch (t) {
      case Jt.Schema:
        return _e.fromJSON(e);
      case Jt.RecordBatch:
        return _i.fromJSON(e);
      case Jt.DictionaryBatch:
        return Zr.fromJSON(e);
    }
    throw new Error(`Unrecognized Message type: { name: ${Jt[t]}, type: ${t} }`);
  };
}
function RE(e, t) {
  return () => {
    switch (t) {
      case Jt.Schema:
        return _e.decode(e.header(new ki()));
      case Jt.RecordBatch:
        return _i.decode(e.header(new Nr()), e.version());
      case Jt.DictionaryBatch:
        return Zr.decode(e.header(new Na()), e.version());
    }
    throw new Error(`Unrecognized Message type: { name: ${Jt[t]}, type: ${t} }`);
  };
}
Me.encode = GE;
Me.decode = qE;
Me.fromJSON = DE;
_e.encode = WE;
_e.decode = CE;
_e.fromJSON = TE;
_i.encode = XE;
_i.decode = kE;
_i.fromJSON = c3;
Zr.encode = HE;
Zr.decode = UE;
Zr.fromJSON = BE;
Wc.encode = KE;
Wc.decode = PE;
kr.encode = ZE;
kr.decode = zE;
function CE(e, t = /* @__PURE__ */ new Map()) {
  const n = YE(e, t);
  return new _e(n, Sh(e), t);
}
function kE(e, t = Yn.V4) {
  if (e.compression() !== null)
    throw new Error("Record batch compression not implemented");
  return new _i(e.length(), VE(e), jE(e, t));
}
function UE(e, t = Yn.V4) {
  return new Zr(_i.decode(e.data(), t), e.id(), e.isDelta());
}
function zE(e) {
  return new kr(e.offset(), e.length());
}
function PE(e) {
  return new Wc(e.length(), e.nullCount());
}
function VE(e) {
  const t = [];
  for (let n, i = -1, r = -1, s = e.nodesLength(); ++i < s; )
    (n = e.nodes(i)) && (t[++r] = Wc.decode(n));
  return t;
}
function jE(e, t) {
  const n = [];
  for (let i, r = -1, s = -1, o = e.buffersLength(); ++r < o; )
    (i = e.buffers(r)) && (t < Yn.V4 && (i.bb_pos += 8 * (r + 1)), n[++s] = kr.decode(i));
  return n;
}
function YE(e, t) {
  const n = [];
  for (let i, r = -1, s = -1, o = e.fieldsLength(); ++r < o; )
    (i = e.fields(r)) && (n[++s] = Me.decode(i, t));
  return n;
}
function tv(e, t) {
  const n = [];
  for (let i, r = -1, s = -1, o = e.childrenLength(); ++r < o; )
    (i = e.children(r)) && (n[++s] = Me.decode(i, t));
  return n;
}
function qE(e, t) {
  let n, i, r, s, o, a;
  return !t || !(a = e.dictionary()) ? (r = nv(e, tv(e, t)), i = new Me(e.name(), r, e.nullable(), Sh(e))) : t.has(n = bi(a.id())) ? (s = (s = a.indexType()) ? ev(s) : new lu(), o = new uc(t.get(n), s, n, a.isOrdered()), i = new Me(e.name(), o, e.nullable(), Sh(e))) : (s = (s = a.indexType()) ? ev(s) : new lu(), t.set(n, r = nv(e, tv(e, t))), o = new uc(r, s, n, a.isOrdered()), i = new Me(e.name(), o, e.nullable(), Sh(e))), i || null;
}
function Sh(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 ev(e) {
  return new Ls(e.isSigned(), e.bitWidth());
}
function nv(e, t) {
  const n = e.typeType();
  switch (n) {
    case ge.NONE:
      return new Os();
    case ge.Null:
      return new Os();
    case ge.Binary:
      return new Ph();
    case ge.Utf8:
      return new Vh();
    case ge.Bool:
      return new jh();
    case ge.List:
      return new Xh((t || [])[0]);
    case ge.Struct_:
      return new on(t || []);
  }
  switch (n) {
    case ge.Int: {
      const i = e.type(new Ca());
      return new Ls(i.isSigned(), i.bitWidth());
    }
    case ge.FloatingPoint: {
      const i = e.type(new bh());
      return new uu(i.precision());
    }
    case ge.Decimal: {
      const i = e.type(new Ia());
      return new Yh(i.scale(), i.precision(), i.bitWidth());
    }
    case ge.Date: {
      const i = e.type(new yh());
      return new qh(i.unit());
    }
    case ge.Time: {
      const i = e.type(new El());
      return new fu(i.unit(), i.bitWidth());
    }
    case ge.Timestamp: {
      const i = e.type(new Ol());
      return new Wh(i.unit(), i.timezone());
    }
    case ge.Interval: {
      const i = e.type(new _h());
      return new Gh(i.unit());
    }
    case ge.Union: {
      const i = e.type(new vo());
      return new Hh(i.mode(), i.typeIdsArray() || [], t || []);
    }
    case ge.FixedSizeBinary: {
      const i = e.type(new mh());
      return new Kh(i.byteWidth());
    }
    case ge.FixedSizeList: {
      const i = e.type(new gh());
      return new Zh(i.listSize(), (t || [])[0]);
    }
    case ge.Map: {
      const i = e.type(new wh());
      return new Jh((t || [])[0], i.keysSorted());
    }
  }
  throw new Error(`Unrecognized type: "${ge[n]}" (${n})`);
}
function WE(e, t) {
  const n = t.fields.map((s) => Me.encode(e, s));
  ki.startFieldsVector(e, n.length);
  const i = ki.createFieldsVector(e, n), r = t.metadata && t.metadata.size > 0 ? ki.createCustomMetadataVector(e, [...t.metadata].map(([s, o]) => {
    const a = e.createString(`${s}`), c = e.createString(`${o}`);
    return Gn.startKeyValue(e), Gn.addKey(e, a), Gn.addValue(e, c), Gn.endKeyValue(e);
  })) : -1;
  return ki.startSchema(e), ki.addFields(e, i), ki.addEndianness(e, JE ? dc.Little : dc.Big), r !== -1 && ki.addCustomMetadata(e, r), ki.endSchema(e);
}
function GE(e, t) {
  let n = -1, i = -1, r = -1;
  const s = t.type;
  let o = t.typeId;
  Nt.isDictionary(s) ? (o = s.dictionary.typeId, r = T0.visit(s, e), i = T0.visit(s.dictionary, e)) : i = T0.visit(s, e);
  const a = (s.children || []).map((u) => Me.encode(e, u)), c = Cn.createChildrenVector(e, a), l = t.metadata && t.metadata.size > 0 ? Cn.createCustomMetadataVector(e, [...t.metadata].map(([u, f]) => {
    const h = e.createString(`${u}`), d = e.createString(`${f}`);
    return Gn.startKeyValue(e), Gn.addKey(e, h), Gn.addValue(e, d), Gn.endKeyValue(e);
  })) : -1;
  return t.name && (n = e.createString(t.name)), Cn.startField(e), Cn.addType(e, i), Cn.addTypeType(e, o), Cn.addChildren(e, c), Cn.addNullable(e, !!t.nullable), n !== -1 && Cn.addName(e, n), r !== -1 && Cn.addDictionary(e, r), l !== -1 && Cn.addCustomMetadata(e, l), Cn.endField(e);
}
function XE(e, t) {
  const n = t.nodes || [], i = t.buffers || [];
  Nr.startNodesVector(e, n.length);
  for (const o of n.slice().reverse())
    Wc.encode(e, o);
  const r = e.endVector();
  Nr.startBuffersVector(e, i.length);
  for (const o of i.slice().reverse())
    kr.encode(e, o);
  const s = e.endVector();
  return Nr.startRecordBatch(e), Nr.addLength(e, BigInt(t.length)), Nr.addNodes(e, r), Nr.addBuffers(e, s), Nr.endRecordBatch(e);
}
function HE(e, t) {
  const n = _i.encode(e, t.data);
  return Na.startDictionaryBatch(e), Na.addId(e, BigInt(t.id)), Na.addIsDelta(e, t.isDelta), Na.addData(e, n), Na.endDictionaryBatch(e);
}
function KE(e, t) {
  return a3.createFieldNode(e, BigInt(t.length), BigInt(t.nullCount));
}
function ZE(e, t) {
  return o3.createBuffer(e, BigInt(t.offset), BigInt(t.length));
}
const JE = (() => {
  const e = new ArrayBuffer(2);
  return new DataView(e).setInt16(
    0,
    256,
    !0
    /* littleEndian */
  ), new Int16Array(e)[0] === 256;
})(), V1 = (e) => `Expected ${Jt[e]} Message in stream, but was null or length 0.`, j1 = (e) => `Header pointer of flatbuffer-encoded ${Jt[e]} Message is null or length 0.`, f3 = (e, t) => `Expected to read ${e} metadata bytes, but only read ${t}.`, h3 = (e, t) => `Expected to read ${e} bytes for message body, but only read ${t}.`;
let d3 = class {
  constructor(t) {
    this.source = t instanceof od ? t : new od(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 ? we : 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(V1(t));
    return n.value;
  }
  readMessageBody(t) {
    if (t <= 0)
      return new Uint8Array(0);
    const n = Xt(this.source.read(t));
    if (n.byteLength < t)
      throw new Error(h3(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 = Jt.Schema, i = this.readMessage(n), r = i == null ? void 0 : i.header();
    if (t && !r)
      throw new Error(j1(n));
    return r;
  }
  readMetadataLength() {
    const t = this.source.read(ay), n = t && new fc(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 we;
    if (n.byteLength < t)
      throw new Error(f3(t, n.byteLength));
    return { done: !1, value: Xl.decode(n) };
  }
}, QE = class {
  constructor(t, n) {
    this.source = t instanceof ad ? t : MS(t) ? new cd(t, n) : new ad(t);
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  next() {
    return Y(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 ? we : t;
    });
  }
  throw(t) {
    return Y(this, void 0, void 0, function* () {
      return yield this.source.throw(t);
    });
  }
  return(t) {
    return Y(this, void 0, void 0, function* () {
      return yield this.source.return(t);
    });
  }
  readMessage(t) {
    return Y(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(V1(t));
      return n.value;
    });
  }
  readMessageBody(t) {
    return Y(this, void 0, void 0, function* () {
      if (t <= 0)
        return new Uint8Array(0);
      const n = Xt(yield this.source.read(t));
      if (n.byteLength < t)
        throw new Error(h3(t, n.byteLength));
      return (
        /* 1. */
        n.byteOffset % 8 === 0 && /* 2. */
        n.byteOffset + n.byteLength <= n.buffer.byteLength ? n : n.slice()
      );
    });
  }
  readSchema(t = !1) {
    return Y(this, void 0, void 0, function* () {
      const n = Jt.Schema, i = yield this.readMessage(n), r = i == null ? void 0 : i.header();
      if (t && !r)
        throw new Error(j1(n));
      return r;
    });
  }
  readMetadataLength() {
    return Y(this, void 0, void 0, function* () {
      const t = yield this.source.read(ay), n = t && new fc(t), i = (n == null ? void 0 : n.readInt32(0)) || 0;
      return { done: i === 0, value: i };
    });
  }
  readMetadata(t) {
    return Y(this, void 0, void 0, function* () {
      const n = yield this.source.read(t);
      if (!n)
        return we;
      if (n.byteLength < t)
        throw new Error(f3(t, n.byteLength));
      return { done: !1, value: Xl.decode(n) };
    });
  }
}, tO = class extends d3 {
  constructor(t) {
    super(new Uint8Array(0)), this._schema = !1, this._body = [], this._batchIndex = 0, this._dictionaryIndex = 0, this._json = t instanceof Xw ? t : new Xw(t);
  }
  next() {
    const { _json: t } = this;
    if (!this._schema)
      return this._schema = !0, { done: !1, value: Xl.fromJSON(t.schema, Jt.Schema) };
    if (this._dictionaryIndex < t.dictionaries.length) {
      const n = t.dictionaries[this._dictionaryIndex++];
      return this._body = n.data.columns, { done: !1, value: Xl.fromJSON(n, Jt.DictionaryBatch) };
    }
    if (this._batchIndex < t.batches.length) {
      const n = t.batches[this._batchIndex++];
      return this._body = n.columns, { done: !1, value: Xl.fromJSON(n, Jt.RecordBatch) };
    }
    return this._body = [], we;
  }
  readMessageBody(t) {
    return n(this._body);
    function n(i) {
      return (i || []).reduce((r, s) => [
        ...r,
        ...s.VALIDITY && [s.VALIDITY] || [],
        ...s.TYPE && [s.TYPE] || [],
        ...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(V1(t));
    return n.value;
  }
  readSchema() {
    const t = Jt.Schema, n = this.readMessage(t), i = n == null ? void 0 : n.header();
    if (!n || !i)
      throw new Error(j1(t));
    return i;
  }
};
const ay = 4, Hm = "ARROW1", hd = new Uint8Array(Hm.length);
for (let e = 0; e < Hm.length; e += 1)
  hd[e] = Hm.codePointAt(e);
function Y1(e, t = 0) {
  for (let n = -1, i = hd.length; ++n < i; )
    if (hd[n] !== e[t + n])
      return !1;
  return !0;
}
const qu = hd.length, p3 = qu + ay, eO = qu * 2 + ay;
let Wu = class Ih extends JI {
  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 ou(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 Un.toDOMStream(this.isSync() ? { [Symbol.iterator]: () => this } : { [Symbol.asyncIterator]: () => this });
  }
  toNodeStream() {
    return Un.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 Ih ? t : Lm(t) ? sO(t) : MS(t) ? cO(t) : ou(t) ? (() => Y(this, void 0, void 0, function* () {
      return yield Ih.from(yield t);
    }))() : $S(t) || M1(t) || BS(t) || A1(t) ? aO(new ad(t)) : oO(new od(t));
  }
  /** @nocollapse */
  static readAll(t) {
    return t instanceof Ih ? t.isSync() ? iv(t) : rv(t) : Lm(t) || ArrayBuffer.isView(t) || ry(t) || AS(t) ? iv(t) : rv(t);
  }
}, dd = class extends Wu {
  constructor(t) {
    super(t), this._impl = t;
  }
  readAll() {
    return [...this];
  }
  [Symbol.iterator]() {
    return this._impl[Symbol.iterator]();
  }
  [Symbol.asyncIterator]() {
    return Fe(this, arguments, function* () {
      yield G(yield* Bs(Qn(this[Symbol.iterator]())));
    });
  }
}, pd = class extends Wu {
  constructor(t) {
    super(t), this._impl = t;
  }
  readAll() {
    var t, n, i, r;
    return Y(this, void 0, void 0, function* () {
      const s = new Array();
      try {
        for (var o = !0, a = Qn(this), c; c = yield a.next(), t = c.done, !t; ) {
          r = c.value, o = !1;
          try {
            const l = r;
            s.push(l);
          } finally {
            o = !0;
          }
        }
      } 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]();
  }
}, y3 = class extends dd {
  constructor(t) {
    super(t), this._impl = t;
  }
}, nO = class extends pd {
  constructor(t) {
    super(t), this._impl = t;
  }
}, m3 = 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 = Lt({ type: new on(this.schema.fields), length: t.length, children: i });
    return new ui(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 $e(l)) : new $e(l)).memoize();
    }
    return a.memoize();
  }
  _loadVectors(t, n, i) {
    return new e3(n, t.nodes, t.buffers, this.dictionaries).visitMany(i);
  }
}, yd = class extends m3 {
  constructor(t, n) {
    super(n), this._reader = Lm(t) ? new tO(this._handle = t) : new d3(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 = b3(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) : we;
  }
  return(t) {
    return !this.closed && this.autoDestroy && (this.closed = !0) ? this.reset()._reader.return(t) : we;
  }
  next() {
    if (this.closed)
      return we;
    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 s3(this.schema) }) : this.return();
  }
  _readNextMessageAndValidate(t) {
    return this._reader.readMessage(t);
  }
}, md = class extends m3 {
  constructor(t, n) {
    super(n), this._reader = new QE(this._handle = t);
  }
  isAsync() {
    return !0;
  }
  isStream() {
    return !0;
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  cancel() {
    return Y(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 Y(this, void 0, void 0, function* () {
      return this.closed || (this.autoDestroy = b3(this, t), this.schema || (this.schema = yield this._reader.readSchema()) || (yield this.cancel())), this;
    });
  }
  throw(t) {
    return Y(this, void 0, void 0, function* () {
      return !this.closed && this.autoDestroy && (this.closed = !0) ? yield this.reset()._reader.throw(t) : we;
    });
  }
  return(t) {
    return Y(this, void 0, void 0, function* () {
      return !this.closed && this.autoDestroy && (this.closed = !0) ? yield this.reset()._reader.return(t) : we;
    });
  }
  next() {
    return Y(this, void 0, void 0, function* () {
      if (this.closed)
        return we;
      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 s3(this.schema) }) : yield this.return();
    });
  }
  _readNextMessageAndValidate(t) {
    return Y(this, void 0, void 0, function* () {
      return yield this._reader.readMessage(t);
    });
  }
}, g3 = class extends yd {
  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 Hw ? t : new Hw(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(Jt.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(Jt.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 - p3, i = t.readInt32(n), r = t.readAt(n - i, i);
    return C1.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;
  }
}, iO = class extends md {
  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 cd ? t : new cd(t, i), r);
  }
  isFile() {
    return !0;
  }
  isAsync() {
    return !0;
  }
  open(t) {
    const n = Object.create(null, {
      open: { get: () => super.open }
    });
    return Y(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 Y(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(Jt.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 Y(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(Jt.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 Y(this, void 0, void 0, function* () {
      const { _handle: t } = this;
      t._pending && (yield t._pending);
      const n = t.size - p3, i = yield t.readInt32(n), r = yield t.readAt(n - i, i);
      return C1.decode(r);
    });
  }
  _readNextMessageAndValidate(t) {
    return Y(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;
    });
  }
}, rO = class extends yd {
  constructor(t, n) {
    super(t, n);
  }
  _loadVectors(t, n, i) {
    return new yE(n, t.nodes, t.buffers, this.dictionaries).visitMany(i);
  }
};
function b3(e, t) {
  return t && typeof t.autoDestroy == "boolean" ? t.autoDestroy : e.autoDestroy;
}
function* iv(e) {
  const t = Wu.from(e);
  try {
    if (!t.open({ autoDestroy: !1 }).closed)
      do
        yield t;
      while (!t.reset().open().closed);
  } finally {
    t.cancel();
  }
}
function rv(e) {
  return Fe(this, arguments, function* () {
    const n = yield G(Wu.from(e));
    try {
      if (!(yield G(n.open({ autoDestroy: !1 }))).closed)
        do
          yield yield G(n);
        while (!(yield G(n.reset().open())).closed);
    } finally {
      yield G(n.cancel());
    }
  });
}
function sO(e) {
  return new dd(new rO(e));
}
function oO(e) {
  const t = e.peek(qu + 7 & -8);
  return t && t.byteLength >= 4 ? Y1(t) ? new y3(new g3(e.read())) : new dd(new yd(e)) : new dd(new yd(/* @__PURE__ */ function* () {
  }()));
}
function aO(e) {
  return Y(this, void 0, void 0, function* () {
    const t = yield e.peek(qu + 7 & -8);
    return t && t.byteLength >= 4 ? Y1(t) ? new y3(new g3(yield e.read())) : new pd(new md(e)) : new pd(new md(function() {
      return Fe(this, arguments, function* () {
      });
    }()));
  });
}
function cO(e) {
  return Y(this, void 0, void 0, function* () {
    const { size: t } = yield e.stat(), n = new cd(e, t);
    return t >= eO && Y1(yield n.readAt(0, qu + 7 & -8)) ? new nO(new iO(n)) : new pd(new md(n));
  });
}
function _3(e) {
  const t = Wu.from(e);
  return ou(t) ? t.then((n) => _3(n)) : t.isAsync() ? t.readAll().then((n) => new hu(n)) : new hu(t.readAll());
}
function lO(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(_3(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 Cs {
  /**
   * 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 ? `${sv(t)}.` : ""}${i}`;
    } else
      return t ? sv(t) : "NULL";
  }
}
function sv(e) {
  return e.split(".").map((n) => `"${n}"`).join(".");
}
function uO(e, t) {
  return e instanceof Cs && e.column === t;
}
function fe(e) {
  return typeof e == "string" ? q1(e) : e;
}
function Ah(e) {
  return typeof e == "string" ? fO(e) : e;
}
function fO(e) {
  return new Cs(e);
}
function q1(e, t) {
  return arguments.length === 1 && (t = e, e = null), new Cs(e, t);
}
function Gu(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 mc = (e) => typeof (e == null ? void 0 : e.addEventListener) == "function";
function w3(e) {
  return e instanceof cy;
}
class cy {
  /**
   * 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) => mc(s));
    r.length > 0 ? (this._params = Array.from(new Set(r)), this._params.forEach((s) => {
      s.addEventListener("value", () => {
        var o;
        return hO(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) => mc(t) && !w3(t) ? Gu(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 hO(e, t) {
  if (t != null && t.size)
    return Promise.allSettled(Array.from(t, (n) => n(e)));
}
function v3(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];
    mc(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 : Gu(a));
    const c = e[++s];
    mc(n[o]) ? n[++o] = c : n[o] += c;
  }
  return { spans: n, cols: Array.from(i) };
}
function q(e, ...t) {
  const { spans: n, cols: i } = v3(e, t);
  return new cy(n, i);
}
function dO(e) {
  const t = fe(e);
  return q`${t} DESC NULLS LAST`.annotate({ label: t == null ? void 0 : t.label, desc: !0 });
}
const Xu = (e) => ({
  value: e,
  toString: () => Gu(e)
});
function ly(e) {
  var t;
  e(this.op, this), (t = this.children) == null || t.forEach((n) => n.visit(e));
}
function x3(e, t) {
  const n = t.filter((r) => r != null).map(fe), i = n.map((r, s) => s ? ` ${e} ` : "");
  return t.length && i.push(""), q(i, ...n).annotate({ op: e, children: n, visit: ly });
}
const Yo = (...e) => x3("AND", e.flat()), S3 = (...e) => x3("OR", e.flat()), I3 = (e) => (t) => q`(${fe(t)} ${e})`.annotate({ op: e, a: t, visit: ly }), A3 = I3("IS NULL"), gd = I3("IS NOT NULL"), Gc = (e) => (t, n) => q`(${fe(t)} ${e} ${fe(n)})`.annotate({ op: e, a: t, b: n, visit: ly }), W1 = Gc("="), pO = Gc("<>"), bd = Gc("<"), M3 = Gc(">"), _d = Gc("<="), yO = Gc("IS NOT DISTINCT FROM");
function mO(e, t, n, i) {
  t = fe(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: ly, field: t, range: n });
}
const Dn = (e, t, n) => mO("BETWEEN", e, t, n);
function wd(e, t) {
  return Array.from({ length: e }, () => t);
}
function Hu(e, t) {
  return (...n) => {
    const i = n.map(fe), r = t ? `::${t}` : "";
    return (i.length ? q([`${e}(`, ...wd(i.length - 1, ", "), `)${r}`], ...i) : q`${e}()${r}`).annotate({ func: e, args: i });
  };
}
const gO = Hu("REGEXP_MATCHES"), bO = Hu("CONTAINS"), _O = Hu("PREFIX"), wO = Hu("SUFFIX");
class vs extends cy {
  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 vs(n, i, r, t, s, o, a);
  }
  partitionby(...t) {
    const n = t.flat().filter((u) => u).map(fe), i = q(
      ["PARTITION BY ", wd(n.length - 1, ", "), ""],
      ...n
    ), { window: r, func: s, type: o, name: a, order: c, frame: l } = this;
    return new vs(r, s, o, a, i, c, l);
  }
  orderby(...t) {
    const n = t.flat().filter((u) => u).map(fe), i = q(
      ["ORDER BY ", wd(n.length - 1, ", "), ""],
      ...n
    ), { window: r, func: s, type: o, name: a, group: c, frame: l } = this;
    return new vs(r, s, o, a, c, i, l);
  }
  rows(t) {
    const n = ov("ROWS", t), { window: i, func: r, type: s, name: o, group: a, order: c } = this;
    return new vs(i, r, s, o, a, c, n);
  }
  range(t) {
    const n = ov("RANGE", t), { window: i, func: r, type: s, name: o, group: a, order: c } = this;
    return new vs(i, r, s, o, a, c, n);
  }
}
function ov(e, t) {
  if (mc(t)) {
    const n = q`${t}`;
    return n.toString = () => `${e} ${av(t.value)}`, n;
  }
  return `${e} ${av(t)}`;
}
function av(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 Bi(e, t) {
  return (...n) => {
    const i = Hu(e)(...n);
    return new vs(e, i, t);
  };
}
const vO = Bi("ROW_NUMBER", "INTEGER"), xO = Bi("RANK", "INTEGER"), SO = Bi("DENSE_RANK", "INTEGER"), IO = Bi("PERCENT_RANK"), AO = Bi("CUME_DIST"), MO = Bi("NTILE"), $O = Bi("LAG"), TO = Bi("LEAD"), BO = Bi("FIRST_VALUE"), NO = Bi("LAST_VALUE"), FO = Bi("NTH_VALUE");
class Hl extends cy {
  constructor(t, n, i, r, s) {
    n = (n || []).map(fe);
    const { strings: o, exprs: a } = DO(t, n, i, r, s), { spans: c, cols: l } = v3(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(EO).join(", ")})` : "";
    return `${t.toLowerCase()}${s}`;
  }
  distinct() {
    const { aggregate: t, args: n, type: i, filter: r } = this;
    return new Hl(t, n, i, !0, r);
  }
  where(t) {
    const { aggregate: n, args: i, type: r, isDistinct: s } = this;
    return new Hl(n, i, r, s, t);
  }
  window() {
    const { aggregate: t, args: n, type: i, isDistinct: r } = this, s = new Hl(t, n, null, r);
    return new vs(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 DO(e, t, n, i, r) {
  const s = `)${n ? `::${n}` : ""}`;
  let o = [`${e}(${i ? "DISTINCT " : ""}`], a = [];
  return t.length ? (o = o.concat([
    ...wd(t.length - 1, ", "),
    `${s}${r ? " FILTER (WHERE " : ""}`,
    ...r ? [")"] : []
  ]), a = [...t, ...r ? [r] : []]) : o[0] += "*" + s, { exprs: a, strings: o };
}
function EO(e) {
  const t = Gu(e);
  return t && t.startsWith('"') && t.endsWith('"') ? t.slice(1, -1) : t;
}
function Ze(e, t) {
  return (...n) => new Hl(e, n, t);
}
const Uo = Ze("COUNT", "INTEGER"), OO = Ze("AVG"), gc = Ze("MAX"), bc = Ze("MIN"), na = Ze("SUM", "DOUBLE"), LO = Ze("MEDIAN"), RO = Ze("QUANTILE"), CO = Ze("MODE"), kO = Ze("REGR_INTERCEPT"), UO = Ze("REGR_SLOPE"), zO = Ze("REGR_COUNT"), PO = Ze("REGR_SYY"), VO = Ze("REGR_SXX"), jO = Ze("REGR_AVGX"), cv = Ze("ARG_MIN"), lv = Ze("ARG_MAX");
function YO(e, t) {
  const n = fe(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 uv = (e) => YO(e, "DOUBLE"), $3 = (e) => {
  const t = fe(e);
  return q`(1000 * (epoch(${t}) - second(${t})) + millisecond(${t}))::DOUBLE`;
}, qO = (e) => {
  const t = fe(e);
  return q`MAKE_DATE(2012, MONTH(${t}), 1)`.annotate({ label: "month" });
}, WO = (e) => {
  const t = fe(e);
  return q`MAKE_DATE(2012, MONTH(${t}), DAY(${t}))`.annotate({ label: "date" });
}, GO = (e) => {
  const t = fe(e);
  return q`MAKE_DATE(2012, 1, DAY(${t}))`.annotate({ label: "date" });
};
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());
  }
  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: fe(r) });
          else if (r instanceof Cs)
            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: Of(s), expr: fe(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: Ah(r) });
          else if (r instanceof Cs)
            i.push({ as: r.table, from: r });
          else if (B0(r) || w3(r))
            i.push({ from: r });
          else if (Array.isArray(r))
            i.push({ as: Of(r[0]), from: Ah(r[1]) });
          else
            for (const s in r)
              i.push({ as: Of(s), from: Ah(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(fe)
    ), 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: Of(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(fe)
    ), 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 (B0(o))
        s.push(o);
      else if (r[o.table]) {
        const a = r[o.table];
        s.push(a);
      }
    }), s;
  }
  toString() {
    const {
      select: t,
      distinct: n,
      from: i,
      sample: r,
      where: s,
      groupby: o,
      having: a,
      window: c,
      qualify: l,
      orderby: u,
      limit: f,
      offset: h,
      with: d
    } = this.query, p = [];
    if (d.length) {
      const g = d.map(({ as: y, query: b }) => `"${y}" AS (${b})`);
      p.push(`WITH ${g.join(", ")}`);
    }
    const m = t.map(
      ({ as: g, expr: y }) => uO(y, g) && !y.table ? `${y}` : `${y} AS "${g}"`
    );
    if (p.push(`SELECT${n ? " DISTINCT" : ""} ${m.join(", ")}`), i.length) {
      const g = i.map(({ as: y, from: b }) => {
        const _ = B0(b) ? `(${b})` : `${b}`;
        return !y || y === b.table ? _ : `${_} AS "${y}"`;
      });
      p.push(`FROM ${g.join(", ")}`);
    }
    if (s.length) {
      const g = s.map(String).filter((y) => y).join(" AND ");
      g && p.push(`WHERE ${g}`);
    }
    if (r) {
      const { rows: g, perc: y, method: b, seed: _ } = r, w = g ? `${g} ROWS` : `${y} PERCENT`, x = b ? ` (${b}${_ != null ? `, ${_}` : ""})` : "";
      p.push(`USING SAMPLE ${w}${x}`);
    }
    if (o.length && p.push(`GROUP BY ${o.join(", ")}`), a.length) {
      const g = a.map(String).filter((y) => y).join(" AND ");
      g && p.push(`HAVING ${g}`);
    }
    if (c.length) {
      const g = c.map(({ as: y, expr: b }) => `"${y}" AS (${b})`);
      p.push(`WINDOW ${g.join(", ")}`);
    }
    if (l.length) {
      const g = l.map(String).filter((y) => y).join(" AND ");
      g && p.push(`QUALIFY ${g}`);
    }
    return u.length && p.push(`ORDER BY ${u.join(", ")}`), Number.isFinite(f) && p.push(`LIMIT ${f}`), Number.isFinite(h) && p.push(`OFFSET ${h}`), 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(fe)
    ), 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 B0(e) {
  return e instanceof Et || e instanceof Bo;
}
function Of(e) {
  return XO(e) ? e.slice(1, -1) : e;
}
function XO(e) {
  return e[0] === '"' && e[e.length - 1] === '"';
}
function uy(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 HO(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) => `${Gu(r[o])} AS "${t[o]}"`);
    i.push(`(SELECT ${s.join(", ")})`);
  }
  return i.join(" UNION ALL ");
}
function G1(e, t, n, i = {}, r = {}) {
  const { select: s = ["*"], where: o, view: a, temp: c, replace: l, ...u } = i, f = t5({ ...r, ...u }), h = `${e}('${n}'${f ? ", " + f : ""})`, d = o ? ` WHERE ${o}` : "", p = `SELECT ${s.join(", ")} FROM ${h}${d}`;
  return uy(t, p, { view: a, temp: c, replace: l });
}
function KO(e, t, n) {
  return G1("read_csv", e, t, n, { auto_detect: !0, sample_size: -1 });
}
function ZO(e, t, n) {
  return G1("read_json", e, t, n, { auto_detect: !0, json_format: "auto" });
}
function JO(e, t, n) {
  return G1("read_parquet", e, t, n);
}
function QO(e, t, n = {}) {
  const { select: i = ["*"], ...r } = n, s = HO(t), o = i.length === 1 && i[0] === "*" ? s : `SELECT ${i} FROM ${s}`;
  return uy(e, o, r);
}
function t5(e) {
  return Object.entries(e).map(([t, n]) => {
    const i = typeof n, r = i === "boolean" ? String(n) : i === "string" ? `'${n}'` : n;
    return `${t}=${r}`;
  }).join(", ");
}
function e5(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":
    case "DECIMAL":
      return "number";
    case "DATE":
    case "TIMESTAMP":
    case "TIMESTAMPTZ":
    case "TIME":
      return "date";
    case "BOOLEAN":
      return "boolean";
    case "VARCHAR":
    case "UUID":
      return "string";
    case "LIST":
      return "array";
    case "BLOB":
    case "STRUCT":
    case "MAP":
      return "object";
    default:
      throw new Error(`Unsupported type: ${e}`);
  }
}
const n5 = "count", i5 = "nulls", r5 = "max", s5 = "min", o5 = "distinct", a5 = {
  [n5]: Uo,
  [o5]: (e) => Uo(e).distinct(),
  [r5]: gc,
  [s5]: bc,
  [i5]: (e) => Uo().where(A3(e))
};
function c5({ table: e, column: t }, n) {
  return Et.from(e).select(n.map((i) => [i, a5[i](t)]));
}
const T3 = () => /* @__PURE__ */ Object.create(null);
class l5 {
  constructor(t) {
    this.mc = t, this.clear();
  }
  clear() {
    this.tables = T3();
  }
  tableInfo(t) {
    const n = this.tables;
    if (n[t])
      return n[t];
    const i = u5(this.mc, t).catch((r) => {
      throw n[t] = null, r;
    });
    return n[t] = i;
  }
  async fieldInfo({ table: t, column: n, stats: i }) {
    const s = (await this.tableInfo(t))[n];
    if (s == null)
      return;
    if (!(i != null && i.length))
      return s;
    const o = await this.mc.query(
      c5(s, i),
      { persist: !0 }
    ), a = { ...s, ...Array.from(o)[0] };
    for (const c in a) {
      const l = a[c];
      typeof l == "bigint" && (a[c] = Number(l));
    }
    return a;
  }
  async queryFields(t) {
    const n = await f5(this, t);
    return (await Promise.all(n.map((r) => this.fieldInfo(r)))).filter((r) => r);
  }
}
async function u5(e, t) {
  const n = await e.query(
    `DESCRIBE ${Ah(t)}`,
    { type: "json", cache: !1 }
  ), i = T3();
  for (const r of n)
    i[r.column_name] = {
      table: t,
      column: r.column_name,
      sqlType: r.column_type,
      type: e5(r.column_type),
      nullable: r.null === "YES"
    };
  return i;
}
async function f5(e, t) {
  return t.length === 1 && t[0].column === "*" ? Object.values(await e.tableInfo(t[0].table)) : t;
}
function h5(e) {
  let t = 2166136261;
  for (let n = 0, i = e.length; n < i; ++n) {
    const r = e.charCodeAt(n), s = r & 65280;
    s && (t = fv(t ^ s >> 8)), t = fv(t ^ r & 255);
  }
  return d5(t);
}
function fv(e) {
  return e + (e << 1) + (e << 4) + (e << 7) + (e << 8) + (e << 24);
}
function d5(e) {
  return e += e << 13, e ^= e >>> 7, e += e << 3, e ^= e >>> 17, e += e << 5, e & 4294967295;
}
const B3 = (e) => e;
class p5 {
  /**
   *
   * @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, dv), 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 = y5(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 = dv(f), d = f.query(s.predicate(f)).select({ ...r.columns, ...h.count }).groupby(Object.keys(r.columns)), [p] = d.subqueries;
      if (p) {
        const _ = Object.values(r.columns).map((w) => w.columns[0]);
        b5(p, _);
      }
      const m = d.toString(), y = `cube_index_${(h5(m) >>> 0).toString(16)}`, b = a.exec(uy(y, m, { temp: c }));
      o.set(f, { table: y, result: b, ...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 } = i, a = Et.select(s, o).from(r).groupby(s).where(n);
    return this.mc.updateClient(t, a);
  }
}
function y5(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) => m5(u, o));
    if (l.some((u) => u == null))
      return null;
    l.length === 1 ? (a = (u) => u ? Dn("active0", u.range.map(l[0])) : [], i = { active0: l[0](e.predicate.field) }) : (a = (u) => u ? Yo(u.children.map(({ range: f }, h) => Dn(`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 = B3, i = Object.fromEntries(i.map((l) => [l.toString(), l]));
  else
    return null;
  return { source: t, columns: i, predicate: a };
}
function m5(e, t) {
  const { type: n, domain: i, range: r } = e;
  let s, o;
  switch (n) {
    case "linear":
      s = B3, o = fe;
      break;
    case "log":
      s = Math.log, o = (a) => q`LN(${fe(a)})`;
      break;
    case "symlog":
      s = (a) => Math.sign(a) * Math.log1p(Math.abs(a)), o = (a) => (a = fe(a), q`SIGN(${a}) * LN(1 + ABS(${a}))`);
      break;
    case "sqrt":
      s = Math.sqrt, o = (a) => q`SQRT(${fe(a)})`;
      break;
    case "utc":
    case "time":
      s = (a) => +a, o = (a) => a instanceof Date ? +a : $3(fe(a));
      break;
  }
  return s ? g5(i, r, t, s, o) : null;
}
function g5(e, t, n, i, r) {
  const s = i(Math.min(e[0], e[1])), o = i(Math.max(e[0], e[1])), a = Math.abs(i(t[1]) - i(t[0])) / (o - s) / n, c = n === 1 ? "" : `${n}::INTEGER * `;
  return (l) => q`${c}FLOOR(${a}::DOUBLE * (${r(l)} - ${s}::DOUBLE))::INTEGER`;
}
const hv = { from: NaN };
function dv(e) {
  if (!e.filterIndexable)
    return hv;
  const t = e.query(), n = Km(t);
  if (!n || !t.groupby)
    return hv;
  const i = new Set(t.groupby().map((a) => a.column)), r = [], s = [];
  let o;
  for (const { as: a, expr: { aggregate: c } } of t.select())
    switch (c == null ? void 0 : c.toUpperCase()) {
      case "COUNT":
      case "SUM":
        r.push({ [a]: q`SUM("${a}")::DOUBLE` });
        break;
      case "AVG":
        o = "_count_", r.push({ [a]: q`(SUM("${a}" * ${o}) / SUM(${o}))::DOUBLE` });
        break;
      case "MAX":
        r.push({ [a]: q`MAX("${a}")` });
        break;
      case "MIN":
        r.push({ [a]: q`MIN("${a}")` });
        break;
      default:
        if (i.has(a))
          s.push(a);
        else
          return null;
    }
  return {
    aggr: r,
    dims: s,
    count: o ? { [o]: q`COUNT(*)` } : {},
    from: n
  };
}
function Km(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 = Km(t[0]);
  for (let i = 1; i < t.length; ++i) {
    const r = Km(t[i]);
    if (r !== void 0 && r !== n)
      return NaN;
  }
  return n;
}
function b5(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 _5 {
  /**
   * @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 p5(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() : w5(t, i, r);
  }
}
function w5(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 N3() {
  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 v5(e, t, n) {
  let i = [], r = 0;
  function s() {
    const o = x5(i, t);
    i = [], r = 0;
    for (const a of o)
      I5(a, e, n), $5(a, t);
  }
  return {
    add(o, a) {
      o.request.type === "arrow" ? (r = r || requestAnimationFrame(() => s()), i.push({ entry: o, priority: a, index: i.length })) : e(o, a);
    }
  };
}
function x5(e, t) {
  const n = [], i = /* @__PURE__ */ new Map();
  for (const r of e) {
    const { entry: { request: s } } = r, o = S5(s.query, t);
    if (!i.has(o)) {
      const a = [];
      n.push(a), i.set(o, a);
    }
    i.get(o).push(r);
  }
  return n;
}
function S5(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 Cs && s[o.column] || o));
    }
    return `${i}`;
  } else
    return n;
}
function I5(e, t, n) {
  if (A5(e))
    t({
      request: {
        type: "arrow",
        cache: !1,
        record: !1,
        query: M5(e, n)
      },
      result: e.result = N3()
    });
  else
    for (const { entry: i, priority: r } of e)
      t(i, r);
}
function A5(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 M5(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 Cs && o[a.column] || a));
  }
  return r.$select(Array.from(i.values()));
}
async function $5(e, t) {
  const { maps: n, result: i } = e;
  if (!n)
    return;
  let r;
  try {
    r = await i;
  } catch (s) {
    for (const { entry: o } of e)
      o.result.reject(s);
    return;
  }
  e.forEach(({ entry: s }, o) => {
    const { request: a, result: c } = s, l = T5(r, n[o]);
    a.cache && t.set(String(a.query), l), c.fulfill(l);
  });
}
function T5(e, t) {
  if (t) {
    const n = {};
    for (const [i, r] of t)
      n[r] = e.getChild(i);
    return new e.constructor(n);
  } else
    return e;
}
const B5 = typeof requestIdleCallback < "u" ? requestIdleCallback : setTimeout, N5 = () => ({
  get: () => {
  },
  set: (e, t) => t,
  clear: () => {
  }
});
function F5({
  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 && B5(i), s;
    },
    clear() {
      n = /* @__PURE__ */ new Map();
    }
  };
}
function D5(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 gs = { High: 0, Normal: 1, Low: 2 };
function E5() {
  const e = D5(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 = gs.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: m = !1, record: g = !0, options: y } = f, b = d ? `${d}` : null;
      if (g && l(b), m) {
        const x = n.get(b);
        if (x) {
          i.debug("Cache"), h.fulfill(x);
          return;
        }
      }
      const _ = performance.now(), w = await t.query({ type: p, sql: b, ...y });
      m && n.set(b, w), i.debug(`Request: ${(performance.now() - _).toFixed(1)}`), h.fulfill(w);
    } catch (d) {
      h.reject(d);
    }
  }
  return {
    cache(f) {
      return f !== void 0 ? n = f === !0 ? F5() : f || N5() : n;
    },
    logger(f) {
      return f ? i = f : i;
    },
    connector(f) {
      return f ? t = f : t;
    },
    consolidate(f) {
      f && !o ? o = v5(c, n, l) : !f && o && (o = null);
    },
    request(f, h = gs.Normal) {
      const d = N3(), 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 O5() {
  return {
    debug() {
    },
    info() {
    },
    log() {
    },
    warn() {
    },
    error() {
    }
  };
}
let Lf;
function qn(e) {
  return e ? Lf = e : Lf == null && (Lf = new L5()), Lf;
}
class L5 {
  constructor(t = lO(), n = {}) {
    this.catalog = new l5(this), this.manager = n.manager || E5(), this.logger(n.logger || console), this.configure(n), this.databaseConnector(t), this.clear();
  }
  logger(t) {
    return arguments.length && (this._logger = t || O5(), 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, catalog: i = !1 } = {}) {
    var r, s;
    this.manager.clear(), t && ((r = this.clients) == null || r.forEach((o) => this.disconnect(o)), (s = this.filterGroups) == null || s.forEach((o) => o.finalize()), this.clients = /* @__PURE__ */ new Set(), this.filterGroups = /* @__PURE__ */ new Map()), n && this.manager.cache().clear(), i && this.catalog.clear();
  }
  databaseConnector(t) {
    return this.manager.connector(t);
  }
  // -- Query Management ----
  cancel(t) {
    this.manager.cancel(t);
  }
  exec(t, { priority: n = gs.Normal } = {}) {
    return this.manager.request({ type: "exec", query: t }, n);
  }
  query(t, {
    type: n = "arrow",
    cache: i = !0,
    priority: r = gs.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: gs.Low });
  }
  createBundle(t, n, i = gs.Low) {
    const r = { name: t, queries: n };
    return this.manager.request({ type: "create-bundle", options: r }, i);
  }
  loadBundle(t, n = gs.High) {
    const i = { name: t };
    return this.manager.request({ type: "load-bundle", options: i }, n);
  }
  // -- Client Management ----
  updateClient(t, n, i = gs.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 { catalog: n, clients: i, filterGroups: r, indexes: s } = this;
    if (i.has(t))
      throw new Error("Client already connected.");
    i.add(t);
    const o = t.fields();
    o != null && o.length && t.fieldInfo(await n.queryFields(o));
    const a = t.filterBy;
    if (a)
      if (r.has(a))
        r.get(a).add(t);
      else {
        const c = new _5(this, a, s);
        r.set(a, c.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));
  }
}
const pv = {};
function F3(e, t = !1) {
  let n, i, r = pv;
  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 = pv, a(u);
    }), r = l;
  }
  return t ? c : a;
}
class Ku {
  /**
   * 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 = F3(() => this.requestQuery(), !0);
  }
  /**
   * 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 qn().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;
  }
}
class R5 {
  /**
   * 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 C5()
    }), 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 C5 {
  /**
   * 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 D3(e, t) {
  return e === t ? !1 : e instanceof Date && t instanceof Date ? +e != +t : Array.isArray(e) && Array.isArray(t) ? k5(e, t) : !0;
}
function k5(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 Ns(e) {
  return e instanceof qr;
}
class qr extends R5 {
  /**
   * 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 qr(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) => Ns(n))) {
      const n = new qr(), i = () => n.update(t.map((r) => Ns(r) ? r.value : r));
      return i(), t.forEach((r) => Ns(r) ? r.addEventListener("value", i) : 0), n;
    }
    return new qr(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 D3(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 qo(e) {
  return e instanceof Ms;
}
let Ms = class Da extends qr {
  /**
   * 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 Da(new dl({ 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 Da(new dl({ 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 Da(new dl({ 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 Da(new dl({ cross: !0 }));
  }
  /**
   * Create a new Selection instance.
   * @param {SelectionResolver} resolver The selection resolution
   *  strategy to apply.
   */
  constructor(t = new dl()) {
    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 Da(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 dl {
  /**
   * 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 ? S3(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 U5() {
  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;
    }
  };
}
function fy(e, t) {
  const n = new e(t);
  return qn().connect(n), n.element;
}
const z5 = (e) => e && typeof e == "object" && !Array.isArray(e), P5 = (e) => fy(V5, e);
class V5 extends Ku {
  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((m) => z5(m) ? m : { value: m }), 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);
    }), qo(this.selection) || this.selection.addEventListener("value", (m) => {
      m !== this.select.value && this.selectedValue(m);
    }));
  }
  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;
    qo(n) ? n.update({
      source: this,
      schema: { type: "point" },
      value: t,
      predicate: t ? W1(i, Xu(t)) : null
    }) : Ns(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 j5 = { contains: bO, prefix: _O, suffix: wO, regexp: gO };
let Y5 = 0;
const q5 = (e) => fy(W5, e);
class W5 extends Ku {
  constructor({
    element: t,
    filterBy: n,
    from: i,
    column: r,
    label: s,
    type: o = "contains",
    as: a
  } = {}) {
    if (super(n), this.id = "search_" + ++Y5, 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);
    }), qo(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;
    qo(n) ? n.update({
      source: this,
      schema: { type: r },
      value: t,
      predicate: t ? j5[r](i, Xu(t)) : null
    }) : Ns(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 G5 = 0;
const X5 = (e) => fy(H5, e);
class H5 extends Ku {
  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_" + ++G5, 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);
    }), qo(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: bc(i), max: gc(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;
    qo(n) ? n.update({
      source: this,
      schema: { type: "point" },
      value: t,
      predicate: W1(i, Xu(t))
    }) : Ns(this.selection) && n.update(t);
  }
}
function E3(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 `${K5(e.getUTCFullYear())}-${Or(e.getUTCMonth() + 1, 2)}-${Or(e.getUTCDate(), 2)}${n || i || r || s ? `T${Or(n, 2)}:${Or(i, 2)}${r || s ? `:${Or(r, 2)}${s ? `.${Or(s, 3)}` : ""}` : ""}Z` : ""}`;
}
function K5(e) {
  return e < 0 ? `-${Or(-e, 6)}` : e > 9999 ? `+${Or(e, 6)}` : Or(e, 4);
}
function Or(e, t) {
  return `${e}`.padStart(t, "0");
}
const Z5 = /^(?:[-+]\d{2})?\d{4}(?:-\d{2}(?:-\d{2})?)?(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d{3})?)?(?:Z|[-+]\d{2}:?\d{2})?)?$/;
function X1(e, t) {
  return Z5.test(e += "") ? new Date(e) : typeof t == "function" ? t(e) : t;
}
const O3 = K1((e) => {
  const t = H1(e);
  return (n) => n == null ? "" : typeof n == "number" ? t(n) : n instanceof Date ? L3(n) : `${n}`;
}), H1 = K1((e) => (t) => t === 0 ? "0" : t.toLocaleString(e));
O3();
H1();
function L3(e) {
  return E3(e, "Invalid Date");
}
function K1(e) {
  let t = K1, n;
  return (i = "en") => i === t ? n : n = e(t = i);
}
let J5 = -1;
const Q5 = (e) => fy(tL, e);
let tL = class extends Ku {
  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-${++J5}`, 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: m, scrollTop: g, clientHeight: y } = h.target, b = g < f;
      f = g, !(b || d || p) && m - g < 2 * y && (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), qn().prefetch(n.clone().offset(t + this.limit));
  }
  fields() {
    return this.columns.map((t) => q1(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 = eL(this.format, t), this.style.innerText = rL(
      this.id,
      nL(this.align, t),
      iL(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 ? dO(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 eL(e = {}, t, n) {
  return t.map(({ column: i, type: r }) => {
    if (i in e)
      return e[i];
    switch (r) {
      case "number":
        return H1(n);
      case "date":
        return L3;
      default:
        return O3(n);
    }
  });
}
function nL(e = {}, t) {
  return t.map(({ column: n, type: i }) => n in e ? e[n] : i === "number" ? "right" : "left");
}
function iL(e = {}, t) {
  return t.map(({ column: n }) => e[n]);
}
function rL(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(" ");
}
const Z1 = Symbol("Fixed"), Wo = Symbol("Transient"), R3 = Symbol("Transform"), sL = [
  "rectY-x",
  "rectX-y",
  "rect-x",
  "rect-y"
];
function oL(e, t) {
  return sL.includes(`${t}-${e}`);
}
function yv(e, t = { steps: 25 }) {
  const n = (i, r) => oL(r, i.type) ? {
    [`${r}1`]: N0(i, e, t),
    [`${r}2`]: N0(i, e, { ...t, offset: 1 })
  } : {
    [r]: N0(i, e, t)
  };
  return n[R3] = !0, n;
}
function N0(e, t, n) {
  return {
    column: t,
    label: t,
    get stats() {
      return ["min", "max"];
    },
    get columns() {
      return [t];
    },
    get basis() {
      return t;
    },
    toString() {
      const { min: i, max: r } = e.stats[t], s = aL(i, r, n), o = fe(t), a = s.min === 0 ? o : `(${o} - ${s.min})`, c = `${(s.max - s.min) / s.steps}::DOUBLE`, l = n.offset ? `${n.offset} + ` : "";
      return `${i} + ${c} * (${l}FLOOR(${a} / ${c})::INTEGER)`;
    }
  };
}
function aL(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 m = 0, g = f.length; m < g; ++m)
      h = u / f[m], 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 };
}
function Be(e, t) {
  return e == null || t == null ? NaN : e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN;
}
function Zu(e, t) {
  return e == null || t == null ? NaN : t < e ? -1 : t > e ? 1 : t >= e ? 0 : NaN;
}
function du(e) {
  let t, n, i;
  e.length !== 2 ? (t = Be, n = (a, c) => Be(e(a), c), i = (a, c) => e(a) - c) : (t = e === Be || e === Zu ? e : cL, 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 cL() {
  return 0;
}
function C3(e) {
  return e === null ? NaN : +e;
}
function* lL(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 uL = du(Be), fL = uL.right;
du(C3).center;
const hy = fL, k3 = U3(z3), hL = U3(dL);
function U3(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 ? (la(a, l, r, s, o), la(a, r, l, s, o), la(a, l, r, s, o), ua(c, r, l, s, o), ua(c, l, r, s, o), ua(c, r, l, s, o)) : a ? (la(a, r, l, s, o), la(a, l, r, s, o), la(a, r, l, s, o)) : c && (ua(c, r, l, s, o), ua(c, l, r, s, o), ua(c, r, l, s, o)), t;
  };
}
function la(e, t, n, i, r) {
  for (let s = 0, o = i * r; s < o; )
    e(t, n, s, s += i, 1);
}
function ua(e, t, n, i, r) {
  for (let s = 0, o = i * r; s < i; ++s)
    e(t, n, s, s + o, i);
}
function dL(e) {
  const t = z3(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 z3(e) {
  const t = Math.floor(e);
  if (t === e)
    return pL(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 pL(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 dy(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 yL(e) {
  return e.length | 0;
}
function mL(e) {
  return !(e > 0);
}
function gL(e) {
  return typeof e != "object" || "length" in e ? e : Array.from(e);
}
function bL(e) {
  return (t) => e(...t);
}
function _L(...e) {
  const t = typeof e[e.length - 1] == "function" && bL(e.pop());
  e = e.map(gL);
  const n = e.map(yL), i = e.length - 1, r = new Array(i + 1).fill(0), s = [];
  if (i < 0 || n.some(mL))
    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 wL(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 J1(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 py(e, t) {
  const n = J1(e, t);
  return n && Math.sqrt(n);
}
function je(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 tr {
  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 Go extends Map {
  constructor(t, n = j3) {
    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(Zm(this, t));
  }
  has(t) {
    return super.has(Zm(this, t));
  }
  set(t, n) {
    return super.set(P3(this, t), n);
  }
  delete(t) {
    return super.delete(V3(this, t));
  }
}
class yy extends Set {
  constructor(t, n = j3) {
    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(Zm(this, t));
  }
  add(t) {
    return super.add(P3(this, t));
  }
  delete(t) {
    return super.delete(V3(this, t));
  }
}
function Zm({ _intern: e, _key: t }, n) {
  const i = t(n);
  return e.has(i) ? e.get(i) : n;
}
function P3({ _intern: e, _key: t }, n) {
  const i = t(n);
  return e.has(i) ? e.get(i) : (e.set(i, n), n);
}
function V3({ _intern: e, _key: t }, n) {
  const i = t(n);
  return e.has(i) && (n = e.get(i), e.delete(i)), n;
}
function j3(e) {
  return e !== null && typeof e == "object" ? e.valueOf() : e;
}
function Jm(e) {
  return e;
}
function os(e, ...t) {
  return Q1(e, Jm, Jm, t);
}
function Xa(e, t, ...n) {
  return Q1(e, Jm, t, n);
}
function vL(e, t, ...n) {
  return Q1(e, Array.from, t, n);
}
function Q1(e, t, n, i) {
  return function r(s, o) {
    if (o >= i.length)
      return n(s);
    const a = new Go(), 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 xL(e, t) {
  return Array.from(t, (n) => e[n]);
}
function pu(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 = yu(o[r], o[s]);
        if (a)
          return a;
      }
    })) : (n = e.map(n), i.sort((r, s) => yu(n[r], n[s]))), xL(e, i);
  }
  return e.sort(tb(n));
}
function tb(e = Be) {
  if (e === Be)
    return yu;
  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 yu(e, t) {
  return (e == null || !(e >= e)) - (t == null || !(t >= t)) || (e < t ? -1 : e > t ? 1 : 0);
}
function eb(e, t, n) {
  return (t.length !== 2 ? pu(Xa(e, t, n), ([i, r], [s, o]) => Be(r, o) || Be(i, s)) : pu(os(e, n), ([i, r], [s, o]) => t(r, o) || Be(i, s))).map(([i]) => i);
}
const SL = Math.sqrt(50), IL = Math.sqrt(10), AL = Math.sqrt(2);
function vd(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 >= SL ? 10 : s >= IL ? 5 : s >= AL ? 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 ? vd(e, t, n * 2) : [a, c, l];
}
function ks(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 ? vd(t, e, n) : vd(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 mu(e, t, n) {
  return t = +t, e = +e, n = +n, vd(e, t, n)[2];
}
function Qm(e, t, n) {
  t = +t, e = +e, n = +n;
  const i = t < e, r = i ? mu(t, e, n) : mu(e, t, n);
  return (i ? -1 : 1) * (r < 0 ? 1 / -r : r);
}
function Y3(e, t, n) {
  let i;
  for (; ; ) {
    const r = mu(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 nb(e) {
  return Math.max(1, Math.ceil(Math.log(dy(e)) / Math.LN2) + 1);
}
function Se(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 ML(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 ze(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 $L(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 q3(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 ? yu : tb(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));
      q3(e, t, d, p, r);
    }
    const s = e[t];
    let o = n, a = i;
    for (pl(e, n, t), r(e[i], s) > 0 && pl(e, n, i); o < a; ) {
      for (pl(e, o, a), ++o, --a; r(e[o], s) < 0; )
        ++o;
      for (; r(e[a], s) > 0; )
        --a;
    }
    r(e[n], s) === 0 ? pl(e, n, a) : (++a, pl(e, a, i)), a <= t && (n = a + 1), t <= a && (i = a - 1);
  }
  return e;
}
function pl(e, t, n) {
  const i = e[t];
  e[t] = e[n], e[n] = i;
}
function ib(e, t = Be) {
  let n, i = !1;
  if (t.length === 1) {
    let r;
    for (const s of e) {
      const o = t(s);
      (i ? Be(o, r) > 0 : Be(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 Us(e, t, n) {
  if (e = Float64Array.from(lL(e, n)), !(!(i = e.length) || isNaN(t = +t))) {
    if (t <= 0 || i < 2)
      return ze(e);
    if (t >= 1)
      return Se(e);
    var i, r = (i - 1) * t, s = Math.floor(r), o = Se(q3(e, s).subarray(0, s + 1)), a = ze(e.subarray(s + 1));
    return o + (a - o) * (r - s);
  }
}
function TL(e, t, n = C3) {
  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 BL(e, t, n) {
  const i = dy(e), r = Us(e, 0.75) - Us(e, 0.25);
  return i && r ? Math.ceil((n - t) / (2 * r * Math.pow(i, -1 / 3))) : 1;
}
function W3(e, t, n) {
  const i = dy(e), r = py(e);
  return i && r ? Math.ceil((n - t) * Math.cbrt(i) / (3.49 * r)) : 1;
}
function rb(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 _c(e, t) {
  return Us(e, 0.5, t);
}
function* NL(e) {
  for (const t of e)
    yield* t;
}
function G3(e) {
  return Array.from(NL(e));
}
function X3(e, t) {
  const n = new Go();
  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 FL(e, t = DL) {
  const n = [];
  let i, r = !1;
  for (const s of e)
    r && n.push(t(i, s)), i = s, r = !0;
  return n;
}
function DL(e, t) {
  return [e, t];
}
function Bn(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 H3(e, t = Be) {
  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 = Be);
  const r = (a, c) => t(n[a], n[c]);
  let s, o;
  return e = Uint32Array.from(n, (a, c) => c), e.sort(t === Be ? (a, c) => yu(n[a], n[c]) : tb(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 EL(e, t = Be) {
  let n, i = !1;
  if (t.length === 1) {
    let r;
    for (const s of e) {
      const o = t(s);
      (i ? Be(o, r) < 0 : Be(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 sr(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 xd(e) {
  if (typeof e[Symbol.iterator] != "function")
    throw new TypeError("values is not iterable");
  return Array.from(e).reverse();
}
function OL(e) {
  return e;
}
var F0 = 1, D0 = 2, tg = 3, Rf = 4, mv = 1e-6;
function LL(e) {
  return "translate(" + e + ",0)";
}
function RL(e) {
  return "translate(0," + e + ")";
}
function CL(e) {
  return (t) => +e(t);
}
function kL(e, t) {
  return t = Math.max(0, e.bandwidth() - t * 2) / 2, e.round() && (t = Math.round(t)), (n) => +e(n) + t;
}
function UL() {
  return !this.__axis;
}
function zL(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 === F0 || e === Rf ? -1 : 1, u = e === Rf || e === D0 ? "x" : "y", f = e === F0 || e === tg ? LL : RL;
  function h(d) {
    var p = i ?? (t.ticks ? t.ticks.apply(t, n) : t.domain()), m = r ?? (t.tickFormat ? t.tickFormat.apply(t, n) : OL), g = Math.max(s, 0) + a, y = t.range(), b = +y[0] + c, _ = +y[y.length - 1] + c, w = (t.bandwidth ? kL : CL)(t.copy(), c), x = d.selection ? d.selection() : d, v = x.selectAll(".domain").data([null]), I = x.selectAll(".tick").data(p, t).order(), T = I.exit(), F = I.enter().append("g").attr("class", "tick"), A = I.select("line"), $ = I.select("text");
    v = v.merge(v.enter().insert("path", ".tick").attr("class", "domain").attr("stroke", "currentColor")), I = I.merge(F), A = A.merge(F.append("line").attr("stroke", "currentColor").attr(u + "2", l * s)), $ = $.merge(F.append("text").attr("fill", "currentColor").attr(u, l * g).attr("dy", e === F0 ? "0em" : e === tg ? "0.71em" : "0.32em")), d !== x && (v = v.transition(d), I = I.transition(d), A = A.transition(d), $ = $.transition(d), T = T.transition(d).attr("opacity", mv).attr("transform", function(D) {
      return isFinite(D = w(D)) ? f(D + c) : this.getAttribute("transform");
    }), F.attr("opacity", mv).attr("transform", function(D) {
      var O = this.parentNode.__axis;
      return f((O && isFinite(O = O(D)) ? O : w(D)) + c);
    })), T.remove(), v.attr("d", e === Rf || e === D0 ? o ? "M" + l * o + "," + b + "H" + c + "V" + _ + "H" + l * o : "M" + c + "," + b + "V" + _ : o ? "M" + b + "," + l * o + "V" + c + "H" + _ + "V" + l * o : "M" + b + "," + c + "H" + _), I.attr("opacity", 1).attr("transform", function(D) {
      return f(w(D) + c);
    }), A.attr(u + "2", l * s), $.attr(u, l * g).text(m), x.filter(UL).attr("fill", "none").attr("font-size", 10).attr("font-family", "sans-serif").attr("text-anchor", e === D0 ? "start" : e === Rf ? "end" : "middle"), x.each(function() {
      this.__axis = w;
    });
  }
  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 PL(e) {
  return zL(tg, e);
}
var VL = { value: () => {
} };
function my() {
  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 Mh(n);
}
function Mh(e) {
  this._ = e;
}
function jL(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 };
  });
}
Mh.prototype = my.prototype = {
  constructor: Mh,
  on: function(e, t) {
    var n = this._, i = jL(e + "", n), r, s = -1, o = i.length;
    if (arguments.length < 2) {
      for (; ++s < o; )
        if ((r = (e = i[s]).type) && (r = YL(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] = gv(n[r], e.name, t);
      else if (t == null)
        for (r in n)
          n[r] = gv(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 Mh(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 YL(e, t) {
  for (var n = 0, i = e.length, r; n < i; ++n)
    if ((r = e[n]).name === t)
      return r.value;
}
function gv(e, t, n) {
  for (var i = 0, r = e.length; i < r; ++i)
    if (e[i].name === t) {
      e[i] = VL, e = e.slice(0, i).concat(e.slice(i + 1));
      break;
    }
  return n != null && e.push({ name: t, value: n }), e;
}
var eg = "http://www.w3.org/1999/xhtml";
const Xo = {
  svg: "http://www.w3.org/2000/svg",
  xhtml: eg,
  xlink: "http://www.w3.org/1999/xlink",
  xml: "http://www.w3.org/XML/1998/namespace",
  xmlns: "http://www.w3.org/2000/xmlns/"
};
function gy(e) {
  var t = e += "", n = t.indexOf(":");
  return n >= 0 && (t = e.slice(0, n)) !== "xmlns" && (e = e.slice(n + 1)), Xo.hasOwnProperty(t) ? { space: Xo[t], local: e } : e;
}
function qL(e) {
  return function() {
    var t = this.ownerDocument, n = this.namespaceURI;
    return n === eg && t.documentElement.namespaceURI === eg ? t.createElement(e) : t.createElementNS(n, e);
  };
}
function WL(e) {
  return function() {
    return this.ownerDocument.createElementNS(e.space, e.local);
  };
}
function by(e) {
  var t = gy(e);
  return (t.local ? WL : qL)(t);
}
function GL() {
}
function sb(e) {
  return e == null ? GL : function() {
    return this.querySelector(e);
  };
}
function XL(e) {
  typeof e != "function" && (e = sb(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 En(i, this._parents);
}
function HL(e) {
  return e == null ? [] : Array.isArray(e) ? e : Array.from(e);
}
function KL() {
  return [];
}
function K3(e) {
  return e == null ? KL : function() {
    return this.querySelectorAll(e);
  };
}
function ZL(e) {
  return function() {
    return HL(e.apply(this, arguments));
  };
}
function JL(e) {
  typeof e == "function" ? e = ZL(e) : e = K3(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 En(i, r);
}
function Z3(e) {
  return function() {
    return this.matches(e);
  };
}
function J3(e) {
  return function(t) {
    return t.matches(e);
  };
}
var QL = Array.prototype.find;
function tR(e) {
  return function() {
    return QL.call(this.children, e);
  };
}
function eR() {
  return this.firstElementChild;
}
function nR(e) {
  return this.select(e == null ? eR : tR(typeof e == "function" ? e : J3(e)));
}
var iR = Array.prototype.filter;
function rR() {
  return Array.from(this.children);
}
function sR(e) {
  return function() {
    return iR.call(this.children, e);
  };
}
function oR(e) {
  return this.selectAll(e == null ? rR : sR(typeof e == "function" ? e : J3(e)));
}
function aR(e) {
  typeof e != "function" && (e = Z3(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 En(i, this._parents);
}
function Q3(e) {
  return new Array(e.length);
}
function cR() {
  return new En(this._enter || this._groups.map(Q3), this._parents);
}
function Sd(e, t) {
  this.ownerDocument = e.ownerDocument, this.namespaceURI = e.namespaceURI, this._next = null, this._parent = e, this.__data__ = t;
}
Sd.prototype = {
  constructor: Sd,
  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 lR(e) {
  return function() {
    return e;
  };
}
function uR(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 Sd(e, s[o]);
  for (; o < c; ++o)
    (a = t[o]) && (r[o] = a);
}
function fR(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 Sd(e, s[a]);
  for (a = 0; a < u; ++a)
    (c = t[a]) && l.get(h[a]) === c && (r[a] = c);
}
function hR(e) {
  return e.__data__;
}
function dR(e, t) {
  if (!arguments.length)
    return Array.from(this, hR);
  var n = t ? fR : uR, i = this._parents, r = this._groups;
  typeof e != "function" && (e = lR(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 = pR(e.call(u, u && u.__data__, l, i)), p = d.length, m = a[l] = new Array(p), g = o[l] = new Array(p), y = c[l] = new Array(h);
    n(u, f, m, g, y, d, t);
    for (var b = 0, _ = 0, w, x; b < p; ++b)
      if (w = m[b]) {
        for (b >= _ && (_ = b + 1); !(x = g[_]) && ++_ < p; )
          ;
        w._next = x || null;
      }
  }
  return o = new En(o, i), o._enter = a, o._exit = c, o;
}
function pR(e) {
  return typeof e == "object" && "length" in e ? e : Array.from(e);
}
function yR() {
  return new En(this._exit || this._groups.map(Q3), this._parents);
}
function mR(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 gR(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 En(a, this._parents);
}
function bR() {
  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 _R(e) {
  e || (e = wR);
  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 En(r, this._parents).order();
}
function wR(e, t) {
  return e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN;
}
function vR() {
  var e = arguments[0];
  return arguments[0] = this, e.apply(null, arguments), this;
}
function xR() {
  return Array.from(this);
}
function SR() {
  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 IR() {
  let e = 0;
  for (const t of this)
    ++e;
  return e;
}
function AR() {
  return !this.node();
}
function MR(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 $R(e) {
  return function() {
    this.removeAttribute(e);
  };
}
function TR(e) {
  return function() {
    this.removeAttributeNS(e.space, e.local);
  };
}
function BR(e, t) {
  return function() {
    this.setAttribute(e, t);
  };
}
function NR(e, t) {
  return function() {
    this.setAttributeNS(e.space, e.local, t);
  };
}
function FR(e, t) {
  return function() {
    var n = t.apply(this, arguments);
    n == null ? this.removeAttribute(e) : this.setAttribute(e, n);
  };
}
function DR(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 ER(e, t) {
  var n = gy(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 ? TR : $R : typeof t == "function" ? n.local ? DR : FR : n.local ? NR : BR)(n, t));
}
function tA(e) {
  return e.ownerDocument && e.ownerDocument.defaultView || e.document && e || e.defaultView;
}
function OR(e) {
  return function() {
    this.style.removeProperty(e);
  };
}
function LR(e, t, n) {
  return function() {
    this.style.setProperty(e, t, n);
  };
}
function RR(e, t, n) {
  return function() {
    var i = t.apply(this, arguments);
    i == null ? this.style.removeProperty(e) : this.style.setProperty(e, i, n);
  };
}
function CR(e, t, n) {
  return arguments.length > 1 ? this.each((t == null ? OR : typeof t == "function" ? RR : LR)(e, t, n ?? "")) : wc(this.node(), e);
}
function wc(e, t) {
  return e.style.getPropertyValue(t) || tA(e).getComputedStyle(e, null).getPropertyValue(t);
}
function kR(e) {
  return function() {
    delete this[e];
  };
}
function UR(e, t) {
  return function() {
    this[e] = t;
  };
}
function zR(e, t) {
  return function() {
    var n = t.apply(this, arguments);
    n == null ? delete this[e] : this[e] = n;
  };
}
function PR(e, t) {
  return arguments.length > 1 ? this.each((t == null ? kR : typeof t == "function" ? zR : UR)(e, t)) : this.node()[e];
}
function eA(e) {
  return e.trim().split(/^|\s+/);
}
function ob(e) {
  return e.classList || new nA(e);
}
function nA(e) {
  this._node = e, this._names = eA(e.getAttribute("class") || "");
}
nA.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 iA(e, t) {
  for (var n = ob(e), i = -1, r = t.length; ++i < r; )
    n.add(t[i]);
}
function rA(e, t) {
  for (var n = ob(e), i = -1, r = t.length; ++i < r; )
    n.remove(t[i]);
}
function VR(e) {
  return function() {
    iA(this, e);
  };
}
function jR(e) {
  return function() {
    rA(this, e);
  };
}
function YR(e, t) {
  return function() {
    (t.apply(this, arguments) ? iA : rA)(this, e);
  };
}
function qR(e, t) {
  var n = eA(e + "");
  if (arguments.length < 2) {
    for (var i = ob(this.node()), r = -1, s = n.length; ++r < s; )
      if (!i.contains(n[r]))
        return !1;
    return !0;
  }
  return this.each((typeof t == "function" ? YR : t ? VR : jR)(n, t));
}
function WR() {
  this.textContent = "";
}
function GR(e) {
  return function() {
    this.textContent = e;
  };
}
function XR(e) {
  return function() {
    var t = e.apply(this, arguments);
    this.textContent = t ?? "";
  };
}
function HR(e) {
  return arguments.length ? this.each(e == null ? WR : (typeof e == "function" ? XR : GR)(e)) : this.node().textContent;
}
function KR() {
  this.innerHTML = "";
}
function ZR(e) {
  return function() {
    this.innerHTML = e;
  };
}
function JR(e) {
  return function() {
    var t = e.apply(this, arguments);
    this.innerHTML = t ?? "";
  };
}
function QR(e) {
  return arguments.length ? this.each(e == null ? KR : (typeof e == "function" ? JR : ZR)(e)) : this.node().innerHTML;
}
function t7() {
  this.nextSibling && this.parentNode.appendChild(this);
}
function e7() {
  return this.each(t7);
}
function n7() {
  this.previousSibling && this.parentNode.insertBefore(this, this.parentNode.firstChild);
}
function i7() {
  return this.each(n7);
}
function r7(e) {
  var t = typeof e == "function" ? e : by(e);
  return this.select(function() {
    return this.appendChild(t.apply(this, arguments));
  });
}
function s7() {
  return null;
}
function o7(e, t) {
  var n = typeof e == "function" ? e : by(e), i = t == null ? s7 : typeof t == "function" ? t : sb(t);
  return this.select(function() {
    return this.insertBefore(n.apply(this, arguments), i.apply(this, arguments) || null);
  });
}
function a7() {
  var e = this.parentNode;
  e && e.removeChild(this);
}
function c7() {
  return this.each(a7);
}
function l7() {
  var e = this.cloneNode(!1), t = this.parentNode;
  return t ? t.insertBefore(e, this.nextSibling) : e;
}
function u7() {
  var e = this.cloneNode(!0), t = this.parentNode;
  return t ? t.insertBefore(e, this.nextSibling) : e;
}
function f7(e) {
  return this.select(e ? u7 : l7);
}
function h7(e) {
  return arguments.length ? this.property("__data__", e) : this.node().__data__;
}
function d7(e) {
  return function(t) {
    e.call(this, t, this.__data__);
  };
}
function p7(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 y7(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 m7(e, t, n) {
  return function() {
    var i = this.__on, r, s = d7(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 g7(e, t, n) {
  var i = p7(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 ? m7 : y7, r = 0; r < s; ++r)
    this.each(a(i[r], t, n));
  return this;
}
function sA(e, t, n) {
  var i = tA(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 b7(e, t) {
  return function() {
    return sA(this, e, t);
  };
}
function _7(e, t) {
  return function() {
    return sA(this, e, t.apply(this, arguments));
  };
}
function w7(e, t) {
  return this.each((typeof t == "function" ? _7 : b7)(e, t));
}
function* v7() {
  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 oA = [null];
function En(e, t) {
  this._groups = e, this._parents = t;
}
function Ju() {
  return new En([[document.documentElement]], oA);
}
function x7() {
  return this;
}
En.prototype = Ju.prototype = {
  constructor: En,
  select: XL,
  selectAll: JL,
  selectChild: nR,
  selectChildren: oR,
  filter: aR,
  data: dR,
  enter: cR,
  exit: yR,
  join: mR,
  merge: gR,
  selection: x7,
  order: bR,
  sort: _R,
  call: vR,
  nodes: xR,
  node: SR,
  size: IR,
  empty: AR,
  each: MR,
  attr: ER,
  style: CR,
  property: PR,
  classed: qR,
  text: HR,
  html: QR,
  raise: e7,
  lower: i7,
  append: r7,
  insert: o7,
  remove: c7,
  clone: f7,
  datum: h7,
  on: g7,
  dispatch: w7,
  [Symbol.iterator]: v7
};
function re(e) {
  return typeof e == "string" ? new En([[document.querySelector(e)]], [document.documentElement]) : new En([[e]], oA);
}
function S7(e) {
  let t;
  for (; t = e.sourceEvent; )
    e = t;
  return e;
}
function ci(e, t) {
  if (e = S7(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 ng = { capture: !0, passive: !1 };
function ig(e) {
  e.preventDefault(), e.stopImmediatePropagation();
}
function aA(e) {
  var t = e.document.documentElement, n = re(e).on("dragstart.drag", ig, ng);
  "onselectstart" in t ? n.on("selectstart.drag", ig, ng) : (t.__noselect = t.style.MozUserSelect, t.style.MozUserSelect = "none");
}
function cA(e, t) {
  var n = e.document.documentElement, i = re(e).on("dragstart.drag", null);
  t && (i.on("click.drag", ig, ng), 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 Xc(e, t, n) {
  e.prototype = t.prototype = n, n.constructor = e;
}
function Qu(e, t) {
  var n = Object.create(e.prototype);
  for (var i in t)
    n[i] = t[i];
  return n;
}
function Js() {
}
var Ho = 0.7, vc = 1 / Ho, Ha = "\\s*([+-]?\\d+)\\s*", gu = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", er = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", I7 = /^#([0-9a-f]{3,8})$/, A7 = new RegExp(`^rgb\\(${Ha},${Ha},${Ha}\\)$`), M7 = new RegExp(`^rgb\\(${er},${er},${er}\\)$`), $7 = new RegExp(`^rgba\\(${Ha},${Ha},${Ha},${gu}\\)$`), T7 = new RegExp(`^rgba\\(${er},${er},${er},${gu}\\)$`), B7 = new RegExp(`^hsl\\(${gu},${er},${er}\\)$`), N7 = new RegExp(`^hsla\\(${gu},${er},${er},${gu}\\)$`), bv = {
  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
};
Xc(Js, Jr, {
  copy(e) {
    return Object.assign(new this.constructor(), this, e);
  },
  displayable() {
    return this.rgb().displayable();
  },
  hex: _v,
  // Deprecated! Use color.formatHex.
  formatHex: _v,
  formatHex8: F7,
  formatHsl: D7,
  formatRgb: wv,
  toString: wv
});
function _v() {
  return this.rgb().formatHex();
}
function F7() {
  return this.rgb().formatHex8();
}
function D7() {
  return lA(this).formatHsl();
}
function wv() {
  return this.rgb().formatRgb();
}
function Jr(e) {
  var t, n;
  return e = (e + "").trim().toLowerCase(), (t = I7.exec(e)) ? (n = t[1].length, t = parseInt(t[1], 16), n === 6 ? vv(t) : n === 3 ? new Ue(t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | t & 240, (t & 15) << 4 | t & 15, 1) : n === 8 ? Cf(t >> 24 & 255, t >> 16 & 255, t >> 8 & 255, (t & 255) / 255) : n === 4 ? Cf(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 = A7.exec(e)) ? new Ue(t[1], t[2], t[3], 1) : (t = M7.exec(e)) ? new Ue(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, 1) : (t = $7.exec(e)) ? Cf(t[1], t[2], t[3], t[4]) : (t = T7.exec(e)) ? Cf(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, t[4]) : (t = B7.exec(e)) ? Iv(t[1], t[2] / 100, t[3] / 100, 1) : (t = N7.exec(e)) ? Iv(t[1], t[2] / 100, t[3] / 100, t[4]) : bv.hasOwnProperty(e) ? vv(bv[e]) : e === "transparent" ? new Ue(NaN, NaN, NaN, 0) : null;
}
function vv(e) {
  return new Ue(e >> 16 & 255, e >> 8 & 255, e & 255, 1);
}
function Cf(e, t, n, i) {
  return i <= 0 && (e = t = n = NaN), new Ue(e, t, n, i);
}
function ab(e) {
  return e instanceof Js || (e = Jr(e)), e ? (e = e.rgb(), new Ue(e.r, e.g, e.b, e.opacity)) : new Ue();
}
function ei(e, t, n, i) {
  return arguments.length === 1 ? ab(e) : new Ue(e, t, n, i ?? 1);
}
function Ue(e, t, n, i) {
  this.r = +e, this.g = +t, this.b = +n, this.opacity = +i;
}
Xc(Ue, ei, Qu(Js, {
  brighter(e) {
    return e = e == null ? vc : Math.pow(vc, e), new Ue(this.r * e, this.g * e, this.b * e, this.opacity);
  },
  darker(e) {
    return e = e == null ? Ho : Math.pow(Ho, e), new Ue(this.r * e, this.g * e, this.b * e, this.opacity);
  },
  rgb() {
    return this;
  },
  clamp() {
    return new Ue(zo(this.r), zo(this.g), zo(this.b), Id(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: xv,
  // Deprecated! Use color.formatHex.
  formatHex: xv,
  formatHex8: E7,
  formatRgb: Sv,
  toString: Sv
}));
function xv() {
  return `#${No(this.r)}${No(this.g)}${No(this.b)}`;
}
function E7() {
  return `#${No(this.r)}${No(this.g)}${No(this.b)}${No((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`;
}
function Sv() {
  const e = Id(this.opacity);
  return `${e === 1 ? "rgb(" : "rgba("}${zo(this.r)}, ${zo(this.g)}, ${zo(this.b)}${e === 1 ? ")" : `, ${e})`}`;
}
function Id(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 No(e) {
  return e = zo(e), (e < 16 ? "0" : "") + e.toString(16);
}
function Iv(e, t, n, i) {
  return i <= 0 ? e = t = n = NaN : n <= 0 || n >= 1 ? e = t = NaN : t <= 0 && (e = NaN), new hi(e, t, n, i);
}
function lA(e) {
  if (e instanceof hi)
    return new hi(e.h, e.s, e.l, e.opacity);
  if (e instanceof Js || (e = Jr(e)), !e)
    return new hi();
  if (e instanceof hi)
    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 hi(o, a, c, e.opacity);
}
function rg(e, t, n, i) {
  return arguments.length === 1 ? lA(e) : new hi(e, t, n, i ?? 1);
}
function hi(e, t, n, i) {
  this.h = +e, this.s = +t, this.l = +n, this.opacity = +i;
}
Xc(hi, rg, Qu(Js, {
  brighter(e) {
    return e = e == null ? vc : Math.pow(vc, e), new hi(this.h, this.s, this.l * e, this.opacity);
  },
  darker(e) {
    return e = e == null ? Ho : Math.pow(Ho, e), new hi(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 Ue(
      E0(e >= 240 ? e - 240 : e + 120, r, i),
      E0(e, r, i),
      E0(e < 120 ? e + 240 : e - 120, r, i),
      this.opacity
    );
  },
  clamp() {
    return new hi(Av(this.h), kf(this.s), kf(this.l), Id(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 = Id(this.opacity);
    return `${e === 1 ? "hsl(" : "hsla("}${Av(this.h)}, ${kf(this.s) * 100}%, ${kf(this.l) * 100}%${e === 1 ? ")" : `, ${e})`}`;
  }
}));
function Av(e) {
  return e = (e || 0) % 360, e < 0 ? e + 360 : e;
}
function kf(e) {
  return Math.max(0, Math.min(1, e || 0));
}
function E0(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 uA = Math.PI / 180, fA = 180 / Math.PI, Ad = 18, hA = 0.96422, dA = 1, pA = 0.82521, yA = 4 / 29, Ka = 6 / 29, mA = 3 * Ka * Ka, O7 = Ka * Ka * Ka;
function gA(e) {
  if (e instanceof nr)
    return new nr(e.l, e.a, e.b, e.opacity);
  if (e instanceof Ur)
    return bA(e);
  e instanceof Ue || (e = ab(e));
  var t = C0(e.r), n = C0(e.g), i = C0(e.b), r = O0((0.2225045 * t + 0.7168786 * n + 0.0606169 * i) / dA), s, o;
  return t === n && n === i ? s = o = r : (s = O0((0.4360747 * t + 0.3850649 * n + 0.1430804 * i) / hA), o = O0((0.0139322 * t + 0.0971045 * n + 0.7141733 * i) / pA)), new nr(116 * r - 16, 500 * (s - r), 200 * (r - o), e.opacity);
}
function sg(e, t, n, i) {
  return arguments.length === 1 ? gA(e) : new nr(e, t, n, i ?? 1);
}
function nr(e, t, n, i) {
  this.l = +e, this.a = +t, this.b = +n, this.opacity = +i;
}
Xc(nr, sg, Qu(Js, {
  brighter(e) {
    return new nr(this.l + Ad * (e ?? 1), this.a, this.b, this.opacity);
  },
  darker(e) {
    return new nr(this.l - Ad * (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 = hA * L0(t), e = dA * L0(e), n = pA * L0(n), new Ue(
      R0(3.1338561 * t - 1.6168667 * e - 0.4906146 * n),
      R0(-0.9787684 * t + 1.9161415 * e + 0.033454 * n),
      R0(0.0719453 * t - 0.2289914 * e + 1.4052427 * n),
      this.opacity
    );
  }
}));
function O0(e) {
  return e > O7 ? Math.pow(e, 1 / 3) : e / mA + yA;
}
function L0(e) {
  return e > Ka ? e * e * e : mA * (e - yA);
}
function R0(e) {
  return 255 * (e <= 31308e-7 ? 12.92 * e : 1.055 * Math.pow(e, 1 / 2.4) - 0.055);
}
function C0(e) {
  return (e /= 255) <= 0.04045 ? e / 12.92 : Math.pow((e + 0.055) / 1.055, 2.4);
}
function L7(e) {
  if (e instanceof Ur)
    return new Ur(e.h, e.c, e.l, e.opacity);
  if (e instanceof nr || (e = gA(e)), e.a === 0 && e.b === 0)
    return new Ur(NaN, 0 < e.l && e.l < 100 ? 0 : NaN, e.l, e.opacity);
  var t = Math.atan2(e.b, e.a) * fA;
  return new Ur(t < 0 ? t + 360 : t, Math.sqrt(e.a * e.a + e.b * e.b), e.l, e.opacity);
}
function og(e, t, n, i) {
  return arguments.length === 1 ? L7(e) : new Ur(e, t, n, i ?? 1);
}
function Ur(e, t, n, i) {
  this.h = +e, this.c = +t, this.l = +n, this.opacity = +i;
}
function bA(e) {
  if (isNaN(e.h))
    return new nr(e.l, 0, 0, e.opacity);
  var t = e.h * uA;
  return new nr(e.l, Math.cos(t) * e.c, Math.sin(t) * e.c, e.opacity);
}
Xc(Ur, og, Qu(Js, {
  brighter(e) {
    return new Ur(this.h, this.c, this.l + Ad * (e ?? 1), this.opacity);
  },
  darker(e) {
    return new Ur(this.h, this.c, this.l - Ad * (e ?? 1), this.opacity);
  },
  rgb() {
    return bA(this).rgb();
  }
}));
var _A = -0.14861, cb = 1.78277, lb = -0.29227, _y = -0.90649, bu = 1.97294, Mv = bu * _y, $v = bu * cb, Tv = cb * lb - _y * _A;
function R7(e) {
  if (e instanceof Po)
    return new Po(e.h, e.s, e.l, e.opacity);
  e instanceof Ue || (e = ab(e));
  var t = e.r / 255, n = e.g / 255, i = e.b / 255, r = (Tv * i + Mv * t - $v * n) / (Tv + Mv - $v), s = i - r, o = (bu * (n - r) - lb * s) / _y, a = Math.sqrt(o * o + s * s) / (bu * r * (1 - r)), c = a ? Math.atan2(o, s) * fA - 120 : NaN;
  return new Po(c < 0 ? c + 360 : c, a, r, e.opacity);
}
function or(e, t, n, i) {
  return arguments.length === 1 ? R7(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;
}
Xc(Po, or, Qu(Js, {
  brighter(e) {
    return e = e == null ? vc : Math.pow(vc, e), new Po(this.h, this.s, this.l * e, this.opacity);
  },
  darker(e) {
    return e = e == null ? Ho : Math.pow(Ho, e), new Po(this.h, this.s, this.l * e, this.opacity);
  },
  rgb() {
    var e = isNaN(this.h) ? 0 : (this.h + 120) * uA, t = +this.l, n = isNaN(this.s) ? 0 : this.s * t * (1 - t), i = Math.cos(e), r = Math.sin(e);
    return new Ue(
      255 * (t + n * (_A * i + cb * r)),
      255 * (t + n * (lb * i + _y * r)),
      255 * (t + n * (bu * i)),
      this.opacity
    );
  }
}));
function C7(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 k7(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 C7((n - i / t) * t, o, r, s, a);
  };
}
const wy = (e) => () => e;
function wA(e, t) {
  return function(n) {
    return e + n * t;
  };
}
function U7(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 ub(e, t) {
  var n = t - e;
  return n ? wA(e, n > 180 || n < -180 ? n - 360 * Math.round(n / 360) : n) : wy(isNaN(e) ? t : e);
}
function z7(e) {
  return (e = +e) == 1 ? Ke : function(t, n) {
    return n - t ? U7(t, n, e) : wy(isNaN(t) ? n : t);
  };
}
function Ke(e, t) {
  var n = t - e;
  return n ? wA(e, n) : wy(isNaN(e) ? t : e);
}
const Ko = function e(t) {
  var n = z7(t);
  function i(r, s) {
    var o = n((r = ei(r)).r, (s = ei(s)).r), a = n(r.g, s.g), c = n(r.b, s.b), l = Ke(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 P7(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 = ei(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 V7 = P7(k7);
function j7(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 Y7(e) {
  return ArrayBuffer.isView(e) && !(e instanceof DataView);
}
function q7(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] = Hc(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 W7(e, t) {
  var n = /* @__PURE__ */ new Date();
  return e = +e, t = +t, function(i) {
    return n.setTime(e * (1 - i) + t * i), n;
  };
}
function Xe(e, t) {
  return e = +e, t = +t, function(n) {
    return e * (1 - n) + t * n;
  };
}
function G7(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] = Hc(e[r], t[r]) : i[r] = t[r];
  return function(s) {
    for (r in n)
      i[r] = n[r](s);
    return i;
  };
}
var ag = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, k0 = new RegExp(ag.source, "g");
function X7(e) {
  return function() {
    return e;
  };
}
function H7(e) {
  return function(t) {
    return e(t) + "";
  };
}
function vA(e, t) {
  var n = ag.lastIndex = k0.lastIndex = 0, i, r, s, o = -1, a = [], c = [];
  for (e = e + "", t = t + ""; (i = ag.exec(e)) && (r = k0.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: Xe(i, r) })), n = k0.lastIndex;
  return n < t.length && (s = t.slice(n), a[o] ? a[o] += s : a[++o] = s), a.length < 2 ? c[0] ? H7(c[0].x) : X7(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 Hc(e, t) {
  var n = typeof t, i;
  return t == null || n === "boolean" ? wy(t) : (n === "number" ? Xe : n === "string" ? (i = Jr(t)) ? (t = i, Ko) : vA : t instanceof Jr ? Ko : t instanceof Date ? W7 : Y7(t) ? j7 : Array.isArray(t) ? q7 : typeof t.valueOf != "function" && typeof t.toString != "function" || isNaN(t) ? G7 : Xe)(e, t);
}
function fb(e, t) {
  return e = +e, t = +t, function(n) {
    return Math.round(e * (1 - n) + t * n);
  };
}
var Bv = 180 / Math.PI, cg = {
  translateX: 0,
  translateY: 0,
  rotate: 0,
  skewX: 0,
  scaleX: 1,
  scaleY: 1
};
function xA(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) * Bv,
    skewX: Math.atan(c) * Bv,
    scaleX: o,
    scaleY: a
  };
}
var Uf;
function K7(e) {
  const t = new (typeof DOMMatrix == "function" ? DOMMatrix : WebKitCSSMatrix)(e + "");
  return t.isIdentity ? cg : xA(t.a, t.b, t.c, t.d, t.e, t.f);
}
function Z7(e) {
  return e == null || (Uf || (Uf = document.createElementNS("http://www.w3.org/2000/svg", "g")), Uf.setAttribute("transform", e), !(e = Uf.transform.baseVal.consolidate())) ? cg : (e = e.matrix, xA(e.a, e.b, e.c, e.d, e.e, e.f));
}
function SA(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 m = d.push("translate(", null, t, null, n);
      p.push({ i: m - 4, x: Xe(l, f) }, { i: m - 2, x: Xe(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: Xe(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: Xe(l, u) }) : u && f.push(r(f) + "skewX(" + u + i);
  }
  function c(l, u, f, h, d, p) {
    if (l !== f || u !== h) {
      var m = d.push(r(d) + "scale(", null, ",", null, ")");
      p.push({ i: m - 4, x: Xe(l, f) }, { i: m - 2, x: Xe(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, m = h.length, g; ++p < m; )
        f[(g = h[p]).i] = g.x(d);
      return f.join("");
    };
  };
}
var J7 = SA(K7, "px, ", "px)", "deg)"), Q7 = SA(Z7, ", ", ")", ")"), tC = 1e-12;
function Nv(e) {
  return ((e = Math.exp(e)) + 1 / e) / 2;
}
function eC(e) {
  return ((e = Math.exp(e)) - 1 / e) / 2;
}
function nC(e) {
  return ((e = Math.exp(2 * e)) - 1) / (e + 1);
}
const iC = 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, m = d * d + p * p, g, y;
    if (m < tC)
      y = Math.log(h / l) / t, g = function(I) {
        return [
          a + I * d,
          c + I * p,
          l * Math.exp(t * I * y)
        ];
      };
    else {
      var b = Math.sqrt(m), _ = (h * h - l * l + i * m) / (2 * l * n * b), w = (h * h - l * l - i * m) / (2 * h * n * b), x = Math.log(Math.sqrt(_ * _ + 1) - _), v = Math.log(Math.sqrt(w * w + 1) - w);
      y = (v - x) / t, g = function(I) {
        var T = I * y, F = Nv(x), A = l / (n * b) * (F * nC(t * T + x) - eC(x));
        return [
          a + A * d,
          c + A * p,
          l * F / Nv(t * T + x)
        ];
      };
    }
    return g.duration = y * 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 rC(e) {
  return function(t, n) {
    var i = e((t = rg(t)).h, (n = rg(n)).h), r = Ke(t.s, n.s), s = Ke(t.l, n.l), o = Ke(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 sC = rC(ub);
function oC(e, t) {
  var n = Ke((e = sg(e)).l, (t = sg(t)).l), i = Ke(e.a, t.a), r = Ke(e.b, t.b), s = Ke(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 aC(e) {
  return function(t, n) {
    var i = e((t = og(t)).h, (n = og(n)).h), r = Ke(t.c, n.c), s = Ke(t.l, n.l), o = Ke(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 cC = aC(ub);
function IA(e) {
  return function t(n) {
    n = +n;
    function i(r, s) {
      var o = e((r = or(r)).h, (s = or(s)).h), a = Ke(r.s, s.s), c = Ke(r.l, s.l), l = Ke(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);
}
IA(ub);
var hb = IA(Ke);
function vy(e, t) {
  t === void 0 && (t = e, e = Hc);
  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 wi(e, t) {
  for (var n = new Array(t), i = 0; i < t; ++i)
    n[i] = e(i / (t - 1));
  return n;
}
var xc = 0, Cl = 0, yl = 0, AA = 1e3, Md, kl, $d = 0, Zo = 0, xy = 0, _u = typeof performance == "object" && performance.now ? performance : Date, MA = typeof window == "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(e) {
  setTimeout(e, 17);
};
function db() {
  return Zo || (MA(lC), Zo = _u.now() + xy);
}
function lC() {
  Zo = 0;
}
function Td() {
  this._call = this._time = this._next = null;
}
Td.prototype = $A.prototype = {
  constructor: Td,
  restart: function(e, t, n) {
    if (typeof e != "function")
      throw new TypeError("callback is not a function");
    n = (n == null ? db() : +n) + (t == null ? 0 : +t), !this._next && kl !== this && (kl ? kl._next = this : Md = this, kl = this), this._call = e, this._time = n, lg();
  },
  stop: function() {
    this._call && (this._call = null, this._time = 1 / 0, lg());
  }
};
function $A(e, t, n) {
  var i = new Td();
  return i.restart(e, t, n), i;
}
function uC() {
  db(), ++xc;
  for (var e = Md, t; e; )
    (t = Zo - e._time) >= 0 && e._call.call(void 0, t), e = e._next;
  --xc;
}
function Fv() {
  Zo = ($d = _u.now()) + xy, xc = Cl = 0;
  try {
    uC();
  } finally {
    xc = 0, hC(), Zo = 0;
  }
}
function fC() {
  var e = _u.now(), t = e - $d;
  t > AA && (xy -= t, $d = e);
}
function hC() {
  for (var e, t = Md, 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 : Md = n);
  kl = e, lg(i);
}
function lg(e) {
  if (!xc) {
    Cl && (Cl = clearTimeout(Cl));
    var t = e - Zo;
    t > 24 ? (e < 1 / 0 && (Cl = setTimeout(Fv, e - _u.now() - xy)), yl && (yl = clearInterval(yl))) : (yl || ($d = _u.now(), yl = setInterval(fC, AA)), xc = 1, MA(Fv));
  }
}
function Dv(e, t, n) {
  var i = new Td();
  return t = t == null ? 0 : +t, i.restart((r) => {
    i.stop(), e(r + t);
  }, t, n), i;
}
var dC = my("start", "end", "cancel", "interrupt"), pC = [], TA = 0, Ev = 1, ug = 2, $h = 3, Ov = 4, fg = 5, Th = 6;
function Sy(e, t, n, i, r, s) {
  var o = e.__transition;
  if (!o)
    e.__transition = {};
  else if (n in o)
    return;
  yC(e, n, {
    name: t,
    index: i,
    // For context during callback.
    group: r,
    // For context during callback.
    on: dC,
    tween: pC,
    time: s.time,
    delay: s.delay,
    duration: s.duration,
    ease: s.ease,
    timer: null,
    state: TA
  });
}
function pb(e, t) {
  var n = Ni(e, t);
  if (n.state > TA)
    throw new Error("too late; already scheduled");
  return n;
}
function ur(e, t) {
  var n = Ni(e, t);
  if (n.state > $h)
    throw new Error("too late; already running");
  return n;
}
function Ni(e, t) {
  var n = e.__transition;
  if (!n || !(n = n[t]))
    throw new Error("transition not found");
  return n;
}
function yC(e, t, n) {
  var i = e.__transition, r;
  i[t] = n, n.timer = $A(s, 0, n.time);
  function s(l) {
    n.state = Ev, 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 !== Ev)
      return c();
    for (u in i)
      if (d = i[u], d.name === n.name) {
        if (d.state === $h)
          return Dv(o);
        d.state === Ov ? (d.state = Th, d.timer.stop(), d.on.call("interrupt", e, e.__data__, d.index, d.group), delete i[u]) : +u < t && (d.state = Th, d.timer.stop(), d.on.call("cancel", e, e.__data__, d.index, d.group), delete i[u]);
      }
    if (Dv(function() {
      n.state === $h && (n.state = Ov, n.timer.restart(a, n.delay, n.time), a(l));
    }), n.state = ug, n.on.call("start", e, e.__data__, n.index, n.group), n.state === ug) {
      for (n.state = $h, 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 = fg, 1), f = -1, h = r.length; ++f < h; )
      r[f].call(e, u);
    n.state === fg && (n.on.call("end", e, e.__data__, n.index, n.group), c());
  }
  function c() {
    n.state = Th, n.timer.stop(), delete i[t];
    for (var l in i)
      return;
    delete e.__transition;
  }
}
function Za(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 > ug && i.state < fg, i.state = Th, i.timer.stop(), i.on.call(r ? "interrupt" : "cancel", e, e.__data__, i.index, i.group), delete n[o];
    }
    s && delete e.__transition;
  }
}
function mC(e) {
  return this.each(function() {
    Za(this, e);
  });
}
function gC(e, t) {
  var n, i;
  return function() {
    var r = ur(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 bC(e, t, n) {
  var i, r;
  if (typeof n != "function")
    throw new Error();
  return function() {
    var s = ur(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 _C(e, t) {
  var n = this._id;
  if (e += "", arguments.length < 2) {
    for (var i = Ni(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 ? gC : bC)(n, e, t));
}
function yb(e, t, n) {
  var i = e._id;
  return e.each(function() {
    var r = ur(this, i);
    (r.value || (r.value = {}))[t] = n.apply(this, arguments);
  }), function(r) {
    return Ni(r, i).value[t];
  };
}
function BA(e, t) {
  var n;
  return (typeof t == "number" ? Xe : t instanceof Jr ? Ko : (n = Jr(t)) ? (t = n, Ko) : vA)(e, t);
}
function wC(e) {
  return function() {
    this.removeAttribute(e);
  };
}
function vC(e) {
  return function() {
    this.removeAttributeNS(e.space, e.local);
  };
}
function xC(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 SC(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 IC(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 AC(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 MC(e, t) {
  var n = gy(e), i = n === "transform" ? Q7 : BA;
  return this.attrTween(e, typeof t == "function" ? (n.local ? AC : IC)(n, i, yb(this, "attr." + e, t)) : t == null ? (n.local ? vC : wC)(n) : (n.local ? SC : xC)(n, i, t));
}
function $C(e, t) {
  return function(n) {
    this.setAttribute(e, t.call(this, n));
  };
}
function TC(e, t) {
  return function(n) {
    this.setAttributeNS(e.space, e.local, t.call(this, n));
  };
}
function BC(e, t) {
  var n, i;
  function r() {
    var s = t.apply(this, arguments);
    return s !== i && (n = (i = s) && TC(e, s)), n;
  }
  return r._value = t, r;
}
function NC(e, t) {
  var n, i;
  function r() {
    var s = t.apply(this, arguments);
    return s !== i && (n = (i = s) && $C(e, s)), n;
  }
  return r._value = t, r;
}
function FC(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 = gy(e);
  return this.tween(n, (i.local ? BC : NC)(i, t));
}
function DC(e, t) {
  return function() {
    pb(this, e).delay = +t.apply(this, arguments);
  };
}
function EC(e, t) {
  return t = +t, function() {
    pb(this, e).delay = t;
  };
}
function OC(e) {
  var t = this._id;
  return arguments.length ? this.each((typeof e == "function" ? DC : EC)(t, e)) : Ni(this.node(), t).delay;
}
function LC(e, t) {
  return function() {
    ur(this, e).duration = +t.apply(this, arguments);
  };
}
function RC(e, t) {
  return t = +t, function() {
    ur(this, e).duration = t;
  };
}
function CC(e) {
  var t = this._id;
  return arguments.length ? this.each((typeof e == "function" ? LC : RC)(t, e)) : Ni(this.node(), t).duration;
}
function kC(e, t) {
  if (typeof t != "function")
    throw new Error();
  return function() {
    ur(this, e).ease = t;
  };
}
function UC(e) {
  var t = this._id;
  return arguments.length ? this.each(kC(t, e)) : Ni(this.node(), t).ease;
}
function zC(e, t) {
  return function() {
    var n = t.apply(this, arguments);
    if (typeof n != "function")
      throw new Error();
    ur(this, e).ease = n;
  };
}
function PC(e) {
  if (typeof e != "function")
    throw new Error();
  return this.each(zC(this._id, e));
}
function VC(e) {
  typeof e != "function" && (e = Z3(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 Qr(i, this._parents, this._name, this._id);
}
function jC(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 Qr(o, this._parents, this._name, this._id);
}
function YC(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 qC(e, t, n) {
  var i, r, s = YC(t) ? pb : ur;
  return function() {
    var o = s(this, e), a = o.on;
    a !== i && (r = (i = a).copy()).on(t, n), o.on = r;
  };
}
function WC(e, t) {
  var n = this._id;
  return arguments.length < 2 ? Ni(this.node(), n).on.on(e) : this.each(qC(n, e, t));
}
function GC(e) {
  return function() {
    var t = this.parentNode;
    for (var n in this.__transition)
      if (+n !== e)
        return;
    t && t.removeChild(this);
  };
}
function XC() {
  return this.on("end.remove", GC(this._id));
}
function HC(e) {
  var t = this._name, n = this._id;
  typeof e != "function" && (e = sb(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, Sy(l[h], t, n, h, l, Ni(u, n)));
  return new Qr(s, this._parents, t, n);
}
function KC(e) {
  var t = this._name, n = this._id;
  typeof e != "function" && (e = K3(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 = Ni(u, n), m = 0, g = h.length; m < g; ++m)
          (d = h[m]) && Sy(d, t, n, m, h, p);
        s.push(h), o.push(u);
      }
  return new Qr(s, o, t, n);
}
var ZC = Ju.prototype.constructor;
function JC() {
  return new ZC(this._groups, this._parents);
}
function QC(e, t) {
  var n, i, r;
  return function() {
    var s = wc(this, e), o = (this.style.removeProperty(e), wc(this, e));
    return s === o ? null : s === n && o === i ? r : r = t(n = s, i = o);
  };
}
function NA(e) {
  return function() {
    this.style.removeProperty(e);
  };
}
function tk(e, t, n) {
  var i, r = n + "", s;
  return function() {
    var o = wc(this, e);
    return o === r ? null : o === i ? s : s = t(i = o, n);
  };
}
function ek(e, t, n) {
  var i, r, s;
  return function() {
    var o = wc(this, e), a = n(this), c = a + "";
    return a == null && (c = a = (this.style.removeProperty(e), wc(this, e))), o === c ? null : o === i && c === r ? s : (r = c, s = t(i = o, a));
  };
}
function nk(e, t) {
  var n, i, r, s = "style." + t, o = "end." + s, a;
  return function() {
    var c = ur(this, e), l = c.on, u = c.value[s] == null ? a || (a = NA(t)) : void 0;
    (l !== n || r !== u) && (i = (n = l).copy()).on(o, r = u), c.on = i;
  };
}
function ik(e, t, n) {
  var i = (e += "") == "transform" ? J7 : BA;
  return t == null ? this.styleTween(e, QC(e, i)).on("end.style." + e, NA(e)) : typeof t == "function" ? this.styleTween(e, ek(e, i, yb(this, "style." + e, t))).each(nk(this._id, e)) : this.styleTween(e, tk(e, i, t), n).on("end.style." + e, null);
}
function rk(e, t, n) {
  return function(i) {
    this.style.setProperty(e, t.call(this, i), n);
  };
}
function sk(e, t, n) {
  var i, r;
  function s() {
    var o = t.apply(this, arguments);
    return o !== r && (i = (r = o) && rk(e, o, n)), i;
  }
  return s._value = t, s;
}
function ok(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, sk(e, t, n ?? ""));
}
function ak(e) {
  return function() {
    this.textContent = e;
  };
}
function ck(e) {
  return function() {
    var t = e(this);
    this.textContent = t ?? "";
  };
}
function lk(e) {
  return this.tween("text", typeof e == "function" ? ck(yb(this, "text", e)) : ak(e == null ? "" : e + ""));
}
function uk(e) {
  return function(t) {
    this.textContent = e.call(this, t);
  };
}
function fk(e) {
  var t, n;
  function i() {
    var r = e.apply(this, arguments);
    return r !== n && (t = (n = r) && uk(r)), t;
  }
  return i._value = e, i;
}
function hk(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, fk(e));
}
function dk() {
  for (var e = this._name, t = this._id, n = FA(), 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 = Ni(c, t);
        Sy(c, e, n, l, o, {
          time: u.time + u.delay + u.duration,
          delay: 0,
          duration: u.duration,
          ease: u.ease
        });
      }
  return new Qr(i, this._parents, e, n);
}
function pk() {
  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 = ur(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 yk = 0;
function Qr(e, t, n, i) {
  this._groups = e, this._parents = t, this._name = n, this._id = i;
}
function FA() {
  return ++yk;
}
var mr = Ju.prototype;
Qr.prototype = {
  constructor: Qr,
  select: HC,
  selectAll: KC,
  selectChild: mr.selectChild,
  selectChildren: mr.selectChildren,
  filter: VC,
  merge: jC,
  selection: JC,
  transition: dk,
  call: mr.call,
  nodes: mr.nodes,
  node: mr.node,
  size: mr.size,
  empty: mr.empty,
  each: mr.each,
  on: WC,
  attr: MC,
  attrTween: FC,
  style: ik,
  styleTween: ok,
  text: lk,
  textTween: hk,
  remove: XC,
  tween: _C,
  delay: OC,
  duration: CC,
  ease: UC,
  easeVarying: PC,
  end: pk,
  [Symbol.iterator]: mr[Symbol.iterator]
};
function mk(e) {
  return ((e *= 2) <= 1 ? e * e * e : (e -= 2) * e * e + 2) / 2;
}
var gk = {
  time: null,
  // Set on use.
  delay: 0,
  duration: 250,
  ease: mk
};
function bk(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 _k(e) {
  var t, n;
  e instanceof Qr ? (t = e._id, e = e._name) : (t = FA(), (n = gk).time = db(), 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]) && Sy(c, e, t, l, o, n || bk(c, t));
  return new Qr(i, this._parents, e, t);
}
Ju.prototype.interrupt = mC;
Ju.prototype.transition = _k;
const U0 = (e) => () => e;
function wk(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 vk(e) {
  e.stopImmediatePropagation();
}
function z0(e) {
  e.preventDefault(), e.stopImmediatePropagation();
}
var Lv = { name: "drag" }, P0 = { name: "space" }, fa = { name: "handle" }, ha = { name: "center" };
const { abs: Rv, max: qe, min: We } = Math;
function Cv(e) {
  return [+e[0], +e[1]];
}
function hg(e) {
  return [Cv(e[0]), Cv(e[1])];
}
var Bh = {
  name: "x",
  handles: ["w", "e"].map(wu),
  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]];
  }
}, Nh = {
  name: "y",
  handles: ["n", "s"].map(wu),
  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]];
  }
}, xk = {
  name: "xy",
  handles: ["n", "w", "e", "s", "nw", "ne", "sw", "se"].map(wu),
  input: function(e) {
    return e == null ? null : hg(e);
  },
  output: function(e) {
    return e;
  }
}, gr = {
  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"
}, kv = {
  e: "w",
  w: "e",
  nw: "ne",
  ne: "nw",
  se: "sw",
  sw: "se"
}, Uv = {
  n: "s",
  s: "n",
  nw: "sw",
  ne: "se",
  se: "ne",
  sw: "nw"
}, Sk = {
  overlay: 1,
  selection: 1,
  n: null,
  e: 1,
  s: null,
  w: -1,
  nw: -1,
  ne: 1,
  se: 1,
  sw: -1
}, Ik = {
  overlay: 1,
  selection: 1,
  n: -1,
  e: null,
  s: 1,
  w: null,
  nw: -1,
  ne: -1,
  se: 1,
  sw: 1
};
function wu(e) {
  return { type: e };
}
function Ak(e) {
  return !e.ctrlKey && !e.button;
}
function Mk() {
  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 $k() {
  return navigator.maxTouchPoints || "ontouchstart" in this;
}
function V0(e) {
  for (; !e.__brush; )
    if (!(e = e.parentNode))
      return;
  return e.__brush;
}
function Tk(e) {
  return e[0][0] === e[1][0] || e[0][1] === e[1][1];
}
function Bk() {
  return mb(Bh);
}
function Nk() {
  return mb(Nh);
}
function Fk() {
  return mb(xk);
}
function mb(e) {
  var t = Mk, n = Ak, i = $k, r = !0, s = my("start", "brush", "end"), o = 6, a;
  function c(g) {
    var y = g.property("__brush", m).selectAll(".overlay").data([wu("overlay")]);
    y.enter().append("rect").attr("class", "overlay").attr("pointer-events", "all").attr("cursor", gr.overlay).merge(y).each(function() {
      var _ = V0(this).extent;
      re(this).attr("x", _[0][0]).attr("y", _[0][1]).attr("width", _[1][0] - _[0][0]).attr("height", _[1][1] - _[0][1]);
    }), g.selectAll(".selection").data([wu("selection")]).enter().append("rect").attr("class", "selection").attr("cursor", gr.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(_) {
      return _.type;
    });
    b.exit().remove(), b.enter().append("rect").attr("class", function(_) {
      return "handle handle--" + _.type;
    }).attr("cursor", function(_) {
      return gr[_.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, y, b) {
    g.tween ? g.on("start.brush", function(_) {
      u(this, arguments).beforestart().start(_);
    }).on("interrupt.brush end.brush", function(_) {
      u(this, arguments).end(_);
    }).tween("brush", function() {
      var _ = this, w = _.__brush, x = u(_, arguments), v = w.selection, I = e.input(typeof y == "function" ? y.apply(this, arguments) : y, w.extent), T = Hc(v, I);
      function F(A) {
        w.selection = A === 1 && I === null ? null : T(A), l.call(_), x.brush();
      }
      return v !== null && I !== null ? F : F(1);
    }) : g.each(function() {
      var _ = this, w = arguments, x = _.__brush, v = e.input(typeof y == "function" ? y.apply(_, w) : y, x.extent), I = u(_, w).beforestart();
      Za(_), x.selection = v === null ? null : v, l.call(_), I.start(b).brush(b).end(b);
    });
  }, c.clear = function(g, y) {
    c.move(g, null, y);
  };
  function l() {
    var g = re(this), y = V0(this).selection;
    y ? (g.selectAll(".selection").style("display", null).attr("x", y[0][0]).attr("y", y[0][1]).attr("width", y[1][0] - y[0][0]).attr("height", y[1][1] - y[0][1]), g.selectAll(".handle").style("display", null).attr("x", function(b) {
      return b.type[b.type.length - 1] === "e" ? y[1][0] - o / 2 : y[0][0] - o / 2;
    }).attr("y", function(b) {
      return b.type[0] === "s" ? y[1][1] - o / 2 : y[0][1] - o / 2;
    }).attr("width", function(b) {
      return b.type === "n" || b.type === "s" ? y[1][0] - y[0][0] + o : o;
    }).attr("height", function(b) {
      return b.type === "e" || b.type === "w" ? y[1][1] - y[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, y, b) {
    var _ = g.__brush.emitter;
    return _ && (!b || !_.clean) ? _ : new f(g, y, b);
  }
  function f(g, y, b) {
    this.that = g, this.args = y, 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, y) {
      return this.starting ? (this.starting = !1, this.emit("start", g, y)) : this.emit("brush", g), this;
    },
    brush: function(g, y) {
      return this.emit("brush", g, y), this;
    },
    end: function(g, y) {
      return --this.active === 0 && (delete this.state.emitter, this.emit("end", g, y)), this;
    },
    emit: function(g, y, b) {
      var _ = re(this.that).datum();
      s.call(
        g,
        this.that,
        new wk(g, {
          sourceEvent: y,
          target: c,
          selection: e.output(this.state.selection),
          mode: b,
          dispatch: s
        }),
        _
      );
    }
  };
  function h(g) {
    if (a && !g.touches || !n.apply(this, arguments))
      return;
    var y = this, b = g.target.__data__.type, _ = (r && g.metaKey ? b = "overlay" : b) === "selection" ? Lv : r && g.altKey ? ha : fa, w = e === Nh ? null : Sk[b], x = e === Bh ? null : Ik[b], v = V0(y), I = v.extent, T = v.selection, F = I[0][0], A, $, D = I[0][1], O, S, M = I[1][0], B, N, L = I[1][1], k, U, V = 0, j = 0, X, J = w && x && r && g.shiftKey, rt, Gt, W = Array.from(g.touches || [g], (Q) => {
      const ee = Q.identifier;
      return Q = ci(Q, y), Q.point0 = Q.slice(), Q.identifier = ee, Q;
    });
    Za(y);
    var H = u(y, arguments, !0).beforestart();
    if (b === "overlay") {
      T && (X = !0);
      const Q = [W[0], W[1] || W[0]];
      v.selection = T = [[
        A = e === Nh ? F : We(Q[0][0], Q[1][0]),
        O = e === Bh ? D : We(Q[0][1], Q[1][1])
      ], [
        B = e === Nh ? M : qe(Q[0][0], Q[1][0]),
        k = e === Bh ? L : qe(Q[0][1], Q[1][1])
      ]], W.length > 1 && tt(g);
    } else
      A = T[0][0], O = T[0][1], B = T[1][0], k = T[1][1];
    $ = A, S = O, N = B, U = k;
    var P = re(y).attr("pointer-events", "none"), K = P.selectAll(".overlay").attr("cursor", gr[b]);
    if (g.touches)
      H.moved = z, H.ended = lt;
    else {
      var Z = re(g.view).on("mousemove.brush", z, !0).on("mouseup.brush", lt, !0);
      r && Z.on("keydown.brush", zt, !0).on("keyup.brush", Dt, !0), aA(g.view);
    }
    l.call(y), H.start(g, _.name);
    function z(Q) {
      for (const ee of Q.changedTouches || [Q])
        for (const Oi of W)
          Oi.identifier === ee.identifier && (Oi.cur = ci(ee, y));
      if (J && !rt && !Gt && W.length === 1) {
        const ee = W[0];
        Rv(ee.cur[0] - ee[0]) > Rv(ee.cur[1] - ee[1]) ? Gt = !0 : rt = !0;
      }
      for (const ee of W)
        ee.cur && (ee[0] = ee.cur[0], ee[1] = ee.cur[1]);
      X = !0, z0(Q), tt(Q);
    }
    function tt(Q) {
      const ee = W[0], Oi = ee.point0;
      var Mn;
      switch (V = ee[0] - Oi[0], j = ee[1] - Oi[1], _) {
        case P0:
        case Lv: {
          w && (V = qe(F - A, We(M - B, V)), $ = A + V, N = B + V), x && (j = qe(D - O, We(L - k, j)), S = O + j, U = k + j);
          break;
        }
        case fa: {
          W[1] ? (w && ($ = qe(F, We(M, W[0][0])), N = qe(F, We(M, W[1][0])), w = 1), x && (S = qe(D, We(L, W[0][1])), U = qe(D, We(L, W[1][1])), x = 1)) : (w < 0 ? (V = qe(F - A, We(M - A, V)), $ = A + V, N = B) : w > 0 && (V = qe(F - B, We(M - B, V)), $ = A, N = B + V), x < 0 ? (j = qe(D - O, We(L - O, j)), S = O + j, U = k) : x > 0 && (j = qe(D - k, We(L - k, j)), S = O, U = k + j));
          break;
        }
        case ha: {
          w && ($ = qe(F, We(M, A - V * w)), N = qe(F, We(M, B + V * w))), x && (S = qe(D, We(L, O - j * x)), U = qe(D, We(L, k + j * x)));
          break;
        }
      }
      N < $ && (w *= -1, Mn = A, A = B, B = Mn, Mn = $, $ = N, N = Mn, b in kv && K.attr("cursor", gr[b = kv[b]])), U < S && (x *= -1, Mn = O, O = k, k = Mn, Mn = S, S = U, U = Mn, b in Uv && K.attr("cursor", gr[b = Uv[b]])), v.selection && (T = v.selection), rt && ($ = T[0][0], N = T[1][0]), Gt && (S = T[0][1], U = T[1][1]), (T[0][0] !== $ || T[0][1] !== S || T[1][0] !== N || T[1][1] !== U) && (v.selection = [[$, S], [N, U]], l.call(y), H.brush(Q, _.name));
    }
    function lt(Q) {
      if (vk(Q), Q.touches) {
        if (Q.touches.length)
          return;
        a && clearTimeout(a), a = setTimeout(function() {
          a = null;
        }, 500);
      } else
        cA(Q.view, X), Z.on("keydown.brush keyup.brush mousemove.brush mouseup.brush", null);
      P.attr("pointer-events", "all"), K.attr("cursor", gr.overlay), v.selection && (T = v.selection), Tk(T) && (v.selection = null, l.call(y)), H.end(Q, _.name);
    }
    function zt(Q) {
      switch (Q.keyCode) {
        case 16: {
          J = w && x;
          break;
        }
        case 18: {
          _ === fa && (w && (B = N - V * w, A = $ + V * w), x && (k = U - j * x, O = S + j * x), _ = ha, tt(Q));
          break;
        }
        case 32: {
          (_ === fa || _ === ha) && (w < 0 ? B = N - V : w > 0 && (A = $ - V), x < 0 ? k = U - j : x > 0 && (O = S - j), _ = P0, K.attr("cursor", gr.selection), tt(Q));
          break;
        }
        default:
          return;
      }
      z0(Q);
    }
    function Dt(Q) {
      switch (Q.keyCode) {
        case 16: {
          J && (rt = Gt = J = !1, tt(Q));
          break;
        }
        case 18: {
          _ === ha && (w < 0 ? B = N : w > 0 && (A = $), x < 0 ? k = U : x > 0 && (O = S), _ = fa, tt(Q));
          break;
        }
        case 32: {
          _ === P0 && (Q.altKey ? (w && (B = N - V * w, A = $ + V * w), x && (k = U - j * x, O = S + j * x), _ = ha) : (w < 0 ? B = N : w > 0 && (A = $), x < 0 ? k = U : x > 0 && (O = S), _ = fa), K.attr("cursor", gr[b]), tt(Q));
          break;
        }
        default:
          return;
      }
      z0(Q);
    }
  }
  function d(g) {
    u(this, arguments).moved(g);
  }
  function p(g) {
    u(this, arguments).ended(g);
  }
  function m() {
    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 : U0(hg(g)), c) : t;
  }, c.filter = function(g) {
    return arguments.length ? (n = typeof g == "function" ? g : U0(!!g), c) : n;
  }, c.touchable = function(g) {
    return arguments.length ? (i = typeof g == "function" ? g : U0(!!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 dg = Math.PI, pg = 2 * dg, Mo = 1e-6, Dk = pg - Mo;
function DA(e) {
  this._ += e[0];
  for (let t = 1, n = e.length; t < n; ++t)
    this._ += arguments[t] + e[t];
}
function Ek(e) {
  let t = Math.floor(e);
  if (!(t >= 0))
    throw new Error(`invalid digits: ${e}`);
  if (t > 15)
    return DA;
  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 EA = class {
  constructor(t) {
    this._x0 = this._y0 = // start of current subpath
    this._x1 = this._y1 = null, this._ = "", this._append = t == null ? DA : Ek(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 > Mo)
      if (!(Math.abs(f * c - l * u) > Mo) || !s)
        this._append`L${this._x1 = t},${this._y1 = n}`;
      else {
        let d = i - o, p = r - a, m = c * c + l * l, g = d * d + p * p, y = Math.sqrt(m), b = Math.sqrt(h), _ = s * Math.tan((dg - Math.acos((m + h - g) / (2 * y * b))) / 2), w = _ / b, x = _ / y;
        Math.abs(w - 1) > Mo && this._append`L${t + w * u},${n + w * f}`, this._append`A${s},${s},0,0,${+(f * d > u * p)},${this._x1 = t + x * c},${this._y1 = n + x * 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) > Mo || Math.abs(this._y1 - u) > Mo) && this._append`L${l},${u}`, i && (h < 0 && (h = h % pg + pg), h > Dk ? 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 > Mo && this._append`A${i},${i},0,${+(h >= dg)},${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 zr(e = 3) {
  return new EA(+e);
}
var Ok = Array.prototype, OA = Ok.slice;
function Lk(e, t) {
  return e - t;
}
function Rk(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 bs = (e) => () => e;
function Ck(e, t) {
  for (var n = -1, i = t.length, r; ++n < i; )
    if (r = kk(e, t[n]))
      return r;
  return 0;
}
function kk(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 (Uk(c, f, t))
      return 0;
    u > i != d > i && n < (h - l) * (i - u) / (d - u) + l && (r = -r);
  }
  return r;
}
function Uk(e, t, n) {
  var i;
  return zk(e, t, n) && Pk(e[i = +(e[0] === t[0])], n[i], t[i]);
}
function zk(e, t, n) {
  return (t[0] - e[0]) * (n[1] - e[1]) === (n[0] - e[0]) * (t[1] - e[1]);
}
function Pk(e, t, n) {
  return e <= t && t <= n || n <= t && t <= e;
}
function Vk() {
}
var br = [
  [],
  [[[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 Bd() {
  var e = 1, t = 1, n = nb, i = c;
  function r(l) {
    var u = n(l);
    if (Array.isArray(u))
      u = u.slice().sort(Lk);
    else {
      const f = je(l, jk);
      for (u = ks(...Y3(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), Rk(p) > 0 ? h.push([p]) : d.push(p);
    }), d.forEach(function(p) {
      for (var m = 0, g = h.length, y; m < g; ++m)
        if (Ck((y = h[m])[0], p) !== -1) {
          y.push(p);
          return;
        }
    }), {
      type: "MultiPolygon",
      value: u,
      coordinates: h
    };
  }
  function o(l, u, f) {
    var h = new Array(), d = new Array(), p, m, g, y, b, _;
    for (p = m = -1, y = ho(l[0], u), br[y << 1].forEach(w); ++p < e - 1; )
      g = y, y = ho(l[p + 1], u), br[g | y << 1].forEach(w);
    for (br[y << 0].forEach(w); ++m < t - 1; ) {
      for (p = -1, y = ho(l[m * e + e], u), b = ho(l[m * e], u), br[y << 1 | b << 2].forEach(w); ++p < e - 1; )
        g = y, y = ho(l[m * e + e + p + 1], u), _ = b, b = ho(l[m * e + p + 1], u), br[g | y << 1 | b << 2 | _ << 3].forEach(w);
      br[y | b << 3].forEach(w);
    }
    for (p = -1, b = l[m * e] >= u, br[b << 2].forEach(w); ++p < e - 1; )
      _ = b, b = ho(l[m * e + p + 1], u), br[b << 2 | _ << 3].forEach(w);
    br[b << 3].forEach(w);
    function w(x) {
      var v = [x[0][0] + p, x[0][1] + m], I = [x[1][0] + p, x[1][1] + m], T = a(v), F = a(I), A, $;
      (A = d[T]) ? ($ = h[F]) ? (delete d[A.end], delete h[$.start], A === $ ? (A.ring.push(I), f(A.ring)) : h[A.start] = d[$.end] = { start: A.start, end: $.end, ring: A.ring.concat($.ring) }) : (delete d[A.end], A.ring.push(I), d[A.end = F] = A) : (A = h[F]) ? ($ = d[T]) ? (delete h[A.start], delete d[$.end], A === $ ? (A.ring.push(I), f(A.ring)) : h[$.start] = d[A.end] = { start: $.start, end: A.end, ring: $.ring.concat(A.ring) }) : (delete h[A.start], A.ring.unshift(v), h[A.start = T] = A) : h[T] = d[F] = { start: T, end: F, ring: [v, 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], m = d | 0, g = p | 0, y = j0(u[g * e + m]);
      d > 0 && d < e && m === d && (h[0] = zv(d, j0(u[g * e + m - 1]), y, f)), p > 0 && p < t && g === p && (h[1] = zv(p, j0(u[(g - 1) * e + m]), y, 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) ? bs(OA.call(l)) : bs(l), r) : n;
  }, r.smooth = function(l) {
    return arguments.length ? (i = l ? c : Vk, r) : i === c;
  }, r;
}
function jk(e) {
  return isFinite(e) ? e : NaN;
}
function ho(e, t) {
  return e == null ? !1 : +e >= t;
}
function j0(e) {
  return e == null || isNaN(e = +e) ? -1 / 0 : e;
}
function zv(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 Yk(e) {
  return e[0];
}
function qk(e) {
  return e[1];
}
function Wk() {
  return 1;
}
function Gk() {
  var e = Yk, t = qk, n = Wk, i = 960, r = 500, s = 20, o = 2, a = s * 3, c = i + a * 2 >> o, l = r + a * 2 >> o, u = bs(20);
  function f(b) {
    var _ = new Float32Array(c * l), w = Math.pow(2, -o), x = -1;
    for (const O of b) {
      var v = (e(O, ++x, b) + a) * w, I = (t(O, x, b) + a) * w, T = +n(O, x, b);
      if (T && v >= 0 && v < c && I >= 0 && I < l) {
        var F = Math.floor(v), A = Math.floor(I), $ = v - F - 0.5, D = I - A - 0.5;
        _[F + A * c] += (1 - $) * (1 - D) * T, _[F + 1 + A * c] += $ * (1 - D) * T, _[F + 1 + (A + 1) * c] += $ * D * T, _[F + (A + 1) * c] += (1 - $) * D * T;
      }
    }
    return k3({ data: _, width: c, height: l }, s * w), _;
  }
  function h(b) {
    var _ = f(b), w = u(_), x = Math.pow(2, 2 * o);
    return Array.isArray(w) || (w = ks(Number.MIN_VALUE, Se(_) / x, w)), Bd().size([c, l]).thresholds(w.map((v) => v * x))(_).map((v, I) => (v.value = +w[I], d(v)));
  }
  h.contours = function(b) {
    var _ = f(b), w = Bd().size([c, l]), x = Math.pow(2, 2 * o), v = (I) => {
      I = +I;
      var T = d(w.contour(_, I * x));
      return T.value = I, T;
    };
    return Object.defineProperty(v, "max", { get: () => Se(_) / x }), v;
  };
  function d(b) {
    return b.coordinates.forEach(p), b;
  }
  function p(b) {
    b.forEach(m);
  }
  function m(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 y() {
    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 : bs(+b), h) : e;
  }, h.y = function(b) {
    return arguments.length ? (t = typeof b == "function" ? b : bs(+b), h) : t;
  }, h.weight = function(b) {
    return arguments.length ? (n = typeof b == "function" ? b : bs(+b), h) : n;
  }, h.size = function(b) {
    if (!arguments.length)
      return [i, r];
    var _ = +b[0], w = +b[1];
    if (!(_ >= 0 && w >= 0))
      throw new Error("invalid size");
    return i = _, r = w, y();
  }, 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), y();
  }, h.thresholds = function(b) {
    return arguments.length ? (u = typeof b == "function" ? b : Array.isArray(b) ? bs(OA.call(b)) : bs(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, y();
  }, h;
}
const Wr = 11102230246251565e-32, Ge = 134217729, Xk = (3 + 8 * Wr) * Wr;
function Y0(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 Hk(e, t) {
  let n = t[0];
  for (let i = 1; i < e; i++)
    n += t[i];
  return n;
}
function tf(e) {
  return new Float64Array(e);
}
const Kk = (3 + 16 * Wr) * Wr, Zk = (2 + 12 * Wr) * Wr, Jk = (9 + 64 * Wr) * Wr * Wr, da = tf(4), Pv = tf(8), Vv = tf(12), jv = tf(16), Je = tf(4);
function Qk(e, t, n, i, r, s, o) {
  let a, c, l, u, f, h, d, p, m, g, y, b, _, w, x, v, I, T;
  const F = e - r, A = n - r, $ = t - s, D = i - s;
  w = F * D, h = Ge * F, d = h - (h - F), p = F - d, h = Ge * D, m = h - (h - D), g = D - m, x = p * g - (w - d * m - p * m - d * g), v = $ * A, h = Ge * $, d = h - (h - $), p = $ - d, h = Ge * A, m = h - (h - A), g = A - m, I = p * g - (v - d * m - p * m - d * g), y = x - I, f = x - y, da[0] = x - (y + f) + (f - I), b = w + y, f = b - w, _ = w - (b - f) + (y - f), y = _ - v, f = _ - y, da[1] = _ - (y + f) + (f - v), T = b + y, f = T - b, da[2] = b - (T - f) + (y - f), da[3] = T;
  let O = Hk(4, da), S = Zk * o;
  if (O >= S || -O >= S || (f = e - F, a = e - (F + f) + (f - r), f = n - A, l = n - (A + f) + (f - r), f = t - $, c = t - ($ + f) + (f - s), f = i - D, u = i - (D + f) + (f - s), a === 0 && c === 0 && l === 0 && u === 0) || (S = Jk * o + Xk * Math.abs(O), O += F * u + D * a - ($ * l + A * c), O >= S || -O >= S))
    return O;
  w = a * D, h = Ge * a, d = h - (h - a), p = a - d, h = Ge * D, m = h - (h - D), g = D - m, x = p * g - (w - d * m - p * m - d * g), v = c * A, h = Ge * c, d = h - (h - c), p = c - d, h = Ge * A, m = h - (h - A), g = A - m, I = p * g - (v - d * m - p * m - d * g), y = x - I, f = x - y, Je[0] = x - (y + f) + (f - I), b = w + y, f = b - w, _ = w - (b - f) + (y - f), y = _ - v, f = _ - y, Je[1] = _ - (y + f) + (f - v), T = b + y, f = T - b, Je[2] = b - (T - f) + (y - f), Je[3] = T;
  const M = Y0(4, da, 4, Je, Pv);
  w = F * u, h = Ge * F, d = h - (h - F), p = F - d, h = Ge * u, m = h - (h - u), g = u - m, x = p * g - (w - d * m - p * m - d * g), v = $ * l, h = Ge * $, d = h - (h - $), p = $ - d, h = Ge * l, m = h - (h - l), g = l - m, I = p * g - (v - d * m - p * m - d * g), y = x - I, f = x - y, Je[0] = x - (y + f) + (f - I), b = w + y, f = b - w, _ = w - (b - f) + (y - f), y = _ - v, f = _ - y, Je[1] = _ - (y + f) + (f - v), T = b + y, f = T - b, Je[2] = b - (T - f) + (y - f), Je[3] = T;
  const B = Y0(M, Pv, 4, Je, Vv);
  w = a * u, h = Ge * a, d = h - (h - a), p = a - d, h = Ge * u, m = h - (h - u), g = u - m, x = p * g - (w - d * m - p * m - d * g), v = c * l, h = Ge * c, d = h - (h - c), p = c - d, h = Ge * l, m = h - (h - l), g = l - m, I = p * g - (v - d * m - p * m - d * g), y = x - I, f = x - y, Je[0] = x - (y + f) + (f - I), b = w + y, f = b - w, _ = w - (b - f) + (y - f), y = _ - v, f = _ - y, Je[1] = _ - (y + f) + (f - v), T = b + y, f = T - b, Je[2] = b - (T - f) + (y - f), Je[3] = T;
  const N = Y0(B, Vv, 4, Je, jv);
  return jv[N - 1];
}
function zf(e, t, n, i, r, s) {
  const o = (t - s) * (n - r), a = (e - r) * (i - s), c = o - a;
  if (o === 0 || a === 0 || o > 0 != a > 0)
    return c;
  const l = Math.abs(o + a);
  return Math.abs(c) >= Kk * l ? c : -Qk(e, t, n, i, r, s, l);
}
const Yv = Math.pow(2, -52), Pf = new Uint32Array(512);
class Nd {
  static from(t, n = r9, i = s9) {
    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 Nd(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).fill(-1), 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 $ = t[2 * A], D = t[2 * A + 1];
      $ < a && (a = $), D < c && (c = D), $ > l && (l = $), D > u && (u = D), this._ids[A] = A;
    }
    const f = (a + l) / 2, h = (c + u) / 2;
    let d = 1 / 0, p, m, g;
    for (let A = 0; A < o; A++) {
      const $ = q0(f, h, t[2 * A], t[2 * A + 1]);
      $ < d && (p = A, d = $);
    }
    const y = t[2 * p], b = t[2 * p + 1];
    d = 1 / 0;
    for (let A = 0; A < o; A++) {
      if (A === p)
        continue;
      const $ = q0(y, b, t[2 * A], t[2 * A + 1]);
      $ < d && $ > 0 && (m = A, d = $);
    }
    let _ = t[2 * m], w = t[2 * m + 1], x = 1 / 0;
    for (let A = 0; A < o; A++) {
      if (A === p || A === m)
        continue;
      const $ = n9(y, b, _, w, t[2 * A], t[2 * A + 1]);
      $ < x && (g = A, x = $);
    }
    let v = t[2 * g], I = t[2 * g + 1];
    if (x === 1 / 0) {
      for (let D = 0; D < o; D++)
        this._dists[D] = t[2 * D] - t[0] || t[2 * D + 1] - t[1];
      Ua(this._ids, this._dists, 0, o - 1);
      const A = new Uint32Array(o);
      let $ = 0;
      for (let D = 0, O = -1 / 0; D < o; D++) {
        const S = this._ids[D];
        this._dists[S] > O && (A[$++] = S, O = this._dists[S]);
      }
      this.hull = A.subarray(0, $), this.triangles = new Uint32Array(0), this.halfedges = new Uint32Array(0);
      return;
    }
    if (zf(y, b, _, w, v, I) < 0) {
      const A = m, $ = _, D = w;
      m = g, _ = v, w = I, g = A, v = $, I = D;
    }
    const T = i9(y, b, _, w, v, I);
    this._cx = T.x, this._cy = T.y;
    for (let A = 0; A < o; A++)
      this._dists[A] = q0(t[2 * A], t[2 * A + 1], T.x, T.y);
    Ua(this._ids, this._dists, 0, o - 1), this._hullStart = p;
    let F = 3;
    i[p] = n[g] = m, i[m] = n[p] = g, i[g] = n[m] = p, r[p] = 0, r[m] = 1, r[g] = 2, s.fill(-1), s[this._hashKey(y, b)] = p, s[this._hashKey(_, w)] = m, s[this._hashKey(v, I)] = g, this.trianglesLen = 0, this._addTriangle(p, m, g, -1, -1, -1);
    for (let A = 0, $, D; A < this._ids.length; A++) {
      const O = this._ids[A], S = t[2 * O], M = t[2 * O + 1];
      if (A > 0 && Math.abs(S - $) <= Yv && Math.abs(M - D) <= Yv || ($ = S, D = M, O === p || O === m || O === g))
        continue;
      let B = 0;
      for (let V = 0, j = this._hashKey(S, M); V < this._hashSize && (B = s[(j + V) % this._hashSize], !(B !== -1 && B !== i[B])); V++)
        ;
      B = n[B];
      let N = B, L;
      for (; L = i[N], zf(S, M, t[2 * N], t[2 * N + 1], t[2 * L], t[2 * L + 1]) >= 0; )
        if (N = L, N === B) {
          N = -1;
          break;
        }
      if (N === -1)
        continue;
      let k = this._addTriangle(N, O, i[N], -1, -1, r[N]);
      r[O] = this._legalize(k + 2), r[N] = k, F++;
      let U = i[N];
      for (; L = i[U], zf(S, M, t[2 * U], t[2 * U + 1], t[2 * L], t[2 * L + 1]) < 0; )
        k = this._addTriangle(U, O, L, r[O], -1, r[U]), r[O] = this._legalize(k + 2), i[U] = U, F--, U = L;
      if (N === B)
        for (; L = n[N], zf(S, M, t[2 * L], t[2 * L + 1], t[2 * N], t[2 * N + 1]) < 0; )
          k = this._addTriangle(L, O, N, -1, r[N], r[L]), this._legalize(k + 2), r[L] = k, i[N] = N, F--, N = L;
      this._hullStart = n[O] = N, i[N] = n[U] = O, i[O] = U, s[this._hashKey(S, M)] = O, s[this._hashKey(t[2 * N], t[2 * N + 1])] = N;
    }
    this.hull = new Uint32Array(F);
    for (let A = 0, $ = this._hullStart; A < F; A++)
      this.hull[A] = $, $ = i[$];
    this.triangles = this._triangles.subarray(0, this.trianglesLen), this.halfedges = this._halfedges.subarray(0, this.trianglesLen);
  }
  _hashKey(t, n) {
    return Math.floor(t9(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 = Pf[--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], m = n[f];
      if (e9(
        r[2 * h],
        r[2 * h + 1],
        r[2 * d],
        r[2 * d + 1],
        r[2 * p],
        r[2 * p + 1],
        r[2 * m],
        r[2 * m + 1]
      )) {
        n[t] = m, n[a] = h;
        const y = i[f];
        if (y === -1) {
          let _ = this._hullStart;
          do {
            if (this._hullTri[_] === f) {
              this._hullTri[_] = t;
              break;
            }
            _ = this._hullPrev[_];
          } while (_ !== this._hullStart);
        }
        this._link(t, y), this._link(a, i[o]), this._link(o, f);
        const b = l + (a + 1) % 3;
        s < Pf.length && (Pf[s++] = b);
      } else {
        if (s === 0)
          break;
        t = Pf[--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 t9(e, t) {
  const n = e / (Math.abs(e) + Math.abs(t));
  return (t > 0 ? 3 - n : 1 + n) / 4;
}
function q0(e, t, n, i) {
  const r = e - n, s = t - i;
  return r * r + s * s;
}
function e9(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, m = u * u + f * f, g = h * h + d * d;
  return c * (f * g - m * d) - l * (u * g - m * h) + p * (u * d - f * h) < 0;
}
function n9(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 i9(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 Ua(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;
    ml(e, r, s), t[e[n]] > t[e[i]] && ml(e, n, i), t[e[s]] > t[e[i]] && ml(e, s, i), t[e[n]] > t[e[s]] && ml(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;
      ml(e, s, o);
    }
    e[n + 1] = e[o], e[o] = a, i - s + 1 >= o - n ? (Ua(e, t, s, i), Ua(e, t, n, o - 1)) : (Ua(e, t, n, o - 1), Ua(e, t, s, i));
  }
}
function ml(e, t, n) {
  const i = e[t];
  e[t] = e[n], e[n] = i;
}
function r9(e) {
  return e[0];
}
function s9(e) {
  return e[1];
}
const qv = 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) > qv || Math.abs(this._y1 - s) > qv) && (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 yg {
  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 o9 = 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 m = 0, g = 0, y = i.length, b, _; m < y; m += 3, g += 2) {
      const w = i[m] * 2, x = i[m + 1] * 2, v = i[m + 2] * 2, I = t[w], T = t[w + 1], F = t[x], A = t[x + 1], $ = t[v], D = t[v + 1], O = F - I, S = A - T, M = $ - I, B = D - T, N = (O * B - S * M) * 2;
      if (Math.abs(N) < 1e-9) {
        if (s === void 0) {
          s = o = 0;
          for (const k of n)
            s += t[k * 2], o += t[k * 2 + 1];
          s /= n.length, o /= n.length;
        }
        const L = 1e9 * Math.sign((s - I) * B - (o - T) * M);
        b = (I + $) / 2 - L * B, _ = (T + D) / 2 + L * M;
      } else {
        const L = 1 / N, k = O * O + S * S, U = M * M + B * B;
        b = I + (B * k - S * U) * L, _ = T + (O * U - M * k) * L;
      }
      a[g] = b, a[g + 1] = _;
    }
    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 m = 0; m < n.length; ++m)
      c = n[m], 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, m = o[d], g = o[d + 1], y = o[p], b = o[p + 1];
      this._renderSegment(m, g, y, 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, m = this._project(h, d, a[p + 2], a[p + 3]);
      m && this._renderSegment(h, d, m[0], m[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 yg();
    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, m, g, y, b;
        if (l === 0) {
          if ((p = this._clipSegment(s, o, a, c, l, u)) === null)
            continue;
          [m, g, y, b] = p;
        } else {
          if ((p = this._clipSegment(a, c, s, o, u, l)) === null)
            continue;
          [y, b, m, g] = p, f = h, h = this._edgecode(m, g), f && h && this._edge(t, f, h, r, r.length), r ? r.push(m, g) : r = [m, g];
        }
        f = h, h = this._edgecode(y, b), f && h && this._edge(t, f, h, r, r.length), r ? r.push(y, b) : r = [y, 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 a9 = 2 * Math.PI, pa = Math.pow;
function c9(e) {
  return e[0];
}
function l9(e) {
  return e[1];
}
function u9(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 f9(e, t, n) {
  return [e + Math.sin(e + t) * n, t + Math.cos(e - t) * n];
}
class Qs {
  static from(t, n = c9, i = l9, r) {
    return new Qs("length" in t ? h9(t, n, i, r) : Float64Array.from(d9(t, n, i, r)));
  }
  constructor(t) {
    this._delaunator = new Nd(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 && u9(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 = f9(n[2 * h], n[2 * h + 1], f);
        n[2 * h] = p[0], n[2 * h + 1] = p[1];
      }
      this._delaunator = new Nd(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 o9(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 = pa(n - l[t * 2], 2) + pa(i - l[t * 2 + 1], 2);
    const h = r[t];
    let d = h;
    do {
      let p = c[d];
      const m = pa(n - l[p * 2], 2) + pa(i - l[p * 2 + 1], 2);
      if (m < f && (f = m, 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 && pa(n - l[d * 2], 2) + pa(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, a9);
    }
    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 yg();
    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 yg();
    return this.renderTriangle(t, n), n.value();
  }
}
function h9(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* d9(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 p9(e) {
  return Math.abs(e = Math.round(e)) >= 1e21 ? e.toLocaleString("en").replace(/,/g, "") : e.toString(10);
}
function Fd(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 Sc(e) {
  return e = Fd(Math.abs(e)), e ? e[1] : NaN;
}
function y9(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 m9(e) {
  return function(t) {
    return t.replace(/[0-9]/g, function(n) {
      return e[+n];
    });
  };
}
var g9 = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
function vu(e) {
  if (!(t = g9.exec(e)))
    throw new Error("invalid format: " + e);
  var t;
  return new gb({
    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]
  });
}
vu.prototype = gb.prototype;
function gb(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 + "";
}
gb.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 b9(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 LA;
function _9(e, t) {
  var n = Fd(e, t);
  if (!n)
    return e + "";
  var i = n[0], r = n[1], s = r - (LA = 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") + Fd(e, Math.max(0, t + s - 1))[0];
}
function Wv(e, t) {
  var n = Fd(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 Gv = {
  "%": (e, t) => (e * 100).toFixed(t),
  b: (e) => Math.round(e).toString(2),
  c: (e) => e + "",
  d: p9,
  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) => Wv(e * 100, t),
  r: Wv,
  s: _9,
  X: (e) => Math.round(e).toString(16).toUpperCase(),
  x: (e) => Math.round(e).toString(16)
};
function Xv(e) {
  return e;
}
var Hv = Array.prototype.map, Kv = ["y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"];
function w9(e) {
  var t = e.grouping === void 0 || e.thousands === void 0 ? Xv : y9(Hv.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 ? Xv : m9(Hv.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 = vu(f);
    var h = f.fill, d = f.align, p = f.sign, m = f.symbol, g = f.zero, y = f.width, b = f.comma, _ = f.precision, w = f.trim, x = f.type;
    x === "n" ? (b = !0, x = "g") : Gv[x] || (_ === void 0 && (_ = 12), w = !0, x = "g"), (g || h === "0" && d === "=") && (g = !0, h = "0", d = "=");
    var v = m === "$" ? n : m === "#" && /[boxX]/.test(x) ? "0" + x.toLowerCase() : "", I = m === "$" ? i : /[%p]/.test(x) ? o : "", T = Gv[x], F = /[defgprs%]/.test(x);
    _ = _ === void 0 ? 6 : /[gprs]/.test(x) ? Math.max(1, Math.min(21, _)) : Math.max(0, Math.min(20, _));
    function A($) {
      var D = v, O = I, S, M, B;
      if (x === "c")
        O = T($) + O, $ = "";
      else {
        $ = +$;
        var N = $ < 0 || 1 / $ < 0;
        if ($ = isNaN($) ? c : T(Math.abs($), _), w && ($ = b9($)), N && +$ == 0 && p !== "+" && (N = !1), D = (N ? p === "(" ? p : a : p === "-" || p === "(" ? "" : p) + D, O = (x === "s" ? Kv[8 + LA / 3] : "") + O + (N && p === "(" ? ")" : ""), F) {
          for (S = -1, M = $.length; ++S < M; )
            if (B = $.charCodeAt(S), 48 > B || B > 57) {
              O = (B === 46 ? r + $.slice(S + 1) : $.slice(S)) + O, $ = $.slice(0, S);
              break;
            }
        }
      }
      b && !g && ($ = t($, 1 / 0));
      var L = D.length + $.length + O.length, k = L < y ? new Array(y - L + 1).join(h) : "";
      switch (b && g && ($ = t(k + $, k.length ? y - O.length : 1 / 0), k = ""), d) {
        case "<":
          $ = D + $ + O + k;
          break;
        case "=":
          $ = D + k + $ + O;
          break;
        case "^":
          $ = k.slice(0, L = k.length >> 1) + D + $ + O + k.slice(L);
          break;
        default:
          $ = k + D + $ + O;
          break;
      }
      return s($);
    }
    return A.toString = function() {
      return f + "";
    }, A;
  }
  function u(f, h) {
    var d = l((f = vu(f), f.type = "f", f)), p = Math.max(-8, Math.min(8, Math.floor(Sc(h) / 3))) * 3, m = Math.pow(10, -p), g = Kv[8 + p / 3];
    return function(y) {
      return d(m * y) + g;
    };
  }
  return {
    format: l,
    formatPrefix: u
  };
}
var Vf, ef, RA;
v9({
  thousands: ",",
  grouping: [3],
  currency: ["$", ""]
});
function v9(e) {
  return Vf = w9(e), ef = Vf.format, RA = Vf.formatPrefix, Vf;
}
function x9(e) {
  return Math.max(0, -Sc(Math.abs(e)));
}
function S9(e, t) {
  return Math.max(0, Math.max(-8, Math.min(8, Math.floor(Sc(t) / 3))) * 3 - Sc(Math.abs(e)));
}
function I9(e, t) {
  return e = Math.abs(e), t = Math.abs(t) - e, Math.max(0, Sc(t) - Sc(e)) + 1;
}
var ot = 1e-6, Dd = 1e-12, Ft = Math.PI, Ae = Ft / 2, Zv = Ft / 4, On = Ft * 2, Ve = 180 / Ft, Pt = Ft / 180, qt = Math.abs, Kc = Math.atan, vi = Math.atan2, at = Math.cos, jf = Math.ceil, CA = Math.exp, mg = Math.hypot, Ed = Math.log, W0 = Math.pow, et = Math.sin, Xn = Math.sign || function(e) {
  return e > 0 ? 1 : e < 0 ? -1 : 0;
}, ln = Math.sqrt, bb = Math.tan;
function kA(e) {
  return e > 1 ? 0 : e < -1 ? Ft : Math.acos(e);
}
function bn(e) {
  return e > 1 ? Ae : e < -1 ? -Ae : Math.asin(e);
}
function Nn() {
}
function Od(e, t) {
  e && Qv.hasOwnProperty(e.type) && Qv[e.type](e, t);
}
var Jv = {
  Feature: function(e, t) {
    Od(e.geometry, t);
  },
  FeatureCollection: function(e, t) {
    for (var n = e.features, i = -1, r = n.length; ++i < r; )
      Od(n[i].geometry, t);
  }
}, Qv = {
  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) {
    gg(e.coordinates, t, 0);
  },
  MultiLineString: function(e, t) {
    for (var n = e.coordinates, i = -1, r = n.length; ++i < r; )
      gg(n[i], t, 0);
  },
  Polygon: function(e, t) {
    t2(e.coordinates, t);
  },
  MultiPolygon: function(e, t) {
    for (var n = e.coordinates, i = -1, r = n.length; ++i < r; )
      t2(n[i], t);
  },
  GeometryCollection: function(e, t) {
    for (var n = e.geometries, i = -1, r = n.length; ++i < r; )
      Od(n[i], t);
  }
};
function gg(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 t2(e, t) {
  var n = -1, i = e.length;
  for (t.polygonStart(); ++n < i; )
    gg(e[n], t, 1);
  t.polygonEnd();
}
function xs(e, t) {
  e && Jv.hasOwnProperty(e.type) ? Jv[e.type](e, t) : Od(e, t);
}
function bg(e) {
  return [vi(e[1], e[0]), bn(e[2])];
}
function Ic(e) {
  var t = e[0], n = e[1], i = at(n);
  return [i * at(t), i * et(t), et(n)];
}
function Yf(e, t) {
  return e[0] * t[0] + e[1] * t[1] + e[2] * t[2];
}
function Ld(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 G0(e, t) {
  e[0] += t[0], e[1] += t[1], e[2] += t[2];
}
function qf(e, t) {
  return [e[0] * t, e[1] * t, e[2] * t];
}
function _g(e) {
  var t = ln(e[0] * e[0] + e[1] * e[1] + e[2] * e[2]);
  e[0] /= t, e[1] /= t, e[2] /= t;
}
var Ul, Rd, Cd, kd, Ud, zd, Pd, Vd, wg, vg, xg, UA, zA, nn, rn, sn, yi = {
  sphere: Nn,
  point: _b,
  lineStart: e2,
  lineEnd: n2,
  polygonStart: function() {
    yi.lineStart = $9, yi.lineEnd = T9;
  },
  polygonEnd: function() {
    yi.lineStart = e2, yi.lineEnd = n2;
  }
};
function _b(e, t) {
  e *= Pt, t *= Pt;
  var n = at(t);
  nf(n * at(e), n * et(e), et(t));
}
function nf(e, t, n) {
  ++Ul, Cd += (e - Cd) / Ul, kd += (t - kd) / Ul, Ud += (n - Ud) / Ul;
}
function e2() {
  yi.point = A9;
}
function A9(e, t) {
  e *= Pt, t *= Pt;
  var n = at(t);
  nn = n * at(e), rn = n * et(e), sn = et(t), yi.point = M9, nf(nn, rn, sn);
}
function M9(e, t) {
  e *= Pt, t *= Pt;
  var n = at(t), i = n * at(e), r = n * et(e), s = et(t), o = vi(ln((o = rn * s - sn * r) * o + (o = sn * i - nn * s) * o + (o = nn * r - rn * i) * o), nn * i + rn * r + sn * s);
  Rd += o, zd += o * (nn + (nn = i)), Pd += o * (rn + (rn = r)), Vd += o * (sn + (sn = s)), nf(nn, rn, sn);
}
function n2() {
  yi.point = _b;
}
function $9() {
  yi.point = B9;
}
function T9() {
  PA(UA, zA), yi.point = _b;
}
function B9(e, t) {
  UA = e, zA = t, e *= Pt, t *= Pt, yi.point = PA;
  var n = at(t);
  nn = n * at(e), rn = n * et(e), sn = et(t), nf(nn, rn, sn);
}
function PA(e, t) {
  e *= Pt, t *= Pt;
  var n = at(t), i = n * at(e), r = n * et(e), s = et(t), o = rn * s - sn * r, a = sn * i - nn * s, c = nn * r - rn * i, l = mg(o, a, c), u = bn(l), f = l && -u / l;
  wg.add(f * o), vg.add(f * a), xg.add(f * c), Rd += u, zd += u * (nn + (nn = i)), Pd += u * (rn + (rn = r)), Vd += u * (sn + (sn = s)), nf(nn, rn, sn);
}
function N9(e) {
  Ul = Rd = Cd = kd = Ud = zd = Pd = Vd = 0, wg = new tr(), vg = new tr(), xg = new tr(), xs(e, yi);
  var t = +wg, n = +vg, i = +xg, r = mg(t, n, i);
  return r < Dd && (t = zd, n = Pd, i = Vd, Rd < ot && (t = Cd, n = kd, i = Ud), r = mg(t, n, i), r < Dd) ? [NaN, NaN] : [vi(n, t) * Ve, bn(i / r) * Ve];
}
function Sg(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 Ig(e, t) {
  return qt(e) > Ft && (e -= Math.round(e / On) * On), [e, t];
}
Ig.invert = Ig;
function VA(e, t, n) {
  return (e %= On) ? t || n ? Sg(r2(e), s2(t, n)) : r2(e) : t || n ? s2(t, n) : Ig;
}
function i2(e) {
  return function(t, n) {
    return t += e, qt(t) > Ft && (t -= Math.round(t / On) * On), [t, n];
  };
}
function r2(e) {
  var t = i2(e);
  return t.invert = i2(-e), t;
}
function s2(e, t) {
  var n = at(e), i = et(e), r = at(t), s = et(t);
  function o(a, c) {
    var l = at(c), u = at(a) * l, f = et(a) * l, h = et(c), d = h * n + u * i;
    return [
      vi(f * r - d * s, u * n - h * i),
      bn(d * r + f * s)
    ];
  }
  return o.invert = function(a, c) {
    var l = at(c), u = at(a) * l, f = et(a) * l, h = et(c), d = h * r - f * s;
    return [
      vi(f * r + h * s, u * n + d * i),
      bn(d * n - u * i)
    ];
  }, o;
}
function F9(e) {
  e = VA(e[0] * Pt, e[1] * Pt, e.length > 2 ? e[2] * Pt : 0);
  function t(n) {
    return n = e(n[0] * Pt, n[1] * Pt), n[0] *= Ve, n[1] *= Ve, n;
  }
  return t.invert = function(n) {
    return n = e.invert(n[0] * Pt, n[1] * Pt), n[0] *= Ve, n[1] *= Ve, n;
  }, t;
}
function D9(e, t, n, i, r, s) {
  if (n) {
    var o = at(t), a = et(t), c = i * n;
    r == null ? (r = t + i * On, s = t - c / 2) : (r = o2(o, r), s = o2(o, s), (i > 0 ? r < s : r > s) && (r += i * On));
    for (var l, u = r; i > 0 ? u > s : u < s; u -= c)
      l = bg([o, -a * at(u), -a * et(u)]), e.point(l[0], l[1]);
  }
}
function o2(e, t) {
  t = Ic(t), t[0] -= e, _g(t);
  var n = kA(-t[1]);
  return ((-t[2] < 0 ? -n : n) + On - ot) % On;
}
function jA() {
  var e = [], t;
  return {
    point: function(n, i, r) {
      t.push([n, i, r]);
    },
    lineStart: function() {
      e.push(t = []);
    },
    lineEnd: Nn,
    rejoin: function() {
      e.length > 1 && e.push(e.pop().concat(e.shift()));
    },
    result: function() {
      var n = e;
      return e = [], t = null, n;
    }
  };
}
function Fh(e, t) {
  return qt(e[0] - t[0]) < ot && qt(e[1] - t[1]) < ot;
}
function Wf(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 YA(e, t, n, i, r) {
  var s = [], o = [], a, c;
  if (e.forEach(function(p) {
    if (!((m = p.length - 1) <= 0)) {
      var m, g = p[0], y = p[m], b;
      if (Fh(g, y)) {
        if (!g[2] && !y[2]) {
          for (r.lineStart(), a = 0; a < m; ++a)
            r.point((g = p[a])[0], g[1]);
          r.lineEnd();
          return;
        }
        y[0] += 2 * ot;
      }
      s.push(b = new Wf(g, p, null, !0)), o.push(b.o = new Wf(g, null, b, !1)), s.push(b = new Wf(y, p, null, !1)), o.push(b.o = new Wf(y, null, b, !0));
    }
  }), !!s.length) {
    for (o.sort(t), a2(s), a2(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 a2(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 X0(e) {
  return qt(e[0]) <= Ft ? e[0] : Xn(e[0]) * ((qt(e[0]) + Ft) % On - Ft);
}
function E9(e, t) {
  var n = X0(t), i = t[1], r = et(i), s = [et(n), -at(n), 0], o = 0, a = 0, c = new tr();
  r === 1 ? i = Ae + ot : r === -1 && (i = -Ae - ot);
  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 = X0(d), m = d[1] / 2 + Zv, g = et(m), y = at(m), b = 0; b < h; ++b, p = w, g = v, y = I, d = _) {
        var _ = f[b], w = X0(_), x = _[1] / 2 + Zv, v = et(x), I = at(x), T = w - p, F = T >= 0 ? 1 : -1, A = F * T, $ = A > Ft, D = g * v;
        if (c.add(vi(D * F * et(A), y * I + D * at(A))), o += $ ? T + F * On : T, $ ^ p >= n ^ w >= n) {
          var O = Ld(Ic(d), Ic(_));
          _g(O);
          var S = Ld(s, O);
          _g(S);
          var M = ($ ^ T >= 0 ? -1 : 1) * bn(S[2]);
          (i > M || i === M && (O[0] || O[1])) && (a += $ ^ T >= 0 ? 1 : -1);
        }
      }
  return (o < -ot || o < ot && c < -Dd) ^ a & 1;
}
function qA(e, t, n, i) {
  return function(r) {
    var s = t(r), o = jA(), a = t(o), c = !1, l, u, f, h = {
      point: d,
      lineStart: m,
      lineEnd: g,
      polygonStart: function() {
        h.point = y, h.lineStart = b, h.lineEnd = _, u = [], l = [];
      },
      polygonEnd: function() {
        h.point = d, h.lineStart = m, h.lineEnd = g, u = G3(u);
        var w = E9(l, i);
        u.length ? (c || (r.polygonStart(), c = !0), YA(u, L9, w, n, r)) : w && (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(w, x) {
      e(w, x) && r.point(w, x);
    }
    function p(w, x) {
      s.point(w, x);
    }
    function m() {
      h.point = p, s.lineStart();
    }
    function g() {
      h.point = d, s.lineEnd();
    }
    function y(w, x) {
      f.push([w, x]), a.point(w, x);
    }
    function b() {
      a.lineStart(), f = [];
    }
    function _() {
      y(f[0][0], f[0][1]), a.lineEnd();
      var w = a.clean(), x = o.result(), v, I = x.length, T, F, A;
      if (f.pop(), l.push(f), f = null, !!I) {
        if (w & 1) {
          if (F = x[0], (T = F.length - 1) > 0) {
            for (c || (r.polygonStart(), c = !0), r.lineStart(), v = 0; v < T; ++v)
              r.point((A = F[v])[0], A[1]);
            r.lineEnd();
          }
          return;
        }
        I > 1 && w & 2 && x.push(x.pop().concat(x.shift())), u.push(x.filter(O9));
      }
    }
    return h;
  };
}
function O9(e) {
  return e.length > 1;
}
function L9(e, t) {
  return ((e = e.x)[0] < 0 ? e[1] - Ae - ot : Ae - e[1]) - ((t = t.x)[0] < 0 ? t[1] - Ae - ot : Ae - t[1]);
}
const c2 = qA(
  function() {
    return !0;
  },
  R9,
  k9,
  [-Ft, -Ae]
);
function R9(e) {
  var t = NaN, n = NaN, i = NaN, r;
  return {
    lineStart: function() {
      e.lineStart(), r = 1;
    },
    point: function(s, o) {
      var a = s > 0 ? Ft : -Ft, c = qt(s - t);
      qt(c - Ft) < ot ? (e.point(t, n = (n + o) / 2 > 0 ? Ae : -Ae), e.point(i, n), e.lineEnd(), e.lineStart(), e.point(a, n), e.point(s, n), r = 0) : i !== a && c >= Ft && (qt(t - i) < ot && (t -= i * ot), qt(s - a) < ot && (s -= a * ot), n = C9(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 C9(e, t, n, i) {
  var r, s, o = et(e - n);
  return qt(o) > ot ? Kc((et(t) * (s = at(i)) * et(n) - et(i) * (r = at(t)) * et(e)) / (r * s * o)) : (t + i) / 2;
}
function k9(e, t, n, i) {
  var r;
  if (e == null)
    r = n * Ae, i.point(-Ft, r), i.point(0, r), i.point(Ft, r), i.point(Ft, 0), i.point(Ft, -r), i.point(0, -r), i.point(-Ft, -r), i.point(-Ft, 0), i.point(-Ft, r);
  else if (qt(e[0] - t[0]) > ot) {
    var s = e[0] < t[0] ? Ft : -Ft;
    r = n * s / 2, i.point(-s, r), i.point(0, r), i.point(s, r);
  } else
    i.point(t[0], t[1]);
}
function U9(e) {
  var t = at(e), n = 6 * Pt, i = t > 0, r = qt(t) > ot;
  function s(u, f, h, d) {
    D9(d, e, n, h, u, f);
  }
  function o(u, f) {
    return at(u) * at(f) > t;
  }
  function a(u) {
    var f, h, d, p, m;
    return {
      lineStart: function() {
        p = d = !1, m = 1;
      },
      point: function(g, y) {
        var b = [g, y], _, w = o(g, y), x = i ? w ? 0 : l(g, y) : w ? l(g + (g < 0 ? Ft : -Ft), y) : 0;
        if (!f && (p = d = w) && u.lineStart(), w !== d && (_ = c(f, b), (!_ || Fh(f, _) || Fh(b, _)) && (b[2] = 1)), w !== d)
          m = 0, w ? (u.lineStart(), _ = c(b, f), u.point(_[0], _[1])) : (_ = c(f, b), u.point(_[0], _[1], 2), u.lineEnd()), f = _;
        else if (r && f && i ^ w) {
          var v;
          !(x & h) && (v = c(b, f, !0)) && (m = 0, i ? (u.lineStart(), u.point(v[0][0], v[0][1]), u.point(v[1][0], v[1][1]), u.lineEnd()) : (u.point(v[1][0], v[1][1]), u.lineEnd(), u.lineStart(), u.point(v[0][0], v[0][1], 3)));
        }
        w && (!f || !Fh(f, b)) && u.point(b[0], b[1]), f = b, d = w, h = x;
      },
      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 m | (p && d) << 1;
      }
    };
  }
  function c(u, f, h) {
    var d = Ic(u), p = Ic(f), m = [1, 0, 0], g = Ld(d, p), y = Yf(g, g), b = g[0], _ = y - b * b;
    if (!_)
      return !h && u;
    var w = t * y / _, x = -t * b / _, v = Ld(m, g), I = qf(m, w), T = qf(g, x);
    G0(I, T);
    var F = v, A = Yf(I, F), $ = Yf(F, F), D = A * A - $ * (Yf(I, I) - 1);
    if (!(D < 0)) {
      var O = ln(D), S = qf(F, (-A - O) / $);
      if (G0(S, I), S = bg(S), !h)
        return S;
      var M = u[0], B = f[0], N = u[1], L = f[1], k;
      B < M && (k = M, M = B, B = k);
      var U = B - M, V = qt(U - Ft) < ot, j = V || U < ot;
      if (!V && L < N && (k = N, N = L, L = k), j ? V ? N + L > 0 ^ S[1] < (qt(S[0] - M) < ot ? N : L) : N <= S[1] && S[1] <= L : U > Ft ^ (M <= S[0] && S[0] <= B)) {
        var X = qf(F, (-A + O) / $);
        return G0(X, I), [S, bg(X)];
      }
    }
  }
  function l(u, f) {
    var h = i ? e : Ft - e, d = 0;
    return u < -h ? d |= 1 : u > h && (d |= 2), f < -h ? d |= 4 : f > h && (d |= 8), d;
  }
  return qA(o, a, s, i ? [0, -e] : [-Ft, e - Ft]);
}
function z9(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 zl = 1e9, Gf = -zl;
function WA(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 qt(l[0] - e) < ot ? u > 0 ? 0 : 3 : qt(l[0] - n) < ot ? u > 0 ? 2 : 1 : qt(l[1] - t) < ot ? 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 = jA(), h, d, p, m, g, y, b, _, w, x, v, I = {
      point: T,
      lineStart: D,
      lineEnd: O,
      polygonStart: A,
      polygonEnd: $
    };
    function T(M, B) {
      r(M, B) && u.point(M, B);
    }
    function F() {
      for (var M = 0, B = 0, N = d.length; B < N; ++B)
        for (var L = d[B], k = 1, U = L.length, V = L[0], j, X, J = V[0], rt = V[1]; k < U; ++k)
          j = J, X = rt, V = L[k], J = V[0], rt = V[1], X <= i ? rt > i && (J - j) * (i - X) > (rt - X) * (e - j) && ++M : rt <= i && (J - j) * (i - X) < (rt - X) * (e - j) && --M;
      return M;
    }
    function A() {
      u = f, h = [], d = [], v = !0;
    }
    function $() {
      var M = F(), B = v && M, N = (h = G3(h)).length;
      (B || N) && (l.polygonStart(), B && (l.lineStart(), s(null, null, 1, l), l.lineEnd()), N && YA(h, a, M, s, l), l.polygonEnd()), u = l, h = d = p = null;
    }
    function D() {
      I.point = S, d && d.push(p = []), x = !0, w = !1, b = _ = NaN;
    }
    function O() {
      h && (S(m, g), y && w && f.rejoin(), h.push(f.result())), I.point = T, w && u.lineEnd();
    }
    function S(M, B) {
      var N = r(M, B);
      if (d && p.push([M, B]), x)
        m = M, g = B, y = N, x = !1, N && (u.lineStart(), u.point(M, B));
      else if (N && w)
        u.point(M, B);
      else {
        var L = [b = Math.max(Gf, Math.min(zl, b)), _ = Math.max(Gf, Math.min(zl, _))], k = [M = Math.max(Gf, Math.min(zl, M)), B = Math.max(Gf, Math.min(zl, B))];
        z9(L, k, e, t, n, i) ? (w || (u.lineStart(), u.point(L[0], L[1])), u.point(k[0], k[1]), N || u.lineEnd(), v = !1) : N && (u.lineStart(), u.point(M, B), v = !1);
      }
      b = M, _ = B, w = N;
    }
    return I;
  };
}
function l2(e, t, n) {
  var i = Bn(e, t - ot, n).concat(t);
  return function(r) {
    return i.map(function(s) {
      return [r, s];
    });
  };
}
function u2(e, t, n) {
  var i = Bn(e, t - ot, n).concat(t);
  return function(r) {
    return i.map(function(s) {
      return [s, r];
    });
  };
}
function P9() {
  var e, t, n, i, r, s, o, a, c = 10, l = c, u = 90, f = 360, h, d, p, m, g = 2.5;
  function y() {
    return { type: "MultiLineString", coordinates: b() };
  }
  function b() {
    return Bn(jf(i / u) * u, n, u).map(p).concat(Bn(jf(a / f) * f, o, f).map(m)).concat(Bn(jf(t / c) * c, e, c).filter(function(_) {
      return qt(_ % u) > ot;
    }).map(h)).concat(Bn(jf(s / l) * l, r, l).filter(function(_) {
      return qt(_ % f) > ot;
    }).map(d));
  }
  return y.lines = function() {
    return b().map(function(_) {
      return { type: "LineString", coordinates: _ };
    });
  }, y.outline = function() {
    return {
      type: "Polygon",
      coordinates: [
        p(i).concat(
          m(o).slice(1),
          p(n).reverse().slice(1),
          m(a).reverse().slice(1)
        )
      ]
    };
  }, y.extent = function(_) {
    return arguments.length ? y.extentMajor(_).extentMinor(_) : y.extentMinor();
  }, y.extentMajor = function(_) {
    return arguments.length ? (i = +_[0][0], n = +_[1][0], a = +_[0][1], o = +_[1][1], i > n && (_ = i, i = n, n = _), a > o && (_ = a, a = o, o = _), y.precision(g)) : [[i, a], [n, o]];
  }, y.extentMinor = function(_) {
    return arguments.length ? (t = +_[0][0], e = +_[1][0], s = +_[0][1], r = +_[1][1], t > e && (_ = t, t = e, e = _), s > r && (_ = s, s = r, r = _), y.precision(g)) : [[t, s], [e, r]];
  }, y.step = function(_) {
    return arguments.length ? y.stepMajor(_).stepMinor(_) : y.stepMinor();
  }, y.stepMajor = function(_) {
    return arguments.length ? (u = +_[0], f = +_[1], y) : [u, f];
  }, y.stepMinor = function(_) {
    return arguments.length ? (c = +_[0], l = +_[1], y) : [c, l];
  }, y.precision = function(_) {
    return arguments.length ? (g = +_, h = l2(s, r, 90), d = u2(t, e, g), p = l2(a, o, 90), m = u2(i, n, g), y) : g;
  }, y.extentMajor([[-180, -90 + ot], [180, 90 - ot]]).extentMinor([[-180, -80 - ot], [180, 80 + ot]]);
}
function V9() {
  return P9()();
}
const Ag = (e) => e;
var H0 = new tr(), Mg = new tr(), GA, XA, $g, Tg, Ss = {
  point: Nn,
  lineStart: Nn,
  lineEnd: Nn,
  polygonStart: function() {
    Ss.lineStart = j9, Ss.lineEnd = q9;
  },
  polygonEnd: function() {
    Ss.lineStart = Ss.lineEnd = Ss.point = Nn, H0.add(qt(Mg)), Mg = new tr();
  },
  result: function() {
    var e = H0 / 2;
    return H0 = new tr(), e;
  }
};
function j9() {
  Ss.point = Y9;
}
function Y9(e, t) {
  Ss.point = HA, GA = $g = e, XA = Tg = t;
}
function HA(e, t) {
  Mg.add(Tg * e - $g * t), $g = e, Tg = t;
}
function q9() {
  HA(GA, XA);
}
const f2 = Ss;
var Ac = 1 / 0, jd = Ac, xu = -Ac, Yd = xu, W9 = {
  point: G9,
  lineStart: Nn,
  lineEnd: Nn,
  polygonStart: Nn,
  polygonEnd: Nn,
  result: function() {
    var e = [[Ac, jd], [xu, Yd]];
    return xu = Yd = -(jd = Ac = 1 / 0), e;
  }
};
function G9(e, t) {
  e < Ac && (Ac = e), e > xu && (xu = e), t < jd && (jd = t), t > Yd && (Yd = t);
}
const qd = W9;
var Bg = 0, Ng = 0, Pl = 0, Wd = 0, Gd = 0, za = 0, Fg = 0, Dg = 0, Vl = 0, KA, ZA, Yi, qi, di = {
  point: Jo,
  lineStart: h2,
  lineEnd: d2,
  polygonStart: function() {
    di.lineStart = K9, di.lineEnd = Z9;
  },
  polygonEnd: function() {
    di.point = Jo, di.lineStart = h2, di.lineEnd = d2;
  },
  result: function() {
    var e = Vl ? [Fg / Vl, Dg / Vl] : za ? [Wd / za, Gd / za] : Pl ? [Bg / Pl, Ng / Pl] : [NaN, NaN];
    return Bg = Ng = Pl = Wd = Gd = za = Fg = Dg = Vl = 0, e;
  }
};
function Jo(e, t) {
  Bg += e, Ng += t, ++Pl;
}
function h2() {
  di.point = X9;
}
function X9(e, t) {
  di.point = H9, Jo(Yi = e, qi = t);
}
function H9(e, t) {
  var n = e - Yi, i = t - qi, r = ln(n * n + i * i);
  Wd += r * (Yi + e) / 2, Gd += r * (qi + t) / 2, za += r, Jo(Yi = e, qi = t);
}
function d2() {
  di.point = Jo;
}
function K9() {
  di.point = J9;
}
function Z9() {
  JA(KA, ZA);
}
function J9(e, t) {
  di.point = JA, Jo(KA = Yi = e, ZA = qi = t);
}
function JA(e, t) {
  var n = e - Yi, i = t - qi, r = ln(n * n + i * i);
  Wd += r * (Yi + e) / 2, Gd += r * (qi + t) / 2, za += r, r = qi * e - Yi * t, Fg += r * (Yi + e), Dg += r * (qi + t), Vl += r * 3, Jo(Yi = e, qi = t);
}
const p2 = di;
function QA(e) {
  this._context = e;
}
QA.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, On);
        break;
      }
    }
  },
  result: Nn
};
var Eg = new tr(), K0, tM, eM, jl, Yl, Xd = {
  point: Nn,
  lineStart: function() {
    Xd.point = Q9;
  },
  lineEnd: function() {
    K0 && nM(tM, eM), Xd.point = Nn;
  },
  polygonStart: function() {
    K0 = !0;
  },
  polygonEnd: function() {
    K0 = null;
  },
  result: function() {
    var e = +Eg;
    return Eg = new tr(), e;
  }
};
function Q9(e, t) {
  Xd.point = nM, tM = jl = e, eM = Yl = t;
}
function nM(e, t) {
  jl -= e, Yl -= t, Eg.add(ln(jl * jl + Yl * Yl)), jl = e, Yl = t;
}
const y2 = Xd;
let m2, Hd, g2, b2;
class _2 {
  constructor(t) {
    this._append = t == null ? iM : tU(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 !== g2 || this._append !== Hd) {
          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`, g2 = i, Hd = this._append, b2 = this._, this._ = r;
        }
        this._ += b2;
        break;
      }
    }
  }
  result() {
    const t = this._;
    return this._ = "", t.length ? t : null;
  }
}
function iM(e) {
  let t = 1;
  this._ += e[0];
  for (const n = e.length; t < n; ++t)
    this._ += arguments[t] + e[t];
}
function tU(e) {
  const t = Math.floor(e);
  if (!(t >= 0))
    throw new RangeError(`invalid digits: ${e}`);
  if (t > 15)
    return iM;
  if (t !== m2) {
    const n = 10 ** t;
    m2 = t, Hd = 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 Hd;
}
function to(e, t) {
  let n = 3, i = 4.5, r, s;
  function o(a) {
    return a && (typeof i == "function" && s.pointRadius(+i.apply(this, arguments)), xs(a, r(s))), s.result();
  }
  return o.area = function(a) {
    return xs(a, r(f2)), f2.result();
  }, o.measure = function(a) {
    return xs(a, r(y2)), y2.result();
  }, o.bounds = function(a) {
    return xs(a, r(qd)), qd.result();
  }, o.centroid = function(a) {
    return xs(a, r(p2)), p2.result();
  }, o.projection = function(a) {
    return arguments.length ? (r = a == null ? (e = null, Ag) : (e = a).stream, o) : e;
  }, o.context = function(a) {
    return arguments.length ? (s = a == null ? (t = null, new _2(n)) : new QA(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 _2(n)), o;
  }, o.projection(e).digits(n).context(t);
}
function Kd(e) {
  return {
    stream: Iy(e)
  };
}
function Iy(e) {
  return function(t) {
    var n = new Og();
    for (var i in e)
      n[i] = e[i];
    return n.stream = t, n;
  };
}
function Og() {
}
Og.prototype = {
  constructor: Og,
  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 wb(e, t, n) {
  var i = e.clipExtent && e.clipExtent();
  return e.scale(150).translate([0, 0]), i != null && e.clipExtent(null), xs(n, e.stream(qd)), t(qd.result()), i != null && e.clipExtent(i), e;
}
function vb(e, t, n) {
  return wb(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 rM(e, t, n) {
  return vb(e, [[0, 0], t], n);
}
function sM(e, t, n) {
  return wb(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 oM(e, t, n) {
  return wb(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 w2 = 16, eU = at(30 * Pt);
function v2(e, t) {
  return +t ? iU(e, t) : nU(e);
}
function nU(e) {
  return Iy({
    point: function(t, n) {
      t = e(t, n), this.stream.point(t[0], t[1]);
    }
  });
}
function iU(e, t) {
  function n(i, r, s, o, a, c, l, u, f, h, d, p, m, g) {
    var y = l - i, b = u - r, _ = y * y + b * b;
    if (_ > 4 * t && m--) {
      var w = o + h, x = a + d, v = c + p, I = ln(w * w + x * x + v * v), T = bn(v /= I), F = qt(qt(v) - 1) < ot || qt(s - f) < ot ? (s + f) / 2 : vi(x, w), A = e(F, T), $ = A[0], D = A[1], O = $ - i, S = D - r, M = b * O - y * S;
      (M * M / _ > t || qt((y * O + b * S) / _ - 0.5) > 0.3 || o * h + a * d + c * p < eU) && (n(i, r, s, o, a, c, $, D, F, w /= I, x /= I, v, m, g), g.point($, D), n($, D, F, w, x, v, l, u, f, h, d, p, m, g));
    }
  }
  return function(i) {
    var r, s, o, a, c, l, u, f, h, d, p, m, g = {
      point: y,
      lineStart: b,
      lineEnd: w,
      polygonStart: function() {
        i.polygonStart(), g.lineStart = x;
      },
      polygonEnd: function() {
        i.polygonEnd(), g.lineStart = b;
      }
    };
    function y(T, F) {
      T = e(T, F), i.point(T[0], T[1]);
    }
    function b() {
      f = NaN, g.point = _, i.lineStart();
    }
    function _(T, F) {
      var A = Ic([T, F]), $ = e(T, F);
      n(f, h, u, d, p, m, f = $[0], h = $[1], u = T, d = A[0], p = A[1], m = A[2], w2, i), i.point(f, h);
    }
    function w() {
      g.point = y, i.lineEnd();
    }
    function x() {
      b(), g.point = v, g.lineEnd = I;
    }
    function v(T, F) {
      _(r = T, F), s = f, o = h, a = d, c = p, l = m, g.point = _;
    }
    function I() {
      n(f, h, u, d, p, m, s, o, r, a, c, l, w2, i), g.lineEnd = w, w();
    }
    return g;
  };
}
var rU = Iy({
  point: function(e, t) {
    this.stream.point(e * Pt, t * Pt);
  }
});
function sU(e) {
  return Iy({
    point: function(t, n) {
      var i = e(t, n);
      return this.stream.point(i[0], i[1]);
    }
  });
}
function oU(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 x2(e, t, n, i, r, s) {
  if (!s)
    return oU(e, t, n, i, r);
  var o = at(s), a = et(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(m, g) {
    return m *= i, g *= r, [c * m - l * g + t, n - l * m - c * g];
  }
  return p.invert = function(m, g) {
    return [i * (u * m - f * g + h), r * (d - f * m - u * g)];
  }, p;
}
function eo(e) {
  return aM(function() {
    return e;
  })();
}
function aM(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, m = c2, g = null, y, b, _, w = Ag, x = 0.5, v, I, T, F, A;
  function $(M) {
    return T(M[0] * Pt, M[1] * Pt);
  }
  function D(M) {
    return M = T.invert(M[0], M[1]), M && [M[0] * Ve, M[1] * Ve];
  }
  $.stream = function(M) {
    return F && A === M ? F : F = rU(sU(u)(m(v(w(A = M)))));
  }, $.preclip = function(M) {
    return arguments.length ? (m = M, p = void 0, S()) : m;
  }, $.postclip = function(M) {
    return arguments.length ? (w = M, g = y = b = _ = null, S()) : w;
  }, $.clipAngle = function(M) {
    return arguments.length ? (m = +M ? U9(p = M * Pt) : (p = null, c2), S()) : p * Ve;
  }, $.clipExtent = function(M) {
    return arguments.length ? (w = M == null ? (g = y = b = _ = null, Ag) : WA(g = +M[0][0], y = +M[0][1], b = +M[1][0], _ = +M[1][1]), S()) : g == null ? null : [[g, y], [b, _]];
  }, $.scale = function(M) {
    return arguments.length ? (n = +M, O()) : n;
  }, $.translate = function(M) {
    return arguments.length ? (i = +M[0], r = +M[1], O()) : [i, r];
  }, $.center = function(M) {
    return arguments.length ? (s = M[0] % 360 * Pt, o = M[1] % 360 * Pt, O()) : [s * Ve, o * Ve];
  }, $.rotate = function(M) {
    return arguments.length ? (a = M[0] % 360 * Pt, c = M[1] % 360 * Pt, l = M.length > 2 ? M[2] % 360 * Pt : 0, O()) : [a * Ve, c * Ve, l * Ve];
  }, $.angle = function(M) {
    return arguments.length ? (f = M % 360 * Pt, O()) : f * Ve;
  }, $.reflectX = function(M) {
    return arguments.length ? (h = M ? -1 : 1, O()) : h < 0;
  }, $.reflectY = function(M) {
    return arguments.length ? (d = M ? -1 : 1, O()) : d < 0;
  }, $.precision = function(M) {
    return arguments.length ? (v = v2(I, x = M * M), S()) : ln(x);
  }, $.fitExtent = function(M, B) {
    return vb($, M, B);
  }, $.fitSize = function(M, B) {
    return rM($, M, B);
  }, $.fitWidth = function(M, B) {
    return sM($, M, B);
  }, $.fitHeight = function(M, B) {
    return oM($, M, B);
  };
  function O() {
    var M = x2(n, 0, 0, h, d, f).apply(null, t(s, o)), B = x2(n, i - M[0], r - M[1], h, d, f);
    return u = VA(a, c, l), I = Sg(t, B), T = Sg(u, I), v = v2(I, x), S();
  }
  function S() {
    return F = A = null, $;
  }
  return function() {
    return t = e.apply(this, arguments), $.invert = t.invert && D, O();
  };
}
function xb(e) {
  var t = 0, n = Ft / 3, i = aM(e), r = i(t, n);
  return r.parallels = function(s) {
    return arguments.length ? i(t = s[0] * Pt, n = s[1] * Pt) : [t * Ve, n * Ve];
  }, r;
}
function aU(e) {
  var t = at(e);
  function n(i, r) {
    return [i * t, et(r) / t];
  }
  return n.invert = function(i, r) {
    return [i / t, bn(r * t)];
  }, n;
}
function cU(e, t) {
  var n = et(e), i = (n + et(t)) / 2;
  if (qt(i) < ot)
    return aU(e);
  var r = 1 + n * (2 * i - n), s = ln(r) / i;
  function o(a, c) {
    var l = ln(r - 2 * i * et(c)) / i;
    return [l * et(a *= i), s - l * at(a)];
  }
  return o.invert = function(a, c) {
    var l = s - c, u = vi(a, qt(l)) * Xn(l);
    return l * i < 0 && (u -= Ft * Xn(a) * Xn(l)), [u / i, bn((r - (a * a + l * l) * i * i) / (2 * i))];
  }, o;
}
function Zd() {
  return xb(cU).scale(155.424).center([0, 33.6442]);
}
function cM() {
  return Zd().parallels([29.5, 45.5]).scale(1070).translate([480, 250]).rotate([96, 0]).center([-0.6, 38.7]);
}
function lU(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 uU() {
  var e, t, n = cM(), i, r = Zd().rotate([154, 0]).center([-2, 58.5]).parallels([55, 65]), s, o = Zd().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(), m = (h[0] - p[0]) / d, g = (h[1] - p[1]) / d;
    return (g >= 0.12 && g < 0.234 && m >= -0.425 && m < -0.214 ? r : g >= 0.166 && g < 0.234 && m >= -0.214 && m < -0.115 ? o : n).invert(h);
  }, u.stream = function(h) {
    return e && t === h ? e : e = lU([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], m = +h[1];
    return i = n.translate(h).clipExtent([[p - 0.455 * d, m - 0.238 * d], [p + 0.455 * d, m + 0.238 * d]]).stream(l), s = r.translate([p - 0.307 * d, m + 0.201 * d]).clipExtent([[p - 0.425 * d + ot, m + 0.12 * d + ot], [p - 0.214 * d - ot, m + 0.234 * d - ot]]).stream(l), a = o.translate([p - 0.205 * d, m + 0.212 * d]).clipExtent([[p - 0.214 * d + ot, m + 0.166 * d + ot], [p - 0.115 * d - ot, m + 0.234 * d - ot]]).stream(l), f();
  }, u.fitExtent = function(h, d) {
    return vb(u, h, d);
  }, u.fitSize = function(h, d) {
    return rM(u, h, d);
  }, u.fitWidth = function(h, d) {
    return sM(u, h, d);
  }, u.fitHeight = function(h, d) {
    return oM(u, h, d);
  };
  function f() {
    return e = t = null, u;
  }
  return u.scale(1070);
}
function lM(e) {
  return function(t, n) {
    var i = at(t), r = at(n), s = e(i * r);
    return s === 1 / 0 ? [2, 0] : [
      s * r * et(t),
      s * et(n)
    ];
  };
}
function rf(e) {
  return function(t, n) {
    var i = ln(t * t + n * n), r = e(i), s = et(r), o = at(r);
    return [
      vi(t * s, i * o),
      bn(i && n * s / i)
    ];
  };
}
var uM = lM(function(e) {
  return ln(2 / (1 + e));
});
uM.invert = rf(function(e) {
  return 2 * bn(e / 2);
});
function fU() {
  return eo(uM).scale(124.75).clipAngle(180 - 1e-3);
}
var fM = lM(function(e) {
  return (e = kA(e)) && e / et(e);
});
fM.invert = rf(function(e) {
  return e;
});
function hU() {
  return eo(fM).scale(79.4188).clipAngle(180 - 1e-3);
}
function Ay(e, t) {
  return [e, Ed(bb((Ae + t) / 2))];
}
Ay.invert = function(e, t) {
  return [e, 2 * Kc(CA(t)) - Ae];
};
function dU() {
  return hM(Ay).scale(961 / On);
}
function hM(e) {
  var t = eo(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 = Ft * i(), h = t(F9(t.rotate()).invert([0, 0]));
    return s(o == null ? [[h[0] - f, h[1] - f], [h[0] + f, h[1] + f]] : e === Ay ? [[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 Xf(e) {
  return bb((Ae + e) / 2);
}
function pU(e, t) {
  var n = at(e), i = e === t ? et(e) : Ed(n / at(t)) / Ed(Xf(t) / Xf(e)), r = n * W0(Xf(e), i) / i;
  if (!i)
    return Ay;
  function s(o, a) {
    r > 0 ? a < -Ae + ot && (a = -Ae + ot) : a > Ae - ot && (a = Ae - ot);
    var c = r / W0(Xf(a), i);
    return [c * et(i * o), r - c * at(i * o)];
  }
  return s.invert = function(o, a) {
    var c = r - a, l = Xn(i) * ln(o * o + c * c), u = vi(o, qt(c)) * Xn(c);
    return c * i < 0 && (u -= Ft * Xn(o) * Xn(c)), [u / i, 2 * Kc(W0(r / l, 1 / i)) - Ae];
  }, s;
}
function yU() {
  return xb(pU).scale(109.5).parallels([30, 30]);
}
function Jd(e, t) {
  return [e, t];
}
Jd.invert = Jd;
function mU() {
  return eo(Jd).scale(152.63);
}
function gU(e, t) {
  var n = at(e), i = e === t ? et(e) : (n - at(t)) / (t - e), r = n / i + e;
  if (qt(i) < ot)
    return Jd;
  function s(o, a) {
    var c = r - a, l = i * o;
    return [c * et(l), r - c * at(l)];
  }
  return s.invert = function(o, a) {
    var c = r - a, l = vi(o, qt(c)) * Xn(c);
    return c * i < 0 && (l -= Ft * Xn(o) * Xn(c)), [l / i, r - Xn(i) * ln(o * o + c * c)];
  }, s;
}
function bU() {
  return xb(gU).scale(131.154).center([0, 13.9389]);
}
var Kl = 1.340264, Zl = -0.081106, Jl = 893e-6, Ql = 3796e-6, Qd = ln(3) / 2, _U = 12;
function dM(e, t) {
  var n = bn(Qd * et(t)), i = n * n, r = i * i * i;
  return [
    e * at(n) / (Qd * (Kl + 3 * Zl * i + r * (7 * Jl + 9 * Ql * i))),
    n * (Kl + Zl * i + r * (Jl + Ql * i))
  ];
}
dM.invert = function(e, t) {
  for (var n = t, i = n * n, r = i * i * i, s = 0, o, a, c; s < _U && (a = n * (Kl + Zl * i + r * (Jl + Ql * i)) - t, c = Kl + 3 * Zl * i + r * (7 * Jl + 9 * Ql * i), n -= o = a / c, i = n * n, r = i * i * i, !(qt(o) < Dd)); ++s)
    ;
  return [
    Qd * e * (Kl + 3 * Zl * i + r * (7 * Jl + 9 * Ql * i)) / at(n),
    bn(et(n) / Qd)
  ];
};
function wU() {
  return eo(dM).scale(177.158);
}
function pM(e, t) {
  var n = at(t), i = at(e) * n;
  return [n * et(e) / i, et(t) / i];
}
pM.invert = rf(Kc);
function vU() {
  return eo(pM).scale(144.049).clipAngle(60);
}
function yM(e, t) {
  return [at(t) * et(e), et(t)];
}
yM.invert = rf(bn);
function xU() {
  return eo(yM).scale(249.5).clipAngle(90 + ot);
}
function mM(e, t) {
  var n = at(t), i = 1 + at(e) * n;
  return [n * et(e) / i, et(t) / i];
}
mM.invert = rf(function(e) {
  return 2 * Kc(e);
});
function SU() {
  return eo(mM).scale(250).clipAngle(142);
}
function gM(e, t) {
  return [Ed(bb((Ae + t) / 2)), -e];
}
gM.invert = function(e, t) {
  return [-t, 2 * Kc(CA(e)) - Ae];
};
function IU() {
  var e = hM(gM), 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 AU(e, t) {
  return e.parent === t.parent ? 1 : 2;
}
function MU(e) {
  return e.reduce($U, 0) / e.length;
}
function $U(e, t) {
  return e + t.x;
}
function TU(e) {
  return 1 + e.reduce(BU, 0);
}
function BU(e, t) {
  return Math.max(e, t.y);
}
function NU(e) {
  for (var t; t = e.children; )
    e = t[0];
  return e;
}
function FU(e) {
  for (var t; t = e.children; )
    e = t[t.length - 1];
  return e;
}
function bM() {
  var e = AU, t = 1, n = 1, i = !1;
  function r(s) {
    var o, a = 0;
    s.eachAfter(function(h) {
      var d = h.children;
      d ? (h.x = MU(d), h.y = TU(d)) : (h.x = o ? a += e(h, o) : 0, h.y = 0, o = h);
    });
    var c = NU(s), l = FU(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 DU(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 EU() {
  return this.eachAfter(DU);
}
function OU(e, t) {
  let n = -1;
  for (const i of this)
    e.call(t, i, ++n, this);
  return this;
}
function LU(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 RU(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 CU(e, t) {
  let n = -1;
  for (const i of this)
    if (e.call(t, i, ++n, this))
      return i;
}
function kU(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 UU(e) {
  return this.eachBefore(function(t) {
    t.children && t.children.sort(e);
  });
}
function zU(e) {
  for (var t = this, n = PU(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 PU(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 VU() {
  for (var e = this, t = [e]; e = e.parent; )
    t.push(e);
  return t;
}
function jU() {
  return Array.from(this);
}
function YU() {
  var e = [];
  return this.eachBefore(function(t) {
    t.children || e.push(t);
  }), e;
}
function qU() {
  var e = this, t = [];
  return e.each(function(n) {
    n !== e && t.push({ source: n.parent, target: n });
  }), t;
}
function* WU() {
  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 _M(e, t) {
  e instanceof Map ? (e = [void 0, e], t === void 0 && (t = HU)) : t === void 0 && (t = XU);
  for (var n = new Mc(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 Mc(o[a])), s.parent = i, s.depth = i.depth + 1;
  return n.eachBefore(wM);
}
function GU() {
  return _M(this).eachBefore(KU);
}
function XU(e) {
  return e.children;
}
function HU(e) {
  return Array.isArray(e) ? e[1] : null;
}
function KU(e) {
  e.data.value !== void 0 && (e.value = e.data.value), e.data = e.data.data;
}
function wM(e) {
  var t = 0;
  do
    e.height = t;
  while ((e = e.parent) && e.height < ++t);
}
function Mc(e) {
  this.data = e, this.depth = this.height = 0, this.parent = null;
}
Mc.prototype = _M.prototype = {
  constructor: Mc,
  count: EU,
  each: OU,
  eachAfter: RU,
  eachBefore: LU,
  find: CU,
  sum: kU,
  sort: UU,
  path: zU,
  ancestors: VU,
  descendants: jU,
  leaves: YU,
  links: qU,
  copy: GU,
  [Symbol.iterator]: WU
};
function Z0(e) {
  return e == null ? null : ZU(e);
}
function ZU(e) {
  if (typeof e != "function")
    throw new Error();
  return e;
}
var JU = { depth: -1 }, S2 = {}, J0 = {};
function QU(e) {
  return e.id;
}
function tz(e) {
  return e.parentId;
}
function vM() {
  var e = QU, t = tz, n;
  function i(r) {
    var s = Array.from(r), o = e, a = t, c, l, u, f, h, d, p, m, g = /* @__PURE__ */ new Map();
    if (n != null) {
      const y = s.map((w, x) => ez(n(w, x, r))), b = y.map(I2), _ = new Set(y).add("");
      for (const w of b)
        _.has(w) || (_.add(w), y.push(w), b.push(I2(w)), s.push(J0));
      o = (w, x) => y[x], a = (w, x) => b[x];
    }
    for (u = 0, c = s.length; u < c; ++u)
      l = s[u], d = s[u] = new Mc(l), (p = o(l, u, r)) != null && (p += "") && (m = d.id = p, g.set(m, g.has(m) ? S2 : 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 === S2)
          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 === J0 && f.children.length === 1; )
        f = f.children[0], --c;
      for (let y = s.length - 1; y >= 0 && (d = s[y], d.data === J0); --y)
        d.data = null;
    }
    if (f.parent = JU, f.eachBefore(function(y) {
      y.depth = y.parent.depth + 1, --c;
    }).eachBefore(wM), f.parent = null, c > 0)
      throw new Error("cycle");
    return f;
  }
  return i.id = function(r) {
    return arguments.length ? (e = Z0(r), i) : e;
  }, i.parentId = function(r) {
    return arguments.length ? (t = Z0(r), i) : t;
  }, i.path = function(r) {
    return arguments.length ? (n = Z0(r), i) : n;
  }, i;
}
function ez(e) {
  e = `${e}`;
  let t = e.length;
  return Lg(e, t - 1) && !Lg(e, t - 2) && (e = e.slice(0, -1)), e[0] === "/" ? e : `/${e}`;
}
function I2(e) {
  let t = e.length;
  if (t < 2)
    return "";
  for (; --t > 1 && !Lg(e, t); )
    ;
  return e.slice(0, t);
}
function Lg(e, t) {
  if (e[t] === "/") {
    let n = 0;
    for (; t > 0 && e[--t] === "\\"; )
      ++n;
    if (!(n & 1))
      return !0;
  }
  return !1;
}
function nz(e, t) {
  return e.parent === t.parent ? 1 : 2;
}
function Q0(e) {
  var t = e.children;
  return t ? t[0] : e.t;
}
function tm(e) {
  var t = e.children;
  return t ? t[t.length - 1] : e.t;
}
function iz(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 rz(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 sz(e, t, n) {
  return e.a.parent === t.parent ? e.a : n;
}
function Dh(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;
}
Dh.prototype = Object.create(Mc.prototype);
function oz(e) {
  for (var t = new Dh(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 Dh(s[o], o)), r.parent = n;
  return (t.parent = new Dh(null, 0)).children = [t], t;
}
function tp() {
  var e = nz, t = 1, n = 1, i = null;
  function r(l) {
    var u = oz(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, m = p - f.x, g = t / (h.x + p + m), y = n / (d.depth || 1);
      l.eachBefore(function(b) {
        b.x = (b.x + m) * g, b.y = b.depth * y;
      });
    }
    return l;
  }
  function s(l) {
    var u = l.children, f = l.parent.children, h = l.i ? f[l.i - 1] : null;
    if (u) {
      rz(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, m = h.parent.children[0], g = h.m, y = d.m, b = p.m, _ = m.m, w; p = tm(p), h = Q0(h), p && h; )
        m = Q0(m), d = tm(d), d.a = l, w = p.z + b - h.z - g + e(p._, h._), w > 0 && (iz(sz(p, l, f), l, w), g += w, y += w), b += p.m, g += h.m, _ += m.m, y += d.m;
      p && !tm(d) && (d.t = p, d.m += b - y), h && !Q0(m) && (m.t = h, m.m += g - _, 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 az = 1664525, cz = 1013904223, A2 = 1 / 4294967296;
function Sb(e = Math.random()) {
  let t = (0 <= e && e < 1 ? e / A2 : Math.abs(e)) | 0;
  return () => (t = az * t + cz | 0, A2 * (t >>> 0));
}
function fr(e, t) {
  switch (arguments.length) {
    case 0:
      break;
    case 1:
      this.range(e);
      break;
    default:
      this.range(t).domain(e);
      break;
  }
  return this;
}
function My(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 Rg = Symbol("implicit");
function Ib() {
  var e = new Go(), t = [], n = [], i = Rg;
  function r(s) {
    let o = e.get(s);
    if (o === void 0) {
      if (i !== Rg)
        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 Go();
    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 Ib(t, n).unknown(i);
  }, fr.apply(r, arguments), r;
}
function $y() {
  var e = Ib().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, m = d ? i : r;
    s = (m - p) / Math.max(1, h - c + l * 2), a && (s = Math.floor(s)), p += (m - p - s * (h - c)) * u, o = s * (1 - c), a && (p = Math.round(p), o = Math.round(o));
    var g = Bn(h).map(function(y) {
      return p + s * y;
    });
    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 $y(t(), [i, r]).round(a).paddingInner(c).paddingOuter(l).align(u);
  }, fr.apply(f(), arguments);
}
function xM(e) {
  var t = e.copy;
  return e.padding = e.paddingOuter, delete e.paddingInner, delete e.paddingOuter, e.copy = function() {
    return xM(t());
  }, e;
}
function lz() {
  return xM($y.apply(null, arguments).paddingInner(1));
}
function uz(e) {
  return function() {
    return e;
  };
}
function Cg(e) {
  return +e;
}
var M2 = [0, 1];
function Hn(e) {
  return e;
}
function kg(e, t) {
  return (t -= e = +e) ? function(n) {
    return (n - e) / t;
  } : uz(isNaN(t) ? NaN : 0.5);
}
function fz(e, t) {
  var n;
  return e > t && (n = e, e = t, t = n), function(i) {
    return Math.max(e, Math.min(t, i));
  };
}
function hz(e, t, n) {
  var i = e[0], r = e[1], s = t[0], o = t[1];
  return r < i ? (i = kg(r, i), s = n(o, s)) : (i = kg(i, r), s = n(s, o)), function(a) {
    return s(i(a));
  };
}
function dz(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] = kg(e[o], e[o + 1]), s[o] = n(t[o], t[o + 1]);
  return function(a) {
    var c = hy(e, a, 1, i) - 1;
    return s[c](r[c](a));
  };
}
function sf(e, t) {
  return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown());
}
function Ty() {
  var e = M2, t = M2, n = Hc, i, r, s, o = Hn, a, c, l;
  function u() {
    var h = Math.min(e.length, t.length);
    return o !== Hn && (o = fz(e[0], e[h - 1])), a = h > 2 ? dz : hz, 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), Xe)))(h)));
  }, f.domain = function(h) {
    return arguments.length ? (e = Array.from(h, Cg), 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 = fb, u();
  }, f.clamp = function(h) {
    return arguments.length ? (o = h ? !0 : Hn, u()) : o !== Hn;
  }, 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 SM() {
  return Ty()(Hn, Hn);
}
function pz(e, t, n, i) {
  var r = Qm(e, t, n), s;
  switch (i = vu(i ?? ",f"), i.type) {
    case "s": {
      var o = Math.max(Math.abs(e), Math.abs(t));
      return i.precision == null && !isNaN(s = S9(r, o)) && (i.precision = s), RA(i, o);
    }
    case "":
    case "e":
    case "g":
    case "p":
    case "r": {
      i.precision == null && !isNaN(s = I9(r, Math.max(Math.abs(e), Math.abs(t)))) && (i.precision = s - (i.type === "e"));
      break;
    }
    case "f":
    case "%": {
      i.precision == null && !isNaN(s = x9(r)) && (i.precision = s - (i.type === "%") * 2);
      break;
    }
  }
  return ef(i);
}
function of(e) {
  var t = e.domain;
  return e.ticks = function(n) {
    var i = t();
    return ks(i[0], i[i.length - 1], n ?? 10);
  }, e.tickFormat = function(n, i) {
    var r = t();
    return pz(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 = mu(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 By() {
  var e = SM();
  return e.copy = function() {
    return sf(e, By());
  }, fr.apply(e, arguments), of(e);
}
function IM(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, Cg), n) : e.slice();
  }, n.unknown = function(i) {
    return arguments.length ? (t = i, n) : t;
  }, n.copy = function() {
    return IM(e).unknown(t);
  }, e = arguments.length ? Array.from(e, Cg) : [0, 1], of(n);
}
function AM(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 $2(e) {
  return Math.log(e);
}
function T2(e) {
  return Math.exp(e);
}
function yz(e) {
  return -Math.log(-e);
}
function mz(e) {
  return -Math.exp(-e);
}
function gz(e) {
  return isFinite(e) ? +("1e" + e) : e < 0 ? 0 : e;
}
function bz(e) {
  return e === 10 ? gz : e === Math.E ? Math.exp : (t) => Math.pow(e, t);
}
function _z(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 B2(e) {
  return (t, n) => -e(-t, n);
}
function MM(e) {
  const t = e($2, T2), n = t.domain;
  let i = 10, r, s;
  function o() {
    return r = _z(i), s = bz(i), n()[0] < 0 ? (r = B2(r), s = B2(s), e(yz, mz)) : e($2, T2), 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, m;
    const g = a == null ? 10 : +a;
    let y = [];
    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 (m = h < 0 ? p / s(-h) : p * s(h), !(m < l)) {
              if (m > u)
                break;
              y.push(m);
            }
      } else
        for (; h <= d; ++h)
          for (p = i - 1; p >= 1; --p)
            if (m = h > 0 ? p / s(-h) : p * s(h), !(m < l)) {
              if (m > u)
                break;
              y.push(m);
            }
      y.length * 2 < g && (y = ks(l, u, g));
    } else
      y = ks(h, d, Math.min(d - h, g)).map(s);
    return f ? y.reverse() : y;
  }, t.tickFormat = (a, c) => {
    if (a == null && (a = 10), c == null && (c = i === 10 ? "s" : ","), typeof c != "function" && (!(i % 1) && (c = vu(c)).precision == null && (c.trim = !0), c = ef(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(AM(n(), {
    floor: (a) => s(Math.floor(r(a))),
    ceil: (a) => s(Math.ceil(r(a)))
  })), t;
}
function $M() {
  const e = MM(Ty()).domain([1, 10]);
  return e.copy = () => sf(e, $M()).base(e.base()), fr.apply(e, arguments), e;
}
function N2(e) {
  return function(t) {
    return Math.sign(t) * Math.log1p(Math.abs(t / e));
  };
}
function F2(e) {
  return function(t) {
    return Math.sign(t) * Math.expm1(Math.abs(t)) * e;
  };
}
function TM(e) {
  var t = 1, n = e(N2(t), F2(t));
  return n.constant = function(i) {
    return arguments.length ? e(N2(t = +i), F2(t)) : t;
  }, of(n);
}
function BM() {
  var e = TM(Ty());
  return e.copy = function() {
    return sf(e, BM()).constant(e.constant());
  }, fr.apply(e, arguments);
}
function D2(e) {
  return function(t) {
    return t < 0 ? -Math.pow(-t, e) : Math.pow(t, e);
  };
}
function wz(e) {
  return e < 0 ? -Math.sqrt(-e) : Math.sqrt(e);
}
function vz(e) {
  return e < 0 ? -e * e : e * e;
}
function NM(e) {
  var t = e(Hn, Hn), n = 1;
  function i() {
    return n === 1 ? e(Hn, Hn) : n === 0.5 ? e(wz, vz) : e(D2(n), D2(1 / n));
  }
  return t.exponent = function(r) {
    return arguments.length ? (n = +r, i()) : n;
  }, of(t);
}
function FM() {
  var e = NM(Ty());
  return e.copy = function() {
    return sf(e, FM()).exponent(e.exponent());
  }, fr.apply(e, arguments), e;
}
function DM() {
  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] = TL(e, o / a);
    return s;
  }
  function s(o) {
    return o == null || isNaN(o = +o) ? i : t[hy(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(Be), 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 DM().domain(e).range(t).unknown(i);
  }, fr.apply(s, arguments);
}
function EM() {
  var e = [0.5], t = [0, 1], n, i = 1;
  function r(s) {
    return s != null && s <= s ? t[hy(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 EM().domain(e).range(t).unknown(n);
  }, fr.apply(r, arguments);
}
const em = /* @__PURE__ */ new Date(), nm = /* @__PURE__ */ new Date();
function Ee(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) => Ee((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) => (em.setTime(+s), nm.setTime(+o), e(em), e(nm), Math.floor(n(em, nm))), 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 ep = Ee(() => {
}, (e, t) => {
  e.setTime(+e + t);
}, (e, t) => t - e);
ep.every = (e) => (e = Math.floor(e), !isFinite(e) || !(e > 0) ? null : e > 1 ? Ee((t) => {
  t.setTime(Math.floor(t / e) * e);
}, (t, n) => {
  t.setTime(+t + n * e);
}, (t, n) => (n - t) / e) : ep);
ep.range;
const Pr = 1e3, Kn = Pr * 60, Vr = Kn * 60, ts = Vr * 24, Ab = ts * 7, E2 = ts * 30, im = ts * 365, jr = Ee((e) => {
  e.setTime(e - e.getMilliseconds());
}, (e, t) => {
  e.setTime(+e + t * Pr);
}, (e, t) => (t - e) / Pr, (e) => e.getUTCSeconds());
jr.range;
const Ny = Ee((e) => {
  e.setTime(e - e.getMilliseconds() - e.getSeconds() * Pr);
}, (e, t) => {
  e.setTime(+e + t * Kn);
}, (e, t) => (t - e) / Kn, (e) => e.getMinutes());
Ny.range;
const Fy = Ee((e) => {
  e.setUTCSeconds(0, 0);
}, (e, t) => {
  e.setTime(+e + t * Kn);
}, (e, t) => (t - e) / Kn, (e) => e.getUTCMinutes());
Fy.range;
const Dy = Ee((e) => {
  e.setTime(e - e.getMilliseconds() - e.getSeconds() * Pr - e.getMinutes() * Kn);
}, (e, t) => {
  e.setTime(+e + t * Vr);
}, (e, t) => (t - e) / Vr, (e) => e.getHours());
Dy.range;
const Ey = Ee((e) => {
  e.setUTCMinutes(0, 0, 0);
}, (e, t) => {
  e.setTime(+e + t * Vr);
}, (e, t) => (t - e) / Vr, (e) => e.getUTCHours());
Ey.range;
const Zc = Ee(
  (e) => e.setHours(0, 0, 0, 0),
  (e, t) => e.setDate(e.getDate() + t),
  (e, t) => (t - e - (t.getTimezoneOffset() - e.getTimezoneOffset()) * Kn) / ts,
  (e) => e.getDate() - 1
);
Zc.range;
const Oy = Ee((e) => {
  e.setUTCHours(0, 0, 0, 0);
}, (e, t) => {
  e.setUTCDate(e.getUTCDate() + t);
}, (e, t) => (t - e) / ts, (e) => e.getUTCDate() - 1);
Oy.range;
const Mb = Ee((e) => {
  e.setUTCHours(0, 0, 0, 0);
}, (e, t) => {
  e.setUTCDate(e.getUTCDate() + t);
}, (e, t) => (t - e) / ts, (e) => Math.floor(e / ts));
Mb.range;
function ia(e) {
  return Ee((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()) * Kn) / Ab);
}
const $c = ia(0), Su = ia(1), OM = ia(2), LM = ia(3), Qo = ia(4), RM = ia(5), CM = ia(6);
$c.range;
Su.range;
OM.range;
LM.range;
Qo.range;
RM.range;
CM.range;
function ra(e) {
  return Ee((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) / Ab);
}
const Tc = ra(0), Iu = ra(1), kM = ra(2), UM = ra(3), ta = ra(4), zM = ra(5), PM = ra(6);
Tc.range;
Iu.range;
kM.range;
UM.range;
ta.range;
zM.range;
PM.range;
const Ly = Ee((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());
Ly.range;
const Ry = Ee((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());
Ry.range;
const xi = Ee((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());
xi.every = (e) => !isFinite(e = Math.floor(e)) || !(e > 0) ? null : Ee((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);
});
xi.range;
const Si = Ee((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());
Si.every = (e) => !isFinite(e = Math.floor(e)) || !(e > 0) ? null : Ee((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);
});
Si.range;
function VM(e, t, n, i, r, s) {
  const o = [
    [jr, 1, Pr],
    [jr, 5, 5 * Pr],
    [jr, 15, 15 * Pr],
    [jr, 30, 30 * Pr],
    [s, 1, Kn],
    [s, 5, 5 * Kn],
    [s, 15, 15 * Kn],
    [s, 30, 30 * Kn],
    [r, 1, Vr],
    [r, 3, 3 * Vr],
    [r, 6, 6 * Vr],
    [r, 12, 12 * Vr],
    [i, 1, ts],
    [i, 2, 2 * ts],
    [n, 1, Ab],
    [t, 1, E2],
    [t, 3, 3 * E2],
    [e, 1, im]
  ];
  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 = du(([, , g]) => g).right(o, h);
    if (d === o.length)
      return e.every(Qm(l / im, u / im, f));
    if (d === 0)
      return ep.every(Math.max(Qm(l, u, f), 1));
    const [p, m] = o[h / o[d - 1][2] < o[d][2] / h ? d - 1 : d];
    return p.every(m);
  }
  return [a, c];
}
const [xz, jM] = VM(Si, Ry, Tc, Mb, Ey, Fy), [Sz, Iz] = VM(xi, Ly, $c, Zc, Dy, Ny);
function rm(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 sm(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 gl(e, t, n) {
  return { y: e, m: t, d: n, H: 0, M: 0, S: 0, L: 0 };
}
function Az(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 = bl(r), u = _l(r), f = bl(s), h = _l(s), d = bl(o), p = _l(o), m = bl(a), g = _l(a), y = bl(c), b = _l(c), _ = {
    a: N,
    A: L,
    b: k,
    B: U,
    c: null,
    d: U2,
    e: U2,
    f: Xz,
    g: rP,
    G: oP,
    H: qz,
    I: Wz,
    j: Gz,
    L: YM,
    m: Hz,
    M: Kz,
    p: V,
    q: j,
    Q: V2,
    s: j2,
    S: Zz,
    u: Jz,
    U: Qz,
    V: tP,
    w: eP,
    W: nP,
    x: null,
    X: null,
    y: iP,
    Y: sP,
    Z: aP,
    "%": P2
  }, w = {
    a: X,
    A: J,
    b: rt,
    B: Gt,
    c: null,
    d: z2,
    e: z2,
    f: fP,
    g: vP,
    G: SP,
    H: cP,
    I: lP,
    j: uP,
    L: WM,
    m: hP,
    M: dP,
    p: W,
    q: H,
    Q: V2,
    s: j2,
    S: pP,
    u: yP,
    U: mP,
    V: gP,
    w: bP,
    W: _P,
    x: null,
    X: null,
    y: wP,
    Y: xP,
    Z: IP,
    "%": P2
  }, x = {
    a: A,
    A: $,
    b: D,
    B: O,
    c: S,
    d: C2,
    e: C2,
    f: Pz,
    g: R2,
    G: L2,
    H: k2,
    I: k2,
    j: Cz,
    L: zz,
    m: Rz,
    M: kz,
    p: F,
    q: Lz,
    Q: jz,
    s: Yz,
    S: Uz,
    u: Nz,
    U: Fz,
    V: Dz,
    w: Bz,
    W: Ez,
    x: M,
    X: B,
    y: R2,
    Y: L2,
    Z: Oz,
    "%": Vz
  };
  _.x = v(n, _), _.X = v(i, _), _.c = v(t, _), w.x = v(n, w), w.X = v(i, w), w.c = v(t, w);
  function v(P, K) {
    return function(Z) {
      var z = [], tt = -1, lt = 0, zt = P.length, Dt, Q, ee;
      for (Z instanceof Date || (Z = /* @__PURE__ */ new Date(+Z)); ++tt < zt; )
        P.charCodeAt(tt) === 37 && (z.push(P.slice(lt, tt)), (Q = O2[Dt = P.charAt(++tt)]) != null ? Dt = P.charAt(++tt) : Q = Dt === "e" ? " " : "0", (ee = K[Dt]) && (Dt = ee(Z, Q)), z.push(Dt), lt = tt + 1);
      return z.push(P.slice(lt, tt)), z.join("");
    };
  }
  function I(P, K) {
    return function(Z) {
      var z = gl(1900, void 0, 1), tt = T(z, P, Z += "", 0), lt, zt;
      if (tt != Z.length)
        return null;
      if ("Q" in z)
        return new Date(z.Q);
      if ("s" in z)
        return new Date(z.s * 1e3 + ("L" in z ? z.L : 0));
      if (K && !("Z" in z) && (z.Z = 0), "p" in z && (z.H = z.H % 12 + z.p * 12), z.m === void 0 && (z.m = "q" in z ? z.q : 0), "V" in z) {
        if (z.V < 1 || z.V > 53)
          return null;
        "w" in z || (z.w = 1), "Z" in z ? (lt = sm(gl(z.y, 0, 1)), zt = lt.getUTCDay(), lt = zt > 4 || zt === 0 ? Iu.ceil(lt) : Iu(lt), lt = Oy.offset(lt, (z.V - 1) * 7), z.y = lt.getUTCFullYear(), z.m = lt.getUTCMonth(), z.d = lt.getUTCDate() + (z.w + 6) % 7) : (lt = rm(gl(z.y, 0, 1)), zt = lt.getDay(), lt = zt > 4 || zt === 0 ? Su.ceil(lt) : Su(lt), lt = Zc.offset(lt, (z.V - 1) * 7), z.y = lt.getFullYear(), z.m = lt.getMonth(), z.d = lt.getDate() + (z.w + 6) % 7);
      } else
        ("W" in z || "U" in z) && ("w" in z || (z.w = "u" in z ? z.u % 7 : "W" in z ? 1 : 0), zt = "Z" in z ? sm(gl(z.y, 0, 1)).getUTCDay() : rm(gl(z.y, 0, 1)).getDay(), z.m = 0, z.d = "W" in z ? (z.w + 6) % 7 + z.W * 7 - (zt + 5) % 7 : z.w + z.U * 7 - (zt + 6) % 7);
      return "Z" in z ? (z.H += z.Z / 100 | 0, z.M += z.Z % 100, sm(z)) : rm(z);
    };
  }
  function T(P, K, Z, z) {
    for (var tt = 0, lt = K.length, zt = Z.length, Dt, Q; tt < lt; ) {
      if (z >= zt)
        return -1;
      if (Dt = K.charCodeAt(tt++), Dt === 37) {
        if (Dt = K.charAt(tt++), Q = x[Dt in O2 ? K.charAt(tt++) : Dt], !Q || (z = Q(P, Z, z)) < 0)
          return -1;
      } else if (Dt != Z.charCodeAt(z++))
        return -1;
    }
    return z;
  }
  function F(P, K, Z) {
    var z = l.exec(K.slice(Z));
    return z ? (P.p = u.get(z[0].toLowerCase()), Z + z[0].length) : -1;
  }
  function A(P, K, Z) {
    var z = d.exec(K.slice(Z));
    return z ? (P.w = p.get(z[0].toLowerCase()), Z + z[0].length) : -1;
  }
  function $(P, K, Z) {
    var z = f.exec(K.slice(Z));
    return z ? (P.w = h.get(z[0].toLowerCase()), Z + z[0].length) : -1;
  }
  function D(P, K, Z) {
    var z = y.exec(K.slice(Z));
    return z ? (P.m = b.get(z[0].toLowerCase()), Z + z[0].length) : -1;
  }
  function O(P, K, Z) {
    var z = m.exec(K.slice(Z));
    return z ? (P.m = g.get(z[0].toLowerCase()), Z + z[0].length) : -1;
  }
  function S(P, K, Z) {
    return T(P, t, K, Z);
  }
  function M(P, K, Z) {
    return T(P, n, K, Z);
  }
  function B(P, K, Z) {
    return T(P, i, K, Z);
  }
  function N(P) {
    return o[P.getDay()];
  }
  function L(P) {
    return s[P.getDay()];
  }
  function k(P) {
    return c[P.getMonth()];
  }
  function U(P) {
    return a[P.getMonth()];
  }
  function V(P) {
    return r[+(P.getHours() >= 12)];
  }
  function j(P) {
    return 1 + ~~(P.getMonth() / 3);
  }
  function X(P) {
    return o[P.getUTCDay()];
  }
  function J(P) {
    return s[P.getUTCDay()];
  }
  function rt(P) {
    return c[P.getUTCMonth()];
  }
  function Gt(P) {
    return a[P.getUTCMonth()];
  }
  function W(P) {
    return r[+(P.getUTCHours() >= 12)];
  }
  function H(P) {
    return 1 + ~~(P.getUTCMonth() / 3);
  }
  return {
    format: function(P) {
      var K = v(P += "", _);
      return K.toString = function() {
        return P;
      }, K;
    },
    parse: function(P) {
      var K = I(P += "", !1);
      return K.toString = function() {
        return P;
      }, K;
    },
    utcFormat: function(P) {
      var K = v(P += "", w);
      return K.toString = function() {
        return P;
      }, K;
    },
    utcParse: function(P) {
      var K = I(P += "", !0);
      return K.toString = function() {
        return P;
      }, K;
    }
  };
}
var O2 = { "-": "", _: " ", 0: "0" }, Pe = /^\s*\d+/, Mz = /^%/, $z = /[\\^$*+?|[\]().{}]/g;
function Vt(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 Tz(e) {
  return e.replace($z, "\\$&");
}
function bl(e) {
  return new RegExp("^(?:" + e.map(Tz).join("|") + ")", "i");
}
function _l(e) {
  return new Map(e.map((t, n) => [t.toLowerCase(), n]));
}
function Bz(e, t, n) {
  var i = Pe.exec(t.slice(n, n + 1));
  return i ? (e.w = +i[0], n + i[0].length) : -1;
}
function Nz(e, t, n) {
  var i = Pe.exec(t.slice(n, n + 1));
  return i ? (e.u = +i[0], n + i[0].length) : -1;
}
function Fz(e, t, n) {
  var i = Pe.exec(t.slice(n, n + 2));
  return i ? (e.U = +i[0], n + i[0].length) : -1;
}
function Dz(e, t, n) {
  var i = Pe.exec(t.slice(n, n + 2));
  return i ? (e.V = +i[0], n + i[0].length) : -1;
}
function Ez(e, t, n) {
  var i = Pe.exec(t.slice(n, n + 2));
  return i ? (e.W = +i[0], n + i[0].length) : -1;
}
function L2(e, t, n) {
  var i = Pe.exec(t.slice(n, n + 4));
  return i ? (e.y = +i[0], n + i[0].length) : -1;
}
function R2(e, t, n) {
  var i = Pe.exec(t.slice(n, n + 2));
  return i ? (e.y = +i[0] + (+i[0] > 68 ? 1900 : 2e3), n + i[0].length) : -1;
}
function Oz(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 Lz(e, t, n) {
  var i = Pe.exec(t.slice(n, n + 1));
  return i ? (e.q = i[0] * 3 - 3, n + i[0].length) : -1;
}
function Rz(e, t, n) {
  var i = Pe.exec(t.slice(n, n + 2));
  return i ? (e.m = i[0] - 1, n + i[0].length) : -1;
}
function C2(e, t, n) {
  var i = Pe.exec(t.slice(n, n + 2));
  return i ? (e.d = +i[0], n + i[0].length) : -1;
}
function Cz(e, t, n) {
  var i = Pe.exec(t.slice(n, n + 3));
  return i ? (e.m = 0, e.d = +i[0], n + i[0].length) : -1;
}
function k2(e, t, n) {
  var i = Pe.exec(t.slice(n, n + 2));
  return i ? (e.H = +i[0], n + i[0].length) : -1;
}
function kz(e, t, n) {
  var i = Pe.exec(t.slice(n, n + 2));
  return i ? (e.M = +i[0], n + i[0].length) : -1;
}
function Uz(e, t, n) {
  var i = Pe.exec(t.slice(n, n + 2));
  return i ? (e.S = +i[0], n + i[0].length) : -1;
}
function zz(e, t, n) {
  var i = Pe.exec(t.slice(n, n + 3));
  return i ? (e.L = +i[0], n + i[0].length) : -1;
}
function Pz(e, t, n) {
  var i = Pe.exec(t.slice(n, n + 6));
  return i ? (e.L = Math.floor(i[0] / 1e3), n + i[0].length) : -1;
}
function Vz(e, t, n) {
  var i = Mz.exec(t.slice(n, n + 1));
  return i ? n + i[0].length : -1;
}
function jz(e, t, n) {
  var i = Pe.exec(t.slice(n));
  return i ? (e.Q = +i[0], n + i[0].length) : -1;
}
function Yz(e, t, n) {
  var i = Pe.exec(t.slice(n));
  return i ? (e.s = +i[0], n + i[0].length) : -1;
}
function U2(e, t) {
  return Vt(e.getDate(), t, 2);
}
function qz(e, t) {
  return Vt(e.getHours(), t, 2);
}
function Wz(e, t) {
  return Vt(e.getHours() % 12 || 12, t, 2);
}
function Gz(e, t) {
  return Vt(1 + Zc.count(xi(e), e), t, 3);
}
function YM(e, t) {
  return Vt(e.getMilliseconds(), t, 3);
}
function Xz(e, t) {
  return YM(e, t) + "000";
}
function Hz(e, t) {
  return Vt(e.getMonth() + 1, t, 2);
}
function Kz(e, t) {
  return Vt(e.getMinutes(), t, 2);
}
function Zz(e, t) {
  return Vt(e.getSeconds(), t, 2);
}
function Jz(e) {
  var t = e.getDay();
  return t === 0 ? 7 : t;
}
function Qz(e, t) {
  return Vt($c.count(xi(e) - 1, e), t, 2);
}
function qM(e) {
  var t = e.getDay();
  return t >= 4 || t === 0 ? Qo(e) : Qo.ceil(e);
}
function tP(e, t) {
  return e = qM(e), Vt(Qo.count(xi(e), e) + (xi(e).getDay() === 4), t, 2);
}
function eP(e) {
  return e.getDay();
}
function nP(e, t) {
  return Vt(Su.count(xi(e) - 1, e), t, 2);
}
function iP(e, t) {
  return Vt(e.getFullYear() % 100, t, 2);
}
function rP(e, t) {
  return e = qM(e), Vt(e.getFullYear() % 100, t, 2);
}
function sP(e, t) {
  return Vt(e.getFullYear() % 1e4, t, 4);
}
function oP(e, t) {
  var n = e.getDay();
  return e = n >= 4 || n === 0 ? Qo(e) : Qo.ceil(e), Vt(e.getFullYear() % 1e4, t, 4);
}
function aP(e) {
  var t = e.getTimezoneOffset();
  return (t > 0 ? "-" : (t *= -1, "+")) + Vt(t / 60 | 0, "0", 2) + Vt(t % 60, "0", 2);
}
function z2(e, t) {
  return Vt(e.getUTCDate(), t, 2);
}
function cP(e, t) {
  return Vt(e.getUTCHours(), t, 2);
}
function lP(e, t) {
  return Vt(e.getUTCHours() % 12 || 12, t, 2);
}
function uP(e, t) {
  return Vt(1 + Oy.count(Si(e), e), t, 3);
}
function WM(e, t) {
  return Vt(e.getUTCMilliseconds(), t, 3);
}
function fP(e, t) {
  return WM(e, t) + "000";
}
function hP(e, t) {
  return Vt(e.getUTCMonth() + 1, t, 2);
}
function dP(e, t) {
  return Vt(e.getUTCMinutes(), t, 2);
}
function pP(e, t) {
  return Vt(e.getUTCSeconds(), t, 2);
}
function yP(e) {
  var t = e.getUTCDay();
  return t === 0 ? 7 : t;
}
function mP(e, t) {
  return Vt(Tc.count(Si(e) - 1, e), t, 2);
}
function GM(e) {
  var t = e.getUTCDay();
  return t >= 4 || t === 0 ? ta(e) : ta.ceil(e);
}
function gP(e, t) {
  return e = GM(e), Vt(ta.count(Si(e), e) + (Si(e).getUTCDay() === 4), t, 2);
}
function bP(e) {
  return e.getUTCDay();
}
function _P(e, t) {
  return Vt(Iu.count(Si(e) - 1, e), t, 2);
}
function wP(e, t) {
  return Vt(e.getUTCFullYear() % 100, t, 2);
}
function vP(e, t) {
  return e = GM(e), Vt(e.getUTCFullYear() % 100, t, 2);
}
function xP(e, t) {
  return Vt(e.getUTCFullYear() % 1e4, t, 4);
}
function SP(e, t) {
  var n = e.getUTCDay();
  return e = n >= 4 || n === 0 ? ta(e) : ta.ceil(e), Vt(e.getUTCFullYear() % 1e4, t, 4);
}
function IP() {
  return "+0000";
}
function P2() {
  return "%";
}
function V2(e) {
  return +e;
}
function j2(e) {
  return Math.floor(+e / 1e3);
}
var ya, Cy, Au;
AP({
  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 AP(e) {
  return ya = Az(e), Cy = ya.format, ya.parse, Au = ya.utcFormat, ya.utcParse, ya;
}
function MP(e) {
  return new Date(e);
}
function $P(e) {
  return e instanceof Date ? +e : +/* @__PURE__ */ new Date(+e);
}
function $b(e, t, n, i, r, s, o, a, c, l) {
  var u = SM(), f = u.invert, h = u.domain, d = l(".%L"), p = l(":%S"), m = l("%I:%M"), g = l("%I %p"), y = l("%a %d"), b = l("%b %d"), _ = l("%B"), w = l("%Y");
  function x(v) {
    return (c(v) < v ? d : a(v) < v ? p : o(v) < v ? m : s(v) < v ? g : i(v) < v ? r(v) < v ? y : b : n(v) < v ? _ : w)(v);
  }
  return u.invert = function(v) {
    return new Date(f(v));
  }, u.domain = function(v) {
    return arguments.length ? h(Array.from(v, $P)) : h().map(MP);
  }, u.ticks = function(v) {
    var I = h();
    return e(I[0], I[I.length - 1], v ?? 10);
  }, u.tickFormat = function(v, I) {
    return I == null ? x : l(I);
  }, u.nice = function(v) {
    var I = h();
    return (!v || typeof v.range != "function") && (v = t(I[0], I[I.length - 1], v ?? 10)), v ? h(AM(I, v)) : u;
  }, u.copy = function() {
    return sf(u, $b(e, t, n, i, r, s, o, a, c, l));
  }, u;
}
function TP() {
  return fr.apply($b(Sz, Iz, xi, Ly, $c, Zc, Dy, Ny, jr, Cy).domain([new Date(2e3, 0, 1), new Date(2e3, 0, 2)]), arguments);
}
function BP() {
  return fr.apply($b(xz, jM, Si, Ry, Tc, Oy, Ey, Fy, jr, Au).domain([Date.UTC(2e3, 0, 1), Date.UTC(2e3, 0, 2)]), arguments);
}
function ky(e, t) {
  return t.domain(e.domain()).interpolator(e.interpolator()).clamp(e.clamp()).unknown(e.unknown());
}
function Uy() {
  var e = 0, t = 0.5, n = 1, i = 1, r, s, o, a, c, l = Hn, u, f = !1, h;
  function d(m) {
    return isNaN(m = +m) ? h : (m = 0.5 + ((m = +u(m)) - s) * (i * m < i * s ? a : c), l(f ? Math.max(0, Math.min(1, m)) : m));
  }
  d.domain = function(m) {
    return arguments.length ? ([e, t, n] = m, 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(m) {
    return arguments.length ? (f = !!m, d) : f;
  }, d.interpolator = function(m) {
    return arguments.length ? (l = m, d) : l;
  };
  function p(m) {
    return function(g) {
      var y, b, _;
      return arguments.length ? ([y, b, _] = g, l = vy(m, [y, b, _]), d) : [l(0), l(0.5), l(1)];
    };
  }
  return d.range = p(Hc), d.rangeRound = p(fb), d.unknown = function(m) {
    return arguments.length ? (h = m, d) : h;
  }, function(m) {
    return u = m, r = m(e), s = m(t), o = m(n), a = r === s ? 0 : 0.5 / (s - r), c = s === o ? 0 : 0.5 / (o - s), i = s < r ? -1 : 1, d;
  };
}
function XM() {
  var e = of(Uy()(Hn));
  return e.copy = function() {
    return ky(e, XM());
  }, My.apply(e, arguments);
}
function HM() {
  var e = MM(Uy()).domain([0.1, 1, 10]);
  return e.copy = function() {
    return ky(e, HM()).base(e.base());
  }, My.apply(e, arguments);
}
function KM() {
  var e = TM(Uy());
  return e.copy = function() {
    return ky(e, KM()).constant(e.constant());
  }, My.apply(e, arguments);
}
function ZM() {
  var e = NM(Uy());
  return e.copy = function() {
    return ky(e, ZM()).exponent(e.exponent());
  }, My.apply(e, arguments);
}
function $t(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 NP = $t("1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf"), FP = $t("7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666"), DP = $t("1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666"), EP = $t("a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928"), OP = $t("fbb4aeb3cde3ccebc5decbe4fed9a6ffffcce5d8bdfddaecf2f2f2"), LP = $t("b3e2cdfdcdaccbd5e8f4cae4e6f5c9fff2aef1e2cccccccc"), RP = $t("e41a1c377eb84daf4a984ea3ff7f00ffff33a65628f781bf999999"), CP = $t("66c2a5fc8d628da0cbe78ac3a6d854ffd92fe5c494b3b3b3"), kP = $t("8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f"), UP = $t("4e79a7f28e2ce1575976b7b259a14fedc949af7aa1ff9da79c755fbab0ab"), oe = (e) => V7(e[e.length - 1]);
var JM = new Array(3).concat(
  "d8b365f5f5f55ab4ac",
  "a6611adfc27d80cdc1018571",
  "a6611adfc27df5f5f580cdc1018571",
  "8c510ad8b365f6e8c3c7eae55ab4ac01665e",
  "8c510ad8b365f6e8c3f5f5f5c7eae55ab4ac01665e",
  "8c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e",
  "8c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e",
  "5430058c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e003c30",
  "5430058c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e003c30"
).map($t);
const QM = oe(JM);
var t6 = new Array(3).concat(
  "af8dc3f7f7f77fbf7b",
  "7b3294c2a5cfa6dba0008837",
  "7b3294c2a5cff7f7f7a6dba0008837",
  "762a83af8dc3e7d4e8d9f0d37fbf7b1b7837",
  "762a83af8dc3e7d4e8f7f7f7d9f0d37fbf7b1b7837",
  "762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b7837",
  "762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b7837",
  "40004b762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b783700441b",
  "40004b762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b783700441b"
).map($t);
const e6 = oe(t6);
var n6 = new Array(3).concat(
  "e9a3c9f7f7f7a1d76a",
  "d01c8bf1b6dab8e1864dac26",
  "d01c8bf1b6daf7f7f7b8e1864dac26",
  "c51b7de9a3c9fde0efe6f5d0a1d76a4d9221",
  "c51b7de9a3c9fde0eff7f7f7e6f5d0a1d76a4d9221",
  "c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221",
  "c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221",
  "8e0152c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221276419",
  "8e0152c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221276419"
).map($t);
const i6 = oe(n6);
var r6 = new Array(3).concat(
  "998ec3f7f7f7f1a340",
  "5e3c99b2abd2fdb863e66101",
  "5e3c99b2abd2f7f7f7fdb863e66101",
  "542788998ec3d8daebfee0b6f1a340b35806",
  "542788998ec3d8daebf7f7f7fee0b6f1a340b35806",
  "5427888073acb2abd2d8daebfee0b6fdb863e08214b35806",
  "5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b35806",
  "2d004b5427888073acb2abd2d8daebfee0b6fdb863e08214b358067f3b08",
  "2d004b5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b358067f3b08"
).map($t);
const s6 = oe(r6);
var Ug = new Array(3).concat(
  "ef8a62f7f7f767a9cf",
  "ca0020f4a58292c5de0571b0",
  "ca0020f4a582f7f7f792c5de0571b0",
  "b2182bef8a62fddbc7d1e5f067a9cf2166ac",
  "b2182bef8a62fddbc7f7f7f7d1e5f067a9cf2166ac",
  "b2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac",
  "b2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac",
  "67001fb2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac053061",
  "67001fb2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac053061"
).map($t);
const np = oe(Ug);
var o6 = new Array(3).concat(
  "ef8a62ffffff999999",
  "ca0020f4a582bababa404040",
  "ca0020f4a582ffffffbababa404040",
  "b2182bef8a62fddbc7e0e0e09999994d4d4d",
  "b2182bef8a62fddbc7ffffffe0e0e09999994d4d4d",
  "b2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d",
  "b2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d",
  "67001fb2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d1a1a1a",
  "67001fb2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d1a1a1a"
).map($t);
const a6 = oe(o6);
var zg = new Array(3).concat(
  "fc8d59ffffbf91bfdb",
  "d7191cfdae61abd9e92c7bb6",
  "d7191cfdae61ffffbfabd9e92c7bb6",
  "d73027fc8d59fee090e0f3f891bfdb4575b4",
  "d73027fc8d59fee090ffffbfe0f3f891bfdb4575b4",
  "d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4",
  "d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4",
  "a50026d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4313695",
  "a50026d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4313695"
).map($t);
const ip = oe(zg);
var c6 = new Array(3).concat(
  "fc8d59ffffbf91cf60",
  "d7191cfdae61a6d96a1a9641",
  "d7191cfdae61ffffbfa6d96a1a9641",
  "d73027fc8d59fee08bd9ef8b91cf601a9850",
  "d73027fc8d59fee08bffffbfd9ef8b91cf601a9850",
  "d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850",
  "d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850",
  "a50026d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850006837",
  "a50026d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850006837"
).map($t);
const l6 = oe(c6);
var u6 = new Array(3).concat(
  "fc8d59ffffbf99d594",
  "d7191cfdae61abdda42b83ba",
  "d7191cfdae61ffffbfabdda42b83ba",
  "d53e4ffc8d59fee08be6f59899d5943288bd",
  "d53e4ffc8d59fee08bffffbfe6f59899d5943288bd",
  "d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd",
  "d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd",
  "9e0142d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd5e4fa2",
  "9e0142d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd5e4fa2"
).map($t);
const f6 = oe(u6);
var h6 = new Array(3).concat(
  "e5f5f999d8c92ca25f",
  "edf8fbb2e2e266c2a4238b45",
  "edf8fbb2e2e266c2a42ca25f006d2c",
  "edf8fbccece699d8c966c2a42ca25f006d2c",
  "edf8fbccece699d8c966c2a441ae76238b45005824",
  "f7fcfde5f5f9ccece699d8c966c2a441ae76238b45005824",
  "f7fcfde5f5f9ccece699d8c966c2a441ae76238b45006d2c00441b"
).map($t);
const d6 = oe(h6);
var p6 = new Array(3).concat(
  "e0ecf49ebcda8856a7",
  "edf8fbb3cde38c96c688419d",
  "edf8fbb3cde38c96c68856a7810f7c",
  "edf8fbbfd3e69ebcda8c96c68856a7810f7c",
  "edf8fbbfd3e69ebcda8c96c68c6bb188419d6e016b",
  "f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d6e016b",
  "f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d810f7c4d004b"
).map($t);
const y6 = oe(p6);
var m6 = new Array(3).concat(
  "e0f3dba8ddb543a2ca",
  "f0f9e8bae4bc7bccc42b8cbe",
  "f0f9e8bae4bc7bccc443a2ca0868ac",
  "f0f9e8ccebc5a8ddb57bccc443a2ca0868ac",
  "f0f9e8ccebc5a8ddb57bccc44eb3d32b8cbe08589e",
  "f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe08589e",
  "f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe0868ac084081"
).map($t);
const g6 = oe(m6);
var b6 = new Array(3).concat(
  "fee8c8fdbb84e34a33",
  "fef0d9fdcc8afc8d59d7301f",
  "fef0d9fdcc8afc8d59e34a33b30000",
  "fef0d9fdd49efdbb84fc8d59e34a33b30000",
  "fef0d9fdd49efdbb84fc8d59ef6548d7301f990000",
  "fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301f990000",
  "fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301fb300007f0000"
).map($t);
const _6 = oe(b6);
var w6 = new Array(3).concat(
  "ece2f0a6bddb1c9099",
  "f6eff7bdc9e167a9cf02818a",
  "f6eff7bdc9e167a9cf1c9099016c59",
  "f6eff7d0d1e6a6bddb67a9cf1c9099016c59",
  "f6eff7d0d1e6a6bddb67a9cf3690c002818a016450",
  "fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016450",
  "fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016c59014636"
).map($t);
const v6 = oe(w6);
var x6 = new Array(3).concat(
  "ece7f2a6bddb2b8cbe",
  "f1eef6bdc9e174a9cf0570b0",
  "f1eef6bdc9e174a9cf2b8cbe045a8d",
  "f1eef6d0d1e6a6bddb74a9cf2b8cbe045a8d",
  "f1eef6d0d1e6a6bddb74a9cf3690c00570b0034e7b",
  "fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0034e7b",
  "fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0045a8d023858"
).map($t);
const S6 = oe(x6);
var I6 = new Array(3).concat(
  "e7e1efc994c7dd1c77",
  "f1eef6d7b5d8df65b0ce1256",
  "f1eef6d7b5d8df65b0dd1c77980043",
  "f1eef6d4b9dac994c7df65b0dd1c77980043",
  "f1eef6d4b9dac994c7df65b0e7298ace125691003f",
  "f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125691003f",
  "f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125698004367001f"
).map($t);
const A6 = oe(I6);
var M6 = new Array(3).concat(
  "fde0ddfa9fb5c51b8a",
  "feebe2fbb4b9f768a1ae017e",
  "feebe2fbb4b9f768a1c51b8a7a0177",
  "feebe2fcc5c0fa9fb5f768a1c51b8a7a0177",
  "feebe2fcc5c0fa9fb5f768a1dd3497ae017e7a0177",
  "fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a0177",
  "fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a017749006a"
).map($t);
const $6 = oe(M6);
var T6 = new Array(3).concat(
  "edf8b17fcdbb2c7fb8",
  "ffffcca1dab441b6c4225ea8",
  "ffffcca1dab441b6c42c7fb8253494",
  "ffffccc7e9b47fcdbb41b6c42c7fb8253494",
  "ffffccc7e9b47fcdbb41b6c41d91c0225ea80c2c84",
  "ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea80c2c84",
  "ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea8253494081d58"
).map($t);
const B6 = oe(T6);
var N6 = new Array(3).concat(
  "f7fcb9addd8e31a354",
  "ffffccc2e69978c679238443",
  "ffffccc2e69978c67931a354006837",
  "ffffccd9f0a3addd8e78c67931a354006837",
  "ffffccd9f0a3addd8e78c67941ab5d238443005a32",
  "ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443005a32",
  "ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443006837004529"
).map($t);
const F6 = oe(N6);
var D6 = new Array(3).concat(
  "fff7bcfec44fd95f0e",
  "ffffd4fed98efe9929cc4c02",
  "ffffd4fed98efe9929d95f0e993404",
  "ffffd4fee391fec44ffe9929d95f0e993404",
  "ffffd4fee391fec44ffe9929ec7014cc4c028c2d04",
  "ffffe5fff7bcfee391fec44ffe9929ec7014cc4c028c2d04",
  "ffffe5fff7bcfee391fec44ffe9929ec7014cc4c02993404662506"
).map($t);
const E6 = oe(D6);
var O6 = new Array(3).concat(
  "ffeda0feb24cf03b20",
  "ffffb2fecc5cfd8d3ce31a1c",
  "ffffb2fecc5cfd8d3cf03b20bd0026",
  "ffffb2fed976feb24cfd8d3cf03b20bd0026",
  "ffffb2fed976feb24cfd8d3cfc4e2ae31a1cb10026",
  "ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cb10026",
  "ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cbd0026800026"
).map($t);
const L6 = oe(O6);
var R6 = new Array(3).concat(
  "deebf79ecae13182bd",
  "eff3ffbdd7e76baed62171b5",
  "eff3ffbdd7e76baed63182bd08519c",
  "eff3ffc6dbef9ecae16baed63182bd08519c",
  "eff3ffc6dbef9ecae16baed64292c62171b5084594",
  "f7fbffdeebf7c6dbef9ecae16baed64292c62171b5084594",
  "f7fbffdeebf7c6dbef9ecae16baed64292c62171b508519c08306b"
).map($t);
const C6 = oe(R6);
var k6 = new Array(3).concat(
  "e5f5e0a1d99b31a354",
  "edf8e9bae4b374c476238b45",
  "edf8e9bae4b374c47631a354006d2c",
  "edf8e9c7e9c0a1d99b74c47631a354006d2c",
  "edf8e9c7e9c0a1d99b74c47641ab5d238b45005a32",
  "f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45005a32",
  "f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45006d2c00441b"
).map($t);
const U6 = oe(k6);
var z6 = new Array(3).concat(
  "f0f0f0bdbdbd636363",
  "f7f7f7cccccc969696525252",
  "f7f7f7cccccc969696636363252525",
  "f7f7f7d9d9d9bdbdbd969696636363252525",
  "f7f7f7d9d9d9bdbdbd969696737373525252252525",
  "fffffff0f0f0d9d9d9bdbdbd969696737373525252252525",
  "fffffff0f0f0d9d9d9bdbdbd969696737373525252252525000000"
).map($t);
const P6 = oe(z6);
var V6 = new Array(3).concat(
  "efedf5bcbddc756bb1",
  "f2f0f7cbc9e29e9ac86a51a3",
  "f2f0f7cbc9e29e9ac8756bb154278f",
  "f2f0f7dadaebbcbddc9e9ac8756bb154278f",
  "f2f0f7dadaebbcbddc9e9ac8807dba6a51a34a1486",
  "fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a34a1486",
  "fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a354278f3f007d"
).map($t);
const j6 = oe(V6);
var Y6 = new Array(3).concat(
  "fee0d2fc9272de2d26",
  "fee5d9fcae91fb6a4acb181d",
  "fee5d9fcae91fb6a4ade2d26a50f15",
  "fee5d9fcbba1fc9272fb6a4ade2d26a50f15",
  "fee5d9fcbba1fc9272fb6a4aef3b2ccb181d99000d",
  "fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181d99000d",
  "fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181da50f1567000d"
).map($t);
const q6 = oe(Y6);
var W6 = new Array(3).concat(
  "fee6cefdae6be6550d",
  "feeddefdbe85fd8d3cd94701",
  "feeddefdbe85fd8d3ce6550da63603",
  "feeddefdd0a2fdae6bfd8d3ce6550da63603",
  "feeddefdd0a2fdae6bfd8d3cf16913d948018c2d04",
  "fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d948018c2d04",
  "fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d94801a636037f2704"
).map($t);
const G6 = oe(W6);
function X6(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 H6 = hb(or(300, 0.5, 0), or(-240, 0.5, 1));
var K6 = hb(or(-100, 0.75, 0.35), or(80, 1.5, 0.8)), Z6 = hb(or(260, 0.75, 0.35), or(80, 1.5, 0.8)), Hf = or();
function J6(e) {
  (e < 0 || e > 1) && (e -= Math.floor(e));
  var t = Math.abs(e - 0.5);
  return Hf.h = 360 * e - 100, Hf.s = 1.5 - 1.5 * t, Hf.l = 0.8 - 0.9 * t, Hf + "";
}
var Kf = ei(), zP = Math.PI / 3, PP = Math.PI * 2 / 3;
function Q6(e) {
  var t;
  return e = (0.5 - e) * Math.PI, Kf.r = 255 * (t = Math.sin(e)) * t, Kf.g = 255 * (t = Math.sin(e + zP)) * t, Kf.b = 255 * (t = Math.sin(e + PP)) * t, Kf + "";
}
function t$(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 zy(e) {
  var t = e.length;
  return function(n) {
    return e[Math.max(0, Math.min(t - 1, Math.floor(n * t)))];
  };
}
const e$ = zy($t("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725"));
var n$ = zy($t("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf")), i$ = zy($t("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4")), r$ = zy($t("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921"));
function Ce(e) {
  return function() {
    return e;
  };
}
const s$ = Math.cos, Tb = Math.min, rp = Math.sin, Oe = Math.sqrt, Y2 = 1e-12, sp = Math.PI, Py = 2 * sp;
function o$(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 EA(t);
}
function a$(e) {
  return typeof e == "object" && "length" in e ? e : Array.from(e);
}
function c$(e) {
  this._context = e;
}
c$.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 af(e) {
  return new c$(e);
}
function l$(e) {
  return e[0];
}
function u$(e) {
  return e[1];
}
function f$(e, t) {
  var n = Ce(!0), i = null, r = af, s = null, o = o$(a);
  e = typeof e == "function" ? e : e === void 0 ? l$ : Ce(e), t = typeof t == "function" ? t : t === void 0 ? u$ : Ce(t);
  function a(c) {
    var l, u = (c = a$(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 : Ce(+c), a) : e;
  }, a.y = function(c) {
    return arguments.length ? (t = typeof c == "function" ? c : Ce(+c), a) : t;
  }, a.defined = function(c) {
    return arguments.length ? (n = typeof c == "function" ? c : Ce(!!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 Bb(e, t, n) {
  var i = null, r = Ce(!0), s = null, o = af, a = null, c = o$(l);
  e = typeof e == "function" ? e : e === void 0 ? l$ : Ce(+e), t = typeof t == "function" ? t : Ce(t === void 0 ? 0 : +t), n = typeof n == "function" ? n : n === void 0 ? u$ : Ce(+n);
  function l(f) {
    var h, d, p, m = (f = a$(f)).length, g, y = !1, b, _ = new Array(m), w = new Array(m);
    for (s == null && (a = o(b = c())), h = 0; h <= m; ++h) {
      if (!(h < m && r(g = f[h], h, f)) === y)
        if (y = !y)
          d = h, a.areaStart(), a.lineStart();
        else {
          for (a.lineEnd(), a.lineStart(), p = h - 1; p >= d; --p)
            a.point(_[p], w[p]);
          a.lineEnd(), a.areaEnd();
        }
      y && (_[h] = +e(g, h, f), w[h] = +t(g, h, f), a.point(i ? +i(g, h, f) : _[h], n ? +n(g, h, f) : w[h]));
    }
    if (b)
      return a = null, b + "" || null;
  }
  function u() {
    return f$().defined(r).curve(o).context(s);
  }
  return l.x = function(f) {
    return arguments.length ? (e = typeof f == "function" ? f : Ce(+f), i = null, l) : e;
  }, l.x0 = function(f) {
    return arguments.length ? (e = typeof f == "function" ? f : Ce(+f), l) : e;
  }, l.x1 = function(f) {
    return arguments.length ? (i = f == null ? null : typeof f == "function" ? f : Ce(+f), l) : i;
  }, l.y = function(f) {
    return arguments.length ? (t = typeof f == "function" ? f : Ce(+f), n = null, l) : t;
  }, l.y0 = function(f) {
    return arguments.length ? (t = typeof f == "function" ? f : Ce(+f), l) : t;
  }, l.y1 = function(f) {
    return arguments.length ? (n = f == null ? null : typeof f == "function" ? f : Ce(+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 : Ce(!!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 h$ {
  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 VP(e) {
  return new h$(e, !0);
}
function jP(e) {
  return new h$(e, !1);
}
const YP = Oe(3), d$ = {
  draw(e, t) {
    const n = Oe(t + Tb(t / 28, 0.75)) * 0.59436, i = n / 2, r = i * YP;
    e.moveTo(0, n), e.lineTo(0, -n), e.moveTo(-r, -i), e.lineTo(r, i), e.moveTo(-r, i), e.lineTo(r, -i);
  }
}, Mu = {
  draw(e, t) {
    const n = Oe(t / sp);
    e.moveTo(n, 0), e.arc(0, 0, n, 0, Py);
  }
}, p$ = {
  draw(e, t) {
    const n = Oe(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();
  }
}, y$ = Oe(1 / 3), qP = y$ * 2, m$ = {
  draw(e, t) {
    const n = Oe(t / qP), i = n * y$;
    e.moveTo(0, -n), e.lineTo(i, 0), e.lineTo(0, n), e.lineTo(-i, 0), e.closePath();
  }
}, g$ = {
  draw(e, t) {
    const n = Oe(t) * 0.62625;
    e.moveTo(0, -n), e.lineTo(n, 0), e.lineTo(0, n), e.lineTo(-n, 0), e.closePath();
  }
}, b$ = {
  draw(e, t) {
    const n = Oe(t - Tb(t / 7, 2)) * 0.87559;
    e.moveTo(-n, 0), e.lineTo(n, 0), e.moveTo(0, n), e.lineTo(0, -n);
  }
}, _$ = {
  draw(e, t) {
    const n = Oe(t), i = -n / 2;
    e.rect(i, i, n, n);
  }
}, w$ = {
  draw(e, t) {
    const n = Oe(t) * 0.4431;
    e.moveTo(n, n), e.lineTo(n, -n), e.lineTo(-n, -n), e.lineTo(-n, n), e.closePath();
  }
}, WP = 0.8908130915292852, v$ = rp(sp / 10) / rp(7 * sp / 10), GP = rp(Py / 10) * v$, XP = -s$(Py / 10) * v$, x$ = {
  draw(e, t) {
    const n = Oe(t * WP), i = GP * n, r = XP * n;
    e.moveTo(0, -n), e.lineTo(i, r);
    for (let s = 1; s < 5; ++s) {
      const o = Py * s / 5, a = s$(o), c = rp(o);
      e.lineTo(c * n, -a * n), e.lineTo(a * i - c * r, c * i + a * r);
    }
    e.closePath();
  }
}, om = Oe(3), S$ = {
  draw(e, t) {
    const n = -Oe(t / (om * 3));
    e.moveTo(0, n * 2), e.lineTo(-om * n, -n), e.lineTo(om * n, -n), e.closePath();
  }
}, HP = Oe(3), I$ = {
  draw(e, t) {
    const n = Oe(t) * 0.6824, i = n / 2, r = n * HP / 2;
    e.moveTo(0, -n), e.lineTo(r, i), e.lineTo(-r, i), e.closePath();
  }
}, Ln = -0.5, Rn = Oe(3) / 2, Pg = 1 / Oe(12), KP = (Pg / 2 + 1) * 3, A$ = {
  draw(e, t) {
    const n = Oe(t / KP), i = n / 2, r = n * Pg, s = i, o = n * Pg + n, a = -s, c = o;
    e.moveTo(i, r), e.lineTo(s, o), e.lineTo(a, c), e.lineTo(Ln * i - Rn * r, Rn * i + Ln * r), e.lineTo(Ln * s - Rn * o, Rn * s + Ln * o), e.lineTo(Ln * a - Rn * c, Rn * a + Ln * c), e.lineTo(Ln * i + Rn * r, Ln * r - Rn * i), e.lineTo(Ln * s + Rn * o, Ln * o - Rn * s), e.lineTo(Ln * a + Rn * c, Ln * c - Rn * a), e.closePath();
  }
}, M$ = {
  draw(e, t) {
    const n = Oe(t - Tb(t / 6, 1.7)) * 0.6189;
    e.moveTo(-n, -n), e.lineTo(n, n), e.moveTo(-n, n), e.lineTo(n, -n);
  }
}, ZP = [
  Mu,
  p$,
  m$,
  _$,
  x$,
  S$,
  A$
], JP = [
  Mu,
  b$,
  M$,
  I$,
  d$,
  w$,
  g$
];
function zs() {
}
function op(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 Vy(e) {
  this._context = e;
}
Vy.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:
        op(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:
        op(this, e, t);
        break;
    }
    this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t;
  }
};
function QP(e) {
  return new Vy(e);
}
function $$(e) {
  this._context = e;
}
$$.prototype = {
  areaStart: zs,
  areaEnd: zs,
  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:
        op(this, e, t);
        break;
    }
    this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t;
  }
};
function tV(e) {
  return new $$(e);
}
function T$(e) {
  this._context = e;
}
T$.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:
        op(this, e, t);
        break;
    }
    this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t;
  }
};
function eV(e) {
  return new T$(e);
}
function B$(e, t) {
  this._basis = new Vy(e), this._beta = t;
}
B$.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 nV = function e(t) {
  function n(i) {
    return t === 1 ? new Vy(i) : new B$(i, t);
  }
  return n.beta = function(i) {
    return e(+i);
  }, n;
}(0.85);
function ap(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 Nb(e, t) {
  this._context = e, this._k = (1 - t) / 6;
}
Nb.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:
        ap(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:
        ap(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 iV = function e(t) {
  function n(i) {
    return new Nb(i, t);
  }
  return n.tension = function(i) {
    return e(+i);
  }, n;
}(0);
function Fb(e, t) {
  this._context = e, this._k = (1 - t) / 6;
}
Fb.prototype = {
  areaStart: zs,
  areaEnd: zs,
  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:
        ap(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 rV = function e(t) {
  function n(i) {
    return new Fb(i, t);
  }
  return n.tension = function(i) {
    return e(+i);
  }, n;
}(0);
function Db(e, t) {
  this._context = e, this._k = (1 - t) / 6;
}
Db.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:
        ap(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 sV = function e(t) {
  function n(i) {
    return new Db(i, t);
  }
  return n.tension = function(i) {
    return e(+i);
  }, n;
}(0);
function Eb(e, t, n) {
  var i = e._x1, r = e._y1, s = e._x2, o = e._y2;
  if (e._l01_a > Y2) {
    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 > Y2) {
    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 N$(e, t) {
  this._context = e, this._alpha = t;
}
N$.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:
        Eb(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 oV = function e(t) {
  function n(i) {
    return t ? new N$(i, t) : new Nb(i, 0);
  }
  return n.alpha = function(i) {
    return e(+i);
  }, n;
}(0.5);
function F$(e, t) {
  this._context = e, this._alpha = t;
}
F$.prototype = {
  areaStart: zs,
  areaEnd: zs,
  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:
        Eb(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 aV = function e(t) {
  function n(i) {
    return t ? new F$(i, t) : new Fb(i, 0);
  }
  return n.alpha = function(i) {
    return e(+i);
  }, n;
}(0.5);
function D$(e, t) {
  this._context = e, this._alpha = t;
}
D$.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:
        Eb(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 cV = function e(t) {
  function n(i) {
    return t ? new D$(i, t) : new Db(i, 0);
  }
  return n.alpha = function(i) {
    return e(+i);
  }, n;
}(0.5);
function E$(e) {
  this._context = e;
}
E$.prototype = {
  areaStart: zs,
  areaEnd: zs,
  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 lV(e) {
  return new E$(e);
}
function q2(e) {
  return e < 0 ? -1 : 1;
}
function W2(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 (q2(s) + q2(o)) * Math.min(Math.abs(s), Math.abs(o), 0.5 * Math.abs(a)) || 0;
}
function G2(e, t) {
  var n = e._x1 - e._x0;
  return n ? (3 * (e._y1 - e._y0) / n - t) / 2 : t;
}
function am(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:
        am(this, this._t0, G2(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, am(this, G2(this, n = W2(this, e, t)), n);
          break;
        default:
          am(this, this._t0, n = W2(this, e, t));
          break;
      }
      this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t, this._t0 = n;
    }
  }
};
function O$(e) {
  this._context = new L$(e);
}
(O$.prototype = Object.create(cp.prototype)).point = function(e, t) {
  cp.prototype.point.call(this, t, e);
};
function L$(e) {
  this._context = e;
}
L$.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 uV(e) {
  return new cp(e);
}
function fV(e) {
  return new O$(e);
}
function R$(e) {
  this._context = e;
}
R$.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 = X2(e), r = X2(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 X2(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 hV(e) {
  return new R$(e);
}
function jy(e, t) {
  this._context = e, this._t = t;
}
jy.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 dV(e) {
  return new jy(e, 0.5);
}
function pV(e) {
  return new jy(e, 0);
}
function yV(e) {
  return new jy(e, 1);
}
const Zf = (e) => () => e;
function mV(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 Ji(e, t, n) {
  this.k = e, this.x = t, this.y = n;
}
Ji.prototype = {
  constructor: Ji,
  scale: function(e) {
    return e === 1 ? this : new Ji(this.k * e, this.x, this.y);
  },
  translate: function(e, t) {
    return e === 0 & t === 0 ? this : new Ji(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 C$ = new Ji(1, 0, 0);
Ji.prototype;
function cm(e) {
  e.stopImmediatePropagation();
}
function wl(e) {
  e.preventDefault(), e.stopImmediatePropagation();
}
function gV(e) {
  return (!e.ctrlKey || e.type === "wheel") && !e.button;
}
function bV() {
  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 H2() {
  return this.__zoom || C$;
}
function _V(e) {
  return -e.deltaY * (e.deltaMode === 1 ? 0.05 : e.deltaMode ? 1 : 2e-3) * (e.ctrlKey ? 10 : 1);
}
function wV() {
  return navigator.maxTouchPoints || "ontouchstart" in this;
}
function vV(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 xV() {
  var e = gV, t = bV, n = vV, i = _V, r = wV, s = [0, 1 / 0], o = [[-1 / 0, -1 / 0], [1 / 0, 1 / 0]], a = 250, c = iC, l = my("start", "zoom", "end"), u, f, h, d = 500, p = 150, m = 0, g = 10;
  function y(S) {
    S.property("__zoom", H2).on("wheel.zoom", T, { passive: !1 }).on("mousedown.zoom", F).on("dblclick.zoom", A).filter(r).on("touchstart.zoom", $).on("touchmove.zoom", D).on("touchend.zoom touchcancel.zoom", O).style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
  }
  y.transform = function(S, M, B, N) {
    var L = S.selection ? S.selection() : S;
    L.property("__zoom", H2), S !== L ? x(S, M, B, N) : L.interrupt().each(function() {
      v(this, arguments).event(N).start().zoom(null, typeof M == "function" ? M.apply(this, arguments) : M).end();
    });
  }, y.scaleBy = function(S, M, B, N) {
    y.scaleTo(S, function() {
      var L = this.__zoom.k, k = typeof M == "function" ? M.apply(this, arguments) : M;
      return L * k;
    }, B, N);
  }, y.scaleTo = function(S, M, B, N) {
    y.transform(S, function() {
      var L = t.apply(this, arguments), k = this.__zoom, U = B == null ? w(L) : typeof B == "function" ? B.apply(this, arguments) : B, V = k.invert(U), j = typeof M == "function" ? M.apply(this, arguments) : M;
      return n(_(b(k, j), U, V), L, o);
    }, B, N);
  }, y.translateBy = function(S, M, B, N) {
    y.transform(S, function() {
      return n(this.__zoom.translate(
        typeof M == "function" ? M.apply(this, arguments) : M,
        typeof B == "function" ? B.apply(this, arguments) : B
      ), t.apply(this, arguments), o);
    }, null, N);
  }, y.translateTo = function(S, M, B, N, L) {
    y.transform(S, function() {
      var k = t.apply(this, arguments), U = this.__zoom, V = N == null ? w(k) : typeof N == "function" ? N.apply(this, arguments) : N;
      return n(C$.translate(V[0], V[1]).scale(U.k).translate(
        typeof M == "function" ? -M.apply(this, arguments) : -M,
        typeof B == "function" ? -B.apply(this, arguments) : -B
      ), k, o);
    }, N, L);
  };
  function b(S, M) {
    return M = Math.max(s[0], Math.min(s[1], M)), M === S.k ? S : new Ji(M, S.x, S.y);
  }
  function _(S, M, B) {
    var N = M[0] - B[0] * S.k, L = M[1] - B[1] * S.k;
    return N === S.x && L === S.y ? S : new Ji(S.k, N, L);
  }
  function w(S) {
    return [(+S[0][0] + +S[1][0]) / 2, (+S[0][1] + +S[1][1]) / 2];
  }
  function x(S, M, B, N) {
    S.on("start.zoom", function() {
      v(this, arguments).event(N).start();
    }).on("interrupt.zoom end.zoom", function() {
      v(this, arguments).event(N).end();
    }).tween("zoom", function() {
      var L = this, k = arguments, U = v(L, k).event(N), V = t.apply(L, k), j = B == null ? w(V) : typeof B == "function" ? B.apply(L, k) : B, X = Math.max(V[1][0] - V[0][0], V[1][1] - V[0][1]), J = L.__zoom, rt = typeof M == "function" ? M.apply(L, k) : M, Gt = c(J.invert(j).concat(X / J.k), rt.invert(j).concat(X / rt.k));
      return function(W) {
        if (W === 1)
          W = rt;
        else {
          var H = Gt(W), P = X / H[2];
          W = new Ji(P, j[0] - H[0] * P, j[1] - H[1] * P);
        }
        U.zoom(null, W);
      };
    });
  }
  function v(S, M, B) {
    return !B && S.__zooming || new I(S, M);
  }
  function I(S, M) {
    this.that = S, this.args = M, this.active = 0, this.sourceEvent = null, this.extent = t.apply(S, M), 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, M) {
      return this.mouse && S !== "mouse" && (this.mouse[1] = M.invert(this.mouse[0])), this.touch0 && S !== "touch" && (this.touch0[1] = M.invert(this.touch0[0])), this.touch1 && S !== "touch" && (this.touch1[1] = M.invert(this.touch1[0])), this.that.__zoom = M, this.emit("zoom"), this;
    },
    end: function() {
      return --this.active === 0 && (delete this.that.__zooming, this.emit("end")), this;
    },
    emit: function(S) {
      var M = re(this.that).datum();
      l.call(
        S,
        this.that,
        new mV(S, {
          sourceEvent: this.sourceEvent,
          target: y,
          type: S,
          transform: this.that.__zoom,
          dispatch: l
        }),
        M
      );
    }
  };
  function T(S, ...M) {
    if (!e.apply(this, arguments))
      return;
    var B = v(this, M).event(S), N = this.__zoom, L = Math.max(s[0], Math.min(s[1], N.k * Math.pow(2, i.apply(this, arguments)))), k = ci(S);
    if (B.wheel)
      (B.mouse[0][0] !== k[0] || B.mouse[0][1] !== k[1]) && (B.mouse[1] = N.invert(B.mouse[0] = k)), clearTimeout(B.wheel);
    else {
      if (N.k === L)
        return;
      B.mouse = [k, N.invert(k)], Za(this), B.start();
    }
    wl(S), B.wheel = setTimeout(U, p), B.zoom("mouse", n(_(b(N, L), B.mouse[0], B.mouse[1]), B.extent, o));
    function U() {
      B.wheel = null, B.end();
    }
  }
  function F(S, ...M) {
    if (h || !e.apply(this, arguments))
      return;
    var B = S.currentTarget, N = v(this, M, !0).event(S), L = re(S.view).on("mousemove.zoom", j, !0).on("mouseup.zoom", X, !0), k = ci(S, B), U = S.clientX, V = S.clientY;
    aA(S.view), cm(S), N.mouse = [k, this.__zoom.invert(k)], Za(this), N.start();
    function j(J) {
      if (wl(J), !N.moved) {
        var rt = J.clientX - U, Gt = J.clientY - V;
        N.moved = rt * rt + Gt * Gt > m;
      }
      N.event(J).zoom("mouse", n(_(N.that.__zoom, N.mouse[0] = ci(J, B), N.mouse[1]), N.extent, o));
    }
    function X(J) {
      L.on("mousemove.zoom mouseup.zoom", null), cA(J.view, N.moved), wl(J), N.event(J).end();
    }
  }
  function A(S, ...M) {
    if (e.apply(this, arguments)) {
      var B = this.__zoom, N = ci(S.changedTouches ? S.changedTouches[0] : S, this), L = B.invert(N), k = B.k * (S.shiftKey ? 0.5 : 2), U = n(_(b(B, k), N, L), t.apply(this, M), o);
      wl(S), a > 0 ? re(this).transition().duration(a).call(x, U, N, S) : re(this).call(y.transform, U, N, S);
    }
  }
  function $(S, ...M) {
    if (e.apply(this, arguments)) {
      var B = S.touches, N = B.length, L = v(this, M, S.changedTouches.length === N).event(S), k, U, V, j;
      for (cm(S), U = 0; U < N; ++U)
        V = B[U], j = ci(V, this), j = [j, this.__zoom.invert(j), V.identifier], L.touch0 ? !L.touch1 && L.touch0[2] !== j[2] && (L.touch1 = j, L.taps = 0) : (L.touch0 = j, k = !0, L.taps = 1 + !!u);
      u && (u = clearTimeout(u)), k && (L.taps < 2 && (f = j[0], u = setTimeout(function() {
        u = null;
      }, d)), Za(this), L.start());
    }
  }
  function D(S, ...M) {
    if (this.__zooming) {
      var B = v(this, M).event(S), N = S.changedTouches, L = N.length, k, U, V, j;
      for (wl(S), k = 0; k < L; ++k)
        U = N[k], V = ci(U, this), B.touch0 && B.touch0[2] === U.identifier ? B.touch0[0] = V : B.touch1 && B.touch1[2] === U.identifier && (B.touch1[0] = V);
      if (U = B.that.__zoom, B.touch1) {
        var X = B.touch0[0], J = B.touch0[1], rt = B.touch1[0], Gt = B.touch1[1], W = (W = rt[0] - X[0]) * W + (W = rt[1] - X[1]) * W, H = (H = Gt[0] - J[0]) * H + (H = Gt[1] - J[1]) * H;
        U = b(U, Math.sqrt(W / H)), V = [(X[0] + rt[0]) / 2, (X[1] + rt[1]) / 2], j = [(J[0] + Gt[0]) / 2, (J[1] + Gt[1]) / 2];
      } else if (B.touch0)
        V = B.touch0[0], j = B.touch0[1];
      else
        return;
      B.zoom("touch", n(_(U, V, j), B.extent, o));
    }
  }
  function O(S, ...M) {
    if (this.__zooming) {
      var B = v(this, M).event(S), N = S.changedTouches, L = N.length, k, U;
      for (cm(S), h && clearTimeout(h), h = setTimeout(function() {
        h = null;
      }, d), k = 0; k < L; ++k)
        U = N[k], B.touch0 && B.touch0[2] === U.identifier ? delete B.touch0 : B.touch1 && B.touch1[2] === U.identifier && delete B.touch1;
      if (B.touch1 && !B.touch0 && (B.touch0 = B.touch1, delete B.touch1), B.touch0)
        B.touch0[1] = this.__zoom.invert(B.touch0[0]);
      else if (B.end(), B.taps === 2 && (U = ci(U, this), Math.hypot(f[0] - U[0], f[1] - U[1]) < g)) {
        var V = re(this).on("dblclick.zoom");
        V && V.apply(this, arguments);
      }
    }
  }
  return y.wheelDelta = function(S) {
    return arguments.length ? (i = typeof S == "function" ? S : Zf(+S), y) : i;
  }, y.filter = function(S) {
    return arguments.length ? (e = typeof S == "function" ? S : Zf(!!S), y) : e;
  }, y.touchable = function(S) {
    return arguments.length ? (r = typeof S == "function" ? S : Zf(!!S), y) : r;
  }, y.extent = function(S) {
    return arguments.length ? (t = typeof S == "function" ? S : Zf([[+S[0][0], +S[0][1]], [+S[1][0], +S[1][1]]]), y) : t;
  }, y.scaleExtent = function(S) {
    return arguments.length ? (s[0] = +S[0], s[1] = +S[1], y) : [s[0], s[1]];
  }, y.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], y) : [[o[0][0], o[0][1]], [o[1][0], o[1][1]]];
  }, y.constrain = function(S) {
    return arguments.length ? (n = S, y) : n;
  }, y.duration = function(S) {
    return arguments.length ? (a = +S, y) : a;
  }, y.interpolate = function(S) {
    return arguments.length ? (c = S, y) : c;
  }, y.on = function() {
    var S = l.on.apply(l, arguments);
    return S === l ? y : S;
  }, y.clickDistance = function(S) {
    return arguments.length ? (m = (S = +S) * S, y) : Math.sqrt(m);
  }, y.tapDistance = function(S) {
    return arguments.length ? (g = +S, y) : g;
  }, y;
}
function cn(e) {
  return e != null && !Number.isNaN(e);
}
function ni(e, t) {
  return +cn(t) - +cn(e) || Be(e, t);
}
function lp(e, t) {
  return +cn(t) - +cn(e) || Zu(e, t);
}
function Ob(e) {
  return e != null && `${e}` != "";
}
function up(e) {
  return isFinite(e) ? e : NaN;
}
function Gr(e) {
  return e > 0 && isFinite(e) ? e : NaN;
}
function Yy(e) {
  return e < 0 && isFinite(e) ? e : NaN;
}
const Eh = 1e3, Vg = Eh * 60, jg = Vg * 60, $u = jg * 24, SV = $u * 7, K2 = $u * 30, IV = $u * 365, vl = [
  ["millisecond", 0.5 * Eh],
  ["second", Eh],
  ["second", 30 * Eh],
  ["minute", Vg],
  ["minute", 30 * Vg],
  ["hour", jg],
  ["hour", 12 * jg],
  ["day", $u],
  ["day", 2 * $u],
  ["week", SV],
  ["month", K2],
  ["month", 3 * K2],
  ["year", IV]
], AV = /* @__PURE__ */ new Map([
  ["second", jr],
  ["minute", Ny],
  ["hour", Dy],
  ["day", Zc],
  // TODO local time equivalent of unixDay?
  ["week", $c],
  ["month", Ly],
  ["year", xi],
  ["monday", Su],
  ["tuesday", OM],
  ["wednesday", LM],
  ["thursday", Qo],
  ["friday", RM],
  ["saturday", CM],
  ["sunday", $c]
]), MV = /* @__PURE__ */ new Map([
  ["second", jr],
  ["minute", Fy],
  ["hour", Ey],
  ["day", Mb],
  ["week", Tc],
  ["month", Ry],
  ["year", Si],
  ["monday", Iu],
  ["tuesday", kM],
  ["wednesday", UM],
  ["thursday", ta],
  ["friday", zM],
  ["saturday", PM],
  ["sunday", Tc]
]);
function k$(e, t) {
  let n = `${e}`.toLowerCase();
  n.endsWith("s") && (n = n.slice(0, -1));
  let i = 1;
  const r = /^(?:(\d+)\s+)/.exec(n);
  switch (r && (n = n.slice(r[0].length), i = +r[1]), n) {
    case "quarter":
      n = "month", i *= 3;
      break;
    case "half":
      n = "month", i *= 6;
      break;
  }
  let s = t.get(n);
  if (!s)
    throw new Error(`unknown interval: ${e}`);
  if (!(i > 1))
    return s;
  if (!s.every)
    throw new Error(`non-periodic interval: ${n}`);
  return s.every(i);
}
function $V(e) {
  return k$(e, AV);
}
function U$(e) {
  return k$(e, MV);
}
function TV(e) {
  if (!e)
    return !1;
  const t = e.floor(new Date(Date.UTC(2e3, 11, 31)));
  return Si(t) >= t;
}
function BV(e) {
  if (!e)
    return !1;
  const t = e.floor(new Date(2e3, 11, 31));
  return xi(t) >= t;
}
function NV(e, t, n, i) {
  const r = e.type === "time" ? Cy : Au, s = i === "left" || i === "right" ? (o, a) => `
${o}
${a}` : i === "top" ? (o, a) => `${a}
${o}` : (o, a) => `${o}
${a}`;
  switch (FV(e, t, n)) {
    case "millisecond":
      return po(r(".%L"), r(":%M:%S"), s);
    case "second":
      return po(r(":%S"), r("%-I:%M"), s);
    case "minute":
      return po(r("%-I:%M"), r("%p"), s);
    case "hour":
      return po(r("%-I %p"), r("%b %-d"), s);
    case "day":
      return po(r("%-d"), r("%b"), s);
    case "week":
      return po(r("%-d"), r("%b"), s);
    case "month":
      return po(r("%b"), r("%Y"), s);
    case "year":
      return r("%Y");
  }
  throw new Error("unable to format time ticks");
}
function FV(e, t, n) {
  const i = _c(FL(t, (c, l) => Math.abs(l - c) || NaN));
  if (i > 0)
    return vl[du(([, c]) => c).right(vl, i, 1, vl.length) - 1][0];
  const [r, s] = je(e.domain()), o = typeof n == "number" ? n : 10, a = Math.abs(s - r) / o;
  return vl[du(([, c]) => Math.log(c)).center(vl, Math.log(a))][0];
}
function po(e, t, n) {
  return (i, r, s) => {
    const o = e(i, r), a = t(i, r), c = r - Fc(s);
    return r !== c && s[c] !== void 0 && a === t(s[c], c) ? o : n(o, a);
  };
}
const Bc = Object.getPrototypeOf(Uint8Array), DV = Object.prototype.toString;
function Ot(e, t, n) {
  const i = typeof t;
  return i === "string" ? Z2(e, z$(t), n) : i === "function" ? Z2(e, t, n) : i === "number" || t instanceof Date || i === "boolean" ? he(e, ii(t), n) : typeof (t == null ? void 0 : t.transform) == "function" ? J2(t.transform(e), n) : J2(t, n);
}
function Z2(e, t, n) {
  return he(e, (n == null ? void 0 : n.prototype) instanceof Bc ? EV(t) : t, n);
}
function J2(e, t) {
  return t === void 0 ? wn(e) : e instanceof t ? e : t.prototype instanceof Bc && !(e instanceof Bc) ? t.from(e, Cb) : t.from(e);
}
function EV(e) {
  return (t, n) => Cb(e(t, n));
}
const tu = [null], z$ = (e) => (t) => t[e], In = { transform: as }, ct = { transform: (e) => e }, Lb = () => 1, OV = () => !0, He = (e) => e == null ? e : `${e}`, Ct = (e) => e == null ? e : +e, cf = (e) => e ? e[0] : void 0, Tu = (e) => e ? e[1] : void 0, LV = (e) => e ? e[2] : void 0, ii = (e) => () => e;
function Rb(e) {
  const t = +`${e}`.slice(1) / 100;
  return (n, i) => Us(n, t, i);
}
function pn(e) {
  return e instanceof Bc ? e : he(e, Cb, Float64Array);
}
function Cb(e) {
  return e == null ? NaN : Number(e);
}
function RV(e) {
  return he(e, P$);
}
function P$(e) {
  return e instanceof Date && !isNaN(e) ? e : typeof e == "string" ? X1(e) : e == null || isNaN(e = +e) ? void 0 : new Date(e);
}
function _n(e, t) {
  return e === void 0 && (e = t), e === null ? [void 0, "none"] : uf(e) ? [void 0, e] : [e, void 0];
}
function Te(e, t) {
  return e === void 0 && (e = t), e === null || typeof e == "number" ? [void 0, e] : [e, void 0];
}
function qy(e, t, n) {
  if (e != null)
    return hr(e, t, n);
}
function hr(e, t, n) {
  const i = `${e}`.toLowerCase();
  if (!n.includes(i))
    throw new Error(`invalid ${t}: ${e}`);
  return i;
}
function wn(e) {
  return e == null || e instanceof Array || e instanceof Bc ? e : Array.from(e);
}
function he(e, t, n = Array) {
  return e == null ? e : e instanceof n ? e.map(t) : n.from(e, t);
}
function Yg(e, t = Array) {
  return e instanceof t ? e.slice() : t.from(e);
}
function V$({ x: e, x1: t, x2: n }) {
  return e !== void 0 || t !== void 0 || n !== void 0;
}
function j$({ y: e, y1: t, y2: n }) {
  return e !== void 0 || t !== void 0 || n !== void 0;
}
function Wy(e) {
  return V$(e) || j$(e) || e.interval !== void 0;
}
function Fi(e) {
  return (e == null ? void 0 : e.toString) === DV;
}
function Vo(e) {
  return Fi(e) && (e.type !== void 0 || e.domain !== void 0);
}
function Pi(e) {
  return Fi(e) && typeof e.transform != "function";
}
function Ps(e) {
  return Pi(e) && e.value === void 0 && e.channel === void 0;
}
function Y$(e, t, n, i = ct) {
  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 Di(e, t) {
  return e === void 0 && t === void 0 ? [cf, Tu] : [e, t];
}
function no({ z: e, fill: t, stroke: n } = {}) {
  return e === void 0 && ([e] = _n(t)), e === void 0 && ([e] = _n(n)), e;
}
function as(e) {
  const t = e.length, n = new Uint32Array(t);
  for (let i = 0; i < t; ++i)
    n[i] = i;
  return n;
}
function kb(e, t) {
  return he(t, (n) => e[n]);
}
function Ub(e) {
  return e.length === 1 ? (t, n) => e(kb(n, t)) : e;
}
function jo(e, t, n) {
  return e.subarray ? e.subarray(t, n) : e.slice(t, n);
}
function Do(e) {
  return e !== null && typeof e == "object" ? e.valueOf() : e;
}
function q$(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 Fn(e) {
  let t;
  return [
    {
      transform: () => t,
      label: cs(e)
    },
    (n) => t = n
  ];
}
function un(e) {
  return e == null ? [e] : Fn(e);
}
function cs(e, t) {
  return typeof e == "string" ? e : e && e.label !== void 0 ? e.label : t;
}
function fp(e, t) {
  return {
    transform(n) {
      const i = e.transform(n), r = t.transform(n);
      return ri(i) || ri(r) ? he(i, (s, o) => new Date((+i[o] + +r[o]) / 2)) : he(i, (s, o) => (+i[o] + +r[o]) / 2, Float64Array);
    },
    label: e.label
  };
}
function hp(e, t) {
  const n = W$(t == null ? void 0 : t.interval, t == null ? void 0 : t.type);
  return n ? he(e, n) : e;
}
function W$(e, t) {
  const n = zb(e, t);
  return n && ((i) => cn(i) ? n.floor(i) : i);
}
function zb(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) => Bn(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) => Bn(Math.ceil(i / n), r / n).map((s) => s * n)
      };
    }
    if (typeof e == "string")
      return (t === "time" ? $V : U$)(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 Jc(e, t) {
  if (e = zb(e, t), e && typeof e.range != "function")
    throw new Error("invalid interval: missing range method");
  return e;
}
function CV(e, t) {
  if (e = Jc(e, t), e && typeof e.ceil != "function")
    throw new Error("invalid interval: missing ceil method");
  return e;
}
function lf(e) {
  return e === void 0 || Pi(e) ? e : { value: e };
}
function kV(e) {
  return e == null ? null : {
    transform: (t) => Ot(t, e, Float64Array),
    label: cs(e)
  };
}
function UV(e) {
  if (!dr(e))
    return !1;
  for (const t of e)
    if (t != null)
      return typeof t == "object" && "0" in t && "1" in t;
}
function dr(e) {
  return e && typeof e[Symbol.iterator] == "function";
}
function G$(e) {
  for (const t of e)
    if (t != null)
      return typeof t != "object" || t instanceof Date;
}
function Qe(e) {
  for (const t of e) {
    if (t == null)
      continue;
    const n = typeof t;
    return n === "string" || n === "boolean";
  }
}
function ri(e) {
  for (const t of e)
    if (t != null)
      return t instanceof Date;
}
function zV(e) {
  for (const t of e)
    if (t != null)
      return typeof t == "string" && isNaN(t) && X1(t);
}
function PV(e) {
  for (const t of e)
    if (t != null) {
      if (typeof t != "string")
        return !1;
      if (t.trim())
        return !isNaN(t);
    }
}
function X$(e) {
  for (const t of e)
    if (t != null)
      return typeof t == "number";
}
function lm(e, t) {
  let n;
  for (const i of e)
    if (i != null) {
      if (!t(i))
        return !1;
      n = !0;
    }
  return n;
}
function uf(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
  Jr(e) !== null);
}
function VV(e) {
  return typeof e == "number" && (0 <= e && e <= 1 || isNaN(e));
}
function ke(e) {
  return e == null || Nc(e);
}
function Nc(e) {
  return /^\s*none\s*$/i.test(e);
}
function jV(e) {
  return /^\s*round\s*$/i.test(e);
}
function H$(e, t) {
  return qy(e, t, [
    "middle",
    "top-left",
    "top",
    "top-right",
    "right",
    "bottom-right",
    "bottom",
    "bottom-left",
    "left"
  ]);
}
function ff(e = "middle") {
  return H$(e, "frameAnchor");
}
function Fc(e) {
  if (e == null)
    return;
  const t = e[0], n = e[e.length - 1];
  return Zu(t, n);
}
function YV(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 qV(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 Pb(e) {
  return dr(e) ? qV(e) : e;
}
const Qi = Symbol("position"), ls = Symbol("color"), Gy = Symbol("radius"), Xy = Symbol("length"), Hy = Symbol("opacity"), Ky = Symbol("symbol"), WV = Symbol("projection"), ve = /* @__PURE__ */ new Map([
  ["x", Qi],
  ["y", Qi],
  ["fx", Qi],
  ["fy", Qi],
  ["r", Gy],
  ["color", ls],
  ["opacity", Hy],
  ["symbol", Ky],
  ["length", Xy],
  ["projection", WV]
]), K$ = Math.sqrt(3), Z$ = 2 / K$, GV = {
  draw(e, t) {
    const n = Math.sqrt(t / Math.PI), i = n * Z$, 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();
  }
}, Vb = /* @__PURE__ */ new Map([
  ["asterisk", d$],
  ["circle", Mu],
  ["cross", p$],
  ["diamond", m$],
  ["diamond2", g$],
  ["hexagon", GV],
  ["plus", b$],
  ["square", _$],
  ["square2", w$],
  ["star", x$],
  ["times", M$],
  ["triangle", S$],
  ["triangle2", I$],
  ["wye", A$]
]);
function jb(e) {
  return e && typeof e.draw == "function";
}
function XV(e) {
  return jb(e) ? !0 : typeof e != "string" ? !1 : Vb.has(e.toLowerCase());
}
function Yb(e) {
  if (e == null || jb(e))
    return e;
  const t = Vb.get(`${e}`.toLowerCase());
  if (t)
    return t;
  throw new Error(`invalid symbol: ${e}`);
}
function HV(e) {
  if (e == null || jb(e))
    return [void 0, e];
  if (typeof e == "string") {
    const t = Vb.get(`${e}`.toLowerCase());
    if (t)
      return [void 0, t];
  }
  return [e, void 0];
}
function pr({ filter: e, sort: t, reverse: n, transform: i, initializer: r, ...s } = {}, o) {
  if (i === void 0 && (e != null && (i = qb(e)), t != null && !Ps(t) && (i = um(i, Gb(t))), n && (i = um(i, Wb))), o != null && r != null)
    throw new Error("transforms cannot be applied after initializers");
  return {
    ...s,
    ...(t === null || Ps(t)) && { sort: t },
    transform: um(i, o)
  };
}
function vn({ filter: e, sort: t, reverse: n, initializer: i, ...r } = {}, s) {
  return i === void 0 && (e != null && (i = qb(e)), t != null && !Ps(t) && (i = fm(i, Gb(t))), n && (i = fm(i, Wb))), {
    ...r,
    ...(t === null || Ps(t)) && { sort: t },
    initializer: fm(i, s)
  };
}
function um(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, wn(n), i, r);
  };
}
function fm(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 Zy(e, t) {
  return (e.initializer != null ? vn : pr)(e, t);
}
function KV(e, t) {
  return Zy(t, qb(e));
}
function qb(e) {
  return (t, n) => {
    const i = Ot(t, e);
    return { data: t, facets: n.map((r) => r.filter((s) => i[s])) };
  };
}
function ZV({ sort: e, ...t } = {}) {
  return {
    ...Zy(t, Wb),
    sort: Ps(e) ? e : null
  };
}
function Wb(e, t) {
  return { data: e, facets: t.map((n) => n.slice().reverse()) };
}
function JV({ seed: e, sort: t, ...n } = {}) {
  return {
    ...Zy(n, Q$(e == null ? Math.random : Sb(e))),
    sort: Ps(t) ? t : null
  };
}
function J$(e, { sort: t, ...n } = {}) {
  return {
    ...(Pi(e) && e.channel !== void 0 ? vn : Zy)(n, Gb(e)),
    sort: Ps(t) ? t : null
  };
}
function Gb(e) {
  return (typeof e == "function" && e.length !== 1 ? QV : Q$)(e);
}
function QV(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 Q$(e) {
  let t, n;
  ({ channel: t, value: e, order: n } = { ...lf(e) });
  const i = t == null ? void 0 : t.startsWith("-");
  if (i && (t = t.slice(1)), n === void 0 && (n = i ? lp : ni), typeof n != "function")
    switch (`${n}`.toLowerCase()) {
      case "ascending":
        n = ni;
        break;
      case "descending":
        n = lp;
        break;
      default:
        throw new Error(`invalid order: ${n}`);
    }
  return (r, s, o) => {
    let a;
    if (t === void 0)
      a = Ot(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 Xb(e, t) {
  return Jy(null, null, e, t);
}
function Bu(e = { y: "count" }, t = {}) {
  const { x: n = ct } = t;
  if (n == null)
    throw new Error("missing channel: x");
  return Jy(n, null, e, t);
}
function Nu(e = { x: "count" }, t = {}) {
  const { y: n = ct } = t;
  if (n == null)
    throw new Error("missing channel: y");
  return Jy(null, n, e, t);
}
function Hb(e = { fill: "count" }, t = {}) {
  let { x: n, y: i } = t;
  if ([n, i] = Di(n, i), n == null)
    throw new Error("missing channel: x");
  if (i == null)
    throw new Error("missing channel: y");
  return Jy(n, i, e, t);
}
function Jy(e, t, {
  data: n = t_,
  filter: i,
  sort: r,
  reverse: s,
  ...o
  // output channel definitions
} = {}, a = {}) {
  o = Kb(o, a), n = Qy(n, ct), r = r == null ? void 0 : Zb("sort", r, a), i = i == null ? void 0 : Jb("filter", i, a);
  const [c, l] = un(e), [u, f] = un(t), {
    z: h,
    fill: d,
    stroke: p,
    x1: m,
    x2: g,
    // consumed if x is an output
    y1: y,
    y2: b,
    // consumed if y is an output
    ..._
  } = a, [w, x] = un(h), [v] = _n(d), [I] = _n(p), [T, F] = un(v), [A, $] = un(I);
  return {
    ..."z" in a && { z: w || h },
    ..."fill" in a && { fill: T || d },
    ..."stroke" in a && { stroke: A || p },
    ...pr(_, (D, O, S) => {
      const M = hp(Ot(D, e), S == null ? void 0 : S.x), B = hp(Ot(D, t), S == null ? void 0 : S.y), N = Ot(D, h), L = Ot(D, v), k = Ot(D, I), U = Qb(o, { z: N, fill: L, stroke: k }), V = [], j = [], X = M && l([]), J = B && f([]), rt = N && x([]), Gt = L && F([]), W = k && $([]);
      let H = 0;
      for (const P of o)
        P.initialize(D);
      r && r.initialize(D), i && i.initialize(D);
      for (const P of O) {
        const K = [];
        for (const Z of o)
          Z.scope("facet", P);
        r && r.scope("facet", P), i && i.scope("facet", P);
        for (const [Z, z] of Ja(P, U))
          for (const [tt, lt] of Ja(z, B))
            for (const [zt, Dt] of Ja(lt, M))
              if (!(i && !i.reduce(Dt))) {
                K.push(H++), j.push(n.reduceIndex(Dt, D)), M && X.push(zt), B && J.push(tt), N && rt.push(U === N ? Z : N[Dt[0]]), L && Gt.push(U === L ? Z : L[Dt[0]]), k && W.push(U === k ? Z : k[Dt[0]]);
                for (const Q of o)
                  Q.reduce(Dt);
                r && r.reduce(Dt);
              }
        V.push(K);
      }
      return t4(V, r, s), { data: j, facets: V };
    }),
    ...!$s(o, "x") && (c ? { x: c } : { x1: m, x2: g }),
    ...!$s(o, "y") && (u ? { y: u } : { y1: y, y2: b }),
    ...Object.fromEntries(o.map(({ name: D, output: O }) => [D, O]))
  };
}
function $s(e, ...t) {
  for (const { name: n } of e)
    if (t.includes(n))
      return !0;
  return !1;
}
function Kb(e, t, n = Zb) {
  const i = Object.entries(e);
  return t.title != null && e.title === void 0 && i.push(["title", rj]), t.href != null && e.href === void 0 && i.push(["href", e_]), i.filter(([, r]) => r !== void 0).map(([r, s]) => s === null ? tj(r) : n(r, s, t));
}
function Zb(e, t, n, i = Jb) {
  let r;
  Fi(t) && "reduce" in t && (r = t.scale, t = t.reduce);
  const s = i(e, t, n), [o, a] = Fn(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 tj(e) {
  return { name: e, initialize() {
  }, scope() {
  }, reduce() {
  } };
}
function Jb(e, t, n, i = Qy) {
  const r = q$(e, n), s = i(t, r);
  let o, a;
  return {
    label: cs(s === dp ? null : r, s.label),
    initialize(c) {
      o = r === void 0 ? c : Ot(c, r), s.scope === "data" && (a = s.reduceIndex(as(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 Ja(e, t) {
  return t ? pu(
    os(e, (n) => t[n]),
    cf
  ) : [[, e]];
}
function Qy(e, t, n = ej) {
  if (e == null)
    return n(e);
  if (typeof e.reduceIndex == "function")
    return e;
  if (typeof e.reduce == "function" && Fi(e))
    return nj(e);
  if (typeof e == "function")
    return ij(e);
  if (/^p\d{2}$/i.test(e))
    return Mr(Rb(e));
  switch (`${e}`.toLowerCase()) {
    case "first":
      return e_;
    case "last":
      return sj;
    case "identity":
      return t_;
    case "count":
      return dp;
    case "distinct":
      return oj;
    case "sum":
      return t == null ? dp : aj;
    case "proportion":
      return tx(t, "data");
    case "proportion-facet":
      return tx(t, "facet");
    case "deviation":
      return Mr(py);
    case "min":
      return Mr(ze);
    case "min-index":
      return Mr($L);
    case "max":
      return Mr(Se);
    case "max-index":
      return Mr(ML);
    case "mean":
      return Q2(rb);
    case "median":
      return Q2(_c);
    case "variance":
      return Mr(J1);
    case "mode":
      return Mr(X3);
  }
  return n(e);
}
function ej(e) {
  throw new Error(`invalid reduce: ${e}`);
}
function Qb(e, t) {
  for (const n in t) {
    const i = t[n];
    if (i !== void 0 && !e.some((r) => r.name === n))
      return i;
  }
}
function t4(e, t, n) {
  if (t) {
    const i = t.output.transform(), r = (s, o) => ni(i[s], i[o]);
    e.forEach((s) => s.sort(r));
  }
  n && e.forEach((i) => i.reverse());
}
function nj(e) {
  return console.warn("deprecated reduce interface; implement reduceIndex instead."), { ...e, reduceIndex: e.reduce.bind(e) };
}
function ij(e) {
  return {
    reduceIndex(t, n, i) {
      return e(kb(n, t), i);
    }
  };
}
function Mr(e) {
  return {
    reduceIndex(t, n) {
      return e(t, (i) => n[i]);
    }
  };
}
function Q2(e) {
  return {
    reduceIndex(t, n) {
      const i = e(t, (r) => n[r]);
      return ri(n) ? new Date(i) : i;
    }
  };
}
const t_ = {
  reduceIndex(e, t) {
    return kb(t, e);
  }
}, e_ = {
  reduceIndex(e, t) {
    return t[e[0]];
  }
}, rj = {
  reduceIndex(e, t) {
    const i = pu(
      Xa(
        e,
        (s) => s.length,
        (s) => t[s]
      ),
      Tu
    ), r = i.slice(-5).reverse();
    if (r.length < i.length) {
      const s = i.slice(0, -4);
      r[5 - 1] = [`… ${s.length.toLocaleString("en-US")} more`, sr(s, Tu)];
    }
    return r.map(([s, o]) => `${s} (${o.toLocaleString("en-US")})`).join(`
`);
  }
}, sj = {
  reduceIndex(e, t) {
    return t[e[e.length - 1]];
  }
}, dp = {
  label: "Frequency",
  reduceIndex(e) {
    return e.length;
  }
}, oj = {
  label: "Distinct",
  reduceIndex(e, t) {
    const n = new yy();
    for (const i of e)
      n.add(t[i]);
    return n.size;
  }
}, aj = Mr(sr);
function tx(e, t) {
  return e == null ? { scope: t, label: "Frequency", reduceIndex: (n, i, r = 1) => n.length / r } : { scope: t, reduceIndex: (n, i, r = 1) => sr(n, (s) => i[s]) / r };
}
function Fu(e, { scale: t, type: n, value: i, filter: r, hint: s }, o) {
  return s === void 0 && typeof (i == null ? void 0 : i.transform) == "function" && (s = i.hint), n4(o, {
    scale: t,
    type: n,
    value: Ot(e, i),
    label: cs(i),
    filter: r,
    hint: s
  });
}
function e4(e, t) {
  return Object.fromEntries(
    Object.entries(e).map(([n, i]) => [n, Fu(t, i, n)])
  );
}
function n_(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 : he(s, o)];
    })
  );
  return n.channels = e, n;
}
function n4(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 && lm(i, uf) ? null : "color";
        break;
      case "fillOpacity":
      case "strokeOpacity":
      case "opacity":
        t.scale = n !== !0 && lm(i, VV) ? null : "opacity";
        break;
      case "symbol":
        n !== !0 && lm(i, XV) ? (t.scale = null, t.value = he(i, Yb)) : t.scale = "symbol";
        break;
      default:
        t.scale = ve.has(e) ? e : null;
        break;
    }
  else if (n === !1)
    t.scale = null;
  else if (n != null && !ve.has(n))
    throw new Error(`unknown scale: ${n}`);
  return t;
}
function cj(e, t, n, i, r) {
  const { order: s, reverse: o, reduce: a = !0, limit: c } = r;
  for (const l in r) {
    if (!ve.has(l))
      continue;
    let { value: u, order: f = s, reverse: h = o, reduce: d = a, limit: p = c } = lf(r[l]);
    const m = u == null ? void 0 : u.startsWith("-");
    if (m && (u = u.slice(1)), f = f === void 0 ? m !== (u === "width" || u === "height") ? r4 : i4 : fj(f), d == null || d === !1)
      continue;
    const g = l === "fx" || l === "fy" ? uj(t, i[l]) : lj(n, l);
    if (!g)
      throw new Error(`missing channel for scale: ${l}`);
    const y = g.value, [b = 0, _ = 1 / 0] = dr(p) ? p : p < 0 ? [p] : [0, p];
    if (u == null)
      g.domain = () => {
        let w = Array.from(new yy(y));
        return h && (w = w.reverse()), (b !== 0 || _ !== 1 / 0) && (w = w.slice(b, _)), w;
      };
    else {
      const w = u === "data" ? e : u === "height" ? ex(n, "y1", "y2") : u === "width" ? ex(n, "x1", "x2") : qg(n, u, u === "y" ? "y2" : u === "x" ? "x2" : void 0), x = Qy(d === !0 ? "max" : d, w);
      g.domain = () => {
        let v = vL(
          as(y),
          (I) => x.reduceIndex(I, w),
          (I) => y[I]
        );
        return f && v.sort(f), h && v.reverse(), (b !== 0 || _ !== 1 / 0) && (v = v.slice(b, _)), v.map(cf);
      };
    }
  }
}
function lj(e, t) {
  for (const n in e) {
    const i = e[n];
    if (i.scale === t)
      return i;
  }
}
function uj(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 ex(e, t, n) {
  const i = qg(e, t), r = qg(e, n);
  return he(r, (s, o) => Math.abs(s - i[o]), Float64Array);
}
function qg(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 fj(e) {
  if (e == null || typeof e == "function")
    return e;
  switch (`${e}`.toLowerCase()) {
    case "ascending":
      return i4;
    case "descending":
      return r4;
  }
  throw new Error(`invalid order: ${e}`);
}
function i4([e, t], [n, i]) {
  return ni(t, i) || ni(e, n);
}
function r4([e, t], [n, i]) {
  return lp(t, i) || ni(e, n);
}
function s4(e, t) {
  let n = e[t];
  if (n) {
    for (; n.source; )
      n = n.source;
    return n.source === null ? null : n;
  }
}
function t0(e = {}) {
  const { document: t = typeof window < "u" ? window.document : void 0 } = e;
  return { document: t };
}
function Wt(e, { document: t }) {
  return re(by(e).call(t.documentElement));
}
let Wg = 0;
function hj() {
  const e = Wg;
  return Wg = 0, e;
}
function Fs(e) {
  console.warn(e), ++Wg;
}
const o4 = Math.PI, _r = 2 * o4, nx = 0.618;
function dj({
  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 (Fi(e)) {
    let x;
    if ({
      type: e,
      domain: c,
      inset: x,
      insetTop: n = x !== void 0 ? x : n,
      insetRight: i = x !== void 0 ? x : i,
      insetBottom: r = x !== void 0 ? x : r,
      insetLeft: s = x !== void 0 ? x : s,
      clip: l = l,
      ...a
    } = e, e == null)
      return;
  }
  typeof e != "function" && ({ type: e } = a4(e));
  const { width: u, height: f, marginLeft: h, marginRight: d, marginTop: p, marginBottom: m } = o, g = u - h - d - s - i, y = f - p - m - n - r;
  if (e = e == null ? void 0 : e({ width: g, height: y, clip: l, ...a }), e == null)
    return;
  l = pj(l, h, p, u - d, f - m);
  let b = h + s, _ = p + n, w;
  if (c != null) {
    const [[x, v], [I, T]] = to(e).bounds(c), F = Math.min(g / (I - x), y / (T - v));
    F > 0 ? (b -= (F * (x + I) - g) / 2, _ -= (F * (v + T) - y) / 2, w = Kd({
      point(A, $) {
        this.stream.point(A * F + b, $ * F + _);
      }
    })) : Fs("Warning: the projection could not be fit to the specified domain; using the default scale.");
  }
  return w ?? (w = b === 0 && _ === 0 ? c4() : Kd({
    point(x, v) {
      this.stream.point(x + b, v + _);
    }
  })), { stream: (x) => e.stream(w.stream(l(x))) };
}
function a4(e) {
  switch (`${e}`.toLowerCase()) {
    case "albers-usa":
      return oi(uU, 0.7463, 0.4673);
    case "albers":
      return Jf(cM, 0.7463, 0.4673);
    case "azimuthal-equal-area":
      return oi(fU, 4, 4);
    case "azimuthal-equidistant":
      return oi(hU, _r, _r);
    case "conic-conformal":
      return Jf(yU, _r, _r);
    case "conic-equal-area":
      return Jf(Zd, 6.1702, 2.9781);
    case "conic-equidistant":
      return Jf(bU, 7.312, 3.6282);
    case "equal-earth":
      return oi(wU, 5.4133, 2.6347);
    case "equirectangular":
      return oi(mU, _r, o4);
    case "gnomonic":
      return oi(vU, 3.4641, 3.4641);
    case "identity":
      return { type: c4 };
    case "reflect-y":
      return { type: yj };
    case "mercator":
      return oi(dU, _r, _r);
    case "orthographic":
      return oi(xU, 2, 2);
    case "stereographic":
      return oi(SU, 2, 2);
    case "transverse-mercator":
      return oi(IU, _r, _r);
    default:
      throw new Error(`unknown projection type: ${e}`);
  }
}
function pj(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 WA(t, n, i, r);
    default:
      throw new Error(`unknown projection clip type: ${e}`);
  }
}
function oi(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 Jf(e, t, n) {
  const { type: i, aspectRatio: r } = oi(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 c4 = ii({ stream: (e) => e }), yj = ii(
  Kd({
    point(e, t) {
      this.stream.point(e, -t);
    }
  })
);
function l4(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 mj({ projection: e } = {}) {
  return e == null ? !1 : typeof e.stream == "function" ? !0 : (Fi(e) && (e = e.type), e != null);
}
function gj(e) {
  if (typeof (e == null ? void 0 : e.stream) == "function")
    return nx;
  if (Fi(e) && (e = e.type), e != null) {
    if (typeof e != "function") {
      const { aspectRatio: t } = a4(e);
      if (t)
        return t;
    }
    return nx;
  }
}
function e0(e, t, { projection: n }) {
  const { x: i, y: r } = e;
  let s = {};
  return i && (s.x = i), r && (s.y = r), s = n_(s, t), n && (i == null ? void 0 : i.scale) === "x" && (r == null ? void 0 : r.scale) === "y" && l4("x", "y", s, n), i && (s.x = pn(s.x)), r && (s.y = pn(s.y)), s;
}
function bj(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)
    xs(o, s);
  return [i, r];
}
const u4 = /* @__PURE__ */ new Map([
  ["accent", FP],
  ["category10", NP],
  ["dark2", DP],
  ["paired", EP],
  ["pastel1", OP],
  ["pastel2", LP],
  ["set1", RP],
  ["set2", CP],
  ["set3", kP],
  ["tableau10", UP]
]);
function _j(e) {
  return e != null && u4.has(`${e}`.toLowerCase());
}
const ix = new Map([
  ...u4,
  // diverging
  ["brbg", wr(JM, QM)],
  ["prgn", wr(t6, e6)],
  ["piyg", wr(n6, i6)],
  ["puor", wr(r6, s6)],
  ["rdbu", wr(Ug, np)],
  ["rdgy", wr(o6, a6)],
  ["rdylbu", wr(zg, ip)],
  ["rdylgn", wr(c6, l6)],
  ["spectral", wr(u6, f6)],
  // reversed diverging (for temperature data)
  ["burd", rx(Ug, np)],
  ["buylrd", rx(zg, ip)],
  // sequential (single-hue)
  ["blues", Re(R6, C6)],
  ["greens", Re(k6, U6)],
  ["greys", Re(z6, P6)],
  ["oranges", Re(W6, G6)],
  ["purples", Re(V6, j6)],
  ["reds", Re(Y6, q6)],
  // sequential (multi-hue)
  ["turbo", vr(t$)],
  ["viridis", vr(e$)],
  ["magma", vr(n$)],
  ["inferno", vr(i$)],
  ["plasma", vr(r$)],
  ["cividis", vr(X6)],
  ["cubehelix", vr(H6)],
  ["warm", vr(K6)],
  ["cool", vr(Z6)],
  ["bugn", Re(h6, d6)],
  ["bupu", Re(p6, y6)],
  ["gnbu", Re(m6, g6)],
  ["orrd", Re(b6, _6)],
  ["pubu", Re(x6, S6)],
  ["pubugn", Re(w6, v6)],
  ["purd", Re(I6, A6)],
  ["rdpu", Re(M6, $6)],
  ["ylgn", Re(N6, F6)],
  ["ylgnbu", Re(T6, B6)],
  ["ylorbr", Re(D6, E6)],
  ["ylorrd", Re(O6, L6)],
  // cyclical
  ["rainbow", sx(J6)],
  ["sinebow", sx(Q6)]
]);
function Re(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 ? wi(t, n) : e[n]);
}
function wr(e, t) {
  return ({ length: n }) => n === 2 ? [e[3][0], e[3][2]] : (n = Math.max(3, Math.floor(n)), n > 11 ? wi(t, n) : e[n]);
}
function rx(e, t) {
  return ({ length: n }) => n === 2 ? [e[3][2], e[3][0]] : (n = Math.max(3, Math.floor(n)), n > 11 ? wi((i) => t(1 - i), n) : e[n].slice().reverse());
}
function vr(e) {
  return ({ length: t }) => wi(e, Math.max(2, Math.floor(t)));
}
function sx(e) {
  return ({ length: t }) => wi(e, Math.floor(t) + 1).slice(0, -1);
}
function f4(e) {
  const t = `${e}`.toLowerCase();
  if (!ix.has(t))
    throw new Error(`unknown ordinal scheme: ${t}`);
  return ix.get(t);
}
function n0(e, t) {
  const n = f4(e), i = typeof n == "function" ? n({ length: t }) : n;
  return i.length !== t ? i.slice(0, t) : i;
}
function wj(e, t = "greys") {
  const n = /* @__PURE__ */ new Set(), [i, r] = n0(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 ox = /* @__PURE__ */ new Map([
  // diverging
  ["brbg", QM],
  ["prgn", e6],
  ["piyg", i6],
  ["puor", s6],
  ["rdbu", np],
  ["rdgy", a6],
  ["rdylbu", ip],
  ["rdylgn", l6],
  ["spectral", f6],
  // reversed diverging (for temperature data)
  ["burd", (e) => np(1 - e)],
  ["buylrd", (e) => ip(1 - e)],
  // sequential (single-hue)
  ["blues", C6],
  ["greens", U6],
  ["greys", P6],
  ["purples", j6],
  ["reds", q6],
  ["oranges", G6],
  // sequential (multi-hue)
  ["turbo", t$],
  ["viridis", e$],
  ["magma", n$],
  ["inferno", i$],
  ["plasma", r$],
  ["cividis", X6],
  ["cubehelix", H6],
  ["warm", K6],
  ["cool", Z6],
  ["bugn", d6],
  ["bupu", y6],
  ["gnbu", g6],
  ["orrd", _6],
  ["pubugn", v6],
  ["pubu", S6],
  ["purd", A6],
  ["rdpu", $6],
  ["ylgnbu", B6],
  ["ylgn", F6],
  ["ylorbr", E6],
  ["ylorrd", L6],
  // cyclical
  ["rainbow", J6],
  ["sinebow", Q6]
]);
function i_(e) {
  const t = `${e}`.toLowerCase();
  if (!ox.has(t))
    throw new Error(`unknown quantitative scheme: ${t}`);
  return ox.get(t);
}
const vj = /* @__PURE__ */ new Set([
  "brbg",
  "prgn",
  "piyg",
  "puor",
  "rdbu",
  "rdgy",
  "rdylbu",
  "rdylgn",
  "spectral",
  "burd",
  "buylrd"
]);
function xj(e) {
  return e != null && vj.has(`${e}`.toLowerCase());
}
const h4 = (e) => (t) => e(1 - t), hm = [0, 1], ax = /* @__PURE__ */ new Map([
  // numbers
  ["number", Xe],
  // color spaces
  ["rgb", Ko],
  ["hsl", sC],
  ["hcl", cC],
  ["lab", oC]
]);
function d4(e) {
  const t = `${e}`.toLowerCase();
  if (!ax.has(t))
    throw new Error(`unknown interpolator: ${t}`);
  return ax.get(t);
}
function hf(e, t, n, {
  type: i,
  nice: r,
  clamp: s,
  zero: o,
  domain: a = y4(e, n),
  unknown: c,
  round: l,
  scheme: u,
  interval: f,
  range: h = ve.get(e) === Gy ? Ej(n, a) : ve.get(e) === Xy ? Oj(n, a) : ve.get(e) === Hy ? hm : void 0,
  interpolate: d = ve.get(e) === ls ? u == null && h !== void 0 ? Ko : i_(u !== void 0 ? u : i === "cyclical" ? "rainbow" : "turbo") : l ? fb : Xe,
  reverse: p
}) {
  if (f = Jc(f, i), (i === "cyclical" || i === "sequential") && (i = "linear"), typeof d != "function" && (d = d4(d)), p = !!p, h !== void 0) {
    const m = (a = wn(a)).length, g = (h = wn(h)).length;
    if (m !== g) {
      if (d.length === 1)
        throw new Error("invalid piecewise interpolator");
      d = vy(d, h), h = void 0;
    }
  }
  if (d.length === 1 ? (p && (d = h4(d), p = !1), h === void 0 && (h = Float64Array.from(a, (m, g) => g / (a.length - 1)), h.length === 2 && (h = hm)), t.interpolate((h === hm ? ii : s_)(d))) : t.interpolate(d), o) {
    const [m, g] = je(a);
    (m > 0 || g < 0) && (a = Yg(a), Fc(a) !== Math.sign(m) ? a[a.length - 1] = 0 : a[0] = 0);
  }
  return p && (a = xd(a)), t.domain(a).unknown(c), r && (t.nice(Sj(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 Sj(e, t) {
  return e === !0 ? void 0 : typeof e == "number" ? e : CV(e, t);
}
function Ij(e, t, n) {
  return hf(e, By(), t, n);
}
function Aj(e, t, n) {
  return p4(e, t, { ...n, exponent: 0.5 });
}
function p4(e, t, { exponent: n = 1, ...i }) {
  return hf(e, FM().exponent(n), t, { ...i, type: "pow" });
}
function Mj(e, t, { base: n = 10, domain: i = Lj(t), ...r }) {
  return hf(e, $M().base(n), t, { ...r, domain: i });
}
function $j(e, t, { constant: n = 1, ...i }) {
  return hf(e, BM().constant(n), t, i);
}
function Tj(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 = Rj(t),
  unknown: a,
  interpolate: c,
  reverse: l
}) {
  return n === void 0 && (n = c !== void 0 ? wi(c, r) : ve.get(e) === ls ? n0(s, r) : void 0), o.length > 0 && (o = DM(o, n === void 0 ? { length: r } : n).quantiles()), r_(e, t, { domain: o, range: n, reverse: l, unknown: a });
}
function Bj(e, t, {
  range: n,
  n: i = n === void 0 ? 5 : (n = [...n]).length,
  scheme: r = "rdylbu",
  domain: s = y4(e, t),
  unknown: o,
  interpolate: a,
  reverse: c
}) {
  const [l, u] = je(s);
  let f;
  return n === void 0 ? (f = ks(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 ? wi(a, i) : ve.get(e) === ls ? n0(r, i) : void 0) : (f = wi(Xe(l, u), i + 1).slice(1, -1), l instanceof Date && (f = f.map((h) => new Date(h)))), Fc(wn(s)) < 0 && f.reverse(), r_(e, t, { domain: f, range: n, reverse: c, unknown: o });
}
function r_(e, t, {
  domain: n = [0],
  // explicit thresholds in ascending order
  unknown: i,
  scheme: r = "rdylbu",
  interpolate: s,
  range: o = s !== void 0 ? wi(s, n.length + 1) : ve.get(e) === ls ? n0(r, n.length + 1) : void 0,
  reverse: a
}) {
  n = wn(n);
  const c = Fc(n);
  if (!isNaN(c) && !Nj(n, c))
    throw new Error(`the ${e} scale has a non-monotonic domain`);
  return a && (o = xd(o)), {
    type: "threshold",
    scale: EM(c < 0 ? xd(n) : n, o === void 0 ? [] : o).unknown(i),
    domain: n,
    range: o
  };
}
function Nj(e, t) {
  for (let n = 1, i = e.length, r = e[0]; n < i; ++n) {
    const s = Zu(r, r = e[n]);
    if (s !== 0 && s !== t)
      return !1;
  }
  return !0;
}
function Fj() {
  return { type: "identity", scale: IM() };
}
function Du(e, t = up) {
  return e.length ? [
    ze(e, ({ value: n }) => n === void 0 ? n : ze(n, t)),
    Se(e, ({ value: n }) => n === void 0 ? n : Se(n, t))
  ] : [0, 1];
}
function y4(e, t) {
  const n = ve.get(e);
  return (n === Gy || n === Hy || n === Xy ? Dj : Du)(t);
}
function Dj(e) {
  return [0, e.length ? Se(e, ({ value: t }) => t === void 0 ? t : Se(t, up)) : 1];
}
function Ej(e, t) {
  const n = e.find(({ radius: o }) => o !== void 0);
  if (n !== void 0)
    return [0, n.radius];
  const i = Us(e, 0.5, ({ value: o }) => o === void 0 ? NaN : Us(o, 0.25, Gr)), r = t.map((o) => 3 * Math.sqrt(o / i)), s = 30 / Se(r);
  return s < 1 ? r.map((o) => o * s) : r;
}
function Oj(e, t) {
  const n = _c(e, ({ value: s }) => s === void 0 ? NaN : _c(s, Math.abs)), i = t.map((s) => 12 * s / n), r = 60 / Se(i);
  return r < 1 ? i.map((s) => s * r) : i;
}
function Lj(e) {
  for (const { value: t } of e)
    if (t !== void 0)
      for (let n of t) {
        if (n > 0)
          return Du(e, Gr);
        if (n < 0)
          return Du(e, Yy);
      }
  return [1, 10];
}
function Rj(e) {
  const t = [];
  for (const { value: n } of e)
    if (n !== void 0)
      for (const i of n)
        t.push(i);
  return t;
}
function s_(e) {
  return (t, n) => (i) => e(t + i * (n - t));
}
function i0(e, t, n, i, {
  type: r,
  nice: s,
  clamp: o,
  domain: a = Du(i),
  unknown: c,
  pivot: l = 0,
  scheme: u,
  range: f,
  symmetric: h = !0,
  interpolate: d = ve.get(e) === ls ? u == null && f !== void 0 ? Ko : i_(u !== void 0 ? u : "rdbu") : Xe,
  reverse: p
}) {
  l = +l, a = wn(a);
  let [m, g] = a;
  if (a.length > 2 && Fs(`Warning: the diverging ${e} scale domain contains extra elements.`), Zu(m, g) < 0 && ([m, g] = [g, m], p = !p), m = Math.min(m, l), g = Math.max(g, l), typeof d != "function" && (d = d4(d)), f !== void 0 && (d = d.length === 1 ? s_(d)(...f) : vy(d, f)), p && (d = h4(d)), h) {
    const y = n.apply(l), b = y - n.apply(m), _ = n.apply(g) - y;
    b < _ ? m = n.invert(y - _) : b > _ && (g = n.invert(y + b));
  }
  return t.domain([m, l, g]).unknown(c).interpolator(d), o && t.clamp(o), s && t.nice(s), { type: r, domain: [m, g], pivot: l, interpolate: d, scale: t };
}
function Cj(e, t, n) {
  return i0(e, XM(), Pj, t, n);
}
function kj(e, t, n) {
  return m4(e, t, { ...n, exponent: 0.5 });
}
function m4(e, t, { exponent: n = 1, ...i }) {
  return i0(e, ZM().exponent(n = +n), Yj(n), t, {
    ...i,
    type: "diverging-pow"
  });
}
function Uj(e, t, { base: n = 10, pivot: i = 1, domain: r = Du(t, i < 0 ? Yy : Gr), ...s }) {
  return i0(e, HM().base(n = +n), Vj, t, {
    domain: r,
    pivot: i,
    ...s
  });
}
function zj(e, t, { constant: n = 1, ...i }) {
  return i0(
    e,
    KM().constant(n = +n),
    qj(n),
    t,
    i
  );
}
const Pj = {
  apply(e) {
    return e;
  },
  invert(e) {
    return e;
  }
}, Vj = {
  apply: Math.log,
  invert: Math.exp
}, jj = {
  apply(e) {
    return Math.sign(e) * Math.sqrt(Math.abs(e));
  },
  invert(e) {
    return Math.sign(e) * (e * e);
  }
};
function Yj(e) {
  return e === 0.5 ? jj : {
    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 qj(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 g4(e, t, n, i) {
  return hf(e, t, n, i);
}
function Wj(e, t, n) {
  return g4(e, TP(), t, n);
}
function Gj(e, t, n) {
  return g4(e, BP(), t, n);
}
const df = Symbol("ordinal");
function b4(e, t, n, { type: i, interval: r, domain: s, range: o, reverse: a, hint: c }) {
  return r = Jc(r, i), s === void 0 && (s = w4(n, r, e)), (i === "categorical" || i === df) && (i = "ordinal"), a && (s = xd(s)), t.domain(s), 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 Xj(e, t, { type: n, interval: i, domain: r, range: s, scheme: o, unknown: a, ...c }) {
  i = Jc(i, n), r === void 0 && (r = w4(t, i, e));
  let l;
  if (ve.get(e) === Ky)
    l = Zj(t), s = s === void 0 ? Jj(l) : he(s, Yb);
  else if (ve.get(e) === ls && (s === void 0 && (n === "ordinal" || n === df) && (s = wj(r, o), s !== void 0 && (o = void 0)), o === void 0 && s === void 0 && (o = n === "ordinal" ? "turbo" : "tableau10"), o !== void 0))
    if (s !== void 0) {
      const u = i_(o), f = s[0], h = s[1] - s[0];
      s = ({ length: d }) => wi((p) => u(f + h * p), d);
    } else
      s = f4(o);
  if (a === Rg)
    throw new Error(`implicit unknown on ${e} scale is not supported`);
  return b4(e, Ib().unknown(a), t, { ...c, type: n, domain: r, range: s, hint: l });
}
function Hj(e, t, { align: n = 0.5, padding: i = 0.5, ...r }) {
  return _4(lz().align(n).padding(i), t, r, e);
}
function Kj(e, t, {
  align: n = 0.5,
  padding: i = 0.1,
  paddingInner: r = i,
  paddingOuter: s = e === "fx" || e === "fy" ? 0 : i,
  ...o
}) {
  return _4(
    $y().align(n).paddingInner(r).paddingOuter(s),
    t,
    o,
    e
  );
}
function _4(e, t, n, i) {
  let { round: r } = n;
  return r !== void 0 && e.round(r = !!r), e = b4(i, e, t, n), e.round = r, e;
}
function w4(e, t, n) {
  const i = new yy();
  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] = je(i).map(t.floor, t);
    return t.range(r, t.offset(s));
  }
  if (i.size > 1e4 && ve.get(n) === Qi)
    throw new Error(`implicit ordinal domain of ${n} scale has more than 10,000 values`);
  return pu(i, ni);
}
function cx(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 Zj(e) {
  return {
    fill: cx(e, "fill"),
    stroke: cx(e, "stroke")
  };
}
function Jj(e) {
  return ke(e.fill) ? JP : ZP;
}
function Gg(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 } = {},
  ...m
} = {}) {
  const g = {};
  for (const [y, b] of e) {
    const _ = m[y], w = I4(y, b, {
      round: ve.get(y) === Qi ? a : void 0,
      // only for position
      nice: c,
      clamp: l,
      zero: u,
      align: f,
      padding: h,
      projection: d,
      ..._
    });
    if (w) {
      let {
        label: x = y === "fx" || y === "fy" ? p : t,
        percent: v,
        transform: I,
        inset: T,
        insetTop: F = T !== void 0 ? T : y === "y" ? i : 0,
        // not fy
        insetRight: A = T !== void 0 ? T : y === "x" ? r : 0,
        // not fx
        insetBottom: $ = T !== void 0 ? T : y === "y" ? s : 0,
        // not fy
        insetLeft: D = T !== void 0 ? T : y === "x" ? o : 0
        // not fx
      } = _ || {};
      if (I == null)
        I = void 0;
      else if (typeof I != "function")
        throw new Error("invalid scale transform; not a function");
      w.percent = !!v, w.label = x === void 0 ? tY(b, w) : x, w.transform = I, y === "x" || y === "fx" ? (w.insetLeft = +D, w.insetRight = +A) : (y === "y" || y === "fy") && (w.insetTop = +F, w.insetBottom = +$), g[y] = w;
    }
  }
  return g;
}
function lx(e) {
  return Object.fromEntries(
    Object.entries(e).filter(([, { scale: t }]) => t).map(([t, { scale: n, type: i, interval: r, label: s }]) => (n.type = i, r != null && (n.interval = r), s != null && (n.label = s), [t, n]))
  );
}
function Qj(e, t) {
  const { x: n, y: i, fx: r, fy: s } = e, o = r || s ? o_(t) : t;
  r && ux(r, o), s && fx(s, o);
  const a = r || s ? v4(e, t) : t;
  n && ux(n, a), i && fx(i, a);
}
function tY(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 !sa(t) && t.percent && (n = `${n} (%)`), { inferred: !0, toString: () => n };
}
function o_(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 v4({ fx: e, fy: t }, n) {
  const { marginTop: i, marginRight: r, marginBottom: s, marginLeft: o, width: a, height: c } = o_(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 ux(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)], sa(e) || (e.range = S4(e)), e.scale.range(e.range);
  }
  x4(e);
}
function fx(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], sa(e) ? e.range.reverse() : e.range = S4(e), e.scale.range(e.range);
  }
  x4(e);
}
function x4(e) {
  e.round === void 0 && iY(e) && eY(e) <= 30 && e.scale.round(!0);
}
function eY({ 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 S4(e) {
  const t = e.scale.domain().length + A4(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 Xg(e, t, n) {
  return I4(e, n === void 0 ? void 0 : [{ hint: n }], { ...t });
}
function I4(e, t = [], n = {}) {
  const i = nY(e, t, n);
  if (n.type === void 0 && n.domain === void 0 && n.range === void 0 && n.interval == null && e !== "fx" && e !== "fy" && sa({ type: i })) {
    const r = t.map(({ value: s }) => s).filter((s) => s !== void 0);
    r.some(ri) ? Fs(
      `Warning: some data associated with the ${e} scale are dates. Dates are typically associated with a "utc" or "time" scale rather than a "${ma(
        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 "${ma(
        i
      )}".`
    ) : r.some(zV) ? Fs(
      `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 "${ma(
        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 "${ma(
        i
      )}".`
    ) : r.some(PV) && Fs(
      `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 "${ma(
        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 "${ma(
        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 = Qf(t, n, pn);
      break;
    case "identity":
      switch (ve.get(e)) {
        case Qi:
          n = Qf(t, n, pn);
          break;
        case Ky:
          n = Qf(t, n, rY);
          break;
      }
      break;
    case "utc":
    case "time":
      n = Qf(t, n, RV);
      break;
  }
  switch (i) {
    case "diverging":
      return Cj(e, t, n);
    case "diverging-sqrt":
      return kj(e, t, n);
    case "diverging-pow":
      return m4(e, t, n);
    case "diverging-log":
      return Uj(e, t, n);
    case "diverging-symlog":
      return zj(e, t, n);
    case "categorical":
    case "ordinal":
    case df:
      return Xj(e, t, n);
    case "cyclical":
    case "sequential":
    case "linear":
      return Ij(e, t, n);
    case "sqrt":
      return Aj(e, t, n);
    case "threshold":
      return r_(e, t, n);
    case "quantile":
      return Tj(e, t, n);
    case "quantize":
      return Bj(e, t, n);
    case "pow":
      return p4(e, t, n);
    case "log":
      return Mj(e, t, n);
    case "symlog":
      return $j(e, t, n);
    case "utc":
      return Gj(e, t, n);
    case "time":
      return Wj(e, t, n);
    case "point":
      return Hj(e, t, n);
    case "band":
      return Kj(e, t, n);
    case "identity":
      return ve.get(e) === Qi ? Fj() : { type: "identity" };
    case void 0:
      return;
    default:
      throw new Error(`unknown scale type: ${i}`);
  }
}
function ma(e) {
  return typeof e == "symbol" ? e.description : e;
}
const hx = { toString: () => "projection" };
function nY(e, t, { type: n, domain: i, range: r, scheme: s, pivot: o, projection: a }) {
  if (e === "fx" || e === "fy")
    return "band";
  (e === "x" || e === "y") && a != null && (n = hx);
  for (const { type: l } of t)
    if (l !== void 0) {
      if (n === void 0)
        n = l;
      else if (n !== l)
        throw new Error(`scale incompatible with channel: ${n} !== ${l}`);
    }
  if (n === hx)
    return;
  if (n !== void 0)
    return n;
  if (i === void 0 && !t.some(({ value: l }) => l !== void 0))
    return;
  const c = ve.get(e);
  if (c === Gy)
    return "sqrt";
  if (c === Hy || c === Xy)
    return "linear";
  if (c === Ky)
    return "ordinal";
  if ((i || r || []).length > 2)
    return dm(c);
  if (i !== void 0) {
    if (Qe(i))
      return dm(c);
    if (ri(i))
      return "utc";
  } else {
    const l = t.map(({ value: u }) => u).filter((u) => u !== void 0);
    if (l.some(Qe))
      return dm(c);
    if (l.some(ri))
      return "utc";
  }
  if (c === ls) {
    if (o != null || xj(s))
      return "diverging";
    if (_j(s))
      return "categorical";
  }
  return "linear";
}
function dm(e) {
  switch (e) {
    case Qi:
      return "point";
    case ls:
      return df;
    default:
      return "ordinal";
  }
}
function a_({ type: e }) {
  return e === "time" || e === "utc";
}
function sa({ type: e }) {
  return e === "ordinal" || e === "point" || e === "band" || e === df;
}
function A4({ type: e }) {
  return e === "threshold";
}
function iY({ type: e }) {
  return e === "point" || e === "band";
}
function Zn(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 Qf(e, { domain: t, ...n }, i) {
  for (const r of e)
    r.value !== void 0 && (r.value = i(r.value));
  return {
    domain: t === void 0 ? t : i(t),
    ...n
  };
}
function rY(e) {
  return he(e, Yb);
}
function ea(e = {}) {
  let t;
  for (const n in e)
    if (ve.has(n) && Vo(e[n])) {
      if (t !== void 0)
        throw new Error("ambiguous scale definition; multiple scales found");
      t = M4(Xg(n, e[n]));
    }
  if (t === void 0)
    throw new Error("invalid scale definition; no scale found");
  return t;
}
function sY(e) {
  return (t) => {
    if (!ve.has(t = `${t}`))
      throw new Error(`unknown scale: ${t}`);
    return t in e ? M4(e[t]) : void 0;
  };
}
function M4({ 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: Yg(n),
    // defensive copy
    ...i !== void 0 && { range: Yg(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 c_(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 oY = c_((e) => new Intl.NumberFormat(e)), aY = c_((e, t) => new Intl.DateTimeFormat(e, { timeZone: "UTC", ...t && { month: t } })), cY = c_((e, t) => new Intl.DateTimeFormat(e, { timeZone: "UTC", ...t && { weekday: t } }));
function lY(e = "en-US") {
  const t = oY(e);
  return (n) => n != null && !isNaN(n) ? t.format(n) : void 0;
}
function uY(e = "en-US", t = "short") {
  const n = aY(e, t);
  return (i) => i != null && !isNaN(i = +new Date(Date.UTC(2e3, +i))) ? n.format(i) : void 0;
}
function fY(e = "en-US", t = "short") {
  const n = cY(e, t);
  return (i) => i != null && !isNaN(i = +new Date(Date.UTC(2001, 0, +i))) ? n.format(i) : void 0;
}
function $4(e) {
  return E3(e, "Invalid Date");
}
function hY(e = "en-US") {
  const t = lY(e);
  return (n) => (n instanceof Date ? $4 : typeof n == "number" ? t : He)(n);
}
const Xr = hY(), Ye = (typeof window < "u" ? window.devicePixelRatio > 1 : typeof it > "u") ? 0 : 0.5;
let dY = 0;
function dx() {
  return `plot-clip-${++dY}`;
}
function T4(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: m,
  strokeDashoffset: g,
  opacity: y,
  mixBlendMode: b,
  imageFilter: _,
  paintOrder: w,
  pointerEvents: x,
  shapeRendering: v,
  channels: I
}, {
  ariaLabel: T,
  fill: F = "currentColor",
  fillOpacity: A,
  stroke: $ = "none",
  strokeOpacity: D,
  strokeWidth: O,
  strokeLinecap: S,
  strokeLinejoin: M,
  strokeMiterlimit: B,
  paintOrder: N
}) {
  F === null && (a = null, c = null), $ === null && (l = null, f = null), ke(F) ? !ke($) && (!ke(a) || I != null && I.fill) && ($ = "none") : ke($) && (!ke(l) || I != null && I.stroke) && (F = "none");
  const [L, k] = _n(a, F), [U, V] = Te(c, A), [j, X] = _n(l, $), [J, rt] = Te(f, D), [Gt, W] = Te(y);
  Nc(X) || (u === void 0 && (u = O), d === void 0 && (d = S), h === void 0 && (h = M), p === void 0 && !jV(h) && (p = B), !Nc(k) && w === void 0 && (w = N));
  const [H, P] = Te(u);
  return F !== null && (e.fill = Ie(k, "currentColor"), e.fillOpacity = xl(V, 1)), $ !== null && (e.stroke = Ie(X, "none"), e.strokeWidth = xl(P, 1), e.strokeOpacity = xl(rt, 1), e.strokeLinejoin = Ie(h, "miter"), e.strokeLinecap = Ie(d, "butt"), e.strokeMiterlimit = xl(p, 4), e.strokeDasharray = Ie(m, "none"), e.strokeDashoffset = Ie(g, "0")), e.target = He(o), e.ariaLabel = He(T), e.ariaDescription = He(r), e.ariaHidden = He(s), e.opacity = xl(W, 1), e.mixBlendMode = Ie(b, "normal"), e.imageFilter = Ie(_, "none"), e.paintOrder = Ie(w, "normal"), e.pointerEvents = Ie(x, "auto"), e.shapeRendering = Ie(v, "auto"), {
    title: { value: t, optional: !0, filter: null },
    href: { value: n, optional: !0, filter: null },
    ariaLabel: { value: i, optional: !0, filter: null },
    fill: { value: L, scale: "auto", optional: !0 },
    fillOpacity: { value: U, scale: "auto", optional: !0 },
    stroke: { value: j, scale: "auto", optional: !0 },
    strokeOpacity: { value: J, scale: "auto", optional: !0 },
    strokeWidth: { value: H, optional: !0 },
    opacity: { value: Gt, scale: "auto", optional: !0 }
  };
}
function pY(e, t) {
  t && e.filter((n) => Ob(t[n])).append("title").call(mY, t);
}
function yY(e, t) {
  t && e.filter(([n]) => Ob(t[n])).append("title").call(gY, t);
}
function mY(e, t) {
  t && e.text((n) => Xr(t[n]));
}
function gY(e, t) {
  t && e.text(([n]) => Xr(t[n]));
}
function Le(e, { target: t, tip: n }, {
  ariaLabel: i,
  title: r,
  fill: s,
  fillOpacity: o,
  stroke: a,
  strokeOpacity: c,
  strokeWidth: l,
  opacity: u,
  href: f
}) {
  i && st(e, "aria-label", (h) => i[h]), s && st(e, "fill", (h) => s[h]), o && st(e, "fill-opacity", (h) => o[h]), a && st(e, "stroke", (h) => a[h]), c && st(e, "stroke-opacity", (h) => c[h]), l && st(e, "stroke-width", (h) => l[h]), u && st(e, "opacity", (h) => u[h]), f && N4(e, (h) => f[h], t), n || pY(e, r);
}
function pp(e, { target: t, tip: n }, {
  ariaLabel: i,
  title: r,
  fill: s,
  fillOpacity: o,
  stroke: a,
  strokeOpacity: c,
  strokeWidth: l,
  opacity: u,
  href: f
}) {
  i && st(e, "aria-label", ([h]) => i[h]), s && st(e, "fill", ([h]) => s[h]), o && st(e, "fill-opacity", ([h]) => o[h]), a && st(e, "stroke", ([h]) => a[h]), c && st(e, "stroke-opacity", ([h]) => c[h]), l && st(e, "stroke-width", ([h]) => l[h]), u && st(e, "opacity", ([h]) => u[h]), f && N4(e, ([h]) => f[h], t), n || yY(e, r);
}
function bY({
  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 l_(e, t, n) {
  const i = os(e, (r) => t[r]);
  return n === void 0 && i.size > 1 + e.length >> 1 && Fs(
    "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* B4(e, t, n, i) {
  const { z: r } = n, { z: s } = i, o = bY(i, n), a = [...t, ...o];
  for (const c of s ? l_(e, s, r) : [e]) {
    let l, u;
    t:
      for (const f of c) {
        for (const h of a)
          if (!cn(h[f])) {
            u && u.push(-1);
            continue t;
          }
        if (l === void 0) {
          u && (yield u), l = o.map((h) => Do(h[f])), u = [f];
          continue;
        }
        u.push(f);
        for (let h = 0; h < o.length; ++h)
          if (Do(o[h][f]) !== l[h]) {
            yield u, l = o.map((p) => Do(p[f])), u = [f];
            continue t;
          }
      }
    u && (yield u);
  }
}
function _Y(e) {
  return e === !0 ? e = "frame" : e === !1 && (e = null), qy(e, "clip", ["frame", "sphere"]);
}
function wY(e, t, n, i) {
  let r;
  switch (t.clip) {
    case "frame": {
      const { width: s, height: o, marginLeft: a, marginRight: c, marginTop: l, marginBottom: u } = n, f = dx();
      r = `url(#${f})`, e = Wt("svg:g", i).call(
        (h) => h.append("svg:clipPath").attr("id", f).append("rect").attr("x", a).attr("y", l).attr("width", s - c - a).attr("height", o - l - u)
      ).each(function() {
        this.appendChild(e.node()), e.node = () => this;
      });
      break;
    }
    case "sphere": {
      const { projection: s } = i;
      if (!s)
        throw new Error('the "sphere" clip option requires a projection');
      const o = dx();
      r = `url(#${o})`, e.append("clipPath").attr("id", o).append("path").attr("d", to(s)({ type: "Sphere" }));
      break;
    }
  }
  st(e, "aria-label", t.ariaLabel), st(e, "aria-description", t.ariaDescription), st(e, "aria-hidden", t.ariaHidden), st(e, "clip-path", r);
}
function ye(e, t, n, i) {
  wY(e, t, n, i), st(e, "fill", t.fill), st(e, "fill-opacity", t.fillOpacity), st(e, "stroke", t.stroke), st(e, "stroke-width", t.strokeWidth), st(e, "stroke-opacity", t.strokeOpacity), st(e, "stroke-linejoin", t.strokeLinejoin), st(e, "stroke-linecap", t.strokeLinecap), st(e, "stroke-miterlimit", t.strokeMiterlimit), st(e, "stroke-dasharray", t.strokeDasharray), st(e, "stroke-dashoffset", t.strokeDashoffset), st(e, "shape-rendering", t.shapeRendering), st(e, "filter", t.imageFilter), st(e, "paint-order", t.paintOrder);
  const { pointerEvents: r = i.pointerSticky === !1 ? "none" : void 0 } = t;
  st(e, "pointer-events", r);
}
function pe(e, t) {
  vY(e, "mix-blend-mode", t.mixBlendMode), st(e, "opacity", t.opacity);
}
function N4(e, t, n) {
  e.each(function(i) {
    const r = t(i);
    if (r != null) {
      const s = this.ownerDocument.createElementNS(Xo.svg, "a");
      s.setAttribute("fill", "inherit"), s.setAttributeNS(Xo.xlink, "href", r), n != null && s.setAttribute("target", n), this.parentNode.insertBefore(s, this).appendChild(this);
    }
  });
}
function st(e, t, n) {
  n != null && e.attr(t, n);
}
function vY(e, t, n) {
  n != null && e.style(t, n);
}
function ae(e, t, { x: n, y: i }, r = Ye, s = Ye) {
  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 Ie(e, t) {
  if ((e = He(e)) !== t)
    return e;
}
function xl(e, t) {
  if ((e = Ct(e)) !== t)
    return e;
}
const xY = /^-?([_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 u_(e) {
  if (e === void 0)
    return "plot-d6a7b5";
  if (e = `${e}`, !xY.test(e))
    throw new Error(`invalid class name: ${e}`);
  return e;
}
function f_(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 yr({ 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 SY(e, t, n = {}) {
  let i = 0.5 - Ye, r = 0.5 + Ye, s = 0.5 + Ye, o = 0.5 - Ye;
  for (const { marginTop: m, marginRight: g, marginBottom: y, marginLeft: b } of t)
    m > i && (i = m), g > r && (r = g), y > s && (s = y), 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 = IY(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: m,
      marginTop: g = m !== void 0 ? m : c,
      marginRight: y = m !== void 0 ? m : l,
      marginBottom: b = m !== void 0 ? m : u,
      marginLeft: _ = m !== void 0 ? m : f
    } = n.facet ?? {};
    g = +g, y = +y, b = +b, _ = +_, p.facet = {
      marginTop: g,
      marginRight: y,
      marginBottom: b,
      marginLeft: _
    };
  }
  return p;
}
function IY({ 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 = gj(r);
  if (h) {
    const p = i ? i.scale.domain().length : 1, m = (1.1 * f - 0.1) / (1.1 * p - 0.1) * h, g = Math.max(0.1, Math.min(10, m));
    return Math.round((o - u - c) * g + a + l);
  }
  const d = t ? sa(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 = px("y", t) / (px("x", e) * s), m = i ? i.scale.bandwidth() : 1, g = n ? n.scale.bandwidth() : 1, y = m * (o - u - c) - e.insetLeft - e.insetRight;
    return (p * y + t.insetTop + t.insetBottom) / g + a + l;
  }
  return !!(t || n) * Math.max(1, Math.min(60, d * f)) * 20 + !!i * 30 + 60;
}
function px(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] = je(i);
  return Math.abs(r(o) - r(s));
}
function AY(e, t) {
  const { fx: n, fy: i } = Gg(e, t), r = n == null ? void 0 : n.scale.domain(), s = i == null ? void 0 : i.scale.domain();
  return r && s ? _L(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 MY(e, { x: t, y: n }) {
  return t && (t = Hg(t)), n && (n = Hg(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 h_(e, { fx: t, fy: n }) {
  const i = as(e), r = t == null ? void 0 : t.value, s = n == null ? void 0 : n.value;
  return t && n ? Xa(
    i,
    (o) => (o.fx = r[o[0]], o.fy = s[o[0]], o),
    (o) => r[o],
    (o) => s[o]
  ) : t ? Xa(
    i,
    (o) => (o.fx = r[o[0]], o),
    (o) => r[o]
  ) : Xa(
    i,
    (o) => (o.fy = s[o[0]], o),
    (o) => s[o]
  );
}
function $Y(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 TY(e) {
  const t = [], n = new Uint32Array(sr(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 BY = /* @__PURE__ */ new Map([
  ["top", pm],
  ["right", gm],
  ["bottom", ym],
  ["left", mm],
  ["top-left", th(pm, mm)],
  ["top-right", th(pm, gm)],
  ["bottom-left", th(ym, mm)],
  ["bottom-right", th(ym, gm)],
  ["top-empty", DY],
  ["right-empty", LY],
  ["bottom-empty", EY],
  ["left-empty", OY],
  ["empty", RY]
]);
function NY(e) {
  if (e == null)
    return null;
  const t = BY.get(`${e}`.toLowerCase());
  if (t)
    return t;
  throw new Error(`invalid facet anchor: ${e}`);
}
const yx = /* @__PURE__ */ new WeakMap();
function Hg(e) {
  let t = yx.get(e);
  return t || yx.set(e, t = new Go(he(e, (n, i) => [n, i]))), t;
}
function io(e, t) {
  return Hg(e).get(t);
}
function FY(e, t, n) {
  return t = Do(t), n = Do(n), e.find((i) => Object.is(Do(i.x), t) && Object.is(Do(i.y), n));
}
function r0(e, t, n) {
  var i;
  return (i = FY(e, t, n)) == null ? void 0 : i.empty;
}
function pm(e, { y: t }, { y: n }) {
  return t ? io(t, n) === 0 : !0;
}
function ym(e, { y: t }, { y: n }) {
  return t ? io(t, n) === t.length - 1 : !0;
}
function mm(e, { x: t }, { x: n }) {
  return t ? io(t, n) === 0 : !0;
}
function gm(e, { x: t }, { x: n }) {
  return t ? io(t, n) === t.length - 1 : !0;
}
function DY(e, { y: t }, { x: n, y: i, empty: r }) {
  if (r)
    return !1;
  if (!t)
    return;
  const s = io(t, i);
  if (s > 0)
    return r0(e, n, t[s - 1]);
}
function EY(e, { y: t }, { x: n, y: i, empty: r }) {
  if (r)
    return !1;
  if (!t)
    return;
  const s = io(t, i);
  if (s < t.length - 1)
    return r0(e, n, t[s + 1]);
}
function OY(e, { x: t }, { x: n, y: i, empty: r }) {
  if (r)
    return !1;
  if (!t)
    return;
  const s = io(t, n);
  if (s > 0)
    return r0(e, t[s - 1], i);
}
function LY(e, { x: t }, { x: n, y: i, empty: r }) {
  if (r)
    return !1;
  if (!t)
    return;
  const s = io(t, n);
  if (s < t.length - 1)
    return r0(e, t[s + 1], i);
}
function RY(e, t, { empty: n }) {
  return n;
}
function th(e, t) {
  return function() {
    return e.apply(null, arguments) && t.apply(null, arguments);
  };
}
function bm(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 ce = 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: m = h,
      marginLeft: g = h,
      clip: y,
      channels: b,
      tip: _,
      render: w
    } = i;
    if (this.data = t, this.sort = Ps(l) ? l : null, this.initializer = vn(i).initializer, this.transform = this.initializer ? i.transform : pr(i).transform, s === null || s === !1 ? this.facet = null : (this.facet = hr(s === !0 ? "include" : s, "facet", ["auto", "include", "exclude", "super"]), this.fx = t === tu && typeof a == "string" ? [a] : a, this.fy = t === tu && typeof c == "string" ? [c] : c), this.facetAnchor = NY(o), n = Pb(n), b !== void 0 && (n = { ...CY(b), ...n }), r !== void 0 && (n = { ...T4(this, i, r), ...n }), this.channels = Object.fromEntries(
      Object.entries(n).map(([x, v]) => {
        if (Pi(v.value)) {
          const { value: I, scale: T = v.scale } = v.value;
          v = { ...v, scale: T, value: I };
        }
        if (t === tu && typeof v.value == "string") {
          const { value: I } = v;
          v = { ...v, value: [I] };
        }
        return [x, v];
      }).filter(([x, { value: v, optional: I }]) => {
        if (v != null)
          return !0;
        if (I)
          return !1;
        throw new Error(`missing channel value: ${x}`);
      })
    ), this.dx = +u, this.dy = +f, this.marginTop = +d, this.marginRight = +p, this.marginBottom = +m, this.marginLeft = +g, this.clip = _Y(y), this.tip = kY(_), this.facet === "super") {
      if (a || c)
        throw new Error("super-faceting cannot use fx or fy");
      for (const x in this.channels) {
        const { scale: v } = n[x];
        if (!(v !== "x" && v !== "y"))
          throw new Error("super-faceting cannot use x or y");
      }
    }
    w != null && (this.render = F4(w, this.render));
  }
  initialize(t, n, i) {
    let r = wn(this.data);
    t === void 0 && r != null && (t = [as(r)]);
    const s = t;
    this.transform != null && ({ facets: t, data: r } = this.transform(r, t, i), r = wn(r)), t !== void 0 && (t.original = s);
    const o = e4(this.channels, r);
    return this.sort != null && cj(r, t, o, n, this.sort), { data: r, facets: t, channels: o };
  }
  filter(t, n, i) {
    for (const r in n) {
      const { filter: s = cn } = 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" && l4(r, s, n, i.projection);
      }
  }
  scale(t, n, i) {
    const r = n_(t, n);
    return i.projection && this.project(t, r, i), r;
  }
};
function es(...e) {
  return e.plot = ce.prototype.plot, e;
}
function F4(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 CY(e) {
  return Object.fromEntries(
    Object.entries(Pb(e)).map(([t, n]) => (n = lf(n), n.filter === void 0 && n.scale == null && (n = { ...n, filter: null }), [t, n]))
  );
}
function kY(e) {
  return e === !0 ? "xy" : e === !1 ? null : qy(e, "tip", ["x", "y", "xy"]);
}
function Qc(e, t) {
  return (e == null ? void 0 : e.tip) === !0 ? { ...e, tip: t } : e;
}
const mx = /* @__PURE__ */ new WeakMap();
function d_(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: F4(function(u, f, h, d, p, m) {
      p = { ...p, pointerSticky: !1 };
      const g = p.ownerSVGElement, { data: y } = p.getMarkState(this);
      let b = mx.get(g);
      b || mx.set(g, b = { sticky: !1, roots: [], renders: [] });
      let _ = b.renders.push(X) - 1;
      const { x: w, y: x, fx: v, fy: I } = f;
      let T = v ? v(u.fx) - d.marginLeft : 0, F = I ? I(u.fy) - d.marginTop : 0;
      w != null && w.bandwidth && (T += w.bandwidth() / 2), x != null && x.bandwidth && (F += x.bandwidth() / 2);
      const A = u.fi != null;
      let $;
      if (A) {
        let W = b.facetStates;
        W || (b.facetStates = W = /* @__PURE__ */ new Map()), $ = W.get(this), $ || W.set(this, $ = /* @__PURE__ */ new Map());
      }
      const [D, O] = yr(this, d), { px: S, py: M } = h, B = S ? (W) => S[W] : D4(h, D), N = M ? (W) => M[W] : E4(h, O);
      let L, k, U, V;
      function j(W, H) {
        if (A)
          if (V && (V = cancelAnimationFrame(V)), W == null)
            $.delete(u.fi);
          else {
            $.set(u.fi, H), V = requestAnimationFrame(() => {
              V = null;
              for (const P of $.values())
                if (P < H) {
                  W = null;
                  break;
                }
              X(W);
            });
            return;
          }
        X(W);
      }
      function X(W) {
        if (L === W && U === b.sticky)
          return;
        L = W, U = p.pointerSticky = b.sticky;
        const H = L == null ? [] : [L];
        A && (H.fx = u.fx, H.fy = u.fy, H.fi = u.fi);
        const P = m(H, f, h, d, p);
        if (k) {
          if (A) {
            const K = k.parentNode, Z = k.getAttribute("transform"), z = P.getAttribute("transform");
            Z ? P.setAttribute("transform", Z) : P.removeAttribute("transform"), z ? K.setAttribute("transform", z) : K.removeAttribute("transform"), P.removeAttribute("aria-label"), P.removeAttribute("aria-description"), P.removeAttribute("aria-hidden");
          }
          k.replaceWith(P);
        }
        return b.roots[_] = k = P, p.dispatchValue(L == null ? null : y[L]), P;
      }
      function J(W) {
        if (b.sticky || W.pointerType === "mouse" && W.buttons === 1)
          return;
        let [H, P] = ci(W);
        H -= T, P -= F;
        let K = null, Z = o * o;
        for (const z of u) {
          const tt = e * (B(z) - H), lt = t * (N(z) - P), zt = tt * tt + lt * lt;
          zt <= Z && (K = z, Z = zt);
        }
        j(K, Z);
      }
      function rt(W) {
        W.pointerType === "mouse" && L != null && (b.sticky && b.roots.some((H) => H == null ? void 0 : H.contains(W.target)) || (b.sticky ? (b.sticky = !1, b.renders.forEach((H) => H(null))) : (b.sticky = !0, X(L)), W.stopImmediatePropagation()));
      }
      function Gt(W) {
        W.pointerType === "mouse" && (b.sticky || j(null));
      }
      return g.addEventListener("pointerenter", J), g.addEventListener("pointermove", J), g.addEventListener("pointerdown", rt), g.addEventListener("pointerleave", Gt), X(null);
    }, c)
  };
}
function p_(e) {
  return d_(1, 1, e);
}
function y_(e) {
  return d_(1, 0.01, e);
}
function m_(e) {
  return d_(0.01, 1, e);
}
function D4({ x1: e, x2: t, x: n = e }, i) {
  return e && t ? (r) => (e[r] + t[r]) / 2 : n ? (r) => n[r] : () => i;
}
function E4({ y1: e, y2: t, y: n = e }, i) {
  return e && t ? (r) => (e[r] + t[r]) / 2 : n ? (r) => n[r] : () => i;
}
function O4(e) {
  return sa(e) && e.interval === void 0 ? void 0 : "tabular-nums";
}
function UY(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 = O4(e),
    round: p = !0,
    opacity: m,
    className: g
  } = t;
  const y = t0(t);
  g = u_(g), m = Te(m)[1], h === null && (h = () => null);
  const b = Wt("svg", y).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(
    (D) => (
      // Warning: if you edit this, change defaultClassName.
      D.append("style").text(
        `.${g}-ramp {
  display: block;
  background: white;
  height: auto;
  height: intrinsic;
  max-width: 100%;
  overflow: visible;
}
.${g}-ramp text {
  white-space: pre;
}`
      )
    )
  ).call(f_, u);
  let _ = (D) => D.selectAll(".tick line").attr("y1", o + c - s), w;
  const x = p ? (D, O) => D.rangeRound(O) : (D, O) => D.range(O), { type: v, domain: I, range: T, interpolate: F, scale: A, pivot: $ } = e;
  if (F) {
    const D = T === void 0 ? F : vy(F.length === 1 ? s_(F) : F, T);
    w = x(
      A.copy(),
      wi(
        Xe(l, r - a),
        Math.min(I.length + ($ !== void 0), T === void 0 ? 1 / 0 : T.length)
      )
    );
    const O = 256, S = y.document.createElement("canvas");
    S.width = O, S.height = 1;
    const M = S.getContext("2d");
    for (let B = 0, N = O - 1; B < O; ++B)
      M.fillStyle = D(B / N), M.fillRect(B, 0, 1, 1);
    b.append("image").attr("opacity", m).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 (v === "threshold") {
    const D = I, O = h === void 0 ? (S) => S : typeof h == "string" ? ef(h) : h;
    w = x(By().domain([-1, T.length - 1]), [l, r - a]), b.append("g").attr("fill-opacity", m).selectAll().data(T).enter().append("rect").attr("x", (S, M) => w(M - 1)).attr("y", o).attr("width", (S, M) => w(M) - w(M - 1)).attr("height", s - o - c).attr("fill", (S) => S), f = he(D, (S, M) => M), h = (S) => O(D[S], S);
  } else
    w = x($y().domain(I), [l, r - a]), b.append("g").attr("fill-opacity", m).selectAll().data(I).enter().append("rect").attr("x", w).attr("y", o).attr("width", Math.max(0, w.bandwidth() - 1)).attr("height", s - o - c).attr("fill", A), _ = () => {
    };
  return b.append("g").attr("transform", `translate(0,${s - c})`).call(
    PL(w).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", Ie(d, "normal")).call(_).call((D) => D.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 yp = Math.PI / 180;
function tl(e, { marker: t, markerStart: n = t, markerMid: i = t, markerEnd: r = t } = {}) {
  e.markerStart = _m(n), e.markerMid = _m(i), e.markerEnd = _m(r);
}
function _m(e) {
  if (e == null || e === !1)
    return null;
  if (e === !0)
    return bx;
  if (typeof e == "function")
    return e;
  switch (`${e}`.toLowerCase()) {
    case "none":
      return null;
    case "arrow":
      return gx("auto");
    case "arrow-reverse":
      return gx("auto-start-reverse");
    case "dot":
      return zY;
    case "circle":
    case "circle-fill":
      return bx;
    case "circle-stroke":
      return PY;
  }
  throw new Error(`invalid marker: ${e}`);
}
function gx(e) {
  return (t, n) => Wt("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 zY(e, t) {
  return Wt("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 bx(e, t) {
  return Wt("svg:marker", t).attr("viewBox", "-5 -5 10 10").attr("markerWidth", 6.67).attr("markerHeight", 6.67).attr("fill", e).attr("stroke", "white").attr("stroke-width", 1.5).call((n) => n.append("circle").attr("r", 3)).node();
}
function PY(e, t) {
  return Wt("svg:marker", t).attr("viewBox", "-5 -5 10 10").attr("markerWidth", 6.67).attr("markerHeight", 6.67).attr("fill", "white").attr("stroke", e).attr("stroke-width", 1.5).call((n) => n.append("circle").attr("r", 3)).node();
}
let VY = 0;
function pf(e, t, { stroke: n }, i) {
  return L4(e, t, n && ((r) => n[r]), i);
}
function jY(e, t, { stroke: n }, i) {
  return L4(e, t, n && (([r]) => n[r]), i);
}
function L4(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), m = `plot-marker-${++VY}`;
        p.setAttribute("id", m), h.set(f, d = `url(#${m})`);
      }
      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] = R4(e, t, n), { inset: e, insetLeft: t, insetRight: n, ...i };
}
function mf({ inset: e, insetTop: t, insetBottom: n, ...i } = {}) {
  return [t, n] = R4(e, t, n), { inset: e, insetTop: t, insetBottom: n, ...i };
}
function R4(e, t, n) {
  return e === void 0 && t === void 0 && n === void 0 ? Ye ? [1, 0] : [0.5, 0.5] : [t, n];
}
function C4(e, { interval: t }) {
  return e = { ...lf(e) }, e.interval = zb(e.interval === void 0 ? t : e.interval), e;
}
function s0(e, t, n, i) {
  const { [e]: r, [`${e}1`]: s, [`${e}2`]: o } = n, { value: a, interval: c } = C4(r, n);
  if (a == null || c == null && !i)
    return n;
  const l = cs(r);
  if (c == null) {
    let d;
    const p = { transform: (m) => d || (d = Ot(m, a)), label: l };
    return {
      ...n,
      [e]: void 0,
      [`${e}1`]: s === void 0 ? p : s,
      [`${e}2`]: o === void 0 ? p : o
    };
  }
  let u, f;
  function h(d) {
    return f !== void 0 && d === u ? f : f = he(Ot(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 k4(e, t, n) {
  const { [e]: i } = n, { value: r, interval: s } = C4(i, n);
  return r == null || s == null ? n : t({
    ...n,
    [e]: {
      label: cs(i),
      transform: (o) => {
        const a = he(Ot(o, r), (l) => s.floor(l)), c = a.map((l) => s.offset(l));
        return a.map(
          ri(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 U4(e = {}) {
  return s0("x", yf, e, !0);
}
function z4(e = {}) {
  return s0("y", mf, e, !0);
}
function P4(e = {}) {
  return s0("x", yf, e);
}
function V4(e = {}) {
  return s0("y", mf, e);
}
function j4(e = {}) {
  return k4("x", yf, e);
}
function Y4(e = {}) {
  return k4("y", mf, e);
}
const q4 = {
  ariaLabel: "rule",
  fill: null,
  stroke: "currentColor"
};
class W4 extends ce {
  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 }
      },
      Qc(n, "x"),
      q4
    ), this.insetTop = Ct(a), this.insetBottom = Ct(c), tl(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: m, marginBottom: g } = r, { insetTop: y, insetBottom: b } = this;
    return Wt("svg:g", s).call(ye, this, r, s).call(ae, this, { x: c && o }, Ye, 0).call(
      (_) => _.selectAll().data(t).enter().append("line").call(pe, this).attr("x1", c ? (w) => c[w] : (m + f - p) / 2).attr("x2", c ? (w) => c[w] : (m + f - p) / 2).attr("y1", l && !Zn(a) ? (w) => l[w] + y : d + y).attr(
        "y2",
        u && !Zn(a) ? a.bandwidth ? (w) => u[w] + a.bandwidth() - b : (w) => u[w] - b : h - g - b
      ).call(Le, this, i).call(pf, this, i, s)
    ).node();
  }
}
class G4 extends ce {
  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 }
      },
      Qc(n, "y"),
      q4
    ), this.insetRight = Ct(a), this.insetLeft = Ct(c), tl(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: m, marginBottom: g } = r, { insetLeft: y, insetRight: b } = this;
    return Wt("svg:g", s).call(ye, this, r, s).call(ae, this, { y: c && a }, 0, Ye).call(
      (_) => _.selectAll().data(t).enter().append("line").call(pe, this).attr("x1", l && !Zn(o) ? (w) => l[w] + y : m + y).attr(
        "x2",
        u && !Zn(o) ? o.bandwidth ? (w) => u[w] + o.bandwidth() - b : (w) => u[w] - b : f - p - b
      ).attr("y1", c ? (w) => c[w] : (d + h - g) / 2).attr("y2", c ? (w) => c[w] : (d + h - g) / 2).call(Le, this, i).call(pf, this, i, s)
    ).node();
  }
}
function Vs(e, t) {
  let { x: n = ct, y: i, y1: r, y2: s, ...o } = V4(t);
  return [r, s] = X4(i, r, s), new W4(e, { ...o, x: n, y1: r, y2: s });
}
function js(e, t) {
  let { y: n = ct, x: i, x1: r, x2: s, ...o } = P4(t);
  return [r, s] = X4(i, r, s), new G4(e, { ...o, y: n, x1: r, x2: s });
}
function X4(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 o0(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 YY = {
  ariaLabel: "text",
  strokeLinejoin: "round",
  strokeWidth: 3,
  paintOrder: "stroke"
}, H4 = "­";
class a0 extends ce {
  constructor(t, n = {}) {
    const {
      x: i,
      y: r,
      text: s = dr(t) && G$(t) ? ct : In,
      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: m,
      fontVariant: g,
      fontWeight: y,
      rotate: b
    } = n, [_, w] = Te(b, 0), [x, v] = XY(p);
    if (super(
      t,
      {
        x: { value: i, scale: "x", optional: !0 },
        y: { value: r, scale: "y", optional: !0 },
        fontSize: { value: x, optional: !0 },
        rotate: { value: kV(_), optional: !0 },
        text: { value: s, filter: Ob, optional: !0 }
      },
      n,
      YY
    ), this.rotate = w, this.textAnchor = Ie(a, "middle"), this.lineAnchor = hr(c, "lineAnchor", ["top", "middle", "bottom"]), this.lineHeight = +l, this.lineWidth = +u, this.textOverflow = K4(f), this.monospace = !!h, this.fontFamily = He(d), this.fontSize = v, this.fontStyle = He(m), this.fontVariant = He(g), this.fontWeight = He(y), this.frameAnchor = ff(o), !(this.lineWidth >= 0))
      throw new Error(`invalid lineWidth: ${u}`);
    this.splitLines = tT(this), this.clipLine = eT(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, [m, g] = yr(this, r);
    return Wt("svg:g", s).call(ye, this, r, s).call(Q4, this, f, r).call(ae, this, { x: c && o, y: l && a }).call(
      (y) => y.selectAll().data(t).enter().append("text").call(pe, this).call(qY, this, f, h).attr(
        "transform",
        o0`translate(${c ? (b) => c[b] : m},${l ? (b) => l[b] : g})${u ? (b) => ` rotate(${u[b]})` : p ? ` rotate(${p})` : ""}`
      ).call(st, "font-size", d && ((b) => d[b])).call(Le, this, i)
    ).node();
  }
}
function K4(e) {
  return e == null ? null : hr(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 qY(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(Xr(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 m = this.ownerDocument.createElementNS(Xo.svg, "tspan");
        m.setAttribute("x", 0), p === d - 1 ? m.setAttribute("y", `${(h + p) * s}em`) : m.setAttribute("dy", `${d * s}em`), m.textContent = u[p], this.appendChild(m), 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(Xo.svg, "title");
      d.textContent = n[l], this.appendChild(d);
    }
  });
}
function Dc(e, { x: t, y: n, ...i } = {}) {
  return i.frameAnchor === void 0 && ([t, n] = Di(t, n)), new a0(e, { ...i, x: t, y: n });
}
function Z4(e, { x: t = ct, ...n } = {}) {
  return new a0(e, Y4({ ...n, x: t }));
}
function J4(e, { y: t = ct, ...n } = {}) {
  return new a0(e, j4({ ...n, y: t }));
}
function Q4(e, t, n) {
  st(e, "text-anchor", t.textAnchor), st(e, "font-family", t.fontFamily), st(e, "font-size", t.fontSize), st(e, "font-style", t.fontStyle), st(e, "font-variant", t.fontVariant === void 0 ? WY(n) : t.fontVariant), st(e, "font-weight", t.fontWeight);
}
function WY(e) {
  return e && (X$(e) || ri(e)) ? "tabular-nums" : void 0;
}
const GY = /* @__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 XY(e) {
  return e == null || typeof e == "number" ? [void 0, e] : typeof e != "string" ? [e, void 0] : (e = e.trim().toLowerCase(), GY.has(e) || /^[+-]?\d*\.?\d+(e[+-]?\d+)?(\w*|%)$/.test(e) ? [void 0, e] : [e, void 0]);
}
function HY(e, t, n) {
  const i = [];
  let r, s = 0;
  for (const [o, a, c] of KY(e)) {
    if (r === void 0 && (r = o), s > r && n(e, r, a) > t && (i.push(e.slice(r, s) + (e[s - 1] === H4 ? "-" : "")), r = o), c) {
      i.push(e.slice(r, a)), r = void 0;
      continue;
    }
    s = a;
  }
  return i;
}
function* KY(e) {
  let t = 0, n = 0;
  const i = e.length;
  for (; n < i; ) {
    let r = 1;
    switch (e[n]) {
      case H4:
      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 _x = {
  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 g_(e, t = 0, n = e.length) {
  let i = 0;
  for (let r = t; r < n; r = el(e, r))
    i += _x[e[r]] ?? (iT(e, r) ? 120 : _x.e);
  return i;
}
function b_(e, t = 0, n = e.length) {
  let i = 0;
  for (let r = t; r < n; r = el(e, r))
    i += iT(e, r) ? 200 : 100;
  return i;
}
function tT({ monospace: e, lineWidth: t, textOverflow: n }) {
  if (n != null || t == 1 / 0)
    return (s) => s.split(/\r\n?|\n/g);
  const i = e ? b_ : g_, r = t * 100;
  return (s) => HY(s, r, i);
}
function eT({ monospace: e, lineWidth: t, textOverflow: n }) {
  if (n == null || t == 1 / 0)
    return (s) => s;
  const i = e ? b_ : g_, r = t * 100;
  switch (n) {
    case "clip-start":
      return (s) => vx(s, r, i, "");
    case "clip-end":
      return (s) => wx(s, r, i, "");
    case "ellipsis-start":
      return (s) => vx(s, r, i, Qa);
    case "ellipsis-middle":
      return (s) => ZY(s, r, i, Qa);
    case "ellipsis-end":
      return (s) => wx(s, r, i, Qa);
  }
}
const Qa = "…";
function Ec(e, t, n, i) {
  const r = [];
  let s = 0;
  for (let o = 0, a = 0, c = e.length; o < c; o = a) {
    a = el(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 wx(e, t, n, i) {
  e = e.trim();
  const r = n(i), [s] = Ec(e, t, n, r);
  return s < 0 ? e : e.slice(0, s).trimEnd() + i;
}
function ZY(e, t, n, i) {
  e = e.trim();
  const r = n(e);
  if (r <= t)
    return e;
  const s = n(i) / 2, [o, a] = Ec(e, t / 2, n, s), [c] = Ec(e, r - t / 2 - a + s, n, -s);
  return c < 0 ? i : e.slice(0, o).trimEnd() + i + e.slice(el(e, c)).trimStart();
}
function vx(e, t, n, i) {
  e = e.trim();
  const r = n(e);
  if (r <= t)
    return e;
  const s = n(i), [o] = Ec(e, r - t + s, n, -s);
  return o < 0 ? i : i + e.slice(el(e, o)).trimStart();
}
const Kg = /[\p{Combining_Mark}\p{Emoji_Modifier}]+/uy, xx = /\p{Extended_Pictographic}/uy;
function el(e, t) {
  return t += JY(e, t) ? 2 : 1, tq(e, t) && (t = Kg.lastIndex), QY(e, t) ? el(e, t + 1) : t;
}
function nT(e, t) {
  return e.charCodeAt(t) < 128;
}
function JY(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 QY(e, t) {
  return e.charCodeAt(t) === 8205;
}
function tq(e, t) {
  return nT(e, t) ? !1 : (Kg.lastIndex = t, Kg.test(e));
}
function iT(e, t) {
  return nT(e, t) ? !1 : (xx.lastIndex = t, xx.test(e));
}
const rT = {
  ariaLabel: "vector",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1.5,
  strokeLinejoin: "round",
  strokeLinecap: "round"
}, sT = 3.5, eq = sT * 5, oT = {
  draw(e, t, n) {
    const i = t * n / eq;
    e.moveTo(0, 0), e.lineTo(0, -t), e.moveTo(-i, i - t), e.lineTo(0, -t), e.lineTo(i, i - t);
  }
}, aT = {
  draw(e, t, n) {
    e.moveTo(-n, 0), e.lineTo(0, -t), e.lineTo(n, 0);
  }
}, nq = /* @__PURE__ */ new Map([
  ["arrow", oT],
  ["spike", aT]
]);
function iq(e) {
  return e && typeof e.draw == "function";
}
function rq(e) {
  if (iq(e))
    return e;
  const t = nq.get(`${e}`.toLowerCase());
  if (t)
    return t;
  throw new Error(`invalid shape: ${e}`);
}
let c0 = class extends ce {
  constructor(t, n = {}) {
    const { x: i, y: r, r: s = sT, length: o, rotate: a, shape: c = oT, anchor: l = "middle", frameAnchor: u } = n, [f, h] = Te(o, 12), [d, p] = Te(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,
      rT
    ), this.r = +s, this.length = h, this.rotate = p, this.shape = rq(c), this.anchor = hr(l, "anchor", ["start", "middle", "end"]), this.frameAnchor = ff(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: m, r: g } = this, [y, b] = yr(this, r);
    return Wt("svg:g", s).call(ye, this, r, s).call(ae, this, { x: c && o, y: l && a }).call(
      (_) => _.selectAll().data(t).enter().append("path").call(pe, this).attr(
        "transform",
        o0`translate(${c ? (w) => c[w] : y},${l ? (w) => l[w] : b})${f ? (w) => ` rotate(${f[w]})` : d ? ` rotate(${d})` : ""}${p === "start" ? "" : p === "end" ? u ? (w) => ` translate(0,${u[w]})` : ` translate(0,${h})` : u ? (w) => ` translate(0,${u[w] / 2})` : ` translate(0,${h / 2})`}`
      ).attr(
        "d",
        u ? (w) => {
          const x = zr();
          return m.draw(x, u[w], g), x;
        } : (() => {
          const w = zr();
          return m.draw(w, h, g), w;
        })()
      ).call(Le, this, i)
    ).node();
  }
};
function cT(e, t = {}) {
  let { x: n, y: i, ...r } = t;
  return t.frameAnchor === void 0 && ([n, i] = Di(n, i)), new c0(e, { ...r, x: n, y: i });
}
function lT(e, t = {}) {
  const { x: n = ct, ...i } = t;
  return new c0(e, { ...i, x: n });
}
function uT(e, t = {}) {
  const { y: n = ct, ...i } = t;
  return new c0(e, { ...i, y: n });
}
function sq(e, t = {}) {
  const {
    shape: n = aT,
    stroke: i = rT.stroke,
    strokeWidth: r = 1,
    fill: s = i,
    fillOpacity: o = 0.3,
    anchor: a = "start",
    ...c
  } = t;
  return cT(e, { ...c, shape: n, stroke: i, strokeWidth: r, fill: s, fillOpacity: o, anchor: a });
}
function ro(e, t) {
  return arguments.length < 2 && !dr(e) && (t = e, e = null), t === void 0 && (t = {}), [e, t];
}
function l0({ anchor: e } = {}, t) {
  return e === void 0 ? t[0] : hr(e, "anchor", t);
}
function fT(e) {
  return l0(e, ["left", "right"]);
}
function hT(e) {
  return l0(e, ["right", "left"]);
}
function dT(e) {
  return l0(e, ["bottom", "top"]);
}
function pT(e) {
  return l0(e, ["top", "bottom"]);
}
function __() {
  const [e, t] = ro(...arguments);
  return gT("y", fT(t), e, t);
}
function yT() {
  const [e, t] = ro(...arguments);
  return gT("fy", hT(t), e, t);
}
function w_() {
  const [e, t] = ro(...arguments);
  return bT("x", dT(t), e, t);
}
function mT() {
  const [e, t] = ro(...arguments);
  return bT("fx", pT(t), e, t);
}
function gT(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: m,
  tickRotate: g,
  x: y,
  margin: b,
  marginTop: _ = b === void 0 ? 20 : b,
  marginRight: w = b === void 0 ? t === "right" ? 40 : 0 : b,
  marginBottom: x = b === void 0 ? 20 : b,
  marginLeft: v = b === void 0 ? t === "left" ? 40 : 0 : b,
  label: I,
  labelAnchor: T,
  labelArrow: F,
  labelOffset: A,
  ...$
}) {
  return p = Ct(p), m = Ct(m), g = Ct(g), T !== void 0 && (T = hr(T, "labelAnchor", ["center", "top", "bottom"])), F = NT(F), es(
    p && !ke(s) ? oq(e, t, n, {
      stroke: s,
      strokeOpacity: o,
      strokeWidth: a,
      tickSize: p,
      tickPadding: m,
      tickRotate: g,
      x: y,
      ...$
    }) : null,
    ke(c) ? null : cq(e, t, n, {
      fill: c,
      fillOpacity: l,
      stroke: f,
      strokeOpacity: h,
      strokeWidth: d,
      textAnchor: u,
      tickSize: p,
      tickPadding: m,
      tickRotate: g,
      x: y,
      marginTop: _,
      marginRight: w,
      marginBottom: x,
      marginLeft: v,
      ...$
    }),
    !ke(c) && I !== null ? Dc(
      [],
      MT({ fill: c, fillOpacity: l, ...$ }, function(D, O, S, M, B) {
        const N = M[e], { marginTop: L, marginRight: k, marginBottom: U, marginLeft: V } = e === "y" && B.inset || B, j = T ?? (N.bandwidth ? "center" : "top"), X = A ?? (t === "right" ? k : V) - 3;
        return j === "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 = j, this.frameAnchor = `${j}-${t}`, this.rotate = 0), this.dy = j === "top" ? 3 - L : j === "bottom" ? U - 3 : 0, this.dx = t === "right" ? X : -X, this.ariaLabel = `${e}-axis label`, {
          facets: [[0]],
          channels: { text: { value: [BT(e, N, { anchor: t, label: I, labelAnchor: j, labelArrow: F })] } }
        };
      })
    ) : null
  );
}
function bT(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: m,
  tickRotate: g,
  y,
  margin: b,
  marginTop: _ = b === void 0 ? t === "top" ? 30 : 0 : b,
  marginRight: w = b === void 0 ? 20 : b,
  marginBottom: x = b === void 0 ? t === "bottom" ? 30 : 0 : b,
  marginLeft: v = b === void 0 ? 20 : b,
  label: I,
  labelAnchor: T,
  labelArrow: F,
  labelOffset: A,
  ...$
}) {
  return p = Ct(p), m = Ct(m), g = Ct(g), T !== void 0 && (T = hr(T, "labelAnchor", ["center", "left", "right"])), F = NT(F), es(
    p && !ke(s) ? aq(e, t, n, {
      stroke: s,
      strokeOpacity: o,
      strokeWidth: a,
      tickSize: p,
      tickPadding: m,
      tickRotate: g,
      y,
      ...$
    }) : null,
    ke(c) ? null : lq(e, t, n, {
      fill: c,
      fillOpacity: l,
      stroke: f,
      strokeOpacity: h,
      strokeWidth: d,
      textAnchor: u,
      tickSize: p,
      tickPadding: m,
      tickRotate: g,
      y,
      marginTop: _,
      marginRight: w,
      marginBottom: x,
      marginLeft: v,
      ...$
    }),
    !ke(c) && I !== null ? Dc(
      [],
      MT({ fill: c, fillOpacity: l, ...$ }, function(D, O, S, M, B) {
        const N = M[e], { marginTop: L, marginRight: k, marginBottom: U, marginLeft: V } = e === "x" && B.inset || B, j = T ?? (N.bandwidth ? "center" : "right"), X = A ?? (t === "top" ? L : U) - 3;
        return j === "center" ? (this.frameAnchor = t, this.textAnchor = void 0) : (this.frameAnchor = `${t}-${j}`, this.textAnchor = j === "right" ? "end" : "start"), this.lineAnchor = t, this.dy = t === "top" ? -X : X, this.dx = j === "right" ? k - 3 : j === "left" ? 3 - V : 0, this.ariaLabel = `${e}-axis label`, {
          facets: [[0]],
          channels: { text: { value: [BT(e, N, { anchor: t, label: I, labelAnchor: j, labelArrow: F })] } }
        };
      })
    ) : null
  );
}
function oq(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 nl(uT, e, `${e}-axis tick`, n, {
    strokeWidth: i,
    strokeLinecap: r,
    strokeLinejoin: s,
    facetAnchor: o,
    frameAnchor: a,
    y: d,
    ...p,
    dx: t === "left" ? +h - Ye + +u : +h + Ye - f,
    anchor: "start",
    length: c,
    shape: t === "left" ? hq : dq
  });
}
function aq(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 nl(lT, e, `${e}-axis tick`, n, {
    strokeWidth: i,
    strokeLinejoin: s,
    strokeLinecap: r,
    facetAnchor: o,
    frameAnchor: a,
    x: d,
    ...p,
    dy: t === "bottom" ? +h - Ye - f : +h + Ye + +u,
    anchor: "start",
    length: c,
    shape: t === "bottom" ? uq : fq
  });
}
function cq(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 * yp) : 0),
  tickFormat: c,
  text: l = typeof c == "function" ? c : void 0,
  textAnchor: u = Math.abs(o) > 60 ? "middle" : t === "left" ? "end" : "start",
  lineAnchor: f = o > 60 ? "top" : o < -60 ? "bottom" : "middle",
  fontVariant: h,
  inset: d = 0,
  insetLeft: p = d,
  insetRight: m = d,
  dx: g = 0,
  y = e === "y" ? void 0 : null,
  ...b
}) {
  return nl(
    J4,
    e,
    `${e}-axis tick label`,
    n,
    {
      facetAnchor: i,
      frameAnchor: r,
      text: l === void 0 ? null : l,
      textAnchor: u,
      lineAnchor: f,
      fontVariant: h,
      rotate: o,
      y,
      ...b,
      dx: t === "left" ? +g - s - a + +p : +g + +s + +a - m
    },
    function(_, w, x, v) {
      h === void 0 && (this.fontVariant = TT(_)), l === void 0 && (v.text = $T(_, w, x, c, t));
    }
  );
}
function lq(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 * yp) : 0),
  tickFormat: c,
  text: l = typeof c == "function" ? c : void 0,
  textAnchor: u = Math.abs(o) >= 10 ? o < 0 ^ t === "bottom" ? "start" : "end" : "middle",
  lineAnchor: f = Math.abs(o) >= 10 ? "middle" : t === "bottom" ? "top" : "bottom",
  fontVariant: h,
  inset: d = 0,
  insetTop: p = d,
  insetBottom: m = d,
  dy: g = 0,
  x: y = e === "x" ? void 0 : null,
  ...b
}) {
  return nl(
    Z4,
    e,
    `${e}-axis tick label`,
    n,
    {
      facetAnchor: i,
      frameAnchor: r,
      text: l === void 0 ? null : l,
      textAnchor: u,
      lineAnchor: f,
      fontVariant: h,
      rotate: o,
      x: y,
      ...b,
      dy: t === "bottom" ? +g + +s + +a - m : +g - s - a + +p
    },
    function(_, w, x, v) {
      h === void 0 && (this.fontVariant = TT(_)), l === void 0 && (v.text = $T(_, w, x, c, t));
    }
  );
}
function _T() {
  const [e, t] = ro(...arguments);
  return ST("y", fT(t), e, t);
}
function wT() {
  const [e, t] = ro(...arguments);
  return ST("fy", hT(t), e, t);
}
function vT() {
  const [e, t] = ro(...arguments);
  return IT("x", dT(t), e, t);
}
function xT() {
  const [e, t] = ro(...arguments);
  return IT("fx", pT(t), e, t);
}
function ST(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 nl(js, e, `${e}-grid`, n, { y: i, x1: s, x2: o, ...AT(a) });
}
function IT(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 nl(Vs, e, `${e}-grid`, n, { x: i, y1: s, y2: o, ...AT(a) });
}
function AT({
  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 MT({ fill: e, fillOpacity: t, fontFamily: n, fontSize: i, fontStyle: r, fontWeight: s, monospace: o, pointerEvents: a, shapeRendering: c }, l) {
  return [, e] = _n(e), [, t] = Te(t), {
    facet: "super",
    x: null,
    y: null,
    fill: e,
    fillOpacity: t,
    fontFamily: n,
    fontSize: i,
    fontStyle: r,
    fontWeight: s,
    monospace: o,
    pointerEvents: a,
    shapeRendering: c,
    initializer: l
  };
}
function nl(e, t, n, i, r, s) {
  let o;
  function a(u, f, h, d, p, m) {
    const g = u == null && (t === "fx" || t === "fy"), { [t]: y } = d;
    if (!y)
      throw new Error(`missing scale: ${t}`);
    let { ticks: b, tickSpacing: _, interval: w } = r;
    if (a_(y) && typeof b == "string" && (w = b, b = void 0), u == null) {
      if (dr(b))
        u = wn(b);
      else if (y.ticks)
        if (b !== void 0)
          u = y.ticks(b);
        else if (w = Jc(w === void 0 ? y.interval : w, y.type), w !== void 0) {
          const [v, I] = je(y.domain());
          u = w.range(v, w.offset(w.floor(I)));
        } else {
          const [v, I] = je(y.range());
          b = (I - v) / (_ === void 0 ? t === "x" ? 80 : 35 : _), u = y.ticks(b);
        }
      else
        u = y.domain();
      t === "y" || t === "x" ? f = [as(u)] : o[t] = { scale: t, value: ct };
    }
    s == null || s.call(this, y, u, b, o);
    const x = Object.fromEntries(
      Object.entries(o).map(([v, I]) => [v, { ...I, value: Ot(u, I.value) }])
    );
    return g && (f = m.filterFacets(u, x)), { data: u, facets: f, channels: x };
  }
  const c = vn(r).initializer, l = e(i, vn({ ...r, initializer: a }, c));
  return i == null ? (o = l.channels, l.channels = {}) : o = {}, l.ariaLabel = n, l;
}
function $T(e, t, n, i, r) {
  return { value: mp(e, t, n, i, r) };
}
function mp(e, t, n, i, r) {
  return i === void 0 && a_(e) ? NV(e, t, n, r) : e.tickFormat ? e.tickFormat(dr(n) ? null : n, i) : i === void 0 ? TV(e.interval) ? Au("%Y") : BV(e.interval) ? Cy("%Y") : Xr : typeof i == "string" ? (ri(e.domain()) ? Au : ef)(i) : ii(i);
}
const uq = {
  draw(e, t) {
    e.moveTo(0, 0), e.lineTo(0, t);
  }
}, fq = {
  draw(e, t) {
    e.moveTo(0, 0), e.lineTo(0, -t);
  }
}, hq = {
  draw(e, t) {
    e.moveTo(0, 0), e.lineTo(-t, 0);
  }
}, dq = {
  draw(e, t) {
    e.moveTo(0, 0), e.lineTo(t, 0);
  }
};
function TT(e) {
  return e.bandwidth && !e.interval ? void 0 : "tabular-nums";
}
function pq(e) {
  return Math.sign(Fc(e.domain())) * Math.sign(Fc(e.range()));
}
function BT(e, t, { anchor: n, label: i = t.label, labelAnchor: r, labelArrow: s } = {}) {
  if (!(i == null || i.inferred && yq(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 = pq(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 NT(e = "auto") {
  return ke(e) ? !1 : typeof e == "boolean" ? e : hr(e, "labelArrow", ["auto", "up", "right", "down", "left"]);
}
function yq(e) {
  return a_(e) || e.interval != null;
}
function Sx(e, t) {
  if (t == null)
    return t;
  const n = e(t);
  if (!n)
    throw new Error(`scale not found: ${t}`);
  return n;
}
function mq(e, { opacity: t, ...n } = {}) {
  if (!sa(e) && !A4(e))
    throw new Error(`swatches legend requires ordinal or threshold color scale (not ${e.type})`);
  return FT(
    e,
    n,
    (i, r, s, o) => i.append("svg").attr("width", s).attr("height", o).attr("fill", r.scale).attr("fill-opacity", Te(t)[1]).append("rect").attr("width", "100%").attr("height", "100%")
  );
}
function gq(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 : ke(t) ? "currentColor" : "none",
  strokeOpacity: r = 1,
  strokeWidth: s = 1.5,
  r: o = 4.5,
  ...a
} = {}, c) {
  const [f, h] = _n(t), [d, p] = _n(i), m = Sx(c, f), g = Sx(c, d), y = o * o * Math.PI;
  return n = Te(n)[1], r = Te(r)[1], s = Te(s)[1], FT(
    e,
    a,
    (b, _, w, x) => b.append("svg").attr("viewBox", "-8 -8 16 16").attr("width", w).attr("height", x).attr("fill", f === "color" ? (v) => m.scale(v) : h).attr("fill-opacity", n).attr("stroke", d === "color" ? (v) => g.scale(v) : p).attr("stroke-opacity", r).attr("stroke-width", s).append("path").attr("d", (v) => {
      const I = zr();
      return e.scale(v).draw(I, y), I;
    })
  );
}
function FT(e, t = {}, n) {
  let {
    columns: i,
    tickFormat: r,
    fontVariant: s = O4(e),
    // TODO label,
    swatchSize: o = 15,
    swatchWidth: a = o,
    swatchHeight: c = o,
    marginLeft: l = 0,
    className: u,
    style: f,
    width: h
  } = t;
  const d = t0(t);
  u = u_(u), typeof r != "function" && (r = mp(e.scale, e.domain, void 0, r));
  const p = Wt("div", d).attr(
    "class",
    `${u}-swatches ${u}-swatches-${i != null ? "columns" : "wrap"}`
  );
  let m;
  return i != null ? (m = `.${u}-swatches-columns .${u}-swatch {
  display: flex;
  align-items: center;
  break-inside: avoid;
  padding-bottom: 1px;
}
.${u}-swatches-columns .${u}-swatch::before {
  flex-shrink: 0;
}
.${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)
  )) : (m = `.${u}-swatches-wrap {
  display: flex;
  align-items: center;
  min-height: 33px;
  flex-wrap: wrap;
}
.${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(
      `.${u}-swatches {
  font-family: system-ui, sans-serif;
  font-size: 10px;
  margin-bottom: 0.5em;
}
.${u}-swatch > svg {
  margin-right: 0.5em;
  overflow: visible;
}
${m}`
    )
  ).style("margin-left", l ? `${+l}px` : null).style("width", h === void 0 ? null : `${+h}px`).style("font-variant", Ie(s, "normal")).call(f_, f).node();
}
const gp = /* @__PURE__ */ new Map([
  ["symbol", gq],
  ["color", DT],
  ["opacity", wq]
]);
function bq(e = {}) {
  for (const [t, n] of gp) {
    const i = e[t];
    if (Vo(i)) {
      const r = t0(e);
      let s;
      if (t === "symbol") {
        const { fill: o, stroke: a = o === void 0 && Vo(e.color) ? "color" : void 0 } = e;
        s = { fill: o, stroke: a };
      }
      return n(
        Xg(t, i, s),
        v_(r, i, e),
        (o) => Vo(e[o]) ? Xg(o, e[o]) : null
      );
    }
  }
  throw new Error("unknown legend type; no scale found");
}
function _q(e, t, n = {}) {
  return (i, r) => {
    if (!gp.has(i))
      throw new Error(`unknown legend type: ${i}`);
    if (i in e)
      return gp.get(i)(e[i], v_(t, n[i], r), (s) => e[s]);
  };
}
function v_({ className: e, ...t }, { label: n, ticks: i, tickFormat: r } = {}, s) {
  return YV(s, { className: e, ...t }, { label: n, ticks: i, tickFormat: r });
}
function DT(e, { legend: t = !0, ...n }) {
  if (t === !0 && (t = e.type === "ordinal" ? "swatches" : "ramp"), e.domain !== void 0)
    switch (`${t}`.toLowerCase()) {
      case "swatches":
        return mq(e, n);
      case "ramp":
        return UY(e, n);
      default:
        throw new Error(`unknown legend type: ${t}`);
    }
}
function wq({ type: e, interpolate: t, ...n }, { legend: i = !0, color: r = ei(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 DT({ type: e, ...n, interpolate: vq(r) }, { legend: i, ...s });
}
function vq(e) {
  const { r: t, g: n, b: i } = ei(e) || ei(0, 0, 0);
  return (r) => `rgba(${t},${n},${i},${r})`;
}
function xq(e, t, n) {
  const i = [];
  for (const [r, s] of gp) {
    const o = n[r];
    if (o != null && o.legend && r in e) {
      const a = s(e[r], v_(t, e[r], o), (c) => e[c]);
      a != null && i.push(a);
    }
  }
  return i;
}
const Sq = {
  ariaLabel: "frame",
  fill: "none",
  stroke: "currentColor"
}, Iq = {
  ariaLabel: "frame",
  fill: null,
  stroke: "currentColor",
  strokeLinecap: "square"
};
class ET extends ce {
  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(tu, void 0, t, n == null ? Sq : Iq), this.anchor = qy(n, "anchor", ["top", "right", "bottom", "left"]), this.insetTop = Ct(r), this.insetRight = Ct(s), this.insetBottom = Ct(o), this.insetLeft = Ct(a), this.rx = Ct(c), this.ry = Ct(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: m, insetLeft: g, rx: y, ry: b } = this, _ = l + g, w = u - a - p, x = o + d, v = f - c - m;
    return Wt(h ? "svg:line" : "svg:rect", s).datum(0).call(ye, this, r, s).call(pe, this).call(Le, this, i).call(ae, this, {}).call(
      h === "left" ? (I) => I.attr("x1", _).attr("x2", _).attr("y1", x).attr("y2", v) : h === "right" ? (I) => I.attr("x1", w).attr("x2", w).attr("y1", x).attr("y2", v) : h === "top" ? (I) => I.attr("x1", _).attr("x2", w).attr("y1", x).attr("y2", x) : h === "bottom" ? (I) => I.attr("x1", _).attr("x2", w).attr("y1", v).attr("y2", v) : (I) => I.attr("x", _).attr("y", x).attr("width", w - _).attr("height", v - x).attr("rx", y).attr("ry", b)
    ).node();
  }
}
function x_(e) {
  return new ET(e);
}
const wm = {
  ariaLabel: "tip",
  fill: "white",
  stroke: "currentColor"
}, Aq = /* @__PURE__ */ new Set(["geometry", "href", "src", "ariaLabel"]);
class OT extends ce {
  constructor(t, n = {}) {
    n.tip && (n = { ...n, tip: !1 }), n.title === void 0 && dr(t) && G$(t) && (n = { ...n, title: ct });
    const {
      x: i,
      y: r,
      x1: s,
      x2: o,
      y1: a,
      y2: c,
      anchor: l,
      monospace: u,
      fontFamily: f = u ? "ui-monospace, monospace" : void 0,
      fontSize: h,
      fontStyle: d,
      fontVariant: p,
      fontWeight: m,
      lineHeight: g = 1,
      lineWidth: y = 20,
      frameAnchor: b,
      textAnchor: _ = "start",
      textOverflow: w,
      textPadding: x = 8,
      title: v,
      pointerSize: I = 12,
      pathFilter: T = "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: v, optional: !0 }
        // filter: defined
      },
      n,
      wm
    ), this.anchor = H$(l, "anchor"), this.previousAnchor = this.anchor ?? "top-left", this.frameAnchor = ff(b), this.textAnchor = Ie(_, "middle"), this.textPadding = +x, this.pointerSize = +I, this.pathFilter = He(T), this.lineHeight = +g, this.lineWidth = +y, this.textOverflow = K4(w), this.monospace = !!u, this.fontFamily = He(f), this.fontSize = Ct(h), this.fontStyle = He(d), this.fontVariant = He(p), this.fontWeight = He(m);
    for (const F in wm)
      F in this.channels && (this[F] = wm[F]);
    this.splitLines = tT(this), this.clipLine = eT(this);
  }
  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: m, lineWidth: g } = this, { textPadding: y, pointerSize: b, pathFilter: _ } = this, { marginTop: w, marginLeft: x } = r, v = Bq(i), { x1: I, y1: T, x2: F, y2: A, x: $ = I ?? F, y: D = T ?? A } = i, O = l ? l(t.fx) - x : 0, S = u ? u(t.fy) - w : 0, [M, B] = yr(this, r), N = D4(i, M), L = E4(i, B), k = p ? b_ : g_, U = k(Qa), V = l && mp(l), j = u && mp(u);
    function* X(W, H) {
      if ("title" in W) {
        const P = W.title.value[H];
        for (const K of o.splitLines(Xr(P)))
          yield { name: "", value: o.clipLine(K) };
        return;
      }
      for (const P in W) {
        if (P === "x1" && "x2" in W || P === "y1" && "y2" in W)
          continue;
        const K = W[P], Z = K.value[H];
        if (!(!cn(Z) && K.scale == null))
          if (P === "x2" && "x1" in W)
            yield { name: vm(n, K, "x"), value: Ix(W.x1, K, H) };
          else if (P === "y2" && "y1" in W)
            yield { name: vm(n, K, "y"), value: Ix(W.y1, K, H) };
          else {
            const z = K.scale, tt = { name: vm(n, K, P), value: Xr(Z) };
            (z === "color" || z === "opacity") && (tt[z] = i[P][H]), yield tt;
          }
      }
      t.fi != null && l && (yield { name: String(l.label ?? "fx"), value: V(t.fx) }), t.fi != null && u && (yield { name: String(u.label ?? "fy"), value: j(t.fy) });
    }
    const J = Wt("svg:g", s).call(ye, this, r, s).call(Q4, this).call(ae, this, { x: $ && a, y: D && c }).call(
      (W) => W.selectAll().data(t).enter().append("g").attr("transform", (H) => `translate(${Math.round(N(H))},${Math.round(L(H))})`).call(pe, this).call((H) => H.append("path").attr("filter", _)).call(
        (H) => H.append("text").each(function(P) {
          const K = re(this);
          this.setAttribute("fill", "currentColor"), this.setAttribute("fill-opacity", 1), this.setAttribute("stroke", "none");
          const Z = /* @__PURE__ */ new Set();
          for (const z of X(v, P)) {
            const tt = z.name;
            tt && Z.has(tt) || (Z.add(tt), rt(K, z));
          }
        })
      )
    );
    function rt(W, { name: H, value: P, color: K, opacity: Z }) {
      const z = K != null || Z != null;
      let tt, lt = g * 100;
      const [zt] = Ec(H, lt, k, U);
      if (zt >= 0)
        H = H.slice(0, zt).trimEnd() + Qa, tt = P.trim(), P = "";
      else {
        (H || !P && !z) && (P = " " + P);
        const [Q] = Ec(P, lt - k(H), k, U);
        Q >= 0 && (P = P.slice(0, Q).trimEnd() + Qa, tt = P.trim());
      }
      const Dt = W.append("tspan").attr("x", 0).attr("dy", `${m}em`).text("​");
      H && Dt.append("tspan").attr("font-weight", "bold").text(H), P && Dt.append(() => h.createTextNode(P)), z && Dt.append("tspan").text(" ■").attr("fill", K).attr("fill-opacity", Z).style("user-select", "none"), tt && Dt.append("title").text(tt);
    }
    function Gt() {
      const { width: W, height: H } = r.facet ?? r;
      J.selectChildren().each(function(P) {
        let { x: K, width: Z, height: z } = this.getBBox();
        Z = Math.round(Z), z = Math.round(z);
        let tt = d;
        if (tt === void 0) {
          tt = o.previousAnchor;
          const Dt = N(P) + O, Q = L(P) + S, ee = Dt + Z + y * 2 < W, Oi = Dt - Z - y * 2 > 0, Mn = Q + z + b + y * 2 + 7 < H, Bf = Q - z - b - y * 2 > 0, Nf = (/-left$/.test(tt) ? ee || !Oi : ee && !Oi) ? "left" : "right", S0 = (/^top-/.test(tt) ? Mn || !Bf : Mn && !Bf) ? "top" : "bottom";
          tt = o.previousAnchor = `${S0}-${Nf}`;
        }
        const lt = this.firstChild, zt = this.lastChild;
        if (lt.setAttribute("d", Tq(tt, b, y, Z, z)), K)
          for (const Dt of zt.childNodes)
            Dt.setAttribute("x", -K);
        zt.setAttribute("y", `${+Mq(tt, zt.childNodes.length, m).toFixed(6)}em`), zt.setAttribute("transform", `translate(${$q(tt, b, y, Z, z)})`);
      });
    }
    return f.isConnected ? Promise.resolve().then(Gt) : typeof requestAnimationFrame < "u" && requestAnimationFrame(Gt), J.node();
  }
}
function LT(e, { x: t, y: n, ...i } = {}) {
  return i.frameAnchor === void 0 && ([t, n] = Di(t, n)), new OT(e, { ...i, x: t, y: n });
}
function Mq(e, t, n) {
  return /^top(?:-|$)/.test(e) ? 0.94 - n : -0.29 - t * n;
}
function $q(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 Tq(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 Bq({ channels: e }) {
  const t = {};
  for (const n in e) {
    if (Aq.has(n))
      continue;
    const i = s4(e, n);
    i && (t[n] = i);
  }
  return t;
}
function Ix(e, t, n) {
  var i;
  return (i = t.hint) != null && i.length ? `${Xr(t.value[n] - e.value[n])}` : `${Xr(e.value[n])}–${Xr(t.value[n])}`;
}
function vm(e, t, n) {
  var i;
  return String(((i = e[t.scale]) == null ? void 0 : i.label) ?? (t == null ? void 0 : t.label) ?? n);
}
function S_(e = {}) {
  var B;
  const { facet: t, style: n, caption: i, ariaLabel: r, ariaDescription: s } = e, o = u_(e.className), a = e.marks === void 0 ? [] : Ax(e.marks);
  a.push(...Rq(a));
  const c = Oq(t, e), l = /* @__PURE__ */ new Map();
  for (const N of a) {
    const L = Mx(N, c, e);
    L && l.set(N, L);
  }
  const u = /* @__PURE__ */ new Map();
  c && Sl(u, [c], e), Sl(u, l, e);
  const f = Ax(Cq(a, u, e));
  for (const N of f) {
    const L = Mx(N, c, e);
    L && l.set(N, L);
  }
  a.unshift(...f);
  let h = AY(u, e);
  if (h !== void 0) {
    const N = c ? bm(h, c) : void 0;
    for (const k of a) {
      if (k.facet === null || k.facet === "super")
        continue;
      const U = l.get(k);
      U !== void 0 && (U.facetsIndex = k.fx != null || k.fy != null ? bm(h, U) : N);
    }
    const L = /* @__PURE__ */ new Set();
    for (const { facetsIndex: k } of l.values())
      k == null || k.forEach((U, V) => {
        (U == null ? void 0 : U.length) > 0 && L.add(V);
      });
    h.forEach(
      0 < L.size && L.size < h.length ? (k, U) => k.empty = !L.has(U) : (k) => k.empty = !1
    );
    for (const k of a)
      if (k.facet === "exclude") {
        const U = l.get(k);
        U !== void 0 && (U.facetsIndex = TY(U.facetsIndex));
      }
  }
  for (const N of ve.keys())
    Vo(e[N]) && N !== "fx" && N !== "fy" && u.set(N, []);
  const d = /* @__PURE__ */ new Map();
  for (const N of a) {
    if (d.has(N))
      throw new Error("duplicate mark; each mark must be unique");
    const { facetsIndex: L, channels: k } = l.get(N) ?? {}, { data: U, facets: V, channels: j } = N.initialize(L, k, e);
    I_(j, e), d.set(N, { data: U, facets: V, channels: j });
  }
  const p = Gg(Sl(u, d, e), e), m = lx(p), g = SY(p, a, e);
  Qj(p, g);
  const { fx: y, fy: b } = m, _ = y || b ? v4(p, g) : g, w = y || b ? Yq(m, g) : g, x = t0(e), v = x.document, I = by("svg").call(v.documentElement);
  let T = I;
  x.ownerSVGElement = I, x.className = o, x.projection = dj(e, _), x.filterFacets = (N, L) => bm(h, { channels: L, groups: h_(N, L) }), x.getMarkState = (N) => {
    const L = d.get(N), k = l.get(N);
    return { ...L, channels: { ...L.channels, ...k == null ? void 0 : k.channels } };
  }, x.dispatchValue = (N) => {
    T.value !== N && (T.value = N, T.dispatchEvent(new Event("input", { bubbles: !0 })));
  };
  const F = /* @__PURE__ */ new Set();
  for (const [N, L] of d)
    if (N.initializer != null) {
      const k = N.facet === "super" ? w : _, U = N.initializer(L.data, L.facets, L.channels, m, k, x);
      if (U.data !== void 0 && (L.data = U.data), U.facets !== void 0 && (L.facets = U.facets), U.channels !== void 0) {
        const { fx: V, fy: j, ...X } = U.channels;
        Eq(X), Object.assign(L.channels, X);
        for (const J of Object.values(X)) {
          const { scale: rt } = J;
          rt != null && ve.get(rt) !== Qi && (RT(J, e), F.add(rt));
        }
        (V != null || j != null) && l.set(N, !0);
      }
    }
  if (F.size) {
    const N = /* @__PURE__ */ new Map();
    Sl(N, d, e, (U) => F.has(U)), Sl(u, d, e, (U) => F.has(U));
    const L = jq(Gg(N, e), p), k = lx(L);
    Object.assign(p, L), Object.assign(m, k);
  }
  let A, $;
  h !== void 0 && (A = { x: y == null ? void 0 : y.domain(), y: b == null ? void 0 : b.domain() }, h = MY(h, A), $ = $Y(y, b, g));
  for (const [N, L] of d)
    L.values = N.scale(L.channels, m, x);
  const { width: D, height: O } = g;
  re(I).attr("class", o).attr("fill", "currentColor").attr("font-family", "system-ui, sans-serif").attr("font-size", 10).attr("text-anchor", "middle").attr("width", D).attr("height", O).attr("viewBox", `0 0 ${D} ${O}`).attr("aria-label", r).attr("aria-description", s).call(
    (N) => (
      // Warning: if you edit this, change defaultClassName.
      N.append("style").text(
        `.${o} {
  display: block;
  background: white;
  height: auto;
  height: intrinsic;
  max-width: 100%;
}
.${o} text,
.${o} tspan {
  white-space: pre;
}`
      )
    )
  ).call(f_, n);
  for (const N of a) {
    const { channels: L, values: k, facets: U } = d.get(N);
    if (h === void 0 || N.facet === "super") {
      let V = null;
      if (U && (V = U[0], V = N.filter(V, L, k), V.length === 0))
        continue;
      const j = N.render(V, m, k, w, x);
      if (j == null)
        continue;
      I.appendChild(j);
    } else {
      let V;
      for (const j of h) {
        if (!(((B = N.facetAnchor) == null ? void 0 : B.call(N, h, A, j)) ?? !j.empty))
          continue;
        let X = null;
        if (U) {
          const rt = l.has(N);
          if (X = U[rt ? j.i : 0], X = N.filter(X, L, k), X.length === 0)
            continue;
          !rt && X === U[0] && (X = jo(X)), X.fx = j.x, X.fy = j.y, X.fi = j.i;
        }
        const J = N.render(X, m, k, _, x);
        if (J != null) {
          (V ?? (V = re(I).append("g"))).append(() => J).datum(j);
          for (const rt of ["aria-label", "aria-description", "aria-hidden", "transform"])
            J.hasAttribute(rt) && (V.attr(rt, J.getAttribute(rt)), J.removeAttribute(rt));
        }
      }
      V == null || V.selectChildren().attr("transform", $);
    }
  }
  const S = xq(p, x, e);
  if (i != null || S.length > 0) {
    T = v.createElement("figure"), T.style.maxWidth = "initial";
    for (const N of S)
      T.appendChild(N);
    if (T.appendChild(I), i != null) {
      const N = v.createElement("figcaption");
      N.appendChild(i != null && i.ownerDocument ? i : v.createTextNode(i)), T.appendChild(N);
    }
  }
  T.scale = sY(p), T.legend = _q(p, x, e);
  const M = hj();
  return M > 0 && re(I).append("text").attr("x", D).attr("y", 20).attr("dy", "-1em").attr("text-anchor", "end").attr("font-family", "initial").text("⚠️").append("title").text(`${M.toLocaleString("en-US")} warning${M === 1 ? "" : "s"}. Please check the console.`), T;
}
function Nq({ marks: e = [], ...t } = {}) {
  return S_({ ...t, marks: [...e, this] });
}
ce.prototype.plot = Nq;
function Ax(e) {
  return e.flat(1 / 0).filter((t) => t != null).map(Fq);
}
function Fq(e) {
  return typeof e.render == "function" ? e : new Dq(e);
}
class Dq extends ce {
  constructor(t) {
    if (typeof t != "function")
      throw new TypeError("invalid mark; missing render function");
    super(), this.render = t;
  }
  render() {
  }
}
function I_(e, t) {
  for (const n in e)
    RT(e[n], t);
  return e;
}
function RT(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 : W$(o, r)
  } = t[n] ?? {};
  a != null && (e.value = he(e.value, a), e.transform = !1);
}
function Eq(e) {
  for (const t in e)
    n4(t, e[t]);
}
function Sl(e, t, n, i = OV) {
  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 (!mj(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] = bj(c);
              u && xm(e, "x", h), f && xm(e, "y", d);
            }
          }
        } else
          xm(e, l, c);
    }
  return e;
}
function xm(e, t, n) {
  const i = e.get(t);
  i !== void 0 ? i.push(n) : e.set(t, [n]);
}
function Oq(e, t) {
  if (e == null)
    return;
  const { x: n, y: i } = e;
  if (n == null && i == null)
    return;
  const r = wn(e.data);
  if (r == null)
    throw new Error("missing facet data");
  const s = {};
  n != null && (s.fx = Fu(r, { value: n, scale: "fx" })), i != null && (s.fy = Fu(r, { value: i, scale: "fy" })), I_(s, t);
  const o = h_(r, s);
  return { channels: s, groups: o, data: e.data };
}
function Mx(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 = wn(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 = Fu(l, { value: i, scale: "fx" })), r != null && (u.fy = Fu(l, { value: r, scale: "fy" })), I_(u, n), { channels: u, groups: h_(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 = wn(e.data)) == null ? void 0 : c.length) === a.length && Fs(
    `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 Lq(e, t = {}) {
  return vn({ ...t, x: null, y: null }, (n, i, r, s, o, a) => a.getMarkState(e));
}
function Rq(e) {
  const t = [];
  for (const n of e) {
    const i = n.tip;
    if (i) {
      const s = (i === "x" ? y_ : i === "y" ? m_ : p_)(Lq(n));
      s.title = null, t.push(LT(n.data, s));
    }
  }
  return t;
}
function Cq(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: m = c, grid: g = m === null ? null : l } = s,
    fx: { axis: y = f, grid: b = y === null ? null : h } = o,
    fy: { axis: _ = f, grid: w = _ === null ? null : h } = a
  } = n;
  (i || !Vo(r) && !$x("x", e)) && (d = p = null), (i || !Vo(s) && !$x("y", e)) && (m = g = null), t.has("fx") || (y = b = null), t.has("fy") || (_ = w = null), d === void 0 && (d = !ih(e, "x")), m === void 0 && (m = !ih(e, "y")), y === void 0 && (y = !ih(e, "fx")), _ === void 0 && (_ = !ih(e, "fy")), d === !0 && (d = "bottom"), m === !0 && (m = "left"), y === !0 && (y = d === "top" || d === null ? "bottom" : "top"), _ === !0 && (_ = m === "right" || m === null ? "left" : "right");
  const x = [];
  return nh(x, w, wT, a), eh(x, _, yT, "right", "left", u, a), nh(x, b, xT, o), eh(x, y, mT, "top", "bottom", u, o), nh(x, g, _T, s), eh(x, m, __, "left", "right", n, s), nh(x, p, vT, r), eh(x, d, w_, "bottom", "top", n, r), x;
}
function eh(e, t, n, i, r, s, o) {
  if (!t)
    return;
  const a = kq(t);
  o = Uq(a ? i : t, s, o);
  const { line: c } = o;
  (n === __ || n === w_) && c && !Nc(c) && e.push(x_(zq(o))), e.push(n(o)), a && e.push(n({ ...o, anchor: r, label: null }));
}
function nh(e, t, n, i) {
  !t || Nc(t) || e.push(n(Pq(t, i)));
}
function kq(e) {
  return /^\s*both\s*$/i.test(e);
}
function Uq(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: m
}) {
  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: m
  };
}
function zq(e) {
  const { anchor: t, line: n } = e;
  return { anchor: t, facetAnchor: t + "-empty", stroke: n === !0 ? void 0 : n };
}
function Pq(e, {
  stroke: t = uf(e) ? e : void 0,
  ticks: n = Vq(e) ? e : void 0,
  tickSpacing: i,
  ariaLabel: r,
  ariaDescription: s
}) {
  return {
    stroke: t,
    ticks: n,
    tickSpacing: i,
    ariaLabel: r,
    ariaDescription: s
  };
}
function Vq(e) {
  switch (typeof e) {
    case "number":
      return !0;
    case "string":
      return !uf(e);
  }
  return dr(e) || typeof (e == null ? void 0 : e.range) == "function";
}
function ih(e, t) {
  const n = `${t}-axis `;
  return e.some((i) => {
    var r;
    return (r = i.ariaLabel) == null ? void 0 : r.startsWith(n);
  });
}
function $x(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 jq(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 Yq({ fx: e, fy: t }, n) {
  const { marginTop: i, marginRight: r, marginBottom: s, marginLeft: o, width: a, height: c } = o_(n), l = e && Tx(e), u = t && Tx(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 Tx(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 qq = /* @__PURE__ */ new Map([
  ["basis", QP],
  ["basis-closed", tV],
  ["basis-open", eV],
  ["bundle", nV],
  ["bump-x", VP],
  ["bump-y", jP],
  ["cardinal", iV],
  ["cardinal-closed", rV],
  ["cardinal-open", sV],
  ["catmull-rom", oV],
  ["catmull-rom-closed", aV],
  ["catmull-rom-open", cV],
  ["linear", af],
  ["linear-closed", lV],
  ["monotone-x", uV],
  ["monotone-y", fV],
  ["natural", hV],
  ["step", dV],
  ["step-after", yV],
  ["step-before", pV]
]);
function A_(e = af, t) {
  if (typeof e == "function")
    return e;
  const n = qq.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 CT(e = Oc, t) {
  return typeof e != "function" && `${e}`.toLowerCase() === "auto" ? Oc : A_(e, t);
}
function Oc(e) {
  return af(e);
}
function Is(e = { y: "count" }, t = {}) {
  [e, t] = B_(e, t);
  const { x: n, y: i } = t;
  return T_(bp(n, t, ct), null, null, i, e, yf(t));
}
function As(e = { x: "count" }, t = {}) {
  [e, t] = B_(e, t);
  const { x: n, y: i } = t;
  return T_(null, bp(i, t, ct), n, null, e, mf(t));
}
function To(e = { fill: "count" }, t = {}) {
  [e, t] = B_(e, t);
  const { x: n, y: i } = Wq(t);
  return T_(n, i, null, null, e, yf(mf(t)));
}
function kT(e, t, n = {}) {
  return (n == null ? void 0 : n.interval) == null ? n : e({ [t]: (n == null ? void 0 : n.reduce) === void 0 ? e_ : n.reduce, filter: null }, n);
}
function M_(e = {}) {
  return kT(Is, "y", Qc(e, "x"));
}
function $_(e = {}) {
  return kT(As, "x", Qc(e, "y"));
}
function T_(e, t, n, i, {
  data: r = t_,
  // TODO avoid materializing when unused?
  filter: s = dp,
  // return only non-empty bins by default
  sort: o,
  reverse: a,
  ...c
  // output channel definitions
} = {}, l = {}) {
  e = Bx(e), t = Bx(t), c = Gq(c, l), r = VT(r, ct), o = o == null ? void 0 : zT("sort", o, l), s = s == null ? void 0 : PT("filter", s, l), n != null && $s(c, "x", "x1", "x2") && (n = null), i != null && $s(c, "y", "y1", "y2") && (i = null);
  const [u, f] = un(e), [h, d] = un(e), [p, m] = un(t), [g, y] = un(t), [b, _] = n != null ? [n, "x"] : i != null ? [i, "y"] : [], [w, x] = un(b), {
    x: v,
    y: I,
    z: T,
    fill: F,
    stroke: A,
    x1: $,
    x2: D,
    // consumed if x is an output
    y1: O,
    y2: S,
    // consumed if y is an output
    domain: M,
    cumulative: B,
    thresholds: N,
    interval: L,
    ...k
  } = l, [U, V] = un(T), [j] = _n(F), [X] = _n(A), [J, rt] = un(j), [Gt, W] = un(X);
  return {
    ..."z" in l && { z: U || T },
    ..."fill" in l && { fill: J || F },
    ..."stroke" in l && { stroke: Gt || A },
    ...pr(k, (H, P, K) => {
      const Z = hp(Ot(H, b), K == null ? void 0 : K[_]), z = Ot(H, T), tt = Ot(H, j), lt = Ot(H, X), zt = Qb(c, { z, fill: tt, stroke: lt }), Dt = [], Q = [], ee = Z && x([]), Oi = z && V([]), Mn = tt && rt([]), Bf = lt && W([]), Nf = e && f([]), S0 = e && d([]), Nw = t && m([]), yF = t && y([]), mF = Zq(e == null ? void 0 : e(H), t == null ? void 0 : t(H));
      let gF = 0;
      for (const aa of c)
        aa.initialize(H);
      o && o.initialize(H), s && s.initialize(H);
      for (const aa of P) {
        const Fw = [];
        for (const fl of c)
          fl.scope("facet", aa);
        o && o.scope("facet", aa), s && s.scope("facet", aa);
        for (const [fl, bF] of Ja(aa, zt))
          for (const [_F, wF] of Ja(bF, Z))
            for (const [lo, uo] of mF(wF))
              if (!(s && !s.reduce(lo, uo))) {
                Fw.push(gF++), Q.push(r.reduceIndex(lo, H, uo)), Z && ee.push(_F), z && Oi.push(zt === z ? fl : z[lo[0]]), tt && Mn.push(zt === tt ? fl : tt[lo[0]]), lt && Bf.push(zt === lt ? fl : lt[lo[0]]), Nf && (Nf.push(uo.x1), S0.push(uo.x2)), Nw && (Nw.push(uo.y1), yF.push(uo.y2));
                for (const vF of c)
                  vF.reduce(lo, uo);
                o && o.reduce(lo);
              }
        Dt.push(Fw);
      }
      return t4(Dt, o, a), { data: Q, facets: Dt };
    }),
    ...!$s(c, "x") && (u ? { x1: u, x2: h, x: fp(u, h) } : { x: v, x1: $, x2: D }),
    ...!$s(c, "y") && (p ? { y1: p, y2: g, y: fp(p, g) } : { y: I, y1: O, y2: S }),
    ...w && { [_]: w },
    ...Object.fromEntries(c.map(({ name: H, output: P }) => [H, P]))
  };
}
function B_({ cumulative: e, domain: t, thresholds: n, interval: i, ...r }, s) {
  return [r, { cumulative: e, domain: t, thresholds: n, interval: i, ...s }];
}
function bp(e, { cumulative: t, domain: n, thresholds: i, interval: r }, s) {
  return e = { ...lf(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 = UT(e.thresholds, e.interval), e;
}
function Wq(e) {
  let { x: t, y: n } = e;
  return t = bp(t, e), n = bp(n, e), [t.value, n.value] = Di(t.value, n.value), { x: t, y: n };
}
function Bx(e) {
  if (e == null)
    return;
  const { value: t, cumulative: n, domain: i = je, thresholds: r } = e, s = (o) => {
    let a = Ot(o, t), c;
    if (ri(a) || Hq(r)) {
      a = he(a, P$, Float64Array);
      let [u, f] = typeof i == "function" ? i(a) : i, h = typeof r == "function" && !ql(r) ? r(a, u, f) : r;
      typeof h == "number" && (h = jM(u, f, h)), ql(h) && (i === je && (u = h.floor(u), f = h.offset(h.floor(f))), h = h.range(u, h.offset(f))), c = h;
    } else {
      a = pn(a);
      let [u, f] = typeof i == "function" ? i(a) : i, h = typeof r == "function" && !ql(r) ? r(a, u, f) : r;
      if (typeof h == "number")
        if (i === je) {
          let d = mu(u, f, h);
          if (isFinite(d))
            if (d > 0) {
              let p = Math.round(u / d), m = Math.round(f / d);
              p * d <= u || --p, m * d > f || ++m;
              let g = m - p + 1;
              h = new Float64Array(g);
              for (let y = 0; y < g; ++y)
                h[y] = (p + y) * d;
            } else if (d < 0) {
              d = -d;
              let p = Math.round(u * d), m = Math.round(f * d);
              p / d <= u || --p, m / d > f || ++m;
              let g = m - p + 1;
              h = new Float64Array(g);
              for (let y = 0; y < g; ++y)
                h[y] = (p + y) / d;
            } else
              h = [u];
          else
            h = [u];
        } else
          h = ks(u, f, h);
      else
        ql(h) && (i === je && (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 ? Qq : n > 0 ? Jq : N_)(l, c, a), l;
  };
  return s.label = cs(t), s;
}
function UT(e, t, n = Nx) {
  if (e === void 0)
    return t === void 0 ? n : Jc(t);
  if (typeof e == "string") {
    switch (e.toLowerCase()) {
      case "freedman-diaconis":
        return BL;
      case "scott":
        return W3;
      case "sturges":
        return nb;
      case "auto":
        return Nx;
    }
    return U$(e);
  }
  return e;
}
function Gq(e, t) {
  return Kb(e, t, zT);
}
function zT(e, t, n) {
  return Zb(e, t, n, PT);
}
function PT(e, t, n) {
  return Jb(e, t, n, VT);
}
function VT(e, t) {
  return Qy(e, t, Xq);
}
function Xq(e) {
  switch (`${e}`.toLowerCase()) {
    case "x":
      return tW;
    case "x1":
      return nW;
    case "x2":
      return iW;
    case "y":
      return eW;
    case "y1":
      return rW;
    case "y2":
      return sW;
  }
  throw new Error(`invalid bin reduce: ${e}`);
}
function Nx(e, t, n) {
  return Math.min(200, W3(e, t, n));
}
function Hq(e) {
  return Kq(e) || dr(e) && ri(e);
}
function Kq(e) {
  return ql(e) && typeof e == "function" && e() instanceof Date;
}
function ql(e) {
  return typeof (e == null ? void 0 : e.range) == "function";
}
function Zq(e, t) {
  return e && t ? function* (n) {
    const i = e.bin(n);
    for (const [r, [s, o]] of e.entries()) {
      const a = t.bin(i[r]);
      for (const [c, [l, u]] of t.entries())
        yield [a[c], { x1: s, y1: l, x2: o, y2: u }];
    }
  } : e ? function* (n) {
    const i = e.bin(n);
    for (const [r, [s, o]] of e.entries())
      yield [i[r], { x1: s, x2: o }];
  } : function* (n) {
    const i = t.bin(n);
    for (const [r, [s, o]] of t.entries())
      yield [i[r], { y1: s, y2: o }];
  };
}
function N_(e, t, n) {
  return t = pn(t), (i) => {
    var s;
    const r = e.map(() => []);
    for (const o of i)
      (s = r[hy(t, n[o]) - 1]) == null || s.push(o);
    return r;
  };
}
function Jq(e, t, n) {
  const i = N_(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 Qq(e, t, n) {
  const i = N_(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 jT(e, t) {
  const n = (+e + +t) / 2;
  return e instanceof Date ? new Date(n) : n;
}
const tW = {
  reduceIndex(e, t, { x1: n, x2: i }) {
    return jT(n, i);
  }
}, eW = {
  reduceIndex(e, t, { y1: n, y2: i }) {
    return jT(n, i);
  }
}, nW = {
  reduceIndex(e, t, { x1: n }) {
    return n;
  }
}, iW = {
  reduceIndex(e, t, { x2: n }) {
    return n;
  }
}, rW = {
  reduceIndex(e, t, { y1: n }) {
    return n;
  }
}, sW = {
  reduceIndex(e, t, { y2: n }) {
    return n;
  }
};
function F_(e = {}) {
  return V$(e) ? e : { ...e, x: ct };
}
function D_(e = {}) {
  return j$(e) ? e : { ...e, y: ct };
}
function YT(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = il(e));
  const { y1: n, y: i = n, x: r, ...s } = t, [o, a, c, l] = rl(i, r, "y", "x", e, s);
  return { ...o, y1: n, y: a, x1: c, x2: l, x: fp(c, l) };
}
function oW(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = il(e));
  const { y1: n, y: i = n, x: r } = t, [s, o, a] = rl(i, r, "y", "x", e, t);
  return { ...s, y1: n, y: o, x: a };
}
function aW(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = il(e));
  const { y1: n, y: i = n, x: r } = t, [s, o, , a] = rl(i, r, "y", "x", e, t);
  return { ...s, y1: n, y: o, x: a };
}
function qT(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = il(e));
  const { x1: n, x: i = n, y: r, ...s } = t, [o, a, c, l] = rl(i, r, "x", "y", e, s);
  return { ...o, x1: n, x: a, y1: c, y2: l, y: fp(c, l) };
}
function cW(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = il(e));
  const { x1: n, x: i = n, y: r } = t, [s, o, a] = rl(i, r, "x", "y", e, t);
  return { ...s, x1: n, x: o, y: a };
}
function lW(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = il(e));
  const { x1: n, x: i = n, y: r } = t, [s, o, , a] = rl(i, r, "x", "y", e, t);
  return { ...s, x1: n, x: o, y: a };
}
function E_({ x: e, x1: t, x2: n, ...i } = {}) {
  return i = Qc(i, "y"), t === void 0 && n === void 0 ? YT({ x: e, ...i }) : ([t, n] = Y$(e, t, n), { ...i, x1: t, x2: n });
}
function O_({ y: e, y1: t, y2: n, ...i } = {}) {
  return i = Qc(i, "x"), t === void 0 && n === void 0 ? qT({ y: e, ...i }) : ([t, n] = Y$(e, t, n), { ...i, y1: t, y2: n });
}
function il(e) {
  const { offset: t, order: n, reverse: i, ...r } = e;
  return [{ offset: t, order: n, reverse: i }, r];
}
const uW = { length: !0 };
function rl(e, t = Lb, n, i, { offset: r, order: s, reverse: o }, a) {
  const c = no(a), [l, u] = un(e), [f, h] = Fn(t), [d, p] = Fn(t);
  return f.hint = d.hint = uW, r = fW(r), s = pW(s, r, i), [
    pr(a, (m, g, y) => {
      const b = e == null ? void 0 : u(hp(Ot(m, e), y == null ? void 0 : y[n])), _ = Ot(m, t, Float64Array), w = Ot(m, c), x = s && s(m, b, _, w), v = m.length, I = h(new Float64Array(v)), T = p(new Float64Array(v)), F = [];
      for (const A of g) {
        const $ = b ? Array.from(os(A, (D) => b[D]).values()) : [A];
        if (x)
          for (const D of $)
            D.sort(x);
        for (const D of $) {
          let O = 0, S = 0;
          o && D.reverse();
          for (const M of D) {
            const B = _[M];
            B < 0 ? O = T[M] = (I[M] = O) + B : B > 0 ? S = T[M] = (I[M] = S) + B : T[M] = I[M] = S;
          }
        }
        F.push($);
      }
      return r && r(F, I, T, w), { data: m, facets: g };
    }),
    l,
    f,
    d
  ];
}
function fW(e) {
  if (e != null) {
    if (typeof e == "function")
      return e;
    switch (`${e}`.toLowerCase()) {
      case "expand":
      case "normalize":
        return hW;
      case "center":
      case "silhouette":
        return dW;
      case "wiggle":
        return GT;
    }
    throw new Error(`unknown offset: ${e}`);
  }
}
function WT(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 hW(e, t, n) {
  for (const i of e)
    for (const r of i) {
      const [s, o] = WT(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 dW(e, t, n) {
  for (const i of e) {
    for (const r of i) {
      const [s, o] = WT(r, n);
      for (const a of r) {
        const c = (o + s) / 2;
        t[a] -= c, n[a] -= c;
      }
    }
    XT(i, t, n);
  }
  HT(e, t, n);
}
function GT(e, t, n, i) {
  for (const r of e) {
    const s = new Go();
    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], m = s.has(c) ? p - s.get(c) : 0;
        return s.set(c, p), m;
      }), f = [0, ...wL(u)];
      for (const d of a)
        t[d] += o, n[d] += o;
      const h = sr(l);
      h && (o -= sr(l, (d, p) => (u[p] / 2 + f[p]) * d) / h);
    }
    XT(r, t, n);
  }
  HT(e, t, n);
}
function XT(e, t, n) {
  const i = ze(e, (r) => ze(r, (s) => t[s]));
  for (const r of e)
    for (const s of r)
      t[s] -= i, n[s] -= i;
}
function HT(e, t, n) {
  const i = e.length;
  if (i === 1)
    return;
  const r = e.map((a) => a.flat()), s = r.map((a) => (ze(a, (c) => t[c]) + Se(a, (c) => n[c])) / 2), o = ze(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 pW(e, t, n) {
  if (e === void 0 && t === GT)
    return Fx(ni);
  if (e != null) {
    if (typeof e == "string") {
      const i = e.startsWith("-"), r = i ? lp : ni;
      switch ((i ? e.slice(1) : e).toLowerCase()) {
        case "value":
        case n:
          return yW(r);
        case "z":
          return mW(r);
        case "sum":
          return gW(r);
        case "appearance":
          return bW(r);
        case "inside-out":
          return Fx(r);
      }
      return Dx(z$(e));
    }
    if (typeof e == "function")
      return (e.length === 1 ? Dx : _W)(e);
    if (Array.isArray(e))
      return wW(e);
    throw new Error(`invalid order: ${e}`);
  }
}
function yW(e) {
  return (t, n, i) => (r, s) => e(i[r], i[s]);
}
function mW(e) {
  return (t, n, i, r) => (s, o) => e(r[s], r[o]);
}
function gW(e) {
  return u0(
    e,
    (t, n, i, r) => eb(
      as(t),
      (s) => sr(s, (o) => i[o]),
      (s) => r[s]
    )
  );
}
function bW(e) {
  return u0(
    e,
    (t, n, i, r) => eb(
      as(t),
      (s) => n[ib(s, (o) => i[o])],
      (s) => r[s]
    )
  );
}
function Fx(e) {
  return u0(e, (t, n, i, r) => {
    const s = as(t), o = eb(
      s,
      (f) => n[ib(f, (h) => i[h])],
      (f) => r[f]
    ), a = Xa(
      s,
      (f) => sr(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 Dx(e) {
  return (t) => {
    const n = Ot(t, e);
    return (i, r) => ni(n[i], n[r]);
  };
}
function _W(e) {
  return (t) => (n, i) => e(t[n], t[i]);
}
function wW(e) {
  return u0(ni, () => e);
}
function u0(e, t) {
  return (n, i, r, s) => {
    if (!s)
      throw new Error("missing channel: z");
    const o = new Go(t(n, i, r, s).map((a, c) => [a, c]));
    return (a, c) => e(o.get(s[a]), o.get(s[c]));
  };
}
const vW = {
  ariaLabel: "area",
  strokeWidth: 1,
  strokeLinecap: "round",
  strokeLinejoin: "round",
  strokeMiterlimit: 1
};
class f0 extends ce {
  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: no(n), optional: !0 }
      },
      n,
      vW
    ), this.z = a, this.curve = A_(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 Wt("svg:g", s).call(ye, this, r, s).call(ae, this, n, 0, 0).call(
      (u) => u.selectAll().data(B4(t, [o, a, c, l], this, i)).enter().append("path").call(pe, this).call(pp, this, i).attr(
        "d",
        Bb().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 xW(e, t) {
  return t === void 0 ? Eu(e, { x: cf, y: Tu }) : new f0(e, t);
}
function _p(e, t) {
  const { y: n = In, ...i } = $_(t);
  return new f0(e, E_(F_({ ...i, y1: n, y2: void 0 })));
}
function Eu(e, t) {
  const { x: n = In, ...i } = M_(t);
  return new f0(e, O_(D_({ ...i, x1: n, x2: void 0 })));
}
const SW = {
  ariaLabel: "link",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1
};
class KT extends ce {
  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,
      SW
    ), this.curve = CT(a, c), tl(this, n);
  }
  project(t, n, i) {
    this.curve !== Oc && 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 Wt("svg:g", s).call(ye, this, r, s).call(ae, this, n).call(
      (f) => f.selectAll().data(t).enter().append("path").call(pe, this).attr(
        "d",
        u === Oc && s.projection ? IW(s.projection, o, a, c, l) : (h) => {
          const d = zr(), p = u(d);
          return p.lineStart(), p.point(o[h], a[h]), p.point(c[h], l[h]), p.lineEnd(), d;
        }
      ).call(Le, this, i).call(pf, this, i, s)
    ).node();
  }
}
function IW(e, t, n, i, r) {
  const s = to(e);
  return t = pn(t), n = pn(n), i = pn(i), r = pn(r), (o) => s({
    type: "LineString",
    coordinates: [
      [t[o], n[o]],
      [i[o], r[o]]
    ]
  });
}
function ZT(e, { x: t, x1: n, x2: i, y: r, y1: s, y2: o, ...a } = {}) {
  return [n, i] = wp(t, n, i), [s, o] = wp(r, s, o), new KT(e, { ...a, x1: n, x2: i, y1: s, y2: o });
}
function wp(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 AW = {
  ariaLabel: "arrow",
  fill: "none",
  stroke: "currentColor",
  strokeLinecap: "round",
  strokeMiterlimit: 1,
  strokeWidth: 1.5
};
class JT extends ce {
  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
    } = 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,
      AW
    ), 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;
  }
  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: m, insetEnd: g } = this, y = u ? (x) => u[x] : ii(f === void 0 ? 1 : f), b = h * yp, _ = d * yp / 2, w = p / 1.5;
    return Wt("svg:g", s).call(ye, this, r, s).call(ae, this, n).call(
      (x) => x.selectAll().data(t).enter().append("path").call(pe, this).attr("d", (v) => {
        let I = o[v], T = a[v], F = c[v], A = l[v];
        const $ = Math.hypot(F - I, A - T);
        if ($ <= m + g)
          return null;
        let D = Math.atan2(A - T, F - I);
        const O = Math.min(w * y(v), $ / 3), S = Math.hypot($ / Math.tan(b), $) / 2;
        if (m || g)
          if (S < 1e5) {
            const j = Math.sign(b), [X, J] = MW([I, T], [F, A], S, j);
            if (m && ([I, T] = Ex([X, J, S], [I, T, m], -j * Math.sign(m))), g) {
              const [rt, Gt] = Ex([X, J, S], [F, A, g], j * Math.sign(g));
              D += Math.atan2(Gt - J, rt - X) - Math.atan2(A - J, F - X), F = rt, A = Gt;
            }
          } else {
            const j = F - I, X = A - T, J = Math.hypot(j, X);
            m && (I += j / J * m, T += X / J * m), g && (F -= j / J * g, A -= X / J * g);
          }
        const M = D + b, B = M + _, N = M - _, L = F - O * Math.cos(B), k = A - O * Math.sin(B), U = F - O * Math.cos(N), V = A - O * Math.sin(N);
        return `M${I},${T}${S < 1e5 ? `A${S},${S} 0,0,${b > 0 ? 1 : 0} ` : "L"}${F},${A}M${L},${k}L${F},${A}L${U},${V}`;
      }).call(Le, this, i)
    ).node();
  }
}
function MW([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 Ex([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 $W(e, { x: t, x1: n, x2: i, y: r, y1: s, y2: o, ...a } = {}) {
  return [n, i] = wp(t, n, i), [s, o] = wp(r, s, o), new JT(e, { ...a, x1: n, x2: i, y1: s, y2: o });
}
class L_ extends ce {
  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 = Ct(o), this.insetRight = Ct(a), this.insetBottom = Ct(c), this.insetLeft = Ct(l), this.rx = Ie(u, "auto"), this.ry = Ie(f, "auto");
  }
  render(t, n, i, r, s) {
    const { rx: o, ry: a } = this;
    return Wt("svg:g", s).call(ye, this, r, s).call(this._transform, this, n).call(
      (c) => c.selectAll().data(t).enter().append("rect").call(pe, 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(st, "rx", o).call(st, "ry", a).call(Le, 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 QT = {
  ariaLabel: "bar"
};
class t8 extends L_ {
  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,
      QT
    );
  }
  _transform(t, n, { x: i }) {
    t.call(ae, n, { x: i }, 0, 0);
  }
  _x({ x: t }, { x1: n, x2: i }, { marginLeft: r }) {
    const { insetLeft: s } = this;
    return Zn(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 Zn(t) ? o - r - s - a - c : (l) => Math.max(0, Math.abs(i[l] - n[l]) - a - c);
  }
}
class e8 extends L_ {
  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,
      QT
    );
  }
  _transform(t, n, { y: i }) {
    t.call(ae, n, { y: i }, 0, 0);
  }
  _y({ y: t }, { y1: n, y2: i }, { marginTop: r }) {
    const { insetTop: s } = this;
    return Zn(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 Zn(t) ? o - r - s - a - c : (l) => Math.max(0, Math.abs(i[l] - n[l]) - a - c);
  }
}
function tc(e, t = {}) {
  return Wy(t) || (t = { ...t, y: In, x2: ct }), new t8(e, E_(P4(F_(t))));
}
function ec(e, t = {}) {
  return Wy(t) || (t = { ...t, x: In, y2: ct }), new e8(e, O_(V4(D_(t))));
}
const TW = {
  ariaLabel: "cell"
};
class h0 extends L_ {
  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,
      TW
    );
  }
  _transform(t, n) {
    t.call(ae, n, {}, 0, 0);
  }
}
function vp(e, { x: t, y: n, ...i } = {}) {
  return [t, n] = Di(t, n), new h0(e, { ...i, x: t, y: n });
}
function BW(e, { x: t = In, fill: n, stroke: i, ...r } = {}) {
  return n === void 0 && _n(i)[0] === void 0 && (n = ct), new h0(e, { ...r, x: t, fill: n, stroke: i });
}
function NW(e, { y: t = In, fill: n, stroke: i, ...r } = {}) {
  return n === void 0 && _n(i)[0] === void 0 && (n = ct), new h0(e, { ...r, y: t, fill: n, stroke: i });
}
const FW = {
  ariaLabel: "dot",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1.5
};
function R_(e) {
  return e.sort === void 0 && e.reverse === void 0 ? J$({ channel: "-r" }, e) : e;
}
class d0 extends ce {
  constructor(t, n = {}) {
    const { x: i, y: r, r: s, rotate: o, symbol: a = Mu, frameAnchor: c } = n, [l, u] = Te(o, 0), [f, h] = HV(a), [d, p] = Te(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: Gr, optional: !0 },
        rotate: { value: l, optional: !0 },
        symbol: { value: f, scale: "auto", optional: !0 }
      },
      R_(n),
      FW
    ), this.r = p, this.rotate = u, this.symbol = h, this.frameAnchor = ff(c);
    const { channels: m } = this, { symbol: g } = m;
    if (g) {
      const { fill: y, stroke: b } = m;
      g.hint = {
        fill: y ? y.value === g.value ? "color" : "currentColor" : this.fill,
        stroke: b ? b.value === g.value ? "color" : "currentColor" : this.stroke
      };
    }
  }
  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: m } = this, [g, y] = yr(this, r), b = m === Mu, _ = u ? void 0 : d * d * Math.PI;
    return Yy(d) && (t = []), Wt("svg:g", s).call(ye, this, r, s).call(ae, this, { x: c && o, y: l && a }).call(
      (w) => w.selectAll().data(t).enter().append(b ? "circle" : "path").call(pe, this).call(
        b ? (x) => {
          x.attr("cx", c ? (v) => c[v] : g).attr("cy", l ? (v) => l[v] : y).attr("r", u ? (v) => u[v] : d);
        } : (x) => {
          x.attr(
            "transform",
            o0`translate(${c ? (v) => c[v] : g},${l ? (v) => l[v] : y})${f ? (v) => ` rotate(${f[v]})` : p ? ` rotate(${p})` : ""}`
          ).attr(
            "d",
            u && h ? (v) => {
              const I = zr();
              return h[v].draw(I, u[v] * u[v] * Math.PI), I;
            } : u ? (v) => {
              const I = zr();
              return m.draw(I, u[v] * u[v] * Math.PI), I;
            } : h ? (v) => {
              const I = zr();
              return h[v].draw(I, _), I;
            } : (() => {
              const v = zr();
              return m.draw(v, _), v;
            })()
          );
        }
      ).call(Le, this, i)
    ).node();
  }
}
function so(e, { x: t, y: n, ...i } = {}) {
  return i.frameAnchor === void 0 && ([t, n] = Di(t, n)), new d0(e, { ...i, x: t, y: n });
}
function DW(e, { x: t = ct, ...n } = {}) {
  return new d0(e, Y4({ ...n, x: t }));
}
function EW(e, { y: t = ct, ...n } = {}) {
  return new d0(e, j4({ ...n, y: t }));
}
function OW(e, t) {
  return so(e, { ...t, symbol: "circle" });
}
function LW(e, t) {
  return so(e, { ...t, symbol: "hexagon" });
}
const RW = {
  ariaLabel: "line",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1.5,
  strokeLinecap: "round",
  strokeLinejoin: "round",
  strokeMiterlimit: 1
};
class p0 extends ce {
  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: no(n), optional: !0 }
      },
      n,
      RW
    ), this.z = s, this.curve = CT(o, a), tl(this, n);
  }
  filter(t) {
    return t;
  }
  project(t, n, i) {
    this.curve !== Oc && super.project(t, n, i);
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = i, { curve: c } = this;
    return Wt("svg:g", s).call(ye, this, r, s).call(ae, this, n).call(
      (l) => l.selectAll().data(B4(t, [o, a], this, i)).enter().append("path").call(pe, this).call(pp, this, i).call(jY, this, i, s).attr(
        "d",
        c === Oc && s.projection ? CW(s.projection, o, a) : f$().curve(c).defined((u) => u >= 0).x((u) => o[u]).y((u) => a[u])
      )
    ).node();
  }
}
function CW(e, t, n) {
  const i = to(e);
  return t = pn(t), n = pn(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 C_(e, { x: t, y: n, ...i } = {}) {
  return [t, n] = Di(t, n), new p0(e, { ...i, x: t, y: n });
}
function xp(e, { x: t = ct, y: n = In, ...i } = {}) {
  return new p0(e, $_({ ...i, x: t, y: n }));
}
function Sp(e, { x: t = In, y: n = ct, ...i } = {}) {
  return new p0(e, M_({ ...i, x: t, y: n }));
}
const kW = {
  ariaLabel: "rect"
};
class y0 extends ce {
  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", optional: !0 },
        y1: { value: r, scale: "y", optional: !0 },
        x2: { value: s, scale: "x", optional: !0 },
        y2: { value: o, scale: "y", optional: !0 }
      },
      n,
      kW
    ), this.insetTop = Ct(c), this.insetRight = Ct(l), this.insetBottom = Ct(u), this.insetLeft = Ct(f), this.rx = Ie(h, "auto"), this.ry = Ie(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: m, width: g, height: y } = r, { projection: b } = s, { insetTop: _, insetRight: w, insetBottom: x, insetLeft: v, rx: I, ry: T } = this;
    return Wt("svg:g", s).call(ye, this, r, s).call(ae, this, { x: c && u && o, y: l && f && a }, 0, 0).call(
      (F) => F.selectAll().data(t).enter().append("rect").call(pe, this).attr(
        "x",
        c && u && (b || !Zn(o)) ? (A) => Math.min(c[A], u[A]) + v : m + v
      ).attr(
        "y",
        l && f && (b || !Zn(a)) ? (A) => Math.min(l[A], f[A]) + _ : h + _
      ).attr(
        "width",
        c && u && (b || !Zn(o)) ? (A) => Math.max(0, Math.abs(u[A] - c[A]) - v - w) : g - d - m - w - v
      ).attr(
        "height",
        l && f && (b || !Zn(a)) ? (A) => Math.max(0, Math.abs(l[A] - f[A]) - _ - x) : y - h - p - _ - x
      ).call(st, "rx", I).call(st, "ry", T).call(Le, this, i)
    ).node();
  }
}
function k_(e, t) {
  return new y0(e, U4(z4(t)));
}
function eu(e, t = {}) {
  return Wy(t) || (t = { ...t, y: In, x2: ct, interval: 1 }), new y0(e, E_(z4(F_(t))));
}
function nu(e, t = {}) {
  return Wy(t) || (t = { ...t, x: In, y2: ct, interval: 1 }), new y0(e, O_(U4(D_(t))));
}
function n8(e, t) {
  t = zW(t);
  const { x: n, y: i, color: r, size: s } = t, o = rh(e, n), a = rh(e, i), c = rh(e, r), l = rh(e, s);
  let {
    fx: u,
    fy: f,
    x: { value: h, reduce: d, zero: p, ...m },
    y: { value: g, reduce: y, zero: b, ..._ },
    color: { value: w, color: x, reduce: v },
    size: { value: I, reduce: T },
    // TODO constant radius?
    mark: F
  } = t;
  if (d === void 0 && (d = y == null && h == null && I == null && g != null ? "count" : null), y === void 0 && (y = d == null && g == null && I == null && h != null ? "count" : null), T === void 0 && I == null && v == null && d == null && y == null && (h == null || Qe(o)) && (g == null || Qe(a)) && (T = "count"), p === void 0 && (p = sh(d) ? !0 : void 0), b === void 0 && (b = sh(y) ? !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 (y != null && h == null)
    throw new Error("reducing y requires x");
  F === void 0 && (F = I != null || T != null ? "dot" : sh(d) || sh(y) || v != null ? "bar" : h != null && g != null ? Qe(o) || Qe(a) || d == null && y == null && !Il(o) && !Il(a) ? "dot" : "line" : h != null || g != null ? "rule" : null);
  let A, $, D;
  switch (F) {
    case "dot":
      D = so, $ = "stroke";
      break;
    case "line":
      D = o && a || d != null || y != null ? b || y != null || o && Il(o) ? Sp : p || d != null || a && Il(a) ? xp : C_ : o ? xp : Sp, $ = "stroke", Ox(c) && (A = null);
      break;
    case "area":
      D = !(b || y != null) && (p || d != null || a && Il(a)) ? _p : Eu, $ = "fill", Ox(c) && (A = null);
      break;
    case "rule":
      D = o ? Vs : js, $ = "stroke";
      break;
    case "bar":
      D = b ? ba(d, o) ? ec : nu : p ? ba(y, a) ? tc : eu : ba(d, o) && ba(y, a) ? vp : ba(d, o) ? ec : ba(y, a) ? tc : d != null ? eu : y != null ? nu : v != null ? k_ : vp, $ = "fill";
      break;
    default:
      throw new Error(`invalid mark: ${F}`);
  }
  let O = {
    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
    [$]: c ?? x,
    z: A,
    r: l ?? void 0,
    // treat null size as undefined for default constant radius
    tip: !0
  }, S, M = { [$]: v ?? void 0, r: T ?? void 0 };
  if (d != null && y != null)
    throw new Error("cannot reduce both x and y");
  return y != null ? (M.y = y, S = Qe(o) ? Bu : Is) : d != null ? (M.x = d, S = Qe(a) ? Nu : As) : (v != null || T != null) && (o && a ? S = Qe(o) && Qe(a) ? Hb : Qe(o) ? As : Qe(a) ? Is : To : o ? S = Qe(o) ? Bu : Is : a && (S = Qe(a) ? Nu : As)), (S === To || S === Is) && (O.x = { value: o, ...m }), (S === To || S === As) && (O.y = { value: a, ..._ }), p === void 0 && (p = o && !(S === To || S === Is) && (D === tc || D === _p || D === eu || D === js)), b === void 0 && (b = a && !(S === To || S === As) && (D === ec || D === Eu || D === nu || D === Vs)), {
    fx: u ?? null,
    fy: f ?? null,
    x: {
      value: h ?? null,
      reduce: d ?? null,
      zero: !!p,
      ...m
    },
    y: {
      value: g ?? null,
      reduce: y ?? null,
      zero: !!b,
      ..._
    },
    color: {
      value: w ?? null,
      reduce: v ?? null,
      ...x !== void 0 && { color: x }
    },
    size: {
      value: I ?? null,
      reduce: T ?? null
    },
    mark: F,
    markImpl: Lx[D],
    markOptions: O,
    transformImpl: Lx[S],
    transformOptions: M,
    colorMode: $
  };
}
function UW(e, t) {
  const n = n8(e, t), {
    fx: i,
    fy: r,
    x: { zero: s },
    y: { zero: o },
    markOptions: a,
    transformOptions: c,
    colorMode: l
  } = n, u = Zg[n.markImpl], f = Zg[n.transformImpl], h = i != null || r != null ? x_({ strokeOpacity: 0.1 }) : null, d = [s ? Vs([0]) : null, o ? js([0]) : null], p = u(e, f ? f(c, a) : a);
  return l === "stroke" ? es(h, d, p) : es(h, p, d);
}
function Il(e) {
  let t, n;
  for (const i of e) {
    if (i == null)
      continue;
    if (t === void 0) {
      t = i;
      continue;
    }
    const r = Math.sign(Be(t, i));
    if (r) {
      if (n !== void 0 && r !== n)
        return !1;
      t = i, n = r;
    }
  }
  return !0;
}
function zW({ x: e, y: t, color: n, size: i, fx: r, fy: s, mark: o } = {}) {
  return Pi(e) || (e = ga(e)), Pi(t) || (t = ga(t)), Pi(n) || (n = uf(n) ? { color: n } : ga(n)), Pi(i) || (i = ga(i)), Pi(r) && ({ value: r } = ga(r)), Pi(s) && ({ value: s } = ga(s)), o != null && (o = `${o}`.toLowerCase()), { x: e, y: t, color: n, size: i, fx: r, fy: s, mark: o };
}
function rh(e, t) {
  const n = Ot(e, t.value);
  return n && (n.label = cs(t.value)), n;
}
function ga(e) {
  return VW(e) ? { reduce: e } : { value: e };
}
function sh(e) {
  return /^(?:distinct|count|sum|proportion)$/i.test(e);
}
function PW(e) {
  return /^(?:first|last|mode)$/i.test(e);
}
function ba(e, t) {
  return e != null && !PW(e) || !t ? !1 : Qe(t);
}
function VW(e) {
  if (e == null)
    return !1;
  if (typeof e.reduceIndex == "function" || typeof e.reduce == "function" && Fi(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 Ox(e) {
  return e ? new yy(e).size > e.length >> 1 : !1;
}
const Zg = {
  dot: so,
  line: C_,
  lineX: xp,
  lineY: Sp,
  areaX: _p,
  areaY: Eu,
  ruleX: Vs,
  ruleY: js,
  barX: tc,
  barY: ec,
  rect: k_,
  rectX: eu,
  rectY: nu,
  cell: vp,
  bin: To,
  binX: Is,
  binY: As,
  group: Hb,
  groupX: Bu,
  groupY: Nu
}, Lx = Object.fromEntries(Object.entries(Zg).map(([e, t]) => [t, e]));
function U_(e, t = {}) {
  let { x: n, x1: i, x2: r } = t;
  n === void 0 && i === void 0 && r === void 0 && (t = { ...t, x: n = ct });
  const s = {};
  return n != null && (s.x = e), i != null && (s.x1 = e), r != null && (s.x2 = e), gf(s, t);
}
function z_(e, t = {}) {
  let { y: n, y1: i, y2: r } = t;
  n === void 0 && i === void 0 && r === void 0 && (t = { ...t, y: n = ct });
  const s = {};
  return n != null && (s.y = e), i != null && (s.y1 = e), r != null && (s.y2 = e), gf(s, t);
}
function gf(e = {}, t = {}) {
  const n = no(t), i = Object.entries(e).map(([r, s]) => {
    const o = q$(r, t);
    if (o == null)
      throw new Error(`missing channel: ${r}`);
    const [a, c] = Fn(o);
    return { key: r, input: o, output: a, setOutput: c, map: jW(s) };
  });
  return {
    ...pr(t, (r, s) => {
      const o = Ot(r, n), a = i.map(({ input: l }) => Ot(r, l)), c = i.map(({ setOutput: l }) => l(new Array(r.length)));
      for (const l of s)
        for (const u of o ? os(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 jW(e) {
  if (e == null)
    throw new Error("missing map");
  if (typeof e.mapIndex == "function")
    return e;
  if (typeof e.map == "function" && Fi(e))
    return YW(e);
  if (typeof e == "function")
    return Sm(Ub(e));
  switch (`${e}`.toLowerCase()) {
    case "cumsum":
      return WW;
    case "rank":
      return Sm((t, n) => H3(t, (i) => n[i]));
    case "quantile":
      return Sm((t, n) => qW(t, (i) => n[i]));
  }
  throw new Error(`invalid map: ${e}`);
}
function YW(e) {
  return console.warn("deprecated map interface; implement mapIndex instead."), { mapIndex: e.map.bind(e) };
}
function qW(e, t) {
  const n = dy(e, t) - 1;
  return H3(e, t).map((i) => i / n);
}
function Sm(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 WW = {
  mapIndex(e, t, n) {
    let i = 0;
    for (const r of e)
      n[r] = i += t[r];
  }
}, GW = {
  ariaLabel: "tick",
  fill: null,
  stroke: "currentColor"
};
class i8 extends ce {
  constructor(t, n, i) {
    super(t, n, i, GW), tl(this, i);
  }
  render(t, n, i, r, s) {
    return Wt("svg:g", s).call(ye, this, r, s).call(this._transform, this, n).call(
      (o) => o.selectAll().data(t).enter().append("line").call(pe, 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(Le, this, i).call(pf, this, i, s)
    ).node();
  }
}
class r8 extends i8 {
  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 = Ct(o), this.insetBottom = Ct(a);
  }
  _transform(t, n, { x: i }) {
    t.call(ae, n, { x: i }, Ye, 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 s8 extends i8 {
  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 = Ct(o), this.insetLeft = Ct(a);
  }
  _transform(t, n, { y: i }) {
    t.call(ae, n, { y: i }, 0, Ye);
  }
  _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 o8(e, { x: t = ct, ...n } = {}) {
  return new r8(e, { ...n, x: t });
}
function a8(e, { y: t = ct, ...n } = {}) {
  return new s8(e, { ...n, y: t });
}
function XW(e, {
  x: t = ct,
  y: n = null,
  fill: i = "#ccc",
  fillOpacity: r,
  stroke: s = "currentColor",
  strokeOpacity: o,
  strokeWidth: a = 2,
  sort: c,
  ...l
} = {}) {
  const u = n != null ? Nu : Xb;
  return es(
    js(e, u({ x1: P_, x2: V_ }, { x: t, y: n, stroke: s, strokeOpacity: o, ...l })),
    tc(e, u({ x1: "p25", x2: "p75" }, { x: t, y: n, fill: i, fillOpacity: r, ...l })),
    o8(e, u({ x: "p50" }, { x: t, y: n, stroke: s, strokeOpacity: o, strokeWidth: a, sort: c, ...l })),
    so(e, gf({ x: c8 }, { x: t, y: n, z: n, stroke: s, strokeOpacity: o, ...l }))
  );
}
function HW(e, {
  y: t = ct,
  x: n = null,
  fill: i = "#ccc",
  fillOpacity: r,
  stroke: s = "currentColor",
  strokeOpacity: o,
  strokeWidth: a = 2,
  sort: c,
  ...l
} = {}) {
  const u = n != null ? Bu : Xb;
  return es(
    Vs(e, u({ y1: P_, y2: V_ }, { x: n, y: t, stroke: s, strokeOpacity: o, ...l })),
    ec(e, u({ y1: "p25", y2: "p75" }, { x: n, y: t, fill: i, fillOpacity: r, ...l })),
    a8(e, u({ y: "p50" }, { x: n, y: t, stroke: s, strokeOpacity: o, strokeWidth: a, sort: c, ...l })),
    so(e, gf({ y: c8 }, { x: n, y: t, z: n, stroke: s, strokeOpacity: o, ...l }))
  );
}
function c8(e) {
  const t = P_(e), n = V_(e);
  return e.map((i) => i < t || i > n ? i : NaN);
}
function P_(e) {
  const t = l8(e) * 2.5 - u8(e) * 1.5;
  return ze(e, (n) => n >= t ? n : NaN);
}
function V_(e) {
  const t = u8(e) * 2.5 - l8(e) * 1.5;
  return Se(e, (n) => n <= t ? n : NaN);
}
function l8(e) {
  return Us(e, 0.25);
}
function u8(e) {
  return Us(e, 0.75);
}
const KW = {
  ariaLabel: "raster",
  stroke: null,
  pixelSize: 1
};
function _a(e, t) {
  const n = +e;
  if (isNaN(n))
    throw new Error(`invalid ${t}: ${e}`);
  return n;
}
function Rx(e, t) {
  const n = Math.floor(e);
  if (isNaN(n))
    throw new Error(`invalid ${t}: ${e}`);
  return n;
}
class f8 extends ce {
  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: m
    } = i;
    if (s != null && (s = Rx(s, "width")), o != null && (o = Rx(o, "height")), l != null && (l = _a(l, "x1")), u != null && (u = _a(u, "y1")), f != null && (f = _a(f, "x2")), h != null && (h = _a(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 = sG(l, f, s)), c === void 0 && u != null && h != null && (c = oG(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 = _a(d, "pixelSize"), this.blur = _a(p, "blur"), this.interpolate = a == null || c == null ? null : JW(m);
  }
}
class h8 extends f8 {
  constructor(t, n = {}) {
    const { imageRendering: i } = n;
    if (t == null) {
      const { fill: r, fillOpacity: s } = n;
      Te(s)[0] !== void 0 && (n = Jg("fillOpacity", n)), _n(r)[0] !== void 0 && (n = Jg("fill", n));
    }
    super(t, void 0, n, KW), this.imageRendering = Ie(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 M;
    const o = n[(M = i.channels.fill) == null ? void 0 : M.scale] ?? ((B) => B), { x: a, y: c } = i, { document: l } = s, [u, f, h, d] = p8(i, r, s), p = h - u, m = d - f, { pixelSize: g, width: y = Math.round(Math.abs(p) / g), height: b = Math.round(Math.abs(m) / g) } = this, _ = y * b;
    let { fill: w, fillOpacity: x } = i, v = 0;
    if (this.interpolate) {
      const B = y / p, N = b / m, L = he(a, (U) => (U - u) * B, Float64Array), k = he(c, (U) => (U - f) * N, Float64Array);
      w && (w = this.interpolate(t, y, b, L, k, w)), x && (x = this.interpolate(t, y, b, L, k, x));
    } else
      this.data == null && t && (v = t.fi * _);
    const I = l.createElement("canvas");
    I.width = y, I.height = b;
    const T = I.getContext("2d"), F = T.createImageData(y, b), A = F.data;
    let { r: $, g: D, b: O } = ei(this.fill) ?? { r: 0, g: 0, b: 0 }, S = (this.fillOpacity ?? 1) * 255;
    for (let B = 0; B < _; ++B) {
      const N = B << 2;
      if (w) {
        const L = o(w[B + v]);
        if (L == null) {
          A[N + 3] = 0;
          continue;
        }
        ({ r: $, g: D, b: O } = ei(L));
      }
      x && (S = x[B + v] * 255), A[N + 0] = $, A[N + 1] = D, A[N + 2] = O, A[N + 3] = S;
    }
    return this.blur > 0 && hL(F, this.blur), T.putImageData(F, 0, 0), Wt("svg:g", s).call(ye, this, r, s).call(ae, this, n).call(
      (B) => B.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(m)).attr("preserveAspectRatio", "none").call(st, "image-rendering", this.imageRendering).call(pe, this).attr("xlink:href", I.toDataURL())
    ).node();
  }
}
function d8(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 && UV(t) && (i = cf, r = Tu, s === void 0 && (s = LV)), [t, { ...o, x: i, y: r, [e]: s }];
}
function ZW() {
  const [e, t] = d8("fill", ...arguments);
  return new h8(
    e,
    e == null || t.fill !== void 0 || t.fillOpacity !== void 0 ? t : { ...t, fill: ct }
  );
}
function p8({ 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 y8({ 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), p8(n_(a, r), s, o);
}
function Jg(e, t = {}) {
  const { [e]: n } = t;
  if (typeof n != "function")
    throw new Error(`invalid ${e}: not a function`);
  return vn({ ...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] = y8(s, o, a, c), m = d - f, g = p - h, { pixelSize: y } = this, { width: b = Math.round(Math.abs(m) / y), height: _ = Math.round(Math.abs(g) / y) } = t, w = new Array(b * _ * (r ? r.length : 1)), x = m / b, v = g / _;
    let I = 0;
    for (const T of r ?? [void 0])
      for (let F = 0.5; F < _; ++F)
        for (let A = 0.5; A < b; ++A, ++I)
          w[I] = n(l.invert(f + A * x), u.invert(h + F * v), T);
    return { data: w, facets: r, channels: { [e]: { value: w, scale: "auto" } } };
  });
}
function JW(e) {
  if (typeof e == "function")
    return e;
  if (e == null)
    return Qg;
  switch (`${e}`.toLowerCase()) {
    case "none":
      return Qg;
    case "nearest":
      return g8;
    case "barycentric":
      return m8();
    case "random-walk":
      return b8();
  }
  throw new Error(`invalid interpolate: ${e}`);
}
function Qg(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 m8({ random: e = Sb(42) } = {}) {
  return (t, n, i, r, s, o) => {
    const { points: a, triangles: c, hull: l } = Qs.from(
      t,
      (d) => r[d],
      (d) => s[d]
    ), u = new o.constructor(n * i).fill(NaN), f = new Uint8Array(n * i), h = rG(o, e);
    for (let d = 0; d < c.length; d += 3) {
      const p = c[d], m = c[d + 1], g = c[d + 2], y = a[2 * p], b = a[2 * m], _ = a[2 * g], w = a[2 * p + 1], x = a[2 * m + 1], v = a[2 * g + 1], I = Math.min(y, b, _), T = Math.max(y, b, _), F = Math.min(w, x, v), A = Math.max(w, x, v), $ = (x - v) * (y - _) + (w - v) * (_ - b);
      if (!$)
        continue;
      const D = o[t[p]], O = o[t[m]], S = o[t[g]];
      for (let M = Math.floor(I); M < T; ++M)
        for (let B = Math.floor(F); B < A; ++B) {
          if (M < 0 || M >= n || B < 0 || B >= i)
            continue;
          const N = M + 0.5, L = B + 0.5, k = ((x - v) * (N - _) + (L - v) * (_ - b)) / $;
          if (k < 0)
            continue;
          const U = ((v - w) * (N - _) + (L - v) * (y - _)) / $;
          if (U < 0)
            continue;
          const V = 1 - k - U;
          if (V < 0)
            continue;
          const j = M + n * B;
          u[j] = h(D, k, O, U, S, V, M, B), f[j] = 1;
        }
    }
    return QW(u, f, r, s, o, n, i, l, t, h), u;
  };
}
function QW(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) => eG(p, n, i));
  let h = 0;
  for (let d = 0; d < o; ++d) {
    const p = d + 0.5;
    for (let m = 0; m < s; ++m) {
      const g = m + s * d;
      if (!t[g]) {
        const y = m + 0.5;
        for (let b = 0; b < u; ++b) {
          const _ = (u + h + (b % 2 ? (b + 1) / 2 : -b / 2)) % u;
          if (f[_](y, p)) {
            const w = tG(n.at(_ - 1), i.at(_ - 1), n[_], i[_], y, p);
            e[g] = l(r.at(_ - 1), w, r[_], 1 - w, r[_], 0, m, d), h = _;
            break;
          }
        }
      }
    }
  }
}
function tG(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 Al(e, t, n, i) {
  return e * i - n * t;
}
function eG(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, m = s - a, g = c - u, y = l - f, b = Math.hypot(h, d), _ = Math.hypot(p, m), w = Math.hypot(g, y);
  return (x, v) => {
    const I = x - o, T = v - a, F = x - c, A = v - l;
    return Al(I, T, F, A) > -1e-6 && Al(I, T, h, d) * _ - Al(I, T, p, m) * b > -1e-6 && Al(F, A, g, y) * b - Al(F, A, h, d) * w <= 0;
  };
}
function g8(e, t, n, i, r, s) {
  const o = new s.constructor(t * n), a = Qs.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 b8({ random: e = Sb(42), minDistance: t = 0.5, maxSteps: n = 2 } = {}) {
  return (i, r, s, o, a, c) => {
    const l = new c.constructor(r * s), u = Qs.from(
      i,
      (p) => o[p],
      (p) => a[p]
    );
    let f, h, d;
    for (let p = 0.5, m = 0; p < s; ++p) {
      h = f;
      for (let g = 0.5; g < r; ++g, ++m) {
        let y = g, b = p;
        d = h = u.find(y, b, h), g === 0.5 && (f = h);
        let _, w = 0;
        for (; (_ = Math.hypot(o[i[d]] - y, a[i[d]] - b)) > t && w < n; ) {
          const x = e(g, p, w) * 2 * Math.PI;
          y += Math.cos(x) * _, b += Math.sin(x) * _, d = u.find(y, b, d), ++w;
        }
        l[m] = c[i[d]];
      }
    }
    return l;
  };
}
function nG(e, t, n, i, r, s) {
  return t * e + i * n + s * r;
}
function iG(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 rG(e, t) {
  return X$(e) || ri(e) ? nG : iG(t);
}
function sG(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 oG(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 Cx = {
  ariaLabel: "contour",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1,
  pixelSize: 2
};
class _8 extends f8 {
  constructor(t, { smooth: n = !0, value: i, ...r } = {}) {
    const s = T4({}, r, Cx);
    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: cs(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 = Jg("value", { value: i, ...r }), i = null;
    } else {
      let { interpolate: a } = r;
      i === void 0 && (i = ct), a === void 0 && (r.interpolate = "nearest");
    }
    super(t, { value: { value: i, optional: !0 } }, aG(r), Cx);
    const o = { geometry: { value: ct } };
    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 = to();
    return Wt("svg:g", s).call(ye, this, r, s).call(ae, this, n).call((c) => {
      c.selectAll().data(t).enter().append("path").call(pe, this).attr("d", (l) => a(o[l])).call(Le, this, i);
    }).node();
  }
}
function aG({ thresholds: e, interval: t, ...n }) {
  return e = UT(e, t, nb), vn(n, function(i, r, s, o, a, c) {
    const [l, u, f, h] = y8(s, o, a, c), d = f - l, p = h - u, { pixelSize: m, width: g = Math.round(Math.abs(d) / m), height: y = Math.round(Math.abs(p) / m) } = this, b = g / d, _ = y / p, w = s.value.value, x = [];
    if (this.interpolate) {
      const { x: A, y: $ } = e0(s, o, c), D = he(A, (B) => (B - l) * b, Float64Array), O = he($, (B) => (B - u) * _, Float64Array), S = [s.x, s.y, s.value], M = [D, O, w];
      for (const B of r) {
        const N = this.filter(B, S, M);
        x.push(this.interpolate(N, g, y, D, O, w));
      }
    } else if (r) {
      const A = g * y, $ = r.length;
      for (let D = 0; D < $; ++D)
        x.push(w.slice(D * A, D * A + A));
    } else
      x.push(w);
    if (this.blur > 0)
      for (const A of x)
        k3({ data: A, width: g, height: y }, this.blur);
    const v = cG(e, w, ...uG(x));
    if (v === null)
      throw new Error(`unsupported thresholds: ${e}`);
    const { contour: I } = Bd().size([g, y]).smooth(this.smooth), T = [], F = [];
    for (const A of x)
      F.push(Bn(T.length, T.push(...he(v, ($) => I(A, $)))));
    for (const { coordinates: A } of T)
      for (const $ of A)
        for (const D of $)
          for (const O of D)
            O[0] = O[0] / b + l, O[1] = O[1] / _ + u;
    return {
      data: T,
      facets: F,
      channels: e4(this.contourChannels, T)
    };
  });
}
function cG(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 wn(e);
  const r = ks(...Y3(n, i, e), e);
  for (; r[r.length - 1] >= i; )
    r.pop();
  for (; r[1] < n; )
    r.shift();
  return r;
}
function lG() {
  return new _8(...d8("value", ...arguments));
}
function uG(e) {
  return [ze(e, (t) => ze(t, kx)), Se(e, (t) => Se(t, kx))];
}
function kx(e) {
  return isFinite(e) ? e : NaN;
}
function fG(e, t) {
  return j_(p_, e, t);
}
function hG(e, t = {}) {
  return j_(y_, e, t);
}
function dG(e, t = {}) {
  return j_(m_, e, t);
}
function j_(e, t, n = {}) {
  const { x: i, y: r, maxRadius: s } = n, o = e({ px: i, py: r, maxRadius: s }), a = [];
  i != null && a.push(Vs(t, Ux("x", { ...o, inset: -6 }, n))), r != null && a.push(js(t, Ux("y", { ...o, inset: -6 }, n))), i != null && a.push(Dc(t, zx("x", { ...o, dy: 9, frameAnchor: "bottom", lineAnchor: "top" }, n))), r != null && a.push(Dc(t, zx("y", { ...o, dx: -9, frameAnchor: "left", textAnchor: "end" }, n)));
  for (const c of a)
    c.ariaLabel = `crosshair ${c.ariaLabel}`;
  return es(...a);
}
function w8(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: pG(e, u)
  };
}
function pG(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 Ux(e, t, n) {
  const {
    color: i = "currentColor",
    opacity: r = 0.2,
    ruleStroke: s = i,
    ruleStrokeOpacity: o = r,
    ruleStrokeWidth: a
  } = n;
  return {
    ...w8(e, t, n),
    stroke: s,
    strokeOpacity: o,
    strokeWidth: a
  };
}
function zx(e, t, n) {
  const {
    color: i = "currentColor",
    textFill: r = i,
    textFillOpacity: s,
    textStroke: o = "white",
    textStrokeOpacity: a,
    textStrokeWidth: c = 5
  } = n;
  return {
    ...w8(e, t, yG(e, n)),
    fill: r,
    fillOpacity: s,
    stroke: o,
    strokeOpacity: a,
    strokeWidth: c
  };
}
function yG(e, t) {
  return vn(t, (n, i, r) => {
    var s;
    return { channels: { text: { value: (s = s4(r, e)) == null ? void 0 : s.value } } };
  });
}
const mG = {
  ariaLabel: "delaunay link",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1
}, gG = {
  ariaLabel: "delaunay mesh",
  fill: null,
  stroke: "currentColor",
  strokeOpacity: 0.2
}, bG = {
  ariaLabel: "hull",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1.5,
  strokeMiterlimit: 1
}, _G = {
  ariaLabel: "voronoi",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1
}, wG = {
  ariaLabel: "voronoi mesh",
  fill: null,
  stroke: "currentColor",
  strokeOpacity: 0.2
};
class vG extends ce {
  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,
      mG
    ), this.curve = A_(o, a), tl(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] = yr(this, r), p = c ? (b) => c[b] : ii(h), m = l ? (b) => l[b] : ii(d), g = this;
    function y(b) {
      let _ = -1;
      const w = [], x = {};
      for (const S in i)
        x[S] = [];
      const v = [], I = [], T = [], F = [];
      function A(S, M) {
        S = b[S], M = b[M], w.push(++_), v[_] = p(S), T[_] = m(S), I[_] = p(M), F[_] = m(M);
        for (const B in i)
          x[B].push(i[B][M]);
      }
      const { halfedges: $, hull: D, triangles: O } = Qs.from(b, p, m);
      for (let S = 0; S < $.length; ++S) {
        const M = $[S];
        M > S && A(O[S], O[M]);
      }
      for (let S = 0; S < D.length; ++S)
        A(D[S], D[(S + 1) % D.length]);
      re(this).selectAll().data(w).enter().append("path").call(pe, g).attr("d", (S) => {
        const M = zr(), B = f(M);
        return B.lineStart(), B.point(v[S], T[S]), B.point(I[S], F[S]), B.lineEnd(), M;
      }).call(Le, g, x).call(pf, g, x, s);
    }
    return Wt("svg:g", s).call(ye, this, r, s).call(ae, this, { x: c && o, y: l && a }).call(
      u ? (b) => b.selectAll().data(os(t, (_) => u[_]).values()).enter().append("g").each(y) : (b) => b.datum(t).each(y)
    ).node();
  }
}
class Y_ extends ce {
  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] = yr(this, r), d = c ? (y) => c[y] : ii(f), p = l ? (y) => l[y] : ii(h), m = this;
    function g(y) {
      const b = Qs.from(y, d, p);
      re(this).append("path").datum(y[0]).call(pe, m).attr("d", m._render(b, r)).call(Le, m, i);
    }
    return Wt("svg:g", s).call(ye, this, r, s).call(ae, this, { x: c && o, y: l && a }).call(
      u ? (y) => y.selectAll().data(os(t, (b) => u[b]).values()).enter().append("g").each(g) : (y) => y.datum(t).each(g)
    ).node();
  }
}
class xG extends Y_ {
  constructor(t, n = {}) {
    super(t, n, gG), this.fill = "none";
  }
  _render(t) {
    return t.render();
  }
}
class SG extends Y_ {
  constructor(t, n = {}) {
    super(t, n, bG, no);
  }
  _render(t) {
    return t.renderHull();
  }
}
class IG extends ce {
  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,
      _G
    );
  }
  render(t, n, i, r, s) {
    const { x: o, y: a } = n, { x: c, y: l, z: u } = i, [f, h] = yr(this, r), d = c ? (y) => c[y] : ii(f), p = l ? (y) => l[y] : ii(h), m = this;
    function g(y) {
      const b = Qs.from(y, d, p), _ = v8(b, r);
      re(this).selectAll().data(y).enter().append("path").call(pe, m).attr("d", (w, x) => _.renderCell(x)).call(Le, m, i);
    }
    return Wt("svg:g", s).call(ye, this, r, s).call(ae, this, { x: c && o, y: l && a }).call(
      u ? (y) => y.selectAll().data(os(t, (b) => u[b]).values()).enter().append("g").each(g) : (y) => y.datum(t).each(g)
    ).node();
  }
}
class AG extends Y_ {
  constructor(t, n) {
    super(t, n, wG), this.fill = "none";
  }
  _render(t, n) {
    return v8(t, n).render();
  }
}
function v8(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 bf(e, t, { x: n, y: i, ...r } = {}) {
  return [n, i] = Di(n, i), new e(t, { ...r, x: n, y: i });
}
function MG(e, t) {
  return bf(vG, e, t);
}
function $G(e, t) {
  return bf(xG, e, t);
}
function TG(e, t) {
  return bf(SG, e, t);
}
function BG(e, t) {
  return bf(IG, e, t);
}
function NG(e, t) {
  return bf(AG, e, t);
}
const FG = {
  ariaLabel: "density",
  fill: "none",
  stroke: "currentColor",
  strokeMiterlimit: 1
};
class x8 extends ce {
  constructor(t, { x: n, y: i, z: r, weight: s, fill: o, stroke: a, ...c } = {}) {
    const l = Px(o) && (o = "currentColor", !0), u = Px(a) && (a = "currentColor", !0);
    super(
      t,
      {
        x: { value: n, scale: "x", optional: !0 },
        y: { value: i, scale: "y", optional: !0 },
        z: { value: no({ z: r, fill: o, stroke: a }), optional: !0 },
        weight: { value: s, optional: !0 }
      },
      OG({ ...c, fill: o, stroke: a }, l, u),
      FG
    ), 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 = to();
    return Wt("svg:g", s).call(ye, this, r, s).call(ae, this, {}).call(
      (c) => c.selectAll().data(t).enter().append("path").call(pe, this).call(Le, this, i).attr("d", (l) => a(o[l]))
    ).node();
  }
}
function DG(e, { x: t, y: n, ...i } = {}) {
  return [t, n] = Di(t, n), new x8(e, { ...i, x: t, y: n });
}
const EG = /* @__PURE__ */ new Set(["x", "y", "z", "weight"]);
function OG(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" ? pn(s) : +s, vn(e, function(o, a, c, l, u, f) {
    var O;
    const h = c.weight ? pn(c.weight.value) : null, d = (O = c.z) == null ? void 0 : O.value, { z: p } = this, [m, g] = yr(this, u), { width: y, height: b } = u, { x: _, y: w } = e0(c, l, f), x = Object.fromEntries(
      Object.entries(c).filter(([S]) => !EG.has(S)).map(([S, M]) => [S, { ...M, value: [] }])
    ), v = t && [], I = n && [], T = Gk().x(_ ? (S) => _[S] : m).y(w ? (S) => w[S] : g).weight(h ? (S) => h[S] : 1).size([y, b]).bandwidth(r), F = [];
    for (const S of a) {
      const M = [];
      F.push(M);
      for (const B of d ? l_(S, d, p) : [S]) {
        const N = T.contours(B);
        M.push([B, N]);
      }
    }
    let A = s;
    if (!(A instanceof Bc)) {
      let S = 0;
      for (const M of F)
        for (const [, B] of M) {
          const N = B.max;
          N > S && (S = N);
        }
      A = Float64Array.from({ length: s - 1 }, (M, B) => S * 100 * (B + 1) / s);
    }
    const $ = [], D = [];
    for (const S of F) {
      const M = [];
      $.push(M);
      for (const [B, N] of S)
        for (const L of A) {
          M.push(D.length), D.push(N(L / 100)), v && v.push(L), I && I.push(L);
          for (const k in x)
            x[k].value.push(c[k].value[B[0]]);
        }
    }
    return v && v.push(0), I && I.push(0), {
      data: o,
      facets: $,
      channels: {
        ...x,
        ...v && { fill: { value: v, scale: "color" } },
        ...I && { stroke: { value: I, scale: "color" } },
        contours: { value: D }
      }
    };
  });
}
function Px(e) {
  return /^density$/i.test(e);
}
const LG = {
  ariaLabel: "geo",
  fill: "none",
  stroke: "currentColor",
  strokeWidth: 1,
  strokeLinecap: "round",
  strokeLinejoin: "round",
  strokeMiterlimit: 1
};
class S8 extends ce {
  constructor(t, n = {}) {
    const [i, r] = Te(n.r, 3);
    super(
      t,
      {
        geometry: { value: n.geometry, scale: "projection" },
        r: { value: i, scale: "r", filter: Gr, optional: !0 }
      },
      R_(n),
      LG
    ), this.r = r;
  }
  render(t, n, i, r, s) {
    const { geometry: o, r: a } = i, c = to(s.projection ?? RG(n)), { r: l } = this;
    return Yy(l) ? t = [] : l !== void 0 && c.pointRadius(l), Wt("svg:g", s).call(ye, this, r, s).call(ae, this, n).call((u) => {
      u.selectAll().data(t).enter().append("path").call(pe, this).attr("d", a ? (f) => c.pointRadius(a[f])(o[f]) : (f) => c(o[f])).call(Le, this, i);
    }).node();
  }
}
function RG({ x: e, y: t }) {
  if (e || t)
    return e ?? (e = (n) => n), t ?? (t = (n) => n), Kd({
      point(n, i) {
        this.stream.point(e(n), t(i));
      }
    });
}
function q_(e, { geometry: t = ct, ...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 S8(e, { geometry: t, ...n });
}
function CG({ strokeWidth: e = 1.5, ...t } = {}) {
  return q_({ type: "Sphere" }, { strokeWidth: e, ...t });
}
function kG({ strokeOpacity: e = 0.1, ...t } = {}) {
  return q_(V9(), { strokeOpacity: e, ...t });
}
const iu = 0.5, ru = 0;
function UG(e = { fill: "count" }, { binWidth: t, ...n } = {}) {
  const { z: i } = n;
  return t = t === void 0 ? 20 : Ct(t), e = Kb(e, n), $s(e, "fill") && (n.channels = { ...n.channels, fill: { value: [] } }), n.symbol === void 0 && (n.symbol = "hexagon"), n.r === void 0 && !$s(e, "r") && (n.r = t / 2), vn(n, (r, s, o, a, c, l) => {
    let { x: u, y: f, z: h, fill: d, stroke: p, symbol: m } = 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 } = e0(o, a, l)), h = h ? h.value : Ot(r, i), d = d == null ? void 0 : d.value, p = p == null ? void 0 : p.value, m = m == null ? void 0 : m.value;
    const g = Qb(e, { z: h, fill: d, stroke: p, symbol: m }), y = h && [], b = d && [], _ = p && [], w = m && [], x = [], v = [], I = [];
    let T = -1;
    for (const D of e)
      D.initialize(r);
    for (const D of s) {
      const O = [];
      for (const S of e)
        S.scope("facet", D);
      for (const [S, M] of Ja(D, g))
        for (const B of zG(M, u, f, t)) {
          O.push(++T), v.push(B.x), I.push(B.y), h && y.push(g === h ? S : h[B[0]]), d && b.push(g === d ? S : d[B[0]]), p && _.push(g === p ? S : p[B[0]]), m && w.push(g === m ? S : m[B[0]]);
          for (const N of e)
            N.reduce(B);
        }
      x.push(O);
    }
    const F = o.x.scale, A = o.y.scale, $ = {
      x: { value: v, source: a[F] ? { value: he(v, a[F].invert), scale: F } : null },
      y: { value: I, source: a[A] ? { value: he(I, a[A].invert), scale: A } : null },
      ...h && { z: { value: y } },
      ...d && { fill: { value: b, scale: "auto" } },
      ...p && { stroke: { value: _, scale: "auto" } },
      ...m && { symbol: { value: w, scale: "auto" } },
      ...Object.fromEntries(
        e.map(({ name: D, output: O }) => [
          D,
          {
            scale: "auto",
            label: O.label,
            radius: D === "r" ? t / 2 : void 0,
            value: O.transform()
          }
        ])
      )
    };
    return { data: r, facets: x, channels: $ };
  });
}
function zG(e, t, n, i) {
  const r = i * (1.5 / K$), s = /* @__PURE__ */ new Map();
  for (const o of e) {
    let a = t[o], c = n[o];
    if (isNaN(a) || isNaN(c))
      continue;
    let l = Math.round(c = (c - ru) / r), u = Math.round(a = (a - iu) / i - (l & 1) / 2), f = c - l;
    if (Math.abs(f) * 3 > 1) {
      let p = a - u, m = u + (a < u ? -1 : 1) / 2, g = l + (c < l ? -1 : 1), y = a - m, b = c - g;
      p * p + f * f > y * y + b * b && (u = m + (l & 1 ? 1 : -1) / 2, l = g);
    }
    const h = `${u},${l}`;
    let d = s.get(h);
    d === void 0 && (s.set(h, d = []), d.x = (u + (l & 1) / 2) * i + iu, d.y = l * r + ru), d.push(o);
  }
  return s.values();
}
const PG = {
  ariaLabel: "hexgrid",
  fill: "none",
  stroke: "currentColor",
  strokeOpacity: 0.1
};
function VG(e) {
  return new I8(e);
}
class I8 extends ce {
  constructor({ binWidth: t = 20, clip: n = !0, ...i } = {}) {
    super(tu, void 0, { clip: n, ...i }, PG), this.binWidth = Ct(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 - iu, p = f - c - iu, m = a - ru, g = h - l - ru, y = o / 2, b = y * Z$, _ = b / 2, w = y * 2, x = b * 1.5, v = Math.floor(d / w), I = Math.ceil(p / w), T = Math.floor((m + _) / x), F = Math.ceil((g - _) / x) + 1, A = `m0,${ds(-b)}l${ds(y)},${ds(_)}v${ds(b)}l${ds(-y)},${ds(_)}`;
    let $ = A;
    for (let D = T; D < F; ++D)
      for (let O = v; O < I; ++O)
        $ += `M${ds(O * w + (D & 1) * y)},${ds(D * x)}${A}`;
    return Wt("svg:g", s).datum(0).call(ye, this, r, s).call(ae, this, {}, Ye + iu, Ye + ru).call((D) => D.append("path").call(pe, this).call(Le, this, i).attr("d", $)).node();
  }
}
function ds(e) {
  return Math.round(e * 1e3) / 1e3;
}
const jG = {
  ariaLabel: "image",
  fill: null,
  stroke: null
};
function YG(e) {
  return /^\.*\//.test(e);
}
function qG(e) {
  return /^(blob|data|file|http|https):/i.test(e);
}
function WG(e) {
  return typeof e == "string" && (YG(e) || qG(e)) ? [void 0, e] : [e, void 0];
}
class A8 extends ce {
  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, m] = WG(l), [g, y] = Te(s), [b, _] = Te(o, y !== void 0 ? y * 2 : void 0), [w, x] = Te(a, y !== void 0 ? y * 2 : void 0), [v, I] = Te(c, 0);
    super(
      t,
      {
        x: { value: i, scale: "x", optional: !0 },
        y: { value: r, scale: "y", optional: !0 },
        r: { value: g, scale: "r", filter: Gr, optional: !0 },
        width: { value: b, filter: Gr, optional: !0 },
        height: { value: w, filter: Gr, optional: !0 },
        rotate: { value: v, optional: !0 },
        src: { value: p, optional: !0 }
      },
      R_(n),
      jG
    ), this.src = m, this.width = _, this.rotate = I, this.height = x, this.r = y, this.preserveAspectRatio = Ie(u, "xMidYMid"), this.crossOrigin = He(f), this.frameAnchor = ff(h), this.imageRendering = Ie(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: m, width: g, height: y, rotate: b } = this, [_, w] = yr(this, r);
    return Wt("svg:g", s).call(ye, this, r, s).call(ae, this, { x: c && o, y: l && a }).call(
      (x) => x.selectAll().data(t).enter().append("image").call(pe, this).attr("x", Vx(c, u, h, _, g, m)).attr("y", Vx(l, f, h, w, y, m)).attr("width", u ? (v) => u[v] : g !== void 0 ? g : h ? (v) => h[v] * 2 : m * 2).attr("height", f ? (v) => f[v] : y !== void 0 ? y : h ? (v) => h[v] * 2 : m * 2).attr("transform", d ? (v) => `rotate(${d[v]})` : b ? `rotate(${b})` : null).attr("transform-origin", d || b ? o0`${c ? (v) => c[v] : _}px ${l ? (v) => l[v] : w}px` : null).call(st, "href", p ? (v) => p[v] : this.src).call(st, "preserveAspectRatio", this.preserveAspectRatio).call(st, "crossorigin", this.crossOrigin).call(st, "image-rendering", this.imageRendering).call(st, "clip-path", h ? (v) => `circle(${h[v]}px)` : m !== void 0 ? `circle(${m}px)` : null).call(Le, this, i)
    ).node();
  }
}
function Vx(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 GG(e, { x: t, y: n, ...i } = {}) {
  return i.frameAnchor === void 0 && ([t, n] = Di(t, n)), new A8(e, { ...i, x: t, y: n });
}
function XG(e, t, n) {
  var i = 1e-8, r = t - 1, s = n - 1, o = 0, a, c, l, u, f, h, d, p, m, g, y;
  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, m = 2 / (1 / (2 * t - 1) + 1 / (2 * n - 1)), g = d * Math.sqrt(p + m) / m - (1 / (2 * n - 1) - 1 / (2 * t - 1)) * (p + 5 / 6 - 2 / (3 * m)), 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)), y = -nc(t) - nc(n) + nc(t + n); o < 10; o++) {
    if (d === 0 || d === 1)
      return d;
    if (h = HG(d, t, n) - e, u = Math.exp(r * Math.log(d) + s * Math.log(1 - d) + y), 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 HG(e, t, n) {
  var i = e === 0 || e === 1 ? 0 : Math.exp(nc(t + n) - nc(t) - nc(n) + t * Math.log(e) + n * Math.log(1 - e));
  return e < 0 || e > 1 ? !1 : e < (t + 1) / (t + n + 2) ? i * jx(e, t, n) / t : 1 - i * jx(1 - e, n, t) / n;
}
function jx(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 nc(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 KG(e, t) {
  var n = XG(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 ZG = {
  ariaLabel: "linear-regression",
  fill: "currentColor",
  fillOpacity: 0.1,
  stroke: "currentColor",
  strokeWidth: 1.5,
  strokeLinecap: "round",
  strokeLinejoin: "round",
  strokeMiterlimit: 1
};
class M8 extends ce {
  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: no(n), optional: !0 }
      },
      n,
      ZG
    ), 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 Wt("svg:g", s).call(ye, this, r, s).call(ae, this, n).call(
      (u) => u.selectAll().data(c ? l_(t, c, this.z) : [t]).enter().call(
        (f) => f.append("path").attr("fill", "none").call(pe, this).call(pp, this, { ...i, fill: null, fillOpacity: null }).attr("d", (h) => this._renderLine(h, o, a)).call(
          l && !Nc(this.fill) ? (h) => h.select(JG).attr("stroke", "none").call(pe, this).call(pp, this, {
            ...i,
            stroke: null,
            strokeOpacity: null,
            strokeWidth: null
          }).attr("d", (d) => this._renderBand(d, o, a)) : () => {
          }
        )
      )
    ).node();
  }
}
function JG() {
  return this.parentNode.insertBefore(this.ownerDocument.createElementNS(Xo.svg, "path"), this);
}
class QG extends M8 {
  constructor(t, n) {
    super(t, n);
  }
  _renderBand(t, n, i) {
    const { ci: r, precision: s } = this, [o, a] = je(t, (u) => i[u]), c = Ip(t, i, n), l = $8(t, i, n, (1 - r) / 2, c);
    return Bb().y((u) => u).x0((u) => l(u, -1)).x1((u) => l(u, 1))(Bn(o, a - s / 2, s).concat(a));
  }
  _renderLine(t, n, i) {
    const [r, s] = je(t, (a) => i[a]), o = Ip(t, i, n);
    return `M${o(r)},${r}L${o(s)},${s}`;
  }
}
class tX extends M8 {
  constructor(t, n) {
    super(t, n);
  }
  _renderBand(t, n, i) {
    const { ci: r, precision: s } = this, [o, a] = je(t, (u) => n[u]), c = Ip(t, n, i), l = $8(t, n, i, (1 - r) / 2, c);
    return Bb().x((u) => u).y0((u) => l(u, -1)).y1((u) => l(u, 1))(Bn(o, a - s / 2, s).concat(a));
  }
  _renderLine(t, n, i) {
    const [r, s] = je(t, (a) => n[a]), o = Ip(t, n, i);
    return `M${r},${o(r)}L${s},${o(s)}`;
  }
}
function eX(e, { y: t = In, x: n = ct, stroke: i, fill: r = ke(i) ? "currentColor" : i, ...s } = {}) {
  return new QG(e, $_({ ...s, x: n, y: t, fill: r, stroke: i }));
}
function nX(e, { x: t = In, y: n = ct, stroke: i, fill: r = ke(i) ? "currentColor" : i, ...s } = {}) {
  return new tX(e, M_({ ...s, x: t, y: n, fill: r, stroke: i }));
}
function Ip(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 $8(e, t, n, i, r) {
  const s = sr(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 = KG(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 t1({
  path: e = ct,
  // the delimited path
  delimiter: t,
  // how the path is separated
  frameAnchor: n,
  treeLayout: i = tp,
  treeSort: r,
  treeSeparation: s,
  treeAnchor: o,
  treeFilter: a,
  ...c
} = {}) {
  o = W_(o), r = B8(r), a != null && (a = e1(a)), n === void 0 && (n = o.frameAnchor);
  const l = N8(t), u = R8(c, e1), [f, h] = Fn(), [d, p] = Fn();
  return {
    x: f,
    y: d,
    frameAnchor: n,
    ...pr(c, (m, g) => {
      const y = l(Ot(m, e)), b = h([]), _ = p([]);
      let w = -1;
      const x = [], v = [], I = vM().path((F) => y[F]), T = i();
      T.nodeSize && T.nodeSize([1, 1]), T.separation && s !== void 0 && T.separation(s ?? Lb);
      for (const F of u)
        F[Ap] = F[O8]([]);
      for (const F of g) {
        const A = [], $ = I(F.filter((D) => y[D] != null)).each((D) => D.data = m[D.data]);
        r != null && $.sort(r), T($);
        for (const D of $.descendants())
          if (!(a != null && !a(D))) {
            A.push(++w), x[w] = D.data, o.position(D, w, b, _);
            for (const O of u)
              O[Ap][w] = O[L8](D);
          }
        v.push(A);
      }
      return { data: x, facets: v };
    }),
    ...Object.fromEntries(u)
  };
}
function T8({
  path: e = ct,
  // 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 = tp,
  treeSort: a,
  treeSeparation: c,
  treeAnchor: l,
  treeFilter: u,
  ...f
} = {}) {
  l = W_(l), a = B8(a), u != null && (u = qx(u)), f = { curve: n, stroke: i, strokeWidth: r, strokeOpacity: s, ...f };
  const h = N8(t), d = R8(f, qx), [p, m] = Fn(), [g, y] = Fn(), [b, _] = Fn(), [w, x] = Fn();
  return {
    x1: p,
    x2: g,
    y1: b,
    y2: w,
    ...pr(f, (v, I) => {
      const T = h(Ot(v, e)), F = m([]), A = y([]), $ = _([]), D = x([]);
      let O = -1;
      const S = [], M = [], B = vM().path((L) => T[L]), N = o();
      N.nodeSize && N.nodeSize([1, 1]), N.separation && c !== void 0 && N.separation(c ?? Lb);
      for (const L of d)
        L[Ap] = L[O8]([]);
      for (const L of I) {
        const k = [], U = B(L.filter((V) => T[V] != null)).each((V) => V.data = v[V.data]);
        a != null && U.sort(a), N(U);
        for (const { source: V, target: j } of U.links())
          if (!(u != null && !u(j, V))) {
            k.push(++O), S[O] = j.data, l.position(V, O, F, $), l.position(j, O, A, D);
            for (const X of d)
              X[Ap][O] = X[L8](j, V);
          }
        M.push(k);
      }
      return { data: S, facets: M };
    }),
    ...Object.fromEntries(d)
  };
}
function W_(e = "left") {
  switch (`${e}`.trim().toLowerCase()) {
    case "left":
      return iX;
    case "right":
      return rX;
  }
  throw new Error(`invalid tree anchor: ${e}`);
}
const iX = {
  frameAnchor: "left",
  dx: 6,
  position({ x: e, y: t }, n, i, r) {
    i[n] = t, r[n] = -e;
  }
}, rX = {
  frameAnchor: "right",
  dx: -6,
  position({ x: e, y: t }, n, i, r) {
    i[n] = -t, r[n] = -e;
  }
};
function B8(e) {
  return e == null || typeof e == "function" ? e : `${e}`.trim().toLowerCase().startsWith("node:") ? Yx(e1(e)) : Yx(sX(e));
}
function Yx(e) {
  return (t, n) => ni(e(t), e(n));
}
function sX(e) {
  return (t) => {
    var n;
    return (n = t.data) == null ? void 0 : n[e];
  };
}
function N8(e = "/") {
  return `${e}` == "/" ? (t) => t : (t) => t.map(oX(e, "/"));
}
function oX(e, t) {
  return e = new RegExp(aX(e), "g"), (n) => n == null ? null : `${n}`.replace(e, t);
}
function aX(e) {
  return `${e}`.replace(/[\\^$*+?.()|[\]{}]/g, "\\$&");
}
function F8(e) {
  return Fi(e) && typeof e.node == "function";
}
function cX(e) {
  return Fi(e) && typeof e.link == "function";
}
function e1(e) {
  if (F8(e))
    return e.node;
  if (e = `${e}`.trim().toLowerCase(), !!e.startsWith("node:")) {
    switch (e) {
      case "node:name":
        return i1;
      case "node:path":
        return n1;
      case "node:internal":
        return D8;
      case "node:external":
        return E8;
      case "node:depth":
        return r1;
      case "node:height":
        return s1;
    }
    throw new Error(`invalid node value: ${e}`);
  }
}
function qx(e) {
  if (F8(e))
    return e.node;
  if (cX(e))
    return e.link;
  if (e = `${e}`.trim().toLowerCase(), !(!e.startsWith("node:") && !e.startsWith("parent:"))) {
    switch (e) {
      case "parent:name":
        return oh(i1);
      case "parent:path":
        return oh(n1);
      case "parent:depth":
        return oh(r1);
      case "parent:height":
        return oh(s1);
      case "node:name":
        return i1;
      case "node:path":
        return n1;
      case "node:internal":
        return D8;
      case "node:external":
        return E8;
      case "node:depth":
        return r1;
      case "node:height":
        return s1;
    }
    throw new Error(`invalid link value: ${e}`);
  }
}
function n1(e) {
  return e.id;
}
function i1(e) {
  return lX(e.id);
}
function r1(e) {
  return e.depth;
}
function s1(e) {
  return e.height;
}
function D8(e) {
  return !!e.children;
}
function E8(e) {
  return !e.children;
}
function oh(e) {
  return (t, n) => n == null ? void 0 : e(n);
}
function lX(e) {
  let t = e.length;
  for (; --t > 0 && !uX(e, t); )
    ;
  return e.slice(t + 1);
}
function uX(e, t) {
  if (e[t] === "/") {
    let n = 0;
    for (; t > 0 && e[--t] === "\\"; )
      ++n;
    if (!(n & 1))
      return !0;
  }
  return !1;
}
const O8 = 2, L8 = 3, Ap = 4;
function R8(e, t) {
  const n = [];
  for (const i in e) {
    const r = e[i], s = t(r);
    s !== void 0 && n.push([i, ...Fn(r), s]);
  }
  return n;
}
function C8(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 = ke(f) && ke(h),
  text: p = "node:name",
  textStroke: m = "white",
  title: g = "node:path",
  dx: y,
  dy: b,
  textAnchor: _,
  treeLayout: w = tp,
  textLayout: x = w === tp || w === bM ? "mirrored" : "normal",
  tip: v,
  ...I
} = {}) {
  if (y === void 0 && (y = W_(I.treeAnchor).dx), _ !== void 0)
    throw new Error("textAnchor is not a configurable tree option");
  x = hr(x, "textLayout", ["mirrored", "normal"]);
  function T(F) {
    return Dc(
      e,
      t1({
        treeLayout: w,
        text: p,
        fill: t === void 0 ? "currentColor" : t,
        stroke: m,
        dx: y,
        dy: b,
        title: g,
        ...F,
        ...I
      })
    );
  }
  return es(
    ZT(
      e,
      T8({
        treeLayout: w,
        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 ? so(e, t1({ treeLayout: w, fill: t === void 0 ? "node:internal" : t, title: g, tip: v, ...I })) : null,
    p != null ? x === "mirrored" ? [
      T({ textAnchor: "start", treeFilter: "node:external" }),
      T({ textAnchor: "end", treeFilter: "node:internal", dx: -y })
    ] : T() : null
  );
}
function fX(e, t) {
  return C8(e, { ...t, treeLayout: bM });
}
function hX({ geometry: e = ct, ...t } = {}) {
  return vn({ ...t, x: null, y: null }, (n, i, r, s, o, { projection: a }) => {
    const c = Ot(n, e), l = c.length, u = new Float64Array(l), f = new Float64Array(l), h = to(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, source: null }, y: { value: f, source: null } } };
  });
}
function dX({ geometry: e = ct, ...t } = {}) {
  let n;
  return {
    ...t,
    x: { transform: (i) => Float64Array.from(n = Ot(Ot(i, e), N9), ([r]) => r) },
    y: { transform: () => Float64Array.from(n, ([, i]) => i) }
  };
}
function pX(e) {
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
function yX(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 mX(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 gX(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 bX(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 _X(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 Ml(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 wX = {
  ge: function(e, t, n, i, r) {
    return Ml(e, t, n, i, r, yX);
  },
  gt: function(e, t, n, i, r) {
    return Ml(e, t, n, i, r, mX);
  },
  lt: function(e, t, n, i, r) {
    return Ml(e, t, n, i, r, gX);
  },
  le: function(e, t, n, i, r) {
    return Ml(e, t, n, i, r, bX);
  },
  eq: function(e, t, n, i, r) {
    return Ml(e, t, n, i, r, _X);
  }
}, Mp = wX, Pa = 0, $o = 1, Oh = 2, vX = SX;
function G_(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 _f = G_.prototype;
function Im(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 k8(e, t) {
  var n = Lc(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 Wx(e, t) {
  var n = e.intervals([]);
  n.push(t), k8(e, n);
}
function Gx(e, t) {
  var n = e.intervals([]), i = n.indexOf(t);
  return i < 0 ? Pa : (n.splice(i, 1), k8(e, n), $o);
}
_f.intervals = function(e) {
  return e.push.apply(e, this.leftPoints), this.left && this.left.intervals(e), this.right && this.right.intervals(e), e;
};
_f.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) ? Wx(this, e) : this.left.insert(e) : this.left = Lc([e]);
  else if (e[0] > this.mid)
    this.right ? 4 * (this.right.count + 1) > 3 * (t + 1) ? Wx(this, e) : this.right.insert(e) : this.right = Lc([e]);
  else {
    var n = Mp.ge(this.leftPoints, e, X_), i = Mp.ge(this.rightPoints, e, H_);
    this.leftPoints.splice(n, 0, e), this.rightPoints.splice(i, 0, e);
  }
};
_f.remove = function(e) {
  var t = this.count - this.leftPoints;
  if (e[1] < this.mid) {
    if (!this.left)
      return Pa;
    var n = this.right ? this.right.count : 0;
    if (4 * n > 3 * (t - 1))
      return Gx(this, e);
    var i = this.left.remove(e);
    return i === Oh ? (this.left = null, this.count -= 1, $o) : (i === $o && (this.count -= 1), i);
  } else if (e[0] > this.mid) {
    if (!this.right)
      return Pa;
    var r = this.left ? this.left.count : 0;
    if (4 * r > 3 * (t - 1))
      return Gx(this, e);
    var i = this.right.remove(e);
    return i === Oh ? (this.right = null, this.count -= 1, $o) : (i === $o && (this.count -= 1), i);
  } else {
    if (this.count === 1)
      return this.leftPoints[0] === e ? Oh : Pa;
    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;
        }
        Im(this, o), this.count = (this.left ? this.left.count : 0) + (this.right ? this.right.count : 0) + this.leftPoints.length;
      } else
        this.left ? Im(this, this.left) : Im(this, this.right);
      return $o;
    }
    for (var a = Mp.ge(this.leftPoints, e, X_); 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 = Mp.ge(this.rightPoints, e, H_); i < this.rightPoints.length && this.rightPoints[i][1] === e[1]; ++i)
          if (this.rightPoints[i] === e)
            return this.rightPoints.splice(i, 1), $o;
      }
    return Pa;
  }
};
function U8(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 z8(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 P8(e, t) {
  for (var n = 0; n < e.length; ++n) {
    var i = t(e[n]);
    if (i)
      return i;
  }
}
_f.queryPoint = function(e, t) {
  if (e < this.mid) {
    if (this.left) {
      var n = this.left.queryPoint(e, t);
      if (n)
        return n;
    }
    return U8(this.leftPoints, e, t);
  } else if (e > this.mid) {
    if (this.right) {
      var n = this.right.queryPoint(e, t);
      if (n)
        return n;
    }
    return z8(this.rightPoints, e, t);
  } else
    return P8(this.leftPoints, t);
};
_f.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 ? U8(this.leftPoints, t, n) : e > this.mid ? z8(this.rightPoints, e, n) : P8(this.leftPoints, n);
};
function xX(e, t) {
  return e - t;
}
function X_(e, t) {
  var n = e[0] - t[0];
  return n || e[1] - t[1];
}
function H_(e, t) {
  var n = e[1] - t[1];
  return n || e[0] - t[0];
}
function Lc(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(xX);
  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(X_), l.sort(H_), new G_(
    i,
    Lc(r),
    Lc(s),
    c,
    l
  );
}
function o1(e) {
  this.root = e;
}
var sl = o1.prototype;
sl.insert = function(e) {
  this.root ? this.root.insert(e) : this.root = new G_(e[0], null, null, [e], [e]);
};
sl.remove = function(e) {
  if (this.root) {
    var t = this.root.remove(e);
    return t === Oh && (this.root = null), t !== Pa;
  }
  return !1;
};
sl.queryPoint = function(e, t) {
  if (this.root)
    return this.root.queryPoint(e, t);
};
sl.queryInterval = function(e, t, n) {
  if (e <= t && this.root)
    return this.root.queryInterval(e, t, n);
};
Object.defineProperty(sl, "count", {
  get: function() {
    return this.root ? this.root.count : 0;
  }
});
Object.defineProperty(sl, "intervals", {
  get: function() {
    return this.root ? this.root.intervals([]) : [];
  }
});
function SX(e) {
  return !e || e.length === 0 ? new o1(null) : new o1(Lc(e));
}
const IX = /* @__PURE__ */ pX(vX), AX = ({ marginLeft: e }) => [1, e], MX = ({ width: e, marginRight: t }) => [-1, e - t], $X = ({ width: e, marginLeft: t, marginRight: n }) => [0, (t + e - n) / 2], TX = ({ marginTop: e }) => [1, e], BX = ({ height: e, marginBottom: t }) => [-1, e - t], NX = ({ height: e, marginTop: t, marginBottom: n }) => [0, (t + e - n) / 2];
function V8(e) {
  return typeof e == "string" ? { anchor: e } : e;
}
function FX(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = j8(e));
  let { anchor: n = "left", padding: i = 1, r = t.r } = V8(e);
  switch (`${n}`.toLowerCase()) {
    case "left":
      n = AX;
      break;
    case "right":
      n = MX;
      break;
    case "middle":
      n = $X;
      break;
    default:
      throw new Error(`unknown dodge anchor: ${n}`);
  }
  return Y8("x", "y", n, Ct(i), r, t);
}
function DX(e = {}, t = {}) {
  arguments.length === 1 && ([e, t] = j8(e));
  let { anchor: n = "bottom", padding: i = 1, r = t.r } = V8(e);
  switch (`${n}`.toLowerCase()) {
    case "top":
      n = TX;
      break;
    case "bottom":
      n = BX;
      break;
    case "middle":
      n = NX;
      break;
    default:
      throw new Error(`unknown dodge anchor: ${n}`);
  }
  return Y8("y", "x", n, Ct(i), r, t);
}
function j8(e) {
  const { anchor: t, padding: n, ...i } = e, { r } = i;
  return [{ anchor: t, padding: n, r }, i];
}
function Y8(e, t, n, i, r, s) {
  if (r != null && typeof r != "number") {
    let { channels: o, sort: a, reverse: c } = s;
    o = Pb(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 vn(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 } = e0(c, l, f));
    const p = d ? void 0 : r !== void 0 ? Ct(r) : this.r !== void 0 ? this.r : 3;
    d && (d = Ot(d.value, l[d.scale] || ct, Float64Array));
    let [m, g] = n(u);
    const y = m ? OX : EX, b = new Float64Array(h.length), _ = d ? (w) => d[w] : () => p;
    for (let w of a) {
      const x = IX();
      w = w.filter(d ? (I) => up(h[I]) && Gr(d[I]) : (I) => up(h[I]));
      const v = new Float64Array(2 * w.length + 2);
      for (const I of w) {
        const T = _(I), F = m ? T + i : 0, A = h[I] - T, $ = h[I] + T;
        let D = 2;
        x.queryInterval(A - i, $ + i, ([, , S]) => {
          const M = b[S] - F, B = h[I] - h[S], N = i + (d ? d[I] + d[S] : 2 * p), L = Math.sqrt(N * N - B * B);
          v[D++] = M - L, v[D++] = M + L;
        });
        let O = v.slice(0, D);
        m && (O = O.filter((S) => S >= 0));
        t:
          for (const S of O.sort(y)) {
            for (let M = 0; M < D; M += 2)
              if (v[M] + 1e-6 < S && S < v[M + 1] - 1e-6)
                continue t;
            b[I] = S + F;
            break;
          }
        x.insert([A, $, I]);
      }
    }
    m || (m = 1);
    for (const w of a)
      for (const x of w)
        b[x] = b[x] * m + 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 EX(e, t) {
  return Math.abs(e) - Math.abs(t);
}
function OX(e, t) {
  return e - t;
}
function LX(e, t) {
  return arguments.length === 1 && ({ basis: e, ...t } = e), U_(K_(e), t);
}
function RX(e, t) {
  return arguments.length === 1 && ({ basis: e, ...t } = e), z_(K_(e), t);
}
function K_(e) {
  if (e === void 0)
    return Xx;
  if (typeof e == "function")
    return m0(Ub(e));
  if (/^p\d{2}$/i.test(e))
    return ol(Rb(e));
  switch (`${e}`.toLowerCase()) {
    case "deviation":
      return UX;
    case "first":
      return Xx;
    case "last":
      return kX;
    case "max":
      return zX;
    case "mean":
      return PX;
    case "median":
      return VX;
    case "min":
      return jX;
    case "sum":
      return YX;
    case "extent":
      return CX;
  }
  throw new Error(`invalid basis: ${e}`);
}
function m0(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 ol(e) {
  return m0((t, n) => e(t, (i) => n[i]));
}
const CX = {
  mapIndex(e, t, n) {
    const [i, r] = je(e, (o) => t[o]), s = r - i;
    for (const o of e)
      n[o] = t[o] === null ? NaN : (t[o] - i) / s;
  }
}, Xx = m0((e, t) => {
  for (let n = 0; n < e.length; ++n) {
    const i = t[e[n]];
    if (cn(i))
      return i;
  }
}), kX = m0((e, t) => {
  for (let n = e.length - 1; n >= 0; --n) {
    const i = t[e[n]];
    if (cn(i))
      return i;
  }
}), UX = {
  mapIndex(e, t, n) {
    const i = rb(e, (s) => t[s]), r = py(e, (s) => t[s]);
    for (const s of e)
      n[s] = t[s] === null ? NaN : r ? (t[s] - i) / r : 0;
  }
}, zX = ol(Se), PX = ol(rb), VX = ol(_c), jX = ol(ze), YX = ol(sr);
function qX(e = {}, t) {
  return arguments.length === 1 && (t = e), U_(Z_(e), t);
}
function WX(e = {}, t) {
  return arguments.length === 1 && (t = e), z_(Z_(e), t);
}
function Z_(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 = XX(i), Fs(`Warning: the shift option is deprecated; please use anchor "${r}" instead.`)), !((t = Math.floor(t)) > 0))
    throw new Error(`invalid k: ${t}`);
  return HX(n)(t, GX(r, t), s);
}
function GX(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 XX(e) {
  switch (`${e}`.toLowerCase()) {
    case "centered":
      return "middle";
    case "leading":
      return "start";
    case "trailing":
      return "end";
  }
  throw new Error(`invalid shift: ${e}`);
}
function HX(e = "mean") {
  if (typeof e == "string") {
    if (/^p\d{2}$/i.test(e))
      return ah(Rb(e));
    switch (e.toLowerCase()) {
      case "deviation":
        return ah(py);
      case "max":
        return ch((t, n) => Se(t, (i) => n[i]));
      case "mean":
        return KX;
      case "median":
        return ah(_c);
      case "min":
        return ch((t, n) => ze(t, (i) => n[i]));
      case "mode":
        return ch((t, n) => X3(t, (i) => n[i]));
      case "sum":
        return q8;
      case "variance":
        return ah(J1);
      case "difference":
        return QX;
      case "ratio":
        return tH;
      case "first":
        return eH;
      case "last":
        return nH;
    }
  }
  if (typeof e != "function")
    throw new Error(`invalid reduce: ${e}`);
  return ch(Ub(e));
}
function ah(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(jo(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(jo(r, 0, c + t), a);
      for (let c = 0, l = r.length - n; c < l; ++c)
        o[r[c + n]] = e(jo(r, c, c + t), a);
    }
  };
}
function ch(e) {
  return (t, n, i) => i ? {
    mapIndex(r, s, o) {
      let a = 0;
      for (let c = 0; c < t - 1; ++c)
        a += cn(s[r[c]]);
      for (let c = 0, l = r.length - t + 1; c < l; ++c)
        a += cn(s[r[c + t - 1]]), a === t && (o[r[c + n]] = e(jo(r, c, c + t), s)), a -= cn(s[r[c]]);
    }
  } : {
    mapIndex(r, s, o) {
      for (let a = -n; a < 0; ++a)
        o[r[a + n]] = e(jo(r, 0, a + t), s);
      for (let a = 0, c = r.length - n; a < c; ++a)
        o[r[a + n]] = e(jo(r, a, a + t), s);
    }
  };
}
function q8(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 KX(e, t, n) {
  if (n) {
    const i = q8(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 ZX(e, t, n, i) {
  for (let r = n + i; n < r; ++n) {
    const s = e[t[n]];
    if (cn(s))
      return s;
  }
}
function JX(e, t, n, i) {
  for (let r = n + i - 1; r >= n; --r) {
    const s = e[t[r]];
    if (cn(s))
      return s;
  }
}
function W8(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 G8(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 QX(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]] = G8(r, i, o, e) - W8(r, i, o, e);
    }
  };
}
function tH(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]] = G8(r, i, o, e) / W8(r, i, o, e);
    }
  };
}
function eH(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]] = ZX(r, i, o, e);
    }
  };
}
function nH(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]] = JX(r, i, o, e);
    }
  };
}
function iH(e, t = {}) {
  if (typeof e == "string")
    switch (e.toLowerCase()) {
      case "first":
        return X8(t);
      case "last":
        return H8(t);
    }
  if (typeof e == "function")
    return Ys(null, e, t);
  let n, i;
  for (n in e) {
    if (i !== void 0)
      throw new Error("ambiguous selector; multiple inputs");
    i = rH(e[n]);
  }
  if (i === void 0)
    throw new Error(`invalid selector: ${e}`);
  return Ys(n, i, t);
}
function rH(e) {
  if (typeof e == "function")
    return e;
  switch (`${e}`.toLowerCase()) {
    case "min":
      return J_;
    case "max":
      return Q_;
  }
  throw new Error(`unknown selector: ${e}`);
}
function X8(e) {
  return Ys(null, lH, e);
}
function H8(e) {
  return Ys(null, uH, e);
}
function sH(e) {
  return Ys("x", J_, e);
}
function oH(e) {
  return Ys("y", J_, e);
}
function aH(e) {
  return Ys("x", Q_, e);
}
function cH(e) {
  return Ys("y", Q_, e);
}
function* lH(e) {
  yield e[0];
}
function* uH(e) {
  yield e[e.length - 1];
}
function* J_(e, t) {
  yield EL(e, (n) => t[n]);
}
function* Q_(e, t) {
  yield ib(e, (n) => t[n]);
}
function Ys(e, t, n) {
  if (e != null) {
    if (n[e] == null)
      throw new Error(`missing channel: ${e}`);
    e = n[e];
  }
  const i = no(n);
  return pr(n, (r, s) => {
    const o = Ot(r, i), a = Ot(r, e), c = [];
    for (const l of s) {
      const u = [];
      for (const f of o ? os(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 Hx = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  Area: f0,
  Arrow: JT,
  BarX: t8,
  BarY: e8,
  Cell: h0,
  Contour: _8,
  Density: x8,
  Dot: d0,
  Frame: ET,
  Geo: S8,
  Hexgrid: I8,
  Image: A8,
  Line: p0,
  Link: KT,
  Mark: ce,
  Raster: h8,
  Rect: y0,
  RuleX: W4,
  RuleY: G4,
  Text: a0,
  TickX: r8,
  TickY: s8,
  Tip: OT,
  Vector: c0,
  area: xW,
  areaX: _p,
  areaY: Eu,
  arrow: $W,
  auto: UW,
  autoSpec: n8,
  axisFx: mT,
  axisFy: yT,
  axisX: w_,
  axisY: __,
  barX: tc,
  barY: ec,
  bin: To,
  binX: Is,
  binY: As,
  boxX: XW,
  boxY: HW,
  cell: vp,
  cellX: BW,
  cellY: NW,
  centroid: hX,
  circle: OW,
  cluster: fX,
  column: Fn,
  contour: lG,
  crosshair: fG,
  crosshairX: hG,
  crosshairY: dG,
  delaunayLink: MG,
  delaunayMesh: $G,
  density: DG,
  dodgeX: FX,
  dodgeY: DX,
  dot: so,
  dotX: DW,
  dotY: EW,
  filter: KV,
  formatIsoDate: $4,
  formatMonth: uY,
  formatWeekday: fY,
  frame: x_,
  geo: q_,
  geoCentroid: dX,
  graticule: kG,
  gridFx: xT,
  gridFy: wT,
  gridX: vT,
  gridY: _T,
  group: Hb,
  groupX: Bu,
  groupY: Nu,
  groupZ: Xb,
  hexagon: LW,
  hexbin: UG,
  hexgrid: VG,
  hull: TG,
  identity: ct,
  image: GG,
  indexOf: In,
  initializer: vn,
  interpolateNearest: g8,
  interpolateNone: Qg,
  interpolatorBarycentric: m8,
  interpolatorRandomWalk: b8,
  legend: bq,
  line: C_,
  lineX: xp,
  lineY: Sp,
  linearRegressionX: eX,
  linearRegressionY: nX,
  link: ZT,
  map: gf,
  mapX: U_,
  mapY: z_,
  marks: es,
  normalize: K_,
  normalizeX: LX,
  normalizeY: RX,
  plot: S_,
  pointer: p_,
  pointerX: y_,
  pointerY: m_,
  raster: ZW,
  rect: k_,
  rectX: eu,
  rectY: nu,
  reverse: ZV,
  ruleX: Vs,
  ruleY: js,
  scale: ea,
  select: iH,
  selectFirst: X8,
  selectLast: H8,
  selectMaxX: aH,
  selectMaxY: cH,
  selectMinX: sH,
  selectMinY: oH,
  shuffle: JV,
  sort: J$,
  sphere: CG,
  spike: sq,
  stackX: YT,
  stackX1: oW,
  stackX2: aW,
  stackY: qT,
  stackY1: cW,
  stackY2: lW,
  text: Dc,
  textX: Z4,
  textY: J4,
  tickX: o8,
  tickY: a8,
  tip: LT,
  transform: pr,
  tree: C8,
  treeLink: T8,
  treeNode: t1,
  valueof: Ot,
  vector: cT,
  vectorX: lT,
  vectorY: uT,
  voronoi: BG,
  voronoiMesh: NG,
  window: Z_,
  windowX: qX,
  windowY: WX
}, Symbol.toStringTag, { value: "Module" })), fH = /* @__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"],
  ["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"],
  ["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"],
  ["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"],
  ["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"],
  ["rScale", "r.type"],
  ["rDomain", "r.domain"],
  ["rRange", "r.range"],
  ["rClamp", "r.clamp"],
  ["rNice", "r.nice"],
  ["rZero", "r.zero"],
  ["lengthScale", "length.type"],
  ["lengthDomain", "length.domain"],
  ["lengthRange", "length.range"],
  ["lengthClamp", "length.clamp"],
  ["lengthNice", "length.nice"],
  ["lengthZero", "length.zero"],
  ["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"]
]), hH = /* @__PURE__ */ new Set([
  "frame",
  "hexgrid",
  "sphere",
  "graticule"
]);
function dH(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] = {});
  }
}
async function pH(e) {
  const t = { marks: [] }, n = [], { attributes: i, marks: r } = e;
  for (const a in i) {
    const c = fH.get(a);
    if (c == null)
      throw new Error(`Unrecognized plot attribute: ${a}`);
    const l = i[a];
    typeof l == "symbol" ? n.push(a) : l !== void 0 && dH(t, c.split("."), l);
  }
  const s = [];
  for (const a of r)
    for (const { type: c, data: l, options: u } of a.plotSpecs())
      hH.has(c) ? t.marks.push(Hx[c](u)) : t.marks.push(Hx[c](l, u)), s.push(a.index);
  mH(t, e);
  const o = S_(t);
  gH(o, s), yH(e, o, i, n);
  for (const a of e.interactors)
    await a.init(o);
  return o;
}
function yH(e, t, n, i) {
  i.forEach((r) => {
    const s = n[r];
    if (s === Z1) {
      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 mH(e, t) {
  const { marks: n } = t;
  lh("x", e, n, ["x", "x1", "x2"]), lh("y", e, n, ["y", "y1", "y2"]), lh("fx", e, n), lh("fy", e, n);
}
function lh(e, t, n, i = [e]) {
  const r = t[e] || {};
  if (r.axis === null || r.label !== void 0)
    return;
  const s = n.map((u) => {
    var f;
    return (f = u.channelField(i)) == null ? void 0 : f.field;
  });
  if (s.every((u) => u == null))
    return;
  let o, a, c;
  for (let u = 0; u < s.length; ++u) {
    const { column: f, label: h } = s[u] || {};
    f === void 0 && h === void 0 || (o === void 0 && a === void 0 ? (o = f, a = h, c = bH(n[u].data, i) || "number") : a !== h ? a = void 0 : o !== f && (o = void 0));
  }
  let l = a || o;
  if (l !== void 0) {
    if ((c === "number" || c === "date") && (e === "x" || e === "y")) {
      r.percent && (l = `${l} (%)`);
      const u = (e === "x" ? 1 : -1) * (r.reverse ? -1 : 1);
      e === "x" || r.labelAnchor === "center" ? l = e === "x" == u < 0 ? `← ${l}` : `${l} →` : l = `${u < 0 ? "↑ " : "↓ "}${l}`;
    }
    t[e] = { ...r, label: l };
  }
}
function gH(e, t) {
  const n = e.querySelectorAll('g[aria-label="facet"]');
  if (n.length)
    for (const i of n)
      Kx(i, t);
  else
    Kx(e, t);
}
function Kx(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 bH(e, t) {
  for (const n of e)
    for (let i = 0; i < t.length; ++i) {
      const r = n[t[i]];
      if (r != null)
        return r instanceof Date ? "date" : typeof r;
    }
}
const _H = {
  width: 640,
  marginLeft: 40,
  marginRight: 20,
  marginTop: 20,
  marginBottom: 30
};
class wH {
  constructor(t) {
    this.attributes = { ..._H }, 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 = U5();
  }
  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() {
    const { top: t, bottom: n } = this.margins();
    return this.getAttribute("height") - t - n;
  }
  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 pH(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 D3(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 vH(...e) {
  const t = new wH();
  return e.flat().forEach((n) => n(t)), t.marks.forEach((n) => qn().connect(n)), t.element;
}
class xH 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 tw = new xH();
function SH(e) {
  return (t) => tw.set(e, t);
}
function K8(e, t, n) {
  Ns(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 Z8(e, t) {
  return (n) => {
    K8(n, e, t);
  };
}
function ew(e) {
  return (t) => {
    for (const [n, i] of Object.entries(e))
      K8(t, n, i);
  };
}
function IH(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), ew(s);
}
function AH(e) {
  return ew({ xDomain: e, yDomain: e });
}
const E = (e) => (t) => Z8(e, t), MH = E("style"), $H = E("width"), TH = E("height"), BH = E("margin"), NH = E("marginLeft"), FH = E("marginRight"), DH = E("marginTop"), EH = E("marginBottom"), OH = E("align"), LH = E("aspectRatio"), RH = E("axis"), CH = E("inset"), kH = E("grid"), UH = E("label"), zH = E("padding"), PH = E("round"), VH = E("xScale"), jH = E("xDomain"), YH = E("xRange"), qH = E("xNice"), WH = E("xInset"), GH = E("xInsetLeft"), XH = E("xInsetRight"), HH = E("xClamp"), KH = E("xRound"), ZH = E("xAlign"), JH = E("xPadding"), QH = E("xPaddingInner"), tK = E("xPaddingOuter"), eK = E("xAxis"), nK = E("xTicks"), iK = E("xTickSize"), rK = E("xTickSpacing"), sK = E("xTickPadding"), oK = E("xTickFormat"), aK = E("xTickRotate"), cK = E("xGrid"), lK = E("xLine"), uK = E("xLabel"), fK = E("xLabelAnchor"), hK = E("xLabelOffset"), dK = E("xFontVariant"), pK = E("xAriaLabel"), yK = E("xAriaDescription"), mK = E("xReverse"), gK = E("xZero"), bK = E("yScale"), _K = E("yDomain"), wK = E("yRange"), vK = E("yNice"), xK = E("yInset"), SK = E("yInsetTop"), IK = E("yInsetBottom"), AK = E("yClamp"), MK = E("yRound"), $K = E("yAlign"), TK = E("yPadding"), BK = E("yPaddingInner"), NK = E("yPaddingOuter"), FK = E("yAxis"), DK = E("yTicks"), EK = E("yTickSize"), OK = E("yTickSpacing"), LK = E("yTickPadding"), RK = E("yTickFormat"), CK = E("yTickRotate"), kK = E("yGrid"), UK = E("yLine"), zK = E("yLabel"), PK = E("yLabelAnchor"), VK = E("yLabelOffset"), jK = E("yFontVariant"), YK = E("yAriaLabel"), qK = E("yAriaDescription"), WK = E("yReverse"), GK = E("yZero"), XK = E("facetMargin"), HK = E("facetMarginTop"), KK = E("facetMarginBottom"), ZK = E("facetMarginLeft"), JK = E("facetMarginRight"), QK = E("facetGrid"), tZ = E("facetLabel"), eZ = E("fxDomain"), nZ = E("fxRange"), iZ = E("fxNice"), rZ = E("fxInset"), sZ = E("fxInsetLeft"), oZ = E("fxInsetRight"), aZ = E("fxRound"), cZ = E("fxAlign"), lZ = E("fxPadding"), uZ = E("fxPaddingInner"), fZ = E("fxPaddingOuter"), hZ = E("fxAxis"), dZ = E("fxTicks"), pZ = E("fxTickSize"), yZ = E("fxTickSpacing"), mZ = E("fxTickPadding"), gZ = E("fxTickFormat"), bZ = E("fxTickRotate"), _Z = E("fxGrid"), wZ = E("fxLine"), vZ = E("fxLabel"), xZ = E("fxLabelAnchor"), SZ = E("fxLabelOffset"), IZ = E("fxFontVariant"), AZ = E("fxAriaLabel"), MZ = E("fxAriaDescription"), $Z = E("fxReverse"), TZ = E("fyDomain"), BZ = E("fyRange"), NZ = E("fyNice"), FZ = E("fyInset"), DZ = E("fyInsetTop"), EZ = E("fyInsetBottom"), OZ = E("fyRound"), LZ = E("fyAlign"), RZ = E("fyPadding"), CZ = E("fyPaddingInner"), kZ = E("fyPaddingOuter"), UZ = E("fyAxis"), zZ = E("fyTicks"), PZ = E("fyTickSize"), VZ = E("fyTickSpacing"), jZ = E("fyTickPadding"), YZ = E("fyTickFormat"), qZ = E("fyTickRotate"), WZ = E("fyGrid"), GZ = E("fyLine"), XZ = E("fyLabel"), HZ = E("fyLabelAnchor"), KZ = E("fyLabelOffset"), ZZ = E("fyFontVariant"), JZ = E("fyAriaLabel"), QZ = E("fyAriaDescription"), tJ = E("fyReverse"), eJ = E("colorScale"), nJ = E("colorDomain"), iJ = E("colorRange"), rJ = E("colorClamp"), sJ = E("colorNice"), oJ = E("colorScheme"), aJ = E("colorInterpolate"), cJ = E("colorPivot"), lJ = E("colorSymmetric"), uJ = E("colorLabel"), fJ = E("colorReverse"), hJ = E("colorZero"), dJ = E("colorTickFormat"), pJ = E("opacityScale"), yJ = E("opacityDomain"), mJ = E("opacityRange"), gJ = E("opacityClamp"), bJ = E("opacityNice"), _J = E("opacityLabel"), wJ = E("opacityReverse"), vJ = E("opacityZero"), xJ = E("opacityTickFormat"), SJ = E("rScale"), IJ = E("rDomain"), AJ = E("rRange"), MJ = E("rClamp"), $J = E("rNice"), TJ = E("rZero"), BJ = E("lengthScale"), NJ = E("lengthDomain"), FJ = E("lengthRange"), DJ = E("lengthClamp"), EJ = E("lengthNice"), OJ = E("lengthZero"), LJ = E("projectionType"), RJ = E("projectionParallels"), CJ = E("projectionPrecision"), kJ = E("projectionRotate"), UJ = E("projectionDomain"), zJ = E("projectionInset"), PJ = E("projectionInsetLeft"), VJ = E("projectionInsetRight"), jJ = E("projectionInsetTop"), YJ = E("projectionInsetBottom"), qJ = E("projectionClip"), WJ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  align: OH,
  aspectRatio: LH,
  attribute: Z8,
  attributes: ew,
  axis: RH,
  colorClamp: rJ,
  colorDomain: nJ,
  colorInterpolate: aJ,
  colorLabel: uJ,
  colorNice: sJ,
  colorPivot: cJ,
  colorRange: iJ,
  colorReverse: fJ,
  colorScale: eJ,
  colorScheme: oJ,
  colorSymmetric: lJ,
  colorTickFormat: dJ,
  colorZero: hJ,
  facetGrid: QK,
  facetLabel: tZ,
  facetMargin: XK,
  facetMarginBottom: KK,
  facetMarginLeft: ZK,
  facetMarginRight: JK,
  facetMarginTop: HK,
  fxAlign: cZ,
  fxAriaDescription: MZ,
  fxAriaLabel: AZ,
  fxAxis: hZ,
  fxDomain: eZ,
  fxFontVariant: IZ,
  fxGrid: _Z,
  fxInset: rZ,
  fxInsetLeft: sZ,
  fxInsetRight: oZ,
  fxLabel: vZ,
  fxLabelAnchor: xZ,
  fxLabelOffset: SZ,
  fxLine: wZ,
  fxNice: iZ,
  fxPadding: lZ,
  fxPaddingInner: uZ,
  fxPaddingOuter: fZ,
  fxRange: nZ,
  fxReverse: $Z,
  fxRound: aZ,
  fxTickFormat: gZ,
  fxTickPadding: mZ,
  fxTickRotate: bZ,
  fxTickSize: pZ,
  fxTickSpacing: yZ,
  fxTicks: dZ,
  fyAlign: LZ,
  fyAriaDescription: QZ,
  fyAriaLabel: JZ,
  fyAxis: UZ,
  fyDomain: TZ,
  fyFontVariant: ZZ,
  fyGrid: WZ,
  fyInset: FZ,
  fyInsetBottom: EZ,
  fyInsetTop: DZ,
  fyLabel: XZ,
  fyLabelAnchor: HZ,
  fyLabelOffset: KZ,
  fyLine: GZ,
  fyNice: NZ,
  fyPadding: RZ,
  fyPaddingInner: CZ,
  fyPaddingOuter: kZ,
  fyRange: BZ,
  fyReverse: tJ,
  fyRound: OZ,
  fyTickFormat: YZ,
  fyTickPadding: jZ,
  fyTickRotate: qZ,
  fyTickSize: PZ,
  fyTickSpacing: VZ,
  fyTicks: zZ,
  grid: kH,
  height: TH,
  inset: CH,
  label: UH,
  lengthClamp: DJ,
  lengthDomain: NJ,
  lengthNice: EJ,
  lengthRange: FJ,
  lengthScale: BJ,
  lengthZero: OJ,
  margin: BH,
  marginBottom: EH,
  marginLeft: NH,
  marginRight: FH,
  marginTop: DH,
  margins: IH,
  name: SH,
  opacityClamp: gJ,
  opacityDomain: yJ,
  opacityLabel: _J,
  opacityNice: bJ,
  opacityRange: mJ,
  opacityReverse: wJ,
  opacityScale: pJ,
  opacityTickFormat: xJ,
  opacityZero: vJ,
  padding: zH,
  projectionClip: qJ,
  projectionDomain: UJ,
  projectionInset: zJ,
  projectionInsetBottom: YJ,
  projectionInsetLeft: PJ,
  projectionInsetRight: VJ,
  projectionInsetTop: jJ,
  projectionParallels: RJ,
  projectionPrecision: CJ,
  projectionRotate: kJ,
  projectionType: LJ,
  rClamp: MJ,
  rDomain: IJ,
  rNice: $J,
  rRange: AJ,
  rScale: SJ,
  rZero: TJ,
  round: PH,
  style: MH,
  width: $H,
  xAlign: ZH,
  xAriaDescription: yK,
  xAriaLabel: pK,
  xAxis: eK,
  xClamp: HH,
  xDomain: jH,
  xFontVariant: dK,
  xGrid: cK,
  xInset: WH,
  xInsetLeft: GH,
  xInsetRight: XH,
  xLabel: uK,
  xLabelAnchor: fK,
  xLabelOffset: hK,
  xLine: lK,
  xNice: qH,
  xPadding: JH,
  xPaddingInner: QH,
  xPaddingOuter: tK,
  xRange: YH,
  xReverse: mK,
  xRound: KH,
  xScale: VH,
  xTickFormat: oK,
  xTickPadding: sK,
  xTickRotate: aK,
  xTickSize: iK,
  xTickSpacing: rK,
  xTicks: nK,
  xZero: gK,
  xyDomain: AH,
  yAlign: $K,
  yAriaDescription: qK,
  yAriaLabel: YK,
  yAxis: FK,
  yClamp: AK,
  yDomain: _K,
  yFontVariant: jK,
  yGrid: kK,
  yInset: xK,
  yInsetBottom: IK,
  yInsetTop: SK,
  yLabel: zK,
  yLabelAnchor: PK,
  yLabelOffset: VK,
  yLine: UK,
  yNice: vK,
  yPadding: TK,
  yPaddingInner: BK,
  yPaddingOuter: NK,
  yRange: wK,
  yReverse: WK,
  yRound: MK,
  yScale: bK,
  yTickFormat: RK,
  yTickPadding: LK,
  yTickRotate: CK,
  yTickSize: EK,
  yTickSpacing: OK,
  yTicks: DK,
  yZero: GK
}, Symbol.toStringTag, { value: "Module" }));
function GJ(e, t) {
  return { table: e, options: t };
}
function nw(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
  Jr(e) !== null);
}
const XJ = /* @__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"
]);
function HJ(e) {
  return XJ.has(e);
}
const KJ = /* @__PURE__ */ new Set([
  "asterisk",
  "circle",
  "cross",
  "diamond",
  "diamond2",
  "hexagon",
  "plus",
  "square",
  "square2",
  "star",
  "times",
  "triangle",
  "triangle2",
  "wye"
]);
function ZJ(e) {
  return KJ.has(`${e}`.toLowerCase());
}
const J8 = (e) => e === "stroke" || e === "fill", JJ = (e) => e === "symbol", QJ = (e, t) => e !== "sort" && t != null && !Array.isArray(t), Am = (e, t) => ({
  channel: e,
  field: t,
  as: t instanceof Cs ? t.column : e
}), Mm = (e, t) => ({ channel: e, value: t });
class al extends Ku {
  constructor(t, n, i, r = {}) {
    var c;
    super((c = n == null ? void 0 : n.options) == null ? void 0 : c.filterBy), this.type = t, this.reqs = r, this.source = n, Array.isArray(this.source) && (this.data = this.source);
    const s = this.channels = [], o = this.params = /* @__PURE__ */ new Set(), a = (l, u) => {
      const f = typeof u;
      if (f === "function" && u[R3]) {
        const h = u(this, l);
        for (const d in h)
          a(d, h[d]);
      } else if (f === "string")
        HJ(l) || J8(l) && nw(u) || JJ(l) && ZJ(u) ? s.push(Mm(l, u)) : s.push(Am(l, q1(u)));
      else if (mc(u))
        if (Array.isArray(u.columns))
          s.push(Am(l, u)), o.add(u);
        else {
          const h = Mm(l, u.value);
          s.push(h), u.addEventListener("value", (d) => (h.value = d, this.update()));
        }
      else
        f === "object" && QJ(l, u) ? s.push(Am(l, u)) : u !== void 0 && s.push(Mm(l, u));
    };
    for (const l in i)
      a(l, i[l]);
  }
  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 || Array.isArray(this.source);
  }
  channel(t) {
    return this.channels.find((n) => n.channel === t);
  }
  channelField(...t) {
    const n = t.flat();
    for (const i of n) {
      const r = this.channel(i);
      if (r != null && r.field)
        return r;
    }
    return 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) {
      const u = l == null ? void 0 : l.column;
      if (u) {
        if ((s = l.stats) != null && s.length || i[c]) {
          r.has(u) || r.set(u, /* @__PURE__ */ new Set());
          const f = r.get(u);
          (o = i[c]) == null || o.forEach((h) => f.add(h)), (a = l.stats) == null || a.forEach((h) => f.add(h));
        }
      } else
        continue;
    }
    return Array.from(r, ([c, l]) => ({ table: t, column: c, stats: Array.from(l) }));
  }
  fieldInfo(t) {
    return this.stats = t.reduce(
      (n, i) => (n[i.column] = i, n),
      /* @__PURE__ */ Object.create(null)
    ), this;
  }
  query(t = []) {
    if (this.hasOwnData())
      return null;
    const { channels: n, source: { table: i } } = this;
    return Q8(n, i).where(t);
  }
  queryPending() {
    return this.plot.pending(this), this;
  }
  queryResult(t) {
    return this.data = Array.from(t), this;
  }
  update() {
    return this.plot.update(this);
  }
  plotSpecs() {
    const { type: t, data: n, channels: i } = this, r = {};
    for (const s of i)
      r[s.channel] = Ts(s);
    return [{ type: t, data: n, options: r }];
  }
}
function Ts(e) {
  return Object.hasOwn(e, "value") ? e.value : J8(e.channel) ? { value: e.as, scale: "color" } : e.as;
}
function Q8(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 === "order")
        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 qs(e, t, n) {
  if (!e.stats)
    return i;
  const { field: i } = e.channelField(t), { type: r } = e.stats[i.column];
  return n = n ?? i, r === "date" ? $3(n) : n;
}
function a1(e, t, n, i, r = !1, s = 1) {
  const o = (i - s) / (n - t), a = o !== 1 ? ` * ${o}::DOUBLE` : "";
  return r ? q`(${+n} - ${e}::DOUBLE)${a}` : q`(${e}::DOUBLE - ${+t})${a}`;
}
const tB = { x: ["min", "max"] }, eB = { y: ["min", "max"] }, nB = { ...tB, ...eB };
function iB(e, t, n, i, r) {
  const { plot: s, stats: o } = e, a = s.getAttribute(i), c = s.getAttribute(r);
  if (Array.isArray(a) && !a[Wo])
    return a;
  {
    const { field: l } = e.channelField(n), { column: u } = l, { min: f, max: h } = o[u], d = rB(t, u) || (c ? By().domain([f, h]).nice().domain() : [f, h]);
    return a !== Z1 && (d[Wo] = !0), s.setAttribute(i, d, { silent: !0 }), d;
  }
}
function wf(e, t) {
  return iB(e, t, "x", "xDomain", "xNice");
}
function vf(e, t) {
  return iB(e, t, "y", "yDomain", "yNice");
}
function rB(e, t) {
  if (!e)
    return;
  let n, i;
  const r = (s, o) => {
    if (s === "BETWEEN" && o.field.column === 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 tQ extends al {
  constructor(t, n, i) {
    const r = t.endsWith("X") ? "y" : "x", s = { [r]: ["count", "min", "max"] };
    super(t, n, i, s), this.dim = r;
  }
  query(t = []) {
    const { plot: n, dim: i, source: r, stats: s } = this, { optimize: o = !0 } = r.options || {}, { field: a, as: c } = this.channelField(i), l = super.query(t);
    if (o) {
      const { column: u } = a, { count: f, max: h, min: d } = s[u], p = i === "x" ? n.innerWidth() : n.innerHeight(), [m, g] = rB(t, u) || [d, h], y = (g - m) / (h - d);
      if (f * y > p * 4) {
        const b = qs(this, i, c), _ = this.channelField(i === "x" ? "y" : "x").as, w = l.select().map((x) => x.as).filter((x) => x !== c && x !== _);
        return eQ(l, b, c, _, m, g, p, w);
      }
    }
    return l.orderby(c);
  }
}
function eQ(e, t, n, i, r, s, o, a = []) {
  const c = q`FLOOR(${o / (s - r)}::DOUBLE * (${t} - ${+r}::DOUBLE))::INTEGER`, l = (u) => Et.from(e).select(u).groupby(c, a);
  return Et.union(
    l([{ [n]: bc(n), [i]: cv(i, n) }, ...a]),
    l([{ [n]: gc(n), [i]: lv(i, n) }, ...a]),
    l([{ [n]: cv(n, i), [i]: bc(i) }, ...a]),
    l([{ [n]: lv(n, i), [i]: gc(i) }, ...a])
  ).orderby(a, n);
}
function c1(e, t = !1) {
  const n = new Float64Array(5), i = new Float64Array(4);
  nQ(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 nQ(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 iQ(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);
    l1(e, n.subarray(u), i, 1, s, o, a, f);
  }
  for (let l = 0; l < i; ++l) {
    const u = c.subarray(l);
    l1(t, u, r, i, s, o, a, u);
  }
  return c;
}
function l1(e, t, n, i = 1, r = new Float64Array(n), s = new Float64Array(n), o = new Float64Array(5), a = r, c = rQ) {
  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 rQ(e, t, n, i, r, s, o, a, c, l) {
  const u = Math.abs(i) * n, f = i < 0 ? u + i : 0;
  let h, d, p;
  for (d = 0; d < a; ++d)
    for (l[d] = d <= s ? r[d] : 0, p = 1; p <= a && p <= d; ++p)
      l[d] -= o[p] * l[d - p];
  for (p = 0; p < a; ++p)
    for (e[p] = 0, d = 1; d <= p; ++d)
      h = f + i * d, h >= 0 && h < u && (e[p] += l[p - d] * t[h]);
  const m = t[f];
  if (m > 0)
    for (p = 0; p < a; ++p)
      e[p] += l[p] * m;
}
function sQ(e, t) {
  return oB(new Float64Array(e), t);
}
function oQ(e, t, n, i = []) {
  return i.length ? Object.values(aQ(e * t, n, i)) : [{ grid: oB(new Float64Array(e * t), n) }];
}
function sB(e) {
  return typeof e.getChild == "function";
}
function oB(e, t) {
  if (sB(t)) {
    const n = t.numRows;
    if (n === 0)
      return e;
    const i = t.getChild("index").toArray(), r = t.getChild("value").toArray();
    for (let s = 0; s < n; ++s)
      e[i[s]] = r[s];
  } else
    for (const n of t)
      e[n.index] = n.value;
  return e;
}
function aQ(e, t, n) {
  const i = {}, r = (s) => (i[s] || (i[s] = { key: s, grid: new Float64Array(e) })).grid;
  if (sB(t)) {
    const s = t.numRows;
    if (s === 0)
      return i;
    const o = t.getChild("index").toArray(), a = t.getChild("value").toArray(), c = n.map((l) => t.getChild(l));
    for (let l = 0; l < s; ++l) {
      const u = c.map((f) => f.get(l));
      r(u)[o[l]] = a[l];
    }
  } else
    for (const s of t) {
      const o = n.map((a) => s[a]);
      r(o)[s.index] = s.value;
    }
  return i;
}
function Jn(e, t, n, i) {
  Ns(n) ? (i = i || (() => e.requestUpdate()), n.addEventListener("value", (r) => (e[t] = r, i())), e[t] = n.value) : e[t] = n;
}
class aB extends al {
  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" ? tB : eB), this.dim = a, Jn(this, "bins", r), Jn(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[Wo];
  }
  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, a] = this.extent = (r === "x" ? wf : vf)(this, t), c = qs(this, r);
    return cQ(
      Q8(i, s, [r]).where(t.concat(Dn(c, [o, a]))),
      a1(c, o, a, n),
      this.channelField("weight") ? "weight" : null
    );
  }
  queryResult(t) {
    return this.grid = sQ(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 = c1(n * (t - 1) / l, c), f = l1(u, r, t), h = this.data = [], d = i === "x" ? "y" : "x", p = this.channelField(i).as, m = +o, g = (a - m) / (t - 1), y = 1 / g;
    for (let b = 0; b < t; ++b)
      h.push({
        [p]: m + b * g,
        [d]: f[b] * y
      });
    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] = Ts(o);
    return [{ type: t, data: n, options: s }];
  }
}
function cQ(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", value: na("w") }).groupby("index").having(M3("value", 0));
}
class g0 extends al {
  constructor(t, n, i) {
    const {
      bandwidth: r = 20,
      binType: s = "linear",
      binWidth: o = 2,
      binPad: a = 1,
      ...c
    } = i, l = lQ(c);
    super(t, n, c, nB), this.densityMap = l, Jn(this, "bandwidth", r, () => this.grids ? this.convolve().update() : null), Jn(this, "binWidth", o), Jn(this, "binType", s), Jn(this, "binPad", a);
  }
  setPlot(t, n) {
    const i = () => {
      this.stats && 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[Wo] && !n[Wo];
  }
  query(t = []) {
    const { plot: n, binType: i, binPad: r, channels: s, densityMap: o, source: a } = this, [c, l] = this.extentX = wf(this, t), [u, f] = this.extentY = vf(this, t), [h, d] = this.bins = this.binDimensions(this), p = qs(this, "x"), m = qs(this, "y"), g = !!n.getAttribute("xReverse"), y = !!n.getAttribute("yReverse"), b = Zx(p, c, l, h, g, this.binPad), _ = Zx(m, u, f, d, y, this.binPad), w = r ? [Dn(p, [c, l]), Dn(m, [u, f])] : [_d(c, p), bd(p, l), _d(u, m), bd(m, f)], x = Et.from(a.table).where(t.concat(w)), v = this.groupby = [];
    let I = Uo();
    for (const T of s)
      if (Object.hasOwn(T, "field")) {
        const { as: F, channel: A, field: $ } = T;
        $.aggregate ? (I = $, o[A] = !0) : A === "weight" ? I = na($) : A !== "x" && A !== "y" && (x.select({ [F]: $ }), v.push(F));
      }
    return i === "linear" ? fQ(x, b, _, I, h, v) : uQ(x, b, _, I, h, v);
  }
  binDimensions() {
    const { plot: t, binWidth: n } = this;
    return [
      Math.round(t.innerWidth() / n),
      Math.round(t.innerHeight() / n)
    ];
  }
  queryResult(t) {
    const [n, i] = this.bins;
    return this.grids = oQ(n, i, t, this.groupby), this.convolve();
  }
  convolve() {
    const { bandwidth: t, bins: n, grids: i, plot: r } = this;
    if (t <= 0)
      this.kde = this.grids.map(({ key: s, grid: o }) => (o.key = s, o));
    else {
      const s = r.innerWidth(), o = r.innerHeight(), [a, c] = n, l = i.some(({ grid: h }) => h.some((d) => d < 0)), u = c1(t * (a - 1) / s, l), f = c1(t * (c - 1) / o, l);
      this.kde = this.grids.map(({ key: h, grid: d }) => {
        const p = iQ(u, f, d, n);
        return p.key = h, p;
      });
    }
    return this;
  }
  plotSpecs() {
    throw new Error("Unimplemented. Use a Grid2D mark subclass.");
  }
}
function lQ(e) {
  const t = {};
  for (const n in e)
    e[n] === "density" && (delete e[n], t[n] = !0);
  return t;
}
function Zx(e, t, n, i, r, s) {
  const o = (i - s) / (n - t), a = o !== 1 ? ` * ${o}::DOUBLE` : "";
  return r ? q`(${n} - ${e}::DOUBLE)${a}` : q`(${e}::DOUBLE - ${t})${a}`;
}
function uQ(e, t, n, i, r, s) {
  return e.select({
    index: q`FLOOR(${t})::INTEGER + FLOOR(${n})::INTEGER * ${r}`,
    value: i
  }).groupby("index", s);
}
function fQ(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", value: na("w") }, s).groupby("index", s).having(M3("value", 0));
}
class hQ extends g0 {
  constructor(t, n) {
    const { type: i = "dot", binsX: r, binsY: s, ...o } = n;
    o.binPad = o.binPad ?? 0, super(i, t, o), Jn(this, "binsX", r), Jn(this, "binsY", s);
  }
  convolve() {
    super.convolve();
    const { bins: t, binPad: n, extentX: i, extentY: r } = this, [s, o] = t, [a, c] = i, [l, u] = r, f = (c - a) / (s - n), h = (u - l) / (o - n), d = n ? 0 : 0.5;
    return this.data = dQ(this.kde, t, a, l, f, h, d), this;
  }
  binDimensions() {
    const { plot: t, binWidth: n, binsX: i, binsY: r } = this;
    return [
      i ?? Math.round(t.innerWidth() / n),
      r ?? Math.round(t.innerHeight() / n)
    ];
  }
  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 : Ts(o);
    }
    for (const o in i)
      i[o] && (s[o] = "density");
    return [{ type: t, data: r, options: s }];
  }
}
function dQ(e, t, n, i, r, s, o) {
  const a = 1 / (r * s), [c, l] = t, u = [];
  for (const f of e)
    for (let h = 0, d = 0; d < l; ++d)
      for (let p = 0; p < c; ++p, ++h)
        u.push({
          x: n + (p + o) * r,
          y: i + (d + o) * s,
          density: f[h] * a
        });
  return u;
}
function cB(e, t, n, i, r, s) {
  const o = (s.length >> 2) - 1;
  for (let a = 0, c = 0; a < i; ++a)
    for (let l = 0, u = (i - a - 1) * n; l < n; ++l, c += 4) {
      const f = o * r(e[l + u]) << 2;
      t[c + 0] = s[f + 0], t[c + 1] = s[f + 1], t[c + 2] = s[f + 2], t[c + 3] = s[f + 3];
    }
}
function $p(e, t) {
  const n = new Uint8ClampedArray(4 * e), i = e - 1;
  for (let r = 0; r <= i; ++r) {
    const s = t(r / i), { r: o, g: a, b: c, opacity: l = 1 } = typeof s == "string" ? ei(s) : s, u = r << 2;
    n[u + 0] = o, n[u + 1] = a, n[u + 2] = c, n[u + 3] = 255 * l | 0;
  }
  return n;
}
function lB(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 uB(e = "black") {
  const { r: t, g: n, b: i } = ei(e);
  return (r) => ({ r: t, g: n, b: i, opacity: r });
}
class fB extends g0 {
  constructor(t, n) {
    super("image", t, n);
  }
  setPlot(t, n) {
    const i = () => {
      this.stats && this.rasterize();
    };
    t.addAttributeListener("schemeColor", i), super.setPlot(t, n);
  }
  convolve() {
    return super.convolve().rasterize();
  }
  rasterize() {
    var h;
    const { bins: t, kde: n, groupby: i } = this, [r, s] = t, { canvas: o, ctx: a, img: c } = pQ(this, r, s), l = yQ(this), u = i.indexOf((h = this.channelField("fill")) == null ? void 0 : h.as), f = u < 0 ? [] : n.map(({ key: d }) => d[u]);
    return this.data = n.map((d) => {
      var m;
      const p = mQ(this, f, (m = d.key) == null ? void 0 : m[u]);
      return cB(d, c.data, r, s, l, p), a.putImageData(c, 0, 0), { src: o.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 }];
  }
}
function pQ(e, t, n) {
  if (!e.image || e.image.w !== t || e.image.h !== n) {
    const i = lB(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 yQ(e) {
  const { densityMap: t, kde: n, plot: i } = e;
  let r = t.fill && i.getAttribute("colorDomain");
  if (!r) {
    let o = 0, a = 0;
    n.forEach((c) => {
      for (const l of c)
        l < o && (o = l), l > a && (a = l);
    }), r = o === 0 && a === 0 ? [0, 1] : [o, a];
  }
  const s = i.getAttribute("colorScale");
  return ea({ x: { type: s, domain: r, range: [0, 1] } }).apply;
}
function mQ(e, t, n, i = 1024) {
  const { densityMap: r, plot: s } = e, o = s.getAttribute("colorScheme");
  let a;
  if (r.fill) {
    if (o)
      try {
        return $p(
          i,
          ea({ color: { scheme: o, domain: [0, 1] } }).interpolate
        );
      } catch (c) {
        console.warn(c);
      }
  } else if (t.length) {
    const c = s.getAttribute("colorRange");
    a = ea({ color: {
      domain: t,
      range: c,
      scheme: o || (c ? void 0 : "tableau10")
    } }).apply(n);
  } else {
    const c = e.channelField("fill");
    a = nw(c == null ? void 0 : c.value) ? c.value : void 0;
  }
  return $p(i, uB(a));
}
class gQ extends fB {
  constructor(t, n) {
    const { normalize: i = !0, ...r } = n;
    super(t, { bandwidth: 0, ...r }), Jn(this, "normalize", i);
  }
  query(t = []) {
    const { plot: n, channels: i, normalize: r, source: s } = this, [o, a] = wf(this, t), [c, l] = vf(this, t), [u, f] = this.bins = this.binDimensions(this), h = qs(this, "x"), d = qs(this, "y"), p = !!n.getAttribute("xReverse"), m = !!n.getAttribute("yReverse"), g = a1(h, o, a, u, p, this.binPad), y = a1(d, c, l, f, m, this.binPad), b = Et.from(s.table).where(bQ(this, t)), _ = this.groupby = [], w = [];
    for (const x of i)
      if (Object.hasOwn(x, "field")) {
        const { channel: v, field: I } = x;
        v === "z" ? (b.select({ [v]: I }), w.push("z")) : v !== "x" && v !== "y" && (b.select({ [v]: I }), _.push(v));
      }
    return _Q(b, g, y, w, u, f, _, r);
  }
}
function bQ(e, t) {
  if (Array.isArray(t) && !t.length)
    return t;
  const n = e.channelField("x").field.column, i = e.channelField("y").field.column, r = (o) => o.op !== "BETWEEN" || o.field.column !== n && o.field.column !== i, s = (o) => o.op === "AND" ? Yo(o.children.filter((a) => r(a))) : o;
  return Array.isArray(t) ? t.filter((o) => r(o)).map((o) => s(o)) : s(t);
}
function _Q(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(Yo(
    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(A3("dx"))
  ), p = ["x"].concat(c).join(", "), m = Et.from("raster").select(
    c,
    "x",
    "y",
    a ? { w: q`1.0 / COUNT(*) OVER (PARTITION BY ${p})` } : null
  ).where(Yo(Dn("x", [0, r]), Dn("y", [0, s])));
  return Et.with({ pairs: u, indices: h, raster: d, points: m }).from("points").select(o, {
    index: q`x + y * ${r}::INTEGER`,
    value: a ? na("w") : Uo()
  }).groupby("index", o);
}
class wQ extends g0 {
  constructor(t, n) {
    const { thresholds: i = 10, ...r } = n;
    super("geo", t, r), Jn(this, "thresholds", i, () => this.grids ? this.contours().update() : null);
  }
  convolve() {
    return super.convolve().contours();
  }
  contours() {
    const { bins: t, densityMap: n, kde: i, thresholds: r, groupby: s, plot: o } = this;
    let a = r;
    if (!Array.isArray(a)) {
      const x = Se(i.map((v) => Se(v)));
      a = Array.from({ length: a - 1 }, (v, I) => x * (I + 1) / a);
    }
    (n.fill || n.stroke) && this.plot.getAttribute("colorScale") !== "log" && this.plot.setAttribute("colorZero", !0);
    const [c, l] = t, [u, f] = o.getAttribute("xDomain"), [h, d] = o.getAttribute("yDomain"), p = (f - u) / c, m = (d - h) / l, g = +u, y = +h, b = (x) => g + x * p, _ = (x) => y + x * m, w = Bd().size(t);
    return this.data = i.flatMap((x) => a.map((v) => {
      const I = vQ(w.contour(x, v), b, _);
      return s.forEach((T, F) => I[T] = x.key[F]), I.density = v, I;
    })), 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] = Ts(o));
    }
    return i.fill && (s.fill = "density"), i.stroke && (s.stroke = "density"), [{ type: t, data: r, options: s }];
  }
}
function vQ(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;
}
class xQ extends al {
  constructor(t, n) {
    const { type: i = "hexagon", binWidth: r = 20, ...s } = n;
    super(i, t, { r: r / 2, clip: !0, ...s }, nB), this.binWidth = r;
  }
  get filterIndexable() {
    const t = this.plot.getAttribute("xDomain"), n = this.plot.getAttribute("yDomain");
    return t && n && !t[Wo] && !n[Wo];
  }
  query(t = []) {
    if (this.hasOwnData())
      return null;
    const { plot: n, binWidth: i, channels: r, source: s } = this, [o, a] = wf(this, t), [c, l] = vf(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`, m = `${n.innerHeight() / (l - c)}::DOUBLE`;
    let g, y;
    const b = /* @__PURE__ */ new Set(), _ = {};
    for (const T of r)
      T.channel === "order" ? w.orderby(T.value) : T.channel === "x" ? g = T : T.channel === "y" ? y = T : Object.hasOwn(T, "field") && (_[T.as] = T.field, T.field.aggregate && T.field.columns.forEach((F) => b.add(F)));
    const w = Et.select({
      [g.as]: q`${o}::DOUBLE + ((x + 0.5 * (y & 1)) * ${h} + ${u})::DOUBLE / ${p}`,
      [y.as]: q`${l}::DOUBLE - (y * ${d} + ${f})::DOUBLE / ${m}`,
      ..._
    }).groupby("x", "y"), x = `${p} * (${g.field} - ${o}::DOUBLE)`, v = `${m} * (${l}::DOUBLE - ${y.field})`, I = Et.select({
      py: q`(${v} - ${f}) / ${d}`,
      pj: q`ROUND(py)::INTEGER`,
      px: q`(${x} - ${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(gd(g.field), gd(y.field), t);
    return w.from(I);
  }
}
class SQ extends g0 {
  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.stats && this.rasterize();
    };
    t.addAttributeListener("schemeColor", i), super.setPlot(t, n);
  }
  requestQuery() {
    return this.requestTiles();
  }
  query(t = []) {
    return this._filter = t, null;
  }
  tileQuery(t) {
    const { plot: n, binType: i, binPad: r, channels: s, densityMap: o, source: a } = this, [[c, l], [u, f]] = t, [h, d] = this.bins, p = qs(this, "x"), m = qs(this, "y"), g = !!n.getAttribute("xReverse"), y = !!n.getAttribute("yReverse"), b = Jx(p, c, l, h, g, r), _ = Jx(m, u, f, d, y, r), w = r ? [Dn(p, [c, l]), Dn(m, [u, f])] : [_d(c, p), bd(p, l), _d(u, m), bd(m, f)], x = Et.from(a.table).where(w), v = this.groupby = [];
    let I = Uo();
    for (const T of s)
      if (Object.hasOwn(T, "field")) {
        const { channel: F, field: A } = T;
        A.aggregate ? (I = A, o[F] = !0) : F === "weight" ? I = na(A) : F !== "x" && F !== "y" && (x.select({ [F]: A }), v.push(F));
      }
    return i === "linear" ? NQ(x, b, _, I, h, v) : BQ(x, b, _, I, h, v);
  }
  async requestTiles() {
    const t = qn();
    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] = wf(this, this._filter), [f, h] = vf(this, this._filter), d = u - l, p = h - f, m = Math.floor((l - s) * (a - n) / d), g = Math.floor((f - o) * (c - n) / p), y = (A, $) => [
      [s + A * d, s + (A + 1) * d],
      [o + $ * p, o + ($ + 1) * p]
    ], b = Math.floor((l - s) / d), _ = i ? Qx((u - s) / d) : b, w = Math.floor((f - o) / p), x = r ? Qx((h - o) / p) : w, v = [];
    for (let A = b; A <= _; ++A)
      for (let $ = w; $ <= x; ++$)
        v.push([A, $]);
    const I = v.map(
      ([A, $]) => t.query(this.tileQuery(y(A, $)))
    ), T = [];
    if (i)
      for (let A = w; A <= x; ++A)
        T.push([_ + 1, A]), T.push([b - 1, A]);
    if (r) {
      const A = i ? b - 1 : b, $ = i ? _ + 1 : _;
      for (let D = A; D <= $; ++D)
        T.push([D, x + 1]), T.push([D, w - 1]);
    }
    this.prefetch = T.map(
      ([A, $]) => t.prefetch(this.tileQuery(y(A, $)))
    );
    const F = await Promise.all(I);
    this.grids = [{ grid: IQ(a, c, m, g, v, F) }], this.convolve().update();
  }
  convolve() {
    return super.convolve().rasterize();
  }
  rasterize() {
    var h;
    const { bins: t, kde: n, groupby: i } = this, [r, s] = t, { canvas: o, ctx: a, img: c } = MQ(this, r, s), l = $Q(this), u = i.indexOf((h = this.channelField("fill")) == null ? void 0 : h.as), f = u < 0 ? [] : n.map(({ key: d }) => d[u]);
    return this.data = n.map((d) => {
      var m;
      const p = TQ(this, f, (m = d.key) == null ? void 0 : m[u]);
      return cB(d, c.data, r, s, l, p), a.putImageData(c, 0, 0), { src: o.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 IQ(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;
    AQ(e, t, o, a, f, h);
  }), o;
}
function AQ(e, t, n, i, r, s) {
  const o = i.numRows;
  if (o === 0)
    return;
  const a = i.getChild("index").toArray(), c = i.getChild("value").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 MQ(e, t, n) {
  if (!e.image || e.image.w !== t || e.image.h !== n) {
    const i = lB(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 $Q(e) {
  const { densityMap: t, kde: n, plot: i } = e;
  let r = t.fill && i.getAttribute("colorDomain");
  if (!r) {
    let o = 0, a = 0;
    n.forEach((c) => {
      for (const l of c)
        l < o && (o = l), l > a && (a = l);
    }), r = o === 0 && a === 0 ? [0, 1] : [o, a];
  }
  const s = i.getAttribute("colorScale");
  return ea({ x: { type: s, domain: r, range: [0, 1] } }).apply;
}
function TQ(e, t, n, i = 1024) {
  const { densityMap: r, plot: s } = e, o = s.getAttribute("colorScheme");
  let a;
  if (r.fill) {
    if (o)
      try {
        return $p(
          i,
          ea({ color: { scheme: o, domain: [0, 1] } }).interpolate
        );
      } catch (c) {
        console.warn(c);
      }
  } else if (t.length) {
    const c = s.getAttribute("colorRange");
    a = ea({ color: {
      domain: t,
      range: c,
      scheme: o || (c ? void 0 : "tableau10")
    } }).apply(n);
  } else {
    const c = e.channelField("fill");
    a = nw(c == null ? void 0 : c.value) ? c.value : void 0;
  }
  return $p(i, uB(a));
}
function Jx(e, t, n, i, r, s) {
  const o = (i - s) / (n - t), a = o !== 1 ? ` * ${o}::DOUBLE` : "";
  return r ? q`(${n} - ${e}::DOUBLE)${a}` : q`(${e}::DOUBLE - ${t})${a}`;
}
function BQ(e, t, n, i, r, s) {
  return e.select({
    index: q`FLOOR(${t})::INTEGER + FLOOR(${n})::INTEGER * ${r}`,
    value: i
  }).groupby("index", s);
}
function NQ(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", value: na("w") }, s).groupby("index", s).having(pO("value", 0));
}
function Qx(e) {
  const t = Math.floor(e);
  return t === e ? t - 1 : t;
}
function FQ(e, t, n) {
  var i = 1e-8, r = t - 1, s = n - 1, o = 0, a, c, l, u, f, h, d, p, m, g, y;
  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, m = 2 / (1 / (2 * t - 1) + 1 / (2 * n - 1)), g = d * Math.sqrt(p + m) / m - (1 / (2 * n - 1) - 1 / (2 * t - 1)) * (p + 5 / 6 - 2 / (3 * m)), 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)), y = -ic(t) - ic(n) + ic(t + n); o < 10; o++) {
    if (d === 0 || d === 1)
      return d;
    if (h = DQ(d, t, n) - e, u = Math.exp(r * Math.log(d) + s * Math.log(1 - d) + y), 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 DQ(e, t, n) {
  var i = e === 0 || e === 1 ? 0 : Math.exp(ic(t + n) - ic(t) - ic(n) + t * Math.log(e) + n * Math.log(1 - e));
  return e < 0 || e > 1 ? !1 : e < (t + 1) / (t + n + 2) ? i * tS(e, t, n) / t : 1 - i * tS(1 - e, n, t) / n;
}
function tS(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 ic(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 EQ(e, t) {
  var n = FQ(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 OQ extends al {
  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;
    Jn(this, "ci", i, o), Jn(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: kO(i, n),
      slope: UO(i, n),
      n: zO(i, n),
      ssy: PO(i, n),
      ssx: VO(i, n),
      xm: jO(i, n),
      x0: uv(bc(n).where(gd(i))),
      x1: uv(gc(n).where(gd(i)))
    }).select(r).groupby(r);
  }
  queryResult(t) {
    return this.modelFit = Array.from(t), this.lineData = this.modelFit.flatMap((n) => LQ(n)), this.confidenceBand();
  }
  confidenceBand() {
    const { ci: t, modelFit: n, precision: i, plot: r } = this, s = r.innerWidth();
    return this.areaData = t ? n.flatMap((o) => RQ(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 = Ts(a);
          break;
        case "strokeOpacity":
          s.strokeOpacity = Ts(a);
          break;
        case "fillOpacity":
          o.fillOpacity = Ts(a);
          break;
        default:
          s[a.channel] = o[a.channel] = Ts(a);
          break;
      }
    return [
      ...r ? [{ type: "areaY", data: n, options: o }] : [],
      { type: "line", data: t, options: s }
    ];
  }
}
function LQ(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 RQ(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 = EQ((1 - e) / 2, l - 2) * Math.sqrt(f / (l - 2));
  return Bn(r, s - d / 2, d).concat(s).map((m) => {
    const g = a + m * c, y = p * Math.sqrt(1 / l + (m - o) ** 2 / u);
    return { x: m, y1: g - y, y2: g + y, ...h };
  });
}
const CQ = /* @__PURE__ */ new Set([
  "frame",
  "axisX",
  "axisY",
  "axisFx",
  "axisFy",
  "gridX",
  "gridY",
  "gridFx",
  "gridFy",
  "hexgrid",
  "graticule",
  "sphere"
]);
function nt(e, t, n) {
  arguments.length === 2 && (n = t, t = CQ.has(e) ? null : [{}]);
  const i = e.startsWith("area") || e.startsWith("line") ? tQ : al;
  return iw(i, e, t, n);
}
function iw(e, t, n, i) {
  return (r) => {
    r.addMark(new e(t, n, i));
  };
}
function oa(e, t, n) {
  return (i) => {
    i.addMark(new e(t, n));
  };
}
const kQ = (...e) => nt("area", ...e), UQ = (...e) => nt("areaX", ...e), zQ = (...e) => nt("areaY", ...e), PQ = (...e) => nt("line", ...e), VQ = (...e) => nt("lineX", ...e), jQ = (...e) => nt("lineY", ...e), YQ = (...e) => nt("barX", ...e), qQ = (...e) => nt("barY", ...e), WQ = (...e) => nt("cell", ...e), GQ = (...e) => nt("cellX", ...e), XQ = (...e) => nt("cellY", ...e), HQ = (...e) => nt("rect", ...e), KQ = (...e) => nt("rectX", ...e), ZQ = (...e) => nt("rectY", ...e), JQ = (...e) => nt("dot", ...e), QQ = (...e) => nt("dotX", ...e), ttt = (...e) => nt("dotY", ...e), ett = (...e) => nt("circle", ...e), ntt = (...e) => nt("hexagon", ...e), itt = (...e) => nt("text", ...e), rtt = (...e) => nt("textX", ...e), stt = (...e) => nt("textY", ...e), ott = (...e) => nt("ruleX", ...e), att = (...e) => nt("ruleY", ...e), ctt = (...e) => nt("tickX", ...e), ltt = (...e) => nt("tickY", ...e), utt = (...e) => nt("vector", ...e), ftt = (...e) => nt("vectoX", ...e), htt = (...e) => nt("vectorY", ...e), dtt = (...e) => nt("spike", ...e), ptt = (...e) => nt("image", ...e), ytt = (...e) => iw(aB, "areaX", ...e), mtt = (...e) => iw(aB, "areaY", ...e), gtt = (...e) => oa(hQ, ...e), btt = (...e) => oa(gQ, ...e), _tt = (...e) => oa(wQ, ...e), wtt = (...e) => oa(fB, ...e), vtt = (...e) => oa(SQ, ...e), xtt = (...e) => oa(xQ, ...e), Stt = (...e) => nt("hexgrid", ...e), Itt = (...e) => oa(OQ, ...e), Att = (...e) => nt("voronoi", ...e), Mtt = (...e) => nt("voronoiMesh", ...e), $tt = (...e) => nt("delaunayLink", ...e), Ttt = (...e) => nt("delaunayMesh", ...e), Btt = (...e) => nt("hull", ...e), Ntt = (...e) => nt("arrow", ...e), Ftt = (...e) => nt("link", ...e), Dtt = (...e) => nt("frame", ...e), Ett = (...e) => nt("axisX", ...e), Ott = (...e) => nt("axisY", ...e), Ltt = (...e) => nt("axisFx", ...e), Rtt = (...e) => nt("axisFy", ...e), Ctt = (...e) => nt("gridX", ...e), ktt = (...e) => nt("gridY", ...e), Utt = (...e) => nt("gridFx", ...e), ztt = (...e) => nt("gridFy", ...e), Ptt = (...e) => nt("geo", ...e), Vtt = (...e) => nt("sphere", ...e), jtt = (...e) => nt("graticule", ...e), Ytt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  area: kQ,
  areaX: UQ,
  areaY: zQ,
  arrow: Ntt,
  axisFx: Ltt,
  axisFy: Rtt,
  axisX: Ett,
  axisY: Ott,
  barX: YQ,
  barY: qQ,
  cell: WQ,
  cellX: GQ,
  cellY: XQ,
  circle: ett,
  contour: _tt,
  delaunayLink: $tt,
  delaunayMesh: Ttt,
  denseLine: btt,
  density: gtt,
  densityX: ytt,
  densityY: mtt,
  dot: JQ,
  dotX: QQ,
  dotY: ttt,
  frame: Dtt,
  geo: Ptt,
  graticule: jtt,
  gridFx: Utt,
  gridFy: ztt,
  gridX: Ctt,
  gridY: ktt,
  hexagon: ntt,
  hexbin: xtt,
  hexgrid: Stt,
  hull: Btt,
  image: ptt,
  line: PQ,
  lineX: VQ,
  lineY: jQ,
  link: Ftt,
  raster: wtt,
  rasterTile: vtt,
  rect: HQ,
  rectX: KQ,
  rectY: ZQ,
  regressionY: Itt,
  ruleX: ott,
  ruleY: att,
  sphere: Vtt,
  spike: dtt,
  text: itt,
  textX: rtt,
  textY: stt,
  tickX: ctt,
  tickY: ltt,
  vector: utt,
  vectorX: ftt,
  vectorY: htt,
  voronoi: Att,
  voronoiMesh: Mtt
}, Symbol.toStringTag, { value: "Module" }));
function qtt(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 rw(e) {
  const t = {};
  for (const n in e)
    t[qtt(n)] = e[n];
  return t;
}
class Wtt {
  constructor(t, {
    selection: n,
    channels: i = {}
  }) {
    this.mark = t, this.selection = n;
    const r = Object.entries(rw(i));
    this.channels = r.length ? r : [["opacity", 0.2]], this.selection.addEventListener("value", F3(() => 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 Gtt(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 Gtt(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 = { __: Yo(n) }, s = e.query(i), o = s.groupby().length ? s.select(r) : s.$select(r), a = await qn().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;
}
class hB {
  constructor(t, {
    selection: n,
    channels: i
  }) {
    this.value = null, this.mark = t, this.selection = n, this.clients = (/* @__PURE__ */ new Set()).add(t), this.channels = i.map((r) => {
      var o;
      const s = r === "color" ? ["fill", "stroke"] : r === "x" ? ["x", "x1", "x2"] : r === "y" ? ["y", "y1", "y2"] : [r];
      for (let a = 0; a < s.length; ++a) {
        const c = t.channelField(s[a]);
        if (c)
          return {
            field: ((o = c.field) == null ? void 0 : o.basis) || c.field,
            as: c.as
          };
      }
      throw new Error(`Missing channel: ${r}`);
    });
  }
  clause(t) {
    const { channels: n, clients: i } = this;
    let r = null;
    if (t) {
      const s = t.map((o) => {
        const a = o.map((c, l) => yO(n[l].field, Xu(c)));
        return a.length > 1 ? Yo(a) : a[0];
      });
      r = s.length > 1 ? S3(s) : s[0];
    }
    return {
      source: this,
      schema: { type: "point" },
      clients: 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 (Xtt(c, f)) {
        const d = i(f);
        l.shiftKey && (u != null && u.length) ? (h = u.filter((p) => u1(p, d)), h.length === u.length && h.push(d)) : (u == null ? void 0 : u.length) === 1 && !u1(u[0], d) ? h = null : h = [d];
      }
      this.value = h, Htt(u, h) && o.update(this.clause(h));
    }), t.addEventListener("pointerenter", () => {
      this.selection.activate(this.clause([this.channels.map(() => 0)]));
    });
  }
}
function Xtt(e, t) {
  var n;
  return e.has(t) || e.has(t.parentNode) || e.has((n = t.parentNode) == null ? void 0 : n.parentNode);
}
function Htt(e, t) {
  return e == null || t == null ? e != null || t != null : e.length !== t.length || e.some((n, i) => u1(n, t[i]));
}
function u1(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;
}
function sw(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 Ktt() {
  return sw(Fk());
}
function Ztt() {
  return sw(Bk());
}
function Jtt() {
  return sw(Nk());
}
const eS = 1e-12;
function f1(e, t) {
  return e === t || e && t && Math.abs(e[0] - t[0]) < eS && Math.abs(e[1] - t[1]) < eS || !1;
}
function Rc(e, t) {
  var i;
  const n = (i = e.channelField(t)) == null ? void 0 : i.field;
  return (n == null ? void 0 : n.basis) || n;
}
function h1(e, t, n = 1) {
  return t.invert(n * Math.floor(e / n));
}
function dB() {
  const e = this, t = e.getScreenCTM;
  let n;
  e.getScreenCTM = () => e.isConnected ? n = t.call(e) : n;
}
class pB {
  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 || Rc(t, [n, n + "1", n + "2"]), this.style = a && rw(a), this.brush = n === "y" ? Jtt() : Ztt(), 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) => h1(i, this.scale, this.pixelSize)).sort((i, r) => i - r)), f1(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 ? Dn(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([[ze(s), ze(o)], [Se(s), Se(o)]]);
    const a = re(t).selectAll('g[aria-label="facet"]'), c = a.size() ? a : re(t);
    if (this.g = c.append("g").attr("class", `interval-${i}`).each(dB).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 uh = (e, t) => e - t;
class Qtt {
  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 || Rc(t, ["x", "x1", "x2"]), this.yfield = r || Rc(t, ["y", "y1", "y2"]), this.style = a && rw(a), this.brush = Ktt(), 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) => h1(u, r, i)).sort(uh), a = [c[1], l[1]].map((u) => h1(u, s, i)).sort(uh);
    }
    (!f1(o, n == null ? void 0 : n[0]) || !f1(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 ? Yo(Dn(r, t[0]), Dn(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([[ze(o), ze(a)], [Se(o), Se(a)]]);
    const c = re(t).selectAll('g[aria-label="facet"]'), l = c.size() ? c : re(t);
    if (this.g = l.append("g").attr("class", "interval-xy").each(dB).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(uh), [h, d] = this.value[1].map(s.apply).sort(uh);
      this.g.call(n.moveSilent, [[u, h], [f, d]]);
    }
    t.addEventListener("pointerenter", () => this.activate());
  }
}
const nS = (e, t) => e - t;
class tet {
  constructor(t, {
    x: n = new Ms(),
    y: i = new Ms(),
    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 || Rc(t, ["x", "x1", "x2"]), this.yfield = s || Rc(t, ["y", "y1", "y2"]), this.zoom = $m(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 = eet(t, this.xscale);
      this.xsel.update(this.clause(n, this.xfield, this.xscale));
    }
    if (this.pany) {
      const n = net(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 ? Dn(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(nS), c = this.yscale.range.slice().sort(nS), l = $m(n, [-1 / 0, 1 / 0], a), u = $m(i, [-1 / 0, 1 / 0], c), f = xV().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 Ji(1, 0, 0)).on("zoom", ({ transform: h }) => this.publish(h));
    if (re(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 $m(e, t, n) {
  return e ? Array.isArray(e) ? e : t : n;
}
function eet(e, t) {
  return t.range.map(e.invertX, e).map(t.invert, t);
}
function net(e, t) {
  return t.range.map(e.invertY, e).map(t.invert, t);
}
class yB {
  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 || Rc(t, [i]);
  }
  clause(t) {
    const { clients: n, field: i } = this, r = t ? W1(i, Xu(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 = re(t).selectAll('g[aria-label="facet"]'), l = c.size() ? c : re(t), u = t.scale(r), f = !qo(s);
    l.on("pointerdown pointermove", function(h) {
      const [d, p] = ci(h, this), m = iet(o, a, u.invert(r === "x" ? d : p));
      s.update(f ? m : n.clause(m));
    }), !f && t.addEventListener("pointerenter", () => {
      this.selection.activate(this.clause(0));
    });
  }
}
function iet(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;
}
function oo(e, t) {
  return (n) => {
    const i = n.marks[n.marks.length - 1];
    n.addInteractor(new e(i, t));
  };
}
function ret({ by: e, ...t }) {
  return oo(Wtt, { selection: e, channels: t });
}
function b0({ as: e, ...t }) {
  return oo(hB, { ...t, selection: e });
}
function set({ as: e }) {
  return b0({ as: e, channels: ["x"] });
}
function oet({ as: e }) {
  return b0({ as: e, channels: ["y"] });
}
function aet({ as: e }) {
  return b0({ as: e, channels: ["color"] });
}
function cet({ as: e, ...t }) {
  return oo(yB, { ...t, selection: e, channel: "x" });
}
function uet({ as: e, ...t }) {
  return oo(yB, { ...t, selection: e, channel: "y" });
}
function fet({ as: e, ...t }) {
  return oo(pB, { ...t, selection: e, channel: "x" });
}
function het({ as: e, ...t }) {
  return oo(pB, { ...t, selection: e, channel: "y" });
}
function det({ as: e, ...t }) {
  return oo(Qtt, { ...t, selection: e });
}
function cl(e) {
  return oo(tet, e);
}
function pet(e = {}) {
  return cl({ ...e, zoom: !1 });
}
function yet(e = {}) {
  return cl({ ...e, zoom: !1, pany: !1 });
}
function met(e = {}) {
  return cl({ ...e, zoom: !1, panx: !1 });
}
function get(e = {}) {
  return cl(e);
}
function bet(e = {}) {
  return cl({ ...e, pany: !1 });
}
function _et(e = {}) {
  return cl({ ...e, panx: !1 });
}
const wet = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  highlight: ret,
  intervalX: fet,
  intervalXY: det,
  intervalY: het,
  nearestX: cet,
  nearestY: uet,
  pan: pet,
  panX: yet,
  panY: met,
  panZoom: get,
  panZoomX: bet,
  panZoomY: _et,
  toggle: b0,
  toggleColor: aet,
  toggleX: set,
  toggleY: oet
}, Symbol.toStringTag, { value: "Module" }));
class iS {
  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 = vet(t, n);
    this.selection && r && (this.handler = new hB(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 vet({ 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)
    if (e[i].channelField(n))
      return e[i];
  return null;
}
function ow(e, t = {}) {
  if (t.for) {
    const { for: n, ...i } = t, r = new iS(e, i), s = typeof n, o = (a) => a.addLegend(r, !1);
    return s === "string" ? tw.request(n, o) : n.value && o(n.value), r.element;
  } else
    return (n) => n.addLegend(new iS(e, t));
}
const xet = (e) => ow("color", e), Iet = (e) => ow("opacity", e), Aet = (e) => ow("symbol", e), Met = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  colorLegend: xet,
  opacityLegend: Iet,
  symbolLegend: Aet
}, Symbol.toStringTag, { value: "Module" }));
function mB({ 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 $et(...e) {
  return mB({ direction: "vertical" }, e.flat());
}
function Tet(...e) {
  return mB({ direction: "horizontal" }, e.flat());
}
function gB({ 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 Bet(e) {
  return gB({ dim: "height", size: e });
}
function Net(e) {
  return gB({ dim: "width", size: e });
}
function Fet(e) {
  return e;
}
function Det(e) {
  if (e == null)
    return Fet;
  var t, n, i = e.scale[0], r = e.scale[1], s = e.translate[0], o = e.translate[1];
  return function(a, c) {
    c || (t = n = 0);
    var l = 2, u = a.length, f = new Array(u);
    for (f[0] = (t += a[0]) * i + s, f[1] = (n += a[1]) * r + o; l < u; )
      f[l] = a[l], ++l;
    return f;
  };
}
function Eet(e, t) {
  for (var n, i = e.length, r = i - t; r < --i; )
    n = e[r], e[r++] = e[i], e[i] = n;
}
function Oet(e, t) {
  return typeof t == "string" && (t = e.objects[t]), t.type === "GeometryCollection" ? { type: "FeatureCollection", features: t.geometries.map(function(n) {
    return rS(e, n);
  }) } : rS(e, t);
}
function rS(e, t) {
  var n = t.id, i = t.bbox, r = t.properties == null ? {} : t.properties, s = bB(e, t);
  return n == null && i == null ? { type: "Feature", properties: r, geometry: s } : i == null ? { type: "Feature", id: n, properties: r, geometry: s } : { type: "Feature", id: n, bbox: i, properties: r, geometry: s };
}
function bB(e, t) {
  var n = Det(e.transform), i = e.arcs;
  function r(u, f) {
    f.length && f.pop();
    for (var h = i[u < 0 ? ~u : u], d = 0, p = h.length; d < p; ++d)
      f.push(n(h[d], d));
    u < 0 && Eet(f, p);
  }
  function s(u) {
    return n(u);
  }
  function o(u) {
    for (var f = [], h = 0, d = u.length; h < d; ++h)
      r(u[h], f);
    return f.length < 2 && f.push(f[0]), f;
  }
  function a(u) {
    for (var f = o(u); f.length < 4; )
      f.push(f[0]);
    return f;
  }
  function c(u) {
    return u.map(a);
  }
  function l(u) {
    var f = u.type, h;
    switch (f) {
      case "GeometryCollection":
        return { type: f, geometries: u.geometries.map(l) };
      case "Point":
        h = s(u.coordinates);
        break;
      case "MultiPoint":
        h = u.coordinates.map(s);
        break;
      case "LineString":
        h = o(u.arcs);
        break;
      case "MultiLineString":
        h = u.arcs.map(o);
        break;
      case "Polygon":
        h = c(u.arcs);
        break;
      case "MultiPolygon":
        h = u.arcs.map(c);
        break;
      default:
        return null;
    }
    return { type: f, coordinates: h };
  }
  return l(t);
}
function Let(e, t) {
  var n = {}, i = {}, r = {}, s = [], o = -1;
  t.forEach(function(l, u) {
    var f = e.arcs[l < 0 ? ~l : l], h;
    f.length < 3 && !f[1][0] && !f[1][1] && (h = t[++o], t[o] = l, t[u] = h);
  }), t.forEach(function(l) {
    var u = a(l), f = u[0], h = u[1], d, p;
    if (d = r[f])
      if (delete r[d.end], d.push(l), d.end = h, p = i[h]) {
        delete i[p.start];
        var m = p === d ? d : d.concat(p);
        i[m.start = d.start] = r[m.end = p.end] = m;
      } else
        i[d.start] = r[d.end] = d;
    else if (d = i[h])
      if (delete i[d.start], d.unshift(l), d.start = f, p = r[f]) {
        delete r[p.end];
        var g = p === d ? d : p.concat(d);
        i[g.start = p.start] = r[g.end = d.end] = g;
      } else
        i[d.start] = r[d.end] = d;
    else
      d = [l], i[d.start = f] = r[d.end = h] = d;
  });
  function a(l) {
    var u = e.arcs[l < 0 ? ~l : l], f = u[0], h;
    return e.transform ? (h = [0, 0], u.forEach(function(d) {
      h[0] += d[0], h[1] += d[1];
    })) : h = u[u.length - 1], l < 0 ? [h, f] : [f, h];
  }
  function c(l, u) {
    for (var f in l) {
      var h = l[f];
      delete u[h.start], delete h.start, delete h.end, h.forEach(function(d) {
        n[d < 0 ? ~d : d] = 1;
      }), s.push(h);
    }
  }
  return c(r, i), c(i, r), t.forEach(function(l) {
    n[l < 0 ? ~l : l] || s.push([l]);
  }), s;
}
function Ret(e) {
  return bB(e, Cet.apply(this, arguments));
}
function Cet(e, t, n) {
  var i, r, s;
  if (arguments.length > 1)
    i = ket(e, t, n);
  else
    for (r = 0, i = new Array(s = e.arcs.length); r < s; ++r)
      i[r] = r;
  return { type: "MultiLineString", arcs: Let(e, i) };
}
function ket(e, t, n) {
  var i = [], r = [], s;
  function o(f) {
    var h = f < 0 ? ~f : f;
    (r[h] || (r[h] = [])).push({ i: f, g: s });
  }
  function a(f) {
    f.forEach(o);
  }
  function c(f) {
    f.forEach(a);
  }
  function l(f) {
    f.forEach(c);
  }
  function u(f) {
    switch (s = f, f.type) {
      case "GeometryCollection":
        f.geometries.forEach(u);
        break;
      case "LineString":
        a(f.arcs);
        break;
      case "MultiLineString":
      case "Polygon":
        c(f.arcs);
        break;
      case "MultiPolygon":
        l(f.arcs);
        break;
    }
  }
  return u(t), r.forEach(n == null ? function(f) {
    i.push(f[0].i);
  } : function(f) {
    n(f[0].g, f[f.length - 1].g) && i.push(f[0].i);
  }), i;
}
function Uet(e) {
  const t = typeof e;
  return t === "object" ? e == null ? void 0 : e.param : t === "string" ? zet(e) : null;
}
function zet(e) {
  return (e == null ? void 0 : e[0]) === "$" ? e.slice(1) : null;
}
function Tm(e) {
  return [e].flat();
}
function rc(e) {
  return Array.isArray(e);
}
function _B(e) {
  return e !== null && typeof e == "object" && !rc(e);
}
function sS(e) {
  const t = typeof e;
  return t === "number" || t === "string";
}
function Ds(e) {
  return typeof e == "string";
}
function xf(e) {
  return typeof e == "function";
}
function ar(e, t) {
  throw Object.assign(Error(e), { data: t });
}
function Pet(e, t, n) {
  t = Vet(t, n);
  const i = n.dataFormats.get(t.type);
  if (i)
    return i(e, t, n);
  ar("Unrecognized data format type.", t);
}
function Vet(e, t) {
  return rc(e) && (e = { type: "json", data: e }), Ds(e) && (e = { type: "table", query: e }), {
    ...e,
    type: jet(e),
    file: qet(e, t)
  };
}
function jet(e) {
  return e.type || Yet(e.file) || "table";
}
function Yet(e) {
  const t = e == null ? void 0 : e.lastIndexOf(".");
  return t > 0 ? e.slice(t + 1) : null;
}
function qet({ file: e }, t) {
  return e && t.baseURL ? new URL(e, t.baseURL).toString() : e;
}
function Wet(e, t) {
  const { query: n, type: i, ...r } = t;
  if (n)
    return uy(e, n, r);
}
function Get(e, t) {
  const { file: n, type: i, ...r } = t;
  return JO(e, n, r);
}
function Xet(e, t) {
  const { file: n, type: i, ...r } = t;
  return KO(e, n, r);
}
function Het(e, t) {
  const { data: n, file: i, type: r, ...s } = t;
  return n ? QO(e, n, s) : ZO(e, i, s);
}
const Ket = { menu: P5, search: q5, slider: X5, table: Q5 }, Zet = /* @__PURE__ */ new Map([
  ["intersect", () => Ms.intersect()],
  ["crossfilter", () => Ms.crossfilter()],
  ["union", () => Ms.union()],
  ["single", () => Ms.single()],
  ["value", ({ date: e, value: t }, n) => Array.isArray(t) ? qr.array(t.map((i) => n.maybeParam(i))) : qr.value(X1(e, t))]
]), Jet = /* @__PURE__ */ new Map([
  ["plot", { type: rc, parse: vB }],
  ["mark", { type: Ds, parse: mnt }],
  ["legend", { type: Ds, parse: xB }],
  ["hconcat", { type: rc, parse: ynt }],
  ["vconcat", { type: rc, parse: pnt }],
  ["hspace", { type: sS, parse: fnt }],
  ["vspace", { type: sS, parse: hnt }],
  ["input", { type: Ds, parse: dnt }]
]), Qet = /* @__PURE__ */ new Map([
  ["csv", Xet],
  ["json", Het],
  ["geojson", cnt],
  ["topojson", lnt],
  ["parquet", Get],
  ["table", Wet]
]), tnt = /* @__PURE__ */ new Map([
  ["avg", OO],
  ["bin", yv],
  ["count", Uo],
  ["dateMonth", qO],
  ["dateMonthDay", WO],
  ["dateDay", GO],
  ["bin", yv],
  ["max", gc],
  ["median", LO],
  ["min", bc],
  ["mode", CO],
  ["quantile", RO],
  ["sum", na],
  ["row_number", vO],
  ["rank", xO],
  ["dense_rank", SO],
  ["percent_rank", IO],
  ["cume_dist", AO],
  ["ntile", MO],
  ["lag", $O],
  ["lead", TO],
  ["first_value", BO],
  ["last_value", NO],
  ["nth_value", FO]
]), ent = new Map(Object.entries(Ytt)), nnt = new Map(Object.entries(Ket)), int = new Map(Object.entries(Met)), rnt = new Map(Object.entries(WJ)), snt = new Map(Object.entries(wet));
function ont(e, t) {
  return e = Ds(e) ? JSON.parse(e) : e, new ant(t).parse(e);
}
class ant {
  constructor({
    specParsers: t = Jet,
    paramParsers: n = Zet,
    dataFormats: i = Qet,
    transforms: r = tnt,
    attributes: s = rnt,
    interactors: o = snt,
    legends: a = int,
    inputs: c = nnt,
    marks: l = ent,
    params: u = [],
    datasets: f = [],
    baseURL: h = null
  } = {}) {
    this.specParsers = t, this.paramParsers = n, this.dataFormats = i, this.transforms = r, this.attributes = s, this.interactors = o, this.legends = a, this.inputs = c, this.marks = l, this.params = new Map(u), this.datasets = new Map(f), this.baseURL = h, this.postQueue = [];
  }
  after(t) {
    this.postQueue.push(t);
  }
  maybeParam(t, n = () => qr.value()) {
    const { params: i } = this, r = Uet(t);
    if (r) {
      if (i.has(r))
        return i.get(r);
      {
        const s = n();
        return i.set(r, s), s;
      }
    }
    return t;
  }
  maybeSelection(t) {
    return this.maybeParam(t, () => Ms.intersect());
  }
  maybeTransform(t) {
    if (_B(t))
      return t.expr ? xnt(t, this) : Snt(t, this);
  }
  async parse(t) {
    const { meta: n, data: i = {}, plotDefaults: r = {}, params: s, ...o } = t;
    for (const c in i) {
      const l = await Pet(c, i[c], this);
      l != null && l.data ? this.datasets.set(c, l.data) : l && await qn().exec(l);
    }
    this.plotDefaults = Object.keys(r).map((c) => SB(r, c, this));
    for (const c in s)
      this.params.set(c, unt(s[c], this));
    const a = aw(o, this);
    return this.postQueue.forEach((c) => c()), this.postQueue = [], this.plotDefaults = {}, a;
  }
}
async function wB(e) {
  const { data: t, file: n } = e;
  return t || await fetch(n).then((i) => i.json());
}
async function cnt(e, t) {
  return { data: await wB(t) };
}
async function lnt(e, t) {
  const n = await wB(t);
  let i;
  if (t.feature)
    i = Oet(n, n.objects[t.feature]);
  else {
    const r = t.mesh ? n.objects[t.mesh] : void 0, s = {
      interior: (o, a) => o !== a,
      exterior: (o, a) => o === a
    }[t.filter];
    i = Ret(n, r, s);
  }
  return { data: i && i.features || [i] };
}
function unt(e, t) {
  e = _B(e) ? e : { value: e };
  const { select: n = "value" } = e, i = t.paramParsers.get(n);
  return i || ar(`Unrecognized param type: ${n}`, e), i(e, t);
}
function aw(e, t) {
  for (const [n, { type: i, parse: r }] of t.specParsers) {
    const s = e[n];
    if (s != null) {
      if (i(s))
        return r(e, t);
      ar(`Invalid property type: ${n}`, e);
    }
  }
  ar("Invalid specification.", e);
}
function fnt(e) {
  return Net(e.hspace);
}
function hnt(e) {
  return Bet(e.vspace);
}
function dnt(e, t) {
  const { input: n, ...i } = e, r = t.inputs.get(n);
  xf(r) || ar(`Unrecognized input: ${n}`, e);
  for (const s in i)
    i[s] = t.maybeSelection(i[s]);
  return r(i);
}
function pnt(e, t) {
  return $et(e.vconcat.map((n) => aw(n, t)));
}
function ynt(e, t) {
  return Tet(e.hconcat.map((n) => aw(n, t)));
}
function vB(e, t) {
  const { plot: n, ...i } = e, r = t.plotDefaults.concat(
    Object.keys(i).map((o) => SB(e, o, t))
  ), s = n.map((o) => gnt(o, t));
  return vH(r, s);
}
function mnt(e, t) {
  return vB({ plot: [e] }, t);
}
function xB(e, t) {
  const { legend: n, ...i } = e, r = `${n}Legend`, s = t.legends.get(r);
  xf(s) || ar(`Unrecognized legend type: ${n}`, e);
  for (const o in i)
    i[o] = t.maybeSelection(i[o]);
  return s(i);
}
function SB(e, t, n) {
  const i = n.attributes.get(t);
  xf(i) || ar(`Unrecognized attribute: ${t}`, e);
  const r = e[t], s = r === "Fixed" ? Z1 : n.maybeParam(r);
  return i(s);
}
function gnt(e, t) {
  return Ds(e.mark) ? bnt(e, t) : Ds(e.legend) ? xB(e, t) : Ds(e.select) ? vnt(e, t) : ar("Invalid plot entry.", e);
}
function bnt(e, t) {
  const { mark: n, data: i, ...r } = e, s = t.marks.get(n);
  xf(s) || ar(`Unrecognized mark type: ${n}`, e);
  const o = _nt(i, t);
  for (const a in r)
    r[a] = wnt(r[a], t);
  return o ? s(o, r) : s(r);
}
function _nt(e, t) {
  if (!e)
    return null;
  if (rc(e))
    return e;
  const { from: n, ...i } = e;
  if (t.datasets.has(n))
    return t.datasets.get(n);
  for (const r in i)
    i[r] = t.maybeSelection(i[r]);
  return GJ(n, i);
}
function wnt(e, t) {
  return t.maybeTransform(e) || t.maybeParam(e);
}
function vnt(e, t) {
  const { select: n, ...i } = e, r = t.interactors.get(n);
  xf(r) || ar(`Unrecognized interactor type: ${n}`, e);
  for (const s in i)
    i[s] = t.maybeSelection(i[s]);
  return r(i);
}
function xnt(e, t) {
  const { expr: n, label: i } = e, r = n.split(/(\\'|\\"|"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|\$\w+)/g), s = [""], o = [];
  for (let a = 0, c = 0; a < r.length; ++a) {
    const l = r[a];
    l.startsWith("$") ? (o[c] = t.maybeParam(l), s[++c] = "") : s[c] += l;
  }
  return q(s, ...o).annotate({ label: i });
}
function Snt(e, t) {
  const { transforms: n } = t;
  let i;
  for (const a in e)
    n.has(a) && (i = a);
  if (!i)
    return;
  const r = n.get(i), s = i === "count" || i == null ? [] : Tm(e[i]);
  let o = r(...s);
  if (e.distinct && (o = o.distinct()), e.order) {
    const a = Tm(e.order).map((c) => t.maybeParam(c));
    o = o.orderby(a);
  }
  if (e.partition) {
    const a = Tm(e.partition).map((c) => t.maybeParam(c));
    o = o.partitionby(a);
  }
  return e.rows ? o = o.rows(t.maybeParam(e.rows)) : e.range && (o = o.range(t.maybeParam(e.range))), o;
}
const Int = new TextDecoder("utf-8"), d1 = (e) => Int.decode(e), Ant = new TextEncoder(), cw = (e) => Ant.encode(e), [Sf, Dot] = (() => {
  const e = () => {
    throw new Error("BigInt64Array is not available in this environment");
  };
  class t {
    static get BYTES_PER_ELEMENT() {
      return 8;
    }
    static of() {
      throw e();
    }
    static from() {
      throw e();
    }
    constructor() {
      throw e();
    }
  }
  return typeof BigInt64Array < "u" ? [BigInt64Array, !0] : [t, !1];
})(), [If, Eot] = (() => {
  const e = () => {
    throw new Error("BigUint64Array is not available in this environment");
  };
  class t {
    static get BYTES_PER_ELEMENT() {
      return 8;
    }
    static of() {
      throw e();
    }
    static from() {
      throw e();
    }
    constructor() {
      throw e();
    }
  }
  return typeof BigUint64Array < "u" ? [BigUint64Array, !0] : [t, !1];
})(), Mnt = (e) => typeof e == "number", $nt = (e) => typeof e == "boolean", en = (e) => typeof e == "function", Ii = (e) => e != null && Object(e) === e, Ou = (e) => Ii(e) && en(e.then), _0 = (e) => Ii(e) && en(e[Symbol.iterator]), lw = (e) => Ii(e) && en(e[Symbol.asyncIterator]), p1 = (e) => Ii(e) && Ii(e.schema), IB = (e) => Ii(e) && "done" in e && "value" in e, AB = (e) => Ii(e) && en(e.stat) && Mnt(e.fd), MB = (e) => Ii(e) && uw(e.body), $B = (e) => "_getDOMStream" in e && "_getNodeStream" in e, uw = (e) => Ii(e) && en(e.cancel) && en(e.getReader) && !$B(e), TB = (e) => Ii(e) && en(e.read) && en(e.pipe) && $nt(e.readable) && !$B(e), Tnt = (e) => Ii(e) && en(e.clear) && en(e.bytes) && en(e.position) && en(e.setPosition) && en(e.capacity) && en(e.getBufferIdentifier) && en(e.createLong), fw = typeof SharedArrayBuffer < "u" ? SharedArrayBuffer : ArrayBuffer;
function Bnt(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 oS(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 = Bnt(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 ? oS(o, s, a) : o = s;
      break;
    }
    oS(o || (o = new Uint8Array(l)), s, a), a += s.length;
  }
  return [o || new Uint8Array(0), n.slice(c), i - (o ? o.byteLength : 0)];
}
function ie(e, t) {
  let n = IB(t) ? t.value : t;
  return n instanceof e ? e === Uint8Array ? new e(n.buffer, n.byteOffset, n.byteLength) : n : n ? (typeof n == "string" && (n = cw(n)), n instanceof ArrayBuffer ? new e(n) : n instanceof fw ? new e(n) : Tnt(n) ? ie(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 $l = (e) => ie(Int32Array, e), Ht = (e) => ie(Uint8Array, e), y1 = (e) => (e.next(), e);
function* Nnt(e, t) {
  const n = function* (r) {
    yield r;
  }, i = typeof t == "string" || ArrayBuffer.isView(t) || t instanceof ArrayBuffer || t instanceof fw ? n(t) : _0(t) ? t : n(t);
  return yield* y1(function* (r) {
    let s = null;
    do
      s = r.next(yield ie(e, s));
    while (!s.done);
  }(i[Symbol.iterator]())), new e();
}
const Fnt = (e) => Nnt(Uint8Array, e);
function BB(e, t) {
  return Fe(this, arguments, function* () {
    if (Ou(t))
      return yield G(yield G(yield* Bs(Qn(BB(e, yield G(t))))));
    const i = function(o) {
      return Fe(this, arguments, function* () {
        yield yield G(yield G(o));
      });
    }, r = function(o) {
      return Fe(this, arguments, function* () {
        yield G(yield* Bs(Qn(y1(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 fw ? i(t) : _0(t) ? r(t) : lw(t) ? t : i(t);
    return yield G(
      // otherwise if AsyncIterable, use it
      yield* Bs(Qn(y1(function(o) {
        return Fe(this, arguments, function* () {
          let a = null;
          do
            a = yield G(o.next(yield yield G(ie(e, a))));
          while (!a.done);
        });
      }(s[Symbol.asyncIterator]()))))
    ), yield G(new e());
  });
}
const Dnt = (e) => BB(Uint8Array, e);
function Ent(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 zn = {
  fromIterable(e) {
    return fh(Ont(e));
  },
  fromAsyncIterable(e) {
    return fh(Lnt(e));
  },
  fromDOMStream(e) {
    return fh(Rnt(e));
  },
  fromNodeStream(e) {
    return fh(knt(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');
  }
}, fh = (e) => (e.next(), e);
function* Ont(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);
  const l = Fnt(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 Lnt(e) {
  return Fe(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 G(null));
    const u = Dnt(e)[Symbol.asyncIterator]();
    try {
      do
        if ({ done: n, value: s } = Number.isNaN(a - c) ? yield G(u.next()) : yield G(u.next(a - c)), !n && s.byteLength > 0 && (r.push(s), c += s.byteLength), n || a <= c)
          do
            ({ cmd: o, size: a } = yield yield G(l()));
          while (a < c);
      while (!n);
    } catch (f) {
      (i = !0) && typeof u.throw == "function" && (yield G(u.throw(f)));
    } finally {
      i === !1 && typeof u.return == "function" && (yield G(u.return(new Uint8Array(0))));
    }
    return yield G(null);
  });
}
function Rnt(e) {
  return Fe(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 G(null));
    const u = new Cnt(e);
    try {
      do
        if ({ done: n, value: s } = Number.isNaN(a - c) ? yield G(u.read()) : yield G(u.read(a - c)), !n && s.byteLength > 0 && (r.push(Ht(s)), c += s.byteLength), n || a <= c)
          do
            ({ cmd: o, size: a } = yield yield G(l()));
          while (a < c);
      while (!n);
    } catch (f) {
      (i = !0) && (yield G(u.cancel(f)));
    } finally {
      i === !1 ? yield G(u.cancel()) : e.locked && u.releaseLock();
    }
    return yield G(null);
  });
}
class Cnt {
  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 Y(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 Y(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 = Ht(n)), n;
    });
  }
}
const Bm = (e, t) => {
  const n = (r) => i([t, r]);
  let i;
  return [t, n, new Promise((r) => (i = r) && e.once(t, n))];
};
function knt(e) {
  return Fe(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 G(null), e.isTTY)
      return yield yield G(new Uint8Array(0)), yield G(null);
    try {
      n[0] = Bm(e, "end"), n[1] = Bm(e, "error");
      do {
        if (n[2] = Bm(e, "readable"), [i, s] = yield G(Promise.race(n.map((d) => d[2]))), i === "error")
          break;
        if ((r = i === "end") || (Number.isFinite(a - c) ? (u = Ht(e.read(a - c)), u.byteLength < a - c && (u = Ht(e.read()))) : u = Ht(e.read()), u.byteLength > 0 && (l.push(u), c += u.byteLength)), r || a <= c)
          do
            ({ cmd: o, size: a } = yield yield G(f()));
          while (a < c);
      } while (!r);
    } finally {
      yield G(h(n, i === "error" ? s : null));
    }
    return yield G(null);
    function h(d, p) {
      return u = l = null, new Promise((m, g) => {
        for (const [y, b] of d)
          e.off(y, b);
        try {
          const y = e.destroy;
          y && y.call(e, p), p = void 0;
        } catch (y) {
          p = y || p;
        } finally {
          p != null ? g(p) : m();
        }
      });
    }
  });
}
var Wn;
(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";
})(Wn || (Wn = {}));
var Ai;
(function(e) {
  e[e.Sparse = 0] = "Sparse", e[e.Dense = 1] = "Dense";
})(Ai || (Ai = {}));
var mn;
(function(e) {
  e[e.HALF = 0] = "HALF", e[e.SINGLE = 1] = "SINGLE", e[e.DOUBLE = 2] = "DOUBLE";
})(mn || (mn = {}));
var ns;
(function(e) {
  e[e.DAY = 0] = "DAY", e[e.MILLISECOND = 1] = "MILLISECOND";
})(ns || (ns = {}));
var Yt;
(function(e) {
  e[e.SECOND = 0] = "SECOND", e[e.MILLISECOND = 1] = "MILLISECOND", e[e.MICROSECOND = 2] = "MICROSECOND", e[e.NANOSECOND = 3] = "NANOSECOND";
})(Yt || (Yt = {}));
var Ws;
(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";
})(Ws || (Ws = {}));
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 C;
(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.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";
})(C || (C = {}));
var Fr;
(function(e) {
  e[e.OFFSET = 0] = "OFFSET", e[e.DATA = 1] = "DATA", e[e.VALIDITY = 2] = "VALIDITY", e[e.TYPE = 3] = "TYPE";
})(Fr || (Fr = {}));
const Unt = void 0;
function Lu(e) {
  if (e === null)
    return "null";
  if (e === Unt)
    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 Sf || e instanceof If ? `[${[...e].map((t) => Lu(t))}]` : `[${e}]` : ArrayBuffer.isView(e) ? `[${e}]` : JSON.stringify(e, (t, n) => typeof n == "bigint" ? `${n}` : n);
}
const znt = Symbol.for("isArrowBigNum");
function Ei(e, ...t) {
  return t.length === 0 ? Object.setPrototypeOf(ie(this.TypedArray, e), this.constructor.prototype) : Object.setPrototypeOf(new this.TypedArray(e, ...t), this.constructor.prototype);
}
Ei.prototype[znt] = !0;
Ei.prototype.toJSON = function() {
  return `"${Tp(this)}"`;
};
Ei.prototype.valueOf = function() {
  return NB(this);
};
Ei.prototype.toString = function() {
  return Tp(this);
};
Ei.prototype[Symbol.toPrimitive] = function(e = "default") {
  switch (e) {
    case "number":
      return NB(this);
    case "string":
      return Tp(this);
    case "default":
      return Pnt(this);
  }
  return Tp(this);
};
function sc(...e) {
  return Ei.apply(this, e);
}
function oc(...e) {
  return Ei.apply(this, e);
}
function Ru(...e) {
  return Ei.apply(this, e);
}
Object.setPrototypeOf(sc.prototype, Object.create(Int32Array.prototype));
Object.setPrototypeOf(oc.prototype, Object.create(Uint32Array.prototype));
Object.setPrototypeOf(Ru.prototype, Object.create(Uint32Array.prototype));
Object.assign(sc.prototype, Ei.prototype, { constructor: sc, signed: !0, TypedArray: Int32Array, BigIntArray: Sf });
Object.assign(oc.prototype, Ei.prototype, { constructor: oc, signed: !1, TypedArray: Uint32Array, BigIntArray: If });
Object.assign(Ru.prototype, Ei.prototype, { constructor: Ru, signed: !0, TypedArray: Uint32Array, BigIntArray: If });
function NB(e) {
  const { buffer: t, byteOffset: n, length: i, signed: r } = e, s = new If(t, n, i), o = r && s[s.length - 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 Tp = (e) => e.byteLength === 8 ? `${new e.BigIntArray(e.buffer, e.byteOffset, 1)[0]}` : FB(e), Pnt = (e) => e.byteLength === 8 ? new e.BigIntArray(e.buffer, e.byteOffset, 1)[0] : FB(e);
function FB(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 hw {
  /** @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 Sf:
        return new sc(t);
    }
    return t.byteLength === 16 ? new Ru(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 Ru(t);
  }
  constructor(t, n) {
    return hw.new(t, n);
  }
}
function Mi(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 DB, EB, OB, LB, RB, CB, kB, UB, zB, PB, VB, jB, YB, qB, WB, GB, XB, HB, KB;
class It {
  /** @nocollapse */
  static isNull(t) {
    return (t == null ? void 0 : t.typeId) === C.Null;
  }
  /** @nocollapse */
  static isInt(t) {
    return (t == null ? void 0 : t.typeId) === C.Int;
  }
  /** @nocollapse */
  static isFloat(t) {
    return (t == null ? void 0 : t.typeId) === C.Float;
  }
  /** @nocollapse */
  static isBinary(t) {
    return (t == null ? void 0 : t.typeId) === C.Binary;
  }
  /** @nocollapse */
  static isUtf8(t) {
    return (t == null ? void 0 : t.typeId) === C.Utf8;
  }
  /** @nocollapse */
  static isBool(t) {
    return (t == null ? void 0 : t.typeId) === C.Bool;
  }
  /** @nocollapse */
  static isDecimal(t) {
    return (t == null ? void 0 : t.typeId) === C.Decimal;
  }
  /** @nocollapse */
  static isDate(t) {
    return (t == null ? void 0 : t.typeId) === C.Date;
  }
  /** @nocollapse */
  static isTime(t) {
    return (t == null ? void 0 : t.typeId) === C.Time;
  }
  /** @nocollapse */
  static isTimestamp(t) {
    return (t == null ? void 0 : t.typeId) === C.Timestamp;
  }
  /** @nocollapse */
  static isInterval(t) {
    return (t == null ? void 0 : t.typeId) === C.Interval;
  }
  /** @nocollapse */
  static isList(t) {
    return (t == null ? void 0 : t.typeId) === C.List;
  }
  /** @nocollapse */
  static isStruct(t) {
    return (t == null ? void 0 : t.typeId) === C.Struct;
  }
  /** @nocollapse */
  static isUnion(t) {
    return (t == null ? void 0 : t.typeId) === C.Union;
  }
  /** @nocollapse */
  static isFixedSizeBinary(t) {
    return (t == null ? void 0 : t.typeId) === C.FixedSizeBinary;
  }
  /** @nocollapse */
  static isFixedSizeList(t) {
    return (t == null ? void 0 : t.typeId) === C.FixedSizeList;
  }
  /** @nocollapse */
  static isMap(t) {
    return (t == null ? void 0 : t.typeId) === C.Map;
  }
  /** @nocollapse */
  static isDictionary(t) {
    return (t == null ? void 0 : t.typeId) === C.Dictionary;
  }
  /** @nocollapse */
  static isDenseUnion(t) {
    return It.isUnion(t) && t.mode === Ai.Dense;
  }
  /** @nocollapse */
  static isSparseUnion(t) {
    return It.isUnion(t) && t.mode === Ai.Sparse;
  }
  get typeId() {
    return C.NONE;
  }
}
DB = Symbol.toStringTag;
It[DB] = ((e) => (e.children = null, e.ArrayType = Array, e[Symbol.toStringTag] = "DataType"))(It.prototype);
let Gs = class extends It {
  toString() {
    return "Null";
  }
  get typeId() {
    return C.Null;
  }
};
EB = Symbol.toStringTag;
Gs[EB] = ((e) => e[Symbol.toStringTag] = "Null")(Gs.prototype);
class Xs extends It {
  constructor(t, n) {
    super(), this.isSigned = t, this.bitWidth = n;
  }
  get typeId() {
    return C.Int;
  }
  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 ? Sf : If;
    }
    throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);
  }
  toString() {
    return `${this.isSigned ? "I" : "Ui"}nt${this.bitWidth}`;
  }
}
OB = Symbol.toStringTag;
Xs[OB] = ((e) => (e.isSigned = null, e.bitWidth = null, e[Symbol.toStringTag] = "Int"))(Xs.prototype);
class Cu extends Xs {
  constructor() {
    super(!0, 32);
  }
  get ArrayType() {
    return Int32Array;
  }
}
Object.defineProperty(Cu.prototype, "ArrayType", { value: Int32Array });
class ku extends It {
  constructor(t) {
    super(), this.precision = t;
  }
  get typeId() {
    return C.Float;
  }
  get ArrayType() {
    switch (this.precision) {
      case mn.HALF:
        return Uint16Array;
      case mn.SINGLE:
        return Float32Array;
      case mn.DOUBLE:
        return Float64Array;
    }
    throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);
  }
  toString() {
    return `Float${this.precision << 5 || 16}`;
  }
}
LB = Symbol.toStringTag;
ku[LB] = ((e) => (e.precision = null, e[Symbol.toStringTag] = "Float"))(ku.prototype);
let Bp = class extends It {
  constructor() {
    super();
  }
  get typeId() {
    return C.Binary;
  }
  toString() {
    return "Binary";
  }
};
RB = Symbol.toStringTag;
Bp[RB] = ((e) => (e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "Binary"))(Bp.prototype);
let Np = class extends It {
  constructor() {
    super();
  }
  get typeId() {
    return C.Utf8;
  }
  toString() {
    return "Utf8";
  }
};
CB = Symbol.toStringTag;
Np[CB] = ((e) => (e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "Utf8"))(Np.prototype);
let Fp = class extends It {
  constructor() {
    super();
  }
  get typeId() {
    return C.Bool;
  }
  toString() {
    return "Bool";
  }
};
kB = Symbol.toStringTag;
Fp[kB] = ((e) => (e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "Bool"))(Fp.prototype);
let Dp = class extends It {
  constructor(t, n, i = 128) {
    super(), this.scale = t, this.precision = n, this.bitWidth = i;
  }
  get typeId() {
    return C.Decimal;
  }
  toString() {
    return `Decimal[${this.precision}e${this.scale > 0 ? "+" : ""}${this.scale}]`;
  }
};
UB = Symbol.toStringTag;
Dp[UB] = ((e) => (e.scale = null, e.precision = null, e.ArrayType = Uint32Array, e[Symbol.toStringTag] = "Decimal"))(Dp.prototype);
class Ep extends It {
  constructor(t) {
    super(), this.unit = t;
  }
  get typeId() {
    return C.Date;
  }
  toString() {
    return `Date${(this.unit + 1) * 32}<${ns[this.unit]}>`;
  }
}
zB = Symbol.toStringTag;
Ep[zB] = ((e) => (e.unit = null, e.ArrayType = Int32Array, e[Symbol.toStringTag] = "Date"))(Ep.prototype);
class Uu extends It {
  constructor(t, n) {
    super(), this.unit = t, this.bitWidth = n;
  }
  get typeId() {
    return C.Time;
  }
  toString() {
    return `Time${this.bitWidth}<${Yt[this.unit]}>`;
  }
  get ArrayType() {
    switch (this.bitWidth) {
      case 32:
        return Int32Array;
      case 64:
        return Sf;
    }
    throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);
  }
}
PB = Symbol.toStringTag;
Uu[PB] = ((e) => (e.unit = null, e.bitWidth = null, e[Symbol.toStringTag] = "Time"))(Uu.prototype);
class Op extends It {
  constructor(t, n) {
    super(), this.unit = t, this.timezone = n;
  }
  get typeId() {
    return C.Timestamp;
  }
  toString() {
    return `Timestamp<${Yt[this.unit]}${this.timezone ? `, ${this.timezone}` : ""}>`;
  }
}
VB = Symbol.toStringTag;
Op[VB] = ((e) => (e.unit = null, e.timezone = null, e.ArrayType = Int32Array, e[Symbol.toStringTag] = "Timestamp"))(Op.prototype);
class Lp extends It {
  constructor(t) {
    super(), this.unit = t;
  }
  get typeId() {
    return C.Interval;
  }
  toString() {
    return `Interval<${Ws[this.unit]}>`;
  }
}
jB = Symbol.toStringTag;
Lp[jB] = ((e) => (e.unit = null, e.ArrayType = Int32Array, e[Symbol.toStringTag] = "Interval"))(Lp.prototype);
let Rp = class extends It {
  constructor(t) {
    super(), this.children = [t];
  }
  get typeId() {
    return C.List;
  }
  toString() {
    return `List<${this.valueType}>`;
  }
  get valueType() {
    return this.children[0].type;
  }
  get valueField() {
    return this.children[0];
  }
  get ArrayType() {
    return this.valueType.ArrayType;
  }
};
YB = Symbol.toStringTag;
Rp[YB] = ((e) => (e.children = null, e[Symbol.toStringTag] = "List"))(Rp.prototype);
class an extends It {
  constructor(t) {
    super(), this.children = t;
  }
  get typeId() {
    return C.Struct;
  }
  toString() {
    return `Struct<{${this.children.map((t) => `${t.name}:${t.type}`).join(", ")}}>`;
  }
}
qB = Symbol.toStringTag;
an[qB] = ((e) => (e.children = null, e[Symbol.toStringTag] = "Struct"))(an.prototype);
class Cp extends It {
  constructor(t, n, i) {
    super(), 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));
  }
  get typeId() {
    return C.Union;
  }
  toString() {
    return `${this[Symbol.toStringTag]}<${this.children.map((t) => `${t.type}`).join(" | ")}>`;
  }
}
WB = Symbol.toStringTag;
Cp[WB] = ((e) => (e.mode = null, e.typeIds = null, e.children = null, e.typeIdToChildIndex = null, e.ArrayType = Int8Array, e[Symbol.toStringTag] = "Union"))(Cp.prototype);
let kp = class extends It {
  constructor(t) {
    super(), this.byteWidth = t;
  }
  get typeId() {
    return C.FixedSizeBinary;
  }
  toString() {
    return `FixedSizeBinary[${this.byteWidth}]`;
  }
};
GB = Symbol.toStringTag;
kp[GB] = ((e) => (e.byteWidth = null, e.ArrayType = Uint8Array, e[Symbol.toStringTag] = "FixedSizeBinary"))(kp.prototype);
let Up = class extends It {
  constructor(t, n) {
    super(), this.listSize = t, this.children = [n];
  }
  get typeId() {
    return C.FixedSizeList;
  }
  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}>`;
  }
};
XB = Symbol.toStringTag;
Up[XB] = ((e) => (e.children = null, e.listSize = null, e[Symbol.toStringTag] = "FixedSizeList"))(Up.prototype);
class zp extends It {
  constructor(t, n = !1) {
    super(), this.children = [t], this.keysSorted = n;
  }
  get typeId() {
    return C.Map;
  }
  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(", ")}}>`;
  }
}
HB = Symbol.toStringTag;
zp[HB] = ((e) => (e.children = null, e.keysSorted = null, e[Symbol.toStringTag] = "Map_"))(zp.prototype);
const Vnt = ((e) => () => ++e)(-1);
class Cc extends It {
  constructor(t, n, i, r) {
    super(), this.indices = n, this.dictionary = t, this.isOrdered = r || !1, this.id = i == null ? Vnt() : Mi(i);
  }
  get typeId() {
    return C.Dictionary;
  }
  get children() {
    return this.dictionary.children;
  }
  get valueType() {
    return this.dictionary;
  }
  get ArrayType() {
    return this.dictionary.ArrayType;
  }
  toString() {
    return `Dictionary<${this.indices}, ${this.dictionary}>`;
  }
}
KB = Symbol.toStringTag;
Cc[KB] = ((e) => (e.id = null, e.indices = null, e.isOrdered = null, e.dictionary = null, e[Symbol.toStringTag] = "Dictionary"))(Cc.prototype);
function Dr(e) {
  const t = e;
  switch (e.typeId) {
    case C.Decimal:
      return e.bitWidth / 32;
    case C.Timestamp:
      return 2;
    case C.Date:
      return 1 + t.unit;
    case C.Interval:
      return 1 + t.unit;
    case C.FixedSizeList:
      return t.listSize;
    case C.FixedSizeBinary:
      return t.byteWidth;
    default:
      return 1;
  }
}
class Ut {
  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 jnt(this, t, n);
  }
  getVisitFnByTypeId(t, n = !0) {
    return Ea(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;
  }
  visitBinary(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;
  }
  visitFixedSizeList(t, ...n) {
    return null;
  }
  visitMap(t, ...n) {
    return null;
  }
}
function jnt(e, t, n = !0) {
  return typeof t == "number" ? Ea(e, t, n) : typeof t == "string" && t in C ? Ea(e, C[t], n) : t && t instanceof It ? Ea(e, aS(t), n) : t != null && t.type && t.type instanceof It ? Ea(e, aS(t.type), n) : Ea(e, C.NONE, n);
}
function Ea(e, t, n = !0) {
  let i = null;
  switch (t) {
    case C.Null:
      i = e.visitNull;
      break;
    case C.Bool:
      i = e.visitBool;
      break;
    case C.Int:
      i = e.visitInt;
      break;
    case C.Int8:
      i = e.visitInt8 || e.visitInt;
      break;
    case C.Int16:
      i = e.visitInt16 || e.visitInt;
      break;
    case C.Int32:
      i = e.visitInt32 || e.visitInt;
      break;
    case C.Int64:
      i = e.visitInt64 || e.visitInt;
      break;
    case C.Uint8:
      i = e.visitUint8 || e.visitInt;
      break;
    case C.Uint16:
      i = e.visitUint16 || e.visitInt;
      break;
    case C.Uint32:
      i = e.visitUint32 || e.visitInt;
      break;
    case C.Uint64:
      i = e.visitUint64 || e.visitInt;
      break;
    case C.Float:
      i = e.visitFloat;
      break;
    case C.Float16:
      i = e.visitFloat16 || e.visitFloat;
      break;
    case C.Float32:
      i = e.visitFloat32 || e.visitFloat;
      break;
    case C.Float64:
      i = e.visitFloat64 || e.visitFloat;
      break;
    case C.Utf8:
      i = e.visitUtf8;
      break;
    case C.Binary:
      i = e.visitBinary;
      break;
    case C.FixedSizeBinary:
      i = e.visitFixedSizeBinary;
      break;
    case C.Date:
      i = e.visitDate;
      break;
    case C.DateDay:
      i = e.visitDateDay || e.visitDate;
      break;
    case C.DateMillisecond:
      i = e.visitDateMillisecond || e.visitDate;
      break;
    case C.Timestamp:
      i = e.visitTimestamp;
      break;
    case C.TimestampSecond:
      i = e.visitTimestampSecond || e.visitTimestamp;
      break;
    case C.TimestampMillisecond:
      i = e.visitTimestampMillisecond || e.visitTimestamp;
      break;
    case C.TimestampMicrosecond:
      i = e.visitTimestampMicrosecond || e.visitTimestamp;
      break;
    case C.TimestampNanosecond:
      i = e.visitTimestampNanosecond || e.visitTimestamp;
      break;
    case C.Time:
      i = e.visitTime;
      break;
    case C.TimeSecond:
      i = e.visitTimeSecond || e.visitTime;
      break;
    case C.TimeMillisecond:
      i = e.visitTimeMillisecond || e.visitTime;
      break;
    case C.TimeMicrosecond:
      i = e.visitTimeMicrosecond || e.visitTime;
      break;
    case C.TimeNanosecond:
      i = e.visitTimeNanosecond || e.visitTime;
      break;
    case C.Decimal:
      i = e.visitDecimal;
      break;
    case C.List:
      i = e.visitList;
      break;
    case C.Struct:
      i = e.visitStruct;
      break;
    case C.Union:
      i = e.visitUnion;
      break;
    case C.DenseUnion:
      i = e.visitDenseUnion || e.visitUnion;
      break;
    case C.SparseUnion:
      i = e.visitSparseUnion || e.visitUnion;
      break;
    case C.Dictionary:
      i = e.visitDictionary;
      break;
    case C.Interval:
      i = e.visitInterval;
      break;
    case C.IntervalDayTime:
      i = e.visitIntervalDayTime || e.visitInterval;
      break;
    case C.IntervalYearMonth:
      i = e.visitIntervalYearMonth || e.visitInterval;
      break;
    case C.FixedSizeList:
      i = e.visitFixedSizeList;
      break;
    case C.Map:
      i = e.visitMap;
      break;
  }
  if (typeof i == "function")
    return i;
  if (!n)
    return () => null;
  throw new Error(`Unrecognized type '${C[t]}'`);
}
function aS(e) {
  switch (e.typeId) {
    case C.Null:
      return C.Null;
    case C.Int: {
      const { bitWidth: t, isSigned: n } = e;
      switch (t) {
        case 8:
          return n ? C.Int8 : C.Uint8;
        case 16:
          return n ? C.Int16 : C.Uint16;
        case 32:
          return n ? C.Int32 : C.Uint32;
        case 64:
          return n ? C.Int64 : C.Uint64;
      }
      return C.Int;
    }
    case C.Float:
      switch (e.precision) {
        case mn.HALF:
          return C.Float16;
        case mn.SINGLE:
          return C.Float32;
        case mn.DOUBLE:
          return C.Float64;
      }
      return C.Float;
    case C.Binary:
      return C.Binary;
    case C.Utf8:
      return C.Utf8;
    case C.Bool:
      return C.Bool;
    case C.Decimal:
      return C.Decimal;
    case C.Time:
      switch (e.unit) {
        case Yt.SECOND:
          return C.TimeSecond;
        case Yt.MILLISECOND:
          return C.TimeMillisecond;
        case Yt.MICROSECOND:
          return C.TimeMicrosecond;
        case Yt.NANOSECOND:
          return C.TimeNanosecond;
      }
      return C.Time;
    case C.Timestamp:
      switch (e.unit) {
        case Yt.SECOND:
          return C.TimestampSecond;
        case Yt.MILLISECOND:
          return C.TimestampMillisecond;
        case Yt.MICROSECOND:
          return C.TimestampMicrosecond;
        case Yt.NANOSECOND:
          return C.TimestampNanosecond;
      }
      return C.Timestamp;
    case C.Date:
      switch (e.unit) {
        case ns.DAY:
          return C.DateDay;
        case ns.MILLISECOND:
          return C.DateMillisecond;
      }
      return C.Date;
    case C.Interval:
      switch (e.unit) {
        case Ws.DAY_TIME:
          return C.IntervalDayTime;
        case Ws.YEAR_MONTH:
          return C.IntervalYearMonth;
      }
      return C.Interval;
    case C.Map:
      return C.Map;
    case C.List:
      return C.List;
    case C.Struct:
      return C.Struct;
    case C.Union:
      switch (e.mode) {
        case Ai.Dense:
          return C.DenseUnion;
        case Ai.Sparse:
          return C.SparseUnion;
      }
      return C.Union;
    case C.FixedSizeBinary:
      return C.FixedSizeBinary;
    case C.FixedSizeList:
      return C.FixedSizeList;
    case C.Dictionary:
      return C.Dictionary;
  }
  throw new Error(`Unrecognized type '${C[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;
const ZB = new Float64Array(1), wa = new Uint32Array(ZB.buffer);
function JB(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 Ynt(e) {
  if (e !== e)
    return 32256;
  ZB[0] = e;
  const t = (wa[1] & 2147483648) >> 16 & 65535;
  let n = wa[1] & 2146435072, i = 0;
  return n >= 1089470464 ? wa[0] > 0 ? n = 31744 : (n = (n & 2080374784) >> 16, i = (wa[1] & 1048575) >> 10) : n <= 1056964608 ? (i = 1048576 + (wa[1] & 1048575), i = 1048576 + (i << (n >> 20) - 998) >> 21, n = 0) : (n = n - 1056964608 >> 10, i = (wa[1] & 1048575) + 512 >> 10), t | n | i & 65535;
}
class vt extends Ut {
}
function Mt(e) {
  return (t, n, i) => {
    if (t.setValid(n, i != null))
      return e(t, n, i);
  };
}
const qnt = (e, t, n) => {
  e[t] = Math.trunc(n / 864e5);
}, dw = (e, t, n) => {
  e[t] = Math.trunc(n % 4294967296), e[t + 1] = Math.trunc(n / 4294967296);
}, Wnt = (e, t, n) => {
  e[t] = Math.trunc(n * 1e3 % 4294967296), e[t + 1] = Math.trunc(n * 1e3 / 4294967296);
}, Gnt = (e, t, n) => {
  e[t] = Math.trunc(n * 1e6 % 4294967296), e[t + 1] = Math.trunc(n * 1e6 / 4294967296);
}, QB = (e, t, n, i) => {
  if (n + 1 < t.length) {
    const { [n]: r, [n + 1]: s } = t;
    e.set(i.subarray(0, s - r), r);
  }
}, Xnt = ({ offset: e, values: t }, n, i) => {
  const r = e + n;
  i ? t[r >> 3] |= 1 << r % 8 : t[r >> 3] &= ~(1 << r % 8);
}, us = ({ values: e }, t, n) => {
  e[t] = n;
}, pw = ({ values: e }, t, n) => {
  e[t] = n;
}, tN = ({ values: e }, t, n) => {
  e[t] = Ynt(n);
}, Hnt = (e, t, n) => {
  switch (e.type.precision) {
    case mn.HALF:
      return tN(e, t, n);
    case mn.SINGLE:
    case mn.DOUBLE:
      return pw(e, t, n);
  }
}, eN = ({ values: e }, t, n) => {
  qnt(e, t, n.valueOf());
}, nN = ({ values: e }, t, n) => {
  dw(e, t * 2, n.valueOf());
}, Knt = ({ stride: e, values: t }, n, i) => {
  t.set(i.subarray(0, e), e * n);
}, Znt = ({ values: e, valueOffsets: t }, n, i) => QB(e, t, n, i), Jnt = ({ values: e, valueOffsets: t }, n, i) => {
  QB(e, t, n, cw(i));
}, Qnt = (e, t, n) => {
  e.type.unit === ns.DAY ? eN(e, t, n) : nN(e, t, n);
}, iN = ({ values: e }, t, n) => dw(e, t * 2, n / 1e3), rN = ({ values: e }, t, n) => dw(e, t * 2, n), sN = ({ values: e }, t, n) => Wnt(e, t * 2, n), oN = ({ values: e }, t, n) => Gnt(e, t * 2, n), tit = (e, t, n) => {
  switch (e.type.unit) {
    case Yt.SECOND:
      return iN(e, t, n);
    case Yt.MILLISECOND:
      return rN(e, t, n);
    case Yt.MICROSECOND:
      return sN(e, t, n);
    case Yt.NANOSECOND:
      return oN(e, t, n);
  }
}, aN = ({ values: e }, t, n) => {
  e[t] = n;
}, cN = ({ values: e }, t, n) => {
  e[t] = n;
}, lN = ({ values: e }, t, n) => {
  e[t] = n;
}, uN = ({ values: e }, t, n) => {
  e[t] = n;
}, eit = (e, t, n) => {
  switch (e.type.unit) {
    case Yt.SECOND:
      return aN(e, t, n);
    case Yt.MILLISECOND:
      return cN(e, t, n);
    case Yt.MICROSECOND:
      return lN(e, t, n);
    case Yt.NANOSECOND:
      return uN(e, t, n);
  }
}, nit = ({ values: e, stride: t }, n, i) => {
  e.set(i.subarray(0, t), t * n);
}, iit = (e, t, n) => {
  const i = e.children[0], r = e.valueOffsets, s = si.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));
}, rit = (e, t, n) => {
  const i = e.children[0], { valueOffsets: r } = e, s = si.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;
}, sit = (e, t) => (n, i, r, s) => i && n(i, e, t[s]), oit = (e, t) => (n, i, r, s) => i && n(i, e, t.get(s)), ait = (e, t) => (n, i, r, s) => i && n(i, e, t.get(r.name)), cit = (e, t) => (n, i, r, s) => i && n(i, e, t[r.name]), lit = (e, t, n) => {
  const i = e.type.children.map((s) => si.getVisitFn(s.type)), r = n instanceof Map ? ait(t, n) : n instanceof te ? oit(t, n) : Array.isArray(n) ? sit(t, n) : cit(t, n);
  e.type.children.forEach((s, o) => r(i[o], e.children[o], s, o));
}, uit = (e, t, n) => {
  e.type.mode === Ai.Dense ? fN(e, t, n) : hN(e, t, n);
}, fN = (e, t, n) => {
  const i = e.type.typeIdToChildIndex[e.typeIds[t]], r = e.children[i];
  si.visit(r, e.valueOffsets[t], n);
}, hN = (e, t, n) => {
  const i = e.type.typeIdToChildIndex[e.typeIds[t]], r = e.children[i];
  si.visit(r, t, n);
}, fit = (e, t, n) => {
  var i;
  (i = e.dictionary) === null || i === void 0 || i.set(e.values[t], n);
}, hit = (e, t, n) => {
  e.type.unit === Ws.DAY_TIME ? dN(e, t, n) : pN(e, t, n);
}, dN = ({ values: e }, t, n) => {
  e.set(n.subarray(0, 2), 2 * t);
}, pN = ({ values: e }, t, n) => {
  e[t] = n[0] * 12 + n[1] % 12;
}, dit = (e, t, n) => {
  const { stride: i } = e, r = e.children[0], s = si.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 = Mt(Xnt);
vt.prototype.visitInt = Mt(us);
vt.prototype.visitInt8 = Mt(us);
vt.prototype.visitInt16 = Mt(us);
vt.prototype.visitInt32 = Mt(us);
vt.prototype.visitInt64 = Mt(us);
vt.prototype.visitUint8 = Mt(us);
vt.prototype.visitUint16 = Mt(us);
vt.prototype.visitUint32 = Mt(us);
vt.prototype.visitUint64 = Mt(us);
vt.prototype.visitFloat = Mt(Hnt);
vt.prototype.visitFloat16 = Mt(tN);
vt.prototype.visitFloat32 = Mt(pw);
vt.prototype.visitFloat64 = Mt(pw);
vt.prototype.visitUtf8 = Mt(Jnt);
vt.prototype.visitBinary = Mt(Znt);
vt.prototype.visitFixedSizeBinary = Mt(Knt);
vt.prototype.visitDate = Mt(Qnt);
vt.prototype.visitDateDay = Mt(eN);
vt.prototype.visitDateMillisecond = Mt(nN);
vt.prototype.visitTimestamp = Mt(tit);
vt.prototype.visitTimestampSecond = Mt(iN);
vt.prototype.visitTimestampMillisecond = Mt(rN);
vt.prototype.visitTimestampMicrosecond = Mt(sN);
vt.prototype.visitTimestampNanosecond = Mt(oN);
vt.prototype.visitTime = Mt(eit);
vt.prototype.visitTimeSecond = Mt(aN);
vt.prototype.visitTimeMillisecond = Mt(cN);
vt.prototype.visitTimeMicrosecond = Mt(lN);
vt.prototype.visitTimeNanosecond = Mt(uN);
vt.prototype.visitDecimal = Mt(nit);
vt.prototype.visitList = Mt(iit);
vt.prototype.visitStruct = Mt(lit);
vt.prototype.visitUnion = Mt(uit);
vt.prototype.visitDenseUnion = Mt(fN);
vt.prototype.visitSparseUnion = Mt(hN);
vt.prototype.visitDictionary = Mt(fit);
vt.prototype.visitInterval = Mt(hit);
vt.prototype.visitIntervalDayTime = Mt(dN);
vt.prototype.visitIntervalYearMonth = Mt(pN);
vt.prototype.visitFixedSizeList = Mt(dit);
vt.prototype.visitMap = Mt(rit);
const si = new vt(), li = Symbol.for("parent"), ac = Symbol.for("rowIndex");
class yw {
  constructor(t, n) {
    return this[li] = t, this[ac] = n, new Proxy(this, new yit());
  }
  toArray() {
    return Object.values(this.toJSON());
  }
  toJSON() {
    const t = this[ac], n = this[li], i = n.type.children, r = {};
    for (let s = -1, o = i.length; ++s < o; )
      r[i[s].name] = xn.visit(n.children[s], t);
    return r;
  }
  toString() {
    return `{${[...this].map(([t, n]) => `${Lu(t)}: ${Lu(n)}`).join(", ")}}`;
  }
  [Symbol.for("nodejs.util.inspect.custom")]() {
    return this.toString();
  }
  [Symbol.iterator]() {
    return new pit(this[li], this[ac]);
  }
}
class pit {
  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,
        xn.visit(this.children[t], this.rowIndex)
      ]
    }) : { done: !0, value: null };
  }
}
Object.defineProperties(yw.prototype, {
  [Symbol.toStringTag]: { enumerable: !1, configurable: !1, value: "Row" },
  [li]: { writable: !0, enumerable: !1, configurable: !1, value: null },
  [ac]: { writable: !0, enumerable: !1, configurable: !1, value: -1 }
});
class yit {
  isExtensible() {
    return !1;
  }
  deleteProperty() {
    return !1;
  }
  preventExtensions() {
    return !0;
  }
  ownKeys(t) {
    return t[li].type.children.map((n) => n.name);
  }
  has(t, n) {
    return t[li].type.children.findIndex((i) => i.name === n) !== -1;
  }
  getOwnPropertyDescriptor(t, n) {
    if (t[li].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[li].type.children.findIndex((r) => r.name === n);
    if (i !== -1) {
      const r = xn.visit(t[li].children[i], t[ac]);
      return Reflect.set(t, n, r), r;
    }
  }
  set(t, n, i) {
    const r = t[li].type.children.findIndex((s) => s.name === n);
    return r !== -1 ? (si.visit(t[li].children[r], t[ac], i), Reflect.set(t, n, i)) : Reflect.has(t, n) || typeof n == "symbol" ? Reflect.set(t, n, i) : !1;
  }
}
class pt extends Ut {
}
function xt(e) {
  return (t, n) => t.getValid(n) ? e(t, n) : null;
}
const mit = (e, t) => 864e5 * e[t], mw = (e, t) => 4294967296 * e[t + 1] + (e[t] >>> 0), git = (e, t) => 4294967296 * (e[t + 1] / 1e3) + (e[t] >>> 0) / 1e3, bit = (e, t) => 4294967296 * (e[t + 1] / 1e6) + (e[t] >>> 0) / 1e6, yN = (e) => new Date(e), _it = (e, t) => yN(mit(e, t)), wit = (e, t) => yN(mw(e, t)), vit = (e, t) => null, mN = (e, t, n) => {
  if (n + 1 >= t.length)
    return null;
  const i = t[n], r = t[n + 1];
  return e.subarray(i, r);
}, xit = ({ offset: e, values: t }, n) => {
  const i = e + n;
  return (t[i >> 3] & 1 << i % 8) !== 0;
}, gN = ({ values: e }, t) => _it(e, t), bN = ({ values: e }, t) => wit(e, t * 2), ao = ({ stride: e, values: t }, n) => t[e * n], Sit = ({ stride: e, values: t }, n) => JB(t[e * n]), _N = ({ values: e }, t) => e[t], Iit = ({ stride: e, values: t }, n) => t.subarray(e * n, e * (n + 1)), Ait = ({ values: e, valueOffsets: t }, n) => mN(e, t, n), Mit = ({ values: e, valueOffsets: t }, n) => {
  const i = mN(e, t, n);
  return i !== null ? d1(i) : null;
}, $it = ({ values: e }, t) => e[t], Tit = ({ type: e, values: t }, n) => e.precision !== mn.HALF ? t[n] : JB(t[n]), Bit = (e, t) => e.type.unit === ns.DAY ? gN(e, t) : bN(e, t), wN = ({ values: e }, t) => 1e3 * mw(e, t * 2), vN = ({ values: e }, t) => mw(e, t * 2), xN = ({ values: e }, t) => git(e, t * 2), SN = ({ values: e }, t) => bit(e, t * 2), Nit = (e, t) => {
  switch (e.type.unit) {
    case Yt.SECOND:
      return wN(e, t);
    case Yt.MILLISECOND:
      return vN(e, t);
    case Yt.MICROSECOND:
      return xN(e, t);
    case Yt.NANOSECOND:
      return SN(e, t);
  }
}, IN = ({ values: e }, t) => e[t], AN = ({ values: e }, t) => e[t], MN = ({ values: e }, t) => e[t], $N = ({ values: e }, t) => e[t], Fit = (e, t) => {
  switch (e.type.unit) {
    case Yt.SECOND:
      return IN(e, t);
    case Yt.MILLISECOND:
      return AN(e, t);
    case Yt.MICROSECOND:
      return MN(e, t);
    case Yt.NANOSECOND:
      return $N(e, t);
  }
}, Dit = ({ values: e, stride: t }, n) => hw.decimal(e.subarray(t * n, t * (n + 1))), Eit = (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 te([c]);
}, Oit = (e, t) => {
  const { valueOffsets: n, children: i } = e, { [t]: r, [t + 1]: s } = n, o = i[0];
  return new gw(o.slice(r, s - r));
}, Lit = (e, t) => new yw(e, t), Rit = (e, t) => e.type.mode === Ai.Dense ? TN(e, t) : BN(e, t), TN = (e, t) => {
  const n = e.type.typeIdToChildIndex[e.typeIds[t]], i = e.children[n];
  return xn.visit(i, e.valueOffsets[t]);
}, BN = (e, t) => {
  const n = e.type.typeIdToChildIndex[e.typeIds[t]], i = e.children[n];
  return xn.visit(i, t);
}, Cit = (e, t) => {
  var n;
  return (n = e.dictionary) === null || n === void 0 ? void 0 : n.get(e.values[t]);
}, kit = (e, t) => e.type.unit === Ws.DAY_TIME ? NN(e, t) : FN(e, t), NN = ({ values: e }, t) => e.subarray(2 * t, 2 * (t + 1)), FN = ({ 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;
}, Uit = (e, t) => {
  const { stride: n, children: i } = e, s = i[0].slice(t * n, n);
  return new te([s]);
};
pt.prototype.visitNull = xt(vit);
pt.prototype.visitBool = xt(xit);
pt.prototype.visitInt = xt($it);
pt.prototype.visitInt8 = xt(ao);
pt.prototype.visitInt16 = xt(ao);
pt.prototype.visitInt32 = xt(ao);
pt.prototype.visitInt64 = xt(_N);
pt.prototype.visitUint8 = xt(ao);
pt.prototype.visitUint16 = xt(ao);
pt.prototype.visitUint32 = xt(ao);
pt.prototype.visitUint64 = xt(_N);
pt.prototype.visitFloat = xt(Tit);
pt.prototype.visitFloat16 = xt(Sit);
pt.prototype.visitFloat32 = xt(ao);
pt.prototype.visitFloat64 = xt(ao);
pt.prototype.visitUtf8 = xt(Mit);
pt.prototype.visitBinary = xt(Ait);
pt.prototype.visitFixedSizeBinary = xt(Iit);
pt.prototype.visitDate = xt(Bit);
pt.prototype.visitDateDay = xt(gN);
pt.prototype.visitDateMillisecond = xt(bN);
pt.prototype.visitTimestamp = xt(Nit);
pt.prototype.visitTimestampSecond = xt(wN);
pt.prototype.visitTimestampMillisecond = xt(vN);
pt.prototype.visitTimestampMicrosecond = xt(xN);
pt.prototype.visitTimestampNanosecond = xt(SN);
pt.prototype.visitTime = xt(Fit);
pt.prototype.visitTimeSecond = xt(IN);
pt.prototype.visitTimeMillisecond = xt(AN);
pt.prototype.visitTimeMicrosecond = xt(MN);
pt.prototype.visitTimeNanosecond = xt($N);
pt.prototype.visitDecimal = xt(Dit);
pt.prototype.visitList = xt(Eit);
pt.prototype.visitStruct = xt(Lit);
pt.prototype.visitUnion = xt(Rit);
pt.prototype.visitDenseUnion = xt(TN);
pt.prototype.visitSparseUnion = xt(BN);
pt.prototype.visitDictionary = xt(Cit);
pt.prototype.visitInterval = xt(kit);
pt.prototype.visitIntervalDayTime = xt(NN);
pt.prototype.visitIntervalYearMonth = xt(FN);
pt.prototype.visitFixedSizeList = xt(Uit);
pt.prototype.visitMap = xt(Oit);
const xn = new pt(), Wi = Symbol.for("keys"), cc = Symbol.for("vals");
class gw {
  constructor(t) {
    return this[Wi] = new te([t.children[0]]).memoize(), this[cc] = t.children[1], new Proxy(this, new Pit());
  }
  [Symbol.iterator]() {
    return new zit(this[Wi], this[cc]);
  }
  get size() {
    return this[Wi].length;
  }
  toArray() {
    return Object.values(this.toJSON());
  }
  toJSON() {
    const t = this[Wi], n = this[cc], i = {};
    for (let r = -1, s = t.length; ++r < s; )
      i[t.get(r)] = xn.visit(n, r);
    return i;
  }
  toString() {
    return `{${[...this].map(([t, n]) => `${Lu(t)}: ${Lu(n)}`).join(", ")}}`;
  }
  [Symbol.for("nodejs.util.inspect.custom")]() {
    return this.toString();
  }
}
class zit {
  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),
        xn.visit(this.vals, t)
      ]
    });
  }
}
class Pit {
  isExtensible() {
    return !1;
  }
  deleteProperty() {
    return !1;
  }
  preventExtensions() {
    return !0;
  }
  ownKeys(t) {
    return t[Wi].toArray().map(String);
  }
  has(t, n) {
    return t[Wi].includes(n);
  }
  getOwnPropertyDescriptor(t, n) {
    if (t[Wi].indexOf(n) !== -1)
      return { writable: !0, enumerable: !0, configurable: !0 };
  }
  get(t, n) {
    if (Reflect.has(t, n))
      return t[n];
    const i = t[Wi].indexOf(n);
    if (i !== -1) {
      const r = xn.visit(Reflect.get(t, cc), i);
      return Reflect.set(t, n, r), r;
    }
  }
  set(t, n, i) {
    const r = t[Wi].indexOf(n);
    return r !== -1 ? (si.visit(Reflect.get(t, cc), r, i), Reflect.set(t, n, i)) : Reflect.has(t, n) ? Reflect.set(t, n, i) : !1;
  }
}
Object.defineProperties(gw.prototype, {
  [Symbol.toStringTag]: { enumerable: !1, configurable: !1, value: "Row" },
  [Wi]: { writable: !0, enumerable: !1, configurable: !1, value: null },
  [cc]: { writable: !0, enumerable: !1, configurable: !1, value: null }
});
let cS;
function DN(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 && (cS = s, s = o, o = cS), o > r && (o = r), i ? i(e, s, o) : [s, o];
}
const lS = (e) => e !== e;
function ll(e) {
  if (typeof e !== "object" || e === null)
    return lS(e) ? lS : (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 ? Ent(e, n) : !1 : e instanceof Map ? jit(e) : Array.isArray(e) ? Vit(e) : e instanceof te ? Yit(e) : qit(e, !0);
}
function Vit(e) {
  const t = [];
  for (let n = -1, i = e.length; ++n < i; )
    t[n] = ll(e[n]);
  return w0(t);
}
function jit(e) {
  let t = -1;
  const n = [];
  for (const i of e.values())
    n[++t] = ll(i);
  return w0(n);
}
function Yit(e) {
  const t = [];
  for (let n = -1, i = e.length; ++n < i; )
    t[n] = ll(e.get(n));
  return w0(t);
}
function qit(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] = ll(e[n[r]]);
  return w0(i, n);
}
function w0(e, t) {
  return (n) => {
    if (!n || typeof n != "object")
      return !1;
    switch (n.constructor) {
      case Array:
        return Wit(e, n);
      case Map:
        return uS(e, n, n.keys());
      case gw:
      case yw:
      case Object:
      case void 0:
        return uS(e, n, t || Object.keys(n));
    }
    return n instanceof te ? Git(e, n) : !1;
  };
}
function Wit(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 Git(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 uS(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 EN(e, t, n, i) {
  return (n & 1 << i) !== 0;
}
function Xit(e, t, n, i) {
  return (n & 1 << i) >> i;
}
function Hit(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
      m1(new bw(n, e, t, null, EN)).subarray(0, i)
    )), r;
  }
  return n;
}
function m1(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 bw {
  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 g1(e, t, n) {
  if (n - t <= 0)
    return 0;
  if (n - t < 8) {
    let s = 0;
    for (const o of new bw(e, t, n - t, e, Xit))
      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
    g1(e, t, r) + // Get the popcnt of bits between the right hand side, and the next lowest multiple of 8
    g1(e, i, n) + // Get the popcnt of all bits between the left and right hand sides' multiples of 8
    Kit(e, r >> 3, i - r >> 3)
  );
}
function Kit(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 += Nm(s.getUint32(r)), r += 4;
  for (; o - r >= 2; )
    i += Nm(s.getUint16(r)), r += 2;
  for (; o - r >= 1; )
    i += Nm(s.getUint8(r)), r += 1;
  return i;
}
function Nm(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 Zit = -1;
class ue {
  get typeId() {
    return this.type.typeId;
  }
  get ArrayType() {
    return this.type.ArrayType;
  }
  get buffers() {
    return [this.valueOffsets, this.values, this.nullBitmap, this.typeIds];
  }
  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() {
    let t = this._nullCount, n;
    return t <= Zit && (n = this.nullBitmap) && (this._nullCount = t = this.length - g1(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 ue ? (this.stride = s.stride, this.values = s.values, this.typeIds = s.typeIds, this.nullBitmap = s.nullBitmap, this.valueOffsets = s.valueOffsets) : (this.stride = Dr(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))), this.nullable = this._nullCount !== 0 && this.nullBitmap && this.nullBitmap.byteLength > 0;
  }
  getValid(t) {
    if (this.nullable && this.nullCount > 0) {
      const n = this.offset + t;
      return (this.nullBitmap[n >> 3] & 1 << n % 8) !== 0;
    }
    return !0;
  }
  setValid(t, n) {
    if (!this.nullable)
      return n;
    if (!this.nullBitmap || this.nullBitmap.byteLength <= t >> 3) {
      const { nullBitmap: c } = this._changeLengthAndBackfillNullBitmap(this.length);
      Object.assign(this, { nullBitmap: c, _nullCount: 0 });
    }
    const { nullBitmap: i, offset: r } = this, s = r + t >> 3, o = (r + t) % 8, a = i[s] >> o & 1;
    return n ? a === 0 && (i[s] |= 1 << o, this._nullCount = this.nullCount + 1) : a === 1 && (i[s] &= ~(1 << o), this._nullCount = this.nullCount - 1), n;
  }
  clone(t = this.type, n = this.offset, i = this.length, r = this._nullCount, s = this, o = this.children) {
    return new ue(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 === C.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(Hit(this.offset, n, this.nullBitmap), 0);
    const s = this.buffers;
    return s[Fr.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[Fr.TYPE]) && (o[Fr.TYPE] = s.subarray(t, t + n)), (s = o[Fr.OFFSET]) && (o[Fr.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[Fr.DATA]) && (o[Fr.DATA] = r === 6 ? s : s.subarray(i * t, i * (t + n))), o;
  }
  _sliceChildren(t, n, i) {
    return t.map((r) => r.slice(n, i));
  }
}
ue.prototype.children = Object.freeze([]);
class su 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 ue(n, i, r, 0);
  }
  visitBool(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Ht(t.nullBitmap), s = ie(n.ArrayType, t.data), { ["length"]: o = s.length >> 3, ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new ue(n, i, o, a, [void 0, s, r]);
  }
  visitInt(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Ht(t.nullBitmap), s = ie(n.ArrayType, t.data), { ["length"]: o = s.length, ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new ue(n, i, o, a, [void 0, s, r]);
  }
  visitFloat(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Ht(t.nullBitmap), s = ie(n.ArrayType, t.data), { ["length"]: o = s.length, ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new ue(n, i, o, a, [void 0, s, r]);
  }
  visitUtf8(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Ht(t.data), s = Ht(t.nullBitmap), o = $l(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new ue(n, i, a, c, [o, r, s]);
  }
  visitBinary(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Ht(t.data), s = Ht(t.nullBitmap), o = $l(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new ue(n, i, a, c, [o, r, s]);
  }
  visitFixedSizeBinary(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Ht(t.nullBitmap), s = ie(n.ArrayType, t.data), { ["length"]: o = s.length / Dr(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new ue(n, i, o, a, [void 0, s, r]);
  }
  visitDate(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Ht(t.nullBitmap), s = ie(n.ArrayType, t.data), { ["length"]: o = s.length / Dr(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new ue(n, i, o, a, [void 0, s, r]);
  }
  visitTimestamp(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Ht(t.nullBitmap), s = ie(n.ArrayType, t.data), { ["length"]: o = s.length / Dr(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new ue(n, i, o, a, [void 0, s, r]);
  }
  visitTime(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Ht(t.nullBitmap), s = ie(n.ArrayType, t.data), { ["length"]: o = s.length / Dr(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new ue(n, i, o, a, [void 0, s, r]);
  }
  visitDecimal(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Ht(t.nullBitmap), s = ie(n.ArrayType, t.data), { ["length"]: o = s.length / Dr(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new ue(n, i, o, a, [void 0, s, r]);
  }
  visitList(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["child"]: r } = t, s = Ht(t.nullBitmap), o = $l(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new ue(n, i, a, c, [o, void 0, s], [r]);
  }
  visitStruct(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["children"]: r = [] } = t, s = Ht(t.nullBitmap), { length: o = r.reduce((c, { length: l }) => Math.max(c, l), 0), nullCount: a = t.nullBitmap ? -1 : 0 } = t;
    return new ue(n, i, o, a, [void 0, void 0, s], r);
  }
  visitUnion(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["children"]: r = [] } = t, s = Ht(t.nullBitmap), o = ie(n.ArrayType, t.typeIds), { ["length"]: a = o.length, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    if (It.isSparseUnion(n))
      return new ue(n, i, a, c, [void 0, void 0, s, o], r);
    const l = $l(t.valueOffsets);
    return new ue(n, i, a, c, [l, void 0, s, o], r);
  }
  visitDictionary(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Ht(t.nullBitmap), s = ie(n.indices.ArrayType, t.data), { ["dictionary"]: o = new te([new su().visit({ type: n.dictionary })]) } = t, { ["length"]: a = s.length, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new ue(n, i, a, c, [void 0, s, r], [], o);
  }
  visitInterval(t) {
    const { ["type"]: n, ["offset"]: i = 0 } = t, r = Ht(t.nullBitmap), s = ie(n.ArrayType, t.data), { ["length"]: o = s.length / Dr(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new ue(n, i, o, a, [void 0, s, r]);
  }
  visitFixedSizeList(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["child"]: r = new su().visit({ type: n.valueType }) } = t, s = Ht(t.nullBitmap), { ["length"]: o = r.length / Dr(n), ["nullCount"]: a = t.nullBitmap ? -1 : 0 } = t;
    return new ue(n, i, o, a, [void 0, void 0, s], [r]);
  }
  visitMap(t) {
    const { ["type"]: n, ["offset"]: i = 0, ["child"]: r = new su().visit({ type: n.childType }) } = t, s = Ht(t.nullBitmap), o = $l(t.valueOffsets), { ["length"]: a = o.length - 1, ["nullCount"]: c = t.nullBitmap ? -1 : 0 } = t;
    return new ue(n, i, a, c, [o, void 0, s], [r]);
  }
}
function Rt(e) {
  return new su().visit(e);
}
class fS {
  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 ON(e) {
  return e.reduce((t, n) => t + n.nullCount, 0);
}
function LN(e) {
  return e.reduce((t, n, i) => (t[i + 1] = t[i] + n.length, t), new Uint32Array(e.length + 1));
}
function RN(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 _w(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 ww(e, t) {
  return e.getValid(t);
}
function lc(e) {
  function t(n, i, r) {
    return e(n[i], r);
  }
  return function(n) {
    const i = this.data;
    return _w(i, this._offsets, n, t);
  };
}
function CN(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 = _w(s, this._offsets, i, n);
    return t = void 0, o;
  };
}
function kN(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) : _w(s, this._offsets, r, n);
    return t = void 0, o;
  };
}
class yt extends Ut {
}
function Jit(e, t) {
  return t === null && e.length > 0 ? 0 : -1;
}
function Qit(e, t) {
  const { nullBitmap: n } = e;
  if (!n || e.nullCount <= 0)
    return -1;
  let i = 0;
  for (const r of new bw(n, e.offset + (t || 0), e.length, n, EN)) {
    if (!r)
      return i;
    ++i;
  }
  return -1;
}
function Bt(e, t, n) {
  if (t === void 0)
    return -1;
  if (t === null)
    return Qit(e, n);
  const i = xn.getVisitFn(e), r = ll(t);
  for (let s = (n || 0) - 1, o = e.length; ++s < o; )
    if (r(i(e, s)))
      return s;
  return -1;
}
function UN(e, t, n) {
  const i = xn.getVisitFn(e), r = ll(t);
  for (let s = (n || 0) - 1, o = e.length; ++s < o; )
    if (r(i(e, s)))
      return s;
  return -1;
}
yt.prototype.visitNull = Jit;
yt.prototype.visitBool = Bt;
yt.prototype.visitInt = Bt;
yt.prototype.visitInt8 = Bt;
yt.prototype.visitInt16 = Bt;
yt.prototype.visitInt32 = Bt;
yt.prototype.visitInt64 = Bt;
yt.prototype.visitUint8 = Bt;
yt.prototype.visitUint16 = Bt;
yt.prototype.visitUint32 = Bt;
yt.prototype.visitUint64 = Bt;
yt.prototype.visitFloat = Bt;
yt.prototype.visitFloat16 = Bt;
yt.prototype.visitFloat32 = Bt;
yt.prototype.visitFloat64 = Bt;
yt.prototype.visitUtf8 = Bt;
yt.prototype.visitBinary = Bt;
yt.prototype.visitFixedSizeBinary = Bt;
yt.prototype.visitDate = Bt;
yt.prototype.visitDateDay = Bt;
yt.prototype.visitDateMillisecond = Bt;
yt.prototype.visitTimestamp = Bt;
yt.prototype.visitTimestampSecond = Bt;
yt.prototype.visitTimestampMillisecond = Bt;
yt.prototype.visitTimestampMicrosecond = Bt;
yt.prototype.visitTimestampNanosecond = Bt;
yt.prototype.visitTime = Bt;
yt.prototype.visitTimeSecond = Bt;
yt.prototype.visitTimeMillisecond = Bt;
yt.prototype.visitTimeMicrosecond = Bt;
yt.prototype.visitTimeNanosecond = Bt;
yt.prototype.visitDecimal = Bt;
yt.prototype.visitList = Bt;
yt.prototype.visitStruct = Bt;
yt.prototype.visitUnion = Bt;
yt.prototype.visitDenseUnion = UN;
yt.prototype.visitSparseUnion = UN;
yt.prototype.visitDictionary = Bt;
yt.prototype.visitInterval = Bt;
yt.prototype.visitIntervalDayTime = Bt;
yt.prototype.visitIntervalYearMonth = Bt;
yt.prototype.visitFixedSizeList = Bt;
yt.prototype.visitMap = Bt;
const Pp = new yt();
class mt extends Ut {
}
function St(e) {
  const { type: t } = e;
  if (e.nullCount === 0 && e.stride === 1 && (t.typeId === C.Timestamp || t instanceof Xs && t.bitWidth !== 64 || t instanceof Uu && t.bitWidth !== 64 || t instanceof ku && t.precision !== mn.HALF))
    return new fS(e.data.length, (i) => {
      const r = e.data[i];
      return r.values.subarray(0, r.length)[Symbol.iterator]();
    });
  let n = 0;
  return new fS(e.data.length, (i) => {
    const s = e.data[i].length, o = e.slice(n, n + s);
    return n += s, new trt(o);
  });
}
class trt {
  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;
  }
}
mt.prototype.visitNull = St;
mt.prototype.visitBool = St;
mt.prototype.visitInt = St;
mt.prototype.visitInt8 = St;
mt.prototype.visitInt16 = St;
mt.prototype.visitInt32 = St;
mt.prototype.visitInt64 = St;
mt.prototype.visitUint8 = St;
mt.prototype.visitUint16 = St;
mt.prototype.visitUint32 = St;
mt.prototype.visitUint64 = St;
mt.prototype.visitFloat = St;
mt.prototype.visitFloat16 = St;
mt.prototype.visitFloat32 = St;
mt.prototype.visitFloat64 = St;
mt.prototype.visitUtf8 = St;
mt.prototype.visitBinary = St;
mt.prototype.visitFixedSizeBinary = St;
mt.prototype.visitDate = St;
mt.prototype.visitDateDay = St;
mt.prototype.visitDateMillisecond = St;
mt.prototype.visitTimestamp = St;
mt.prototype.visitTimestampSecond = St;
mt.prototype.visitTimestampMillisecond = St;
mt.prototype.visitTimestampMicrosecond = St;
mt.prototype.visitTimestampNanosecond = St;
mt.prototype.visitTime = St;
mt.prototype.visitTimeSecond = St;
mt.prototype.visitTimeMillisecond = St;
mt.prototype.visitTimeMicrosecond = St;
mt.prototype.visitTimeNanosecond = St;
mt.prototype.visitDecimal = St;
mt.prototype.visitList = St;
mt.prototype.visitStruct = St;
mt.prototype.visitUnion = St;
mt.prototype.visitDenseUnion = St;
mt.prototype.visitSparseUnion = St;
mt.prototype.visitDictionary = St;
mt.prototype.visitInterval = St;
mt.prototype.visitIntervalDayTime = St;
mt.prototype.visitIntervalYearMonth = St;
mt.prototype.visitFixedSizeList = St;
mt.prototype.visitMap = St;
const vw = new mt(), ert = (e, t) => e + t;
class co extends Ut {
  visitNull(t, n) {
    return 0;
  }
  visitInt(t, n) {
    return t.type.bitWidth / 8;
  }
  visitFloat(t, n) {
    return t.type.ArrayType.BYTES_PER_ELEMENT;
  }
  visitBool(t, n) {
    return 1 / 8;
  }
  visitDecimal(t, n) {
    return t.type.bitWidth / 8;
  }
  visitDate(t, n) {
    return (t.type.unit + 1) * 4;
  }
  visitTime(t, n) {
    return t.type.bitWidth / 8;
  }
  visitTimestamp(t, n) {
    return t.type.unit === Yt.SECOND ? 4 : 8;
  }
  visitInterval(t, n) {
    return (t.type.unit + 1) * 4;
  }
  visitStruct(t, n) {
    return t.children.reduce((i, r) => i + lr.visit(r, n), 0);
  }
  visitFixedSizeBinary(t, n) {
    return t.type.byteWidth;
  }
  visitMap(t, n) {
    return 8 + t.children.reduce((i, r) => i + lr.visit(r, n), 0);
  }
  visitDictionary(t, n) {
    var i;
    return t.type.indices.bitWidth / 8 + (((i = t.dictionary) === null || i === void 0 ? void 0 : i.getByteLength(t.values[n])) || 0);
  }
}
const nrt = ({ valueOffsets: e }, t) => 8 + (e[t + 1] - e[t]), irt = ({ valueOffsets: e }, t) => 8 + (e[t + 1] - e[t]), rrt = ({ valueOffsets: e, stride: t, children: n }, i) => {
  const r = n[0], { [i * t]: s } = e, { [i * t + 1]: o } = e, a = lr.getVisitFn(r.type), c = r.slice(s, o - s);
  let l = 8;
  for (let u = -1, f = o - s; ++u < f; )
    l += a(c, u);
  return l;
}, srt = ({ stride: e, children: t }, n) => {
  const i = t[0], r = i.slice(n * e, e), s = lr.getVisitFn(i.type);
  let o = 0;
  for (let a = -1, c = r.length; ++a < c; )
    o += s(r, a);
  return o;
}, ort = (e, t) => e.type.mode === Ai.Dense ? zN(e, t) : PN(e, t), zN = ({ type: e, children: t, typeIds: n, valueOffsets: i }, r) => {
  const s = e.typeIdToChildIndex[n[r]];
  return 8 + lr.visit(t[s], i[r]);
}, PN = ({ children: e }, t) => 4 + lr.visitMany(e, e.map(() => t)).reduce(ert, 0);
co.prototype.visitUtf8 = nrt;
co.prototype.visitBinary = irt;
co.prototype.visitList = rrt;
co.prototype.visitFixedSizeList = srt;
co.prototype.visitUnion = ort;
co.prototype.visitDenseUnion = zN;
co.prototype.visitSparseUnion = PN;
const lr = new co();
var VN;
const jN = {}, YN = {};
class te {
  constructor(t) {
    var n, i, r;
    const s = t[0] instanceof te ? t.flatMap((a) => a.data) : t;
    if (s.length === 0 || s.some((a) => !(a instanceof ue)))
      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, byteLength: u } = jN[o.typeId], f = s[0];
        this.isValid = (h) => ww(f, h), this.get = (h) => a(f, h), this.set = (h, d) => c(f, h, d), this.indexOf = (h) => l(f, h), this.getByteLength = (h) => u(f, h), this._offsets = [0, f.length];
        break;
      }
      default:
        Object.setPrototypeOf(this, YN[o.typeId]), this._offsets = LN(s);
        break;
    }
    this.data = s, this.type = o, this.stride = Dr(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[this._offsets.length - 1];
  }
  /**
   * The aggregate size (in bytes) of this Vector's buffers and/or child Vectors.
   */
  get byteLength() {
    return this._byteLength === -1 && (this._byteLength = this.data.reduce((t, n) => t + n.byteLength, 0)), this._byteLength;
  }
  /**
   * The number of null elements in this Vector.
   */
  get nullCount() {
    return this._nullCount === -1 && (this._nullCount = ON(this.data)), this._nullCount;
  }
  /**
   * The Array or TypedAray 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 `${C[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) > 0;
  }
  /**
   * Get the size in bytes of an element by index.
   * @param index The index at which to get the byteLength.
   */
  // @ts-ignore
  getByteLength(t) {
    return 0;
  }
  /**
   * Iterator for the Vector's elements.
   */
  [Symbol.iterator]() {
    return vw.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 te(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 te(DN(this, t, n, ({ data: i, _offsets: r }, s, o) => RN(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 C.Int:
      case C.Float:
      case C.Decimal:
      case C.Time:
      case C.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 te(this.data.map(({ children: n }) => n[t])) : null;
  }
  get isMemoized() {
    return It.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
   * Uft8. The memoization creates a cache of the size of the Vector and
   * therfore increases memory usage.
   *
   * @returns A new vector that memoizes calls to {@link get}.
   */
  memoize() {
    if (It.isDictionary(this.type)) {
      const t = new Vp(this.data[0].dictionary), n = this.data.map((i) => {
        const r = i.clone();
        return r.dictionary = t, r;
      });
      return new te(n);
    }
    return new Vp(this);
  }
  /**
   * Returns a vector without memoization of the {@link get} method. If this
   * vector is not memoized, this method returns this vector.
   *
   * @returns A a vector without memoization.
   */
  unmemoize() {
    if (It.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 te(n);
    }
    return this;
  }
}
VN = Symbol.toStringTag;
te[VN] = ((e) => {
  e.type = It.prototype, e.data = [], e.length = 0, e.stride = 1, e.numChildren = 0, e._nullCount = -1, e._byteLength = -1, e._offsets = new Uint32Array([0]), e[Symbol.isConcatSpreadable] = !0;
  const t = Object.keys(C).map((n) => C[n]).filter((n) => typeof n == "number" && n !== C.NONE);
  for (const n of t) {
    const i = xn.getVisitFnByTypeId(n), r = si.getVisitFnByTypeId(n), s = Pp.getVisitFnByTypeId(n), o = lr.getVisitFnByTypeId(n);
    jN[n] = { get: i, set: r, indexOf: s, byteLength: o }, YN[n] = Object.create(e, {
      isValid: { value: lc(ww) },
      get: { value: lc(xn.getVisitFnByTypeId(n)) },
      set: { value: CN(si.getVisitFnByTypeId(n)) },
      indexOf: { value: kN(Pp.getVisitFnByTypeId(n)) },
      getByteLength: { value: lc(lr.getVisitFnByTypeId(n)) }
    });
  }
  return "Vector";
})(te.prototype);
class Vp extends te {
  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 Vp(r.call(this, o, a))
    }), Object.defineProperty(this, "isMemoized", { value: !0 }), Object.defineProperty(this, "unmemoize", {
      value: () => new te(this.data)
    }), Object.defineProperty(this, "memoize", {
      value: () => this
    });
  }
}
class b1 {
  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();
  }
}
const Fm = 2, Gi = 4, Rr = 4, le = 4, _s = new Int32Array(2), hS = new Float32Array(_s.buffer), dS = new Float64Array(_s.buffer), hh = new Uint16Array(new Uint8Array([1, 0]).buffer)[0] === 1;
var _1;
(function(e) {
  e[e.UTF8_BYTES = 1] = "UTF8_BYTES", e[e.UTF16_STRING = 2] = "UTF16_STRING";
})(_1 || (_1 = {}));
let kc = class qN {
  /**
   * 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 qN(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 _s[0] = this.readInt32(t), hS[0];
  }
  readFloat64(t) {
    return _s[hh ? 0 : 1] = this.readInt32(t), _s[hh ? 1 : 0] = this.readInt32(t + 4), dS[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) {
    hS[0] = n, this.writeInt32(t, _s[0]);
  }
  writeFloat64(t, n) {
    dS[0] = n, this.writeInt32(t, _s[hh ? 0 : 1]), this.writeInt32(t + 4, _s[hh ? 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_ + Gi + Rr)
      throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");
    let t = "";
    for (let n = 0; n < Rr; n++)
      t += String.fromCharCode(this.readInt8(this.position_ + Gi + 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 += Gi;
    const r = this.bytes_.subarray(t, t + i);
    return n === _1.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) + Gi;
  }
  /**
   * 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 != Rr)
      throw new Error("FlatBuffers: file identifier must be length " + Rr);
    for (let n = 0; n < Rr; n++)
      if (t.charCodeAt(n) != this.readInt8(this.position() + Gi + 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;
  }
}, WN = class GN {
  /**
   * 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 = kc.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 = GN.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 Error("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 Error("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 = kc.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(Gi, 0), this.writeInt32(this.offset() - t + Gi);
  }
  /**
   * 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) * Fm;
    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 = Fm; l < s; l += Fm)
            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 ? le : 0;
    if (n) {
      const s = n;
      if (this.prep(this.minalign, Gi + Rr + r), s.length != Rr)
        throw new Error("FlatBuffers: file identifier must be length " + Rr);
      for (let o = Rr - 1; o >= 0; o--)
        this.writeInt8(s.charCodeAt(o));
    }
    this.prep(this.minalign, Gi + 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 Error("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(Gi, 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 Error("FlatBuffers: Argument for createObjectOffsetList cannot contain null.");
    }
    return n;
  }
  createStructOffsetList(t, n) {
    return n(this, t.length), this.createObjectOffsetList(t.slice().reverse()), this.endVector();
  }
};
class De {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(t, n) {
    return this.bb_pos = t, this.bb = n, this;
  }
  static getRootAsKeyValue(t, n) {
    return (n || new De()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsKeyValue(t, n) {
    return t.setPosition(t.position() + le), (n || new De()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  key(t) {
    const n = this.bb.__offset(this.bb_pos, 4);
    return n ? this.bb.__string(this.bb_pos + n, t) : null;
  }
  value(t) {
    const n = this.bb.__offset(this.bb_pos, 6);
    return n ? this.bb.__string(this.bb_pos + n, t) : null;
  }
  static startKeyValue(t) {
    t.startObject(2);
  }
  static addKey(t, n) {
    t.addFieldOffset(0, n, 0);
  }
  static addValue(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static endKeyValue(t) {
    return t.endObject();
  }
  static createKeyValue(t, n, i) {
    return De.startKeyValue(t), De.addKey(t, n), De.addValue(t, i), De.endKeyValue(t);
  }
}
var Uc;
(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";
})(Uc || (Uc = {}));
var zc;
(function(e) {
  e[e.Little = 0] = "Little", e[e.Big = 1] = "Big";
})(zc || (zc = {}));
var jp;
(function(e) {
  e[e.DenseArray = 0] = "DenseArray";
})(jp || (jp = {}));
class Tn {
  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 Tn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsInt(t, n) {
    return t.setPosition(t.position() + le), (n || new Tn()).__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 Tn.startInt(t), Tn.addBitWidth(t, n), Tn.addIsSigned(t, i), Tn.endInt(t);
  }
}
class Cr {
  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 Cr()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDictionaryEncoding(t, n) {
    return t.setPosition(t.position() + le), (n || new Cr()).__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 Tn()).__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) : jp.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, jp.DenseArray);
  }
  static endDictionaryEncoding(t) {
    return t.endObject();
  }
}
class Eo {
  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 Eo()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsBinary(t, n) {
    return t.setPosition(t.position() + le), (n || new Eo()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startBinary(t) {
    t.startObject(0);
  }
  static endBinary(t) {
    return t.endObject();
  }
  static createBinary(t) {
    return Eo.startBinary(t), Eo.endBinary(t);
  }
}
class Oo {
  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 Oo()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsBool(t, n) {
    return t.setPosition(t.position() + le), (n || new Oo()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startBool(t) {
    t.startObject(0);
  }
  static endBool(t) {
    return t.endObject();
  }
  static createBool(t) {
    return Oo.startBool(t), Oo.endBool(t);
  }
}
var Yp;
(function(e) {
  e[e.DAY = 0] = "DAY", e[e.MILLISECOND = 1] = "MILLISECOND";
})(Yp || (Yp = {}));
let Lh = class Oa {
  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 Oa()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDate(t, n) {
    return t.setPosition(t.position() + le), (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) : Yp.MILLISECOND;
  }
  static startDate(t) {
    t.startObject(1);
  }
  static addUnit(t, n) {
    t.addFieldInt16(0, n, Yp.MILLISECOND);
  }
  static endDate(t) {
    return t.endObject();
  }
  static createDate(t, n) {
    return Oa.startDate(t), Oa.addUnit(t, n), Oa.endDate(t);
  }
};
class hn {
  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 hn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDecimal(t, n) {
    return t.setPosition(t.position() + le), (n || new hn()).__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 hn.startDecimal(t), hn.addPrecision(t, n), hn.addScale(t, i), hn.addBitWidth(t, r), hn.endDecimal(t);
  }
}
var Pc;
(function(e) {
  e[e.SECOND = 0] = "SECOND", e[e.MILLISECOND = 1] = "MILLISECOND", e[e.MICROSECOND = 2] = "MICROSECOND", e[e.NANOSECOND = 3] = "NANOSECOND";
})(Pc || (Pc = {}));
class Xi {
  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 Xi()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFixedSizeBinary(t, n) {
    return t.setPosition(t.position() + le), (n || new Xi()).__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 Xi.startFixedSizeBinary(t), Xi.addByteWidth(t, n), Xi.endFixedSizeBinary(t);
  }
}
class Hi {
  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 Hi()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFixedSizeList(t, n) {
    return t.setPosition(t.position() + le), (n || new Hi()).__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 Hi.startFixedSizeList(t), Hi.addListSize(t, n), Hi.endFixedSizeList(t);
  }
}
var qp;
(function(e) {
  e[e.HALF = 0] = "HALF", e[e.SINGLE = 1] = "SINGLE", e[e.DOUBLE = 2] = "DOUBLE";
})(qp || (qp = {}));
class Ki {
  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 Ki()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFloatingPoint(t, n) {
    return t.setPosition(t.position() + le), (n || new Ki()).__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) : qp.HALF;
  }
  static startFloatingPoint(t) {
    t.startObject(1);
  }
  static addPrecision(t, n) {
    t.addFieldInt16(0, n, qp.HALF);
  }
  static endFloatingPoint(t) {
    return t.endObject();
  }
  static createFloatingPoint(t, n) {
    return Ki.startFloatingPoint(t), Ki.addPrecision(t, n), Ki.endFloatingPoint(t);
  }
}
var Wp;
(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";
})(Wp || (Wp = {}));
class Zi {
  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 Zi()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsInterval(t, n) {
    return t.setPosition(t.position() + le), (n || new Zi()).__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) : Wp.YEAR_MONTH;
  }
  static startInterval(t) {
    t.startObject(1);
  }
  static addUnit(t, n) {
    t.addFieldInt16(0, n, Wp.YEAR_MONTH);
  }
  static endInterval(t) {
    return t.endObject();
  }
  static createInterval(t, n) {
    return Zi.startInterval(t), Zi.addUnit(t, n), Zi.endInterval(t);
  }
}
class Lo {
  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 Lo()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsList(t, n) {
    return t.setPosition(t.position() + le), (n || new Lo()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startList(t) {
    t.startObject(0);
  }
  static endList(t) {
    return t.endObject();
  }
  static createList(t) {
    return Lo.startList(t), Lo.endList(t);
  }
}
let Rh = class La {
  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 La()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsMap(t, n) {
    return t.setPosition(t.position() + le), (n || new La()).__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 La.startMap(t), La.addKeysSorted(t, n), La.endMap(t);
  }
};
class Ro {
  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 Ro()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsNull(t, n) {
    return t.setPosition(t.position() + le), (n || new Ro()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startNull(t) {
    t.startObject(0);
  }
  static endNull(t) {
    return t.endObject();
  }
  static createNull(t) {
    return Ro.startNull(t), Ro.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() + le), (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 Pn {
  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 Pn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsTime(t, n) {
    return t.setPosition(t.position() + le), (n || new Pn()).__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) : Pc.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, Pc.MILLISECOND);
  }
  static addBitWidth(t, n) {
    t.addFieldInt32(1, n, 32);
  }
  static endTime(t) {
    return t.endObject();
  }
  static createTime(t, n, i) {
    return Pn.startTime(t), Pn.addUnit(t, n), Pn.addBitWidth(t, i), Pn.endTime(t);
  }
}
class Vn {
  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 Vn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsTimestamp(t, n) {
    return t.setPosition(t.position() + le), (n || new Vn()).__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) : Pc.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, Pc.SECOND);
  }
  static addTimezone(t, n) {
    t.addFieldOffset(1, n, 0);
  }
  static endTimestamp(t) {
    return t.endObject();
  }
  static createTimestamp(t, n, i) {
    return Vn.startTimestamp(t), Vn.addUnit(t, n), Vn.addTimezone(t, i), Vn.endTimestamp(t);
  }
}
var Gp;
(function(e) {
  e[e.Sparse = 0] = "Sparse", e[e.Dense = 1] = "Dense";
})(Gp || (Gp = {}));
class dn {
  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 dn()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsUnion(t, n) {
    return t.setPosition(t.position() + le), (n || new dn()).__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) : Gp.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, Gp.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 dn.startUnion(t), dn.addMode(t, n), dn.addTypeIds(t, i), dn.endUnion(t);
  }
}
class ko {
  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 ko()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsUtf8(t, n) {
    return t.setPosition(t.position() + le), (n || new ko()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static startUtf8(t) {
    t.startObject(0);
  }
  static endUtf8(t) {
    return t.endObject();
  }
  static createUtf8(t) {
    return ko.startUtf8(t), ko.endUtf8(t);
  }
}
var be;
(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";
})(be || (be = {}));
let kn = class Ch {
  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 Ch()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsField(t, n) {
    return t.setPosition(t.position() + le), (n || new Ch()).__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) : be.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 Cr()).__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 Ch()).__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 De()).__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, be.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();
  }
}, Ui = class $r {
  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 $r()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsSchema(t, n) {
    return t.setPosition(t.position() + le), (n || new $r()).__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) : zc.Little;
  }
  fields(t, n) {
    const i = this.bb.__offset(this.bb_pos, 6);
    return i ? (n || new kn()).__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 De()).__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, zc.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 $r.startSchema(t), $r.addEndianness(t, n), $r.addFields(t, i), $r.addCustomMetadata(t, r), $r.addFeatures(t, s), $r.endSchema(t);
  }
};
class $n {
  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 $n()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsFooter(t, n) {
    return t.setPosition(t.position() + le), (n || new $n()).__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) : Uc.V1;
  }
  schema(t) {
    const n = this.bb.__offset(this.bb_pos, 6);
    return n ? (t || new Ui()).__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 b1()).__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 b1()).__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 De()).__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, Uc.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 Kt {
  constructor(t = [], n, i) {
    this.fields = t || [], this.metadata = n || /* @__PURE__ */ new Map(), i || (i = w1(t)), this.dictionaries = i;
  }
  get [Symbol.toStringTag]() {
    return "Schema";
  }
  get names() {
    return this.fields.map((t) => t.name);
  }
  toString() {
    return `Schema<{ ${this.fields.map((t, n) => `${n}: ${t}`).join(", ")} }>`;
  }
  /**
   * Construct a new Schema containing only specified fields.
   *
   * @param fieldNames Names of fields to keep.
   * @returns A new Schema of fields matching the specified names.
   */
  select(t) {
    const n = new Set(t), i = this.fields.filter((r) => n.has(r.name));
    return new Kt(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 Kt(n, this.metadata);
  }
  assign(...t) {
    const n = t[0] instanceof Kt ? t[0] : Array.isArray(t[0]) ? new Kt(t[0]) : new Kt(t), i = [...this.fields], r = dh(dh(/* @__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: dh(dh(/* @__PURE__ */ new Map(), i[c].metadata), a.metadata)
      })) && !1 : !0;
    }), o = w1(s, /* @__PURE__ */ new Map());
    return new Kt([...i, ...s], r, new Map([...this.dictionaries, ...o]));
  }
}
Kt.prototype.fields = null;
Kt.prototype.metadata = null;
Kt.prototype.dictionaries = null;
class de {
  /** @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 de(`${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], de.new(n, i, r, s);
  }
}
de.prototype.type = null;
de.prototype.name = null;
de.prototype.nullable = null;
de.prototype.metadata = null;
function dh(e, t) {
  return new Map([...e || /* @__PURE__ */ new Map(), ...t || /* @__PURE__ */ new Map()]);
}
function w1(e, t = /* @__PURE__ */ new Map()) {
  for (let n = -1, i = e.length; ++n < i; ) {
    const s = e[n].type;
    if (It.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 && w1(s.children, t);
  }
  return t;
}
var art = WN, crt = kc;
class xw {
  /** @nocollapse */
  static decode(t) {
    t = new crt(Ht(t));
    const n = $n.getRootAsFooter(t), i = Kt.decode(n.schema());
    return new lrt(i, n);
  }
  /** @nocollapse */
  static encode(t) {
    const n = new art(), i = Kt.encode(n, t.schema);
    $n.startRecordBatchesVector(n, t.numRecordBatches);
    for (const o of [...t.recordBatches()].slice().reverse())
      Vc.encode(n, o);
    const r = n.endVector();
    $n.startDictionariesVector(n, t.numDictionaries);
    for (const o of [...t.dictionaryBatches()].slice().reverse())
      Vc.encode(n, o);
    const s = n.endVector();
    return $n.startFooter(n), $n.addSchema(n, i), $n.addVersion(n, Wn.V4), $n.addRecordBatches(n, r), $n.addDictionaries(n, s), $n.finishFooterBuffer(n, $n.endFooter(n)), n.asUint8Array();
  }
  get numRecordBatches() {
    return this._recordBatches.length;
  }
  get numDictionaries() {
    return this._dictionaryBatches.length;
  }
  constructor(t, n = Wn.V4, 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 lrt extends xw {
  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 Vc.decode(n);
    }
    return null;
  }
  getDictionaryBatch(t) {
    if (t >= 0 && t < this.numDictionaries) {
      const n = this._footer.dictionaries(t);
      if (n)
        return Vc.decode(n);
    }
    return null;
  }
}
class Vc {
  /** @nocollapse */
  static decode(t) {
    return new Vc(t.metaDataLength(), t.bodyLength(), t.offset());
  }
  /** @nocollapse */
  static encode(t, n) {
    const { metaDataLength: i } = n, r = BigInt(n.offset), s = BigInt(n.bodyLength);
    return b1.createBlock(t, r, i, s);
  }
  constructor(t, n, i) {
    this.metaDataLength = t, this.offset = Mi(i), this.bodyLength = Mi(n);
  }
}
const xe = Object.freeze({ done: !0, value: void 0 });
class pS {
  constructor(t) {
    this._json = t;
  }
  get schema() {
    return this._json.schema;
  }
  get batches() {
    return this._json.batches || [];
  }
  get dictionaries() {
    return this._json.dictionaries || [];
  }
}
class XN {
  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 urt extends XN {
  constructor() {
    super(), this._values = [], this.resolvers = [], this._closedPromise = new Promise((t) => this._closedPromiseResolve = t);
  }
  get closed() {
    return this._closedPromise;
  }
  cancel(t) {
    return Y(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 zn.toDOMStream(this._closedPromiseResolve || this._error ? this : this._values, t);
  }
  toNodeStream(t) {
    return zn.toNodeStream(this._closedPromiseResolve || this._error ? this : this._values, t);
  }
  throw(t) {
    return Y(this, void 0, void 0, function* () {
      return yield this.abort(t), xe;
    });
  }
  return(t) {
    return Y(this, void 0, void 0, function* () {
      return yield this.close(), xe;
    });
  }
  read(t) {
    return Y(this, void 0, void 0, function* () {
      return (yield this.next(t, "read")).value;
    });
  }
  peek(t) {
    return Y(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");
  }
}
class frt extends urt {
  write(t) {
    if ((t = Ht(t)).byteLength > 0)
      return super.write(t);
  }
  toString(t = !1) {
    return t ? d1(this.toUint8Array(!0)) : this.toUint8Array(!1).then(d1);
  }
  toUint8Array(t = !1) {
    return t ? cr(this._values)[0] : (() => Y(this, void 0, void 0, function* () {
      var n, i, r, s;
      const o = [];
      let a = 0;
      try {
        for (var c = !0, l = Qn(this), u; u = yield l.next(), n = u.done, !n; ) {
          s = u.value, c = !1;
          try {
            const f = s;
            o.push(f), a += f.byteLength;
          } finally {
            c = !0;
          }
        }
      } 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];
    }))();
  }
}
class Xp {
  constructor(t) {
    t && (this.source = new hrt(zn.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 jc {
  constructor(t) {
    t instanceof jc ? this.source = t.source : t instanceof frt ? this.source = new yo(zn.fromAsyncIterable(t)) : TB(t) ? this.source = new yo(zn.fromNodeStream(t)) : uw(t) ? this.source = new yo(zn.fromDOMStream(t)) : MB(t) ? this.source = new yo(zn.fromDOMStream(t.body)) : _0(t) ? this.source = new yo(zn.fromIterable(t)) : Ou(t) ? this.source = new yo(zn.fromAsyncIterable(t)) : lw(t) && (this.source = new yo(zn.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 hrt {
  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);
  }
}
class yo {
  constructor(t) {
    this.source = t, this._closedPromise = new Promise((n) => this._closedPromiseResolve = n);
  }
  cancel(t) {
    return Y(this, void 0, void 0, function* () {
      yield this.return(t);
    });
  }
  get closed() {
    return this._closedPromise;
  }
  read(t) {
    return Y(this, void 0, void 0, function* () {
      return (yield this.next(t, "read")).value;
    });
  }
  peek(t) {
    return Y(this, void 0, void 0, function* () {
      return (yield this.next(t, "peek")).value;
    });
  }
  next(t, n = "read") {
    return Y(this, void 0, void 0, function* () {
      return yield this.source.next({ cmd: n, size: t });
    });
  }
  throw(t) {
    return Y(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 Y(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);
    });
  }
}
class yS extends Xp {
  constructor(t, n) {
    super(), this.position = 0, this.buffer = Ht(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 Hp extends jc {
  constructor(t, n) {
    super(), this.position = 0, this._handle = t, typeof n == "number" ? this.size = n : this._pending = (() => Y(this, void 0, void 0, function* () {
      this.size = (yield t.stat()).size, delete this._pending;
    }))();
  }
  readInt32(t) {
    return Y(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 Y(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 Y(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 Y(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 Y(this, void 0, void 0, function* () {
      const t = this._handle;
      this._handle = null, t && (yield t.close());
    });
  }
  throw(t) {
    return Y(this, void 0, void 0, function* () {
      return yield this.close(), { done: !0, value: t };
    });
  }
  return(t) {
    return Y(this, void 0, void 0, function* () {
      return yield this.close(), { done: !0, value: t };
    });
  }
}
const drt = 65536;
function Va(e) {
  return e < 0 && (e = 4294967295 + e + 1), `0x${e.toString(16)}`;
}
const Yc = 8, Sw = [
  1,
  10,
  100,
  1e3,
  1e4,
  1e5,
  1e6,
  1e7,
  1e8
];
class HN {
  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 ? drt : 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 `${Va(this.buffer[1])} ${Va(this.buffer[0])}`;
  }
}
class Zt extends HN {
  times(t) {
    return this._times(t), this;
  }
  plus(t) {
    return this._plus(t), this;
  }
  /** @nocollapse */
  static from(t, n = new Uint32Array(2)) {
    return Zt.fromString(typeof t == "string" ? t : t.toString(), n);
  }
  /** @nocollapse */
  static fromNumber(t, n = new Uint32Array(2)) {
    return Zt.fromString(t.toString(), n);
  }
  /** @nocollapse */
  static fromString(t, n = new Uint32Array(2)) {
    const i = t.length, r = new Zt(n);
    for (let s = 0; s < i; ) {
      const o = Yc < i - s ? Yc : i - s, a = new Zt(new Uint32Array([Number.parseInt(t.slice(s, s + o), 10), 0])), c = new Zt(new Uint32Array([Sw[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; )
      Zt.from(t[i], new Uint32Array(n.buffer, n.byteOffset + 2 * i * 4, 2));
    return n;
  }
  /** @nocollapse */
  static multiply(t, n) {
    return new Zt(new Uint32Array(t.buffer)).times(n);
  }
  /** @nocollapse */
  static add(t, n) {
    return new Zt(new Uint32Array(t.buffer)).plus(n);
  }
}
class fn extends HN {
  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 fn.fromString(typeof t == "string" ? t : t.toString(), n);
  }
  /** @nocollapse */
  static fromNumber(t, n = new Uint32Array(2)) {
    return fn.fromString(t.toString(), n);
  }
  /** @nocollapse */
  static fromString(t, n = new Uint32Array(2)) {
    const i = t.startsWith("-"), r = t.length, s = new fn(n);
    for (let o = i ? 1 : 0; o < r; ) {
      const a = Yc < r - o ? Yc : r - o, c = new fn(new Uint32Array([Number.parseInt(t.slice(o, o + a), 10), 0])), l = new fn(new Uint32Array([Sw[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; )
      fn.from(t[i], new Uint32Array(n.buffer, n.byteOffset + 2 * i * 4, 2));
    return n;
  }
  /** @nocollapse */
  static multiply(t, n) {
    return new fn(new Uint32Array(t.buffer)).times(n);
  }
  /** @nocollapse */
  static add(t, n) {
    return new fn(new Uint32Array(t.buffer)).plus(n);
  }
}
class zi {
  constructor(t) {
    this.buffer = t;
  }
  high() {
    return new fn(new Uint32Array(this.buffer.buffer, this.buffer.byteOffset + 8, 2));
  }
  low() {
    return new fn(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 Zt(new Uint32Array([this.buffer[3], 0])), i = new Zt(new Uint32Array([this.buffer[2], 0])), r = new Zt(new Uint32Array([this.buffer[1], 0])), s = new Zt(new Uint32Array([this.buffer[0], 0])), o = new Zt(new Uint32Array([t.buffer[3], 0])), a = new Zt(new Uint32Array([t.buffer[2], 0])), c = new Zt(new Uint32Array([t.buffer[1], 0])), l = new Zt(new Uint32Array([t.buffer[0], 0]));
    let u = Zt.multiply(s, l);
    this.buffer[0] = u.low();
    const f = new Zt(new Uint32Array([u.high(), 0]));
    return u = Zt.multiply(r, l), f.plus(u), u = Zt.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 Zt(new Uint32Array(this.buffer.buffer, this.buffer.byteOffset + 8, 2)).plus(Zt.multiply(i, l)).plus(Zt.multiply(r, c)).plus(Zt.multiply(s, a)), this.buffer[3] += Zt.multiply(n, l).plus(Zt.multiply(i, c)).plus(Zt.multiply(r, a)).plus(Zt.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 `${Va(this.buffer[3])} ${Va(this.buffer[2])} ${Va(this.buffer[1])} ${Va(this.buffer[0])}`;
  }
  /** @nocollapse */
  static multiply(t, n) {
    return new zi(new Uint32Array(t.buffer)).times(n);
  }
  /** @nocollapse */
  static add(t, n) {
    return new zi(new Uint32Array(t.buffer)).plus(n);
  }
  /** @nocollapse */
  static from(t, n = new Uint32Array(4)) {
    return zi.fromString(typeof t == "string" ? t : t.toString(), n);
  }
  /** @nocollapse */
  static fromNumber(t, n = new Uint32Array(4)) {
    return zi.fromString(t.toString(), n);
  }
  /** @nocollapse */
  static fromString(t, n = new Uint32Array(4)) {
    const i = t.startsWith("-"), r = t.length, s = new zi(n);
    for (let o = i ? 1 : 0; o < r; ) {
      const a = Yc < r - o ? Yc : r - o, c = new zi(new Uint32Array([Number.parseInt(t.slice(o, o + a), 10), 0, 0, 0])), l = new zi(new Uint32Array([Sw[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; )
      zi.from(t[i], new Uint32Array(n.buffer, n.byteOffset + 4 * 4 * i, 4));
    return n;
  }
}
class KN extends Ut {
  constructor(t, n, i, r) {
    super(), this.nodesIndex = -1, this.buffersIndex = -1, this.bytes = t, this.nodes = n, this.buffers = i, this.dictionaries = r;
  }
  visit(t) {
    return super.visit(t instanceof de ? 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) });
  }
  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) });
  }
  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) {
    return t.mode === Ai.Sparse ? this.visitSparseUnion(t) : this.visitDenseUnion(t);
  }
  visitDenseUnion(t, { length: n, nullCount: i } = this.nextFieldNode()) {
    return Rt({ type: t, length: n, nullCount: i, nullBitmap: this.readNullBitmap(t, 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, nullBitmap: this.readNullBitmap(t, 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) });
  }
  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);
  }
}
class prt extends KN {
  constructor(t, n, i, r) {
    super(new Uint8Array(0), n, i, r), this.sources = t;
  }
  readNullBitmap(t, n, { offset: i } = this.nextBufferRange()) {
    return n <= 0 ? new Uint8Array(0) : m1(this.sources[i]);
  }
  readOffsets(t, { offset: n } = this.nextBufferRange()) {
    return ie(Uint8Array, ie(Int32Array, this.sources[n]));
  }
  readTypeIds(t, { offset: n } = this.nextBufferRange()) {
    return ie(Uint8Array, ie(t.ArrayType, this.sources[n]));
  }
  readData(t, { offset: n } = this.nextBufferRange()) {
    const { sources: i } = this;
    return It.isTimestamp(t) || (It.isInt(t) || It.isTime(t)) && t.bitWidth === 64 || It.isDate(t) && t.unit === ns.MILLISECOND ? ie(Uint8Array, fn.convertArray(i[n])) : It.isDecimal(t) ? ie(Uint8Array, zi.convertArray(i[n])) : It.isBinary(t) || It.isFixedSizeBinary(t) ? yrt(i[n]) : It.isBool(t) ? m1(i[n]) : It.isUtf8(t) ? cw(i[n].join("")) : ie(Uint8Array, ie(t.ArrayType, i[n].map((r) => +r)));
  }
}
function yrt(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 gt 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 An(e, t) {
  return t instanceof e.constructor;
}
function Af(e, t) {
  return e === t || An(e, t);
}
function fs(e, t) {
  return e === t || An(e, t) && e.bitWidth === t.bitWidth && e.isSigned === t.isSigned;
}
function v0(e, t) {
  return e === t || An(e, t) && e.precision === t.precision;
}
function mrt(e, t) {
  return e === t || An(e, t) && e.byteWidth === t.byteWidth;
}
function Iw(e, t) {
  return e === t || An(e, t) && e.unit === t.unit;
}
function Mf(e, t) {
  return e === t || An(e, t) && e.unit === t.unit && e.timezone === t.timezone;
}
function $f(e, t) {
  return e === t || An(e, t) && e.unit === t.unit && e.bitWidth === t.bitWidth;
}
function grt(e, t) {
  return e === t || An(e, t) && e.children.length === t.children.length && Hs.compareManyFields(e.children, t.children);
}
function brt(e, t) {
  return e === t || An(e, t) && e.children.length === t.children.length && Hs.compareManyFields(e.children, t.children);
}
function Aw(e, t) {
  return e === t || An(e, t) && e.mode === t.mode && e.typeIds.every((n, i) => n === t.typeIds[i]) && Hs.compareManyFields(e.children, t.children);
}
function _rt(e, t) {
  return e === t || An(e, t) && e.id === t.id && e.isOrdered === t.isOrdered && Hs.visit(e.indices, t.indices) && Hs.visit(e.dictionary, t.dictionary);
}
function Mw(e, t) {
  return e === t || An(e, t) && e.unit === t.unit;
}
function wrt(e, t) {
  return e === t || An(e, t) && e.listSize === t.listSize && e.children.length === t.children.length && Hs.compareManyFields(e.children, t.children);
}
function vrt(e, t) {
  return e === t || An(e, t) && e.keysSorted === t.keysSorted && e.children.length === t.children.length && Hs.compareManyFields(e.children, t.children);
}
gt.prototype.visitNull = Af;
gt.prototype.visitBool = Af;
gt.prototype.visitInt = fs;
gt.prototype.visitInt8 = fs;
gt.prototype.visitInt16 = fs;
gt.prototype.visitInt32 = fs;
gt.prototype.visitInt64 = fs;
gt.prototype.visitUint8 = fs;
gt.prototype.visitUint16 = fs;
gt.prototype.visitUint32 = fs;
gt.prototype.visitUint64 = fs;
gt.prototype.visitFloat = v0;
gt.prototype.visitFloat16 = v0;
gt.prototype.visitFloat32 = v0;
gt.prototype.visitFloat64 = v0;
gt.prototype.visitUtf8 = Af;
gt.prototype.visitBinary = Af;
gt.prototype.visitFixedSizeBinary = mrt;
gt.prototype.visitDate = Iw;
gt.prototype.visitDateDay = Iw;
gt.prototype.visitDateMillisecond = Iw;
gt.prototype.visitTimestamp = Mf;
gt.prototype.visitTimestampSecond = Mf;
gt.prototype.visitTimestampMillisecond = Mf;
gt.prototype.visitTimestampMicrosecond = Mf;
gt.prototype.visitTimestampNanosecond = Mf;
gt.prototype.visitTime = $f;
gt.prototype.visitTimeSecond = $f;
gt.prototype.visitTimeMillisecond = $f;
gt.prototype.visitTimeMicrosecond = $f;
gt.prototype.visitTimeNanosecond = $f;
gt.prototype.visitDecimal = Af;
gt.prototype.visitList = grt;
gt.prototype.visitStruct = brt;
gt.prototype.visitUnion = Aw;
gt.prototype.visitDenseUnion = Aw;
gt.prototype.visitSparseUnion = Aw;
gt.prototype.visitDictionary = _rt;
gt.prototype.visitInterval = Mw;
gt.prototype.visitIntervalDayTime = Mw;
gt.prototype.visitIntervalYearMonth = Mw;
gt.prototype.visitFixedSizeList = wrt;
gt.prototype.visitMap = vrt;
const Hs = new gt();
function xrt(e, t) {
  return Hs.compareSchemas(e, t);
}
function Dm(e, t) {
  return Srt(e, t.map((n) => n.data.concat()));
}
function Srt(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 = Irt(n, o, u, t, r), o > 0 && (i[s++] = Rt({
      type: new an(n),
      length: o,
      nullCount: 0,
      children: u.slice()
    })));
  }
  return [
    e = e.assign(n),
    i.map((f) => new fi(e, f))
  ];
}
function Irt(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 ZN;
class jn {
  constructor(...t) {
    var n, i;
    if (t.length === 0)
      return this.batches = [], this.schema = new Kt([]), this._offsets = [0], this;
    let r, s;
    t[0] instanceof Kt && (r = t.shift()), t[t.length - 1] instanceof Uint32Array && (s = t.pop());
    const o = (c) => {
      if (c) {
        if (c instanceof fi)
          return [c];
        if (c instanceof jn)
          return c.batches;
        if (c instanceof ue) {
          if (c.type instanceof an)
            return [new fi(new Kt(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 te([c[d]])), f = new Kt(l.map((d, p) => new de(String(d), u[p].type))), [, h] = Dm(f, u);
            return h.length === 0 ? [new fi(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 Kt([]), !(r instanceof Kt))
      throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");
    for (const c of a) {
      if (!(c instanceof fi))
        throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");
      if (!xrt(r, c.schema))
        throw new TypeError("Table and inner RecordBatch schemas must be equivalent.");
    }
    this.schema = r, this.batches = a, this._offsets = s ?? LN(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 = ON(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;
  }
  /**
   * Get the size in bytes of an element by index.
   * @param index The index at which to get the byteLength.
   */
  // @ts-ignore
  getByteLength(t) {
    return 0;
  }
  /**
   * Iterator for rows in this Table.
   */
  [Symbol.iterator]() {
    return this.batches.length > 0 ? vw.visit(new te(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 jn(n, i.map((r) => new fi(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] = DN({ length: this.numRows }, t, n);
    const r = RN(this.data, this._offsets, t, n);
    return new jn(i, r.map((s) => new fi(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 te(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 te([Rt({ type: new Gs(), 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] = Dm(i, a);
    }
    return new jn(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 jn(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 jn(...Dm(s, o));
  }
}
ZN = Symbol.toStringTag;
jn[ZN] = ((e) => (e.schema = null, e.batches = [], e._offsets = new Uint32Array([0]), e._nullCount = -1, e[Symbol.isConcatSpreadable] = !0, e.isValid = lc(ww), e.get = lc(xn.getVisitFn(C.Struct)), e.set = CN(si.getVisitFn(C.Struct)), e.indexOf = kN(Pp.getVisitFn(C.Struct)), e.getByteLength = lc(lr.getVisitFn(C.Struct)), "Table"))(jn.prototype);
var JN;
let fi = class Wl {
  constructor(...t) {
    switch (t.length) {
      case 2: {
        if ([this.schema] = t, !(this.schema instanceof Kt))
          throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");
        if ([
          ,
          this.data = Rt({
            nullCount: 0,
            type: new an(this.schema.fields),
            children: this.schema.fields.map((n) => Rt({ type: n.type, nullCount: 0 }))
          })
        ] = t, !(this.data instanceof ue))
          throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");
        [this.schema, this.data] = mS(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] = de.new({ name: l, type: n[l].type, nullable: !0 }), c), {
          length: 0,
          fields: new Array(),
          children: new Array()
        }), o = new Kt(i), a = Rt({ type: new an(i), length: s, children: r, nullCount: 0 });
        [this.schema, this.data] = mS(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 = QN(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 xn.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 si.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 Pp.visit(this.data, t, n);
  }
  /**
   * Get the size (in bytes) of a row by index.
   * @param index The row index for which to compute the byteLength.
   */
  getByteLength(t) {
    return lr.visit(this.data, t);
  }
  /**
   * Iterator for rows in this RecordBatch.
   */
  [Symbol.iterator]() {
    return vw.visit(new te([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 jn(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 te([this.data]).slice(t, n).data;
    return new Wl(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 te([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 te([Rt({ type: new Gs(), 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 Kt(s, new Map(this.schema.metadata)), r = Rt({ type: new an(s), children: o });
    }
    return new Wl(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 an(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 Wl(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 an(n.fields), length: this.numRows, children: i });
    return new Wl(n, r);
  }
};
JN = Symbol.toStringTag;
fi[JN] = ((e) => (e._nullCount = -1, e[Symbol.isConcatSpreadable] = !0, "RecordBatch"))(fi.prototype);
function mS(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 an(r), length: n, children: s })
  ];
}
function QN(e, t, n = /* @__PURE__ */ new Map()) {
  for (let i = -1, r = e.length; ++i < r; ) {
    const o = e[i].type, a = t[i];
    if (It.isDictionary(o)) {
      if (!n.has(o.id))
        a.dictionary && n.set(o.id, a.dictionary);
      else if (n.get(o.id) !== a.dictionary)
        throw new Error("Cannot create Schema containing two different dictionaries with the same Id");
    }
    o.children && o.children.length > 0 && QN(o.children, a.children, n);
  }
  return n;
}
class tF extends fi {
  constructor(t) {
    const n = t.fields.map((r) => Rt({ type: r.type })), i = Rt({ type: new an(t.fields), nullCount: 0, children: n });
    super(t, i);
  }
}
var Kp;
(function(e) {
  e[e.BUFFER = 0] = "BUFFER";
})(Kp || (Kp = {}));
var Zp;
(function(e) {
  e[e.LZ4_FRAME = 0] = "LZ4_FRAME", e[e.ZSTD = 1] = "ZSTD";
})(Zp || (Zp = {}));
class ws {
  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 ws()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsBodyCompression(t, n) {
    return t.setPosition(t.position() + le), (n || new ws()).__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) : Zp.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) : Kp.BUFFER;
  }
  static startBodyCompression(t) {
    t.startObject(2);
  }
  static addCodec(t, n) {
    t.addFieldInt8(0, n, Zp.LZ4_FRAME);
  }
  static addMethod(t, n) {
    t.addFieldInt8(1, n, Kp.BUFFER);
  }
  static endBodyCompression(t) {
    return t.endObject();
  }
  static createBodyCompression(t, n, i) {
    return ws.startBodyCompression(t), ws.addCodec(t, n), ws.addMethod(t, i), ws.endBodyCompression(t);
  }
}
class eF {
  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 nF = 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 v1 {
  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 v1()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsRecordBatch(t, n) {
    return t.setPosition(t.position() + le), (n || new v1()).__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 nF()).__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 eF()).__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 ws()).__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();
  }
}, Ra = class x1 {
  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 x1()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsDictionaryBatch(t, n) {
    return t.setPosition(t.position() + le), (n || new x1()).__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 Jp;
(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";
})(Jp || (Jp = {}));
let ps = class Ci {
  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 Ci()).__init(t.readInt32(t.position()) + t.position(), t);
  }
  static getSizePrefixedRootAsMessage(t, n) {
    return t.setPosition(t.position() + le), (n || new Ci()).__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) : Uc.V1;
  }
  headerType() {
    const t = this.bb.__offset(this.bb_pos, 6);
    return t ? this.bb.readUint8(this.bb_pos + t) : Jp.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 De()).__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, Uc.V1);
  }
  static addHeaderType(t, n) {
    t.addFieldInt8(1, n, Jp.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 Ci.startMessage(t), Ci.addVersion(t, n), Ci.addHeaderType(t, i), Ci.addHeader(t, r), Ci.addBodyLength(t, s), Ci.addCustomMetadata(t, o), Ci.endMessage(t);
  }
};
class Art extends Ut {
  visit(t, n) {
    return t == null || n == null ? void 0 : super.visit(t, n);
  }
  visitNull(t, n) {
    return Ro.startNull(n), Ro.endNull(n);
  }
  visitInt(t, n) {
    return Tn.startInt(n), Tn.addBitWidth(n, t.bitWidth), Tn.addIsSigned(n, t.isSigned), Tn.endInt(n);
  }
  visitFloat(t, n) {
    return Ki.startFloatingPoint(n), Ki.addPrecision(n, t.precision), Ki.endFloatingPoint(n);
  }
  visitBinary(t, n) {
    return Eo.startBinary(n), Eo.endBinary(n);
  }
  visitBool(t, n) {
    return Oo.startBool(n), Oo.endBool(n);
  }
  visitUtf8(t, n) {
    return ko.startUtf8(n), ko.endUtf8(n);
  }
  visitDecimal(t, n) {
    return hn.startDecimal(n), hn.addScale(n, t.scale), hn.addPrecision(n, t.precision), hn.addBitWidth(n, t.bitWidth), hn.endDecimal(n);
  }
  visitDate(t, n) {
    return Lh.startDate(n), Lh.addUnit(n, t.unit), Lh.endDate(n);
  }
  visitTime(t, n) {
    return Pn.startTime(n), Pn.addUnit(n, t.unit), Pn.addBitWidth(n, t.bitWidth), Pn.endTime(n);
  }
  visitTimestamp(t, n) {
    const i = t.timezone && n.createString(t.timezone) || void 0;
    return Vn.startTimestamp(n), Vn.addUnit(n, t.unit), i !== void 0 && Vn.addTimezone(n, i), Vn.endTimestamp(n);
  }
  visitInterval(t, n) {
    return Zi.startInterval(n), Zi.addUnit(n, t.unit), Zi.endInterval(n);
  }
  visitList(t, n) {
    return Lo.startList(n), Lo.endList(n);
  }
  visitStruct(t, n) {
    return Co.startStruct_(n), Co.endStruct_(n);
  }
  visitUnion(t, n) {
    dn.startTypeIdsVector(n, t.typeIds.length);
    const i = dn.createTypeIdsVector(n, t.typeIds);
    return dn.startUnion(n), dn.addMode(n, t.mode), dn.addTypeIds(n, i), dn.endUnion(n);
  }
  visitDictionary(t, n) {
    const i = this.visit(t.indices, n);
    return Cr.startDictionaryEncoding(n), Cr.addId(n, BigInt(t.id)), Cr.addIsOrdered(n, t.isOrdered), i !== void 0 && Cr.addIndexType(n, i), Cr.endDictionaryEncoding(n);
  }
  visitFixedSizeBinary(t, n) {
    return Xi.startFixedSizeBinary(n), Xi.addByteWidth(n, t.byteWidth), Xi.endFixedSizeBinary(n);
  }
  visitFixedSizeList(t, n) {
    return Hi.startFixedSizeList(n), Hi.addListSize(n, t.listSize), Hi.endFixedSizeList(n);
  }
  visitMap(t, n) {
    return Rh.startMap(n), Rh.addKeysSorted(n, t.keysSorted), Rh.endMap(n);
  }
}
const Em = new Art();
function Mrt(e, t = /* @__PURE__ */ new Map()) {
  return new Kt(Trt(e, t), kh(e.customMetadata), t);
}
function iF(e) {
  return new $i(e.count, rF(e.columns), sF(e.columns));
}
function $rt(e) {
  return new is(iF(e.data), e.id, e.isDelta);
}
function Trt(e, t) {
  return (e.fields || []).filter(Boolean).map((n) => de.fromJSON(n, t));
}
function gS(e, t) {
  return (e.children || []).filter(Boolean).map((n) => de.fromJSON(n, t));
}
function rF(e) {
  return (e || []).reduce((t, n) => [
    ...t,
    new ul(n.count, Brt(n.VALIDITY)),
    ...rF(n.children)
  ], []);
}
function sF(e, t = []) {
  for (let n = -1, i = (e || []).length; ++n < i; ) {
    const r = e[n];
    r.VALIDITY && t.push(new Yr(t.length, r.VALIDITY.length)), r.TYPE && t.push(new Yr(t.length, r.TYPE.length)), r.OFFSET && t.push(new Yr(t.length, r.OFFSET.length)), r.DATA && t.push(new Yr(t.length, r.DATA.length)), t = sF(r.children, t);
  }
  return t;
}
function Brt(e) {
  return (e || []).reduce((t, n) => t + +(n === 0), 0);
}
function Nrt(e, t) {
  let n, i, r, s, o, a;
  return !t || !(s = e.dictionary) ? (o = _S(e, gS(e, t)), r = new de(e.name, o, e.nullable, kh(e.customMetadata))) : t.has(n = s.id) ? (i = (i = s.indexType) ? bS(i) : new Cu(), a = new Cc(t.get(n), i, n, s.isOrdered), r = new de(e.name, a, e.nullable, kh(e.customMetadata))) : (i = (i = s.indexType) ? bS(i) : new Cu(), t.set(n, o = _S(e, gS(e, t))), a = new Cc(o, i, n, s.isOrdered), r = new de(e.name, a, e.nullable, kh(e.customMetadata))), r || null;
}
function kh(e) {
  return new Map(Object.entries(e || {}));
}
function bS(e) {
  return new Xs(e.isSigned, e.bitWidth);
}
function _S(e, t) {
  const n = e.type.name;
  switch (n) {
    case "NONE":
      return new Gs();
    case "null":
      return new Gs();
    case "binary":
      return new Bp();
    case "utf8":
      return new Np();
    case "bool":
      return new Fp();
    case "list":
      return new Rp((t || [])[0]);
    case "struct":
      return new an(t || []);
    case "struct_":
      return new an(t || []);
  }
  switch (n) {
    case "int": {
      const i = e.type;
      return new Xs(i.isSigned, i.bitWidth);
    }
    case "floatingpoint": {
      const i = e.type;
      return new ku(mn[i.precision]);
    }
    case "decimal": {
      const i = e.type;
      return new Dp(i.scale, i.precision, i.bitWidth);
    }
    case "date": {
      const i = e.type;
      return new Ep(ns[i.unit]);
    }
    case "time": {
      const i = e.type;
      return new Uu(Yt[i.unit], i.bitWidth);
    }
    case "timestamp": {
      const i = e.type;
      return new Op(Yt[i.unit], i.timezone);
    }
    case "interval": {
      const i = e.type;
      return new Lp(Ws[i.unit]);
    }
    case "union": {
      const i = e.type;
      return new Cp(Ai[i.mode], i.typeIds || [], t || []);
    }
    case "fixedsizebinary": {
      const i = e.type;
      return new kp(i.byteWidth);
    }
    case "fixedsizelist": {
      const i = e.type;
      return new Up(i.listSize, (t || [])[0]);
    }
    case "map": {
      const i = e.type;
      return new zp((t || [])[0], i.keysSorted);
    }
  }
  throw new Error(`Unrecognized type: "${n}"`);
}
var Frt = WN, Drt = kc;
class pi {
  /** @nocollapse */
  static fromJSON(t, n) {
    const i = new pi(0, Wn.V4, n);
    return i._createHeader = Ert(t, n), i;
  }
  /** @nocollapse */
  static decode(t) {
    t = new Drt(Ht(t));
    const n = ps.getRootAsMessage(t), i = n.bodyLength(), r = n.version(), s = n.headerType(), o = new pi(i, r, s);
    return o._createHeader = Ort(n, s), o;
  }
  /** @nocollapse */
  static encode(t) {
    const n = new Frt();
    let i = -1;
    return t.isSchema() ? i = Kt.encode(n, t.header()) : t.isRecordBatch() ? i = $i.encode(n, t.header()) : t.isDictionaryBatch() && (i = is.encode(n, t.header())), ps.startMessage(n), ps.addVersion(n, Wn.V4), ps.addHeader(n, i), ps.addHeaderType(n, t.headerType), ps.addBodyLength(n, BigInt(t.bodyLength)), ps.finishMessageBuffer(n, ps.endMessage(n)), n.asUint8Array();
  }
  /** @nocollapse */
  static from(t, n = 0) {
    if (t instanceof Kt)
      return new pi(0, Wn.V4, Qt.Schema, t);
    if (t instanceof $i)
      return new pi(n, Wn.V4, Qt.RecordBatch, t);
    if (t instanceof is)
      return new pi(n, Wn.V4, 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 = Mi(t);
  }
}
class $i {
  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 = Mi(t);
  }
}
class is {
  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 = Mi(n);
  }
}
class Yr {
  constructor(t, n) {
    this.offset = Mi(t), this.length = Mi(n);
  }
}
class ul {
  constructor(t, n) {
    this.length = Mi(t), this.nullCount = Mi(n);
  }
}
function Ert(e, t) {
  return () => {
    switch (t) {
      case Qt.Schema:
        return Kt.fromJSON(e);
      case Qt.RecordBatch:
        return $i.fromJSON(e);
      case Qt.DictionaryBatch:
        return is.fromJSON(e);
    }
    throw new Error(`Unrecognized Message type: { name: ${Qt[t]}, type: ${t} }`);
  };
}
function Ort(e, t) {
  return () => {
    switch (t) {
      case Qt.Schema:
        return Kt.decode(e.header(new Ui()));
      case Qt.RecordBatch:
        return $i.decode(e.header(new Er()), e.version());
      case Qt.DictionaryBatch:
        return is.decode(e.header(new Ra()), e.version());
    }
    throw new Error(`Unrecognized Message type: { name: ${Qt[t]}, type: ${t} }`);
  };
}
de.encode = qrt;
de.decode = jrt;
de.fromJSON = Nrt;
Kt.encode = Yrt;
Kt.decode = Lrt;
Kt.fromJSON = Mrt;
$i.encode = Wrt;
$i.decode = Rrt;
$i.fromJSON = iF;
is.encode = Grt;
is.decode = Crt;
is.fromJSON = $rt;
ul.encode = Xrt;
ul.decode = Urt;
Yr.encode = Hrt;
Yr.decode = krt;
function Lrt(e, t = /* @__PURE__ */ new Map()) {
  const n = Vrt(e, t);
  return new Kt(n, Uh(e), t);
}
function Rrt(e, t = Wn.V4) {
  if (e.compression() !== null)
    throw new Error("Record batch compression not implemented");
  return new $i(e.length(), zrt(e), Prt(e, t));
}
function Crt(e, t = Wn.V4) {
  return new is($i.decode(e.data(), t), e.id(), e.isDelta());
}
function krt(e) {
  return new Yr(e.offset(), e.length());
}
function Urt(e) {
  return new ul(e.length(), e.nullCount());
}
function zrt(e) {
  const t = [];
  for (let n, i = -1, r = -1, s = e.nodesLength(); ++i < s; )
    (n = e.nodes(i)) && (t[++r] = ul.decode(n));
  return t;
}
function Prt(e, t) {
  const n = [];
  for (let i, r = -1, s = -1, o = e.buffersLength(); ++r < o; )
    (i = e.buffers(r)) && (t < Wn.V4 && (i.bb_pos += 8 * (r + 1)), n[++s] = Yr.decode(i));
  return n;
}
function Vrt(e, t) {
  const n = [];
  for (let i, r = -1, s = -1, o = e.fieldsLength(); ++r < o; )
    (i = e.fields(r)) && (n[++s] = de.decode(i, t));
  return n;
}
function wS(e, t) {
  const n = [];
  for (let i, r = -1, s = -1, o = e.childrenLength(); ++r < o; )
    (i = e.children(r)) && (n[++s] = de.decode(i, t));
  return n;
}
function jrt(e, t) {
  let n, i, r, s, o, a;
  return !t || !(a = e.dictionary()) ? (r = xS(e, wS(e, t)), i = new de(e.name(), r, e.nullable(), Uh(e))) : t.has(n = Mi(a.id())) ? (s = (s = a.indexType()) ? vS(s) : new Cu(), o = new Cc(t.get(n), s, n, a.isOrdered()), i = new de(e.name(), o, e.nullable(), Uh(e))) : (s = (s = a.indexType()) ? vS(s) : new Cu(), t.set(n, r = xS(e, wS(e, t))), o = new Cc(r, s, n, a.isOrdered()), i = new de(e.name(), o, e.nullable(), Uh(e))), i || null;
}
function Uh(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 vS(e) {
  return new Xs(e.isSigned(), e.bitWidth());
}
function xS(e, t) {
  const n = e.typeType();
  switch (n) {
    case be.NONE:
      return new Gs();
    case be.Null:
      return new Gs();
    case be.Binary:
      return new Bp();
    case be.Utf8:
      return new Np();
    case be.Bool:
      return new Fp();
    case be.List:
      return new Rp((t || [])[0]);
    case be.Struct_:
      return new an(t || []);
  }
  switch (n) {
    case be.Int: {
      const i = e.type(new Tn());
      return new Xs(i.isSigned(), i.bitWidth());
    }
    case be.FloatingPoint: {
      const i = e.type(new Ki());
      return new ku(i.precision());
    }
    case be.Decimal: {
      const i = e.type(new hn());
      return new Dp(i.scale(), i.precision(), i.bitWidth());
    }
    case be.Date: {
      const i = e.type(new Lh());
      return new Ep(i.unit());
    }
    case be.Time: {
      const i = e.type(new Pn());
      return new Uu(i.unit(), i.bitWidth());
    }
    case be.Timestamp: {
      const i = e.type(new Vn());
      return new Op(i.unit(), i.timezone());
    }
    case be.Interval: {
      const i = e.type(new Zi());
      return new Lp(i.unit());
    }
    case be.Union: {
      const i = e.type(new dn());
      return new Cp(i.mode(), i.typeIdsArray() || [], t || []);
    }
    case be.FixedSizeBinary: {
      const i = e.type(new Xi());
      return new kp(i.byteWidth());
    }
    case be.FixedSizeList: {
      const i = e.type(new Hi());
      return new Up(i.listSize(), (t || [])[0]);
    }
    case be.Map: {
      const i = e.type(new Rh());
      return new zp((t || [])[0], i.keysSorted());
    }
  }
  throw new Error(`Unrecognized type: "${be[n]}" (${n})`);
}
function Yrt(e, t) {
  const n = t.fields.map((s) => de.encode(e, s));
  Ui.startFieldsVector(e, n.length);
  const i = Ui.createFieldsVector(e, n), r = t.metadata && t.metadata.size > 0 ? Ui.createCustomMetadataVector(e, [...t.metadata].map(([s, o]) => {
    const a = e.createString(`${s}`), c = e.createString(`${o}`);
    return De.startKeyValue(e), De.addKey(e, a), De.addValue(e, c), De.endKeyValue(e);
  })) : -1;
  return Ui.startSchema(e), Ui.addFields(e, i), Ui.addEndianness(e, Krt ? zc.Little : zc.Big), r !== -1 && Ui.addCustomMetadata(e, r), Ui.endSchema(e);
}
function qrt(e, t) {
  let n = -1, i = -1, r = -1;
  const s = t.type;
  let o = t.typeId;
  It.isDictionary(s) ? (o = s.dictionary.typeId, r = Em.visit(s, e), i = Em.visit(s.dictionary, e)) : i = Em.visit(s, e);
  const a = (s.children || []).map((u) => de.encode(e, u)), c = kn.createChildrenVector(e, a), l = t.metadata && t.metadata.size > 0 ? kn.createCustomMetadataVector(e, [...t.metadata].map(([u, f]) => {
    const h = e.createString(`${u}`), d = e.createString(`${f}`);
    return De.startKeyValue(e), De.addKey(e, h), De.addValue(e, d), De.endKeyValue(e);
  })) : -1;
  return t.name && (n = e.createString(t.name)), kn.startField(e), kn.addType(e, i), kn.addTypeType(e, o), kn.addChildren(e, c), kn.addNullable(e, !!t.nullable), n !== -1 && kn.addName(e, n), r !== -1 && kn.addDictionary(e, r), l !== -1 && kn.addCustomMetadata(e, l), kn.endField(e);
}
function Wrt(e, t) {
  const n = t.nodes || [], i = t.buffers || [];
  Er.startNodesVector(e, n.length);
  for (const o of n.slice().reverse())
    ul.encode(e, o);
  const r = e.endVector();
  Er.startBuffersVector(e, i.length);
  for (const o of i.slice().reverse())
    Yr.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 Grt(e, t) {
  const n = $i.encode(e, t.data);
  return Ra.startDictionaryBatch(e), Ra.addId(e, BigInt(t.id)), Ra.addIsDelta(e, t.isDelta), Ra.addData(e, n), Ra.endDictionaryBatch(e);
}
function Xrt(e, t) {
  return nF.createFieldNode(e, BigInt(t.length), BigInt(t.nullCount));
}
function Hrt(e, t) {
  return eF.createBuffer(e, BigInt(t.offset), BigInt(t.length));
}
const Krt = (() => {
  const e = new ArrayBuffer(2);
  return new DataView(e).setInt16(
    0,
    256,
    !0
    /* littleEndian */
  ), new Int16Array(e)[0] === 256;
})(), $w = (e) => `Expected ${Qt[e]} Message in stream, but was null or length 0.`, Tw = (e) => `Header pointer of flatbuffer-encoded ${Qt[e]} Message is null or length 0.`, oF = (e, t) => `Expected to read ${e} metadata bytes, but only read ${t}.`, aF = (e, t) => `Expected to read ${e} bytes for message body, but only read ${t}.`;
class cF {
  constructor(t) {
    this.source = t instanceof Xp ? t : new Xp(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($w(t));
    return n.value;
  }
  readMessageBody(t) {
    if (t <= 0)
      return new Uint8Array(0);
    const n = Ht(this.source.read(t));
    if (n.byteLength < t)
      throw new Error(aF(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(Tw(n));
    return r;
  }
  readMetadataLength() {
    const t = this.source.read(x0), n = t && new kc(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(oF(t, n.byteLength));
    return { done: !1, value: pi.decode(n) };
  }
}
class Zrt {
  constructor(t, n) {
    this.source = t instanceof jc ? t : AB(t) ? new Hp(t, n) : new jc(t);
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  next() {
    return Y(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 Y(this, void 0, void 0, function* () {
      return yield this.source.throw(t);
    });
  }
  return(t) {
    return Y(this, void 0, void 0, function* () {
      return yield this.source.return(t);
    });
  }
  readMessage(t) {
    return Y(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 Y(this, void 0, void 0, function* () {
      if (t <= 0)
        return new Uint8Array(0);
      const n = Ht(yield this.source.read(t));
      if (n.byteLength < t)
        throw new Error(aF(t, n.byteLength));
      return (
        /* 1. */
        n.byteOffset % 8 === 0 && /* 2. */
        n.byteOffset + n.byteLength <= n.buffer.byteLength ? n : n.slice()
      );
    });
  }
  readSchema(t = !1) {
    return Y(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(Tw(n));
      return r;
    });
  }
  readMetadataLength() {
    return Y(this, void 0, void 0, function* () {
      const t = yield this.source.read(x0), n = t && new kc(t), i = (n == null ? void 0 : n.readInt32(0)) || 0;
      return { done: i === 0, value: i };
    });
  }
  readMetadata(t) {
    return Y(this, void 0, void 0, function* () {
      const n = yield this.source.read(t);
      if (!n)
        return xe;
      if (n.byteLength < t)
        throw new Error(oF(t, n.byteLength));
      return { done: !1, value: pi.decode(n) };
    });
  }
}
class Jrt extends cF {
  constructor(t) {
    super(new Uint8Array(0)), this._schema = !1, this._body = [], this._batchIndex = 0, this._dictionaryIndex = 0, this._json = t instanceof pS ? t : new pS(t);
  }
  next() {
    const { _json: t } = this;
    if (!this._schema)
      return this._schema = !0, { done: !1, value: pi.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: pi.fromJSON(n, Qt.DictionaryBatch) };
    }
    if (this._batchIndex < t.batches.length) {
      const n = t.batches[this._batchIndex++];
      return this._body = n.columns, { done: !1, value: pi.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 && [s.TYPE] || [],
        ...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 = Qt.Schema, n = this.readMessage(t), i = n == null ? void 0 : n.header();
    if (!n || !i)
      throw new Error(Tw(t));
    return i;
  }
}
const x0 = 4, S1 = "ARROW1", Qp = new Uint8Array(S1.length);
for (let e = 0; e < S1.length; e += 1)
  Qp[e] = S1.codePointAt(e);
function Bw(e, t = 0) {
  for (let n = -1, i = Qp.length; ++n < i; )
    if (Qp[n] !== e[t + n])
      return !1;
  return !0;
}
const Tf = Qp.length, lF = Tf + x0, Qrt = Tf * 2 + x0;
class Hr extends XN {
  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 Ou(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 zn.toDOMStream(this.isSync() ? { [Symbol.iterator]: () => this } : { [Symbol.asyncIterator]: () => this });
  }
  toNodeStream() {
    return zn.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 Hr ? t : p1(t) ? ist(t) : AB(t) ? ost(t) : Ou(t) ? (() => Y(this, void 0, void 0, function* () {
      return yield Hr.from(yield t);
    }))() : MB(t) || uw(t) || TB(t) || lw(t) ? sst(new jc(t)) : rst(new Xp(t));
  }
  /** @nocollapse */
  static readAll(t) {
    return t instanceof Hr ? t.isSync() ? SS(t) : IS(t) : p1(t) || ArrayBuffer.isView(t) || _0(t) || IB(t) ? SS(t) : IS(t);
  }
}
class ty extends Hr {
  constructor(t) {
    super(t), this._impl = t;
  }
  readAll() {
    return [...this];
  }
  [Symbol.iterator]() {
    return this._impl[Symbol.iterator]();
  }
  [Symbol.asyncIterator]() {
    return Fe(this, arguments, function* () {
      yield G(yield* Bs(Qn(this[Symbol.iterator]())));
    });
  }
}
class ey extends Hr {
  constructor(t) {
    super(t), this._impl = t;
  }
  readAll() {
    var t, n, i, r;
    return Y(this, void 0, void 0, function* () {
      const s = new Array();
      try {
        for (var o = !0, a = Qn(this), c; c = yield a.next(), t = c.done, !t; ) {
          r = c.value, o = !1;
          try {
            const l = r;
            s.push(l);
          } finally {
            o = !0;
          }
        }
      } 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 uF extends ty {
  constructor(t) {
    super(t), this._impl = t;
  }
}
class tst extends ey {
  constructor(t) {
    super(t), this._impl = t;
  }
}
class fF {
  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 an(this.schema.fields), length: t.length, children: i });
    return new fi(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 te(l)) : new te(l)).memoize();
    }
    return a.memoize();
  }
  _loadVectors(t, n, i) {
    return new KN(n, t.nodes, t.buffers, this.dictionaries).visitMany(i);
  }
}
class ny extends fF {
  constructor(t, n) {
    super(n), this._reader = p1(t) ? new Jrt(this._handle = t) : new cF(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 = dF(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 tF(this.schema) }) : this.return();
  }
  _readNextMessageAndValidate(t) {
    return this._reader.readMessage(t);
  }
}
class iy extends fF {
  constructor(t, n) {
    super(n), this._reader = new Zrt(this._handle = t);
  }
  isAsync() {
    return !0;
  }
  isStream() {
    return !0;
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  cancel() {
    return Y(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 Y(this, void 0, void 0, function* () {
      return this.closed || (this.autoDestroy = dF(this, t), this.schema || (this.schema = yield this._reader.readSchema()) || (yield this.cancel())), this;
    });
  }
  throw(t) {
    return Y(this, void 0, void 0, function* () {
      return !this.closed && this.autoDestroy && (this.closed = !0) ? yield this.reset()._reader.throw(t) : xe;
    });
  }
  return(t) {
    return Y(this, void 0, void 0, function* () {
      return !this.closed && this.autoDestroy && (this.closed = !0) ? yield this.reset()._reader.return(t) : xe;
    });
  }
  next() {
    return Y(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 tF(this.schema) }) : yield this.return();
    });
  }
  _readNextMessageAndValidate(t) {
    return Y(this, void 0, void 0, function* () {
      return yield this._reader.readMessage(t);
    });
  }
}
class hF extends ny {
  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 yS ? t : new yS(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 - lF, i = t.readInt32(n), r = t.readAt(n - i, i);
    return xw.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 est extends iy {
  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 Hp ? t : new Hp(t, i), r);
  }
  isFile() {
    return !0;
  }
  isAsync() {
    return !0;
  }
  open(t) {
    const n = Object.create(null, {
      open: { get: () => super.open }
    });
    return Y(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 Y(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 Y(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 Y(this, void 0, void 0, function* () {
      const { _handle: t } = this;
      t._pending && (yield t._pending);
      const n = t.size - lF, i = yield t.readInt32(n), r = yield t.readAt(n - i, i);
      return xw.decode(r);
    });
  }
  _readNextMessageAndValidate(t) {
    return Y(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 nst extends ny {
  constructor(t, n) {
    super(t, n);
  }
  _loadVectors(t, n, i) {
    return new prt(n, t.nodes, t.buffers, this.dictionaries).visitMany(i);
  }
}
function dF(e, t) {
  return t && typeof t.autoDestroy == "boolean" ? t.autoDestroy : e.autoDestroy;
}
function* SS(e) {
  const t = Hr.from(e);
  try {
    if (!t.open({ autoDestroy: !1 }).closed)
      do
        yield t;
      while (!t.reset().open().closed);
  } finally {
    t.cancel();
  }
}
function IS(e) {
  return Fe(this, arguments, function* () {
    const n = yield G(Hr.from(e));
    try {
      if (!(yield G(n.open({ autoDestroy: !1 }))).closed)
        do
          yield yield G(n);
        while (!(yield G(n.reset().open())).closed);
    } finally {
      yield G(n.cancel());
    }
  });
}
function ist(e) {
  return new ty(new nst(e));
}
function rst(e) {
  const t = e.peek(Tf + 7 & -8);
  return t && t.byteLength >= 4 ? Bw(t) ? new uF(new hF(e.read())) : new ty(new ny(e)) : new ty(new ny(/* @__PURE__ */ function* () {
  }()));
}
function sst(e) {
  return Y(this, void 0, void 0, function* () {
    const t = yield e.peek(Tf + 7 & -8);
    return t && t.byteLength >= 4 ? Bw(t) ? new uF(new hF(yield e.read())) : new ey(new iy(e)) : new ey(new iy(function() {
      return Fe(this, arguments, function* () {
      });
    }()));
  });
}
function ost(e) {
  return Y(this, void 0, void 0, function* () {
    const { size: t } = yield e.stat(), n = new Hp(e, t);
    return t >= Qrt && Bw(yield n.readAt(0, Tf + 7 & -8)) ? new tst(new est(n)) : new ey(new iy(n));
  });
}
function pF(e) {
  const t = Hr.from(e);
  return Ou(t) ? t.then((n) => pF(n)) : t.isAsync() ? t.readAll().then((n) => new jn(n)) : new jn(t.readAll());
}
async function jot(e) {
  e.el.classList.add("mosaic-widget");
  const t = () => e.model.get("spec"), n = () => e.model.get("temp_indexes"), i = qn().logger(), r = /* @__PURE__ */ new Map();
  function s(u, f, h) {
    const d = globalThis.crypto.randomUUID();
    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() {
    qn().clear(), tw.clear();
  }
  async function c() {
    const u = t();
    a(), i.log("Setting spec:", u), e.el.replaceChildren(await ont(u));
    const f = qn(), h = new Set([...f.clients].flatMap((d) => d.filterBy).filter((d) => d));
    for (const d of h)
      d.addEventListener("value", () => {
        const p = [...h].map(
          (m) => m.clauses.map(
            (g) => ({
              value: g.value,
              sql: String(g.predicate)
            })
          )
        );
        e.model.set("selections", p), e.model.save_changes();
      });
  }
  e.model.on("change:spec", () => c());
  function l() {
    const u = { temp: n() };
    qn().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 = pF(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");
  }), qn().databaseConnector(o), l(), c(), () => {
    a();
  };
}
export {
  jot as render
};
