// source --> https://www.ghosh.com/wp-content/plugins/wp-optin-wheel/public/js/public.min.js?ver=1.5.2 
var WOF;!function(e){var n=function(){function e(){}return e.set=function(e,n,t){if(!e||/^(?:expires|max\-age|path|domain|secure)$/i.test(e))return!1;var o=new Date;o.setTime(o.getTime()+24*t*60*60*1e3);var r=";expires="+o.toUTCString();return document.cookie=encodeURIComponent(e)+"="+encodeURIComponent(n)+r+"; path=/;samesite=lax",!0},e.has=function(e){return!!e&&new RegExp("(?:^|;\\s*)"+encodeURIComponent(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(document.cookie)},e.remove=function(e){return!!this.has(e)&&(document.cookie=encodeURIComponent(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/",!0)},e}();e.CookieHelper=n}(WOF||(WOF={}));
var WOF;!function(e){var t=function(){function t(){}return t.getFormFieldValues=function(e){var t=[],r=e.find(".wof-form-fields input,.wof-form-fields select");return jQuery.each(r,function(e,r){var a=jQuery(r),i=a.data("type");"primary_email"!==i&&t.push({id:a.data("fieldId"),value:"consent_checkbox"===i?a.is(":checked"):a.val(),type:i})}),t},t.buildForm=function(t){var r=[];return t.length?(t.forEach(function(t){r.push(e.FormBuilder.createField(t))}),r):[]},t.createField=function(e){e.type=e.type.toLowerCase();var t=jQuery("<div>"),r=null;switch(e.type){case"consent_checkbox":r=jQuery('<input type="checkbox">');break;default:r=jQuery('<input type="'+("number"===e.type?"number":"primary_email"===e.type?"email":"text")+'">').attr("placeholder",e.placeholder)}switch(r.data("type",e.type).data("fieldId",e.id?e.id:""),e.type){case"primary_email":r.attr("name","wof-email")}return t.append(r),e.required&&r.data("wofRequired","primary_email"===e.type||"email"===e.type?"email":"consent_checkbox"===e.type?"checked":"text"),"consent_checkbox"===e.type&&(r.attr("id","ckb-"+e.id),t.append('<label for="ckb-'+e.id+'">'+e.placeholder+"</label>")),t},t}();e.FormBuilder=t}(WOF||(WOF={}));
var WOF;!function(e){var n=function(){function n(){this.wheels=[],this.init()}return n.prototype.init=function(){var n=this;jQuery(".wof-wheel").each(function(t,o){var i=jQuery(o),r=new e.Wheel(i,i.data("id"),i.data("options"),i.data("seq"),i.data("standalone"));n.wheels.push(r);var a=e.FormBuilder.buildForm(i.data("fields"));jQuery.each(a,function(e,n){r.element.find(".wof-form-fields").append(n)})}),this.initFormSubmit(),this.initWheelEvents(),this.initShowWheels()},n.prototype.initShowWheels=function(){function e(e,n){var t=function(){var o=jQuery(window).scrollTop(),i=jQuery(document).height(),r=jQuery(window).height(),a=o/(i-r);Math.round(100*a);Math.round(100*a)>=n&&(e.show(),jQuery(window).off("scroll",t))};jQuery(window).on("scroll",t)}this.wheels.forEach(function(n){if(n.standalone)return void n.show();switch(n.options.appear){case"time":setTimeout(function(){n.show()},1e3*n.options.appearData);break;case"click":jQuery("."+n.options.appearData).on("click",function(e){e.preventDefault(),n.show()});break;case"exit":var t;document.documentElement.addEventListener("mouseleave",function(e){e.clientY>20||(t=setTimeout(function(){n.show()},100))}),document.documentElement.addEventListener("mouseenter",function(e){t&&clearTimeout(t)});break;case"scroll":e(n,n.options.appearData)}})},n.prototype.initWheelEvents=function(){this.wheels.forEach(function(e){e.element.on("click",".wof-close",function(n){n.preventDefault(),e.hide()}),e.element.find(".wof-response").on("click",".wof-btn-again",function(n){n.preventDefault(),e.element.find(".wof-wheel-container").removeClass("wof-spinning").css("animationName","unset").addClass("wof-spinning"),e.game.start()}),e.element.on("keypress","input",function(e){jQuery(e.currentTarget).removeClass("wof-form-error")})})},n.prototype.initFormSubmit=function(){this.wheels.forEach(function(n){n.element.find(".wof-btn-submit").off("click").on("click",function(t){if(t.preventDefault(),e.Helpers.validateForm(n.element)){e.Helpers.triggerLoading(jQuery(t.currentTarget));var o=n.element.find(".wof-email").val();e.Helpers.optIn(n.id,o,n.game.sequence,n.game.sequence,e.FormBuilder.getFormFieldValues(n.element)).then(function(t){if(n.game.mail=o,!1===t.success)return e.Helpers.triggerError(n.element,t.data),void e.Helpers.triggerLoading(n.element.find(".wof-btn-submit"));e.CookieHelper.set("wof-"+n.id,"1",365),n.game.start(t.data)})}})})},n}();e.Frontend=n}(WOF||(WOF={})),jQuery(window).on("load",function(){new WOF.Frontend});
var WOF;!function(e){var t=function(){function t(e,t,i,n){this.rotationDegrees=[720,1050,1020,990,960,930,900,870,840,810,780,750],this.game=0,this.$wheelElement=e,this.wheelId=t,this.sequence=n,this.previousSequence=n,this.maxPlays=i+1,this.status="idle"}return t.prototype.start=function(t){var i=this;void 0===t&&(t=null),this.canStartNewGame()&&(this.status="playing",this.game++,t?this.doPlay(t):(e.Helpers.triggerLoading(this.$wheelElement.find(".wof-btn-submit,.wof-btn-again")),e.Helpers.getSegment(this.wheelId,this.sequence,this.previousSequence,this.mail).then(function(e){if(!1===e.success)return i.triggerGameError(e.data);i.doPlay(e.data)})))},t.prototype.end=function(t){e.Helpers.setResultText(this.$wheelElement,t),this.status="idle"},t.prototype.triggerGameError=function(t){this.status="idle",e.Helpers.triggerError(this.$wheelElement,t),e.Helpers.triggerLoading(this.$wheelElement.find(".wof-btn-submit,.wof-btn-again"))},t.prototype.doPlay=function(e){var t=this;this.previousSequence=this.sequence?this.sequence:e.seq,this.sequence=e.seq,this.doAnimation(e.segment,function(){t.end(e)})},t.prototype.canStartNewGame=function(){return"playing"!==this.status},t.prototype.doAnimation=function(t,i){var n,s,o=this.rotationDegrees[t-1],r=0,a=0,u=o/30,h=!1,l=this.$wheelElement.find(".wof-wheel-container"),c=this.$wheelElement.find(".wof-pointer");l.css("animationName","spin-"+t),n=setInterval(function(){var t=e.Helpers.getRotationDegrees(l);!h&&t>=30*r+12&&(r++,a++,clearTimeout(s),s=setTimeout(function(){c.removeClass("do-nudge")},e.Helpers.calcAnimTimeOut(a,u)),c.addClass("do-nudge")),r%12==0&&(r=0,h=!0),h&&t<50&&(h=!1),a===u&&(clearInterval(n),"function"==typeof i&&setTimeout(function(){i()},100))},1)},t}();e.Game=t}(WOF||(WOF={}));
var WOF;!function(e){var n=function(){function n(){}return n.validateForm=function(e){var n=e.find("input"),t=!0;return jQuery.each(n,function(e,n){var i=jQuery(n),r=i.data("wofRequired");if(r&&r.length){var o=i.val(),f=!0;switch(r){case"email":-1!==o.indexOf("@")&&-1!==o.indexOf(".")||(t=f=!1);break;case"checked":i.is(":checked")||(t=f=!1);break;default:o.length||(t=f=!1)}f||(i.addClass("wof-form-error do-form-nudge"),setTimeout(function(){i.removeClass("do-form-nudge")},300))}}),t},n.isMobile=function(){return jQuery(".wof-mobile-check").is(":visible")},n.isTablet=function(){return jQuery(".wof-tablet-check").is(":visible")},n.getSegment=function(n,t,i,r){return jQuery.post(window.wofVars.ajaxurl,{action:"wof-lite-play",id:n,mail:r,seq:t,pseq:i,nonce:e.Helpers.getNonce()}).then(function(e){return e})},n.optIn=function(n,t,i,r,o){return jQuery.post(window.wofVars.ajaxurl,{action:"wof-lite-email-optin",id:n,mail:t,seq:i,pseq:r,nonce:e.Helpers.getNonce(),fields:JSON.stringify(o)}).then(function(e){return e})},n.getNonce=function(){return jQuery("[data-wof-nonce]").data("wofNonce")},n.triggerError=function(e,n){e.find(".wof-error").html(n).fadeIn("fast"),setTimeout(function(){e.find(".wof-error").fadeOut("fast")},7e3)},n.triggerLoading=function(e){var n=e.find("span");n.is(":visible")?(e.attr("disabled",!0).find(".wof-loader").show(),n.hide()):(n.show(),e.attr("disabled",!1).find(".wof-loader").hide())},n.calcAnimTimeOut=function(e,n){var t=200/(n/e);return Math.round(t<100?100:t)},n.setResultText=function(e,n){var t=e.find(".wof-right-inner");t.fadeOut(150,function(){e.find(".wof-form-fields").remove(),e.find(".wof-title").html(n.title),e.find(".wof-explainer").html(n.text),e.find(".wof-btn-submit").hide(),e.find(".wof-disclaimer").hide(),n.value?e.find(".wof-email").val(n.value).show():e.find(".wof-email").hide(),e.find(".wof-response").html(n.html),t.fadeIn(150)})},n.getRotationDegrees=function(e){var n=e.css("-webkit-transform")||e.css("transform");if("none"!==n)var t=n.split("(")[1].split(")")[0].split(","),i=t[0],r=t[1],o=Math.round(Math.atan2(r,i)*(180/Math.PI));else var o=0;return o<0&&(o+=360),o},n}();e.Helpers=n}(WOF||(WOF={}));
var WOF;!function(e){var t=function(){function t(t,s,i,o,a){void 0===a&&(a=!1),this.storageKey="wof-"+s,this.element=t,this.id=s,this.options=i,this.status="hidden",this.standalone=a,this.game=new e.Game(t,s,i.plays,o)}return t.prototype.show=function(){if("visible"!==this.status){if("click"!==this.options.appear){if(this.options.hideMobile&&e.Helpers.isMobile())return;if(!this.standalone&&!this.canShow())return}this.element.addClass("wof-visible"),this.standalone||jQuery(".wof-overlay").fadeIn(200),this.status="visible","click"!==this.options.appear&&this.setOccurance()}},t.prototype.hide=function(e){void 0===e&&(e=!1),"hidden"!==this.status&&(this.element.removeClass("wof-visible"),this.status="hidden",this.standalone||jQuery(".wof-wheel.wof-visible").not('[data-standalone="1"]').length||jQuery(".wof-overlay").fadeOut(200))},t.prototype.canShow=function(){return!(sessionStorage.getItem(this.storageKey)||localStorage.getItem(this.storageKey)||e.CookieHelper.has(this.storageKey))},t.prototype.setOccurance=function(){switch(this.options.occurance){case"session":sessionStorage.setItem(this.storageKey,"1");break;case"storage":localStorage.setItem(this.storageKey,"1");break;case"time":e.CookieHelper.remove(this.storageKey),e.CookieHelper.set(this.storageKey,"1",this.options.occuranceData)}},t}();e.Wheel=t}(WOF||(WOF={}));