import "core-js/modules/es.promise.js";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import qs from 'query-string';
import { jsonp } from '@wii/jsonp';
const getApiUrl = params => {
  const {
    center,
    radius,
    keyWords,
    pageNo,
    pageSize,
    key,
    filter
  } = params;
  const paramsQueryStr = qs.stringify({
    boundary: `nearby(${center === null || center === void 0 ? void 0 : center.join(',')},${radius || 1000})`,
    keyword: keyWords || undefined,
    page_size: pageSize || 15,
    page_index: pageNo || 1,
    orderby: '_distance',
    key,
    output: 'jsonp',
    filter
  });
  return `https://apis.map.qq.com/ws/place/v1/search?${paramsQueryStr}`;
};
export const getPlaceByRadius = options => {
  return new Promise((resolve, reject) => {
    jsonp(getApiUrl(options), (err, data) => {
      if (err) {
        reject(err);
      } else if (data) {
        resolve(data);
      }
    });
  });
};