/**
 * @license
 * Copyright Tyler Technologies, Inc. 
 * License: Apache-2.0
 */
import { getLightElement, toggleAttribute } from '@tylertech/forge-core';
import { BADGE_CONSTANTS } from '../../badge';
import { BaseAdapter } from '../../core/base/base-adapter';
import { ICON_CONSTANTS } from '../../icon';
import { APP_BAR_NOTIFICATION_BUTTON_CONSTANTS } from './app-bar-notification-button-constants';
import { forwardAttributes } from '../../core/utils/reflect-utils';
import { ICON_BUTTON_CONSTANTS } from '../../icon-button/icon-button-constants';
export class AppBarNotificationButtonAdapter extends BaseAdapter {
    constructor(component) {
        super(component);
    }
    setIcon(icon) {
        this._iconElement.name = icon;
    }
    initialize() {
        this._iconButtonElement = getLightElement(this._component, ICON_BUTTON_CONSTANTS.elementName);
        this._badgeElement = getLightElement(this._component, BADGE_CONSTANTS.elementName);
        this._iconElement = getLightElement(this._component, ICON_CONSTANTS.elementName);
        const originalAriaLabelledby = this._iconButtonElement.getAttribute('aria-labelledby');
        this._forwardObserver = forwardAttributes(this._component, APP_BAR_NOTIFICATION_BUTTON_CONSTANTS.forwardedAttributes, (name, value) => {
            if (name === 'aria-labelledby' && !value) {
                value = originalAriaLabelledby;
            }
            toggleAttribute(this._iconButtonElement, !!value, name, value !== null && value !== void 0 ? value : undefined);
        });
    }
    destroy() {
        var _a;
        (_a = this._forwardObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
        this._forwardObserver = undefined;
    }
    setCount(value) {
        this._badgeElement.textContent = value != null ? String(value) : '';
    }
    setBadgeType(dot) {
        this._badgeElement.dot = dot;
    }
    setBadgeTheme(theme) {
        toggleAttribute(this._badgeElement, !!theme, BADGE_CONSTANTS.attributes.THEME, theme);
    }
    setBadgeVisible(isVisible) {
        this._badgeElement.hide = !isVisible;
    }
}
