(()=>{let r="_wulastsession",a="webtracking",u="https://tracking.woowup.com/web-tracking/track";function i(e,t,n,r){k.config=Object.assign({},v,k.config),k._publicKey=e||k._publicKey,n=s(n),k._metadata=n||k._metadata;var a,i,o=d();o&&(e={publicKey:e,wuid:o,event:t,sessionId:g(),userAgent:window.navigator.userAgent,provider:l(),origin:window.location.href,referrer:document.referrer,utms:{source:f("utm_source"),medium:f("utm_medium"),campaign:f("utm_campaign"),term:f("utm_term")},metadata:n||{}},o=u,n=e,a=r,(i=new XMLHttpRequest).open("POST",o),i.setRequestHeader("Content-Type","application/json"),i.setRequestHeader("Accept","application/json"),i.onreadystatechange=function(){4===i.readyState&&(200===i.status?a&&"function"==typeof a&&a():400<=i.status&&console.log("Request failed. Returned status of "+i.status+". Text: "+i.responseText))},i.send(JSON.stringify(n)),c())}function c(e,t){var n=d(),r=(f("utm_source"),f("utm_medium"),f("utm_campaign"),f("utm_term"),Math.floor(Date.now()/1e3)+1209600);(new Date).toISOString(),k._publicKey,a}function s(e){return e.offer_price&&isNaN(e.offer_price)&&(e.offer_price=null),e.price&&isNaN(e.price)&&(e.price=null),e}function n(e){return"_"+e}function l(){return e()?"vtex":"custom"}function d(){var e=window.WU.config.identifier,t=f(e);return t?(window.localStorage.setItem(n(e),t),t):window.localStorage.getItem(n(e))||null}function g(){var e=window.localStorage.getItem(r);let t=e;var n=new Date;return(!e||n.getTime()-new Date(e).getTime()>1e3*window.WU.config.sessionDuration)&&(window.localStorage.setItem(r,n.toISOString()),t=n.toISOString()),(e=new Date(t)).getUTCFullYear()+(e.getUTCMonth()+1).toString().padStart(2,"0")+e.getUTCDate().toString().padStart(2,"0")+e.getUTCHours().toString().padStart(2,"0")}function f(e,t){if(!e)return null;t=t||window.location.href,e=e.replace(/[\[\]]/g,"\\$&");e=new RegExp("[?&]"+e+"(=([^&#]*)|&|#|$)").exec(t);return e?e[2]?decodeURIComponent(e[2].replace(/\+/g," ")):"":null}function e(){return"Vtex"in window||"vtex"in window||"vtex"===window?.__RUNTIME__?.platform||window?.__RUNTIME__?.assetServerPublishedHost?.includes("vtex")}function o(e,t){var n=k._trackPriceProductVTEXField,r=k._trackListPriceProductVTEXField,a=r in t&&t[r];return e.price=a?t[r]:t[n],e.offer_price=a?t[n]:null,e.price===e.offer_price&&(e.offer_price=null),e}function w(e){if(e)try{var t,n=getSkuData(e),r=k._trackProductVTEXField,a=k._trackParentProductVTEXField;n&&r in n&&n[r]&&(t=n[r],a in n&&n[a]&&(k._metadata.parentId=n[a].toString()),t)&&-1==k._vtexUniqueSkus.indexOf(t)&&(k._metadata.sku=t,k._metadata=o(k._metadata,n),k._vtexUniqueSkus.push(t),i(k._publicKey,"product-view",k._metadata,k._callback))}catch(e){console.error(e),k.wuLogEvent("trackVTEXError",e)}}function _(e){try{(t=e.newSkuId)&&skuJson&&"skus"in skuJson&&skuJson.skus.length&&skuJson.skus.find(function(e){return 1==e.available&&e.sku==t})?(w(e.newSkuId),k.wuLogEvent("loadEventSKUChange",e)):(console.info("[WU] The product "+e.newSkuId+" is not available"),k.wuLogEvent("skuNotAvailableError",e))}catch(e){console.error(e),k.wuLogEvent("loadEventSKUChangeError",e)}var t}var p,k={};let v={sessionDuration:3600,identifier:"wuid"};k.config=Object.assign({},v),k.track=i,k.trackProductVTEX=function(e,t,n){k._publicKey=e||k._publicKey,k._metadata=t||k._metadata,k._callback=n||k._callback;var r=setInterval(function(){var e;"undefined"!=typeof getSkuData&&(w(skuJson&&"skus"in skuJson&&skuJson.skus.length&&(e=skuJson.skus.find(function(e){return 1==e.available}))?e.sku:null),clearInterval(r))},50)},k.wuLogEvent=c,k._trackVTEX=w,k.addPriceMetadataInfoVTEX=o,k.getProvider=l,k.validateOptionalFields=s,k._trackProductVTEXField="reference",k._trackParentProductVTEXField="idProduct",k._trackPriceProductVTEXField="price",k._trackListPriceProductVTEXField="listPrice",k._publicKey=null,k._metadata={},k._callback=void 0,(window.WU=k).wuLogEvent("loadScript",k),e()&&(k._vtexUniqueSkus=[],p=setInterval(function(){var e,t;void 0!==window.Vtex&&(e="skuSelectionChanged",t="WoowUpVTEXTrackingSKUChanged",t=new Vtex.JSEvents.Listener(t,_),skuEventDispatcher.addListener(e,t),clearInterval(p),k.wuLogEvent("loadScriptInVTEX",k))},50)),d(),g()})();