"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: Object.getOwnPropertyDescriptor(all, name).get
    });
}
_export(exports, {
    get notificationConfig () {
        return notificationConfig;
    },
    get notificationRoot () {
        return notificationRoot;
    }
});
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
const _utils = require("../../utils");
const _IconCross = require("../_Icon/Icons/IconCross");
const _IconCrossThin = require("../_Icon/Icons/IconCrossThin");
const _Notificationtokens = require("./Notification.tokens");
const _base = require("./variations/_view/base");
const _base1 = require("./variations/_layout/base");
const _base2 = require("./variations/_size/base");
const _base3 = require("./variations/_closeIconType/base");
const _Notificationtypes = require("./Notification.types");
const _Notificationstyles = require("./Notification.styles");
const _utils1 = require("./utils");
function _getRequireWildcardCache(nodeInterop) {
    if (typeof WeakMap !== "function") return null;
    var cacheBabelInterop = new WeakMap();
    var cacheNodeInterop = new WeakMap();
    return (_getRequireWildcardCache = function(nodeInterop) {
        return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
    })(nodeInterop);
}
function _interop_require_wildcard(obj, nodeInterop) {
    if (!nodeInterop && obj && obj.__esModule) {
        return obj;
    }
    if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
        return {
            default: obj
        };
    }
    var cache = _getRequireWildcardCache(nodeInterop);
    if (cache && cache.has(obj)) {
        return cache.get(obj);
    }
    var newObj = {
        __proto__: null
    };
    var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
    for(var key in obj){
        if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
            var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
            if (desc && (desc.get || desc.set)) {
                Object.defineProperty(newObj, key, desc);
            } else {
                newObj[key] = obj[key];
            }
        }
    }
    newObj.default = obj;
    if (cache) {
        cache.set(obj, newObj);
    }
    return newObj;
}
const notificationRoot = (Root)=>/*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
        const { role = 'status', title, children: content, actions, view, size, iconPlacement, layout = _Notificationtypes.layouts.vertical, icon, showCloseIcon = true, closeIconType, customCloseIcon, textColor, titleColor, backgroundColor, width, maxWidth, onCloseButtonClick, ...rest } = props;
        let ariaLive = 'polite';
        let ariaAtomic = false;
        if (role === 'alert') {
            ariaLive = 'assertive';
        } else if (role === 'status') {
            ariaAtomic = true;
        }
        const isOneLine = !content || !title;
        const oneLineClass = isOneLine ? _Notificationtokens.classes.oneLine : undefined;
        const withoutIconClass = icon ? undefined : _Notificationtokens.classes.withoutIcon;
        const withoutCloseIconClass = showCloseIcon ? undefined : _Notificationtokens.classes.withoutCloseIcon;
        const IconPlacementInternal = (0, _react.useMemo)(()=>icon ? iconPlacement : undefined, [
            icon,
            iconPlacement
        ]);
        return /*#__PURE__*/ _react.default.createElement(Root, {
            view: view,
            size: size,
            layout: layout,
            closeIconType: closeIconType,
            ref: ref,
            role: role,
            "aria-live": ariaLive,
            "aria-atomic": ariaAtomic,
            ...rest
        }, /*#__PURE__*/ _react.default.createElement(_Notificationstyles.Wrapper, {
            backgroundColor: backgroundColor,
            width: width,
            maxWidth: maxWidth,
            className: (0, _utils.cx)(_Notificationtokens.classes.wrapper, (0, _utils1.getLayoutClass)(layout), oneLineClass, withoutCloseIconClass)
        }, /*#__PURE__*/ _react.default.createElement(_Notificationstyles.ContentBox, {
            iconPlacement: IconPlacementInternal,
            className: (0, _utils.cx)(_Notificationtokens.classes.contentBox, (0, _utils1.getLayoutClass)(layout), withoutIconClass)
        }, icon && /*#__PURE__*/ _react.default.createElement(_Notificationstyles.IconWrapper, {
            iconPlacement: IconPlacementInternal,
            className: (0, _utils.cx)(_Notificationtokens.classes.icon, (0, _utils1.getLayoutClass)(layout))
        }, icon), /*#__PURE__*/ _react.default.createElement(_Notificationstyles.TextBox, {
            iconPlacement: IconPlacementInternal,
            showCloseIcon: showCloseIcon,
            className: (0, _utils.cx)(_Notificationtokens.classes.textbox, (0, _utils1.getLayoutClass)(layout))
        }, title && /*#__PURE__*/ _react.default.createElement(_Notificationstyles.StyledTitle, {
            className: _Notificationtokens.classes.title,
            textColor: titleColor
        }, title), content && /*#__PURE__*/ _react.default.createElement(_Notificationstyles.StyledContent, {
            className: _Notificationtokens.classes.text,
            textColor: textColor
        }, content))), actions && /*#__PURE__*/ _react.default.createElement(_Notificationstyles.ButtonsWrapper, {
            iconPlacement: IconPlacementInternal,
            className: (0, _utils.cx)(_Notificationtokens.classes.buttonsWrapper, (0, _utils1.getLayoutClass)(layout))
        }, actions), showCloseIcon && /*#__PURE__*/ _react.default.createElement(_Notificationstyles.CloseIconWrapper, {
            view: "clear",
            size: "s",
            onClick: onCloseButtonClick,
            className: (0, _utils.cx)(_Notificationtokens.classes.closeIcon, (0, _utils1.getLayoutClass)(layout))
        }, customCloseIcon || (closeIconType === 'default' ? /*#__PURE__*/ _react.default.createElement(_IconCross.IconCross, {
            size: "s",
            sizeCustomProperty: _Notificationtokens.tokens.closeIconSize,
            color: "inherit"
        }) : /*#__PURE__*/ _react.default.createElement(_IconCrossThin.IconCrossThin, {
            size: "s",
            sizeCustomProperty: _Notificationtokens.tokens.closeIconSize,
            color: "inherit"
        })))));
    });
const notificationConfig = {
    name: 'Notification',
    tag: 'div',
    layout: notificationRoot,
    base: _Notificationstyles.StyledNotification,
    variations: {
        layout: {
            css: _base1.base
        },
        view: {
            css: _base.base
        },
        size: {
            css: _base2.base
        },
        closeIconType: {
            css: _base3.base
        }
    },
    defaults: {
        view: 'default',
        layout: _Notificationtypes.layouts.vertical,
        size: 'xs',
        closeIconType: 'default'
    }
};
