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KAAM,QACxC,UAACC,YAAD,iBAAC,EAAMC,gBAAP,OAAC,EAAgBC,SAIrBJ,OAAOK,cAAcN,GACrBD,OACC,QAGLI,KAAKC,SAASC,OAAO,wBAAyBE,KAQ/C,SAA8BA,GAC7B,MAAMC,EAAU/C,SAASI,cAAc,4BAElC2C,GAIDC,SAASD,EAAQE,QAAQC,GAAI,MAAQJ,EAAOK,SAASD,KAIzDH,EAAQE,QAAQC,GAAKJ,EAAOK,SAASD,GAUtC,SAAiBE,GACd,MAAMC,EAAOrD,SAASsD,qBAAqB,QAAQ,GAC7B,IAAID,EAAKE,UAAUC,QAAOC,GAAWA,EAAQL,MAAQA,IAC7DM,SAAQC,IACpBA,EAAOC,WAAWC,YAAYF,MAGhC,MAAMA,EAAS3D,SAAS8D,cAAc,UACtCH,EAAOP,IAAMA,EACbC,EAAKU,YAAYJ,GAKjB5B,IApBFiC,CAHgB,IAAIhE,SAASiE,SACEC,MAAKP,GAAUA,EAAOP,IAAIe,SAAS,oBAE3Cf,MAtBrBgB,CAAqBtB,MAhDtBuB,OCvBFC,GAAiBvC,U","sources":["webpack:///../../../../../src/scripts/helpers/svg-map.js","webpack:///../../../../../src/scripts/components/reviews-section.js","webpack:///../../../../../src/scripts/templates/product.@.js"],"sourcesContent":["export const bag = ''\n\nexport const leftArrow = 'Arrow left icon'\n\nexport const rightArrow = ''\n","/**\n * Component: Reviews Section\n * ------------------------------------------------------------------------------\n * Scripts for the shopify reviews section, loaded as an app block outside Vue.\n *\n */\nimport { rightArrow, leftArrow } from '~/helpers/svg-map'\n\n/**\n * DOM selectors.\n */\n const selectors = {\n section: '[js-reviews-section=\"section\"]',\n newReviewButton: '.spr-summary-actions-newreview',\n }\n\n /**\n * Create a reviews section object.\n */\n export default () => {\n\n /**\n * DOM node selectors.\n */\n const nodeSelectors = {\n section: document.querySelector(selectors.section),\n }\n\n /**\n * Initialise component.\n */\n function init() {\n setMutationObserver()\n addEventBusListeners()\n }\n\n /**\n * Watch for app content being injected.\n */\n function setMutationObserver() {\n const targetNode = nodeSelectors.section\n if (!targetNode) {\n return\n }\n\n const config = { attributes: true, childList: true, subtree: true }\n const callback = (mutationList, observer) => {\n for (const mutation of mutationList) {\n if (mutation.type === 'childList') {\n const nodes = [...mutation.addedNodes]\n\n if (!nodes?.length) {\n continue\n }\n observer.disconnect()\n sectionLoaded()\n return\n }\n }\n }\n\n const observer = new MutationObserver(callback)\n observer.observe(targetNode, config)\n }\n\n /**\n * Adds event bus listeners.\n */\n async function addEventBusListeners() {\n await new Promise((resolve) => {\n const cnvsInterval = window.setInterval(() => {\n if (!cnvs?.EventBus?.listen) {\n return\n }\n\n window.clearInterval(cnvsInterval)\n resolve()\n }, 200)\n })\n\n cnvs.EventBus.listen('cnvs:product-updated', (update) => {\n handleProductUpdated(update)\n })\n }\n\n /**\n * Adds arrows to the pagination links instead of the text.\n */\n function handleProductUpdated(update) {\n const reviews = document.querySelector('#shopify-product-reviews')\n\n if (!reviews) {\n return\n }\n\n if (parseInt(reviews.dataset.id, 10) === update.response.id) {\n return\n }\n\n reviews.dataset.id = update.response.id\n const scripts = [...document.scripts]\n const productReviews = scripts.find(script => script.src.includes('productreviews'))\n\n load_js(productReviews.src)\n }\n\n /**\n * Reloads the shopify product reviews script.\n */\n function load_js(src) {\n const head = document.getElementsByTagName('head')[0]\n const reviewScripts = [...head.children].filter(element => element.src === src)\n reviewScripts.forEach(script => {\n script.parentNode.removeChild(script)\n })\n\n const script = document.createElement('script')\n script.src = src\n head.appendChild(script)\n\n /**\n * Re-initialise this script when the product updates.\n */\n init()\n }\n\n /**\n * Adds arrows to the pagination links instead of the text.\n */\n function addPaginationArrows() {\n const previous = document.querySelector('.spr-pagination-prev > a')\n const next = document.querySelector('.spr-pagination-next > a')\n\n if (previous) {\n previous.innerHTML = leftArrow\n }\n\n if (next) {\n next.innerHTML = rightArrow\n }\n }\n\n /**\n * Run all manipulation functions when the app content has been injected.\n */\n function sectionLoaded(setObserver = true) {\n const newReviewBtn = nodeSelectors.section.querySelector(selectors.newReviewButton)\n nodeSelectors.newReviewBtn = newReviewBtn\n\n addButtonClasses()\n addIconToButton()\n addPaginationArrows()\n\n if (!setObserver) {\n return\n }\n setReviewsObservationObserver()\n }\n\n /**\n * Adds another mutation observer to listener for pagination updates.\n */\n function setReviewsObservationObserver() {\n const targetNode = document.querySelector('.spr-reviews')\n if (!targetNode) {\n return\n }\n\n const config = { attributes: true, childList: true, subtree: true }\n\n const callback = (mutationList) => {\n for (const mutation of mutationList) {\n if (mutation.type === 'childList') {\n addPaginationArrows()\n observer.disconnect()\n setReviewsObservationObserver()\n return\n }\n }\n }\n\n\n const observer = new MutationObserver(callback)\n observer.observe(targetNode, config)\n }\n\n /**\n * Make the new review link a button element.\n */\n function addButtonClasses() {\n if (!nodeSelectors.newReviewBtn) {\n return\n }\n\n nodeSelectors.newReviewBtn.classList.add('button')\n }\n\n /**\n * Adds an arrow to the new review button.\n */\n function addIconToButton() {\n if (!nodeSelectors.newReviewBtn) {\n return\n }\n\n nodeSelectors.newReviewBtn.insertAdjacentHTML('beforeend', rightArrow)\n }\n\n /**\n * Expose public interface.\n */\n return Object.freeze({\n init,\n })\n }\n","/**\n * Template: Products\n * -----------------------------------------------------------------------------\n * Used to import styles for all product templates.\n *\n */\n\n import ReviewsSection from '~/components/reviews-section'\n\n document.addEventListener('DOMContentLoaded', () => {\n ReviewsSection().init()\n })\n"],"names":["rightArrow","selectors","document","addEventListener","nodeSelectors","section","querySelector","addPaginationArrows","previous","next","innerHTML","sectionLoaded","setObserver","newReviewBtn","addButtonClasses","addIconToButton","setReviewsObservationObserver","targetNode","observer","MutationObserver","mutationList","mutation","type","disconnect","observe","attributes","childList","subtree","classList","add","insertAdjacentHTML","Object","freeze","init","nodes","addedNodes","length","setMutationObserver","async","Promise","resolve","cnvsInterval","window","setInterval","cnvs","EventBus","listen","clearInterval","update","reviews","parseInt","dataset","id","response","src","head","getElementsByTagName","children","filter","element","forEach","script","parentNode","removeChild","createElement","appendChild","load_js","scripts","find","includes","handleProductUpdated","addEventBusListeners","ReviewsSection"],"sourceRoot":""}