import { jsx as _jsx } from "react/jsx-runtime";
import { createContext, useEffect, useMemo, } from 'react';
import { russianMap } from '../DatePicker/constants';
import { ErrorService } from '../services/ErrorService';
import { NextFeatureFlagsContext, } from './NextFeatureFlagsContext';
const imagesMapDefault = {
    noDataImgSrc: '',
    defaultErrorImgSrc: '',
    outdatedReleaseErrorImgSrc: '',
    mailImgSrc: '',
};
const techSupDefault = {
    phone: '',
    email: '',
};
const defaultHidePersonalDataClassname = 'ym-hide-content sentry-mask';
const defaultHidePersonalInputDataClassname = 'ym-disable-keys sentry-mask';
export const ConfigContext = createContext({
    language: 'ru',
    datePickerLanguageMap: russianMap,
    // biome-ignore lint/suspicious/noConsole: Ошибка для интеграторов
    captureException: (error) => console.error(error),
    imagesMap: imagesMapDefault,
    techSup: techSupDefault,
    emptySymbol: '—',
    hidePersonalDataClassname: defaultHidePersonalDataClassname,
    hidePersonalInputDataClassname: defaultHidePersonalInputDataClassname,
    hidePersonalData: true,
});
export const ConfigProvider = ({ children, language = 'ru', datePickerLanguageMap = russianMap, captureException: captureExceptionProp, emptySymbol = '—', imagesMap = imagesMapDefault, techSup = techSupDefault, hidePersonalData = true, hidePersonalDataClassname = defaultHidePersonalDataClassname, hidePersonalInputDataClassname = defaultHidePersonalInputDataClassname, components: propsComponents, nextFeatureFlags = {}, }) => {
    const captureException = 
    // biome-ignore lint/suspicious/noConsole: Ошибка для интеграторов
    captureExceptionProp || ((error) => console.error(error));
    useMemo(() => {
        ErrorService.getInstance().init(captureException);
    }, [captureException]);
    useEffect(() => {
        if (!captureException) {
            // biome-ignore lint/suspicious/noConsole: Ошибка для интеграторов
            console.warn('ConfigProvider: Необходимо наличие captureException, связанного с сервисом мониторинга ошибок.\n' +
                'На данный момент все ошибки, отлавливаемые в ErrorBoundary будут выводиться только в консоль');
        }
    }, []);
    const components = {
        ...propsComponents,
        layout: {
            ...propsComponents?.layout,
            defaultProps: {
                ...propsComponents?.layout?.defaultProps,
                shouldUpdateDocumentTitle: propsComponents?.layout?.defaultProps?.shouldUpdateDocumentTitle ??
                    true,
            },
        },
        contentState: {
            ...propsComponents?.contentState,
            defaultProps: {
                ...propsComponents?.contentState?.defaultProps,
                isSmoothLoading: propsComponents?.contentState?.defaultProps?.isSmoothLoading ?? true,
            },
        },
    };
    return (_jsx(ConfigContext.Provider, { value: {
            language,
            datePickerLanguageMap,
            captureException,
            emptySymbol,
            imagesMap,
            techSup,
            hidePersonalData,
            hidePersonalDataClassname,
            hidePersonalInputDataClassname,
            components,
        }, children: _jsx(NextFeatureFlagsContext.Provider, { value: nextFeatureFlags, children: children }) }));
};
