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 { omit, useId } from "../utils-external/index.js";
import { cl } from "../utils/helpers/index.js";
import { useI18n } from "../utils/i18n/i18n.hooks.js";
/**
 * A component that displays a loading spinner.
 *
 * @see [📝 Documentation](https://aksel.nav.no/komponenter/core/loader)
 * @see 🏷️ {@link LoaderProps}
 *
 * @example
 * ```jsx
 * <Loader size="3xlarge" title="Venter…" />
 * ```
 */
export const Loader = forwardRef((_a, ref) => {
    var { className, size = "medium", title, transparent = false, variant = "neutral", id, "data-color": color } = _a, rest = __rest(_a, ["className", "size", "title", "transparent", "variant", "id", "data-color"]);
    const internalId = useId();
    const translate = useI18n("Loader");
    return (React.createElement("svg", Object.assign({ "aria-labelledby": id !== null && id !== void 0 ? id : `loader-${internalId}`, ref: ref, className: cl("aksel-loader", className, `aksel-loader--${size}`, `aksel-loader--${variant}`, {
            "aksel-loader--transparent": transparent,
        }), focusable: "false", viewBox: "0 0 50 50", preserveAspectRatio: "xMidYMid", "data-color": color !== null && color !== void 0 ? color : variantToColor(variant) }, omit(rest, ["children"]), { "data-variant": variant }),
        React.createElement("title", { id: id !== null && id !== void 0 ? id : `loader-${internalId}` }, title || translate("title")),
        React.createElement("circle", { className: "aksel-loader__background", xmlns: "http://www.w3.org/2000/svg", cx: "25", cy: "25", r: "20", fill: "none" }),
        React.createElement("circle", { className: "aksel-loader__foreground", cx: "25", cy: "25", r: "20", fill: "none", strokeDasharray: "50 155" })));
});
function variantToColor(variant) {
    switch (variant) {
        case "neutral":
            return "neutral";
        case "inverted":
            return "neutral";
        /* We assume "interaction" is the main app color in this instance */
        case "interaction":
            return undefined;
        default:
            return "neutral";
    }
}
export default Loader;
//# sourceMappingURL=Loader.js.map