import {
  getTypography
} from "./chunk-E4EXM4SY.js";
import {
  useBreakpoints
} from "./chunk-JSGRNWSB.js";
import {
  __spreadProps,
  __spreadValues
} from "./chunk-CIGAQ47A.js";

// src/styles/colors.tsx
import { css, useTheme } from "@emotion/react";
var neutral = {
  black: "#000000",
  gray5: "#0D0D0D",
  gray10: "#1A1A1A",
  gray15: "#262626",
  gray20: "#333333",
  gray25: "#404040",
  gray30: "#4D4D4D",
  gray40: "#666666",
  gray50: "#808080",
  gray60: "#999999",
  gray70: "#B3B3B3",
  gray80: "#CCCCCC",
  gray85: "#D9D9D9",
  gray90: "#E6E6E6",
  gray95: "#F2F2F2",
  white: "#FFFFFF"
};
var uma = {
  background: "#F9F9F9",
  black: "#16171A",
  blue: "#0068C9",
  blue50: "#C0C9D6",
  blue80: "#DCE2EA",
  blue90: "#EBEEF2",
  blue95: "#F2F5F7",
  grey300: "#DEDFE4",
  secondary: "#686A72",
  stroke: "#C0C9D6",
  strokeProminent: "#9BA7B9",
  fill: "#EBEEF2"
};
var darkGradient = "#1d1d1d linear-gradient(180deg, #090909 63.08%, #1d1d1d 100.52%)";
var Themes = /* @__PURE__ */ ((Themes2) => {
  Themes2["Light"] = "light";
  Themes2["Dark"] = "dark";
  return Themes2;
})(Themes || {});
var primary = "#FFF14E";
var colors = __spreadProps(__spreadValues({}, neutral), {
  uma,
  // green
  success: "#17C27C",
  // blue
  blue43: "#145BC6",
  blue22: "#0E2E60",
  blue58: "#28BFFF",
  blue95: "#EBEEF2",
  // yellow
  primary,
  warning: primary,
  // orange
  danger: "#FD2C0F",
  // neutral
  secondary: neutral.black,
  // billing
  tier1: "#179257",
  tier2: "#8B38DE",
  tier3: "#0048F7"
});
function extend(obj, rest) {
  return __spreadValues(__spreadValues({}, obj), rest);
}
function extendBase(obj, rest) {
  return __spreadValues(__spreadValues({}, obj), rest);
}
function hcNeutralFromBg(bgHex, defaultHex, altHex) {
  const bgRGB = hexToRGB(bgHex);
  const hcRGB = hexToRGB(defaultHex);
  if (!bgRGB || !hcRGB)
    return defaultHex;
  const c = contrast(bgRGB, hcRGB);
  if (c < 4.5) {
    return altHex;
  }
  return defaultHex;
}
var lightBaseTheme = {
  type: "light" /* Light */,
  app: "Lightspark" /* Lightspark */,
  bg: colors.white,
  smBg: colors.white,
  c05Neutral: neutral.gray95,
  c1Neutral: neutral.gray90,
  c15Neutral: neutral.gray85,
  c2Neutral: neutral.gray80,
  c3Neutral: neutral.gray70,
  c4Neutral: neutral.gray60,
  c5Neutral: neutral.gray50,
  c6Neutral: neutral.gray40,
  c7Neutral: neutral.gray30,
  c8Neutral: neutral.gray20,
  c9Neutral: neutral.gray10,
  danger: colors.danger,
  hcNeutral: colors.black,
  hcNeutralFromBg: (bgHex) => hcNeutralFromBg(bgHex, colors.black, colors.white),
  info: colors.blue43,
  lcNeutral: neutral.gray80,
  link: colors.blue43,
  mcNeutral: neutral.gray40,
  onInfoText: colors.white,
  onPrimaryText: colors.black,
  onSuccessText: colors.white,
  primary: colors.primary,
  secondary: colors.secondary,
  success: colors.success,
  text: colors.black,
  typography: getTypography(),
  vlcNeutral: neutral.gray95,
  warning: colors.warning
};
var darkBaseTheme = {
  type: "dark" /* Dark */,
  app: "Lightspark" /* Lightspark */,
  bg: colors.black,
  smBg: colors.black,
  c05Neutral: neutral.gray5,
  c1Neutral: neutral.gray10,
  c15Neutral: neutral.gray15,
  c2Neutral: neutral.gray20,
  c3Neutral: neutral.gray30,
  c4Neutral: neutral.gray40,
  c5Neutral: neutral.gray50,
  c6Neutral: neutral.gray60,
  c7Neutral: neutral.gray70,
  c8Neutral: neutral.gray80,
  c9Neutral: neutral.gray90,
  danger: colors.danger,
  hcNeutral: colors.white,
  hcNeutralFromBg: (bgHex) => hcNeutralFromBg(bgHex, colors.white, colors.black),
  info: colors.white,
  lcNeutral: neutral.gray40,
  link: colors.blue43,
  mcNeutral: neutral.gray60,
  onInfoText: colors.white,
  onPrimaryText: colors.black,
  onSuccessText: colors.white,
  primary: colors.primary,
  secondary: colors.secondary,
  success: colors.success,
  text: colors.white,
  typography: getTypography(),
  vlcNeutral: neutral.gray20,
  warning: colors.warning
};
var lightTheme = extend(lightBaseTheme, {
  header: extendBase(lightBaseTheme, {
    text: colors.gray60
  }),
  nav: extendBase(lightBaseTheme, {
    text: colors.gray10,
    secondary: colors.gray40
  }),
  content: extendBase(lightBaseTheme, {
    bg: colors.white,
    smBg: colors.white
  }),
  controls: extendBase(lightBaseTheme, {
    bg: neutral.gray95,
    smBg: neutral.gray95,
    text: neutral.gray60,
    secondary: colors.secondary
  })
});
var darkTheme = extend(darkBaseTheme, {
  header: extendBase(darkBaseTheme, {}),
  nav: extendBase(darkBaseTheme, {}),
  content: extendBase(darkBaseTheme, {}),
  controls: extendBase(darkBaseTheme, {
    bg: neutral.gray40,
    smBg: neutral.gray40,
    text: neutral.white,
    secondary: colors.secondary
  })
});
var umaLightTheme = extend(lightTheme, {
  app: "UmaDocs" /* UmaDocs */,
  bg: uma.background,
  smBg: uma.background,
  secondary: uma.secondary,
  text: uma.black,
  link: uma.blue,
  content: extendBase(lightBaseTheme, {
    bg: uma.background,
    smBg: uma.background,
    text: uma.black,
    secondary: uma.secondary
  }),
  controls: extendBase(lightBaseTheme, {
    text: uma.black,
    secondary: uma.secondary,
    bg: uma.blue90
  })
});
var themeWithTypography = (theme, typography) => {
  return extendBase(theme, { typography });
};
var themes = {
  light: lightTheme,
  dark: darkTheme,
  uma: {
    light: umaLightTheme
  }
};
var isDark = (theme) => theme.type === "dark" /* Dark */;
var isLight = (theme) => theme.type === "light" /* Light */;
var themeOr = (lightValue, darkValue) => ({ theme }) => {
  return isLight(theme) ? lightValue : darkValue;
};
function ifLight(style) {
  return function({ theme }) {
    if (theme.type === "light" /* Light */) {
      return css`
        ${style}
      `;
    }
    return "";
  };
}
function ifDark(style) {
  return function({ theme }) {
    if (theme.type === "dark" /* Dark */) {
      return css`
        ${style}
      `;
    }
    return "";
  };
}
function luminance(r, g, b) {
  const a = [r, g, b].map(function(v) {
    v /= 255;
    return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);
  });
  return a[0] * 0.2126 + a[1] * 0.7152 + a[2] * 0.0722;
}
function contrast(rgb1, rgb2) {
  const lum1 = luminance(rgb1[0], rgb1[1], rgb1[2]);
  const lum2 = luminance(rgb2[0], rgb2[1], rgb2[2]);
  const brightest = Math.max(lum1, lum2);
  const darkest = Math.min(lum1, lum2);
  return (brightest + 0.05) / (darkest + 0.05);
}
function componentToHex(c) {
  const hex = c.toString(16);
  return hex.length === 1 ? "0" + hex : hex;
}
function rgbToHex(r, g, b) {
  return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
}
function hexToRGB(hex) {
  const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
  return result ? [
    parseInt(result[1], 16),
    parseInt(result[2], 16),
    parseInt(result[3], 16)
  ] : [0, 0, 0];
}
function hexToRGBAStr(hex, alpha) {
  const rgb = hexToRGB(hex);
  return `rgba(${rgb[0]}, ${rgb[1]}, ${rgb[2]}, ${alpha})`;
}
function useThemeBg() {
  const theme = useTheme();
  const bp = useBreakpoints();
  const isSm = bp.current("sm" /* sm */);
  if (isDark(theme)) {
    return darkGradient;
  }
  return isSm ? theme.smBg : theme.bg;
}

export {
  darkGradient,
  Themes,
  colors,
  themeWithTypography,
  themes,
  isDark,
  isLight,
  themeOr,
  ifLight,
  ifDark,
  luminance,
  contrast,
  componentToHex,
  rgbToHex,
  hexToRGB,
  hexToRGBAStr,
  useThemeBg
};
