/**
 * @license
 * Copyright 2023 Tyler Technologies, Inc. 
 * License: Apache-2.0
 */
import { CHIP_CONSTANTS } from '../chip/chip-constants';
import { CHIP_SET_CONSTANTS } from './chip-set-constants';
export class ChipSetFoundation {
    constructor(_adapter) {
        this._adapter = _adapter;
        this._vertical = false;
        this._type = CHIP_CONSTANTS.defaults.TYPE;
        this._dense = false;
        this._disabled = false;
        this._focusPreviousListener = (evt) => this._adapter.tryFocusPrevious(evt.target);
        this._focusNextListener = (evt) => this._adapter.tryFocusNext(evt.target);
    }
    initialize() {
        this._adapter.addHostListener(CHIP_CONSTANTS.events.FOCUS_PREVIOUS, this._focusPreviousListener);
        this._adapter.addHostListener(CHIP_CONSTANTS.events.FOCUS_NEXT, this._focusNextListener);
        this._applyVertical();
        this._applyType();
        this._applyDense();
        this._applyDisabled();
    }
    destroy() {
        this._adapter.removeHostListener(CHIP_CONSTANTS.events.FOCUS_PREVIOUS, this._focusPreviousListener);
        this._adapter.removeHostListener(CHIP_CONSTANTS.events.FOCUS_NEXT, this._focusNextListener);
    }
    _applyVertical() {
        this._adapter.setVertical(this._vertical);
        this._adapter.toggleHostAttribute(CHIP_SET_CONSTANTS.attributes.VERTICAL, this._vertical);
    }
    _applyType() {
        this._adapter.setType(this._type);
        this._adapter.setHostAttribute(CHIP_SET_CONSTANTS.attributes.TYPE, this._type);
    }
    _applyDense() {
        this._adapter.setDense(this._dense);
        this._adapter.toggleHostAttribute(CHIP_SET_CONSTANTS.attributes.DENSE, this._dense);
    }
    _applyDisabled() {
        this._adapter.setDisabled(this._disabled);
        this._adapter.toggleHostAttribute(CHIP_SET_CONSTANTS.attributes.DISABLED, this._disabled);
    }
    get vertical() {
        return this._vertical;
    }
    set vertical(value) {
        if (this._vertical !== value) {
            this._vertical = value;
            this._applyVertical();
        }
    }
    get type() {
        return this._type;
    }
    set type(value) {
        if (this._type !== value) {
            this._type = value;
            this._applyType();
        }
    }
    get dense() {
        return this._dense;
    }
    set dense(value) {
        if (this._dense !== value) {
            this._dense = value;
            this._applyDense();
        }
    }
    get disabled() {
        return this._disabled;
    }
    set disabled(value) {
        if (this._disabled !== value) {
            this._disabled = value;
            this._applyDisabled();
        }
    }
}
