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AAW,SAAS,CAAC,GAAG,CAAC,UACzB,WAAW,WACV,EAAW,SAAS,CAAC,MAAM,CAAC,SAC7B,EAAG,MAGA,AAAU,UAAV,EAAE,GAAG,CAAc,CACtB,EAAE,cAAc,GAChB,IAAM,EAAe,EAAO,aAAa,CAAC,gBACpC,EAAa,EAAa,aAAa,CAAC,sBAC9C,GAAI,EACH,EAAW,KAAK,OACV,CACN,IAAM,EAAO,EAAa,aAAa,CAAC,KACpC,GACH,EAAK,KAAK,EAEZ,CACD,CACD,GAGA,IAAM,EAAS,EAAO,gBAAgB,CAAC,UACvC,EAAO,OAAO,CAAC,AAAC,IAEf,IAAM,EAAa,EAAM,aAAa,CAAC,sBAGvC,GAAI,EAAY,CACf,IAAM,EAAoB,EAAwB,EAAO,GACzD,EAAW,gBAAgB,CAAC,QAAS,EAAmB,CACvD,KAAM,CAAA,CACP,GACA,EAAM,WAAW,CAAC,EACnB,CACA,EAAgB,EAAG,EAAc,EAClC,EACD,EAcuB,EACtB,EACD,E","sources":["","acf-blocks/flickity-block/flickity-block.js"],"sourcesContent":["(function () {\n/* global Flickity */ /* eslint-disable @wordpress/no-global-active-element */ /**\n * Close the modal when the escape key is pressed\n *\n * @param {Event} event The keydown event\n * @param {Element} modal The current modal element\n * @param {Element} slide The slide that was clicked to open the modal\n * @param {Element} slider The whole slider element\n * @return {void}\n */ function $cefc2cd607eaf6c6$var$handleEscapeKey(event, modal, slide, slider) {\n if (event.key === 'Escape') $cefc2cd607eaf6c6$var$closeModal(modal, slide, slider);\n}\n/**\n * Close the modal when the button or overlay is clicked\n *\n * @param {Event} event The click event\n * @param {Element} modal The current modal element\n * @param {Element} slide The slide that was clicked to open the modal\n * @param {Element} slider The whole slider element\n * @return {void}\n */ function $cefc2cd607eaf6c6$var$handleModalClick(event, modal, slide, slider) {\n event.preventDefault();\n $cefc2cd607eaf6c6$var$closeModal(modal, slide, slider);\n}\n/**\n * Creates a closure to handle the play button click event.\n *\n * @param {Element} slide The slide element that contains the play button.\n * @param {Element} slider The whole slider element\n * @return {Function} The event handler function\n */ function $cefc2cd607eaf6c6$var$createPlayButtonHandler(slide, slider) {\n return function handlePlayButton(event) {\n event.preventDefault();\n const url = slide.dataset.linkedMedia;\n if (!url) return;\n // create the modal dialog element\n const modal = document.createElement('modal');\n modal.classList.add('paragon-media-modal');\n // create the media wrapper element\n const media = document.createElement('div');\n media.classList.add('media');\n // create the iframe element that will contain the video\n const iframe = document.createElement('iframe');\n iframe.setAttribute('frameborder', '0');\n iframe.setAttribute('allow', 'autoplay; encrypted-media;');\n iframe.setAttribute('allowfullscreen', 'true');\n // set the iframe src and extra attributes based on the media type\n const mediaType = url.includes('youtu') ? 'youtube' : 'vimeo';\n const videoId = url.split('/').pop();\n if (mediaType === 'youtube') iframe.setAttribute('src', 'https://www.youtube.com/embed/' + videoId + '?autoplay=1');\n if (mediaType === 'vimeo') {\n iframe.setAttribute('src', 'https://player.vimeo.com/video/' + videoId + '?autoplay=1');\n iframe.setAttribute('width', '100%');\n iframe.setAttribute('height', '100%');\n }\n media.appendChild(iframe);\n // add the media element that contains the video to the modal\n modal.appendChild(media);\n // create a close button for the modal\n const closeButton = document.createElement('button');\n closeButton.classList.add('close-button');\n closeButton.setAttribute('aria-label', 'Close');\n closeButton.innerHTML = '';\n closeButton.onclick = function(closeButtonEvent) {\n $cefc2cd607eaf6c6$var$handleModalClick(closeButtonEvent, modal, slide, slider);\n };\n modal.appendChild(closeButton);\n // listen for tab key presses to contain focus within the modal\n document.addEventListener('keydown', $cefc2cd607eaf6c6$var$containModalFocus, null, modal);\n // listen for clicks on the modal to close it\n modal.addEventListener('click', function(modalClickEvent) {\n $cefc2cd607eaf6c6$var$handleModalClick(modalClickEvent, modal, slide, slider);\n }, {\n once: true\n });\n // listen for the escape key to close the modal\n document.addEventListener('keydown', function(escapeKeyEvent) {\n $cefc2cd607eaf6c6$var$handleEscapeKey(escapeKeyEvent, modal, slide, slider);\n });\n // add the modal to the DOM\n document.body.appendChild(modal);\n // move focus to the iframe\n const embed = modal.querySelector('iframe');\n embed.focus();\n };\n}\n/**\n * Closes the modal, removes event listeners and sets focus back to the slider.\n *\n * @param {Element} modal The modal element to be removed.\n * @param {Element} slide The slide that was clicked to open the modal.\n * @param {Element} slider The slider element to set focus on.\n *\n * @return {void}\n */ function $cefc2cd607eaf6c6$var$closeModal(modal, slide, slider) {\n modal.remove();\n const playButton = slide.querySelector('.play-video-button');\n const playButtonHandler = $cefc2cd607eaf6c6$var$createPlayButtonHandler(slide, slider);\n // make sure the play button listener is only added once\n // this was a problem at one point, but it might not be necessary anymore\n playButton.removeEventListener('click', playButtonHandler);\n playButton.addEventListener('click', playButtonHandler, {\n once: true\n });\n document.removeEventListener('keydown', $cefc2cd607eaf6c6$var$handleEscapeKey);\n document.removeEventListener('keydown', $cefc2cd607eaf6c6$var$containModalFocus);\n slider.focus();\n}\n/**\n * Contains the focus within the modal when it's open.\n *\n * @param {Event} event The keydown event object.\n * @param {Element} modal The modal element to contain the focus within.\n *\n * @return {void}\n */ function $cefc2cd607eaf6c6$var$containModalFocus(event, modal) {\n if (!modal) return;\n const focusableElements = modal.querySelectorAll('iframe, button, [href], input, select, [tabindex]:not([tabindex=\"-1\"])');\n const firstFocusableElement = focusableElements[0];\n const lastFocusableElement = focusableElements[focusableElements.length - 1];\n if (event.key === 'Tab') {\n if (event.shiftKey) {\n if (document.activeElement === firstFocusableElement) {\n event.preventDefault();\n lastFocusableElement.focus();\n }\n } else if (document.activeElement === lastFocusableElement) {\n event.preventDefault();\n firstFocusableElement.focus();\n }\n }\n}\n/**\n * Sets the instructions for the current slide based on its content.\n *\n * This function checks if the current slide has a link or a play button and\n * updates the instructions accordingly.\n *\n * @param {number} slideIndex The index of the current slide.\n * @param {Element} instructions The element containing the instructions.\n * @param {NodeList} slides The list of all slides.\n * @return {void}\n */ function $cefc2cd607eaf6c6$var$setInstructions(slideIndex, instructions, slides) {\n const activateInstructions = instructions.querySelector('.instructions__activate');\n const activateAction = instructions.querySelector('.instructions__activate-action');\n const currentSlide = slides[slideIndex];\n // does the current slide have a link or a play button?\n const hasLink = currentSlide.querySelector('a');\n const hasPlayButton = currentSlide.querySelector('.play-video-button');\n if (hasLink) {\n activateInstructions.style.display = 'block';\n activateAction.textContent = ' to follow link';\n }\n if (hasPlayButton) {\n activateInstructions.style.display = 'block';\n activateAction.textContent = ' to play video';\n }\n if (!hasLink && !hasPlayButton) activateInstructions.style.display = 'none';\n}\n/**\n * Initializes a Flickity instance for a given block.\n *\n * This function sets up a Flickity slider with various options and event listeners.\n * It also sets up keyboard navigation for the slider.\n *\n * @param {Element} block The block element that contains the slider and its controls.\n * @return {void}\n */ function $cefc2cd607eaf6c6$var$initFlickityInstance(block) {\n const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)');\n const autoplay = prefersReducedMotion.matches ? false : 5000;\n const slider = block.querySelector('.paragon-flickity-block__slider');\n const instructions = block.querySelector('.paragon-flickity-instructions');\n // create the Flickity instance\n new Flickity(slider, {\n cellAlign: 'left',\n contain: true,\n prevNextButtons: true,\n pageDots: false,\n wrapAround: true,\n autoPlay: autoplay,\n imagesLoaded: true,\n percentPosition: false,\n on: {\n change (index) {\n $cefc2cd607eaf6c6$var$setInstructions(index, instructions, slides);\n }\n }\n });\n // we will hide the instructions when using the mouse\n slider.addEventListener('click', function() {\n slider.classList.add('mouse-interaction');\n });\n slider.addEventListener('keydown', function() {\n slider.classList.remove('mouse-interaction');\n });\n // make the slider focusable\n slider.setAttribute('tabindex', '0');\n // remove the tab index from the slider's children\n const tabbableElements = slider.querySelectorAll('a, button, input, select, [tabindex]:not([tabindex=\"-1\"])');\n tabbableElements.forEach((element)=>{\n element.setAttribute('tabindex', '-1');\n });\n // control the slider with the keyboard when it has focus\n const nextButton = slider.querySelector('.flickity-button.next');\n const prevButton = slider.querySelector('.flickity-button.previous');\n block.addEventListener('keydown', function(e) {\n // use arrow keys to navigate between slides\n if (e.key === 'ArrowLeft') {\n prevButton.classList.add('active');\n setTimeout(function() {\n prevButton.classList.remove('active');\n }, 200);\n } else if (e.key === 'ArrowRight') {\n nextButton.classList.add('active');\n setTimeout(function() {\n nextButton.classList.remove('active');\n }, 200);\n }\n // perform the default action for the slide when the enter key is pressed\n if (e.key === 'Enter') {\n e.preventDefault();\n const currentSlide = slider.querySelector('.is-selected');\n const playButton = currentSlide.querySelector('.play-video-button');\n if (playButton) playButton.click();\n else {\n const link = currentSlide.querySelector('a');\n if (link) link.click();\n }\n }\n });\n // set up the individual slides\n const slides = slider.querySelectorAll('.slide');\n slides.forEach((slide)=>{\n // the play button is created in the PHP template\n const playButton = slide.querySelector('.play-video-button');\n // if the slide has a play button, add a click listener to the play button\n if (playButton) {\n const playButtonHandler = $cefc2cd607eaf6c6$var$createPlayButtonHandler(slide, slider);\n playButton.addEventListener('click', playButtonHandler, {\n once: true\n });\n slide.appendChild(playButton);\n }\n $cefc2cd607eaf6c6$var$setInstructions(0, instructions, slides);\n });\n}\n/**\n * Initializes Flickity instances for all blocks on the page.\n *\n * @return {void}\n */ function $cefc2cd607eaf6c6$var$flickityBlockInit() {\n const sliderBlocks = document.querySelectorAll('[data-paragon=\"flickity-block\"]');\n // set up each slider as a new Flickity instance\n sliderBlocks.forEach((block)=>{\n $cefc2cd607eaf6c6$var$initFlickityInstance(block);\n });\n}\ndocument.addEventListener('DOMContentLoaded', $cefc2cd607eaf6c6$var$flickityBlockInit);\n\n})();\n//# sourceMappingURL=flickity-block.js.map\n","/* global Flickity */\n/* eslint-disable @wordpress/no-global-active-element */\n\n/**\n * Close the modal when the escape key is pressed\n *\n * @param {Event} event The keydown event\n * @param {Element} modal The current modal element\n * @param {Element} slide The slide that was clicked to open the modal\n * @param {Element} slider The whole slider element\n * @return {void}\n */\nfunction handleEscapeKey(event, modal, slide, slider) {\n\tif (event.key === 'Escape') {\n\t\tcloseModal(modal, slide, slider);\n\t}\n}\n\n/**\n * Close the modal when the button or overlay is clicked\n *\n * @param {Event} event The click event\n * @param {Element} modal The current modal element\n * @param {Element} slide The slide that was clicked to open the modal\n * @param {Element} slider The whole slider element\n * @return {void}\n */\nfunction handleModalClick(event, modal, slide, slider) {\n\tevent.preventDefault();\n\tcloseModal(modal, slide, slider);\n}\n\n/**\n * Creates a closure to handle the play button click event.\n *\n * @param {Element} slide The slide element that contains the play button.\n * @param {Element} slider The whole slider element\n * @return {Function} The event handler function\n */\nfunction createPlayButtonHandler(slide, slider) {\n\treturn function handlePlayButton(event) {\n\t\tevent.preventDefault();\n\n\t\tconst url = slide.dataset.linkedMedia;\n\t\tif (!url) {\n\t\t\treturn;\n\t\t}\n\n\t\t// create the modal dialog element\n\t\tconst modal = document.createElement('modal');\n\t\tmodal.classList.add('paragon-media-modal');\n\n\t\t// create the media wrapper element\n\t\tconst media = document.createElement('div');\n\t\tmedia.classList.add('media');\n\n\t\t// create the iframe element that will contain the video\n\t\tconst iframe = document.createElement('iframe');\n\t\tiframe.setAttribute('frameborder', '0');\n\t\tiframe.setAttribute('allow', 'autoplay; encrypted-media;');\n\t\tiframe.setAttribute('allowfullscreen', 'true');\n\n\t\t// set the iframe src and extra attributes based on the media type\n\t\tconst mediaType = url.includes('youtu') ? 'youtube' : 'vimeo';\n\t\tconst videoId = url.split('/').pop();\n\t\tif (mediaType === 'youtube') {\n\t\t\tiframe.setAttribute(\n\t\t\t\t'src',\n\t\t\t\t'https://www.youtube.com/embed/' + videoId + '?autoplay=1'\n\t\t\t);\n\t\t}\n\t\tif (mediaType === 'vimeo') {\n\t\t\tiframe.setAttribute(\n\t\t\t\t'src',\n\t\t\t\t'https://player.vimeo.com/video/' + videoId + '?autoplay=1'\n\t\t\t);\n\t\t\tiframe.setAttribute('width', '100%');\n\t\t\tiframe.setAttribute('height', '100%');\n\t\t}\n\t\tmedia.appendChild(iframe);\n\n\t\t// add the media element that contains the video to the modal\n\t\tmodal.appendChild(media);\n\n\t\t// create a close button for the modal\n\t\tconst closeButton = document.createElement('button');\n\t\tcloseButton.classList.add('close-button');\n\t\tcloseButton.setAttribute('aria-label', 'Close');\n\t\tcloseButton.innerHTML =\n\t\t\t'';\n\t\tcloseButton.onclick = function (closeButtonEvent) {\n\t\t\thandleModalClick(closeButtonEvent, modal, slide, slider);\n\t\t};\n\t\tmodal.appendChild(closeButton);\n\n\t\t// listen for tab key presses to contain focus within the modal\n\t\tdocument.addEventListener('keydown', containModalFocus, null, modal);\n\n\t\t// listen for clicks on the modal to close it\n\t\tmodal.addEventListener(\n\t\t\t'click',\n\t\t\tfunction (modalClickEvent) {\n\t\t\t\thandleModalClick(modalClickEvent, modal, slide, slider);\n\t\t\t},\n\t\t\t{ once: true }\n\t\t);\n\n\t\t// listen for the escape key to close the modal\n\t\tdocument.addEventListener('keydown', function (escapeKeyEvent) {\n\t\t\thandleEscapeKey(escapeKeyEvent, modal, slide, slider);\n\t\t});\n\n\t\t// add the modal to the DOM\n\t\tdocument.body.appendChild(modal);\n\n\t\t// move focus to the iframe\n\t\tconst embed = modal.querySelector('iframe');\n\t\tembed.focus();\n\t};\n}\n\n/**\n * Closes the modal, removes event listeners and sets focus back to the slider.\n *\n * @param {Element} modal The modal element to be removed.\n * @param {Element} slide The slide that was clicked to open the modal.\n * @param {Element} slider The slider element to set focus on.\n *\n * @return {void}\n */\nfunction closeModal(modal, slide, slider) {\n\tmodal.remove();\n\n\tconst playButton = slide.querySelector('.play-video-button');\n\tconst playButtonHandler = createPlayButtonHandler(slide, slider);\n\t// make sure the play button listener is only added once\n\t// this was a problem at one point, but it might not be necessary anymore\n\tplayButton.removeEventListener('click', playButtonHandler);\n\tplayButton.addEventListener('click', playButtonHandler, { once: true });\n\n\tdocument.removeEventListener('keydown', handleEscapeKey);\n\tdocument.removeEventListener('keydown', containModalFocus);\n\tslider.focus();\n}\n\n/**\n * Contains the focus within the modal when it's open.\n *\n * @param {Event} event The keydown event object.\n * @param {Element} modal The modal element to contain the focus within.\n *\n * @return {void}\n */\nfunction containModalFocus(event, modal) {\n\tif (!modal) {\n\t\treturn;\n\t}\n\n\tconst focusableElements = modal.querySelectorAll(\n\t\t'iframe, button, [href], input, select, [tabindex]:not([tabindex=\"-1\"])'\n\t);\n\tconst firstFocusableElement = focusableElements[0];\n\tconst lastFocusableElement =\n\t\tfocusableElements[focusableElements.length - 1];\n\tif (event.key === 'Tab') {\n\t\tif (event.shiftKey) {\n\t\t\tif (document.activeElement === firstFocusableElement) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tlastFocusableElement.focus();\n\t\t\t}\n\t\t} else if (document.activeElement === lastFocusableElement) {\n\t\t\tevent.preventDefault();\n\t\t\tfirstFocusableElement.focus();\n\t\t}\n\t}\n}\n\n/**\n * Sets the instructions for the current slide based on its content.\n *\n * This function checks if the current slide has a link or a play button and\n * updates the instructions accordingly.\n *\n * @param {number} slideIndex The index of the current slide.\n * @param {Element} instructions The element containing the instructions.\n * @param {NodeList} slides The list of all slides.\n * @return {void}\n */\nfunction setInstructions(slideIndex, instructions, slides) {\n\tconst activateInstructions = instructions.querySelector(\n\t\t'.instructions__activate'\n\t);\n\tconst activateAction = instructions.querySelector(\n\t\t'.instructions__activate-action'\n\t);\n\tconst currentSlide = slides[slideIndex];\n\t// does the current slide have a link or a play button?\n\tconst hasLink = currentSlide.querySelector('a');\n\tconst hasPlayButton = currentSlide.querySelector('.play-video-button');\n\tif (hasLink) {\n\t\tactivateInstructions.style.display = 'block';\n\t\tactivateAction.textContent = ' to follow link';\n\t}\n\tif (hasPlayButton) {\n\t\tactivateInstructions.style.display = 'block';\n\t\tactivateAction.textContent = ' to play video';\n\t}\n\tif (!hasLink && !hasPlayButton) {\n\t\tactivateInstructions.style.display = 'none';\n\t}\n}\n\n/**\n * Initializes a Flickity instance for a given block.\n *\n * This function sets up a Flickity slider with various options and event listeners.\n * It also sets up keyboard navigation for the slider.\n *\n * @param {Element} block The block element that contains the slider and its controls.\n * @return {void}\n */\nfunction initFlickityInstance(block) {\n\tconst prefersReducedMotion = window.matchMedia(\n\t\t'(prefers-reduced-motion: reduce)'\n\t);\n\tconst autoplay = prefersReducedMotion.matches ? false : 5000;\n\n\tconst slider = block.querySelector('.paragon-flickity-block__slider');\n\tconst instructions = block.querySelector('.paragon-flickity-instructions');\n\n\t// create the Flickity instance\n\tnew Flickity(slider, {\n\t\tcellAlign: 'left',\n\t\tcontain: true,\n\t\tprevNextButtons: true,\n\t\tpageDots: false,\n\t\twrapAround: true,\n\t\tautoPlay: autoplay,\n\t\timagesLoaded: true,\n\t\tpercentPosition: false,\n\t\ton: {\n\t\t\tchange(index) {\n\t\t\t\tsetInstructions(index, instructions, slides);\n\t\t\t},\n\t\t},\n\t});\n\n\t// we will hide the instructions when using the mouse\n\tslider.addEventListener('click', function () {\n\t\tslider.classList.add('mouse-interaction');\n\t});\n\tslider.addEventListener('keydown', function () {\n\t\tslider.classList.remove('mouse-interaction');\n\t});\n\n\t// make the slider focusable\n\tslider.setAttribute('tabindex', '0');\n\n\t// remove the tab index from the slider's children\n\tconst tabbableElements = slider.querySelectorAll(\n\t\t'a, button, input, select, [tabindex]:not([tabindex=\"-1\"])'\n\t);\n\ttabbableElements.forEach((element) => {\n\t\telement.setAttribute('tabindex', '-1');\n\t});\n\n\t// control the slider with the keyboard when it has focus\n\tconst nextButton = slider.querySelector('.flickity-button.next');\n\tconst prevButton = slider.querySelector('.flickity-button.previous');\n\tblock.addEventListener('keydown', function (e) {\n\t\t// use arrow keys to navigate between slides\n\t\tif (e.key === 'ArrowLeft') {\n\t\t\tprevButton.classList.add('active');\n\t\t\tsetTimeout(function () {\n\t\t\t\tprevButton.classList.remove('active');\n\t\t\t}, 200);\n\t\t} else if (e.key === 'ArrowRight') {\n\t\t\tnextButton.classList.add('active');\n\t\t\tsetTimeout(function () {\n\t\t\t\tnextButton.classList.remove('active');\n\t\t\t}, 200);\n\t\t}\n\t\t// perform the default action for the slide when the enter key is pressed\n\t\tif (e.key === 'Enter') {\n\t\t\te.preventDefault();\n\t\t\tconst currentSlide = slider.querySelector('.is-selected');\n\t\t\tconst playButton = currentSlide.querySelector('.play-video-button');\n\t\t\tif (playButton) {\n\t\t\t\tplayButton.click();\n\t\t\t} else {\n\t\t\t\tconst link = currentSlide.querySelector('a');\n\t\t\t\tif (link) {\n\t\t\t\t\tlink.click();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n\n\t// set up the individual slides\n\tconst slides = slider.querySelectorAll('.slide');\n\tslides.forEach((slide) => {\n\t\t// the play button is created in the PHP template\n\t\tconst playButton = slide.querySelector('.play-video-button');\n\n\t\t// if the slide has a play button, add a click listener to the play button\n\t\tif (playButton) {\n\t\t\tconst playButtonHandler = createPlayButtonHandler(slide, slider);\n\t\t\tplayButton.addEventListener('click', playButtonHandler, {\n\t\t\t\tonce: true,\n\t\t\t});\n\t\t\tslide.appendChild(playButton);\n\t\t}\n\t\tsetInstructions(0, instructions, slides);\n\t});\n}\n\n/**\n * Initializes Flickity instances for all blocks on the page.\n *\n * @return {void}\n */\nfunction flickityBlockInit() {\n\tconst sliderBlocks = document.querySelectorAll(\n\t\t'[data-paragon=\"flickity-block\"]'\n\t);\n\n\t// set up each slider as a new Flickity instance\n\tsliderBlocks.forEach((block) => {\n\t\tinitFlickityInstance(block);\n\t});\n}\n\ndocument.addEventListener('DOMContentLoaded', flickityBlockInit);\n"],"names":["$cefc2cd607eaf6c6$var$handleEscapeKey","event","modal","slide","slider","key","$cefc2cd607eaf6c6$var$closeModal","$cefc2cd607eaf6c6$var$handleModalClick","preventDefault","$cefc2cd607eaf6c6$var$createPlayButtonHandler","url","dataset","linkedMedia","document","createElement","classList","add","media","iframe","setAttribute","mediaType","includes","videoId","split","pop","appendChild","closeButton","innerHTML","onclick","closeButtonEvent","addEventListener","$cefc2cd607eaf6c6$var$containModalFocus","modalClickEvent","once","escapeKeyEvent","body","embed","querySelector","focus","remove","playButton","playButtonHandler","removeEventListener","focusableElements","querySelectorAll","firstFocusableElement","lastFocusableElement","length","shiftKey","activeElement","$cefc2cd607eaf6c6$var$setInstructions","slideIndex","instructions","slides","activateInstructions","activateAction","currentSlide","hasLink","hasPlayButton","style","display","textContent","sliderBlocks","forEach","block","$cefc2cd607eaf6c6$var$initFlickityInstance","autoplay","prefersReducedMotion","window","matchMedia","matches","Flickity","cellAlign","contain","prevNextButtons","pageDots","wrapAround","autoPlay","imagesLoaded","percentPosition","on","change","index","tabbableElements","element","nextButton","prevButton","e","setTimeout","click","link"],"version":3,"file":"flickity-block.js.map"}