/**
 * @license
 * Copyright 2023 Tyler Technologies, Inc. 
 * License: Apache-2.0
 */
import { APP_BAR_CONSTANTS } from './app-bar-constants';
/**
 * Provides facilities and helper methods for creating an app-bar component.
 */
export class AppBarFoundation {
    constructor(_adapter) {
        this._adapter = _adapter;
        this._fixed = false;
        this._raised = true;
        this._bottomSlotListener = evt => this._onBottomSlotChanged(evt);
        this._centerSlotListener = evt => this._onCenterSlotChanged(evt);
    }
    initialize() {
        this._adapter.setTitleText(this._titleText);
        this._adapter.addBottomSlotListener(this._bottomSlotListener);
        this._adapter.addCenterSlotListener(this._centerSlotListener);
        this._adapter.setCenterSlotVisibility();
        this._adapter.setRaised(this._raised);
        this._adapter.setFixed(this._fixed);
    }
    _onBottomSlotChanged(evt) {
        const slotElement = evt.target;
        if (slotElement.assignedNodes().length) {
            this._adapter.addBottomClass(APP_BAR_CONSTANTS.classes.ROW);
        }
        else {
            this._adapter.removeBottomClass(APP_BAR_CONSTANTS.classes.ROW);
        }
    }
    _onCenterSlotChanged(evt) {
        this._adapter.setCenterSlotVisibility();
    }
    /** Gets/sets the title text. */
    get titleText() {
        return this._titleText;
    }
    set titleText(value) {
        if (this._titleText !== value) {
            this._titleText = value;
            this._adapter.setTitleText(this._titleText);
            this._adapter.setHostAttribute(APP_BAR_CONSTANTS.attributes.TITLE_TEXT, value);
        }
    }
    /** Gets/sets the fixed state. */
    get fixed() {
        return this._fixed;
    }
    set fixed(value) {
        if (this._fixed !== value) {
            this._fixed = value;
            this._adapter.setFixed(this._fixed);
            this._adapter.setHostAttribute(APP_BAR_CONSTANTS.attributes.FIXED, this._fixed.toString());
        }
    }
    get raised() {
        return this._raised;
    }
    set raised(value) {
        if (this._raised !== value) {
            this._raised = value;
            this._adapter.setRaised(value);
            this._adapter.setHostAttribute(APP_BAR_CONSTANTS.attributes.RAISED, this._raised.toString());
        }
    }
}
