import { create } from "zustand"; type HookModalState = { path: string; screenData: HookPluginProps; }; export type HookModalContextT = { isHooksExecutionInProgress: boolean; setIsHooksExecutionInProgress: (hookExecutionState?: boolean) => void; isRunningInBackground: boolean; isPresentationFullScreen: boolean; setIsRunningInBackground: () => void; setIsPresentingFullScreen: () => void; state: HookModalState; setState: (state: HookModalState) => void; resetState: () => void; hookPresentationMode: HookPresentationMode; }; const initialState = { path: null, screenData: null, }; type HookPresentationMode = "background" | "fullScreen"; // Use useZappHookModalStore() in React components (hooks) // Use zappHookModalStore.getState() in non-React functions (utility functions, etc.) export const useZappHookModalStore = create()((set) => ({ state: initialState, isHooksExecutionInProgress: false, hookPresentationMode: null as HookPresentationMode, isRunningInBackground: false, isPresentationFullScreen: false, setState: (newState: HookModalState) => { set({ state: newState }); }, setIsHooksExecutionInProgress: (hookExecutionState?: boolean) => { set({ isHooksExecutionInProgress: hookExecutionState ?? false }); }, setIsRunningInBackground: () => { set({ hookPresentationMode: "background", isRunningInBackground: true, isPresentationFullScreen: false, }); }, setIsPresentingFullScreen: () => { set({ hookPresentationMode: "fullScreen", isRunningInBackground: false, isPresentationFullScreen: true, }); }, resetState: () => { set({ state: initialState }); }, })); // Export an alias for clearer non-React usage (utility functions, etc.) export const zappHookModalStore = useZappHookModalStore;