"use strict";

exports.__esModule = true;
exports.useCreatePickerModal = useCreatePickerModal;
exports.usePickerModal = usePickerModal;
var _hooks = require("../hooks");
var _bexCore = require("@wix/bex-core");
var _yoshiFlowBm = require("@wix/yoshi-flow-bm");
var _errorMonitorCompat = require("./errorMonitorCompat");
var _businessManagerApi = require("@wix/business-manager-api");
var _react = require("react");
function useCreatePickerModal() {
  const moduleParams = (0, _yoshiFlowBm.useModuleParams)();
  const moduleInfo = (0, _yoshiFlowBm.useModuleInfo)();
  const componentInfo = (0, _yoshiFlowBm.useComponentInfo)();
  const errorMonitor = (0, _errorMonitorCompat.useErrorMonitorCompat)();
  const createPicker = (0, _hooks.useCreatePickerModal)();
  return (0, _react.useCallback)(params => {
    const {
      accountLanguage: language
    } = moduleParams;
    const {
      moduleId
    } = moduleInfo;
    const {
      componentId
    } = componentInfo;
    const {
      _essentials
    } = (0, _businessManagerApi.getModule)(moduleId);
    return createPicker({
      ...params,
      environment: (0, _bexCore.wixPatternsEnvironment)({
        language,
        componentId,
        artifactId: moduleId,
        ...(params == null ? void 0 : params.environment)
      }),
      errorMonitor,
      biLoggerFactory: _essentials.biLoggerFactory
    });
  }, []);
}
function usePickerModal(params) {
  const createPickerModal = useCreatePickerModal();
  const [state] = (0, _react.useState)(() => createPickerModal(params));
  (0, _hooks.useSyncPickerModalProps)(state, params);
  return state;
}
//# sourceMappingURL=usePickerModal.js.map