{"version":3,"file":"BazaarvoiceService.js","names":["BazaarvoiceService","a","setters","Component","default","deepMerge","Event","execute","constructor","element","options","arguments","length","productID","bindEvents","once","afterInit","loadService","emit","elementType","getAttribute","setAttribute","bvUserToken","meta","document","createElement","name","content","getElementsByTagName","appendChild","destroy","removeListener"],"sources":["components/product/BazaarvoiceService.js"],"sourcesContent":["import Component from 'core/Component';\nimport { deepMerge } from 'toolbox/deepMerge';\nimport { Event } from 'services/EventEmitter';\n\n/**\n * This is a description of the BazaarvoiceReviews constructor function.\n * @class\n * @classdesc This is a description of the BazaarvoiceReviews class\n * @extends Component\n */\nexport default class BazaarvoiceService extends Component {\n /**\n * Constructor of the class that mainly merge the options of the components\n * @param {HTMLElement} element HTMLElement of the component\n * @param {Object} options options that belongs to the component\n */\n constructor(element, options = {}) {\n super(element, deepMerge({\n productID: null,\n }, options));\n }\n\n /**\n * Should contain only event listeners and nothing else\n * All the event handlers should be into a separated function. No usage of anonyous function\n */\n bindEvents() {\n Event.once('BV.dependency.check', this.afterInit, this);\n }\n\n /**\n * After init\n * Run any script after the component is fully initialized\n */\n afterInit() {\n this.loadService();\n Event.emit('BV.dependency.loaded');\n }\n\n /**\n * Set product ID to load Bazaarvoice on demand\n */\n loadService() {\n if (this.options.productID) {\n const elementType = this.element.getAttribute('data-element-type');\n if (elementType) {\n this.element.setAttribute('data-bv-show', elementType);\n this.element.setAttribute('data-bv-product-id', this.options.productID);\n }\n }\n if ('bvUserToken' in this.options && this.options.bvUserToken) {\n const meta = document.createElement('meta');\n meta.name = 'bv:userToken';\n meta.content = this.options.bvUserToken;\n document.getElementsByTagName('head')[0].appendChild(meta);\n }\n }\n\n /**\n * Destroy is called automatically after the component is being removed from the DOM\n * You must always destroy the listeners attached to an element to avoid any memory leaks\n */\n destroy() {\n Event.removeListener('BV.dependency.check', this.afterInit, this);\n }\n}\n"],"mappings":"+HAUqBA,CAAkB,QAAAC,CAAA,oBAAAC,OAAA,WAAAD,CAAA,EAVhCE,CAAS,CA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