"use strict";var ctaPopUp_div=document.createElement("div"),ctaPopUp_data={},ctaPopUp_value={},ctaPopUp_setting={},ctaPopUpAddBoxFlag=!0,ctaPopUp_scriptEle=document.querySelector("#ctapopup-2021"),ctaPopUp_src=ctaPopUp_scriptEle.getAttribute("src"),ctaPopUp_storeID=ctaPopUp_src.split("?")[1].split("=")[1],ctapopup_putFlag=!1,openPopPage=!1,url=" ";!function(){var t=document.createElement("link");t.setAttribute("rel","stylesheet"),t.setAttribute("type","text/css"),t.setAttribute("href","https://wix.salesdish.com/page/css/ctaPopUp.css"),document.body.appendChild(t),"undefined"==typeof jQuery&&((t=document.createElement("script")).src="https://wix.salesdish.com/page/js/jquery-3.4.1.min.js",document.head.appendChild(t));var e=setInterval(function(){"function"==typeof jQuery&&($(".ctaPopUp_box")&&$(".ctaPopUp_box").remove(),$(".antools_preview_ctaPopUp")&&$(".antools_preview_ctaPopUp").remove(),CtaPopUpMain(),clearInterval(e))},200)}();var _wr=function(o){var a=history[o];return function(){var t=a.apply(this,arguments),e=new Event(o);return e.arguments=arguments,window.dispatchEvent(e),t}};function CtaPopUpMain(){var s=!(ctapopup_putFlag=!0);$(document).ready(function(){var t={toolsId:36435,shop:ctaPopUp_storeID,onlyVisible:1};$.ajax({type:"get",url:"https://gateway.salesdish.com/shopify-service/app-config/pass/2021?params=CTA+pop-ups&store_id="+ctaPopUp_storeID+"&is_preview=1",success:function(t){t.success&&(s=t.is_open["CTA pop-ups"])}}),$.ajax({type:"get",url:"https://gateway.salesdish.com/shopify-service/app-config/pass/2021?params=CTA+pop-ups+Settings&store_id="+ctaPopUp_storeID+"&is_preview=1",success:function(t){t.success&&(ctaPopUp_setting=JSON.parse(t.data["CTA pop-ups Settings"]))}}),$.ajax({type:"get",url:"https://gateway.salesdish.com/shopify-service/app-config-detail/pass/2021",data:t,success:function(t){if(t.success&&0<t.list.length&&s){null!=localStorage.getItem("routerPage")&&""!=localStorage.getItem("routerPage")||localStorage.setItem("routerPage",0),null!=localStorage.getItem("oldctaPopUpTime")&&""!=localStorage.getItem("oldctaPopUpTime")||localStorage.setItem("oldctaPopUpTime",ctaPopUp_setting.addHour),null!=localStorage.getItem("ctaPopUpTime")&&""!=localStorage.getItem("ctaPopUpTime")||localStorage.setItem("ctaPopUpTime",ctaPopUp_setting.addHour);var e=localStorage.getItem("oldctaPopUpTime");ctaPopUp_setting.addHour!==Number(e)&&(localStorage.setItem("oldctaPopUpTime",ctaPopUp_setting.addHour.toString()),localStorage.setItem("ctaPopUpTime",ctaPopUp_setting.addHour.toString())),""!==localStorage.getItem("routerIndex")&&null!==localStorage.getItem("routerIndex")||localStorage.setItem("routerIndex",JSON.stringify([])),""!==localStorage.getItem("inputIndex")&&null!==localStorage.getItem("inputIndex")||localStorage.setItem("inputIndex",JSON.stringify([])),""!==localStorage.getItem("cartIndex")&&null!==localStorage.getItem("cartIndex")||localStorage.setItem("cartIndex",JSON.stringify([])),null!==localStorage.getItem("isBinding2")&&""!=localStorage.getItem("isBinding2")||localStorage.setItem("isBinding2",JSON.stringify([])),null!==localStorage.getItem("firstInPage")&&""!=localStorage.getItem("firstInPage")||localStorage.setItem("firstInPage",!0);var o=JSON.parse(localStorage.getItem("inputIndex")),a=JSON.parse(localStorage.getItem("cartIndex")),n=JSON.parse(localStorage.getItem("routerIndex")),c=JSON.parse(localStorage.getItem("isBinding2")),l=JSON.parse(localStorage.getItem("firstInPage"));"1"===localStorage.getItem("isBinding1")&&t.list.forEach(function(t,e){"Directly capture"===t.type&&"1"===localStorage.getItem("isBinding1")&&(-1===n.indexOf(t.id)&&n.push(t.id),-1===a.indexOf(t.id)&&a.push(t.id),-1===o.indexOf(t.id)&&o.push(t.id))}),c.length&&t.list.forEach(function(t,e){"Discount capture"===t.type&&(-1!==c.indexOf(t.id)&&-1===n.indexOf(t.id)&&n.push(t.id),-1!==c.indexOf(t.id)&&-1===a.indexOf(t.id)&&a.push(t.id),-1!==c.indexOf(t.id)&&-1===o.indexOf(t.id)&&o.push(t.id))});var p=0,i=0;if(t.list.forEach(function(o,t){n.forEach(function(t,e){o.id==t&&p++}),a.forEach(function(t,e){o.id==t&&i++})}),p===t.list.length)return localStorage.setItem("ctaPopUpTime",(new Date).getTime()+36e5*Number(ctaPopUp_setting.hours)),void localStorage.setItem("routerIndex",JSON.stringify([]));i!==t.list.length?(e=localStorage.getItem("routerPage"),$(".antools_preview_ctaPopUp")&&$(".antools_preview_ctaPopUp").remove(),l?(openPopPage=!0,routerPopUp(t,n),localStorage.setItem("firstInPage",!1)):-1===ctaPopUp_setting.settted.indexOf("2")||"/cart-page"!==window.location.pathname&&"/cart"!==window.location.pathname?Number(e)>=Number(ctaPopUp_setting.page_view)&&(new Date).getTime()>=localStorage.getItem("ctaPopUpTime")&&(openPopPage=!0,routerPopUp(t,n)):(openPopPage=!0,cartPopUp(t,a))):localStorage.setItem("cartIndex",JSON.stringify(o))}}})})}function routerPopUp(o,t){for(var e=Math.floor(Math.random()*o.list.length),a=o.list[e].id;-1!==t.indexOf(a);)e=Math.floor(Math.random()*o.list.length),a=o.list[e].id;var n=null,c=null;o.list.forEach(function(t,e){t.id==a&&(n=JSON.parse(o.list[e].value),c=o.list[e])}),"1"==n.tiggerEvent?(ctaPopUpAddBoxFlag=!0,setTimeout(function(){$(".ctaPopUp_box")&&$(".ctaPopUp_box").remove(),GeneratePopup(c,n),localStorage.setItem("routerPage",0),t.includes(a)||(t.push(a),localStorage.setItem("routerIndex",JSON.stringify(t)))},1e3*Number(n.countNum))):(ctaPopUpAddBoxFlag=!0,window.onbeforeunload=function(){return setTimeout(function(){$(".ctaPopUp_box").remove(),$(".antools_preview_ctaPopUp").remove(),GeneratePopup(c,n),localStorage.setItem("routerPage",0),t.includes(a)||(t.push(a),localStorage.setItem("routerIndex",JSON.stringify(t)))},1e3*Number(n.countNum))," "})}function cartPopUp(o,t){for(var e=Math.floor(Math.random()*o.list.length),a=o.list[e].id;-1!==t.indexOf(a);)e=Math.floor(Math.random()*o.list.length),a=o.list[e].id;var n=null,c=null;o.list.forEach(function(t,e){t.id==a&&(n=JSON.parse(o.list[e].value),c=o.list[e])}),ctaPopUpAddBoxFlag=!0,window.onbeforeunload=function(){return setTimeout(function(){$(".ctaPopUp_box").remove(),$(".antools_preview_ctaPopUp").remove(),GeneratePopup(c,n),t.includes(a)||(t.push(a),localStorage.setItem("cartIndex",JSON.stringify(t)))},1e3),"wlgq"}}function GeneratePopup(o,a){var t;ctaPopUpAddBoxFlag&&(ctaPopUpAddBoxFlag=!1,ctaPopUp_div.className="antools_preview_ctaPopUp",ctaPopUp_div.id="antools_preview_ctaPopUp",document.body.appendChild(ctaPopUp_div),t="","Directly capture"===o.type?(t=0!=a.bgIndex?'\n        <p class="tittext">'+a.initleIntit+'</p>\n        <span class="context">'+a.initleIncont+'</span>\n        <input class="email" placeholder="'+a.initleInemail+'" onfocus="this.placeholder=\'\'" onblur="this.placeholder=\''+a.initleInemail+'\'" />\n        <button class="ctaPopup_sign directly_capture" style= background:'+a.faceBtncolor+";cursor:pointer;>"+a.initleInbtn+"</button>\n        ":'\n        <p class="tittext" style="color:'+a.Tcolor+'">'+a.initleIntit+'</p>\n        <span class="context" style="color:'+a.Tcolor+'">'+a.initleIncont+'</span>\n        <input class="email" placeholder="'+a.initleInemail+'" onfocus="this.placeholder=\'\'" onblur="this.placeholder=\''+a.initleInemail+'\'" />\n        <button class="ctaPopup_sign  directly_capture" style= "background:'+a.Bucolor+"; color:"+a.BuTcolor+'; cursor:pointer;">'+a.initleInbtn+"</button>\n        ",$(document).on("click",".directly_capture",function(){var t=new RegExp("^[a-z0-9A-Z]+[- | a-z0-9A-Z . _]+@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$"),e=$(".email").val();""!==e&&t.test(e)?ctapopup_putFlag&&(ctapopup_putFlag=!1,$.ajax({type:"put",url:"https://gateway.salesdish.com/shopify-service/app-tools/pass/mail/addmember/2021?store_id="+ctaPopUp_storeID+"&mail="+e+"&app_name=Directly capture&config_id="+o.id,success:function(t){t.success&&200===t.code?(0!=a.bgIndex?($("#text_area")[0].innerHTML="",$("#text_area")[0].innerHTML='\n                      <p class="tittext">'+a.resultIntit+'</p>\n                      <span class="context">'+a.resultIncont+"</span>\n                  "):($("#text_area")[0].innerHTML="",$("#text_area")[0].innerHTML='\n                      <p class="tittext" style="color:'+a.Tcolor+'">'+a.resultIntit+'</p>\n                      <span class="context" style="color:'+a.Tcolor+'">'+a.resultIncont+"</span>\n                  "),$(".ctaPopUp_close_img")[0].style.display="block",localStorage.setItem("isBinding1",1)):201===t.code&&($("#antools_ctaPopUp_email").html(ctaPopUp_setting.emailUsed),$("#antools_ctaPopUp_email").css("display","flex").animate({bottom:"70px"}).delay(3e3).animate({bottom:"0"}).hide(0))}})):($("#antools_ctaPopUp_email").html(ctaPopUp_setting.Invalid),$("#antools_ctaPopUp_email").css("display","flex").animate({bottom:"70px"}).delay(3e3).animate({bottom:"0"}).hide(0))})):"Discount capture"===o.type?(t=0!=a.bgIndex?'\n        <p class="tittext">'+a.initleIntit+'</p>\n        <span class="context">'+a.initleIncont+'</span>\n        <input class="email" placeholder="'+a.initleInemail+'" onfocus="this.placeholder=\'\'" onblur="this.placeholder=\''+a.initleInemail+'\'"/>\n        <button class="ctaPopup_sign discount_capture" style= background:'+a.faceBtncolor+";cursor:pointer;>"+a.initleInbtn+"</button>\n        ":'\n        <p class="tittext" style="color:'+a.Tcolor+'">'+a.initleIntit+'</p>\n        <span class="context" style="color:'+a.Tcolor+'">'+a.initleIncont+'</span>\n        <input class="email" placeholder="'+a.initleInemail+'" onfocus="this.placeholder=\'\'" onblur="this.placeholder=\''+a.initleInemail+'\'"/>\n        <button class="ctaPopup_sign discount_capture" style= "background:'+a.Bucolor+";color:"+a.BuTcolor+';cursor:pointer">'+a.initleInbtn+"</button>\n        ",$(document).on("click",".discount_capture",function(){var t=new RegExp("^[a-z0-9A-Z]+[- | a-z0-9A-Z . _]+@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$"),e=$(".email").val();""!==e&&t.test(e)?(ctapopup_putFlag&&(ctapopup_putFlag=!1,$.ajax({type:"put",url:"https://gateway.salesdish.com/shopify-service/app-tools/pass/mail/addmember/2021?store_id="+ctaPopUp_storeID+"&mail="+e+"&app_name=Discount capture&config_id="+o.id,success:function(t){var e;t.success&&200===t.code?(0!=a.bgIndex?($("#text_area")[0].innerHTML="",$("#text_area")[0].innerHTML='\n                    <p class="tittext">'+a.resultIntit+'</p>\n                    <span class="context">'+a.resultIncont+'</span>\n                    <div class="code" style= background:'+a.faceBtncolor+">"+a.initleInbtn2+"</div>\n                "):($("#text_area")[0].innerHTML="",$("#text_area")[0].innerHTML='\n                    <p class="tittext" style="color:'+a.Tcolor+'" >'+a.resultIntit+'</p>\n                    <span class="context" style="color:'+a.Tcolor+'" >'+a.resultIncont+'</span>\n                    <div class="code" style= "background:'+a.Bucolor+";color:"+a.BuTcolor+'">'+a.initleInbtn2+"</div>\n                "),$(".ctaPopUp_close_img")[0].style.display="block",-1===(e=JSON.parse(localStorage.getItem("isBinding2"))).indexOf(o.id)&&(e.push(o.id),localStorage.setItem("isBinding2",JSON.stringify(e)))):201===t.code&&($("#antools_ctaPopUp_email").html(ctaPopUp_setting.emailUsed),$("#antools_ctaPopUp_email").css("display","flex").animate({bottom:"70px"}).delay(3e3).animate({bottom:"0"}).hide(0))}})),$(document).on("click",".code",function(t){var e=t.target.innerHTML,t=document.createElement("input");t.value=e,document.body.appendChild(t),t.select(),document.execCommand("Copy"),t.className="oInput",t.style.display="none",$("#antools_ctaPopUp_email").html("Discount code copied to clipboard"),$("#antools_ctaPopUp_email").css("display","flex").animate({bottom:"70px"}).delay(3e3).animate({bottom:"0"}).hide(0)})):($("#antools_ctaPopUp_email").html(ctaPopUp_setting.Invalid),$("#antools_ctaPopUp_email").css("display","flex").animate({bottom:"70px"}).delay(3e3).animate({bottom:"0"}).hide(0))})):"Guide to click"===o.type&&(t=0!=a.bgIndex?'\n        <span class="context2">'+a.initleIntit+'</span>\n        <p class="tittext2">'+a.initleIncont+'</p>\n        <button class="ctaPopup_clicktoUrl" style= background:'+a.faceBtncolor+";cursor:pointer;>"+a.initleInbtn+'</button>\n        <p class="context3">'+a.resultIncont+"</p>\n        ":'\n        <span class="context2" style="color:'+a.Tcolor+'">'+a.initleIntit+'</span>\n        <p class="tittext2" style="color:'+a.Tcolor+'">'+a.initleIncont+'</p>\n        <button class="ctaPopup_clicktoUrl" style= "background:'+a.Bucolor+";color:"+a.BuTcolor+'cursor:pointer;">'+a.initleInbtn+'</button>\n        <p class="context3" style="color:'+a.Tcolor+'">'+a.resultIncont+"</p>\n        ",$(document).on("click",".ctaPopup_clicktoUrl",function(){window.open(a.actionURL),openPopPage=!1}),$(document).on("click",".context3",function(){$(".ctaPopUp_box").remove(),$(".antools_preview_ctaPopUp").remove(),openPopPage=!1})),$("body").append('<div class="antools_ctaPopUp_email" id="antools_ctaPopUp_email"></div>'),0!=a.bgIndex?$(".antools_preview_ctaPopUp").append('\n        <div class="ctaPopUp_box">\n        <div class="close_ctaPopup">\n        <div class="ctaPopUp_close_img">\n        <img class="ctaPopUp_close_img" src="https://app.salesdish.com/static/close_ctaPopup.svg" />\n        </div>\n        </div>\n        <div class="ctaPopUp" id="ctaPopUp" style= background:url("'+a.topbgimg+'.png") 0% 0% / cover no-repeat;>\n            <div class="text_area" id="text_area">'+t+"</div>\n        </div>\n        </div>\n    "):$(".antools_preview_ctaPopUp").append('\n        <div class="ctaPopUp_box">\n        <div class="close_ctaPopup">\n        <div class="ctaPopUp_close_img">\n        <img class="ctaPopUp_close_img" src="https://app.salesdish.com/static/close_ctaPopup.svg" />\n        </div>\n        </div>\n        <div class="ctaPopUp" id="ctaPopUp" style= background:'+a.topbgimg+';>\n            <div class="text_area" id="text_area">'+t+"</div>\n        </div>\n        </div>\n    "),a.bgIndex<3?$("#ctaPopUp")[0].style.justifyContent="center":$("#ctaPopUp")[0].style.justifyContent="flex-start",ctaPopUp_setting.settted.includes("1")?$(".ctaPopUp_close_img")[0].style.display="block":$(".ctaPopUp_close_img")[0].style.display="none",document.querySelector(".ctaPopUp_close_img"),$(".ctaPopUp_close_img").on("click",function(){$(".ctaPopup_sign").remove(),$(".text_area").remove(),t="",$(".ctaPopUp_box").remove(),$(".antools_preview_ctaPopUp").remove(),openPopPage=!1}))}history.pushState=_wr("pushState"),history.replaceState=_wr("replaceState"),window.addEventListener("replaceState",function(t){localStorage.setItem("routerPage",Number(localStorage.getItem("routerPage"))+1),openPopPage||CtaPopUpMain()});