"use client";
import { initRange as l } from "./init.js";
import f from "../../d3-array/src/ascending.js";
import { quantileSorted as s } from "../../d3-array/src/quantile.js";
import { bisectRight as c } from "../../d3-array/src/bisect.js";
function m() {
  var t = [], u = [], i = [], a;
  function o() {
    var n = 0, r = Math.max(1, u.length);
    for (i = new Array(r - 1); ++n < r; ) i[n - 1] = s(t, n / r);
    return e;
  }
  function e(n) {
    return n == null || isNaN(n = +n) ? a : u[c(i, n)];
  }
  return e.invertExtent = function(n) {
    var r = u.indexOf(n);
    return r < 0 ? [NaN, NaN] : [
      r > 0 ? i[r - 1] : t[0],
      r < i.length ? i[r] : t[t.length - 1]
    ];
  }, e.domain = function(n) {
    if (!arguments.length) return t.slice();
    t = [];
    for (let r of n) r != null && !isNaN(r = +r) && t.push(r);
    return t.sort(f), o();
  }, e.range = function(n) {
    return arguments.length ? (u = Array.from(n), o()) : u.slice();
  }, e.unknown = function(n) {
    return arguments.length ? (a = n, e) : a;
  }, e.quantiles = function() {
    return i.slice();
  }, e.copy = function() {
    return m().domain(t).range(u).unknown(a);
  }, l.apply(e, arguments);
}
export {
  m as default
};
