import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-BdVwMG9u.js';
import { _ as __decorate, a as __metadata } from './tslib.es6-dfXERft2.js';
import { b as balBrowser } from './browser-B1u-Mq75.js';
import { b as balDevice } from './device-TtMibDFL.js';
import { s as startFocusVisible } from './focus-visible-DqCbGYzv.js';
import { k as debounce, r as rIC, l as rOnLoad } from './helpers-BNj87EbG.js';
import { L as Logger } from './log-CwssmmaV.js';
import { b as updateBalAnimated } from './config.utils-B7jugjyM.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.balAppReady = createEvent(this, "balAppReady");
        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');
                this.balAppReady.emit();
            }
        });
    }
    disconnectedCallback() {
        if (balBrowser.hasWindow) {
            window.removeEventListener('resize', this.debouncedNotify);
        }
    }
    async setFocus(elements) {
        if (this.focusVisible) {
            this.focusVisible.setFocus(elements);
        }
    }
    render() {
        return (h(Host, { key: 'e6229236201fea92c4ccb1812f2f280a06130889', class: {
                'bal-app': true,
                'bal-app--safari': balBrowser.isSafari,
                'bal-app--touch': balDevice.hasTouchScreen,
            } }, h("slot", { key: '7712c7609c709dbe754eaf5700fd43ca3992a39f' })));
    }
    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 };
