text: /* eslint-disable no-console */
  import { ApolloClient, ApolloProvider, createHttpLink } from '@apollo/client';
  import { NotificationsPortal, notifications } from '@redhat-cloud-services/frontend-components-notifications/';
  import React, { useEffect, useMemo, useRef } from 'react';
  
  import App from './App';
  import { IntlProvider } from '@redhat-cloud-services/frontend-components-translations';
  import PropTypes from 'prop-types';
  import { Provider } from 'react-redux';
  import { BrowserRouter as Router } from 'react-router-dom';
  import { cache } from './store/cache';
  import { getBaseName } from '@redhat-cloud-services/frontend-components-utilities/helpers/helpers';
  import { getRegistry } from '@redhat-cloud-services/frontend-components-utilities/Registry';
  import { init } from './store';
  import logger from 'redux-logger';
  import messages from '../locales/data.json';
  import { setContext } from '@apollo/client/link/context';
  
  const AppEntry = ({ useLogger, connectToDevTools }) => {
      const tags = useRef();
      const selectedWorkloads = useRef();
      const selectedSID = useRef();
      const registry = getRegistry();
  
      const globalFilterLink = setContext((_, { headers }) => ({
          headers: {
              ...headers,
              ...(tags.current?.length && { 'insights-tags': `${tags.current}` }),
              ...(selectedWorkloads.current?.SAP?.isSelected && { 'insights-sap-system': true }),
              ...(selectedSID.current?.length && { 'insights-sap-sids': `${selectedSID.current}` })
          }
      }));
      const client = useMemo(() =>  new ApolloClient({
          link: globalFilterLink.concat(createHttpLink({
              uri: '/api/malware-detection/v1/graphql'
          })),
          cache,
          connectToDevTools
      }, `${tags.current}`), [connectToDevTools, globalFilterLink]);
      registry.register({ notifications });
  
      useEffect(() => {
          insights.chrome.init();
          insights.chrome.identifyApp('malware');
          if (insights.chrome?.globalFilterScope) {
              insights.chrome.on('GLOBAL_FILTER_UPDATE', ({ data }) => {
                  const [workloads, SID, selectedTags] =
                  insights.chrome?.mapGlobalFilter?.(data, false, true) || [];
                  tags.current =  selectedTags?.join(',') || '';
                  selectedWorkloads.current = workloads  || {};
                  selectedSID.current = SID || [];
  
                  client.resetStore();
              });
          }
  
      // eslint-disable-next-line react-hooks/exhaustive-deps
      }, [client]);
  
      return <IntlProvider locale={navigator.language.slice(0, 2)} messages={messages} onError={console.log}>
          <ApolloProvider client={client}>
              <Provider store={(useLogger ? init(logger) : init()).getStore()}>
                  <Router basename={getBaseName(window.location.pathname)}>
                      <NotificationsPortal />
                      <App />
                  </Router>
              </Provider>
          </ApolloProvider>
      </IntlProvider>;
  };
  
  AppEntry.propTypes = {
      useLogger: PropTypes.bool,
      connectToDevTools: PropTypes.bool
  };
  
  AppEntry.defaultProps = {
      useLogger: false,
      connectToDevTools: false
  };
  
  export default AppEntry;
  