import { n as normalizeComponent, u as use, r as registerComponent } from './normalize-component-63e8c7a0.js';
import './es.object.to-string-5a59fbfc.js';
import './es.array.includes-1f433385.js';
import './es.number.constructor-16a232f3.js';
import './es.array.filter-9f634d7c.js';
import './web.dom-collections.for-each-917714ef.js';
import './es.array.map-093cfbca.js';
import './es.array.from-3ef944e4.js';
import './es.string.iterator-eb7ab984.js';
import './web.dom-collections.iterator-5ecbd86d.js';
import './es.json.stringify-9b0e9796.js';
import { B as BaseTextList } from './BaseTextList-7f2143d5.js';
import './classof-b10e7604.js';
import './export-ecf4b1cb.js';
import './object-keys-a5d351f7.js';
import './object-set-prototype-of-9853ad1a.js';
import './array-iteration-dec5536e.js';
import './function-bind-context-b3fabf77.js';
import './array-species-create-afb281e6.js';
import './array-method-has-species-support-d96108b0.js';
import './dom-iterables-b6f5ef3b.js';
import './array-method-is-strict-903f485b.js';
import './create-property-c00b5c27.js';
import './string-multibyte-88926e02.js';
import './set-to-string-tag-452fb9b0.js';
import './set-species-77dd094d.js';
import './typeof-6c6d8d7a.js';
import './es.array.concat-9f3136dc.js';
import './unsupportedIterableToArray-577176bf.js';
import './es.string.includes-53dbb113.js';
import './is-regexp-5558fd03.js';
import './es.object.keys-6369b884.js';
import './i18n-e25edebe.js';
import './regexp-exec-abstract-04d119fc.js';
import './regexp-flags-b5fc4ddb.js';
import './es.string.split-cd1f3afc.js';

/**
 * A component to display Basemap, locations-list and interact with each other
 */

var script = {
  name: 'BaseMapLocations',
  components: {
    BaseMap: function BaseMap() {
      return import('./BaseMap-463863ab.js').then(function (m) {
        return m.default || m;
      });
    },
    BaseTextList: BaseTextList
  },
  props: {
    /**
     * set additional styles for map e.g. height
     */
    additionalMapStyles: {
      type: Object,
      default: function _default() {
        return {
          height: '368px'
        };
      }
    },

    /**
     * define map attribution
     */
    attribution: {
      type: String,
      default: 'Source: <a href=https://openstreetmap.org/>OpenStreetMap contributors</a>'
    },

    /**
     * define position of map attribution<br>
     *   valid options: 'topright' | 'bottomleft' | 'bottomright'
     */
    attributionPosition: {
      type: String,
      default: 'bottomright',
      validate: function validate(val) {
        return ['topright', 'bottomleft', 'bottomright'].includes(val);
      }
    },

    /**
     * define number of items for cluster sizes<br>
     *   structure: { medium: 5, large: 20, xlarge: 100 }<br>
     *   Note: medium, large, xlarge is mandatory
     */
    clusterSizes: {
      type: Object,
      default: function _default() {
        return {
          medium: 5,
          large: 20,
          xlarge: 100
        };
      },
      validator: function validator(data) {
        return data.medium && data.large && data.xlarge;
      }
    },

    /**
     * define map copyright
     */
    copyright: {
      type: String,
      default: '<a href=http://creativecommons.org/licenses/by-sa/3.0/>CC BY-SA 3.0</a>'
    },

    /*
     * define icon
     */
    icon: {
      type: String,
      default: '<svg viewBox="0 0 70.866 70.866" xmlns="http://www.w3.org/2000/svg"><path d="m35.433 0a22.731 22.731 0 0 0-22.731 22.82 24.125 24.125 0 0 0 1.872 9.1814l19.611 38.063a1.3718 1.3718 0 0 0 2.496 0l19.611-38.063a22.249 22.249 0 0 0 1.872-9.1814 22.731 22.731 0 0 0-22.731-22.82zm0 32.858a10.216 10.216 0 1 1 10.216-10.216 10.241 10.241 0 0 1-10.216 10.216z" fill="#010101"/></svg>'
    },

    /**
     * define icon size
     */
    iconSize: {
      type: Number,
      default: 32
    },

    /**
     * define label for the locations-list
     */
    label: {
      type: String,
      default: 'Addresses'
    },

    /**
     * define locations<br>
     *   structure: [{<br>
     *     coordinates: [16.382782, 48.208309],<br>
     *     latLng: [48.208309, 16.382782],<br>
     *     data: [ 'University of Applied Arts', 'Oskar Kokoschka-Platz 2',
     *     '1010 Vienna', 'Austria']<br>
     *   }]<br><br>
     *   Note: either coordinates or latLng is mandatory
     */
    locations: {
      type: Array,
      default: function _default() {
        return [];
      },
      validator: function validator(data) {
        return data.filter(function (item) {
          return item.latLng || item.coordinates;
        }).length === data.length;
      }
    },

    /**
     * deactivate popups for marker
     */
    markerPopups: {
      type: Boolean,
      default: true
    },

    /**
     * define max zoom factor
     */
    maxZoom: {
      type: Number,
      default: 18
    },

    /**
     * define custom options for map data<br>
     *   e.g. {
     *          style: 'normal',
     *          subdomains: ['maps'],
     *          tileMatrixSet: 'google3857',
     *          type: 'geolandbasemap'
     *   }<br>
     *   usage custom keys in url property:
     *   https://{s}.wien.gv.at/basemap/{type}/{style}/{tileMatrixSet}/{z}/{y}/{x}.png
     */
    options: {
      type: Object,
      default: function _default() {
        return {};
      }
    },

    /**
     * define url to tileLayer service
     */
    url: {
      type: String,
      default: ''
    },

    /**
     * specify service for the [tileLayer](https://leafletjs.com/examples/wms/wms.html)<br>
     * valid values: 'WMTS' | 'TMS' | 'WMS'
     */
    tileLayerService: {
      type: String,
      default: 'WMTS',
      validator: function validator(val) {
        return ['WMTS', 'TMS', 'WMS'].includes(val);
      }
    },

    /**
     * define initial zoom factor
     */
    zoom: {
      type: Number,
      default: 16
    }
  },
  data: function data() {
    return {
      highlightedMarker: null,
      highlightedLocation: null,
      centeredMarker: null,
      initMap: false
    };
  },
  computed: {
    // Observer to check if component is in viewport and show baseMap
    observer: function observer() {
      var _this = this;

      return new IntersectionObserver(function (entries, observer) {
        entries.forEach(function (entry) {
          // If the entry is not in the viewport, do nothing
          if (!entry.isIntersecting) return; // Stop observing

          observer.unobserve(entry.target); // Init map

          _this.initMap = true;
        });
      });
    },
    // compare marker objects and remove duplicates
    locationsFiltered: function locationsFiltered() {
      return Array.from(new Set(this.locations.map(JSON.stringify))).map(JSON.parse);
    }
  },
  beforeDestroy: function beforeDestroy() {
    this.observer.disconnect();
  },
  mounted: function mounted() {
    // Execute only on clientside
    if (!process.browser) {
      return;
    } // Add observer to check if component is in viewport and init baseMap


    this.observer.observe(this.$el);
  },
  methods: {
    highlightLocation: function highlightLocation(value) {
      this.highlightedLocation = value;
    },
    resetMarker: function resetMarker() {
      this.highlightedMarker = null;
      this.centeredMarker = null;
    }
  }
};

/* script */
var __vue_script__ = script;
/* template */

var __vue_render__ = function __vue_render__() {
  var _vm = this;

  var _h = _vm.$createElement;

  var _c = _vm._self._c || _h;

  return _c('div', {
    staticClass: "base-map-locations"
  }, [_c('div', {
    staticClass: "base-map-locations__map",
    style: _vm.additionalMapStyles
  }, [_vm.initMap ? _c('BaseMap', {
    style: _vm.additionalMapStyles,
    attrs: {
      "attribution": _vm.attribution,
      "attribution-position": _vm.attributionPosition,
      "cluster-sizes": _vm.clusterSizes,
      "copyright": _vm.copyright,
      "center-marker": _vm.centeredMarker,
      "icon": _vm.icon,
      "icon-size": _vm.iconSize,
      "highlight-marker": _vm.highlightedMarker,
      "marker": _vm.locationsFiltered,
      "marker-popups": _vm.markerPopups,
      "max-zoom": _vm.maxZoom,
      "options": _vm.options,
      "tile-layer-service": _vm.tileLayerService,
      "url": _vm.url,
      "zoom": _vm.zoom
    },
    on: {
      "highlighted": _vm.highlightLocation
    }
  }) : _vm._e()], 1), _vm._v(" "), _vm.label ? _c('h2', {
    staticClass: "base-map-locations__label"
  }, [_vm._v("\n    " + _vm._s(_vm.label) + "\n  ")]) : _vm._e(), _vm._v(" "), _c('div', {
    staticClass: "base-map-locations__list"
  }, [_vm._l(_vm.locationsFiltered, function (location, index) {
    return [location.latLng || location.coordinates ? _c('baseTextList', {
      key: index,
      class: ['base-map-locations__list__group', {
        'base-map-locations__list__group--highlight': index === _vm.highlightedLocation
      }],
      attrs: {
        "data": [location]
      },
      nativeOn: {
        "click": function click($event) {
          _vm.centeredMarker = index;
        },
        "mouseenter": function mouseenter($event) {
          _vm.highlightedMarker = index;
        },
        "mouseleave": function mouseleave($event) {
          return _vm.resetMarker.apply(null, arguments);
        }
      }
    }) : _vm._e()];
  })], 2)]);
};

var __vue_staticRenderFns__ = [];
/* style */

var __vue_inject_styles__ = undefined;
/* scoped */

var __vue_scope_id__ = "data-v-5fa70c92";
/* module identifier */

var __vue_module_identifier__ = undefined;
/* functional template */

var __vue_is_functional_template__ = false;
/* style inject */

/* style inject SSR */

/* style inject shadow dom */

var __vue_component__ = /*#__PURE__*/normalizeComponent({
  render: __vue_render__,
  staticRenderFns: __vue_staticRenderFns__
}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, false, undefined, undefined, undefined);

var BaseMapLocations = __vue_component__;

var Plugin = {
  install: function install(Vue) {
    registerComponent(Vue, BaseMapLocations);
  }
};
use(Plugin);

export { BaseMapLocations, Plugin as default };
