// #region Imports
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { Appearanceable } from '../../../Behaviors/Appearanceable';
import { Disableable } from '../../../Behaviors/Disableable';
import { Orientable } from '../../../Behaviors/Orientable';
import { Variantable } from '../../../Behaviors/Variantable';
import { Component } from '../../../Decorators/ComponentDecorator';
import { Watch } from '../../../Decorators/WatchDecorator';
import { CustomElement } from '../../Abstracts/CustomElement';
import { ButtonBaseElement } from '../Abstracts/ButtonBaseElement';
import { buttonGroupElementJoyStyle } from './Themes/ButtonGroupElement.Joy';
import { buttonGroupElementTemplate } from './ButtonGroupElementTemplate';
import { buttonGroupElementRetroStyle } from './Themes/ButtonGroupElement.Retro';
import { Themeable } from '../../../../Controls/Behaviors/Themeable';
import { buttonGroupElementCosmopolitanStyle } from './Themes/ButtonGroupElement.Cosmopolitan';
import { Slottable } from '../../../Behaviors/Slottable';
// #endregion
/**
 * Button Group - A user interface component for grouping multiple buttons together.
 *
 * @description
 * The Button Group component is designed to group multiple buttons together for a cohesive user interface.
 * It provides a way to organize related actions or options and visually group them as a single unit.
 * Button groups are commonly used in toolbars, navigation menus, and form layouts.
 *
 * @name Button Group
 * @element mosaik-button-group
 * @category Buttons
 *
 * @slot - The default slot.
 *
 * @cssprop {String} --button-group-font-family
 * @cssprop {String} --button-group-font-size
 * @cssprop {String} --button-group-font-line-height
 * @cssprop {String} --button-group-font-weight
 * @cssprop {String} --button-group-font-letter-spacing
 * @cssprop {String} --button-group-font-text-decoration
 * @cssprop {String} --button-group-font-text-transform
 * @cssprop {String} --button-group-padding-top
 * @cssprop {String} --button-group-padding-right
 * @cssprop {String} --button-group-padding-bottom
 * @cssprop {String} --button-group-padding-left
 * @cssprop {String} --button-group-gap
 * @cssprop {String} --button-group-transition-duration
 * @cssprop {String} --button-group-transition-mode
 * @cssprop {String} --button-group-transition-property
 * @cssprop {String} --button-group-background-color
 * @cssprop {String} --button-group-border-color
 * @cssprop {String} --button-group-foreground-color
 * @cssprop {String} --button-group-border-width
 * @cssprop {String} --button-group-border-radius
 * @cssprop {String} --button-group-border-style
 * @cssprop {String} --button-group-shadow
 * @cssprop {String} --button-border-radius
 * @cssprop {String} --button-border-width
 *
 * @example
 * ```html
 * <mosaik-button-group>
 *   <mosaik-button label="Button 1"></mosaik-button>
 *   <mosaik-button label="Button 2"></mosaik-button>
 *   <mosaik-button label="Button 3"></mosaik-button>
 * </mosaik-button-group>
 * ```
 *
 * @public
 */
let ButtonGroupElement = class ButtonGroupElement extends Themeable(Orientable(Disableable(Appearanceable(Variantable(Slottable(CustomElement)))))) {
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `{@link is}` property.
     * The `{@link is}` property represents natural name of this element.
     *
     * @public
     * @static
     * @readonly
     */
    static get is() {
        return 'mosaik-button-group';
    }
    // #endregion
    // #region Methods
    /**
     * @public
     */
    onSlotChanges() {
        const elements = this.getSlotAssignments('')
            .filter((x) => x instanceof ButtonBaseElement);
        for (const [i, e] of elements.entries()) {
            e.disabled = this.disabled;
            e.appearance = this.appearance;
            e.variant = this.variant;
            e.dir = this.dir;
            e.classList.add('button-group-button');
            e.classList.toggle('first', i === 0);
            e.classList.toggle('inner', i > 0 && i < elements.length - 1);
            e.classList.toggle('last', i === elements.length - 1);
        }
    }
    /**
     * @protected
     */
    onDisabledPropertyChange(_prev, next) {
        const elements = this.getSlotAssignments('')
            .filter((x) => x instanceof ButtonBaseElement);
        if (next !== undefined) {
            elements.forEach((x) => x.disabled = next);
        }
    }
    /**
     * @protected
     */
    onAppearancePropertyChange(_prev, next) {
        if (next) {
            this.getSlotAssignments('')
                .filter((x) => x instanceof ButtonBaseElement)
                .forEach((x) => x.appearance = next);
        }
    }
    /**
     * @protected
     */
    onVariantPropertyChange(_prev, next) {
        if (next) {
            this.getSlotAssignments('')
                .filter((x) => x instanceof ButtonBaseElement)
                .forEach((x) => x.variant = next);
        }
    }
    /**
     * @protected
     */
    onDirPropertyChange(_prev, next) {
        if (next) {
            this.getSlotAssignments('')
                .filter((x) => x instanceof ButtonBaseElement)
                .forEach((x) => x.dir = next);
        }
    }
};
__decorate([
    Watch('disabled'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Boolean, Boolean]),
    __metadata("design:returntype", void 0)
], ButtonGroupElement.prototype, "onDisabledPropertyChange", null);
__decorate([
    Watch('appearance'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String]),
    __metadata("design:returntype", void 0)
], ButtonGroupElement.prototype, "onAppearancePropertyChange", null);
__decorate([
    Watch('variant'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String]),
    __metadata("design:returntype", void 0)
], ButtonGroupElement.prototype, "onVariantPropertyChange", null);
__decorate([
    Watch('dir'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String]),
    __metadata("design:returntype", void 0)
], ButtonGroupElement.prototype, "onDirPropertyChange", null);
ButtonGroupElement = __decorate([
    Component({
        selector: 'mosaik-button-group',
        template: buttonGroupElementTemplate,
        themes: {
            joy: buttonGroupElementJoyStyle,
            retro: buttonGroupElementRetroStyle,
            cosmopolitan: buttonGroupElementCosmopolitanStyle
        },
        host: {
            role: 'group'
        },
        imports: []
    }),
    __metadata("design:paramtypes", [])
], ButtonGroupElement);
export { ButtonGroupElement };
//# sourceMappingURL=ButtonGroupElement.js.map