function sendMessage(e){if(e.source="optinly-iframe",campaign_id&&(e.campaign_id=campaign_id),window.parent)try{window.parent.postMessage(JSON.stringify(e),"*")}catch(e){console.log("message send error",e)}}function closeCampaign(){sendMessage({type:"close"})}function subscribed(e){sendMessage({type:"subscribed",fields:e})}function isValidNumber(e){return!e.hasClass("number-field")||!isNaN(e.val())}function isValidText(e){return $.trim(e.val()).length>0}function isValidEmail(e){return/[^\s@]+@[^\s@]+\.[^\s@]+/.test($.trim(e.val()))}function isValidPhone(e){var t=e.val();const n=(""+(t=(t=(t=String(t).trim()).replace("(","")).replace(")",""))).length;return!(n<6||n>15)&&t.match(/^[+{0,1}]*[(]{0,1}[0-9]{1,4}[)]{0,1}[-\s\./0-9]*$/g)}function isValidCheckbox(e){return"checked"===$(e).attr("checked")}function getFieldType(e){return $(e).attr("type")}function validateForm(){var e=!0;return $("#error-styling")[0]||$('').appendTo($("head")),$.each($("input[required]"),function(t,n){switch(getFieldType(n)){case"checkbox":var r=isValidCheckbox(n),i=$(n).find(".check-box-field"),o=$(n).find(".check-box");r||(e=!1,o.addClass("field-error"),i.click(function(){o.removeClass("field-error")}));case"text":isValidText(a=$(n))||(e=!1,a.addClass("field-error"),a.keyup(function(){a.removeClass("field-error")}));break;case"email":isValidEmail(a=$(n))||(e=!1,a.addClass("field-error"),$("#invalid-email-text")[0]||$(a).after("
Invalid Email
"),a.keyup(function(){a.removeClass("field-error"),$("#invalid-email-text").remove()}));break;case"tel":case"phone":isValidPhone(a=$(n))||(e=!1,a.addClass("field-error"),$("#invalid-phone-text")[0]||$(a).after("
Invalid phone number
"),a.keyup(function(){a.removeClass("field-error"),$("#invalid-phone-text").remove()}));break;case"number":isValidNumber(a=$(n))||(e=!1,a.addClass("field-error"),a.keyup(function(){a.removeClass("field-error")}));break;case"dropdown":var a;isValidText(a=$(n))||(e=!1,a.addClass("field-error"),a.change(function(){a.removeClass("field-error")}))}}),e}function getFormData(e){var t=e.serializeArray(),n={};return $.map(t,function(e,t){n[e.name]=e.value}),n}function getDomain(){let e="";try{if(!(parent.document.location&&parent&&parent.document))throw"failed";e=parent.document.location.href}catch(t){e=document.referrer}return e}function getCustomerInfo(){return{customer_id:""}}function submitForm(e){var t=$("#optinly_subscribe_form");$.trim($(".email-field").val()).toLowerCase();let n=t.attr("action");resizeCampaign();const r=getFormData($(t));var i=Object.assign({},r);let o;try{parent&&parent.document&&parent.document.location&&(o=parent.document.location.href)}catch(e){o=document.referrer}i.customer=getCustomerInfo(),i.campaign_id=campaign_id,i.referrer=o,i.site_id=site_id,i.accepts_marketing=$("#optinly_subscribe_form #termsCheck").attr("checked")?"1":"0",n+=`?recaptcha_token=${encodeURIComponent(e)}`,$.ajax({url:n,type:"POST",data:i,success:function(e){e.success?handleSuccessResponse(i):handleFailedResponse(e.message,i)},error:function(e){const t=e&&e.responseJSON&&e.responseJSON.message;t?handleFailedResponse(t):closeCampaign()}})}function onSubmitting(){$(".submit-loader").css({display:"block"})}function setCloseEvent(){var e=$(".popup-close-btn");e&&$(e).click(function(){closeCampaign()})}function handleSuccessResponse(e){$(parent.document.body).find("#optinly-recaptcha").remove(),$(".first-screen").css({display:"none"}),$(".second-screen").css({display:"block"}),$(".submit-loader").css({display:"none"}),$(".second-screen .message-success").css({display:"block"}),resizeCampaign(),subscribed(e),"function"==typeof handleCustomPage&&handleCustomPage()}function resetError(){$(".first-screen").css({opacity:1}),$(".second-screen").css({display:"none"}),$(".second-screen .message-error").css({display:"none"})}function handleFailedResponse(e,t=null){$(parent.document.body).find("#optinly-recaptcha").remove(),$(".first-screen").css({display:"none"}),$(".second-screen").css({display:"block"}),$(".submit-loader").css({display:"none"}),$(".second-screen .message-success").css({display:"block"}),$(".second-screen .message-success").text(e),t&&subscribed(t),setTimeout(()=>{closeCampaign()},2500)}function isPopover(){return type&&"popover"==type}function adjustReCaptchaVisibility(e){$(parent.document.body).find(".optinly-popover,.optinly-popover-mobile").each(function(){$(this).css({zIndex:e-1})}),$(parent.document.body).find(".optinly-overlay,.optinly-inner-overlay").each(function(){$(this).css({zIndex:e-2})})}function resizeCampaign(){var e=$(document).width(),t=$(document.body).outerHeight();e<1||t<1?setTimeout(resizeCampaign,500):sendMessage({type:"resize",width:$(document).width(),height:$(document.body).outerHeight()})}function loadCampaign(){var e=$(document).width(),t=$(document.body).outerHeight();e<1||t<1?setTimeout(loadCampaign,500):($("#optinly_subscribe_form").focus(),sendMessage({type:"loaded",width:$(document).width(),height:$(document.body).outerHeight()}),setTimeout(resizeCampaign,500))}var resizeTimer;!function(e,t){"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(e,t){function n(e){var t=!!e&&"length"in e&&e.length,n=ae.type(e);return"function"!==n&&!ae.isWindow(e)&&("array"===n||0===t||"number"==typeof t&&0"!==d[1]||We.test(a)?0:l:l.firstChild)&&a.childNodes.length;o--;)ae.nodeName(c=a.childNodes[o],"tbody")&&!c.childNodes.length&&a.removeChild(c);for(ae.merge(v,l.childNodes),l.textContent="";l.firstChild;)l.removeChild(l.firstChild);l=y.lastChild}else v.push(t.createTextNode(a));for(l&&y.removeChild(l),oe.appendChecked||ae.grep(p(v,"input"),m),b=0;a=v[b++];)if(r&&-1")).appendTo(t.documentElement))[0].contentWindow||rt[0].contentDocument).document).write(),t.close(),n=j(e,t),rt.detach()),it[e]=n),n}function D(e,t){return{get:function(){if(!e())return(this.get=t).apply(this,arguments);delete this.get}}}function L(e){if(e in bt)return e;for(var t=e.charAt(0).toUpperCase()+e.slice(1),n=vt.length;n--;)if((e=vt[n]+t)in bt)return e}function $(e,t){for(var n,r,i,o=[],a=0,s=e.length;ax.cacheLength&&delete t[e.shift()],t[n+" "]=r}}function r(e){return e[F]=!0,e}function i(e){var t=D.createElement("div");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function o(e,t){for(var n=e.split("|"),r=n.length;r--;)x.attrHandle[n[r]]=t}function a(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&(~t.sourceIndex||X)-(~e.sourceIndex||X);if(r)return r;if(n)for(;n=n.nextSibling;)if(n===t)return-1;return e?1:-1}function s(e){return function(t){return"input"===t.nodeName.toLowerCase()&&t.type===e}}function l(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function u(e){return r(function(t){return t=+t,r(function(n,r){for(var i,o=e([],n.length,t),a=o.length;a--;)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}function c(e){return e&&void 0!==e.getElementsByTagName&&e}function d(){}function f(e){for(var t=0,n=e.length,r="";t+~]|"+ee+")"+ee+"*"),le=new RegExp("="+ee+"*([^\\]'\"]*?)"+ee+"*\\]","g"),ue=new RegExp(re),ce=new RegExp("^"+te+"$"),de={ID:new RegExp("^#("+te+")"),CLASS:new RegExp("^\\.("+te+")"),TAG:new RegExp("^("+te+"|[*])"),ATTR:new RegExp("^"+ne),PSEUDO:new RegExp("^"+re),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+ee+"*(even|odd|(([+-]|)(\\d*)n|)"+ee+"*(?:([+-]|)"+ee+"*(\\d+)|))"+ee+"*\\)|)","i"),bool:new RegExp("^(?:"+Z+")$","i"),needsContext:new RegExp("^"+ee+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+ee+"*((?:-\\d)?\\d*)"+ee+"*\\)|)(?=[^-]|$)","i")},fe=/^(?:input|select|textarea|button)$/i,pe=/^h\d$/i,he=/^[^{]+\{\s*\[native \w/,me=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ge=/[+~]/,ye=/'|\\/g,ve=new RegExp("\\\\([\\da-f]{1,6}"+ee+"?|("+ee+")|.)","ig"),be=function(e,t,n){var r="0x"+t-65536;return r!=r||n?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)},xe=function(){A()};try{Q.apply(U=G.call(O.childNodes),O.childNodes),U[O.childNodes.length].nodeType}catch(e){Q={apply:U.length?function(e,t){Y.apply(e,G.call(t))}:function(e,t){for(var n=e.length,r=0;e[n++]=t[r++];);e.length=n-1}}}for(v in b=t.support={},C=t.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return!!t&&"HTML"!==t.nodeName},A=t.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:O;return r!==D&&9===r.nodeType&&r.documentElement&&(L=(D=r).documentElement,$=!C(D),(n=D.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",xe,!1):n.attachEvent&&n.attachEvent("onunload",xe)),b.attributes=i(function(e){return e.className="i",!e.getAttribute("className")}),b.getElementsByTagName=i(function(e){return e.appendChild(D.createComment("")),!e.getElementsByTagName("*").length}),b.getElementsByClassName=he.test(D.getElementsByClassName),b.getById=i(function(e){return L.appendChild(e).id=F,!D.getElementsByName||!D.getElementsByName(F).length}),b.getById?(x.find.ID=function(e,t){if(void 0!==t.getElementById&&$){var n=t.getElementById(e);return n?[n]:[]}},x.filter.ID=function(e){var t=e.replace(ve,be);return function(e){return e.getAttribute("id")===t}}):(delete x.find.ID,x.filter.ID=function(e){var t=e.replace(ve,be);return function(e){var n=void 0!==e.getAttributeNode&&e.getAttributeNode("id");return n&&n.value===t}}),x.find.TAG=b.getElementsByTagName?function(e,t){return void 0!==t.getElementsByTagName?t.getElementsByTagName(e):b.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"!==e)return o;for(;n=o[i++];)1===n.nodeType&&r.push(n);return r},x.find.CLASS=b.getElementsByClassName&&function(e,t){if(void 0!==t.getElementsByClassName&&$)return t.getElementsByClassName(e)},H=[],_=[],(b.qsa=he.test(D.querySelectorAll))&&(i(function(e){L.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&_.push("[*^$]="+ee+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||_.push("\\["+ee+"*(?:value|"+Z+")"),e.querySelectorAll("[id~="+F+"-]").length||_.push("~="),e.querySelectorAll(":checked").length||_.push(":checked"),e.querySelectorAll("a#"+F+"+*").length||_.push(".#.+[+~]")}),i(function(e){var t=D.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&_.push("name"+ee+"*[*^$|!~]?="),e.querySelectorAll(":enabled").length||_.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),_.push(",.*:")})),(b.matchesSelector=he.test(q=L.matches||L.webkitMatchesSelector||L.mozMatchesSelector||L.oMatchesSelector||L.msMatchesSelector))&&i(function(e){b.disconnectedMatch=q.call(e,"div"),q.call(e,"[s!='']:x"),H.push("!=",re)}),_=_.length&&new RegExp(_.join("|")),H=H.length&&new RegExp(H.join("|")),t=he.test(L.compareDocumentPosition),M=t||he.test(L.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)for(;t=t.parentNode;)if(t===e)return!0;return!1},z=t?function(e,t){if(e===t)return j=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!b.sortDetached&&t.compareDocumentPosition(e)===n?e===D||e.ownerDocument===O&&M(O,e)?-1:t===D||t.ownerDocument===O&&M(O,t)?1:S?K(S,e)-K(S,t):0:4&n?-1:1)}:function(e,t){if(e===t)return j=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,s=[e],l=[t];if(!i||!o)return e===D?-1:t===D?1:i?-1:o?1:S?K(S,e)-K(S,t):0;if(i===o)return a(e,t);for(n=e;n=n.parentNode;)s.unshift(n);for(n=t;n=n.parentNode;)l.unshift(n);for(;s[r]===l[r];)r++;return r?a(s[r],l[r]):s[r]===O?-1:l[r]===O?1:0}),D},t.matches=function(e,n){return t(e,null,null,n)},t.matchesSelector=function(e,n){if((e.ownerDocument||e)!==D&&A(e),n=n.replace(le,"='$1']"),b.matchesSelector&&$&&!W[n+" "]&&(!H||!H.test(n))&&(!_||!_.test(n)))try{var r=q.call(e,n);if(r||b.disconnectedMatch||e.document&&11!==e.document.nodeType)return r}catch(e){}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(ve,be),e[3]=(e[3]||e[4]||e[5]||"").replace(ve,be),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||t.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&t.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return de.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&ue.test(n)&&(t=T(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(ve,be).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=B[e+" "];return t||(t=new RegExp("(^|"+ee+")"+e+"("+ee+"|$)"))&&B(e,function(e){return t.test("string"==typeof e.className&&e.className||void 0!==e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(e,n,r){return function(i){var o=t.attr(i,e);return null==o?"!="===n:!n||(o+="","="===n?o===r:"!="===n?o!==r:"^="===n?r&&0===o.indexOf(r):"*="===n?r&&-1(?:<\/\1>|)$/,ge=/^.[^:#\[\.,]*$/;ae.filter=function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?ae.find.matchesSelector(r,e)?[r]:[]:ae.find.matches(e,ae.grep(t,function(e){return 1===e.nodeType}))},ae.fn.extend({find:function(e){var t,n=[],r=this,i=r.length;if("string"!=typeof e)return this.pushStack(ae(e).filter(function(){for(t=0;t)[^>]*|#([\w-]*))$/;(ae.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||ye,"string"!=typeof e)return e.nodeType?(this.context=this[0]=e,this.length=1,this):ae.isFunction(e)?void 0!==n.ready?n.ready(e):e(ae):(void 0!==e.selector&&(this.selector=e.selector,this.context=e.context),ae.makeArray(e,this));if(!(r="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&3<=e.length?[null,e,null]:ve.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof ae?t[0]:t,ae.merge(this,ae.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:G,!0)),me.test(r[1])&&ae.isPlainObject(t))for(r in t)ae.isFunction(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}if((i=G.getElementById(r[2]))&&i.parentNode){if(i.id!==r[2])return ye.find(e);this.length=1,this[0]=i}return this.context=G,this.selector=e,this}).prototype=ae.fn,ye=ae(G);var be=/^(?:parents|prev(?:Until|All))/,xe={children:!0,contents:!0,next:!0,prev:!0};ae.fn.extend({has:function(e){var t,n=ae(e,this),r=n.length;return this.filter(function(){for(t=0;ta",oe.leadingWhitespace=3===je.firstChild.nodeType,oe.tbody=!je.getElementsByTagName("tbody").length,oe.htmlSerialize=!!je.getElementsByTagName("link").length,oe.html5Clone="<:nav>"!==G.createElement("nav").cloneNode(!0).outerHTML,De.type="checkbox",De.checked=!0,Ae.appendChild(De),oe.appendChecked=De.checked,je.innerHTML="",oe.noCloneChecked=!!je.cloneNode(!0).lastChild.defaultValue,Ae.appendChild(je),(De=G.createElement("input")).setAttribute("type","radio"),De.setAttribute("checked","checked"),De.setAttribute("name","t"),je.appendChild(De),oe.checkClone=je.cloneNode(!0).cloneNode(!0).lastChild.checked,oe.noCloneEvent=!!je.addEventListener,je[ae.expando]=1,oe.attributes=!je.getAttribute(ae.expando);var Be={option:[1,""],legend:[1,""],area:[1,""],param:[1,""],thead:[1,""],tr:[2,""],col:[2,""],td:[3,""],_default:oe.htmlSerialize?[0,"",""]:[1,"X","
"]};Be.optgroup=Be.option,Be.tbody=Be.tfoot=Be.colgroup=Be.caption=Be.thead,Be.th=Be.td;var Ie=/<|?\w+;/,We=/]","i"),Ge=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi,Ke=/