import '@operato/i18n/ox-i18n.js';
import '@things-factory/notification';
import '@things-factory/auth-ui/dist-client'; /* for domain-switch */
import '@operato/context/ox-title-bar.js';
import { html } from 'lit-html';
import { store, navigate } from '@operato/shell';
import { appendViewpart, updateViewpart, TOOL_POSITION, VIEWPART_LEVEL, VIEWPART_POSITION } from '@operato/layout';
import { APPEND_APP_TOOL } from '@things-factory/apptool-base/client';
import { setupAppToolPart } from '@things-factory/apptool-ui/dist-client';
import { setupContextUIPart } from '@things-factory/context-ui/dist-client';
import { auth } from '@things-factory/auth-base/dist-client';
import { isMobileDevice } from '@operato/utils';
import './menu-tools';
import './features/full-screen-toggle';
console.log(`%c
  ▄▄▄▄▄▄    ▄▄▄▄     ▄▄▄▄    ▄▄   ▄▄   ▄▄▄▄▄
  ▓▓       ▓▓  ▓▓   ▓▓  ▓▓   ▓▓▓ ▓▓▓   ▓▓
  ▓▓       ▓▓       ▓▓  ▓▓   ▓▓▓▓▓▓▓   ▓▓
  ▄▄▄▄      ▄▄▄▄    ▓▓  ▓▓   ▓▓ ▄ ▓▓   ▄▄▄▄
  ▓▓           ▓▓   ▓▓  ▓▓   ▓▓   ▓▓   ▓▓
  ▓▓       ▓▓  ▓▓   ▓▓  ▓▓   ▓▓   ▓▓   ▓▓
  ▄▄▄▄▄     ▄▄▄▄     ▄▄▄▄    ▄▄   ▄▄   ▄▄▄▄▄`, 'background: #222; color: #bada55');
export default async function bootstrap() {
    await setupAppToolPart({
        toolbar: true,
        busybar: true,
        mdibar: true
    });
    await setupContextUIPart({
        titlebar: 'header',
        contextToolbar: 'page-footer'
    });
    auth.on('profile', async ({ credential }) => {
        /* append top-menu to layout */
        var state = store.getState();
        var width = state.layout?.width || 'WIDE';
        appendViewpart({
            name: 'ppms-bottom-menu',
            viewpart: {
                show: true,
                template: html ` <menu-tools></menu-tools> `
            },
            position: width == 'WIDE' ? VIEWPART_POSITION.NAVBAR : VIEWPART_POSITION.FOOTERBAR
        });
        store.subscribe(async () => {
            var state = store.getState();
            if (state.layout.width == width) {
                return;
            }
            width = state.layout.width;
            updateViewpart('ppms-bottom-menu', {
                position: width == 'WIDE' ? VIEWPART_POSITION.NAVBAR : VIEWPART_POSITION.FOOTERBAR,
                level: VIEWPART_LEVEL.TOPMOST
            });
        });
        store.dispatch({
            /* incase of mobile : add empty tool to clear home icon on header bar */
            type: APPEND_APP_TOOL,
            tool: {
                name: 'empty',
                template: html ` <div></div> `,
                position: TOOL_POSITION.FRONT_END
            }
        });
        store.dispatch({
            type: APPEND_APP_TOOL,
            tool: {
                name: 'app-brand',
                template: html `
          <img
            src="/assets/images/hatiolab-logo.png"
            alt="logo"
            @click=${() => {
                    navigate('dashboard');
                }}
            style="height: ${isMobileDevice() ? '27px' : '35px'}; cursor: pointer; margin-left: 10px;"
          />
        `,
                position: TOOL_POSITION.FRONT
            }
        });
        store.dispatch({
            type: APPEND_APP_TOOL,
            tool: {
                name: 'fullscreen',
                template: html `<full-screen-toggle></full-screen-toggle>`,
                position: TOOL_POSITION.REAR
            }
        });
        store.dispatch({
            type: APPEND_APP_TOOL,
            tool: {
                name: 'exit_to_app',
                template: html `<md-icon @click=${() => (window.location.href = '/auth/checkin')}>exit_to_app</md-icon>`,
                position: TOOL_POSITION.REAR
            }
        });
        store.dispatch({
            type: APPEND_APP_TOOL,
            tool: {
                name: 'title-bar',
                template: html ` <ox-title-bar style="color: #fff;font-size:24px"></ox-title-bar> `,
                position: TOOL_POSITION.CENTER
            }
        });
    });
}
//# sourceMappingURL=bootstrap.js.map