import { n as normalizeComponent, u as use, r as registerComponent } from './normalize-component-63e8c7a0.js';
import './es.symbol.description-3b56bced.js';
import { _ as _typeof } from './typeof-6c6d8d7a.js';
import './es.object.to-string-5a59fbfc.js';
import './es.regexp.to-string-784af81c.js';
import './es.array.filter-9f634d7c.js';
import './es.array.map-093cfbca.js';
import './es.object.keys-6369b884.js';
import './es.object.values-a2198dd7.js';
import './es.array.join-6ca857ff.js';
import 'lazysizes';
import Swiper, { Autoplay, Keyboard, Navigation, Pagination } from 'swiper';
import BaseIcon from './BaseIcon-d03b1fa2.js';
import { B as BaseImageBox } from './BaseImageBox-0b824f00.js';
import './export-ecf4b1cb.js';
import './array-species-create-afb281e6.js';
import './es.array.includes-1f433385.js';
import './object-keys-a5d351f7.js';
import './set-to-string-tag-452fb9b0.js';
import './array-iteration-dec5536e.js';
import './function-bind-context-b3fabf77.js';
import './classof-b10e7604.js';
import './regexp-flags-b5fc4ddb.js';
import './array-method-has-species-support-d96108b0.js';
import './array-method-is-strict-903f485b.js';
import './es.array.concat-9f3136dc.js';
import './create-property-c00b5c27.js';
import './es.string.includes-53dbb113.js';
import './is-regexp-5558fd03.js';
import './regexp-exec-abstract-04d119fc.js';
import './string-multibyte-88926e02.js';
import './es.string.replace-07eeebfe.js';
import './BaseBox-a4447dc8.js';
import './BaseImage-7306e391.js';

Swiper.use([Autoplay, Keyboard, Navigation, Pagination]);
var script = {
  name: 'BaseCarousel',
  components: {
    BaseIcon: BaseIcon,
    BaseImageBox: BaseImageBox
  },
  props: {
    /**
     * specify array of items to render<br>
     *   the item object should have the following properties:<br>
     *     title {?string} - the title to display<br>
     *     subtext {?string} - the text below the title<br>
     *     description {?string} - the type of item<br>
     *     additional {?string} - additional information (e.g. dates)<br>
     *     href - a url to follow upon item click<br>
     *     previews - an array of image urls in different sizes in the following form:<br>
     *     e.g. [{ '460w': 'image-url' }, { '640w': 'image url' },...]
     */
    items: {
      type: Array,
      default: function _default() {
        return [];
      }
    },

    /**
     * specify swiper options
     * swiper API: https://swiperjs.com/api/#parameters
     */
    swiperOptions: {
      type: Object,
      default: function _default() {
        return {};
      }
    },

    /**
     * specify how link element should be rendered - this needs to be a
     * valid vue link component (e.g. router-link, nuxt-link) and vue-router
     * is necessary
     */
    renderLinkElementAs: {
      type: String,
      default: 'router-link'
    }
  },
  data: function data() {
    return {
      swiper: undefined,
      swiperIsActive: false
    };
  },
  computed: {
    boxSize: function boxSize() {
      return this.swiperIsActive ? {
        height: '400px'
      } : {
        'min-height': '250px',
        'max-height': '350px'
      };
    },
    vueRouterAvailable: function vueRouterAvailable() {
      return !!this.$router;
    }
  },
  watch: {
    data: function data() {
      this.swiper.update();
    }
  },
  mounted: function mounted() {
    if (process.browser) {
      this.initSwiper();
    }
  },
  methods: {
    getImageSrc: function getImageSrc(object, value) {
      var imageSrc = '';

      if (object && object.length) {
        // filter by value
        imageSrc = object.map(function (obj) {
          return Object.keys(obj)[0] === value ? Object.values(obj)[0] : '';
        }).filter(function (obj) {
          return obj !== '';
        }).toString(); // otherwise take first one

        if (!imageSrc.length) {
          // eslint-disable-next-line
          imageSrc = Object.values(object[0])[0];
        }
      }

      return imageSrc;
    },
    initSwiper: function initSwiper() {
      var _this = this;

      this.swiperIsActive = true;
      this.swiperOptions.init = false;

      if (this.swiperOptions.autoplay) {
        this.swiperOptions.autoplay = {};
        this.swiperOptions.autoplay.delay = this.swiperOptions.autoplayDelay || 3000;
        this.swiperOptions.autoplay.disableOnInteraction = true;
      }

      this.swiperOptions.navigation = {
        nextEl: '.swiper-button-next',
        prevEl: '.swiper-button-prev'
      };
      setTimeout(function () {
        _this.swiper = new Swiper('.swiper-container', _this.swiperOptions);

        _this.swiper.init();
        /**
         * event triggered when slider is initialized
         *
         * @event initialized
         * @type { boolean }
         */


        _this.$emit('initialized', true);
      }, 0);
    },
    subtext: function subtext(value) {
      return _typeof(value) === 'object' && typeof value[0] === 'string' ? value.join(', ') : value;
    },
    boxClicked: function boxClicked(item) {
      /**
       * @event clicked
       * @type {Object}
       */
      this.$emit('clicked', item);
    }
  }
};

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', [_c('div', {
    staticClass: "base-carousel swiper-container"
  }, [_c('div', {
    staticClass: "swiper-wrapper"
  }, _vm._l(_vm.items, function (item, index) {
    return _c('div', {
      directives: [{
        name: "show",
        rawName: "v-show",
        value: _vm.swiperIsActive,
        expression: "swiperIsActive"
      }],
      key: index,
      class: ['base-carousel-slide', {
        'swiper-slide': _vm.swiperIsActive
      }]
    }, [_c('BaseImageBox', {
      staticStyle: {
        "margin-right": "0"
      },
      attrs: {
        "title": item.title,
        "subtext": _vm.subtext(item.subtext),
        "description": item.description,
        "additional": item.additional,
        "image-url": _vm.getImageSrc(item.previews, _vm.items.length < 3 ? '768w' : '640w'),
        "box-size": _vm.boxSize,
        "lazyload": true,
        "image-first": true,
        "center-header": true,
        "render-element-as": _vm.vueRouterAvailable ? _vm.renderLinkElementAs : 'div',
        "link-to": _vm.vueRouterAvailable && item.href ? item.href : ''
      },
      on: {
        "clicked": function clicked($event) {
          return _vm.boxClicked(item);
        }
      }
    })], 1);
  }), 0), _vm._v(" "), _vm.items.length > 2 ? _c('div', {
    staticClass: "swiper-pagination"
  }) : _vm._e(), _vm._v(" "), _vm.items.length > 1 ? [_c('base-icon', {
    staticClass: "swiper-button swiper-button-prev",
    attrs: {
      "name": "prev"
    }
  }), _vm._v(" "), _c('base-icon', {
    staticClass: "swiper-button swiper-button-next",
    attrs: {
      "name": "next"
    }
  })] : _vm._e()], 2)]);
};

var __vue_staticRenderFns__ = [];
/* style */

var __vue_inject_styles__ = undefined;
/* scoped */

var __vue_scope_id__ = "data-v-d405f6ec";
/* 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 BaseCarousel = __vue_component__;

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

export { BaseCarousel, Plugin as default };
