"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const notistack_1 = require("notistack");
const styles_1 = require("@mui/material/styles");
const material_1 = require("@mui/material");
const Icon_1 = tslib_1.__importDefault(require("@mui/material/Icon"));
const Widget_1 = tslib_1.__importDefault(require("../../components/Widget"));
const PREFIX = 'SCCustomSnackMessage';
const classes = {
    root: `${PREFIX}-root`,
    card: `${PREFIX}-card`,
    content: `${PREFIX}-content`,
    close: `${PREFIX}-close`
};
const Root = (0, styles_1.styled)(notistack_1.SnackbarContent, {
    name: PREFIX,
    slot: 'Root',
    overridesResolver: (props, styles) => styles.root
})(({ theme }) => ({}));
/**
 * Custom Snackbar for notistack messages
 * Use this component:
 *  - pass this component as property 'content' in the 'options' of enqueueSnackbar
 *
 * This component add a CloseIcon button on the top-right corner
 * and attach a close handler that close the snackMessage identified as props.id
 */
const CustomSnackMessage = (0, react_1.forwardRef)((props, ref) => {
    const { closeSnackbar } = (0, notistack_1.useSnackbar)();
    const handleDismiss = (0, react_1.useCallback)(() => {
        closeSnackbar(props.id);
    }, [props.id, closeSnackbar]);
    return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ ref: ref, className: classes.root }, { children: (0, jsx_runtime_1.jsx)(Widget_1.default, Object.assign({ className: classes.card }, { children: (0, jsx_runtime_1.jsxs)(material_1.CardContent, Object.assign({ className: classes.content }, { children: [(0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ className: classes.close, onClick: handleDismiss }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "close" }) })), props.message] })) })) }), props.id));
});
exports.default = CustomSnackMessage;
