"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.renderApp = void 0; var _react = _interopRequireDefault(require("react")); var _reactDom = require("react-dom"); var _public = require("@kbn/kibana-react-plugin/public"); var _homeSampleDataTab = require("@kbn/home-sample-data-tab"); var _home_app = require("./components/home_app"); var _kibana_services = require("./kibana_services"); require("./index.scss"); /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ // @ts-ignore const renderApp = async (element, theme$, coreStart, history) => { const { featureCatalogue, chrome, dataViewsService: dataViews, trackUiMetric } = (0, _kibana_services.getServices)(); // all the directories could be get in "start" phase of plugin after all of the legacy plugins will be moved to a NP const directories = featureCatalogue.get(); // Filters solutions by available nav links const navLinksSubscription = chrome.navLinks.getNavLinks$().subscribe(navLinks => { const solutions = featureCatalogue.getSolutions().filter(({ id }) => navLinks.find(({ category, hidden }) => !hidden && (category === null || category === void 0 ? void 0 : category.id) === id)); (0, _reactDom.render)( /*#__PURE__*/_react.default.createElement(_public.RedirectAppLinks, { application: coreStart.application }, /*#__PURE__*/_react.default.createElement(_public.KibanaThemeProvider, { theme$: theme$ }, /*#__PURE__*/_react.default.createElement(_public.KibanaContextProvider, { services: { ...coreStart } }, /*#__PURE__*/_react.default.createElement(_homeSampleDataTab.SampleDataTabKibanaProvider, { coreStart, dataViews, trackUiMetric }, /*#__PURE__*/_react.default.createElement(_home_app.HomeApp, { directories: directories, solutions: solutions }))))), element); }); // dispatch synthetic hash change event to update hash history objects // this is necessary because hash updates triggered by using popState won't trigger this event naturally. // This must be called before the app is mounted to avoid call this after the redirect to default app logic kicks in const unlisten = history.listen(location => { window.dispatchEvent(new HashChangeEvent('hashchange')); }); return () => { (0, _reactDom.unmountComponentAtNode)(element); unlisten(); navLinksSubscription.unsubscribe(); }; }; exports.renderApp = renderApp;