'use strict';

var index = require('./index-CJK1u2Q5.js');
var tslib_es6 = require('./tslib.es6-DrfCPgT9.js');
var device = require('./device-D8GN5vuz.js');
var focusVisible = require('./focus-visible-DFZa8IIA.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) {
        index.registerInstance(this, hostRef);
        this.debouncedNotify = index.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 (index.balBrowser.hasDocument && index.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) {
            index.updateBalAnimated(this.animated);
        }
        if (index.balBrowser.hasWindow) {
            window.addEventListener('resize', this.debouncedNotify);
            this.debouncedNotify();
        }
    }
    componentDidLoad() {
        index.rIC(() => {
            this.ready = true;
            focusVisible.startFocusVisible();
        });
        index.rOnLoad(() => {
            if (index.balBrowser.hasDocument && index.balBrowser.hasWindow) {
                const doc = document.documentElement;
                doc.classList.add('lcp-ready');
            }
        });
    }
    disconnectedCallback() {
        if (index.balBrowser.hasWindow) {
            window.removeEventListener('resize', this.debouncedNotify);
        }
    }
    async setFocus(elements) {
        if (this.focusVisible) {
            this.focusVisible.setFocus(elements);
        }
    }
    render() {
        return (index.h(index.Host, { key: '8aa3c989125e06e500597db9773fca378e4b7467', class: {
                'bal-app': true,
                'bal-app--safari': index.balBrowser.isSafari,
                'bal-app--touch': device.balDevice.hasTouchScreen,
            } }, index.h("slot", { key: 'c0e432a988e29f653198ed4eeead7f18fa447035' })));
    }
    get el() { return index.getElement(this); }
};
tslib_es6.__decorate([
    index.Logger('bal-app'),
    tslib_es6.__metadata("design:type", Function),
    tslib_es6.__metadata("design:paramtypes", [Function]),
    tslib_es6.__metadata("design:returntype", void 0)
], App.prototype, "createLogger", null);
App.style = balAppCss;

exports.bal_app = App;
