import { Typography } from "@mui/material";
import React from "react";
import Search from "../Search";
class Municipalities extends Search {
  constructor() {
    super();
    this.showInPlaceholder = false;
    this.dataProjection = "EPSG:2056";
  }

  // eslint-disable-next-line class-methods-use-this
  search(value) {
    if (this.abortController) {
      this.abortController.abort();
    }
    this.abortController = new AbortController();
    const {
      signal
    } = this.abortController;
    return fetch("".concat(this.searchUrl, "/search/municipalities?query=").concat(encodeURIComponent(value), "&utf8=%E2%9C%93"), {
      signal
    }).then(data => data.json()).then(featureCollection => {
      return (featureCollection === null || featureCollection === void 0 ? void 0 : featureCollection.features) || [];
    }).catch(() => {
      return [];
    });
  }
  render(item) {
    return /*#__PURE__*/React.createElement("div", {
      className: "wkp-search-suggestion"
    }, /*#__PURE__*/React.createElement(Typography, null, item.properties.name));
  }

  // eslint-disable-next-line class-methods-use-this
  value(item) {
    return item.properties.name;
  }
}
export default Municipalities;
//# sourceMappingURL=Municipalities.js.map