import React from 'react'; import { reconstructTheme } from '../utils/theme'; import type { GetIdSdk } from '..'; import type { TrySendEvent } from '../api/postEvent'; export interface Theme { cameraOverlayBackgroundColor: string; cameraFrameColor: string; successColor: string; errorColor: string; } export interface IGetIDContext { theme: Theme; trySendEvent: TrySendEvent; } export type GetIDProviderProps = { children: React.ReactNode; sdk: GetIdSdk; debugMode?: boolean; }; export const GetIDContext = React.createContext(null); export const GetIDProvider = ({ children, sdk, debugMode = false, }: GetIDProviderProps) => { const serverTheme = sdk.config?.configuration?.styles?.theme || {}; const theme = reconstructTheme(serverTheme); if (debugMode) { theme.cameraOverlayBackgroundColor = 'rgba(0, 0, 0, 0.2)'; } const contextValue: IGetIDContext = { theme, trySendEvent: sdk.tracking.trySendEvent, }; return ( {children} ); };