text: require('./styles.scss');
  
  var Flickity = require('flickity');
  require('flickity-imagesloaded');
  //require('flickity-bg-lazyload');
  
  import '@fortawesome/fontawesome-free/js/fontawesome'
  import '@fortawesome/fontawesome-free/js/solid'
  import '@fortawesome/fontawesome-free/js/regular'
  import '@fortawesome/fontawesome-free/js/brands'
  
  var $carousels = new Array();
  
  // Modals
  
  var rootEl = document.documentElement;
  var $modals = getAll('.modal');
  var $modalTriggers = getAll('.modal-trigger');
  var $modalCloses = getAll('.modal-card-head .delete, .modal-card-foot .button');
  var $caption = getAll('.caption');
  
  if ($modalTriggers.length > 0) {
      $modalTriggers.forEach(function ($el) {
          $el.addEventListener('click', function () {
              var target = $el.dataset.target;
              openModal(target);
          });
      });
  }
  
  if ($modalCloses.length > 0) {
      $modalCloses.forEach(function ($el) {
          $el.addEventListener('click', function () {
              closeModals();
          });
      });
  }
  
  function openModal(target) {
      var $target = document.getElementById(target);
      rootEl.classList.add('is-clipped');
      $target.classList.add('is-active');
      var carouselId = target + '-carousel';
  
      if (document.querySelector('#' + carouselId)) {
          // Initialize each carousel one time only
          if ($carousels.length === 0) {
              var $car = initCarousel(carouselId)
          }
          else {
              var index = $carousels.findIndex(c => c.element.id == carouselId);
              if (index === -1) {
                  var $car = initCarousel(carouselId)
              }
          }
         /* $car.on( 'select.flickity', function() {
              $caption.text( $car.data('flickity').selectedElement.alt )
          });*/
          $carousels.push($car);
      }
  }
  
  function closeModals() {
      rootEl.classList.remove('is-clipped');
      $modals.forEach(function ($el) {
          $el.classList.remove('is-active');
      });
  }
  
  // Functions
  
  function initCarousel(id) {
      return new Flickity('#' + id, {
          imagesLoaded: true,
          //LazyLoad: true
          //bgLazyLoad: true
          adaptiveHeight: true // https://github.com/metafizzy/flickity/issues/11
      });
  }
  
  function getAll(selector) {
      return Array.prototype.slice.call(document.querySelectorAll(selector), 0);
  }