'use strict';Object.defineProperty(exports,'__esModule',{value:true});var normalizeComponent=require('./normalize-component-d9981c57.js');require('./es.symbol.description-bf683260.js');var _typeof=require('./typeof-6b9e62b8.js');require('./es.object.to-string-f27a75a8.js'),require('./es.regexp.to-string-5606f728.js'),require('./es.array.filter-6fabfac0.js'),require('./es.array.map-4cfed4ef.js'),require('./es.object.keys-c57f02bd.js'),require('./es.object.values-1f44a4ee.js'),require('./es.array.join-88750c41.js'),require('lazysizes');var Swiper=require('swiper'),BaseIcon=require('./BaseIcon-1ed3bf6e.js'),BaseImageBox=require('./BaseImageBox-9c4e6acb.js');require('./export-61511812.js'),require('./array-species-create-c414c2ec.js'),require('./es.array.includes-3990bfec.js'),require('./object-keys-12f2c5e5.js'),require('./set-to-string-tag-240bb3b0.js'),require('./array-iteration-f8b4483d.js'),require('./function-bind-context-e4685306.js'),require('./classof-819fc780.js'),require('./regexp-flags-abc49c4a.js'),require('./array-method-has-species-support-983ac207.js'),require('./array-method-is-strict-99341ee3.js'),require('./es.array.concat-bb8715dc.js'),require('./create-property-240c71a5.js'),require('./es.string.includes-ec03e639.js'),require('./is-regexp-d6f1551e.js'),require('./regexp-exec-abstract-216cd44a.js'),require('./string-multibyte-a2dff6e3.js'),require('./es.string.replace-25e9e098.js'),require('./BaseBox-1df1f27d.js'),require('./BaseImage-b2322064.js');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e}}var Swiper__default=/*#__PURE__*/_interopDefaultLegacy(Swiper);Swiper__default["default"].use([Swiper.Autoplay, Swiper.Keyboard, Swiper.Navigation, Swiper.Pagination]);
var script = {
  name: 'BaseCarousel',
  components: {
    BaseIcon: BaseIcon["default"],
    BaseImageBox: BaseImageBox.B
  },
  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__default["default"]('.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', [_vm._ssrNode("<div class=\"base-carousel swiper-container\" data-v-d405f6ec>", "</div>", [_vm._ssrNode("<div class=\"swiper-wrapper\" data-v-d405f6ec>", "</div>", _vm._l(_vm.items, function (item, index) {
    return _vm._ssrNode("<div" + _vm._ssrClass(null, ['base-carousel-slide', {
      'swiper-slide': _vm.swiperIsActive
    }]) + _vm._ssrStyle(null, null, {
      display: _vm.swiperIsActive ? '' : 'none'
    }) + " data-v-d405f6ec>", "</div>", [_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._ssrNode(" " + (_vm.items.length > 2 ? "<div class=\"swiper-pagination\" data-v-d405f6ec></div>" : "<!---->") + " "), _vm.items.length > 1 ? [_c('base-icon', {
    staticClass: "swiper-button swiper-button-prev",
    attrs: {
      "name": "prev"
    }
  }), _vm._ssrNode(" "), _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__ = "data-v-d405f6ec";
/* functional template */

var __vue_is_functional_template__ = false;
/* style inject */

/* style inject SSR */

/* style inject shadow dom */

var __vue_component__ = /*#__PURE__*/normalizeComponent.n({
  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) {
    normalizeComponent.r(Vue, BaseCarousel);
  }
};
normalizeComponent.u(Plugin);exports.BaseCarousel=BaseCarousel;exports["default"]=Plugin;