{"version":3,"file":"Image360Modal.js","names":["Image360Modal","a","setters","Component","default","Event","on","off","deepMerge","execute","constructor","element","options","arguments","length","templateName","classNames","contentUrl","ariaLabel","bindEvents","openModal","bind","onProductUpdated","afterInit","analytics","display","emit","e","model","detail","data","preview360trigger","render","event","preventDefault","cssPath","container","virtualPageURL","virtualPageTitle","setTimeout","click","destroy"],"sources":["components/product/Image360Modal.js"],"sourcesContent":["import Component from 'core/Component';\nimport { Event } from 'services/EventEmitter';\nimport { on, off } from 'toolbox/event';\nimport { deepMerge } from 'toolbox/deepMerge';\n\n/**\n * This is a description of the Image360Modal constructor function.\n * @class\n * @classdesc This is a description of the Image360Modal class.\n * @extends Component\n */\nexport default class Image360Modal 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 templateName: 'product/preview360trigger',\n classNames: {},\n contentUrl: '',\n ariaLabel: null, // If defined, this copy will be used as the aria-label of a Modal\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 anonymous function\n */\n bindEvents() {\n on('click', this.element, this.openModal.bind(this));\n on('product.updated', this.element, this.onProductUpdated.bind(this));\n }\n\n /**\n * After init\n * Run any script after the component is fully initialized\n */\n afterInit() {\n if (this.analytics && this.analytics.display) {\n Event.emit('analytics.event', this.analytics.display);\n }\n }\n\n /**\n * Reload component on product update\n * @param {Object} e event object\n */\n onProductUpdated(e) {\n const model = e.detail.data && e.detail.data.preview360trigger;\n if (model) {\n this.render(model);\n }\n }\n\n /**\n * Open modal\n *\n * @param {Object} event Event object\n */\n openModal(event) {\n event.preventDefault();\n\n if (this.options.contentUrl) {\n Event.emit('modal.open', {\n options: {\n cssPath: 'image360.css',\n classNames: this.options.classNames || {\n container: ['m-image360'],\n },\n ariaLabel: this.options.ariaLabel,\n contentUrl: this.options.contentUrl,\n analytics: {\n virtualPageURL: '/quick-view{{pathname}}/product-images',\n virtualPageTitle: 'quick-view/product images',\n },\n },\n });\n }\n\n setTimeout(() => {\n if (this.analytics && this.analytics.click) {\n Event.emit('analytics.event', this.analytics.click);\n }\n }, 0);\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 off('click', this.element);\n off('product.updated', this.element);\n }\n}\n"],"mappings":"mJAWqBA,CAAa,QAAAC,CAAA,oBAAAC,OAAA,WAAAD,CAAA,EAX3BE,CAAS,CAAAF,CAAA,CAAAG,OAAA,WAAAH,CAAA,EACPI,CAAK,CAAAJ,CAAA,CAALI,KAAK,WAAAJ,CAAA,EACLK,CAAE,CAAAL,CAAA,CAAFK,EAAE,CAAEC,CAAG,CAAAN,CAAA,CAAHM,GAAG,WAAAN,CAAA,EACPO,CAAS,CAAAP,CAAA,CAATO,SAAS,GAAAC,OAAA,SAAAA,CAAA,EAAAR,CAAA,WAQGD,CAAa,CAAnB,aAA4B,CAAAG,CAAU,CAMjDO,WAAWA,CAACC,CAAO,CAAgB,IAAd,CAAAC,CAAO,GAAAC,SAAA,CAAAC,MAAA,WAAAD,SAAA,IAAAA,SAAA,IAAG,CAAC,CAAC,CAC7B,KAAK,CAACF,CAAO,CAAEH,CAAS,CAAC,CACrBO,YAAY,CAAE,2BAA2B,CACzCC,UAAU,CAAE,CAAC,CAAC,CACdC,UAAU,CAAE,EAAE,CACdC,SAAS,CAAE,IACf,CAAC,CAAEN,CAAO,CAAC,CACf,CAMAO,UAAUA,CAAA,CAAG,CACTb,CAAE,CAAC,OAAO,CAAE,IAAI,CAACK,OAAO,CAAE,IAAI,CAACS,SAAS,CAACC,IAAI,CAAC,IAAI,CAAC,CAAC,CACpDf,CAAE,CAAC,iBAAiB,CAAE,IAAI,CAACK,OAAO,CAAE,IAAI,CAACW,gBAAgB,CAACD,IAAI,CAAC,IAAI,CAAC,CACxE,CAMAE,SAASA,CAAA,CAAG,CACJ,IAAI,CA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