import { twMerge } from 'tailwind-merge';

export const cleanClass = (...classNames: unknown[]) => {
  return twMerge(
    classNames
      .flatMap((className) => (Array.isArray(className) ? className : [className]))
      .filter((className) => {
        if (!className || typeof className === 'boolean') {
          return false;
        }

        return typeof className === 'string';
      })
      .join(' '),
  );
};

export const isDefined = <T>(value: T): value is NonNullable<T> => value !== null && value !== undefined;
