/**
 * Color utilities for chart components
 * Handles color extraction, manipulation, and theme integration
 */
/**
 * Extracts the fill color class from a combined class string
 * @param classString - Combined class string like "fill-primary-base stroke-primary-base"
 * @returns The fill class or empty string
 */
function extractFillClass(classString) {
    const classes = classString.split(' ');
    const fillClass = classes.find(cls => cls.startsWith('fill-'));
    return fillClass || '';
}
/**
 * Extracts the stroke color class from a combined class string
 * @param classString - Combined class string like "fill-primary-base stroke-primary-base"
 * @returns The stroke class or empty string
 */
function extractStrokeClass(classString) {
    const classes = classString.split(' ');
    const strokeClass = classes.find(cls => cls.startsWith('stroke-'));
    return strokeClass || '';
}
/**
 * Converts a Tailwind color class to a CSS variable
 * @param colorClass - Tailwind color class like "fill-primary-base"
 * @returns CSS variable string like "var(--color-primary-500)"
 */
function colorClassToVariable(colorClass) {
    // Remove the prefix (fill-, stroke-, bg-, text-, etc.)
    const colorPart = colorClass.replace(/^(fill-|stroke-|bg-|text-|border-)/, '');
    // Convert to CSS variable format
    if (colorPart.includes('-base')) {
        return `var(--color-${colorPart.replace('-base', '-500')})`;
    }
    return `var(--color-${colorPart})`;
}
/**
 * Combines multiple Tailwind classes into a single class string
 * @param classes - Array of class strings
 * @returns Combined class string
 */
function combineClasses(...classes) {
    return classes.filter(Boolean).join(' ');
}
/**
 * Creates a color class string for chart elements
 * @param baseColor - Base color (e.g., "primary", "warning")
 * @param type - Type of element ("fill", "stroke", "both")
 * @param shade - Color shade (e.g., "base", "400", "500")
 * @returns Tailwind class string
 */
function createColorClass(baseColor, type = 'both', shade = 'base') {
    const colorName = `${baseColor}-${shade}`;
    switch (type) {
        case 'fill':
            return `fill-${colorName}`;
        case 'stroke':
            return `stroke-${colorName}`;
        case 'both':
            return `fill-${colorName} stroke-${colorName}`;
        default:
            return `fill-${colorName} stroke-${colorName}`;
    }
}
/**
 * Generates a series of color classes for multiple data series
 * @param baseColors - Array of base color names
 * @param type - Type of element ("fill", "stroke", "both")
 * @param shade - Color shade
 * @returns Array of color class strings
 */
function generateSeriesColors(baseColors, type = 'both', shade = 'base') {
    return baseColors.map(color => createColorClass(color, type, shade));
}
/**
 * Default color palette for charts
 */
const DEFAULT_CHART_COLORS = [
    'primary',
    'warning',
    'success',
    'danger',
];
/**
 * Extended color palette for charts with more options
 */
const EXTENDED_CHART_COLORS = [
    'primary',
    'warning',
    'success',
    'danger',
    'info',
    'purple',
    'pink',
    'indigo',
];
/**
 * Minimal color palette for subtle charts
 */
const MINIMAL_CHART_COLORS = [
    'neutral',
    'slate',
    'gray',
    'zinc',
];
/**
 * Generate a color palette for charts
 */
function generateColorPalette(count, baseHue = 200) {
    const colors = [];
    const saturation = 70;
    const lightness = 50;
    for (let i = 0; i < count; i++) {
        const hue = (baseHue + (i * 360) / count) % 360;
        colors.push(`hsl(${hue}, ${saturation}%, ${lightness}%)`);
    }
    return colors;
}
/**
 * Get contrast color (black or white) based on background color
 */
function getContrastColor(backgroundColor) {
    // Convert hex to RGB
    const hex = backgroundColor.replace('#', '');
    const r = parseInt(hex.substring(0, 2), 16);
    const g = parseInt(hex.substring(2, 2), 16);
    const b = parseInt(hex.substring(4, 2), 16);
    // Calculate luminance
    const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
    return luminance > 0.5 ? '#000000' : '#ffffff';
}

export { DEFAULT_CHART_COLORS, EXTENDED_CHART_COLORS, MINIMAL_CHART_COLORS, colorClassToVariable, combineClasses, createColorClass, extractFillClass, extractStrokeClass, generateColorPalette, generateSeriesColors, getContrastColor };
