/**
 * KRA - Charts Hook
 * Chart configuration with theme support
 */
import { useMemo } from 'react';
import type { EChartsOption } from 'echarts';

interface UseChartsOptions {
  isDark?: boolean;
}

export function useCharts(
  optionGenerator: (isDark: boolean) => EChartsOption,
  options: UseChartsOptions = {}
) {
  const { isDark = false } = options;

  const chartOption = useMemo(() => {
    return optionGenerator(isDark);
  }, [optionGenerator, isDark]);

  return { chartOption };
}

// Common chart color palettes
export const chartColors = {
  light: ['#5470c6', '#91cc75', '#fac858', '#ee6666', '#73c0de', '#3ba272', '#fc8452', '#9a60b4'],
  dark: ['#4992ff', '#7cffb2', '#fddd60', '#ff6e76', '#58d9f9', '#05c091', '#ff8a45', '#8d48e3'],
};

// Get theme-aware colors
export function getChartColors(isDark: boolean): string[] {
  return isDark ? chartColors.dark : chartColors.light;
}

export default useCharts;
