"use strict";(self.contorionJsonp=self.contorionJsonp||[]).push([[274],{7664:function(e,t,n){n.r(t),n.d(t,{ImageNavigationComponentV2:function(){return s}});var r,i=n(5457),o=(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),a=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}s((r=r.apply(e,t||[])).next())}))},c=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(c){return function(s){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=0,i&&(c=[2&c[0],i.value]),c[0]){case 0:case 1:i=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!i||c[1]>i[0]&&c[1]<i[3])){a.label=c[1];break}if(6===c[0]&&a.label<i[1]){a.label=i[1],i=c;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(c);break}i[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],r=0}finally{n=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}},s=function(e){function t(t){var n=e.call(this,t)||this;return n.element=t,n.init(),n}return o(t,e),Object.defineProperty(t.prototype,"navigationButtons",{get:function(){return(0,i.Rm)("button",this.element)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"maxNavIndex",{get:function(){return this.element.dataset.maxNavIndex?parseInt(this.element.dataset.maxNavIndex,10)-1:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"imageCount",{get:function(){return parseInt(this.element.dataset.imageCount,10)},enumerable:!1,configurable:!0}),t.prototype.init=function(){return a(this,void 0,void 0,(function(){var e,t;return c(this,(function(n){switch(n.label){case 0:return[4,this.loadServices()];case 1:for(n.sent(),e=0,t=this.navigationButtons;e<t.length;e++)t[e].addEventListener("click",this.onClick.bind(this));return this.videoService.subscribeIsAvailable(this.onVideoAvailabilityChange.bind(this)),[2]}}))}))},t.prototype.loadServices=function(){return a(this,void 0,void 0,(function(){var e,t;return c(this,(function(n){switch(n.label){case 0:return e=this,[4,i.uZ.get("image-service")];case 1:return e.imageService=n.sent(),t=this,[4,i.uZ.get("video-service")];case 2:return t.videoService=n.sent(),[2]}}))}))},t.prototype.onClick=function(e){e.preventDefault();var t=e.currentTarget,n=this.imageService.currentImageIndex;t.dataset.hasOwnProperty("prev")?(n--,this.imageService.imagesOverlay.has(n)||(n=this.getPrevAvailableIndex(n),this.maxNavIndex&&(n=Math.min(n,this.maxNavIndex-1)))):t.dataset.hasOwnProperty("next")&&(n++,this.maxNavIndex&&(n=n>=this.maxNavIndex?0:n),this.imageService.imagesOverlay.has(n)||(n=this.getNextAvailableIndex(n))),this.imageService.setCurrentImage(this.imageService.imagesPreview.get(n)),this.imageService.setCurrentImageThumbnail(this.imageService.imagesThumbnail.get(n)),this.imageService.setCurrentImageOverlay(this.imageService.imagesOverlay.get(n));var r=(0,i.bG)(".".concat("js-overlay-thumb",'[src="').concat(this.imageService.getCurrentImageThumbnail(),'"]'));null==r||r.scrollIntoView()},t.prototype.onVideoAvailabilityChange=function(e){(this.imageCount>1||e&&1===this.imageCount)&&this.element.classList.remove("hidden")},t.prototype.getNextAvailableIndex=function(e){var t=(0,i.E2)(this.imageService.imagesOverlay);if(e>t[t.length-1])return t[0];for(var n=0,r=t;n<r.length;n++){var o=r[n];if(!(o<=e))return o}},t.prototype.getPrevAvailableIndex=function(e){var t=(0,i.E2)(this.imageService.imagesOverlay);if(e<t[0])return t[t.length-1];for(var n=0,r=t.reverse();n<r.length;n++){var o=r[n];if(!(o>=e))return o}},t}(i.wA)},3622:function(e,t,n){n.r(t),n.d(t,{ImageNavigationComponent:function(){return s}});var r,i=n(5457),o=(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),a=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}s((r=r.apply(e,t||[])).next())}))},c=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(c){return function(s){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=0,i&&(c=[2&c[0],i.value]),c[0]){case 0:case 1:i=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!i||c[1]>i[0]&&c[1]<i[3])){a.label=c[1];break}if(6===c[0]&&a.label<i[1]){a.label=i[1],i=c;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(c);break}i[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],r=0}finally{n=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}},s=function(e){function t(t){var n=e.call(this,t)||this;return n.element=t,n.init(),n}return o(t,e),Object.defineProperty(t.prototype,"navigationButtons",{get:function(){return(0,i.Rm)("button",this.element)},enumerable:!1,configurable:!0}),t.prototype.init=function(){return a(this,void 0,void 0,(function(){var e,t;return c(this,(function(n){switch(n.label){case 0:return[4,this.loadServices()];case 1:for(n.sent(),e=0,t=this.navigationButtons;e<t.length;e++)t[e].addEventListener("click",this.onClick.bind(this));return[2]}}))}))},t.prototype.loadServices=function(){return a(this,void 0,void 0,(function(){var e;return c(this,(function(t){switch(t.label){case 0:return e=this,[4,i.uZ.get("image-service")];case 1:return e.imageService=t.sent(),[2]}}))}))},t.prototype.onClick=function(e){e.preventDefault();var t=e.currentTarget,n=this.imageService.currentImageIndex;t.dataset.hasOwnProperty("prev")?(n--,this.imageService.imagesOverlay.has(n)||(n=this.getPrevAvailableIndex(n))):t.dataset.hasOwnProperty("next")&&(n++,this.imageService.imagesOverlay.has(n)||(n=this.getNextAvailableIndex(n))),this.imageService.setCurrentImage(this.imageService.imagesPreview.get(n)),this.imageService.setCurrentImageThumbnail(this.imageService.imagesThumbnail.get(n)),this.imageService.setCurrentImageOverlay(this.imageService.imagesOverlay.get(n))},t.prototype.getNextAvailableIndex=function(e){var t=Array.from(this.imageService.imagesOverlay.keys());if(e>t[t.length-1])return t[0];for(var n=0,r=t;n<r.length;n++){var i=r[n];if(!(i<=e))return i}},t.prototype.getPrevAvailableIndex=function(e){var t=Array.from(this.imageService.imagesOverlay.keys());if(e<t[0])return t[t.length-1];for(var n=0,r=t.reverse();n<r.length;n++){var i=r[n];if(!(i>=e))return i}},t}(i.wA)},4208:function(e,t,n){n.r(t),n.d(t,{ImageThumbnailComponent:function(){return u}});var r,i=n(5457),o=(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),a=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function c(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}s((r=r.apply(e,t||[])).next())}))},c=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(c){return function(s){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=0,i&&(c=[2&c[0],i.value]),c[0]){case 0:case 1:i=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!i||c[1]>i[0]&&c[1]<i[3])){a.label=c[1];break}if(6===c[0]&&a.label<i[1]){a.label=i[1],i=c;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(c);break}i[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],r=0}finally{n=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}},s="active",u=function(e){function t(t){var n=e.call(this,t)||this;return n.element=t,n.init(),n}return o(t,e),t.prototype.isFirstThumbnail=function(){return void 0!==this.element.dataset.isFirst},Object.defineProperty(t.prototype,"thumbnailImage",{get:function(){return(0,i.bG)("img",this.element)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"source",{get:function(){return this.element.dataset.src},enumerable:!1,configurable:!0}),t.prototype.init=function(){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.loadServices()];case 1:return e.sent(),this.bindEvents(),this.isFirstThumbnail()&&this.onImageSrcChange(this.source),[2]}}))}))},t.prototype.loadServices=function(){return a(this,void 0,void 0,(function(){var e;return c(this,(function(t){switch(t.label){case 0:return e=this,[4,i.uZ.get("image-service")];case 1:return e.imageService=t.sent(),[2]}}))}))},t.prototype.bindEvents=function(){this.element.addEventListener("click",this.onClick.bind(this)),this.imageService.subscribeCurrentImageThumbnail(this.onImageSrcChange.bind(this))},t.prototype.onClick=function(e){e.preventDefault();var t=e.currentTarget,n=(0,i.bG)("img",t),r=this.imageService.findIndexInArray(this.imageService.imagesThumbnail,n.src);this.imageService.setCurrentImage(this.imageService.imagesPreview.get(r)),this.imageService.setCurrentImageThumbnail(this.imageService.imagesThumbnail.get(r)),this.imageService.setCurrentImageOverlay(this.imageService.imagesOverlay.get(r))},t.prototype.onImageSrcChange=function(e){var t;e===(null===(t=this.thumbnailImage)||void 0===t?void 0:t.src)?this.element.classList.add(s):this.element.classList.remove(s)},t}(i.wA)}}]); //# sourceMappingURL=product-image-thumbnail.c0c94285d575fcf9b2de.contorion.js.map