'use strict';

// src/lib/closest-palette-color.ts
function getDesignSystemPaletteTokenLabel(paletteTitle, shade) {
  return `${paletteTitle.toLowerCase().replace(/\s+/g, "-")}-${shade}`;
}
var LAB_EPSILON = 216 / 24389;
var LAB_KAPPA = 24389 / 27;
var D65_REF_X = 0.95047;
var D65_REF_Y = 1;
var D65_REF_Z = 1.08883;
function srgbChannelToLinear(channelByte) {
  const c = channelByte / 255;
  return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
}
function rgbToXyz({ r, g, b }) {
  const rl = srgbChannelToLinear(r);
  const gl = srgbChannelToLinear(g);
  const bl = srgbChannelToLinear(b);
  return {
    x: rl * 0.4124564 + gl * 0.3575761 + bl * 0.1804375,
    y: rl * 0.2126729 + gl * 0.7151522 + bl * 0.072175,
    z: rl * 0.0193339 + gl * 0.119192 + bl * 0.9503041
  };
}
function labF(t) {
  return t > LAB_EPSILON ? Math.cbrt(t) : (LAB_KAPPA * t + 16) / 116;
}
function xyzToLab(x, y, z) {
  const xr = x / D65_REF_X;
  const yr = y / D65_REF_Y;
  const zr = z / D65_REF_Z;
  const fx = labF(xr);
  const fy = labF(yr);
  const fz = labF(zr);
  return {
    l: 116 * fy - 16,
    a: 500 * (fx - fy),
    b: 200 * (fy - fz)
  };
}
function rgbToLab(rgb) {
  const { x, y, z } = rgbToXyz(rgb);
  return xyzToLab(x, y, z);
}
function deltaE76(lab1, lab2) {
  const dL = lab1.l - lab2.l;
  const da = lab1.a - lab2.a;
  const db = lab1.b - lab2.b;
  return Math.sqrt(dL * dL + da * da + db * db);
}
function parseHexToRgb(input) {
  const trimmed = input.trim();
  if (trimmed.length === 0) {
    return null;
  }
  let hex = trimmed.startsWith("#") ? trimmed.slice(1) : trimmed;
  if (!/^[0-9a-fA-F]+$/.test(hex)) {
    return null;
  }
  if (hex.length === 3) {
    hex = hex.split("").map((ch) => ch + ch).join("");
  }
  if (hex.length === 8) {
    hex = hex.slice(0, 6);
  }
  if (hex.length !== 6) {
    return null;
  }
  const n = Number.parseInt(hex, 16);
  if (!Number.isFinite(n)) {
    return null;
  }
  return {
    r: n >> 16 & 255,
    g: n >> 8 & 255,
    b: n & 255
  };
}
function findClosestDesignSystemPaletteColor(input, catalog) {
  const targetRgb = parseHexToRgb(input);
  if (!targetRgb) {
    return null;
  }
  const targetLab = rgbToLab(targetRgb);
  let best = null;
  for (const entry of catalog) {
    const rgb = parseHexToRgb(entry.hex);
    if (!rgb) {
      continue;
    }
    const lab = rgbToLab(rgb);
    const de = deltaE76(targetLab, lab);
    if (!best || de < best.deltaE) {
      best = { match: entry, deltaE: de };
    }
  }
  return best;
}

// src/lib/dashboard-chrome-surface.ts
var DASHBOARD_CHROME_SURFACE_CLASS = "bg-card dark:bg-sidebar";
var DASHBOARD_CHROME_SURFACE_HOVER_ELEVATION_CLASS = "transition-[box-shadow,border-color,background-color] duration-200 ease-out motion-reduce:transition-none hover:shadow-[0_2px_8px_-2px_rgb(0_0_0/0.06),0_1px_4px_-1px_rgb(0_0_0/0.04)] dark:hover:shadow-[0_2px_10px_-2px_rgb(0_0_0/0.28),0_1px_4px_-1px_rgb(0_0_0/0.18)]";
var SETTINGS_SURFACE_HOVER_CLASS = "transition-[border-color,background-color,box-shadow] duration-200 ease-out motion-reduce:transition-none hover:border-sidebar-border hover:bg-sidebar dark:hover:bg-sidebar-accent";

exports.DASHBOARD_CHROME_SURFACE_CLASS = DASHBOARD_CHROME_SURFACE_CLASS;
exports.DASHBOARD_CHROME_SURFACE_HOVER_ELEVATION_CLASS = DASHBOARD_CHROME_SURFACE_HOVER_ELEVATION_CLASS;
exports.SETTINGS_SURFACE_HOVER_CLASS = SETTINGS_SURFACE_HOVER_CLASS;
exports.deltaE76 = deltaE76;
exports.findClosestDesignSystemPaletteColor = findClosestDesignSystemPaletteColor;
exports.getDesignSystemPaletteTokenLabel = getDesignSystemPaletteTokenLabel;
exports.parseHexToRgb = parseHexToRgb;
//# sourceMappingURL=index.cjs.map
//# sourceMappingURL=index.cjs.map