(function(){"use strict";function v(t){C(t,"form",a=>a.onsubmit=()=>!1)}function C(t,a,i){Array.from(document.querySelectorAll(t)).map(n=>n.closest(a)??n.querySelector(a)).filter((n,r,o)=>!!n&&o.indexOf(n)===r).forEach(i)}async function d(t,a="module"){return new Promise(i=>{const n=document.createElement("script");n.type=a,n.src=t,n.onload=i,document.head.appendChild(n)})}async function _(t){return new Promise(a=>document.addEventListener(t,a))}async function S(t,a){var i;await d("https://assets.motive.co/wysiwyg/wysiwyg.js"),await((i=window.wysiwyg)==null?void 0:i.setConfig({auth:{baseUrl:"https://iam.motive.co",clientId:"wysiwyg"},analytics:{baseUrl:"https://statistics.api.motive.co"},catalog:{baseUrl:"https://analytics.api.motive.co"},search:{baseUrl:"https://search-platform.motive.co"},instance:t,lang:a,playboardUrl:"https://playboard.motive.co",audience:"sme",appContainerSelector:"#motive-container",searchLayerSelector:"#motive-x"}))}function T(){const t=new URL(location.href).searchParams.get("mot_tcid")??"";t&&(history.pushState=function(a,i,n){n=new URL(n),n.searchParams.set("mot_tcid",t),Object.getPrototypeOf(history).pushState.call(history,a,i,n.href)})}function E(t){t.initParams.callbacks={UserClickedResultAddToCart:U,CartHandlerGettingCartInfo:k}}let p=0;async function U(t,a={}){var m,l,h,w,y,f;const i=((h=(l=(m=window.prestashop)==null?void 0:m.urls)==null?void 0:l.pages)==null?void 0:h.cart)??"",n=!i,[r,o=(y=(w=t.variants)==null?void 0:w[0])==null?void 0:y.id]=t.id.split("-"),c=Math.max(((f=t.availability)==null?void 0:f.minimumQuantity)??1,a.quantity??1,1),s=new URL(i||window.baseUri,location.href);s.searchParams.set("mot_tcid",t.tagging.add2cart.params.clickId),n&&s.searchParams.set("rand",`${Date.now()}`);const q=n?{ajax:!0,controller:"cart",ipa:o,token:window.static_token}:{action:"update",id_product_attribute:o,token:window.prestashop.static_token};return new Promise((P,b)=>{$.ajax({type:"POST",url:s.href,headers:{"cache-control":"no-cache"},cache:!1,data:{id_product:r,id_customization:void 0,qty:c,add:1,...q},dataType:"json",error(e){b(new Error("Failed to add product to cart.")),window.prestashop.emit("handleError",{eventType:"addProductToCart",resp:e})},success(e){var g;if("nbTotalProducts"in e){p=e.nbTotalProducts,(g=window.ajaxCart)==null||g.updateCart(e),e.hasError?b(new Error("Failed to add product to cart.")):P();return}P(),window.prestashop.emit("updateCart",{eventType:"updateCart",reason:{idProduct:e.id_product,idProductAttribute:e.id_product_attribute,idCustomization:e.id_customization,linkAction:"add-to-cart",cart:e.cart},resp:e})}})})}function k(){var t,a,i;return{productsCount:((a=(t=window.prestashop)==null?void 0:t.cart)==null?void 0:a.products_count)??((i=window.ajaxCart)==null?void 0:i.nb_total_products)??p}}const R=t=>t.map(({id:a,variants:i})=>i?{id:a,variants:i.map(({id:n})=>({id:n}))}:{id:a});function x(t){function a(i){i.price&&(i.price.originalValue*=t,i.price.value*=t)}return function(i){return i.forEach(n=>{a(n),n.variants&&n.variants.forEach(a)}),i}}let u="";function j(t){const{options:a,initParams:i,endpoint:n}=t;if(!a.showPrices)return;const r=new URL(n);r.searchParams.append("action","shopperPrices"),u=r.href,i.callbacks.AppendedResultsChanged=i.callbacks.RecommendationsChanged=a.shopperPrices?A:x(a.priceRates.static),i.transformPriceRange=(o,c)=>[o*a.priceRates.min,c*a.priceRates.max]}async function A(t){const a=await fetch(u,{method:"POST",body:JSON.stringify(R(t)),headers:{"Content-Type":"application/json"}});return I(await a.json())}function I(t){return t.forEach(a=>{var i,n;(i=a.availability)!=null&&i.minimal_quantity&&(a.availability.minimumQuantity=(n=a.availability)==null?void 0:n.minimal_quantity)}),t}async function L(){const t=motive??await _("DOMContentLoaded").then(()=>motive);((t==null?void 0:t.initParams.triggerSelector)??"")&&(T(),await O(t),await S(t.initParams.xEngineId,t.initParams.lang))}async function O(t){window.initX=function(){return v(t.initParams.triggerSelector),E(t),j(t),t.initParams.variantAddToCart="SINGLE",t.initParams},await d(t.motive_x_url)}L()})();