File: /home/mciraet/www/wp-content/cache/wpo-minify/1780346326/assets/wpo-minify-footer-dd7e2084.min.js
jQuery(document).ready(function($){window.xooEl=window.xooEl||{};function objectifyForm($form){var form=$form instanceof jQuery?$form[0]:$form;var formData=new FormData(form);var result={};formData.forEach(function(value,name){if(value instanceof File)return;if(result.hasOwnProperty(name)){if(!Array.isArray(result[name])){result[name]=[result[name]]}
result[name].push(value)}else{result[name]=value}});return result}
function parse_notice(message,type){type=(typeof type!=='undefined')?type:'error';return xoo_el_localize.html.notice[type].replace('%s',message)}
var classReferral={'xoo-el-login-tgr':'login','xoo-el-reg-tgr':'register',}
function getReferral(className){return classReferral[className]?classReferral[className]:''}
function getFormsTrigger($container){$container=$container||'';var isSingle=!1;if($container.length&&$container.find('.xoo-el-section[data-section="single"]').length){isSingle=!0}
var formsTrigger={'xoo-el-sing-tgr':'single','xoo-el-login-tgr':isSingle?'single':'login','xoo-el-reg-tgr':isSingle?'single':'register','xoo-el-lostpw-tgr':'lostpw','xoo-el-resetpw-tgr':'resetpw','xoo-el-forcereg-tgr':'register','xoo-el-forcelogin-tgr':'login',}
return formsTrigger}
class Container{constructor($container){this.$container=$container;this.$tabs=$container.find('ul.xoo-el-tabs').length?$container.find('ul.xoo-el-tabs'):null;this.display=$container.hasClass('xoo-el-form-inline')?'inline':'popup';this.formRetries=0;if(this.$container.attr('data-active')){this.toggleForm(this.$container.attr('data-active'))}
this.createFormsTriggerHTML();this.eventHandlers()}
createFormsTriggerHTML(){var HTML='<div style="display: none!important;">';$.each(getFormsTrigger(this.$container),function(triggerClass,type){HTML+='<span class="'+triggerClass+'"></span>'})
HTML+='</div>';this.$container.append(HTML)}
eventHandlers(){this.$container.on('submit','.xoo-el-action-form',this.submitForm.bind(this));this.$container.on('click','.xoo-el-edit-em',this.emailFieldEditClick.bind(this));$(document.body).on('xoo_el_form_submitted',this.singleFormProcess.bind(this));this.formTriggerEvent()}
emailFieldEditClick(e){this.toggleForm('single');this.$container.find('input[name="xoo-el-sing-user"]').val($(e.currentTarget).siblings('input').val()).focus().trigger('keyup')}
formTriggerEvent(){var container=this,formsTrigger=getFormsTrigger(container.$container);$.each(formsTrigger,function(triggerClass,formType){$(container.$container).on('click','.'+triggerClass,function(e){e.preventDefault();e.stopImmediatePropagation();container.toggleForm(formType,getReferral(triggerClass))})})}
toggleForm(formType,referral){referral=referral||'';this.$container.attr('data-active',formType);var $section=this.$container.find('.xoo-el-section[data-section="'+formType+'"]'),activeClass='xoo-el-active';if($section.length){var $sectionForm=$section.find('form');this.$container.find('.xoo-el-section').removeClass(activeClass);$section.addClass(activeClass);$section.find('.xoo-el-notice').html('').hide();$section.find('.xoo-el-action-form').show();if($sectionForm.length&&referral&&$sectionForm.find('input[name="_xoo_el_referral"]').length){$sectionForm.find('input[name="_xoo_el_referral"]').val(referral)}}
if(this.$tabs){this.$tabs.find('li').removeClass(activeClass);if(this.$tabs.find('li[data-tab="'+formType+'"]').length){this.$tabs.find('li[data-tab="'+formType+'"]').addClass(activeClass)}}
$(document.body).trigger('xoo_el_form_toggled',[formType,this,referral]);this.$container.triggerHandler('xoo_el_form_toggled',[formType,this,referral])}
submitForm(e){e.preventDefault();var $form=$(e.currentTarget),$button=$form.find('button[type="submit"]'),$section=$form.parents('.xoo-el-section'),buttonTxt=$button.text(),$notice=$section.find('.xoo-el-notice'),formType=$section.attr('data-section'),container=this;$notice.html('');$button.html(xoo_el_localize.html.spinner).addClass('xoo-el-processing');var form_data=new FormData($form[0]);form_data.append('action','xoo_el_form_action');form_data.append('display',container.display);$.ajax({url:xoo_el_localize.adminurl,type:'POST',processData:!1,contentType:!1,cache:!1,enctype:'multipart/form-data',data:form_data,complete:function(xhr,status){$button.removeClass('xoo-el-processing').html(buttonTxt);if((status!=='success'||!xhr.responseJSON||xhr.responseJSON.error===undefined)){if(container.formRetries<2){$form.submit();container.formRetries++;return}
if(xoo_el_localize.errorLog==='yes'){$notice.html(parse_notice("We could not process your request, please check console or try again later.",'error')).show()}else if(status!=='error'){location.reload()}}},success:function(response){container.formRetries=0;if(response.error===undefined){console.log(response);return}
if(response.notice){$notice.html(response.notice).show();if(container.display==='inline'){$('html, body').animate({scrollTop:$notice.offset().top-100},500)}}
if(response.error===0){if(response.redirect){setTimeout(function(){window.location=response.redirect},xoo_el_localize.redirectDelay)}else{$form.hide()}
$form.trigger('reset');if(formType==='resetpw'&&xoo_el_localize.resetPwPattern==='link'){$form.add('.xoo-el-resetpw-hnotice').remove()}}
$(document.body).trigger('xoo_el_form_submitted',[response,$form,container]);$form.triggerHandler('xoo_el_form_submitted',[response,$form,container])}}).fail(function(jqXHR,textStatus,errorThrown){if(container.formRetries<2)return;$('body, .xoo-el-popup-notice').addClass('xoo-el-popup-notice-active');var iframe=$('.xoo-el-notice-wrap iframe').get(0);iframe.contentWindow.document.open();iframe.contentWindow.document.write(jqXHR.responseText);iframe.contentWindow.document.close();var iframeDocument=iframe.contentWindow.document;var style=iframeDocument.createElement("style");style.textContent=$('.xoo-el-notice-iframestyle').text();iframeDocument.head.appendChild(style)})}
singleFormProcess(e,response,$form,container){if(this!==container)return;if(response.field){var $field=this.$container.find(response.field);if($field.length){this.toggleForm($field.closest('.xoo-el-section').attr('data-section'));$field.closest('form').show();$field.val(response.fieldValue);$field.closest('.xoo-el-section').find('.xoo-el-notice').html(response.notice).show();var $fieldCont=$field.closest('.xoo-aff-group');if(!$fieldCont.find('.xoo-el-edit-em').length){$fieldCont.addClass('xoo-el-block-edit');$(xoo_el_localize.html.editField).insertAfter($field)}}}}}
class Popup{constructor($popup){this.$popup=$popup;this.eventHandlers()}
eventHandlers(){if(!xoo_el_localize.preventClosing){this.$popup.on('click','.xoo-el-close, .xoo-el-modal, .xoo-el-opac',this.closeOnClick.bind(this));$(document.body).on('xoo_el_popup_toggled.xooEscEvent',this.onPopupToggled.bind(this))}
$(document.body).on('xoo_el_form_submitted',this.onFormSubmitSuccess.bind(this));this.$popup.on('click','.xoo-el-action-btn',this.setScrollBarOnSubmit.bind(this));$(window).on('hashchange load',this.openViaHash.bind(this));this.triggerPopupOnClick();if(xoo_el_localize.checkout&&xoo_el_localize.checkout.loginEnabled==='yes'){$('body').on('click','.wc-block-checkout__login-prompt, .wc-block-must-login-prompt',this.checkoutPageLinkClick.bind(this))}}
onPopupToggled(e,type){if($('body').hasClass('xoo-el-popup-active')){$(document).on('keydown.xooEscClose',this.closeOnEscPress.bind(this))}else{$(document).off('keydown.xooEscClose')}}
closeOnEscPress(e){if(event.key==="Escape"||event.keyCode===27){popup.toggle('hide')}}
checkoutPageLinkClick(e){e.preventDefault();$(e.currentTarget).attr('data-redirect',xoo_el_localize.checkout.loginRedirect).addClass('xoo-el-login-tgr').trigger('click')}
triggerPopupOnClick(){$.each(getFormsTrigger(this.$popup),function(triggerClass,formType){$(document.body).on('click','.'+triggerClass,function(e){if($(this).parents('.xoo-el-form-container').length)return!0;e.preventDefault();e.stopImmediatePropagation();popup.toggle('show');if($(this).attr('data-redirect')){popup.$popup.find('input[name="xoo_el_redirect"]').val($(this).attr('data-redirect'))}
popup.$popup.find('.'+triggerClass).trigger('click');return!1})})}
toggle(type){var $els=this.$popup.add('body'),activeClass='xoo-el-popup-active';if(type==='show'){$els.addClass(activeClass)}else if(type==='hide'){$els.removeClass(activeClass)}else{$els.toggleClass(activeClass)}
$(document.body).trigger('xoo_el_popup_toggled',[type])}
closeOnClick(e){var elClassList=e.target.classList;if(elClassList.contains('xoo-el-close')||elClassList.contains('xoo-el-modal')||elClassList.contains('xoo-el-opac')){this.toggle('hide')}}
setScrollbarPosition(position){this.$popup.find('.xoo-el-srcont').scrollTop=position||0}
onFormSubmitSuccess(e,response,$form,container){this.setScrollbarPosition()}
setScrollBarOnSubmit(e){var invalid_els=$(e.currentTarget).closest('form').find('input:invalid');if(invalid_els.length===0)return;this.setScrollbarPosition(invalid_els.filter(":first").closest('.xoo-aff-group').position().top)}
openViaHash(){var hash=$(location).attr('hash');if(hash==='#login'||hash==='#register'){this.toggle('show');var uri=window.location.toString(),clean_uri=uri.substring(0,uri.indexOf("#"));window.history.replaceState({},document.title,clean_uri)}
if(hash==='#login'){this.$popup.find('.xoo-el-login-tgr').trigger('click')}else if(hash==='#register'){this.$popup.find('.xoo-el-reg-tgr').trigger('click')}}}
class Form{constructor($form){this.$form=$form}
eventHandlers(){}}
var popup=null;if($('.xoo-el-container').length){popup=new Popup($('.xoo-el-container'))}
if(xoo_el_localize.isLoggedIn==="no"&&xoo_el_localize.autoOpenPopup==='yes'&&localStorage.getItem("xoo_el_popup_opened")!=="yes"){if(xoo_el_localize.autoOpenPopupOnce==="yes"){localStorage.setItem("xoo_el_popup_opened","yes")}
setTimeout(function(){popup.toggle('show')},xoo_el_localize.aoDelay)}
$('.xoo-el-form-container').each(function(key,el){new Container($(el))})
if($('form.xoo-el-form-resetpw').length&&xoo_el_localize.resetPwPattern==="link"){if($('.xoo-el-form-inline').length){$([document.documentElement,document.body]).animate({scrollTop:$(".xoo-el-form-inline").offset().top},500)}else{if(popup){popup.toggle('show')}}}
if($('body.woocommerce-checkout').length&&$('.xoo-el-form-inline').length&&$('a.showlogin').length){var $inlineForm=$('.xoo-el-form-inline');$inlineForm.hide();$(document.body).on('click','a.showlogin',function(){$inlineForm.slideToggle();$inlineForm.find('.xoo-el-login-tgr').trigger('click')})}
if(popup&&xoo_el_localize.loginClass&&$('.'+xoo_el_localize.loginClass).length){$('body:not(.logged-in) .'+xoo_el_localize.loginClass).on('click',function(e){e.preventDefault();e.stopImmediatePropagation();popup.toggle('show');popup.$popup.find('.xoo-el-login-tgr').trigger('click')})}
if(popup&&xoo_el_localize.registerClass&&$('.'+xoo_el_localize.registerClass).length){$('body:not(.logged-in) .'+xoo_el_localize.registerClass).on('click',function(e){e.preventDefault();e.stopImmediatePropagation();popup.toggle('show');popup.$popup.find('.xoo-el-reg-tgr').trigger('click')})}
$('.xoo-el-notice-close').on('click',function(){$('body, .xoo-el-popup-notice').removeClass('xoo-el-popup-notice-active')})
class CodeFormHandler{constructor($codeForm){const existing=CodeFormHandler.instances.get($codeForm[0]);if(existing)return existing;this.$codeForm=$codeForm;this.codeFormID=this.$codeForm.data('code');this.$parentForm=this.$codeForm.data('parentform')?$(this.$codeForm.siblings(this.$codeForm.data('parentform')).get(0)):$();this.CodePasted=!1;this.resendData={};this.$noticeCont=this.$codeForm.find('.xoo-el-code-notice');this.$submitBtn=this.$codeForm.find('.xoo-el-code-submit-btn');this.submitBtnTxt=this.$submitBtn.html();this.$inputs=this.$codeForm.find('.xoo-el-code-input');this.$resendLink=this.$codeForm.find('.xoo-el-code-resend-link');this.noticeTimout=this.resendTimer=!1;this.parentFormValues={}
this.codesent=!1;this.$container=this.$codeForm.closest('.xoo-el-form-container');this.events();CodeFormHandler.instances.set($codeForm[0],this)}
events(){this.$resendLink.on('click',{_thisObj:this},this.resendCode);this.$codeForm.find('.xoo-el-code-no-change').on('click',{_thisObj:this},this.changeParentInput);this.$codeForm.on('submit',{_thisObj:this},this.onSubmit);this.$inputs.on('paste',{_thisObj:this},this.onCodeInputPaste);this.$inputs.on('input',{_thisObj:this},this.onCodeInputChange);this.$inputs.on('keydown ',{_thisObj:this},this.beforeCodeInputChange);this.$container.on('xoo_el_form_toggled',this.onParentFormToggled.bind(this))}
onParentFormToggled(e,formType,containerObj,referral){let _thisObj=this;if(_thisObj.codesent){_thisObj.$parentForm.hide();_thisObj.$codeForm.show()}}
onCodeInputPaste(event){var _thisObj=event.data._thisObj,_this=$(this);_thisObj.CodePasted=!0;setTimeout(function(){var inputVal=_this.val().trim(),inputValLength=inputVal.length;_thisObj.$inputs.val('');for(var i=0;i<inputValLength;++i){var chr=inputVal.charAt(i),$Codeinput=$(_thisObj.$inputs.get(i));if($Codeinput.length){$Codeinput.val(chr)}
if(i===(inputValLength-1)){$Codeinput.focus()}}
if(inputValLength===_thisObj.$inputs.length){_thisObj.$codeForm.trigger('submit')}
_thisObj.CodePasted=!1},10)}
onCodeInputChange(event){var _thisObj=event.data._thisObj,inputVal=$(this).val(),inputValLength=inputVal.length;if(inputValLength>1&&!_thisObj.CodePasted){$(this).trigger('paste');return}
if(_thisObj.CodePasted||_thisObj.processing){return}
_thisObj.processing=!0;var $nextInput=$(this).next('input.xoo-el-code-input'),$prevInput=$(this).prev('input.xoo-el-code-input');if(inputValLength&&$nextInput.length!==0){$nextInput.focus()}
_thisObj.processing=!1}
beforeCodeInputChange(event){var _thisObj=event.data._thisObj,inputVal=$(this).val(),inputValLength=inputVal.length;var $nextInput=$(this).next('input.xoo-el-code-input'),$prevInput=$(this).prev('input.xoo-el-code-input');if(inputVal.length&&event.keyCode!=8&&event.keyCode!==13){if($nextInput.length&&!$nextInput.val()){$nextInput.focus()}else{$(this).val('')}}
if(!inputValLength&&event.keyCode==8&&$prevInput.length!==0){$prevInput.focus()}}
onSubmit(event){event.preventDefault();var _thisObj=event.data._thisObj;if(!_thisObj.validateInputs()||!_thisObj.getCodeValue().length)return!1;_thisObj.$submitBtn.html(xoo_el_localize.html.spinner).addClass('xoo-el-processing');_thisObj.verifyCode()}
changeParentInput(event){var _thisObj=event.data._thisObj;_thisObj.codesent=!1;_thisObj.$codeForm.hide();_thisObj.$parentForm.show();_thisObj.$inputs.val('')}
resendCode(event){event.preventDefault();var _thisObj=event.data._thisObj;_thisObj.startResendTimer();var form_data={action:'xoo_el_resend_code','parentFormData':objectifyForm(_thisObj.$parentForm),}
form_data=Object.assign({},form_data,_thisObj.resendData);_thisObj.$resendLink.addClass('xoo-el-processing');$.ajax({url:xoo_el_localize.adminurl,type:'POST',data:form_data,success:function(response){_thisObj.$resendLink.trigger('xoo_el_code_resent',[response,_thisObj]);_thisObj.$resendLink.removeClass('xoo-el-processing');if(response.notice){_thisObj.showNotice(response.notice)}},complete:function(){}})}
validateInputs(){var passedValidation=!0;this.$inputs.each(function(index,input){var $input=$(input);if($input.val().trim()===''){$input.focus();passedValidation=!1;return!1}});return passedValidation}
onSuccess(response){this.$codeForm.removeAttr('data-processing');this.codesent=!1;this.$codeForm.hide();this.$inputs.val('');if(this.$parentForm.length){if(response.notice){this.$parentForm.closest('.xoo-el-section').find('.xoo-el-notice').html(response.notice).show()}
this.$parentForm.show()}}
startResendTimer(){var _thisObj=this,$cont=this.$codeForm.find('.xoo-el-code-resend'),$resendLink=$cont.find('.xoo-el-code-resend-link'),$timer=$cont.find('.xoo-el-code-resend-timer'),resendTime=parseInt(xoo_el_localize.resend_wait);if(resendTime===0)return;$resendLink.addClass('xoo-el-disabled');clearInterval(this.resendTimer);this.resendTimer=setInterval(function(){$timer.html('('+resendTime+')');if(resendTime<=0){clearInterval(_thisObj.resendTimer);$resendLink.removeClass('xoo-el-disabled');$timer.html('')}
resendTime--},1000)}
showNotice(notice){var _thisObj=this;clearTimeout(this.noticeTimout);this.$noticeCont.html(notice).show();this.noticeTimout=setTimeout(function(){_thisObj.$noticeCont.hide()},4000)}
onCodeSent(response){var _thisObj=this;if(response.error)return;_thisObj.codesent=!0;_thisObj.$codeForm.show();if(response.code_txt){_thisObj.$codeForm.find('.xoo-el-code-no-txt').html(response.code_txt)}
setTimeout(function(){_thisObj.$inputs.first().trigger('click');_thisObj.$inputs.first().focus();_thisObj.$inputs.first().attr('autofocus',!0)},500)
_thisObj.startResendTimer();_thisObj.parentFormValues=_thisObj.$parentForm.serialize();_thisObj.$codeForm.attr('data-processing','yes');_thisObj.$parentForm.hide()}
verifyCode(data){var _thisObj=this;var form_data=$.extend({'code':_thisObj.getCodeValue(),'action':'xoo_el_code_form_submit','xoo_el_code_ajax':_thisObj.codeFormID,'parentFormData':objectifyForm(_thisObj.$parentForm)},data);$.ajax({url:xoo_el_localize.adminurl,type:'POST',data:form_data,success:function(response){_thisObj.$submitBtn.removeClass('xoo-el-processing').html(_thisObj.submitBtnTxt);if(response.notice){_thisObj.showNotice(response.notice)}
if(response.error===0){_thisObj.onSuccess(response);_thisObj.$codeForm.trigger('xoo_el_on_code_success',[response])}}})}
validateFormSubmit(){if(this.validateInputs()&&this.getCodeValue().length){this.$submitBtn.html(xoo_el_localize.html.spinner).addClass('xoo-el-processing');return!0}}
getCodeValue(){var code='';this.$inputs.each(function(index,input){code+=$(input).val()});return code}}
CodeFormHandler.instances=new WeakMap();$('.xoo-el-code-form').each(function(index,codeForm){new CodeFormHandler($(codeForm))});window.xooEl.CodeFormHandler=CodeFormHandler;if(xoo_el_localize.resetPwPattern==="code"){class lostPasswordFormHandler{constructor($form){this.$form=$form;this.$section=this.$form.closest('.xoo-el-section');this.$resetPwSection=this.$section.siblings('[data-section="resetpw"]');this.$resetPwForm=this.$resetPwSection.find('.xoo-el-form-resetpw');this.$container=this.$section.closest('.xoo-el-form-container');this.codeFormHandler=new CodeFormHandler($form.siblings('.xoo-el-code-form'));this.events()}
events(){this.$form.on('xoo_el_form_submitted',this.onFormSubmit.bind(this));this.$resetPwForm.on('xoo_el_form_submitted',this.onResetPWFormSubmit.bind(this));this.codeFormHandler.$codeForm.on('xoo_el_on_code_success',this.onCodeVerificationSuccess.bind(this));this.$container.on('xoo_el_form_toggled',this.onLostPasswordFormToggle.bind(this))}
onFormSubmit(e,response,$form,container){let _thisObj=this;_thisObj.codeFormHandler.onCodeSent(response);_thisObj.$resetPwSection.removeAttr('data-verified','yes')}
onResetPWFormSubmit(e,response,$form,containerObj){let _thisObj=this;_thisObj.$resetPwSection.removeAttr('data-verified','yes');if(response.error){_thisObj.$section.find('.xoo-el-notice').html(response.notice).show();if(response.error_code==='code_reset'){containerObj.toggleForm('lostpw')}}else{containerObj.toggleForm('login');this.$container.find('.xoo-el-section[data-section="login"]').find('.xoo-el-notice').html(response.notice).show()}}
onCodeVerificationSuccess(e,response){let _thisObj=this;_thisObj.$container.find('.xoo-el-resetpw-tgr').trigger('click');_thisObj.$resetPwSection.attr('data-verified','yes')}
onLostPasswordFormToggle(e,formType,containerObj,referral){let _thisObj=this;if(formType!=='lostpw')return;if(_thisObj.$resetPwSection.attr('data-verified')==="yes"){containerObj.toggleForm('resetpw')}}}
$('form.xoo-el-form-lostpw').each(function(index,el){new lostPasswordFormHandler($(el))})}});
var mailchimp,mailchimp_cart,mailchimp_billing_email,mailchimp_username_email,mailchimp_registration_email,mailchimp_submitted_email=false,mailchimpReady=function(a){/in/.test(document.readyState)?setTimeout(()=>{mailchimpReady(a)},9):a()};function mailchimpGetCurrentUserByHash(a){try{if(!mailchimp_public_data.allowed_to_set_cookies)return;var b=mailchimp_public_data.ajax_url+"?action=mailchimp_get_user_by_hash&hash="+a,c=new XMLHttpRequest;c.open("POST",b,!0),c.onload=function(){if(c.status>=200&&c.status<400){var a=JSON.parse(c.responseText);if(!a)return;mailchimp_cart.valueEmail(a.email)&&mailchimp_cart.setEmail(a.email)}};c.onerror=function(){console.log("mailchimp.get_email_by_hash.request.error",c.responseText)};c.setRequestHeader("Content-Type","application/json");c.setRequestHeader("Accept","application/json");c.send()}catch(a){console.log("mailchimp.get_email_by_hash.error",a)}}function mailchimpHandleBillingEmail(selector){try{if(!mailchimp_public_data.allowed_to_set_cookies)return;if(mailchimp_public_data.disable_carts)return;var subscribed=document.querySelector("#mailchimp_woocommerce_newsletter");if(!subscribed)subscribed=document.querySelector("#subscribe-to-newsletter");if(!selector)selector="#billing_email";var a=document.querySelector(selector);var b=void 0!==a?a.value:"";if(!mailchimp_cart.valueEmail(b)||mailchimp_submitted_email===b){return false}mailchimp_cart.setEmail(b);var c=mailchimp_public_data.ajax_url+"?action=mailchimp_set_user_by_email";var d=new XMLHttpRequest;d.open("POST",c,!0);d.onload=function(){var successful=d.status>=200&&d.status<400;var msg=successful?"mailchimp.handle_billing_email.request.success":"mailchimp.handle_billing_email.request.error";if(successful){mailchimp_submitted_email=b}console.log(msg,d.responseText)};d.onerror=function(){console.log("mailchimp.handle_billing_email.request.error",d.responseText)};d.setRequestHeader("Content-Type","application/x-www-form-urlencoded");d.setRequestHeader("Accept","application/json");d.send("email="+b+"&mc_language="+mailchimp_public_data.language+"&subscribed="+(subscribed&&subscribed.checked?"1":"0"));return true}catch(a){console.log("mailchimp.handle_billing_email.error",a);mailchimp_submitted_email=!1}}!function(){"use strict";function mailchimpCart(){this.email_types="input[type=email]";this.regex_email=/^([A-Za-z0-9_+\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;this.current_email=null;this.previous_email=null;this.expireUser=function(){this.current_email=null;if(!mailchimp_public_data.allowed_to_set_cookies)return;mailchimp.storage.expire("mailchimp.cart.current_email")};this.expireSaved=function(){if(!mailchimp_public_data.allowed_to_set_cookies)return;mailchimp.storage.expire("mailchimp.cart.items")};this.setEmail=function(a){if(!mailchimp_public_data.allowed_to_set_cookies)return;if(!this.valueEmail(a))return false;this.setPreviousEmail(this.getEmail());mailchimp.storage.set("mailchimp.cart.current_email",this.current_email=a)};this.getEmail=function(){if(!mailchimp_public_data.allowed_to_set_cookies)return;if(this.current_email)return this.current_email;var a=mailchimp.storage.get("mailchimp.cart.current_email",!1);if(!a||!this.valueEmail(a))return false;return this.current_email=a};this.setPreviousEmail=function(a){if(!mailchimp_public_data.allowed_to_set_cookies)return;if(!this.valueEmail(a))return false;mailchimp.storage.set("mailchimp.cart.previous_email",this.previous_email=a)};this.valueEmail=function(a){return this.regex_email.test(a)};return this}var g={extend:function(a,b){for(var c in b||{})b.hasOwnProperty(c)&&(a[c]=b[c]);return a},getQueryStringVars:function(){var a=window.location.search||"",b=[],c={};if(a=a.substr(1),a.length){b=a.split("&");for(var d in b){var e=b[d];if("string"==typeof e){var f=e.split("="),g=f[0],h=f[1];g.length&&("undefined"==typeof c[g]&&(c[g]=[]),c[g].push(h))}}}return c},unEscape:function(a){return decodeURIComponent(a)},escape:function(a){return encodeURIComponent(a)},createDate:function(a,b){a||(a=0);var c=new Date,d=b?c.getDate()-a:c.getDate()+a;return c.setDate(d),c},arrayUnique:function(a){for(var b=a.concat(),c=0;c<b.length;++c)for(var d=c+1;d<b.length;++d)b[c]===b[d]&&b.splice(d,1);return b},objectCombineUnique:function(a){for(var b=a[0],c=1;c<a.length;c++){var d=a[c];for(var e in d)b[e]=d[e]}return b}},h=function(a,b){var c=function(a,b,d){return 1===arguments.length?c.get(a):c.set(a,b,d)};return c.get=function(b,d){return a.cookie!==c._cacheString&&c._populateCache(),void 0==c._cache[b]?d:c._cache[b]},c.defaults={path:"/",secure:true,samesite:"strict"},c.set=function(d,e,f){switch(f={path:f&&f.path||c.defaults.path,domain:f&&f.domain||c.defaults.domain,expires:f&&f.expires||c.defaults.expires,secure:f&&f.secure!==b?f.secure:c.defaults.secure,samesite:f&&f.samesite||c.defaults.samesite},e===b&&(f.expires=-1),typeof f.expires){case"number":f.expires=new Date((new Date).getTime()+1e3*f.expires);break;case"string":f.expires=new Date(f.expires)}return d=encodeURIComponent(d)+"="+(e+"").replace(/[^!#-+\--:<-\[\]-~]/g,encodeURIComponent),d+=f.path?";path="+f.path:"",d+=f.domain?";domain="+f.domain:"",d+=f.expires?";expires="+f.expires.toGMTString():"",d+=f.secure?";secure":"",d+=f.samesite?";samesite="+f.samesite:"",a.cookie=d,c},c.expire=function(a,d){return c.set(a,b,d)},c._populateCache=function(){c._cache={};try{c._cacheString=a.cookie;for(var d=c._cacheString.split("; "),e=0;e<d.length;e++){var f=d[e].indexOf("="),g=decodeURIComponent(d[e].substr(0,f)),f=decodeURIComponent(d[e].substr(f+1));c._cache[g]===b&&(c._cache[g]=f)}}catch(a){console.log(a)}},c.enabled=function(){var a="1"===c.set("cookies.js","1").get("cookies.js");return c.expire("cookies.js"),a}(),c}(document);mailchimp={storage:h,utils:g};mailchimp_cart=new mailchimpCart}();mailchimpReady(function(){if(!mailchimp_public_data.allowed_to_set_cookies)return;if(mailchimp_public_data.disable_carts)return;if(void 0===a){var a={site_url:document.location.origin,defaulted:!0,ajax_url:document.location.origin+"/wp-admin?admin-ajax.php"}}try{var b=mailchimp.utils.getQueryStringVars();void 0!==b.mc_cart_id&&mailchimpGetCurrentUserByHash(b.mc_cart_id);var subscribed=document.querySelector("#mailchimp_woocommerce_newsletter");var blockSubscribed=document.querySelector("#subscribe-to-newsletter");if(subscribed){subscribed.onchange=function(){mailchimp_submitted_email=null;mailchimpHandleBillingEmail("#billing_email")}}else if(blockSubscribed){blockSubscribed.onchange=function(){mailchimp_submitted_email=null;mailchimpHandleBillingEmail('#contact-fields input[type="email"]')}}mailchimp_username_email=document.querySelector("#username");mailchimp_billing_email=document.querySelector("#billing_email");mailchimp_registration_email=document.querySelector("#reg_email");var mailchimp_username_email_block=document.querySelector('#contact-fields input[type="email"]');if(mailchimp_billing_email){mailchimp_billing_email.onblur=function(){mailchimpHandleBillingEmail("#billing_email")};mailchimp_billing_email.onfocus=function(){mailchimpHandleBillingEmail("#billing_email")}}if(mailchimp_username_email){mailchimp_username_email.onblur=function(){mailchimpHandleBillingEmail("#username")};mailchimp_username_email.onfocus=function(){mailchimpHandleBillingEmail("#username")}}if(mailchimp_registration_email){mailchimp_registration_email.onblur=function(){mailchimpHandleBillingEmail("#reg_email")};mailchimp_registration_email.onfocus=function(){mailchimpHandleBillingEmail("#reg_email")}}if(mailchimp_username_email_block){mailchimp_username_email_block.onblur=function(){mailchimpHandleBillingEmail('#contact-fields input[type="email"]')};mailchimp_username_email_block.onfocus=function(){mailchimpHandleBillingEmail('#contact-fields input[type="email"]')};var typingTimer;mailchimp_username_email_block.addEventListener("keyup",function(){typingTimer&&clearTimeout(typingTimer);typingTimer=setTimeout(function(){if(mailchimp_cart.valueEmail(mailchimp_username_email_block.value)){mailchimpHandleBillingEmail('#contact-fields input[type="email"]')}},2e3)});mailchimp_username_email_block.addEventListener("keydown",function(){typingTimer&&clearTimeout(typingTimer)})}}catch(e){console.log("mailchimp ready error",e)}});
(function($){'use strict';const PIXEL_SDK_WAIT_CONFIG={initialDelayMs:100,maxDelayMs:5000,maxAttempts:20};const MailchimpPixelTracking={_atcTimer:null,_rfcTimer:null,_atcFetching:!1,_rfcFetching:!1,init:function(){const self=this;this.waitForPixelSDK(PIXEL_SDK_WAIT_CONFIG).then(function(){self.sendPageEvents();self.attachCartEventListeners();self.interceptStoreApiRequests();console.log('Mailchimp Pixel SDK loaded.')}).catch(function(e){console.log('Mailchimp Pixel SDK not loaded within timeout. Tracking disabled.',e)})},waitForPixelSDK:function(options){const config=options||{};const initialDelayMs=config.initialDelayMs!==undefined?config.initialDelayMs:PIXEL_SDK_WAIT_CONFIG.initialDelayMs;const maxDelayMs=config.maxDelayMs!==undefined?config.maxDelayMs:PIXEL_SDK_WAIT_CONFIG.maxDelayMs;const maxAttempts=config.maxAttempts!==undefined?config.maxAttempts:PIXEL_SDK_WAIT_CONFIG.maxAttempts;function isSDKReady(){return typeof window.$mcSite!=='undefined'&&window.$mcSite.pixel&&typeof window.$mcSite.pixel.api!=='undefined'&&typeof window.$mcSite.pixel.api.track==='function'&&window.$mcSite.pixel.installed===!0}
return new Promise(function(resolve,reject){let attempt=0;function scheduleCheck(){if(isSDKReady()){console.warn('Pixel SDK - remediation for pixel ready issue')
setTimeout(function(){resolve()},1000);return}
if(attempt>=maxAttempts){reject(new Error('Pixel SDK not available'));return}
const delay=Math.min(initialDelayMs*Math.pow(2,attempt),maxDelayMs);attempt+=1;setTimeout(scheduleCheck,delay)}
scheduleCheck()})},isPixelSDKReady:function(){return typeof window.$mcSite!=='undefined'&&window.$mcSite.pixel&&typeof window.$mcSite.pixel.api!=='undefined'&&typeof window.$mcSite.pixel.api.track==='function'},getCartId:function(){return window.mcPixel&&window.mcPixel.cartId?window.mcPixel.cartId:''},getRestBase:function(){return(window.mcPixelConfig&&window.mcPixelConfig.restBase)||'/wp-json/mailchimp-for-woocommerce/v1/'},sendPageEvents:function(){if(!window.mcPixel||!window.mcPixel.data){return}
const data=window.mcPixel.data;const events=data.events||[];events.forEach((eventType)=>{switch(eventType){case 'PRODUCT_ADDED_TO_CART':if(data.added_to_cart){var atcItems=Array.isArray(data.added_to_cart)?data.added_to_cart:[data.added_to_cart];for(var ai=0;ai<atcItems.length;ai++){this.sendProductAddedToCart(atcItems[ai])}}
break;case 'PRODUCT_REMOVED_FROM_CART':if(data.removed_from_cart){var rfcItems=Array.isArray(data.removed_from_cart)?data.removed_from_cart:[data.removed_from_cart];for(var ri=0;ri<rfcItems.length;ri++){this.sendProductRemovedFromCart(rfcItems[ri])}}
break;case 'IDENTITY':if(data.identity&&data.identity.email){this.sendIdentityEvent(data.identity.email)}
break;case 'PRODUCT_VIEWED':if(data.product){const viewedId=String(data.product.productId||data.product.id);const atcArr=Array.isArray(data.added_to_cart)?data.added_to_cart:(data.added_to_cart?[data.added_to_cart]:[]);const rfcArr=Array.isArray(data.removed_from_cart)?data.removed_from_cart:(data.removed_from_cart?[data.removed_from_cart]:[]);const atcMatch=atcArr.some(function(p){return String(p.productId||p.id)===viewedId});const rfcMatch=rfcArr.some(function(p){return String(p.productId||p.id)===viewedId});if((events.includes('PRODUCT_ADDED_TO_CART')&&atcMatch)||(events.includes('PRODUCT_REMOVED_FROM_CART')&&rfcMatch)){break}
this.sendProductViewed(data.product)}
break;case 'CART_VIEWED':if(data.cart){this.sendCartViewed(data.cart)}
break;case 'CHECKOUT_STARTED':if(data.checkout){this.sendCheckoutStarted(data.checkout);window.mcPixel._handled.checkout=!0}
break;case 'PURCHASED':if(data.order){this.sendPurchased(data.order)}
break;case 'PRODUCT_CATEGORY_VIEWED':if(data.category){this.sendCategoryViewed(data.category);window.mcPixel._handled.category=!0}
break;case 'SEARCH_SUBMITTED':if(data.search){this.sendSearchSubmitted(data.search);window.mcPixel._handled.search=!0}
break}})},sendProductViewed:function(product){if(!this.isPixelSDKReady())return;window.$mcSite.pixel.api.track('PRODUCT_VIEWED',{product:product}).catch((error)=>{console.error('Mailchimp Pixel: Error tracking PRODUCT_VIEWED',error)})},sendProductAddedToCart:function(product){if(!this.isPixelSDKReady())return;const cartId=this.getCartId();const eventData={cartId:cartId,product:{item:{id:product.id,productId:product.productId,title:product.title,price:product.price,currency:product.currency,sku:product.sku||''},quantity:product.quantity||1,price:product.price*(product.quantity||1),currency:product.currency}};window.$mcSite.pixel.api.track('PRODUCT_ADDED_TO_CART',eventData).catch((error)=>{console.error('Mailchimp Pixel: Error tracking PRODUCT_ADDED_TO_CART',error)})},sendProductRemovedFromCart:function(product){if(!this.isPixelSDKReady())return;const cartId=this.getCartId();const eventData={cartId:cartId,product:{item:{id:product.id,productId:product.productId,title:product.title,price:product.price,currency:product.currency,sku:product.sku||''},quantity:product.quantity||1,price:product.price*(product.quantity||1),currency:product.currency}};window.$mcSite.pixel.api.track('PRODUCT_REMOVED_FROM_CART',eventData).catch((error)=>{console.error('Mailchimp Pixel: Error tracking PRODUCT_REMOVED_FROM_CART',error)})},sendCartViewed:function(cart){if(!this.isPixelSDKReady())return;window.$mcSite.pixel.api.track('CART_VIEWED',{cart:cart}).catch((error)=>{console.error('Mailchimp Pixel: Error tracking CART_VIEWED',error)})},sendCheckoutStarted:function(checkout){if(!this.isPixelSDKReady())return;window.$mcSite.pixel.api.track('CHECKOUT_STARTED',{checkout:checkout}).catch((error)=>{console.error('Mailchimp Pixel: Error tracking CHECKOUT_STARTED',error)})},sendIdentityEvent:function(email){if(!this.isPixelSDKReady())return;window.$mcSite.pixel.api.identify({type:'EMAIL',value:email})},sendPurchased:function(order){if(!this.isPixelSDKReady())return;window.$mcSite.pixel.api.track('PURCHASED',{order:order}).catch((error)=>{console.error('Mailchimp Pixel: Error tracking PURCHASED',error)})},sendCategoryViewed:function(category){if(!this.isPixelSDKReady())return;window.$mcSite.pixel.api.track('PRODUCT_CATEGORY_VIEWED',category).catch((error)=>{console.error('Mailchimp Pixel: Error tracking PRODUCT_CATEGORY_VIEWED',error)})},sendSearchSubmitted:function(search){if(!this.isPixelSDKReady())return;window.$mcSite.pixel.api.track('SEARCH_SUBMITTED',search).catch((error)=>{console.error('Mailchimp Pixel: Error tracking SEARCH_SUBMITTED',error)})},findProductById:function(productId){if(!window.mcPixel||!window.mcPixel.data||!window.mcPixel.data.products){return null}
const products=window.mcPixel.data.products;const id=String(productId);for(let i=0;i<products.length;i++){if(String(products[i].id)===id){return products[i]}}
return null},fetchAndTrackAddToCart:function(){var self=this;if(!this.isPixelSDKReady())return;clearTimeout(this._atcTimer);this._atcTimer=setTimeout(function(){self._drainAddToCartQueue()},600)},_drainAddToCartQueue:async function(){if(this._atcFetching)return;this._atcFetching=!0;try{var res=await fetch(this.getRestBase()+'pixel/atc',{method:'GET',credentials:'same-origin',headers:{'Accept':'application/json'},});if(!res.ok)return;var data=await res.json();if(!data)return;var items=Array.isArray(data)?data:[data];for(var i=0;i<items.length;i++){this.sendProductAddedToCart(items[i])}}catch(e){}finally{this._atcFetching=!1}},fetchAndTrackRemoveFromCart:function(){var self=this;if(!this.isPixelSDKReady())return;clearTimeout(this._rfcTimer);this._rfcTimer=setTimeout(function(){self._drainRemoveFromCartQueue()},600)},_drainRemoveFromCartQueue:async function(){if(this._rfcFetching)return;this._rfcFetching=!0;try{var res=await fetch(this.getRestBase()+'pixel/rfc',{method:'GET',credentials:'same-origin',headers:{'Accept':'application/json'},});if(!res.ok)return;var data=await res.json();if(!data)return;var items=Array.isArray(data)?data:[data];for(var i=0;i<items.length;i++){this.sendProductRemovedFromCart(items[i])}}catch(e){}finally{this._rfcFetching=!1}},attachCartEventListeners:function(){const self=this;$(document.body).on('added_to_cart',function(){self.fetchAndTrackAddToCart()});$(document.body).on('removed_from_cart',function(){self.fetchAndTrackRemoveFromCart()});document.body.addEventListener('wc-blocks_added_to_cart',function(){self.fetchAndTrackAddToCart()});document.body.addEventListener('wc-blocks_removed_from_cart',function(){self.fetchAndTrackRemoveFromCart()})},interceptStoreApiRequests:function(){const self=this;const originalFetch=window.fetch;window.fetch=function(input,init){var promise=originalFetch.apply(this,arguments);promise.then(function(response){try{if(!response.ok)return;var method=(init&&init.method)?init.method.toUpperCase():(input instanceof Request?input.method.toUpperCase():'GET');if(method!=='POST')return;var url=typeof input==='string'?input:(input instanceof Request?input.url:String(input));if(/wc\/store\/v1\/cart\/add-item/.test(url)||/wc\/store\/v1\/cart\/update-item/.test(url)){self.fetchAndTrackAddToCart()}else if(/wc\/store\/v1\/cart\/remove-item/.test(url)){self.fetchAndTrackRemoveFromCart()}}catch(e){}}).catch(function(){});return promise}},};$(document).ready(function(){MailchimpPixelTracking.init()})})(jQuery);