'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
require('../../../../utils/index.cjs');
var lodashEs = require('lodash-es');
var log = require('../../../../utils/log.cjs');

function useSearchConfig(showSearch) {
  const mergedShowSearch = vue.shallowRef(false);
  const mergedSearchConfig = vue.ref({});
  vue.watchEffect(() => {
    if (!showSearch.value) {
      mergedShowSearch.value = false;
      mergedSearchConfig.value = {};
      return;
    }
    let searchConfig = {
      matchInputWidth: true,
      limit: 50
    };
    if (showSearch.value && typeof showSearch.value === "object") {
      searchConfig = {
        ...searchConfig,
        ...showSearch.value
      };
    }
    if (lodashEs.isNumber(searchConfig.limit) && searchConfig.limit <= 0) {
      delete searchConfig.limit;
      if (process.env.NODE_ENV !== "production")
        log.warning(false, "'limit' of showSearch should be positive number or false.");
    }
    mergedShowSearch.value = true;
    mergedSearchConfig.value = searchConfig;
  });
  return { showSearch: mergedShowSearch, searchConfig: mergedSearchConfig };
}

exports.default = useSearchConfig;
//# sourceMappingURL=useSearchConfig.cjs.map
