"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "withSkeleton", {
    enumerable: true,
    get: function() {
        return withSkeleton;
    }
});
const _react = /*#__PURE__*/ _interop_require_default(require("react"));
const _classnames = /*#__PURE__*/ _interop_require_default(require("classnames"));
const _mixins = require("../../../mixins");
const _tokens = require("../tokens");
const _withSkeletonstyles = require("./withSkeleton.styles");
function _interop_require_default(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    };
}
const withSkeleton = (Component)=>/*#__PURE__*/ _react.default.forwardRef(({ skeleton, animationConfig, animationType, className, ...props }, ref)=>{
        const effectiveType = animationConfig?.type ?? animationType ?? 'shimmer';
        const effectiveLighter = animationConfig?.type === 'shimmer' ? animationConfig.lighter ?? true : true;
        const effectiveGradientColor = animationConfig?.type === 'shimmer' ? animationConfig.customGradientColor : undefined;
        const effectiveFadeInColor = animationConfig?.type === 'pulse' ? animationConfig.customFadeInColor : undefined;
        const effectiveFadeOutColor = animationConfig?.type === 'pulse' ? animationConfig.customFadeOutColor : undefined;
        const animationClass = _tokens.classes[`${effectiveType}Animation`];
        const skeletonClass = skeleton ? 'apply-skeleton-gradient' : undefined;
        const skeletonGradientColor = (0, _mixins.getSkeletonColor)({
            lighter: effectiveLighter,
            customGradientColor: effectiveGradientColor
        });
        const wrapperStyle = {
            [_tokens.privateTokens.lineSkeletonGradient]: skeletonGradientColor,
            [_tokens.privateTokens.skeletonFadeInColor]: effectiveFadeInColor || `var(${_tokens.tokens.fadeInColor})`,
            [_tokens.privateTokens.skeletonFadeOutColor]: effectiveFadeOutColor || `var(${_tokens.tokens.fadeOutColor})`
        };
        const componentProps = {
            ...props,
            ref,
            className: (0, _classnames.default)(skeletonClass, animationClass, className)
        };
        return /*#__PURE__*/ _react.default.createElement(_withSkeletonstyles.Wrapper, {
            style: wrapperStyle
        }, /*#__PURE__*/ _react.default.createElement(Component, componentProps));
    });
