'use strict';

const tailwindMerge = require('tailwind-merge');
const clsx = require('clsx');
const tailwindConfig = require('../tailwind-config.cjs');

const customTwMerge = tailwindMerge.extendTailwindMerge({
  extend: {
    theme: {
      colors: Object.entries(tailwindConfig.colorPalette).reduce((acc, currentVal) => {
        const colors = Object.keys(currentVal[1]).map(
          (c) => `text-${currentVal[0]}-${c}`
        );
        return acc.concat(colors);
      }, []),
      borderRadius: Object.keys(tailwindConfig.borderRadius).map((s) => `rounded-${s}`)
    },
    classGroups: {
      shadow: [{ shadow: Object.keys(tailwindConfig.boxShadows).map((s) => `shadow-${s}`) }],
      "font-size": Object.keys(tailwindConfig.fontSizes).map((s) => `text-${s}`),
      "font-weight": Object.keys(tailwindConfig.fontWeights).map((s) => `font-${s}`),
      scale: Object.keys(tailwindConfig.scales).map((s) => `scale-${s}`),
      h: Object.keys(tailwindConfig.heights).map((s) => `h-${s}`),
      leading: Object.keys(tailwindConfig.lineHeights).map((s) => `leading-${s}`)
    }
  }
});
const cn = (...inputs) => {
  return customTwMerge(clsx.clsx(inputs));
};

exports.cn = cn;
