var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
import React, { forwardRef } from "react";
import { CheckmarkCircleFillIcon, ExclamationmarkTriangleFillIcon, InformationSquareFillIcon, XMarkIcon, XMarkOctagonFillIcon, } from "@navikt/aksel-icons";
import { Button } from "../button/index.js";
import { BodyLong } from "../typography/index.js";
import { cl } from "../utils/helpers/index.js";
import { useI18n } from "../utils/i18n/i18n.hooks.js";
const IconMap = {
    error: XMarkOctagonFillIcon,
    warning: ExclamationmarkTriangleFillIcon,
    info: InformationSquareFillIcon,
    success: CheckmarkCircleFillIcon,
};
/**
 * A component for displaying alerts
 * @see [📝 Documentation](https://aksel.nav.no/komponenter/core/alert)
 * @see 🏷️ {@link AlertProps}
 * @example
 * ```jsx
 * <Alert variant="error">Dette er en feilmelding</Alert>
 * ```
 */
export const Alert = forwardRef((_a, ref) => {
    var { children, className, variant, size = "medium", fullWidth = false, contentMaxWidth = true, inline = false, closeButton = false, onClose } = _a, rest = __rest(_a, ["children", "className", "variant", "size", "fullWidth", "contentMaxWidth", "inline", "closeButton", "onClose"]);
    const translate = useI18n("global");
    const Icon = IconMap[variant];
    return (React.createElement("div", Object.assign({}, rest, { "data-color": variantToRole(variant), "data-variant": variant, ref: ref, className: cl(className, "aksel-alert", `aksel-alert--${variant}`, `aksel-alert--${size}`, {
            "aksel-alert--full-width": fullWidth,
            "aksel-alert--inline": inline,
            "aksel-alert--close-button": closeButton,
        }) }),
        React.createElement(Icon, { title: translate(variant), className: "aksel-alert__icon" }),
        React.createElement(BodyLong, { as: "div", size: size, className: cl("aksel-alert__wrapper", contentMaxWidth && "aksel-alert__wrapper--maxwidth") }, children),
        closeButton && !inline && (React.createElement("div", { className: "aksel-alert__button-wrapper" },
            React.createElement(Button, { className: "aksel-alert__button", size: "small", variant: "tertiary-neutral", onClick: onClose, type: "button", icon: React.createElement(XMarkIcon, { title: translate("close") }) })))));
});
function variantToRole(variant) {
    switch (variant) {
        case "warning":
            return "warning";
        case "error":
            return "danger";
        case "info":
            return "info";
        case "success":
            return "success";
        default:
            return "info";
    }
}
export default Alert;
//# sourceMappingURL=Alert.js.map