import useWarning from "../hooks/useWarning";
import { deepMergeObject } from "../utils/object";
import darkTheme from "./variants/dark";
import lightTheme from "./variants/light";
import cosmicTheme from "./variants/cosmic";
export const mergeTheme = (current, custom) => {
  if (!custom) return current;

  if (typeof custom === "function") {
    const merged = custom(current);

    if (!merged || typeof merged !== "object") {
      useWarning("The theme function must return object value.");
    }

    return merged;
  }

  return deepMergeObject(current, custom);
};
export const getThemeByType = type => {
  const themes = {
    light: lightTheme,
    dark: darkTheme,
    cosmic: cosmicTheme
  };
  return themes[type];
};
export const switchTheme = mergedTheme => {
  return { ...getThemeByType(mergedTheme.type),
    ...mergedTheme
  };
};