/*
 * CoolerControl - monitor and control your cooling and other devices
 * Copyright (c) 2021-2025  Guy Boldon and contributors
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

export default {
    root: ({ props }) => ({
        class: [
            // Flexbox
            'flex flex-col',

            // Position
            'relative',
            {
                '!transition-none !transform-none !w-screen !h-screen !max-h-full !top-0 !left-0':
                    props.position === 'full',
            },

            // Size
            {
                'h-full w-80': props.position === 'left' || props.position === 'right',
                'h-auto w-full': props.position === 'top' || props.position === 'bottom',
            },

            // Shape
            // 'border-0 dark:border',
            'shadow-lg',

            // Colors
            'bg-bg-two',
            'text-text-color',

            // Transitions
            'transition-transform',
            'duration-100',

            // Misc
            'pointer-events-auto',
        ],
    }),
    header: {
        class: [
            // Flexbox and Alignment
            'flex items-center justify-between',
            'shrink-0',

            // Spacing
            'p-2',
            // Colors
            'bg-bg-two',
            'text-text-color',
        ],
    },
    title: {
        class: ['font-bold text-lg'],
    },
    icons: {
        class: ['flex items-center'],
    },
    closeButton: {
        class: [
            'relative',

            // Flexbox and Alignment
            'flex items-center justify-center',

            // Size and Spacing
            'mr-2',
            'last:mr-0',
            'w-8 h-8',

            // Shape
            'border-0',
            'rounded-full',

            // Colors
            'text-text-color-secondary',
            'bg-transparent',

            // Transitions
            'transition duration-200 ease-in-out',

            // States
            'hover:text-text-color',
            // 'hover:bg-surface-100 dark:hover:bg-surface-800/80',
            'focus:outline-none focus:outline-offset-0 focus:ring focus:ring-inset',
            // 'focus:ring-primary-400/50 dark:focus:ring-primary-300/50',

            // Misc
            'overflow-hidden',
        ],
    },
    closeButtonIcon: {
        class: [
            // Display
            'inline-block',

            // Size
            'w-4',
            'h-4',
        ],
    },
    content: {
        class: [
            // Spacing and Size
            // 'p-5', // let caller set the spacing
            'pt-0',
            'h-full',
            'w-full',

            // Growth and Overflow
            'grow',
            'overflow-y-auto',
        ],
    },
    mask: ({ props }) => ({
        class: [
            // Transitions
            'transition-all',
            'duration-100',
            { 'p-5': !props.position === 'full' },

            // Background and Effects
            {
                'has-[.mask-active]:bg-transparent bg-black/75': props.modal,
                // 'has-[.mask-active]:bg-transparent bg-black/40': props.modal,
                // 'has-[.mask-active]:backdrop-blur-none backdrop-blur-sm': props.modal,
            },
        ],
    }),
    transition: ({ props }) => {
        return props.position === 'top'
            ? {
                  enterFromClass: 'translate-x-0 -translate-y-full translate-z-0 mask-active',
                  leaveToClass: 'translate-x-0 -translate-y-full translate-z-0 mask-active',
              }
            : props.position === 'bottom'
              ? {
                    enterFromClass: 'translate-x-0 translate-y-full translate-z-0 mask-active',
                    leaveToClass: 'translate-x-0 translate-y-full translate-z-0 mask-active',
                }
              : props.position === 'left'
                ? {
                      enterFromClass: '-translate-x-full translate-y-0 translate-z-0 mask-active',
                      leaveToClass: '-translate-x-full translate-y-0 translate-z-0 mask-active',
                  }
                : props.position === 'right'
                  ? {
                        enterFromClass: 'translate-x-full translate-y-0 translate-z-0 mask-active',
                        leaveToClass: 'translate-x-full translate-y-0 translate-z-0 mask-active',
                    }
                  : {
                        enterFromClass: 'opacity-0 mask-active',
                        enterActiveClass: 'transition-opacity duration-400 ease-in',
                        leaveActiveClass: 'transition-opacity duration-400 ease-in',
                        leaveToClass: 'opacity-0 mask-active',
                    }
    },
}
