/**
 * @license
 * Copyright Tyler Technologies, Inc. 
 * License: Apache-2.0
 */
import { __decorate } from "tslib";
import { attachShadowTemplate, coerceBoolean, CustomElement, FoundationProperty } from '@tylertech/forge-core';
import { ButtonComponent } from '../button';
import { BaseComponent } from '../core/base/base-component';
import { SplitButtonAdapter } from './split-button-adapter';
import { SPLIT_BUTTON_CONSTANTS } from './split-button-constants';
import { SplitButtonFoundation } from './split-button-foundation';
const template = '<template><slot></slot></template>';
const styles = ':host{--_split-button-min-width:var(--forge-split-button-min-width, 0);--_split-button-gap:var(--forge-split-button-gap, var(--forge-border-thin, 1px));--_split-button-focus-indicator-offset:var(--forge-split-button-focus-indicator-offset, var(--forge-button-focus-indicator-offset, 4px));--_split-button-focus-indicator-divider-offset:var(--forge-split-button-focus-indicator-divider-offset, var(--_split-button-gap));--_split-button-focus-indicator-offset-adjusted:calc(var(--_split-button-focus-indicator-offset) + var(--_split-button-focus-indicator-divider-offset) * 2)}:host{display:-webkit-inline-box;display:inline-flex;-webkit-box-pack:center;justify-content:center;-webkit-box-align:center;align-items:center}:host([hidden]){display:none}::slotted(*){--forge-button-min-width:var(--_split-button-min-width);--forge-button-focus-indicator-offset:var(--_split-button-focus-indicator-offset)}::slotted(:first-child){--forge-button-shape-start-end-radius:0;--forge-button-shape-end-end-radius:0;--forge-focus-indicator-shape-start-end:0;--forge-focus-indicator-shape-end-end:0;--forge-focus-indicator-offset-inline:0 var(--_split-button-focus-indicator-offset-adjusted)}::slotted(:not(:first-child):not(:last-child)){--forge-button-shape:0;--forge-focus-indicator-shape:0;--forge-focus-indicator-offset-inline:var(--_split-button-focus-indicator-offset-adjusted)}::slotted(:last-child){--forge-button-shape-start-start-radius:0;--forge-button-shape-end-start-radius:0;--forge-focus-indicator-shape-start-start:0;--forge-focus-indicator-shape-end-start:0;--forge-focus-indicator-offset-inline:var(--_split-button-focus-indicator-offset-adjusted) 0}:host([variant=outlined]){--_split-button-focus-indicator-divider-offset:var(--forge-split-button-focus-indicator-divider-offset, 0px)}:host([variant=outlined]) ::slotted(:not(:first-child)){-webkit-margin-start:calc(-1 * var(--_split-button-gap));margin-inline-start:calc(-1 * var(--_split-button-gap))}:host(:is([variant=tonal],[variant=filled],[variant=raised],:not([variant]))) ::slotted(:not(:last-child)){-webkit-margin-end:var(--_split-button-gap);margin-inline-end:var(--_split-button-gap)}';
/**
 * @tag forge-split-button
 *
 * @summary Split buttons are used for splitting an action into two parts.
 *
 * @property {SplitButtonVariant} variant - The variant of the buttons. Valid values are `text`, `outlined`, `tonal`, `filled`, and `raised`.
 * @property {ButtonTheme} theme - The theme of the buttons. Valid values are `primary`, `secondary`, `tertiary`, `success`, `error`, `warning`, `info`.
 * @property {boolean} disabled - Whether or not the buttons are disabled.
 * @property {boolean} dense - Whether or not the buttons are dense.
 * @property {boolean} pill - Whether or not the buttons are pill-shaped.
 *
 * @attribute {SplitButtonVariant} variant - The variant of the buttons. Valid values are `text`, `outlined`, `tonal`, `filled`, and `raised`.
 * @attribute {ButtonTheme} theme - The theme of the buttons. Valid values are `primary`, `secondary`, `tertiary`, `success`, `error`, `warning`, `info`.
 * @attribute {boolean} disabled - Whether or not the buttons are disabled.
 * @attribute {boolean} dense - Whether or not the buttons are dense.
 * @attribute {boolean} pill - Whether or not the buttons are pill-shaped.
 *
 * @cssproperty --forge-split-button-min-width - The minimum width of the slotted buttons.
 * @cssproperty --forge-split-button-gap - The gap between the slotted buttons.
 * @cssproperty --forge-split-button-focus-indicator-offset - The offset of the focus indicator around the buttons.
 * @cssproperty --forge-split-button-focus-indicator-divider-offset - The offset of the focus indicator divider when using outlined buttons.
 *
 * @slot - This is a default/unnamed slot.
 */
let SplitButtonComponent = class SplitButtonComponent extends BaseComponent {
    static get observedAttributes() {
        return [
            SPLIT_BUTTON_CONSTANTS.attributes.VARIANT,
            SPLIT_BUTTON_CONSTANTS.attributes.THEME,
            SPLIT_BUTTON_CONSTANTS.attributes.DISABLED,
            SPLIT_BUTTON_CONSTANTS.attributes.DENSE,
            SPLIT_BUTTON_CONSTANTS.attributes.PILL
        ];
    }
    constructor() {
        super();
        attachShadowTemplate(this, template, styles);
        this._foundation = new SplitButtonFoundation(new SplitButtonAdapter(this));
    }
    connectedCallback() {
        this._foundation.initialize();
    }
    disconnectedCallback() {
        this._foundation.destroy();
    }
    attributeChangedCallback(name, oldValue, newValue) {
        switch (name) {
            case SPLIT_BUTTON_CONSTANTS.attributes.VARIANT:
                this.variant = newValue;
                break;
            case SPLIT_BUTTON_CONSTANTS.attributes.THEME:
                this.theme = newValue;
                break;
            case SPLIT_BUTTON_CONSTANTS.attributes.DISABLED:
                this.disabled = coerceBoolean(newValue);
                break;
            case SPLIT_BUTTON_CONSTANTS.attributes.DENSE:
                this.dense = coerceBoolean(newValue);
                break;
            case SPLIT_BUTTON_CONSTANTS.attributes.PILL:
                this.pill = coerceBoolean(newValue);
                break;
        }
    }
};
__decorate([
    FoundationProperty()
], SplitButtonComponent.prototype, "variant", void 0);
__decorate([
    FoundationProperty()
], SplitButtonComponent.prototype, "theme", void 0);
__decorate([
    FoundationProperty()
], SplitButtonComponent.prototype, "disabled", void 0);
__decorate([
    FoundationProperty()
], SplitButtonComponent.prototype, "dense", void 0);
__decorate([
    FoundationProperty()
], SplitButtonComponent.prototype, "pill", void 0);
SplitButtonComponent = __decorate([
    CustomElement({
        name: SPLIT_BUTTON_CONSTANTS.elementName,
        dependencies: [
            ButtonComponent
        ]
    })
], SplitButtonComponent);
export { SplitButtonComponent };
