import * as React from 'react' ; import { Provider } from "polar-shared/src/util/Providers" ; import { SetStore , createObservableStore } from "../react/store/ObservableStore" ; import { Analytics } from '../analytics/Analytics' ; /**
 * High level store so that sub-components can determine if we're in zen mode to
 * turn on/off specific UI components.
 */ interface IZenModeStore { readonly zenMode : boolean ; } interface IZenModeCallbacks { readonly toggleZenMode : ( ) => void ; readonly setZenMode : ( zenMode : boolean ) => void ; } const initialStore = { zenMode : false } ; interface Mutation { } interface Mutator { } function mutatorFactory ( storeProvider , setStore ) { return { } ; } function useCallbacksFactory ( storeProvider , setStore , mutator ) { return React . useMemo ( ( ) => { function toggleZenMode ( ) { const store = storeProvider ( ) ; if ( ! store . zenMode ) { Analytics . event2 ( 'global-zenModeEnabled' ) ; } setZenMode ( ! store . zenMode ) ; } function setZenMode ( zenMode ) { const store = storeProvider ( ) ; setStore ( { ... store , zenMode } ) ; } return { toggleZenMode , setZenMode , } ; } , [ storeProvider , setStore ] ) ; } export const [ ZenModeStoreProvider , useZenModeStore , useZenModeCallbacks , useZenModeMutator ] = createObservableStore < IZenModeStore , Mutator , IZenModeCallbacks > ( { initialValue : initialStore , mutatorFactory , callbacksFactory : useCallbacksFactory } ) ;