function _define_property(obj, key, value) {
    if (key in obj) {
        Object.defineProperty(obj, key, {
            value: value,
            enumerable: true,
            configurable: true,
            writable: true
        });
    } else {
        obj[key] = value;
    }
    return obj;
}
function _object_spread(target) {
    for(var i = 1; i < arguments.length; i++){
        var source = arguments[i] != null ? arguments[i] : {};
        var ownKeys = Object.keys(source);
        if (typeof Object.getOwnPropertySymbols === "function") {
            ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
                return Object.getOwnPropertyDescriptor(source, sym).enumerable;
            }));
        }
        ownKeys.forEach(function(key) {
            _define_property(target, key, source[key]);
        });
    }
    return target;
}
function ownKeys(object, enumerableOnly) {
    var keys = Object.keys(object);
    if (Object.getOwnPropertySymbols) {
        var symbols = Object.getOwnPropertySymbols(object);
        if (enumerableOnly) {
            symbols = symbols.filter(function(sym) {
                return Object.getOwnPropertyDescriptor(object, sym).enumerable;
            });
        }
        keys.push.apply(keys, symbols);
    }
    return keys;
}
function _object_spread_props(target, source) {
    source = source != null ? source : {};
    if (Object.getOwnPropertyDescriptors) {
        Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
    } else {
        ownKeys(Object(source)).forEach(function(key) {
            Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
        });
    }
    return target;
}
import { useEditorStyleRegister } from "../../Hooks/useStyle";
import { DEFAULT_TEXT_SWAP_DURATION_MS, TEXT_SWAP_BLUR_PX, TEXT_SWAP_EASING, TEXT_SWAP_TRANSLATE_Y_PX } from "./constants";
var genStyle = function genStyle(token) {
    var componentCls = token.componentCls;
    var _obj;
    return _obj = {}, _define_property(_obj, componentCls, {
        '--text-swap-dur': "".concat(DEFAULT_TEXT_SWAP_DURATION_MS, "ms"),
        '--text-swap-translate-y': "".concat(TEXT_SWAP_TRANSLATE_Y_PX, "px"),
        '--text-swap-blur': "".concat(TEXT_SWAP_BLUR_PX, "px"),
        '--text-swap-ease': TEXT_SWAP_EASING,
        display: 'inline-block',
        minWidth: 0,
        maxWidth: '100%',
        verticalAlign: 'bottom',
        transform: 'translateY(0)',
        filter: 'blur(0)',
        opacity: 1,
        transition: [
            "transform var(--text-swap-dur) var(--text-swap-ease)",
            "filter var(--text-swap-dur) var(--text-swap-ease)",
            "opacity var(--text-swap-dur) var(--text-swap-ease)"
        ].join(','),
        willChange: 'transform, filter, opacity',
        '&-exit': {
            transform: 'translateY(calc(var(--text-swap-translate-y) * -1))',
            filter: 'blur(var(--text-swap-blur))',
            opacity: 0
        },
        '&-enter-start': {
            transform: 'translateY(var(--text-swap-translate-y))',
            filter: 'blur(var(--text-swap-blur))',
            opacity: 0,
            transition: 'none'
        }
    }), _define_property(_obj, '@media (prefers-reduced-motion: reduce)', _define_property({}, componentCls, {
        transition: 'none !important'
    })), _obj;
};
export function useTextSwapStyle(prefixCls) {
    return useEditorStyleRegister('text-swap', function(token) {
        var textSwapToken = _object_spread_props(_object_spread({}, token), {
            componentCls: ".".concat(prefixCls)
        });
        return [
            genStyle(textSwapToken)
        ];
    });
}
