'use strict';

var index = require('./index-p7cvUYAE.js');
var parts = require('./parts-BXshb_S-.js');

const ButtonSpinner = () => (index.h("div", { class: "spinner-border spinner-border-sm", role: "status", part: "button-spinner" }, index.h("span", { class: "visually-hidden" }, "Loading...")));

var __rest = (undefined && undefined.__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;
};
const Button = (props, children) => {
    const { variant, isLoading, className, class: classProp, clickHandler } = props, rest = __rest(props, ["variant", "isLoading", "className", "class", "clickHandler"]);
    const variantToButton = {
        primary: parts.buttonPrimary,
        secondary: parts.buttonSecondary,
        success: parts.buttonSuccess,
        danger: parts.buttonDanger,
        warning: parts.buttonWarning,
        info: parts.buttonInfo,
        light: parts.buttonLight,
        dark: parts.buttonDark,
        link: parts.buttonLink,
        'outline-primary': parts.buttonOutlinePrimary,
        'outline-secondary': parts.buttonOutlineSecondary,
    };
    const getCSSParts = () => {
        return `${variantToButton[variant]} ${isLoading ? parts.buttonLoading : ''}`;
    };
    const extraClasses = className || classProp || '';
    const computedClass = `btn btn-${variant}${extraClasses ? ` ${extraClasses}` : ''}`;
    return (index.h("button", Object.assign({ class: computedClass, onClick: clickHandler, part: getCSSParts() }, rest), isLoading ? ButtonSpinner() : children));
};

exports.Button = Button;
