import { aP as N, aQ as $, aR as w, aS as R, aT as d } from "./index-BDD0CD9m.js";
import { t as q } from "./init-DjUOC4st-C8Nwz6AJ.js";
import { N as D, t as J, n as S, J as M } from "./defaultLocale-D7EN2tov-CK6dgF7Y.js";
function g(t, n) {
  return t == null || n == null ? NaN : t < n ? -1 : t > n ? 1 : t >= n ? 0 : NaN;
}
function T(t, n) {
  return t == null || n == null ? NaN : n < t ? -1 : n > t ? 1 : n >= t ? 0 : NaN;
}
function x(t) {
  let n, u, e;
  t.length !== 2 ? (n = g, u = (i, c) => g(t(i), c), e = (i, c) => t(i) - c) : (n = t === g || t === T ? t : V, u = t, e = t);
  function a(i, c, r = 0, h = i.length) {
    if (r < h) {
      if (n(c, c) !== 0) return h;
      do {
        const l = r + h >>> 1;
        u(i[l], c) < 0 ? r = l + 1 : h = l;
      } while (r < h);
    }
    return r;
  }
  function f(i, c, r = 0, h = i.length) {
    if (r < h) {
      if (n(c, c) !== 0) return h;
      do {
        const l = r + h >>> 1;
        u(i[l], c) <= 0 ? r = l + 1 : h = l;
      } while (r < h);
    }
    return r;
  }
  function o(i, c, r = 0, h = i.length) {
    const l = a(i, c, r, h - 1);
    return l > r && e(i[l - 1], c) > -e(i[l], c) ? l - 1 : l;
  }
  return { left: a, center: o, right: f };
}
function V() {
  return 0;
}
function j(t) {
  return t === null ? NaN : +t;
}
const B = x(g), O = B.right;
x(j).center;
const Q = Math.sqrt(50), C = Math.sqrt(10), E = Math.sqrt(2);
function p(t, n, u) {
  const e = (n - t) / Math.max(0, u), a = Math.floor(Math.log10(e)), f = e / Math.pow(10, a), o = f >= Q ? 10 : f >= C ? 5 : f >= E ? 2 : 1;
  let i, c, r;
  return a < 0 ? (r = Math.pow(10, -a) / o, i = Math.round(t * r), c = Math.round(n * r), i / r < t && ++i, c / r > n && --c, r = -r) : (r = Math.pow(10, a) * o, i = Math.round(t / r), c = Math.round(n / r), i * r < t && ++i, c * r > n && --c), c < i && 0.5 <= u && u < 2 ? p(t, n, u * 2) : [i, c, r];
}
function F(t, n, u) {
  if (n = +n, t = +t, u = +u, !(u > 0)) return [];
  if (t === n) return [t];
  const e = n < t, [a, f, o] = e ? p(n, t, u) : p(t, n, u);
  if (!(f >= a)) return [];
  const i = f - a + 1, c = new Array(i);
  if (e)
    if (o < 0) for (let r = 0; r < i; ++r) c[r] = (f - r) / -o;
    else for (let r = 0; r < i; ++r) c[r] = (f - r) * o;
  else if (o < 0) for (let r = 0; r < i; ++r) c[r] = (a + r) / -o;
  else for (let r = 0; r < i; ++r) c[r] = (a + r) * o;
  return c;
}
function v(t, n, u) {
  return n = +n, t = +t, u = +u, p(t, n, u)[2];
}
function G(t, n, u) {
  n = +n, t = +t, u = +u;
  const e = n < t, a = e ? v(n, t, u) : v(t, n, u);
  return (e ? -1 : 1) * (a < 0 ? 1 / -a : a);
}
function H(t, n) {
  n || (n = []);
  var u = t ? Math.min(n.length, t.length) : 0, e = n.slice(), a;
  return function(f) {
    for (a = 0; a < u; ++a) e[a] = t[a] * (1 - f) + n[a] * f;
    return e;
  };
}
function I(t) {
  return ArrayBuffer.isView(t) && !(t instanceof DataView);
}
function K(t, n) {
  var u = n ? n.length : 0, e = t ? Math.min(u, t.length) : 0, a = new Array(e), f = new Array(u), o;
  for (o = 0; o < e; ++o) a[o] = b(t[o], n[o]);
  for (; o < u; ++o) f[o] = n[o];
  return function(i) {
    for (o = 0; o < e; ++o) f[o] = a[o](i);
    return f;
  };
}
function L(t, n) {
  var u = /* @__PURE__ */ new Date();
  return t = +t, n = +n, function(e) {
    return u.setTime(t * (1 - e) + n * e), u;
  };
}
function P(t, n) {
  var u = {}, e = {}, a;
  (t === null || typeof t != "object") && (t = {}), (n === null || typeof n != "object") && (n = {});
  for (a in n)
    a in t ? u[a] = b(t[a], n[a]) : e[a] = n[a];
  return function(f) {
    for (a in u) e[a] = u[a](f);
    return e;
  };
}
function b(t, n) {
  var u = typeof n, e;
  return n == null || u === "boolean" ? $(n) : (u === "number" ? N : u === "string" ? (e = d(n)) ? (n = e, w) : R : n instanceof d ? w : n instanceof Date ? L : I(n) ? H : Array.isArray(n) ? K : typeof n.valueOf != "function" && typeof n.toString != "function" || isNaN(n) ? P : N)(t, n);
}
function U(t, n) {
  return t = +t, n = +n, function(u) {
    return Math.round(t * (1 - u) + n * u);
  };
}
function W(t) {
  return Math.max(0, -M(Math.abs(t)));
}
function X(t, n) {
  return Math.max(0, Math.max(-8, Math.min(8, Math.floor(M(n) / 3))) * 3 - M(Math.abs(t)));
}
function Y(t, n) {
  return t = Math.abs(t), n = Math.abs(n) - t, Math.max(0, M(n) - M(t)) + 1;
}
function Z(t) {
  return function() {
    return t;
  };
}
function _(t) {
  return +t;
}
var A = [0, 1];
function m(t) {
  return t;
}
function y(t, n) {
  return (n -= t = +t) ? function(u) {
    return (u - t) / n;
  } : Z(isNaN(n) ? NaN : 0.5);
}
function z(t, n) {
  var u;
  return t > n && (u = t, t = n, n = u), function(e) {
    return Math.max(t, Math.min(n, e));
  };
}
function tt(t, n, u) {
  var e = t[0], a = t[1], f = n[0], o = n[1];
  return a < e ? (e = y(a, e), f = u(o, f)) : (e = y(e, a), f = u(f, o)), function(i) {
    return f(e(i));
  };
}
function nt(t, n, u) {
  var e = Math.min(t.length, n.length) - 1, a = new Array(e), f = new Array(e), o = -1;
  for (t[e] < t[0] && (t = t.slice().reverse(), n = n.slice().reverse()); ++o < e; )
    a[o] = y(t[o], t[o + 1]), f[o] = u(n[o], n[o + 1]);
  return function(i) {
    var c = O(t, i, 1, e) - 1;
    return f[c](a[c](i));
  };
}
function et(t, n) {
  return n.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown());
}
function rt() {
  var t = A, n = A, u = b, e, a, f, o = m, i, c, r;
  function h() {
    var s = Math.min(t.length, n.length);
    return o !== m && (o = z(t[0], t[s - 1])), i = s > 2 ? nt : tt, c = r = null, l;
  }
  function l(s) {
    return s == null || isNaN(s = +s) ? f : (c || (c = i(t.map(e), n, u)))(e(o(s)));
  }
  return l.invert = function(s) {
    return o(a((r || (r = i(n, t.map(e), N)))(s)));
  }, l.domain = function(s) {
    return arguments.length ? (t = Array.from(s, _), h()) : t.slice();
  }, l.range = function(s) {
    return arguments.length ? (n = Array.from(s), h()) : n.slice();
  }, l.rangeRound = function(s) {
    return n = Array.from(s), u = U, h();
  }, l.clamp = function(s) {
    return arguments.length ? (o = s ? !0 : m, h()) : o !== m;
  }, l.interpolate = function(s) {
    return arguments.length ? (u = s, h()) : u;
  }, l.unknown = function(s) {
    return arguments.length ? (f = s, l) : f;
  }, function(s, k) {
    return e = s, a = k, h();
  };
}
function ut() {
  return rt()(m, m);
}
function at(t, n, u, e) {
  var a = G(t, n, u), f;
  switch (e = D(e ?? ",f"), e.type) {
    case "s": {
      var o = Math.max(Math.abs(t), Math.abs(n));
      return e.precision == null && !isNaN(f = X(a, o)) && (e.precision = f), J(e, o);
    }
    case "":
    case "e":
    case "g":
    case "p":
    case "r": {
      e.precision == null && !isNaN(f = Y(a, Math.max(Math.abs(t), Math.abs(n)))) && (e.precision = f - (e.type === "e"));
      break;
    }
    case "f":
    case "%": {
      e.precision == null && !isNaN(f = W(a)) && (e.precision = f - (e.type === "%") * 2);
      break;
    }
  }
  return S(e);
}
function ot(t) {
  var n = t.domain;
  return t.ticks = function(u) {
    var e = n();
    return F(e[0], e[e.length - 1], u ?? 10);
  }, t.tickFormat = function(u, e) {
    var a = n();
    return at(a[0], a[a.length - 1], u ?? 10, e);
  }, t.nice = function(u) {
    u == null && (u = 10);
    var e = n(), a = 0, f = e.length - 1, o = e[a], i = e[f], c, r, h = 10;
    for (i < o && (r = o, o = i, i = r, r = a, a = f, f = r); h-- > 0; ) {
      if (r = v(o, i, u), r === c)
        return e[a] = o, e[f] = i, n(e);
      if (r > 0)
        o = Math.floor(o / r) * r, i = Math.ceil(i / r) * r;
      else if (r < 0)
        o = Math.ceil(o * r) / r, i = Math.floor(i * r) / r;
      else
        break;
      c = r;
    }
    return t;
  }, t;
}
function it() {
  var t = ut();
  return t.copy = function() {
    return et(t, it());
  }, q.apply(t, arguments), ot(t);
}
export {
  G as E,
  x as R,
  et as e,
  it as f,
  ut as u
};
