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 { BodyLong, ErrorMessage } from "../../typography/index.js";
import { useId } from "../../utils-external/index.js";
import { cl } from "../../utils/helpers/index.js";
import { Checkbox } from "../checkbox/index.js";
import { useFormField } from "../useFormField.js";
/**
 * A component that displays a confirmation checkbox with a label.
 * @deprecated Use `Checkbox` instead. See [new pattern documentation](https://aksel.nav.no/monster-maler/soknadsdialog/introside-for-soknadsdialoger#8346a8cb849b) for more information.
 *
 * @see [📝 Documentation](https://aksel.nav.no/komponenter/core/confirmationpanel)
 * @see 🏷️ {@link ConfirmationPanelProps}
 *
 * @example
 * ```jsx
      <ConfirmationPanel
        checked={state}
        label="Ja, jeg samtykker."
        onChange={() => setState((x) => !x)}
      >
        For å komme videre må du gi oss lov til å hente inn og bruke opplysninger
        om deg.
      </ConfirmationPanel>
 * ```
 */
export const ConfirmationPanel = forwardRef((_a, ref) => {
    var { className, children, label } = _a, props = __rest(_a, ["className", "children", "label"]);
    const { errorId, showErrorMsg, hasError, size, inputProps } = useFormField(props, "confirmation-panel");
    const id = useId();
    const currentColor = hasError
        ? "danger"
        : props.checked
            ? "success"
            : "warning";
    return (React.createElement("div", { className: cl("aksel-confirmation-panel", "aksel-form-field", className, {
            "aksel-confirmation-panel--small": size === "small",
            "aksel-confirmation-panel--error": hasError,
            "aksel-confirmation-panel--checked": !!props.checked,
        }), "data-color": currentColor },
        React.createElement("div", { className: "aksel-confirmation-panel__inner" },
            children && (React.createElement(BodyLong, { size: props.size, className: "aksel-confirmation-panel__content", id: `confirmation-panel-${id}`, as: "div" }, children)),
            React.createElement(Checkbox, Object.assign({ ref: ref }, props, inputProps, { "aria-describedby": cl(inputProps["aria-describedby"], children && `confirmation-panel-${id}`), error: hasError, size: size }), label)),
        React.createElement("div", { className: "aksel-form-field__error", id: errorId, role: "alert" }, showErrorMsg && (React.createElement(ErrorMessage, { size: size, showIcon: true }, props.error)))));
});
export default ConfirmationPanel;
//# sourceMappingURL=ConfirmationPanel.js.map