"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getPlacesOptions = void 0;
var _locale = require("@mirai/locale");
const [DEFAULT_LANGUAGE] = _locale.DEFAULT_LOCALE.split('-');
const getPlacesOptions = function () {
  let items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  let language = arguments.length > 1 ? arguments[1] : undefined;
  const options = [];
  const parseItems = function () {
    let items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
    let level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
    items.forEach(function () {
      let item = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      const {
        visible,
        isHotel,
        tags = []
      } = item;
      if (visible || isHotel === false) {
        const {
          ids: id = [],
          name: title = {},
          tagId: value
        } = item;
        options.push({
          id,
          isHotel,
          level,
          title: title[language] || title[DEFAULT_LANGUAGE],
          value
        });
      }
      if (tags.length > 0) parseItems(tags, level + 1);
    });
  };
  parseItems(items);
  return options;
};
exports.getPlacesOptions = getPlacesOptions;
//# sourceMappingURL=getPlacesOptions.js.map