'use client';
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var tslib = require('tslib');
var decorators_js = require('lit/decorators.js');
var sgdsElement = require('./sgds-element.cjs.js');
var button = require('./button.cjs.js');

class ButtonElement extends sgdsElement["default"] {
    constructor() {
        super(...arguments);
        /** Sets the visual variants such as: `primary`, `outline`, `ghost`. `danger` is @deprecated since v3.5.6 */
        this.variant = "primary";
        /** Sets the visual colour of the button: `brand`, `danger`, `fixed-light`, `neutral` */
        this.tone = "brand";
        /** Specifies a small, medium or large button, the size is medium by default. */
        this.size = "md";
        /** Manually set the visual state of the button to `:active` */
        this.active = false;
        /** The disabled state of the button */
        this.disabled = false;
        /** Where to display the linked URL, as the name for a browsing context. Forwards to the HTMLAnchor target attribute */
        this.target = "_self";
    }
    /** Sets focus on the button. */
    focus(options) {
        this.button.focus(options);
    }
    /** Simulates a click on the button. */
    click() {
        this.button.click();
    }
    /** Removes focus from the button. */
    blur() {
        this.button.blur();
    }
    _handleBlur() {
        this.emit("sgds-blur");
    }
    _handleFocus() {
        this.emit("sgds-focus");
    }
    _handleClick(event) {
        if (this.disabled || this.loading) {
            event.preventDefault();
            event.stopPropagation();
            return;
        }
    }
    _handleKeydown(event) {
        if (event.key === "Enter" && this.loading) {
            event.preventDefault();
            event.stopPropagation();
            return;
        }
    }
    _assignSpinnerSize(buttonSize) {
        if (buttonSize === "xs" || buttonSize === "sm")
            return "xs";
        if (buttonSize === "md" || buttonSize === "lg")
            return "sm";
    }
    _assignSpinnerTone(buttonTone, buttonVariant) {
        // Default spinner tone
        if (buttonTone === "fixed-light" && buttonVariant === "primary")
            return "fixed-dark";
        if (buttonTone === "neutral" && buttonVariant === "primary")
            return "inverse";
        if (buttonTone === "fixed-light" || buttonVariant === "primary")
            return "fixed-light";
        if (buttonTone === "neutral" && (buttonVariant === "outline" || buttonVariant === "ghost"))
            return "neutral";
        return "brand";
    }
}
ButtonElement.styles = [...sgdsElement["default"].styles, button["default"]];
tslib.__decorate([
    decorators_js.query(".btn")
], ButtonElement.prototype, "button", void 0);
tslib.__decorate([
    decorators_js.property({ reflect: true })
], ButtonElement.prototype, "variant", void 0);
tslib.__decorate([
    decorators_js.property({ reflect: true })
], ButtonElement.prototype, "tone", void 0);
tslib.__decorate([
    decorators_js.property({ reflect: true })
], ButtonElement.prototype, "size", void 0);
tslib.__decorate([
    decorators_js.property({ type: Boolean, reflect: true })
], ButtonElement.prototype, "active", void 0);
tslib.__decorate([
    decorators_js.property({ type: Boolean, reflect: true })
], ButtonElement.prototype, "disabled", void 0);
tslib.__decorate([
    decorators_js.property({ type: String, reflect: true })
], ButtonElement.prototype, "href", void 0);
tslib.__decorate([
    decorators_js.property({ type: String, reflect: true })
], ButtonElement.prototype, "target", void 0);
tslib.__decorate([
    decorators_js.property({ type: String, reflect: true })
], ButtonElement.prototype, "download", void 0);
tslib.__decorate([
    decorators_js.property({ type: String })
], ButtonElement.prototype, "ariaLabel", void 0);
tslib.__decorate([
    decorators_js.property({ type: Boolean })
], ButtonElement.prototype, "loading", void 0);

exports["default"] = ButtonElement;
//# sourceMappingURL=button-element.cjs.js.map
