import { L as Logger, H as registerInstance, I as debounce, a as balBrowser, j as updateBalAnimated, J as rIC, K as rOnLoad, M as h, N as Host, O as getElement } from './index-DGWPFpP6.js';
import { _ as __decorate, a as __metadata } from './tslib.es6-dfXERft2.js';
import { b as balDevice } from './device-CiuS70Dm.js';
import { s as startFocusVisible } from './focus-visible-DqCbGYzv.js';

const balAppCss = ":root{--bal-app-height:100%}.bal-app{position:relative}.lcp-wait{opacity:0;visibility:hidden;display:none}.lcp-ready .lcp-wait{opacity:inherit;visibility:inherit;display:inherit}";

const App = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.debouncedNotify = debounce(() => this.notifyResize(), 100);
        /**
         * Disables all animation inside the bal-app. Can be used for simplify e2e testing.
         */
        this.animated = true;
        /**
         * @internal Is `true` when DS components are ready to be shown.
         */
        this.ready = false;
        this.notifyResize = async () => {
            if (balBrowser.hasDocument && balBrowser.hasWindow) {
                const doc = document.documentElement;
                doc.style.setProperty('--bal-app-height', `${window.innerHeight}px`);
            }
        };
    }
    createLogger(log) {
        this.log = log;
    }
    connectedCallback() {
        if (this.animated === false) {
            updateBalAnimated(this.animated);
        }
        if (balBrowser.hasWindow) {
            window.addEventListener('resize', this.debouncedNotify);
            this.debouncedNotify();
        }
    }
    componentDidLoad() {
        rIC(() => {
            this.ready = true;
            startFocusVisible();
        });
        rOnLoad(() => {
            if (balBrowser.hasDocument && balBrowser.hasWindow) {
                const doc = document.documentElement;
                doc.classList.add('lcp-ready');
            }
        });
    }
    disconnectedCallback() {
        if (balBrowser.hasWindow) {
            window.removeEventListener('resize', this.debouncedNotify);
        }
    }
    async setFocus(elements) {
        if (this.focusVisible) {
            this.focusVisible.setFocus(elements);
        }
    }
    render() {
        return (h(Host, { key: '8aa3c989125e06e500597db9773fca378e4b7467', class: {
                'bal-app': true,
                'bal-app--safari': balBrowser.isSafari,
                'bal-app--touch': balDevice.hasTouchScreen,
            } }, h("slot", { key: 'c0e432a988e29f653198ed4eeead7f18fa447035' })));
    }
    get el() { return getElement(this); }
};
__decorate([
    Logger('bal-app'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Function]),
    __metadata("design:returntype", void 0)
], App.prototype, "createLogger", null);
App.style = balAppCss;

export { App as bal_app };
