{
  "version": 3,
  "sources": ["/cdn/shop/t/23/assets/product-gallery.js?=124908639636300920611773923410&v%5B0%5D%5B1000%5D=whscheck"],
  "sourcesContent": ["class ProductGallery extends HTMLElement {\n  constructor() {\n    super();\n    this.init()\n\n    // Add resize observer to update container height\n    const resizeObserver = new ResizeObserver(entries => {\n      let elem = document.querySelector('.product-gallery__image--active');\n      elem.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'center' });\n      this.update();\n    });\n    resizeObserver.observe(this);\n\n    // Bind event listeners\n    this.navItems.forEach(item => item.addEventListener('click', this.onNavItemClick.bind(this)))\n    //this.prevButton.addEventListener('click', this.onButtonClick.bind(this));\n    //this.nextButton.addEventListener('click', this.onButtonClick.bind(this));\n    // For loop for applying button event handlers in case of using mobile slider buttons\n    this.prevButton.forEach((button) => {\n      button.addEventListener('click', this.onButtonClick.bind(this));\n    });\n    this.nextButton.forEach((button) => {\n      button.addEventListener('click', this.onButtonClick.bind(this));\n    });\n    // Listen for variant selection change to make current variant image active\n    window.addEventListener('message', this.onMessage.bind(this))\n\n    //Resize image\n    window.addEventListener(\"resize\", this.onResize.bind(this));\n    \n    \n  }\n\n  init() {\n    // Set up our DOM element variables\n    this.imagesContainer = this.querySelector('.product-gallery__images');\n    this.navItems = this.querySelectorAll('.product-gallery__nav-item');\n    this.dots = this.querySelectorAll('.product-gallery__nav-item.dot-nav');\n    this.images = this.querySelectorAll('.product-gallery__image');\n    this.filteredImages = this.querySelectorAll('.product-gallery__image.filtered');\n    this.filteredDots = this.querySelectorAll('.product-gallery__nav-item.dot-nav.filtered');\n    this.prevButton = this.querySelectorAll('button[name=\"previous\"]');\n    this.nextButton = this.querySelectorAll('button[name=\"next\"]');\n    this.arrowContainer = this.querySelector(\".carousel-arrow-container\");\n    this.onlyDefaultVariant = this.dataset.onlyDefaultVariant;\n    // If there is no active images, or the product only has the default variant set the first image to active\n    if (this.findCurrentIndex() === -1 || this.onlyDefaultVariant === 'true') {\n      this.setCurrentImage(this.images[0]);\n      this.setCurrentDot(this.dots[0]);\n    } else {\n      this.setSlideCount(this.findCurrentIndex() + 1);\n      this.setCurrentDot(this.dots[this.findCurrentIndex()]);\n    }\n\n    if (window.innerWidth < 750) {\n      this.imagesContainer.style.maxHeight = \"none\";\n    } else {\n      this.imagesContainer.style.maxHeight = this.querySelector(\".product-gallery__image--active img\").height + \"px\";\n      \n    }\n\n    if (this.arrowContainer) {\n    this.arrowContainer.style.top = (this.querySelector(\".product-gallery__image--active img\").height / 2) + \"px\";\n    }\n  }\n  \n\n  onMessage(event) {\n    if (!event.data) return;\n    if (event.data.type !== 'variant_changed' || event.data.action != 'filter') {\n      if (event.data.type == 'variant_changed') {\n        let currentImage = Array.from(this.images).find(item => item.dataset.mediaId == event.data.variant.featured_media.id)\n        if (currentImage) {\n          this.setCurrentImage(currentImage)\n        }\n        this.setCurrentDot(this.dots[Array.from(this.images).findIndex(item => item.classList.contains('product-gallery__image--active'))]);\n      }\n      if (event.data.type == 'product_gallery' && event.data.action == 'filter') {\n        this.filteredImages = this.querySelectorAll('.product-gallery__image.filtered');\n        this.filteredDots = this.querySelectorAll('.product-gallery__nav-item.dot-nav.filtered');\n        this.setCurrentImage(this.filteredImages[0]);\n        this.setCurrentDot(this.filteredDots[0]);\n      }\n\n      if (event.data.type == 'product_gallery' && event.data.action == 'unfilter') {\n        this.setSlideCount(Array.from(this.images).findIndex(item => item.classList.contains('product-gallery__image--active')) + 1);\n        this.setCurrentDot(this.dots[Array.from(this.images).findIndex(item => item.classList.contains('product-gallery__image--active'))]);\n      }\n    }\n  }\n\n  onResize(event) {\n    if (window.innerWidth < 750) {\n      this.imagesContainer.style.maxHeight = \"none\";\n    } else {\n      this.imagesContainer.style.maxHeight = this.querySelector(\".product-gallery__image--active img\").height + \"px\";\n    }\n    if (this.arrowContainer) {\n      this.arrowContainer.style.top = (this.querySelector(\".product-gallery__image--active img\").height / 2) + \"px\";\n      }\n    \n  }\n\n  onVariantChange(event) {\n    if (!event.data || event.data.type !== 'variant_changed') return \n    const currentImage = Array.from(this.images).find(item => item.dataset.mediaId == event.data.variant.featured_media.id)\n    if (currentImage) {\n      this.setCurrentImage(currentImage)\n    }\n    this.setSlideCount(Array.from(this.images).findIndex(item => item.classList.contains('product-gallery__image--active')) + 1);\n  }\n\n  onNavItemClick(event) {\n    window.postMessage({ type: 'product_gallery', action: \"nav_click\" }, '*');\n    const mediaId = event.target.closest('li').dataset.mediaId;\n    const targetDot = event.target.closest('li.dot-nav');\n    this.setCurrentDot(targetDot);\n    this.images.forEach(item => item.classList.remove('product-gallery__image--active'));\n    this.setCurrentImage(Array.from(this.images).find(item => item.dataset.mediaId === mediaId))\n    if (this.querySelectorAll('.product-gallery__image.filtered').length > 0) {\n      this.setSlideCount(Array.from(this.filteredImages).findIndex(item => item.classList.contains('product-gallery__image--active')) + 1);\n    } else {\n      this.setSlideCount(Array.from(this.images).findIndex(item => item.classList.contains('product-gallery__image--active')) + 1);\n    }\n  }\n\n  update() {\n    window.postMessage({ type: 'product_gallery', action: \"update\" }, '*');\n    // For loop for applying button event handlers in case of using mobile slider buttons\n    this.prevButton.forEach((button) => {\n      button.removeAttribute('disabled');\n    });\n    this.nextButton.forEach((button) => {\n      button.removeAttribute('disabled');\n    });\n  }\n\n  setCurrentImage(elem) {\n    window.postMessage({ type: 'product_gallery', action: \"set_image\", media_id: elem.dataset.mediaId }, '*');\n    this.images.forEach(item => item.classList.remove('product-gallery__image--active'))\n    elem.classList.add('product-gallery__image--active')\n    elem.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'center' });\n    this.update()\n  }\n\n  setCurrentDot(elem) {\n    window.postMessage({ type: 'product_gallery', action: \"set_dot\" }, '*');\n    if (this.dots.length > 0) {\n    this.dots.forEach(item => item.classList.remove('product-gallery__nav-item--active'))\n    elem.classList.add('product-gallery__nav-item--active');\n    this.update()\n    }\n  }\n\n  setSlideCount(index) {\n    window.postMessage({ type: 'product_gallery', action: \"set_count\" }, '*');\n    let sliderCount = document.getElementById(\"sliderCount\");\n    if (sliderCount) {\n      document.getElementById(\"sliderCountCurrent\").textContent = index;\n    }\n  }\n\n  findCurrentIndex() {\n    if ($(\".product-gallery__images .filtered\").length > 0) {\n      return Array.from(this.filteredImages).findIndex(item => item.classList.contains('product-gallery__image--active'));\n    } else {\n      return Array.from(this.images).findIndex(item => item.classList.contains('product-gallery__image--active'));\n    }\n    \n  }\n\n  onButtonClick(event) {\n    event.preventDefault();\n    let index = this.findCurrentIndex();\n    let slideCount = this.images.length - 1;\n    if ($(\".product-gallery__images .filtered\").length > 0) {\n      slideCount = $(\".product-gallery__images #sliderCount\").attr(\"data-slides\") - 1;\n      slideCount = $(\".product-gallery__images .filtered\").length - 1;\n    }\n    if (event.currentTarget.name === 'next') {\n      if (index == slideCount) {\n        index = 0;\n      } else {\n        index++;\n      }\n      \n    } else {\n      if (index == 0) {\n        index = slideCount;\n      } else {\n      index--;\n      }\n    }\n\n    this.setSlideCount(index + 1);\n    \n    if ($(\".product-gallery__images .filtered\").length > 0) {\n      this.setCurrentImage(this.filteredImages[index]);\n      this.setCurrentDot(this.filteredDots[index]);\n    } else {\n      this.setCurrentImage(this.images[index]);\n      this.setCurrentDot(this.dots[index])\n    }\n    \n  }\n}\n\ncustomElements.define('product-gallery', ProductGallery);\n\n"],
  "mappings": "AAAA,MAAM,uBAAuB,WAAY,CACvC,aAAc,CACZ,MAAM,EACN,KAAK,KAAK,EAGa,IAAI,eAAe,SAAW,CACxC,SAAS,cAAc,iCAAiC,EAC9D,eAAe,CAAE,SAAU,SAAU,MAAO,UAAW,OAAQ,QAAS,CAAC,EAC9E,KAAK,OAAO,CACd,CAAC,EACc,QAAQ,IAAI,EAG3B,KAAK,SAAS,QAAQ,MAAQ,KAAK,iBAAiB,QAAS,KAAK,eAAe,KAAK,IAAI,CAAC,CAAC,EAI5F,KAAK,WAAW,QAAS,QAAW,CAClC,OAAO,iBAAiB,QAAS,KAAK,cAAc,KAAK,IAAI,CAAC,CAChE,CAAC,EACD,KAA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