import M from "chroma-js";
import { Hsluv as p } from "hsluv";
const r = [
  0,
  50,
  100,
  200,
  300,
  400,
  500,
  600,
  700,
  800,
  900,
  950,
  1e3
], N = 0, V = 100, C = (l, H, c) => {
  const f = r.map((t) => ({ stop: t, tweak: 0 })), _ = r.map((t) => ({ stop: t, tweak: Math.min(0, 100) })), u = new p();
  u.hex = l, u.hexToHsluv();
  const x = u.hsluv_l, h = [
    { stop: 0, tweak: V },
    { stop: c, tweak: x },
    { stop: 1e3, tweak: N }
  ], S = r.map((t) => {
    const o = h.find((v) => v.stop === t);
    if (o)
      return o;
    let n, a;
    if (t < c ? [n, a] = h : [n, a] = h.slice(1), !n || !a)
      throw new Error("Invalid anchor points for interpolation");
    const i = a.stop - n.stop, m = (t - n.stop) / i, w = n.tweak + (a.tweak - n.tweak) * m;
    return { stop: t, tweak: Math.round(w) };
  }), k = r.map((t, o) => {
    if (t === c)
      return l.toUpperCase();
    const n = f[o]?.tweak ?? 0, a = _[o]?.tweak ?? 0, i = S[o]?.tweak ?? 0, s = new p();
    s.hex = l, s.hexToHsluv();
    const w = ((Number.isNaN(s.hsluv_h) ? 0 : s.hsluv_h) + n) % 360, v = Math.max(
      0,
      Math.min(100, s.hsluv_s + a)
    ), d = Math.max(0, Math.min(100, i));
    return s.hsluv_h = w, s.hsluv_s = v, s.hsluv_l = d, s.hsluvToHex(), M(s.hex).hex().toUpperCase();
  }), T = H === "dark" ? k : [...k].reverse(), e = (t) => {
    const o = T[t];
    if (!o)
      throw new Error(`No color found for stop index: ${t}`);
    return o;
  };
  return {
    50: e(1),
    100: e(2),
    200: e(3),
    300: e(4),
    400: e(5),
    500: e(6),
    600: e(7),
    700: e(8),
    800: e(9),
    900: e(10),
    950: e(11)
  };
};
export {
  C as createColorPalette
};
//# sourceMappingURL=createColorPalette.js.map
