import { useCreatePickerModal as useCreatePickerModalBase, useSyncPickerModalProps, } from '../hooks';
import { wixPatternsEnvironment, } from '@wix/bex-core';
import { useComponentInfo, useModuleInfo, useModuleParams, } from '@wix/yoshi-flow-bm';
import { useErrorMonitorCompat } from './errorMonitorCompat';
import { getModule } from '@wix/business-manager-api';
import { useCallback, useState } from 'react';
export function useCreatePickerModal() {
    const moduleParams = useModuleParams();
    const moduleInfo = useModuleInfo();
    const componentInfo = useComponentInfo();
    const errorMonitor = useErrorMonitorCompat();
    const createPicker = useCreatePickerModalBase();
    return useCallback((params) => {
        const { accountLanguage: language } = moduleParams;
        const { moduleId } = moduleInfo;
        const { componentId } = componentInfo;
        const { _essentials } = getModule(moduleId);
        return createPicker({
            ...params,
            environment: wixPatternsEnvironment({
                language,
                componentId,
                artifactId: moduleId,
                ...params?.environment,
            }),
            errorMonitor,
            biLoggerFactory: _essentials.biLoggerFactory,
        });
    }, []);
}
export function usePickerModal(params) {
    const createPickerModal = useCreatePickerModal();
    const [state] = useState(() => createPickerModal(params));
    useSyncPickerModalProps(state, params);
    return state;
}
//# sourceMappingURL=usePickerModal.js.map