/**
 * @license
 * Copyright 2023 Tyler Technologies, Inc. 
 * License: Apache-2.0
 */
import { __decorate } from "tslib";
import { CustomElement, attachShadowTemplate, FoundationProperty, coerceBoolean } from '@tylertech/forge-core';
import { IconAdapter } from './icon-adapter';
import { IconFoundation } from './icon-foundation';
import { ICON_CONSTANTS } from './icon-constants';
import { BaseComponent } from '../core/base/base-component';
const template = '<template></template>';
const styles = ':host{font-size:24px;font-size:var(--forge-icon-font-size, 24px);display:inline-block;contain:content;-webkit-box-sizing:content-box!important;box-sizing:content-box!important}:host>svg{fill:currentColor;fill:var(--forge-icon-theme-color,currentColor);stroke:currentColor;stroke:var(--forge-icon-theme-color,currentColor);display:block;width:1em;height:1em;stroke-width:0}:host([hidden]){display:none}:host([theme=primary]){color:var(\"primary\")}:host([theme=secondary]){color:var(\"secondary\")}:host([theme=warning]){color:#d14900;color:var(\"warning\", #d14900)}:host([theme=danger]){color:#b00020;color:var(\"danger\", #b00020)}:host([theme=success]){color:#2e7d32;color:var(\"success\", #2e7d32)}:host([theme=info]){color:#424242;color:var(\"info\", #424242)}:host([theme=tertiary]){color:#3d5afe;color:var(\"tertiary\", #3d5afe)}';
/**
 * The web component class behind the `<forge-icon>` custom element.
 *
 * @tag forge-icon
 */
let IconComponent = class IconComponent extends BaseComponent {
    constructor() {
        super();
        attachShadowTemplate(this, template, styles);
        this._foundation = new IconFoundation(new IconAdapter(this));
    }
    static get observedAttributes() {
        return [
            ICON_CONSTANTS.attributes.NAME,
            ICON_CONSTANTS.attributes.SRC,
            ICON_CONSTANTS.attributes.LAZY,
            ICON_CONSTANTS.attributes.EXTERNAL,
            ICON_CONSTANTS.attributes.EXTERNAL_TYPE,
            ICON_CONSTANTS.attributes.VIEWBOX
        ];
    }
    connectedCallback() {
        this._foundation.initialize();
    }
    disconnectedCallback() {
        this._foundation.disconnect();
    }
    attributeChangedCallback(name, oldValue, newValue) {
        switch (name) {
            case ICON_CONSTANTS.attributes.NAME:
                this.name = newValue;
                break;
            case ICON_CONSTANTS.attributes.SRC:
                this.src = newValue;
                break;
            case ICON_CONSTANTS.attributes.LAZY:
                this.lazy = coerceBoolean(newValue);
                break;
            case ICON_CONSTANTS.attributes.EXTERNAL:
                this.external = coerceBoolean(newValue);
                break;
            case ICON_CONSTANTS.attributes.EXTERNAL_TYPE:
                this.externalType = newValue;
                break;
            case ICON_CONSTANTS.attributes.VIEWBOX:
                this.viewbox = newValue;
                break;
        }
    }
    /** Forces a reload of the icon. */
    layout() {
        this._foundation.layout();
    }
};
__decorate([
    FoundationProperty()
], IconComponent.prototype, "name", void 0);
__decorate([
    FoundationProperty()
], IconComponent.prototype, "src", void 0);
__decorate([
    FoundationProperty()
], IconComponent.prototype, "lazy", void 0);
__decorate([
    FoundationProperty()
], IconComponent.prototype, "external", void 0);
__decorate([
    FoundationProperty()
], IconComponent.prototype, "externalType", void 0);
__decorate([
    FoundationProperty()
], IconComponent.prototype, "externalUrlBuilder", void 0);
__decorate([
    FoundationProperty()
], IconComponent.prototype, "viewbox", void 0);
IconComponent = __decorate([
    CustomElement({
        name: ICON_CONSTANTS.elementName
    })
], IconComponent);
export { IconComponent };
