/**
 * @license
 * Copyright Tyler Technologies, Inc. 
 * License: Apache-2.0
 */
import { __decorate } from "tslib";
import { attachShadowTemplate, coerceBoolean, CustomElement, FoundationProperty } from '@tylertech/forge-core';
import { WithFocusable } from '../../core/mixins/focus/with-focusable';
import { WithElementInternals } from '../../core/mixins/internals/with-element-internals';
import { FocusIndicatorComponent } from '../../focus-indicator';
import { StateLayerComponent } from '../../state-layer';
import { BaseComponent } from '../../core/base/base-component';
import { ButtonToggleAdapter } from './button-toggle-adapter';
import { BUTTON_TOGGLE_CONSTANTS } from './button-toggle-constants';
import { ButtonToggleFoundation } from './button-toggle-foundation';
import { WithDefaultAria } from '../../core/mixins/internals/with-default-aria';
const template = '<template><div class=\"forge-button-toggle\" part=\"root\"><slot name=\"start\"></slot><slot></slot><slot name=\"end\"></slot><forge-focus-indicator target=\":host\" part=\"focus-indicator\"></forge-focus-indicator><forge-state-layer target=\":host\" exportparts=\"surface:state-layer\"></forge-state-layer></div></template>';
const styles = ':host{--_button-toggle-display:var(--forge-button-toggle-display, inline-flex)}:host{display:var(--_button-toggle-display);position:relative;outline:0;height:100%;-webkit-tap-highlight-color:transparent}:host([hidden]){display:none}.forge-button-toggle{--_button-toggle-min-width:var(--forge-button-toggle-min-width, auto);--_button-toggle-spacing:var(--forge-button-toggle-spacing, var(--forge-spacing-xsmall, 8px));--_button-toggle-padding-block:var(--forge-button-toggle-padding-block, 2px);--_button-toggle-padding-inline:var(--forge-button-toggle-padding-inline, 8px);--_button-toggle-icon-size:var(--forge-button-toggle-icon-size, var(--forge-button-icon-size, calc(var(--forge-typography-font-size, 1rem) * 1.125)));--_button-toggle-color:var(--forge-button-toggle-color, var(--forge-theme-text-medium, rgba(0, 0, 0, 0.6)));--_button-toggle-background:var(--forge-button-toggle-background, transparent);--_button-toggle-hover-background:var(--forge-button-toggle-hover-background, var(--_button-toggle-background));--_button-toggle-active-background:var(--forge-button-toggle-active-background, var(--_button-toggle-background));--_button-toggle-cursor:var(--forge-button-toggle-cursor, pointer);--_button-toggle-border-width:var(--forge-button-toggle-border-width, medium);--_button-toggle-border-style:var(--forge-button-toggle-border-style, none);--_button-toggle-border-color:var(--forge-button-toggle-border-color, var(--forge-theme-outline-medium, #757575));--_button-toggle-shape:var(--forge-button-toggle-shape, var(--forge-shape-small, 2px));--_button-toggle-shape-start-start:var(--forge-button-toggle-shape-start-start, var(--_button-toggle-shape));--_button-toggle-shape-start-end:var(--forge-button-toggle-shape-start-end, var(--_button-toggle-shape));--_button-toggle-shape-end-start:var(--forge-button-toggle-shape-end-start, var(--_button-toggle-shape));--_button-toggle-shape-end-end:var(--forge-button-toggle-shape-end-end, var(--_button-toggle-shape));--_button-toggle-selected-background:var(--forge-button-toggle-selected-background, var(--forge-theme-tertiary-container, #d0d7ff));--_button-toggle-selected-color:var(--forge-button-toggle-selected-color, var(--forge-theme-on-tertiary-container, #213189));--_button-toggle-selected-disabled-background:var(--forge-button-toggle-selected-disabled-background, var(--forge-theme-surface-container, #e0e0e0));--_button-toggle-disabled-opacity:var(--forge-button-toggle-disabled-opacity, 0.38);--_button-toggle-disabled-cursor:var(--forge-button-toggle-disabled-cursor, not-allowed);--_button-toggle-disabled-color:var(--forge-button-toggle-disabled-color, var(--forge-theme-text-low, rgba(0, 0, 0, 0.38)));--_button-toggle-disabled-background:var(--forge-button-toggle-disabled-background, transparent);--_button-toggle-transition-duration:var(--forge-button-toggle-transition-duration, var(--forge-animation-duration-short3, 150ms));--_button-toggle-transition-timing:var(--forge-button-toggle-transition-timing, var(--forge-animation-easing-standard, cubic-bezier(0.2, 0, 0, 1)));--_button-toggle-focus-indicator-color:var(--forge-button-toggle-focus-indicator-color, var(--forge-theme-primary, #3f51b5));--_button-toggle-focus-indicator-offset:var(--forge-button-toggle-focus-indicator-offset, 0px)}.forge-button-toggle{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;font-family:var(--forge-typography-button-font-family, var(--forge-typography-font-family, \"Roboto\", sans-serif));font-size:var(--forge-typography-button-font-size, calc(var(--forge-typography-font-size, 1rem) * var(--forge-typography-button-font-size-scale, .875)));font-weight:var(--forge-typography-button-font-weight,500);line-height:var(--forge-typography-button-line-height, normal);letter-spacing:var(--forge-typography-button-letter-spacing, .0714285714em);text-transform:var(--forge-typography-button-text-transform,inherit);-webkit-text-decoration:var(--forge-typography-button-text-decoration,inherit);text-decoration:var(--forge-typography-button-text-decoration,inherit);position:relative;display:var(--_button-toggle-display);-webkit-box-align:center;align-items:center;-webkit-box-pack:center;justify-content:center;gap:var(--_button-toggle-spacing);z-index:0;-webkit-box-sizing:border-box;box-sizing:border-box;min-inline-size:var(--_button-toggle-min-width);inline-size:100%;border-width:var(--_button-toggle-border-width);border-style:var(--_button-toggle-border-style);border-color:var(--_button-toggle-border-color);border-start-start-radius:var(--_button-toggle-shape-start-start);border-start-end-radius:var(--_button-toggle-shape-start-end);border-end-start-radius:var(--_button-toggle-shape-end-start);border-end-end-radius:var(--_button-toggle-shape-end-end);padding-block:var(--_button-toggle-padding-block);padding-inline:var(--_button-toggle-padding-inline);outline:0;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-appearance:none;vertical-align:middle;text-decoration:none;white-space:nowrap;background:var(--_button-toggle-background);color:var(--_button-toggle-color);cursor:var(--_button-toggle-cursor);-webkit-transition-property:color,background-color,border-color;transition-property:color,background-color,border-color;-webkit-transition-duration:var(--_button-toggle-transition-duration);transition-duration:var(--_button-toggle-transition-duration);-webkit-transition-timing-function:var(--_button-toggle-transition-timing);transition-timing-function:var(--_button-toggle-transition-timing)}.forge-button-toggle forge-state-layer{--forge-state-layer-color:var(--_button-toggle-color)}.forge-button-toggle forge-focus-indicator{--forge-focus-indicator-outward-offset:var(--_button-toggle-focus-indicator-offset);--forge-focus-indicator-color:var(--_button-toggle-focus-indicator-color);--forge-focus-indicator-shape:var(--_button-toggle-shape);--forge-focus-indicator-shape-start-start:var(--_button-toggle-shape-start-start);--forge-focus-indicator-shape-start-end:var(--_button-toggle-shape-start-end);--forge-focus-indicator-shape-end-start:var(--_button-toggle-shape-end-start);--forge-focus-indicator-shape-end-end:var(--_button-toggle-shape-end-end)}::slotted(:is([slot=start],[slot=end])){font-size:var(--_button-toggle-icon-size)}:host([selected]) .forge-button-toggle{--_button-toggle-background:var(--_button-toggle-selected-background);--_button-toggle-color:var(--_button-toggle-selected-color);--_button-toggle-border-color:var(--_button-toggle-background)}:host([disabled]){--_button-toggle-cursor:var(--_button-toggle-disabled-cursor);cursor:not-allowed}:host([disabled]) .forge-button-toggle{--_button-toggle-background:var(--_button-toggle-disabled-background);--_button-toggle-color:var(--_button-toggle-disabled-color);opacity:var(--_button-toggle-disabled-opacity);pointer-events:none}:host([disabled][selected]) .forge-button-toggle{--_button-toggle-background:var(--_button-toggle-selected-disabled-background)}';
/**
 * @tag forge-button-toggle
 *
 * @property {unknown} value - The value of the button toggle.
 * @property {boolean} selected - Whether or not the button is selected.
 * @property {boolean} disabled - Whether or not the button is disabled.
 * @property {boolean} readonly - Whether or not the button is readonly.
 *
 * @attribute {unknown} value - The value of the button toggle.
 * @attribute {boolean} selected - Whether or not the button is selected.
 * @attribute {boolean} disabled - Whether or not the button is disabled.
 * @attribute {boolean} readonly - Whether or not the button is readonly.
 *
 * @event {CustomEvent<IButtonToggleSelectEventData>} forge-button-toggle-select - Dispatches when the user toggles the button.
 *
 * @cssproperty --forge-button-toggle-display - The `display` style for the button toggle container element.
 * @cssproperty --forge-button-toggle-min-width - The minimum width.
 * @cssproperty --forge-button-toggle-spacing - The spacing between the button toggle and its content.
 * @cssproperty --forge-button-toggle-padding-block - The padding on the block axis.
 * @cssproperty --forge-button-toggle-padding-inline - The padding on the inline axis.
 * @cssproperty --forge-button-toggle-icon-size - The font-size of start/end slotted content.
 * @cssproperty --forge-button-toggle-color - The color of the button toggle content.
 * @cssproperty --forge-button-toggle-background - The background of the button toggle.
 * @cssproperty --forge-button-toggle-hover-background - The background of the button toggle when hovered.
 * @cssproperty --forge-button-toggle-active-background - The background of the button toggle when active.
 * @cssproperty --forge-button-toggle-cursor - The cursor of the button toggle.
 * @cssproperty --forge-button-toggle-border-width - The border-width of the button toggle.
 * @cssproperty --forge-button-toggle-border-style - The border-style of the button toggle.
 * @cssproperty --forge-button-toggle-border-color - The border-color of the button toggle.
 * @cssproperty --forge-button-toggle-shape - The shape radius of the button toggle.
 * @cssproperty --forge-button-toggle-shape-start-start - The start-start shape radius of the button toggle.
 * @cssproperty --forge-button-toggle-shape-start-end - The start-end shape radius of the button toggle.
 * @cssproperty --forge-button-toggle-shape-end-start - The end-start shape radius of the button toggle.
 * @cssproperty --forge-button-toggle-shape-end-end - The end-end shape radius of the button toggle.
 * @cssproperty --forge-button-toggle-selected-background - The background of the button toggle when selected.
 * @cssproperty --forge-button-toggle-selected-color - The color of the button toggle content when selected.
 * @cssproperty --forge-button-toggle-selected-disabled-background - The background of the button toggle when selected and disabled.
 * @cssproperty --forge-button-toggle-dense-height - The height of the button toggle when dense.
 * @cssproperty --forge-button-toggle-disabled-opacity - The opacity of the button toggle when disabled.
 * @cssproperty --forge-button-toggle-disabled-cursor - The cursor of the button toggle when disabled.
 * @cssproperty --forge-button-toggle-disabled-color - The color of the button toggle content when disabled.
 * @cssproperty --forge-button-toggle-disabled-background - The background of the button toggle when disabled.
 * @cssproperty --forge-button-toggle-transition-duration - The transition-duration of various properties.
 * @cssproperty --forge-button-toggle-transition-timing - The transition-timing of various properties.
 * @cssproperty --forge-button-toggle-focus-indicator-color - The color of the focus indicator.
 *
 * @csspart root - The root container element.
 * @csspart focus-indicator - The focus indicator element.
 * @csspart state-layer - The state layer surface element.
 *
 * @slot - The default/unnamed slot for the button toggle's content.
 * @slot start - Typically reserved for content/icons that render logically before the default slot content.
 * @slot end - Typically reserved content/icons that render logically after the default slot content.
 */
let ButtonToggleComponent = class ButtonToggleComponent extends WithDefaultAria(WithElementInternals(WithFocusable(BaseComponent))) {
    static get observedAttributes() {
        return Object.values(BUTTON_TOGGLE_CONSTANTS.observedAttributes);
    }
    constructor() {
        super();
        attachShadowTemplate(this, template, styles);
        this._foundation = new ButtonToggleFoundation(new ButtonToggleAdapter(this));
    }
    connectedCallback() {
        this._foundation.initialize();
    }
    disconnectedCallback() {
        this._foundation.destroy();
    }
    attributeChangedCallback(name, oldValue, newValue) {
        switch (name) {
            case BUTTON_TOGGLE_CONSTANTS.attributes.VALUE:
                this.value = newValue;
                return;
            case BUTTON_TOGGLE_CONSTANTS.attributes.SELECTED:
                this.selected = coerceBoolean(newValue);
                return;
            case BUTTON_TOGGLE_CONSTANTS.attributes.DISABLED:
                this.disabled = coerceBoolean(newValue);
                return;
            case BUTTON_TOGGLE_CONSTANTS.attributes.READONLY:
                this.readonly = coerceBoolean(newValue);
                return;
        }
        super.attributeChangedCallback(name, oldValue, newValue);
    }
    focus(options) {
        this._foundation.focus(options);
    }
    click() {
        this._foundation.click();
    }
};
__decorate([
    FoundationProperty()
], ButtonToggleComponent.prototype, "value", void 0);
__decorate([
    FoundationProperty()
], ButtonToggleComponent.prototype, "selected", void 0);
__decorate([
    FoundationProperty()
], ButtonToggleComponent.prototype, "disabled", void 0);
__decorate([
    FoundationProperty()
], ButtonToggleComponent.prototype, "readonly", void 0);
ButtonToggleComponent = __decorate([
    CustomElement({
        name: BUTTON_TOGGLE_CONSTANTS.elementName,
        dependencies: [
            FocusIndicatorComponent,
            StateLayerComponent
        ]
    })
], ButtonToggleComponent);
export { ButtonToggleComponent };
