/**
 * @license
 * Copyright 2023 Tyler Technologies, Inc. 
 * License: Apache-2.0
 */
import { __decorate } from "tslib";
import { CustomElement, attachShadowTemplate, ensureChildren, coerceBoolean, FoundationProperty } from '@tylertech/forge-core';
import { tylIconArrowDropDown, tylIconLanguage, tylIconSearch } from '@tylertech/tyler-icons/standard';
import { AppBarSearchFoundation } from './app-bar-search-foundation';
import { AppBarSearchAdapter } from './app-bar-search-adapter';
import { APP_BAR_SEARCH_CONSTANTS } from './app-bar-search-constants';
import { TooltipComponent } from '../../tooltip';
import { IconComponent, IconRegistry } from '../../icon';
import { BaseComponent } from '../../core/base/base-component';
const template = '<template><div class=\"forge-app-bar-search\" part=\"root\"><div class=\"forge-app-bar-search__container\" part=\"container\"><div class=\"forge-app-bar-search__search-icon-container\" part=\"icon-container\"><forge-icon name=\"search\" class=\"forge-app-bar-search__icon\" part=\"icon\"></forge-icon></div><slot></slot><div class=\"forge-app-bar-search__context\" part=\"context\"><div class=\"forge-app-bar-search__vertical-divider\" part=\"context-divider\"></div><button type=\"button\" class=\"forge-app-bar-search__context-button\" part=\"context-button\"><span class=\"forge-app-bar-search__context-button-text\" part=\"context-button-text\">in this application</span><forge-icon name=\"arrow_drop_down\" class=\"forge-app-bar-search__context-button-icon\" part=\"context-button-icon\"></forge-icon></button></div><div class=\"forge-app-bar-search__global-icon-container\" part=\"global-icon-container\"><forge-icon slot=\"trailing\" name=\"language\" id=\"app-bar-global-context\" part=\"global-icon\"></forge-icon><forge-tooltip delay=\"500\" position=\"bottom\" target=\"#app-bar-global-context\">Global search</forge-tooltip></div></div><div class=\"forge-app-bar-search__actions\" part=\"actions-container\"><slot name=\"action\"></slot></div></div></template>';
const styles = '::slotted([slot=action]){margin-left:8px}.forge-app-bar-search{display:-webkit-box;display:flex;height:2.25rem}.forge-app-bar-search__container{background-color:rgba(255,255,255,.08);background-color:var(--forge-app-bar-search-theme-background,rgba(255,255,255,.08));width:100%;-webkit-box-flex:1;flex:1 1 auto;margin:0;display:-webkit-box;display:flex;-webkit-box-align:center;align-items:center;-webkit-box-sizing:border-box;box-sizing:border-box;position:relative}.forge-app-bar-search__container::before{border-color:#fff;border-color:var(--mdc-theme-on-primary,#fff);content:\"\";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:2px;border-width:1px;border-style:solid;z-index:-1;opacity:.54;-webkit-transition-property:border-color,opacity;transition-property:border-color,opacity;-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.55,0,0.55,0.2);transition-timing-function:cubic-bezier(0.55,0,0.55,0.2);will-change:border-color,border-width,opacity,top,left,bottom,right}.forge-app-bar-search__container:hover::before{opacity:.87;opacity:var(--forge-app-bar-search-theme-hover-opacity, .87)}.forge-app-bar-search__container ::slotted(input){color:#fff;color:var(--mdc-theme-on-primary,#fff);display:block;overflow:hidden;background:0 0;border:none;font-size:1rem;-webkit-box-flex:1;flex:1 1 auto;margin:0;margin-left:-8px;outline:0;pointer-events:auto;-webkit-transition-property:color;transition-property:color;-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-timing-function:cubic-bezier(0.55,0,0.55,0.2);transition-timing-function:cubic-bezier(0.55,0,0.55,0.2)}.forge-app-bar-search__container ::slotted(input)::-webkit-input-placeholder{color:rgba(0,0,0,.54);color:var(--mdc-theme-text-secondary-on-background,rgba(0,0,0,.54));font-size:1rem;opacity:1}.forge-app-bar-search__container ::slotted(input)::-moz-placeholder{color:rgba(0,0,0,.54);color:var(--mdc-theme-text-secondary-on-background,rgba(0,0,0,.54));font-size:1rem;opacity:1}.forge-app-bar-search__container ::slotted(input):-ms-input-placeholder{color:rgba(0,0,0,.54);color:var(--mdc-theme-text-secondary-on-background,rgba(0,0,0,.54));font-size:1rem;opacity:1}.forge-app-bar-search__container ::slotted(input)::-ms-input-placeholder{color:rgba(0,0,0,.54);color:var(--mdc-theme-text-secondary-on-background,rgba(0,0,0,.54));font-size:1rem;opacity:1}.forge-app-bar-search__container ::slotted(input)::placeholder{color:rgba(0,0,0,.54);color:var(--mdc-theme-text-secondary-on-background,rgba(0,0,0,.54));font-size:1rem;opacity:1}.forge-app-bar-search__global-icon-container{display:-webkit-box;display:flex;-webkit-box-pack:center;justify-content:center;-webkit-box-align:center;align-items:center;margin:0 16px}.forge-app-bar-search__search-icon-container{width:56px;height:36px;display:-webkit-box;display:flex;-webkit-box-align:center;align-items:center;-webkit-box-pack:center;justify-content:center;-webkit-box-flex:0;flex:none}.forge-app-bar-search__icon{color:#fff;color:var(--mdc-theme-on-primary,#fff)}.forge-app-bar-search__actions{display:-webkit-box;display:flex;-webkit-box-pack:center;justify-content:center;-webkit-box-align:center;align-items:center}.forge-app-bar-search__context{height:100%;display:-webkit-box;display:flex;-webkit-box-align:center;align-items:center;margin-left:8px}.forge-app-bar-search__context-button{color:#000;color:var(--mdc-theme-on-surface,#000);outline:0;border:none;background:0 0;min-width:100px;display:-webkit-box;display:flex;-webkit-box-align:center;align-items:center;height:70%;margin-left:8px;margin-right:4px;border-radius:4px;background-color:transparent;-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out;will-change:background-color;padding:0;padding-left:8px}.forge-app-bar-search__context-button:hover{background-color:rgba(255,255,255,.12)}.forge-app-bar-search__context-button:focus{background-color:rgba(255,255,255,.2)}.forge-app-bar-search__context-button-text{-webkit-box-flex:1;flex:1;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.forge-app-bar-search__vertical-divider{border-left-color:#fff;border-left-color:var(--mdc-theme-on-primary,#fff);display:inline-block;position:absolute;top:8px;bottom:8px;border-left-width:1px;border-left-style:solid}.forge-app-bar-search--focused .forge-app-bar-search__container{background-color:rgba(255,255,255,.12);background-color:var(--forge-app-bar-search-theme-background-focused,rgba(255,255,255,.12))}.forge-app-bar-search--focused .forge-app-bar-search__container::before{opacity:.87;border-width:2px;top:-1px;right:-1px;bottom:-1px;left:-1px}.forge-app-bar-search--disabled{opacity:.26;opacity:var(--forge-app-bar-search-theme-disabled-opacity, .26);cursor:not-allowed}.forge-app-bar-search--disabled .forge-app-bar-search__container:hover::before{opacity:54%}.forge-app-bar-search--disabled ::slotted(input){cursor:not-allowed}:host{display:block;width:100%;contain:layout style}:host([hidden]){display:none}';
/**
 * The web component class behind the `<forge-app-bar-search>` custom element.
 *
 * @tag forge-app-bar-search
 *
 * @slot - The default (unnamed) slot is where child `<input>` elements will be placed.
 * @slot action - Places actions at the end of the input.
 *
 * @csspart root - The root element
 * @csspart container - The input container element.
 * @csspart icon-container - The icon container element.
 * @csspart icon - The <forge-icon> element.
 * @csspart context - The context container element.
 * @csspart context-divider - The context divider element.
 * @csspart context-button - The context button element.
 * @csspart context-button-text - The context button text element.
 * @csspart context-button-icon - The context button icon element.
 * @csspart global-icon-container - The global icon container element.
 * @csspart global-icon - The global icon <forge-icon> element.
 * @csspart actions-container - The action container element around the slot.
 *
 * @cssproperty --mdc-theme-on-primary - Controls the border-color of the container outline, the font-color, and icon color.
 * @cssproperty --mdc-theme-on-surface - Controls the font color of the buttons.
 * @cssproperty --mdc-theme-text-secondary-on-background - Controls the placeholder font color.
 * @cssproperty --forge-app-bar-search-theme-background - Controls the background-color of the container.
 * @cssproperty --forge-app-bar-search-theme-background-focused - Controls the focused background-color of the container.
 * @cssproperty --forge-app-bar-search-theme-hover-opacity - Controls the hover opacity of the outline.
 * @cssproperty --forge-app-bar-search-theme-disabled-opacity - Controls the disabled opacity of the component.
 */
let AppBarSearchComponent = class AppBarSearchComponent extends BaseComponent {
    constructor() {
        super();
        IconRegistry.define([tylIconSearch, tylIconArrowDropDown, tylIconLanguage]);
        attachShadowTemplate(this, template, styles);
        this._foundation = new AppBarSearchFoundation(new AppBarSearchAdapter(this));
    }
    static get observedAttributes() {
        return [
            APP_BAR_SEARCH_CONSTANTS.attributes.DISABLED,
            APP_BAR_SEARCH_CONSTANTS.attributes.VALUE,
            APP_BAR_SEARCH_CONSTANTS.attributes.PLACEHOLDER,
            APP_BAR_SEARCH_CONSTANTS.attributes.COMBINED,
            APP_BAR_SEARCH_CONSTANTS.attributes.GLOBAL
        ];
    }
    connectedCallback() {
        if (this.children.length) {
            this._initialize();
        }
        else {
            ensureChildren(this).then(() => this._initialize());
        }
    }
    _initialize() {
        this._foundation.initialize();
    }
    disconnectedCallback() {
        this._foundation.disconnect();
    }
    attributeChangedCallback(name, oldValue, newValue) {
        switch (name) {
            case APP_BAR_SEARCH_CONSTANTS.attributes.DISABLED:
                this.disabled = coerceBoolean(newValue);
                break;
            case APP_BAR_SEARCH_CONSTANTS.attributes.VALUE:
                this.value = newValue;
                break;
            case APP_BAR_SEARCH_CONSTANTS.attributes.PLACEHOLDER:
                this.placeholder = newValue;
                break;
            case APP_BAR_SEARCH_CONSTANTS.attributes.COMBINED:
                this.combined = coerceBoolean(newValue);
                break;
            case APP_BAR_SEARCH_CONSTANTS.attributes.GLOBAL:
                this.global = coerceBoolean(newValue);
                break;
        }
    }
    /** Sets the input placeholder value. */
    set placeholder(value) {
        this._foundation.placeholder = value;
    }
};
__decorate([
    FoundationProperty()
], AppBarSearchComponent.prototype, "value", void 0);
__decorate([
    FoundationProperty()
], AppBarSearchComponent.prototype, "disabled", void 0);
__decorate([
    FoundationProperty()
], AppBarSearchComponent.prototype, "combined", void 0);
__decorate([
    FoundationProperty()
], AppBarSearchComponent.prototype, "combinedOptions", void 0);
__decorate([
    FoundationProperty()
], AppBarSearchComponent.prototype, "selectedCombinedOption", void 0);
__decorate([
    FoundationProperty()
], AppBarSearchComponent.prototype, "global", void 0);
AppBarSearchComponent = __decorate([
    CustomElement({
        name: APP_BAR_SEARCH_CONSTANTS.elementName,
        dependencies: [
            TooltipComponent,
            IconComponent
        ]
    })
], AppBarSearchComponent);
export { AppBarSearchComponent };
