import * as React from 'react' ; import { useLocation } from 'react-router-dom' ; import { useZenModeStore } from '../../../mui/ZenModeStore' ; import { createIntercomClient } from "../../../analytics/intercom/IntercomAnalytics" ; import { useIntercomData } from "./IntercomHooks" ; export function useIntercom ( ) { const location = useLocation ( ) ; const booted = React . useRef ( false ) ; const intercomClient = createIntercomClient ( ) ; const intercomData = useIntercomData ( ) ; if ( ! intercomClient ) { return ; } if ( ! intercomData ) { return ; } if ( booted . current ) { intercomClient . update ( intercomData ) ; } else { intercomClient . boot ( intercomData ) ; } } function useIntercomSideNavToggler ( ) { const { zenMode } = useZenModeStore ( [ 'zenMode' ] ) ; React . useEffect ( ( ) => { const launcher = document . querySelector ( '.intercom-launcher, .intercom-namespace' ) as HTMLElement ; if ( launcher ) { if ( zenMode ) { console . log ( "Hiding intercom" ) ; launcher . style . display = 'none' ; } else { console . log ( "Showing intercom" ) ; launcher . style . display = 'unset' ; } } } , [ zenMode ] ) ; } export const Intercom = ( ) => { useIntercom ( ) ; useIntercomSideNavToggler ( ) ; return null ; } ;