/**
 * Copyright (c) Paymium.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root of this projects source tree.
 */

import type { SetTheme } from './types';

export const setTheme: SetTheme = (old, theme) => {
  if (typeof window !== 'undefined') {
    if (!window.document.documentElement.classList.contains(theme)) {
      window.document.documentElement.classList.remove(old);
      window.document.documentElement.classList.add(theme);
    }
  }
};
