"use strict";var TIMEOUT=150,BASE_NEEDLE_ANGLE=22.5,START_NEEDLE_MOVE_ANGLE=21,END_NEEDLE_MOVE_ANGLE=29,NEEDLE_ANGLE_INCREMENT=4.5,DECIMAL_MULTIPLIER=1e3,CLOSE_WIDGET_LINK="--close-widget--",PUSH_PERMISSION_LINK="--push-permission--",AP3_WIDGETS_PREFIX="ap_widgets_",AP3_SESSION_KEY_COOKIE_NAME="ap3sessionkey",HIDDEN_FIELDS_REGEX=/INPUT.hidden\/(.*?) /gm,HIDDEN_FIELDS_SUBSTITUTION="",AP3_MAX_Z_INDEX=2147483647,cookies={SHOWN:"ap3shown",SHOWN_IN_CURRENT_SESSION:"ap3sess",PAGES_VISITED_IN_SESSION:"ap3pages",DISMISSED:"ap3dm",CONVERTED:"ap3converted",CUSTOM_CONSENT_TO_TRACK:"ap3cct",PRIORITY:"ap3prio"},frequencies={ALWAYS:"always",UNTIL_DIMISSED_OR_CONVERTED:"until dismissed",ONCE_PER_SESSION_OR_UNTIL_CONVERTED:"once per session",ONCE_PER_SESSION:"once per session",ONLY_ONCE:"only once",UNTIL_KNOWN:"until they are known"},preFillOptionIds={DONT_PRE_FILL:"dont_pre_fill",VIA_URL:"via_url"},visibilityOptionIds={HIDE_ON_PRE_FILL:"hide_on_pre_fill"},netPromoterScoreThanksVariants={ANY:"any",DETRACTOR:"detractor",PASSIVE:"passive",PROMOTER:"promoter"},buttonOnClickIds={GO_TO_URL:"go-to-url",THANK_YOU:"thank-you",PLAY_VIDYARD_VIDEO:"play-vidyard-video",DOWNLOAD_FILE:"download-file"},AP_MAX_PHONE_WIDTH_MAP={1:10,7:10,20:9,27:9,30:10,31:9,32:9,33:9,34:9,36:9,39:11,40:9,41:12,43:13,44:10,46:13,48:9,49:13,51:11,52:10,54:10,55:10,56:9,57:10,58:10,60:9,61:15,62:10,63:10,66:9,81:13,82:11,84:10,86:12,90:10,91:10,92:11,93:9,94:9,95:9,98:10,212:9,213:9,216:8,218:9,221:9,223:8,224:8,225:8,226:8,227:8,228:8,229:8,232:8,233:9,234:10,235:8,237:8,243:9,244:9,249:9,250:9,251:9,252:8,254:10,255:9,256:9,257:8,258:9,260:9,261:10,263:10,264:10,265:8,351:11,370:8,372:8,373:8,374:8,375:10,380:9,420:12,502:8,505:8,509:8,591:8,593:8,595:9,675:11,850:17,852:9,855:8,856:10,880:10,886:9,961:8,962:9,963:10,964:10,966:9,967:9,972:9,977:9,992:9,993:8,994:9,996:9,998:9};ap3c._isMobile=function(){var _isMobile=!1;return window.navigator&&window.navigator.userAgent&&(_isMobile=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent)),_isMobile},ap3c._isIOSWebView=function(){var _isIOSWebView=!1;return window.navigator&&window.navigator.userAgent&&(_isIOSWebView=/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(window.navigator.userAgent)),_isIOSWebView},ap3c._isIOSSafari=function(){var iOSSafari=!1;if(window.navigator&&window.navigator.userAgent){var ua=window.navigator.userAgent,iOS=!!ua.match(/iPad/i)||!!ua.match(/iPhone/i),hasWebkit=!!ua.match(/WebKit/i);iOSSafari=iOS&&hasWebkit&&!ua.match(/CriOS/i)}return iOSSafari};var isNotificationSupported=function(){return"Notification"in window&&"serviceWorker"in navigator&&"PushManager"in window},isAndroidWebView=function(){var ua=window.navigator.userAgent,isAndroid=/Android/.test(ua),isWebView=/wv/.test(ua)||/Version\/[\d.]+/.test(ua);return isAndroid&&isWebView},isRunningWithinSDK=function(){return!!(window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.messageHandler)||!!window.Android},validShopifyCartAddPaths={"/cart/add.js":!0,"/cart/add":!0},validShopifyCartAddStatuses={200:!0,302:!0},urlParamKeys={AP_WIDGET:"ap_widget"},platforms={IOS:"ios",ANDROID:"android"},getUrlParams=function(search){var params={};return search&&search.slice(search.indexOf("?")+1).split("&").map(function(hash){var keyValTuple=hash.split("=");params[decodeURIComponent(keyValTuple[0])]=decodeURIComponent(keyValTuple[1])}),params},getFieldType=function(el){if(-1!==el.className.indexOf("ap3w-input-areacode"))return"area-code";if(-1!==el.parentElement.className.indexOf("ap3w-input-select-option")||-1!==el.parentElement.className.indexOf("ap3w-form-input-select-option"))return"multi-select";var inputTypeAttr=el.parentElement.dataset&&el.parentElement.dataset.inputType;return inputTypeAttr||("number"===el.name||"date"===el.name||"datetime-local"===el.name?el.name:el.getAttribute("type"))},getDefaultValue=function(preFillOption,fieldId,el){if(!preFillOption||preFillOption===preFillOptionIds.DONT_PRE_FILL)return null;var queryParams=getUrlParams(window.location.search),fieldType=getFieldType(el),defaultValueFromParams=queryParams[fieldId],defaultValue=!defaultValueFromParams&&"areacode"===fieldType&&ap3c.country_code?ap3c.country_code:defaultValueFromParams;if(!defaultValue)return null;var dateParts,month,day,inputTypeAttr=el.parentElement.dataset&&el.parentElement.dataset.inputType;switch("date"!==fieldType&&"datetime-local"!==fieldType||(el.type=inputTypeAttr||el.name,fieldType=el.type),fieldType){case"date":return ap3c.date_format&&"dmy"===ap3c.date_format.substring(0,3)?defaultValue.split("-").reverse().join("-"):ap3c.date_format&&"mdy"===ap3c.date_format.substring(0,3)?(month=(dateParts=defaultValue.split("-"))[0],day=dateParts[1],dateParts[2]+"-"+month+"-"+day):defaultValue;case"datetime-local":var dateTimeParts=defaultValue.split("T"),date=dateTimeParts[0],time=dateTimeParts[1];return ap3c.date_format&&"dmy"===ap3c.date_format.substring(0,3)?date.split("-").reverse().join("-")+"T"+time:ap3c.date_format&&"mdy"===ap3c.date_format.substring(0,3)?(month=(dateParts=date.split("-"))[0],day=dateParts[1],dateParts[2]+"-"+month+"-"+day+"T"+time):defaultValue;case"tel":return defaultValue.split("-")[1];case"area-code":return defaultValue.split("-")[0].replace("+","");case"checkbox":return"true"===defaultValue;case"multi-select":return-1!==defaultValue.split(",").indexOf(el.parentElement.dataset.value);default:return defaultValue}},populateSelectOptions=function(selectList,selectFieldEl,selectedOptions,isEmbeddableForm){var selectListTrigger=selectList.previousElementSibling,fieldDataAttributes=isEmbeddableForm?selectList.closest(".ap3w-form-input").dataset:selectList.closest(".ap3w-input").dataset,isMultiSelect="multi_select"===selectList.dataset.selectType,selectListId=isEmbeddableForm?selectList.dataset.newListId:selectList.dataset.listId;isMultiSelect&&selectFieldEl.firstElementChild.checked&&(selectedOptions[selectListId]||(selectedOptions[selectListId]=[]),selectedOptions[selectListId].push(selectFieldEl.dataset.value),selectFieldEl.classList.add("ap3w-form-input-select-option-selected"),selectListTrigger.innerText=selectedOptions[selectListId].join(", "),selectListTrigger.value=selectedOptions[selectListId]);var defaultValue=getDefaultValue(fieldDataAttributes.preFillOption,fieldDataAttributes.fieldId,selectFieldEl);isMultiSelect||defaultValue!==selectFieldEl.dataset.value||(selectedOptions[selectListId]=defaultValue,selectListTrigger.innerText=selectedOptions[selectListId],selectListTrigger.value=selectedOptions[selectListId]),"true"===fieldDataAttributes.hideIfValueExists&&fieldDataAttributes.fieldId in(ap3c.field_values||{})&&(selectListTrigger.parentNode.style.display="none"),fieldDataAttributes.visibility===visibilityOptionIds.HIDE_ON_PRE_FILL&&defaultValue&&(selectListTrigger.parentNode.style.display="none")},replacePlatformLinks=function(widgetContainerEl,platform){for(var selector=platform===platforms.ANDROID?"[data-android-url], [data-button-submit-android-url]":"[data-ios-url], [data-button-submit-ios-url]",anchorElements=widgetContainerEl.querySelectorAll(selector),i=0;ithis.length)&&(this_len=this.length),this.substring(this_len-search.length,this_len)===search}),Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector),String.prototype.trimStart||(String.prototype.trimStart=function(){return this.replace(/^\s+/,"")}),String.prototype.trimEnd||(String.prototype.trimEnd=function(){return this.replace(/\s+$/,"")}),Element.prototype.closest||(Element.prototype.closest=function(s){var el=this;do{if(Element.prototype.matches.call(el,s))return el;el=el.parentElement||el.parentNode}while(null!==el&&1===el.nodeType);return null}),"remove"in Element.prototype||(Element.prototype.remove=function(){this.parentNode&&this.parentNode.removeChild(this)});var jsonFromXhr=function(url,method,requestPayload,onFetched){if(("ZB5Vs9u5KFKmMvhVY3ViYnliZWRz"===ap3c.uniqueID||"YBoahW3g05-xsBX1c3RnYWN0aXZpdGllcw"===ap3c.uniqueID||ap3c._isIOSWebView())&&window.fetch)fetch(url,{method:method,body:JSON.stringify(requestPayload)}).then(function(response){return response.json()}).then(function(data){onFetched(data)}).catch(function(error){console.error("Fetch error:",error)});else{var req=new XMLHttpRequest;req.open(method,url),req.onload=function(){if(200<=req.status&&req.status<300){var jsonResponse=JSON.parse(req.responseText);onFetched(jsonResponse)}else console.error("XMLHttpRequest error:",req.statusText)},req.onerror=function(){console.error("XMLHttpRequest network error")},req.send(JSON.stringify(requestPayload))}};!function(){var original,lastPathname=window.location.pathname+window.location.hash;function checkAndDispatchLocationChange(){var currentPathname=window.location.pathname+window.location.hash;lastPathname!==currentPathname&&(lastPathname=currentPathname,window.dispatchEvent(new Event("locationchange")))}history.pushState=(original=history.pushState,function(){var ret=original.apply(this,arguments);return checkAndDispatchLocationChange(),ret}),history.replaceState=function(original){return function(){var ret=original.apply(this,arguments);return checkAndDispatchLocationChange(),ret}}(history.replaceState),window.addEventListener("popstate",checkAndDispatchLocationChange)}();var sortObjectAndToString=function(obj){var keys=Object.keys(obj),len=keys.length;keys.sort();for(var result="",i=0;i1);async function* g(){};if(location.protocol!="file:"){window.ap3c.talk.isModernBrowser=true}}catch(e){};'],{type:"text/javascript"});function handleCallback(){callback(),script.remove()}script.src=URL.createObjectURL(blob),script.async=!0,script.type="module",script.onload=handleCallback,""!==ap3c.nonce&&(script.nonce=ap3c.nonce),script.onerror=handleCallback,document.head.appendChild(script)},init:function(){this.hasInitRequested=!0;var config=this.getConfig();config&&config.settings.enabled&&(this.hasScriptInjected||(this.baseAssetPath=(this.captureDomain||config.capture_domain||"https://cdn2l.ink/").replace(/(\/)*$/,"/"),"https://static.ap3stg.com/capture/master/"===this.baseAssetPath&&(this.baseAssetPath="https://static.ap3stg.com/"),this.injectModernBrowserDetector(function(){var script=document.createElement("script"),baseAssetPath=ap3c.talk.baseAssetPath;script.async=!0,ap3c.talk.isModernBrowser?(script.type="module",script.src=baseAssetPath+"talk-widget.js"):(script.type="text/javascript",script.src=baseAssetPath+"polyfills-legacy.js",script.onload=function(){window.System.import(baseAssetPath+"talk-widget-legacy.js")}),document.head.appendChild(script)}),this.hasScriptInjected=!0,void 0!==config.font_urls&&config.font_urls.length&&ap3c.injectCustomFonts(config.font_urls)))},saveConfig:function(config){localStorage.setItem(this.localStorageKey,JSON.stringify(config))},getConfig:function(){try{return JSON.parse(localStorage.getItem(this.localStorageKey))||null}catch(e){return null}},removeConfig:function(){localStorage.removeItem(this.localStorageKey)},removeTalkContact:function(){localStorage.removeItem(this.localStorageContactKey)},setToken:function(token){ap3c.setCookie(token,this.tokenCookieName,this.cookiePath)},getToken:function(){return readCookie(this.tokenCookieName)},removeToken:function(){removeCookie(this.tokenCookieName)},invalidate:function(){this.removeToken()},setVerifiedSession:function(options){var token=options.token,cookiePath=options.cookiePath;token&&(cookiePath&&(this.cookiePath=cookiePath),this.token=token,this.setToken(token),this.notifyEvent("verifiedSessionTokenReceived",{token:token,cookiePath:cookiePath}))},getBrowserTimeZone:function(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(err){return}}},ap3c.addStaticAction=function(key,action){ap3c.staticActions=ap3c.staticActions||[],ap3c.staticActions.push(key),ap3c.staticActionsFuncs=ap3c.staticActionsFuncs||{},ap3c.staticActionsFuncs[key]=action},ap3c.addStaticActionAndProcess=function(key,action){ap3c.addStaticAction(key,action),action.canExecute&&action.canExecute()&&action.execute()},ap3c.checkCookieDomainMatch=function(domain){if(!ap3c.cookieDomains||!domain)return null;for(var i=0;iThere’s been an error. Please try again soon.";else{var code=response.code,discount=response.discount;description=discount&&discount.description;var title=discount&&discount.title,buttonText=discount&&discount.primaryButtonValue,buttonUrl=discount&&discount.primaryButtonUrl,couponActionButtonText=discount&&discount.couponActionButtonText}discount&&code?couponCodeText?couponCodeText.innerText=code:couponDiv.innerText=code:(couponDiv.parentNode.remove(),copyCodeButtonDiv.remove()),copyCodeButtonDiv&&buttonText&&(copyCodeButtonDiv.firstChild.innerText=buttonText),copyCodeButtonDiv&&buttonUrl&©CodeButtonDiv.firstChild.setAttribute("href",buttonUrl),couponCodeActionDiv&&couponActionButtonText&&(couponCodeActionDiv.innerText=couponActionButtonText),description?descriptionTextDiv.firstChild.innerHTML=description:descriptionTextDiv.remove();for(var spinLabels=Array.prototype.slice.call(widgetContainer.getElementsByClassName("ap3w-wheel--coupon-label")),selectedDiscountIndex=0,i=0;i<8;i++)if(spinLabels[i].innerHTML===title){selectedDiscountIndex=i;break}var targetSpin=0-(1800+[0,45,90,135,180,225,270,315][selectedDiscountIndex]),spinDegrees=targetSpin,currentSpin=0;rotatingContentDivs[0].classList.add("ap3w-spinning");var interval=setInterval(function(){if(spinDegrees<0){-.5=+condition.value&&shouldShowWidget(widget,shownWidget,++conditionsMet)&&(show(widget,"",10),shownWidget=!0)}else show(widget,"",2e3);else widget.when&&("load"===widget.when.selection?show(widget,"",10):"on"===widget.when.selection?show(widget,"",1e3*widget.when.value):"click"===widget.when.selection?document.addEventListener("click",function(e){e.target.closest(widget.when.value)&&show(widget,"",10)}):"scroll"===widget.when.selection?window.onscroll=function(){!shownWidget&&window&&document.body&&(100*((window.innerHeight+window.scrollY)/document.body.scrollHeight)>widget.when.value&&(show(widget,"",10),shownWidget=!0))}:"exit"===widget.when.selection?isSafari?(exitIntentCallback=function(e){!e.toElement&&!e.relatedTarget&&e.clientY<10&&(document.removeEventListener("mouseout",exitIntentCallback),e.preventDefault(),show(widget,"",10))},document.addEventListener("mouseout",exitIntentCallback)):(exitIntentCallback=function(e){!!window.chrome&&e.target.activeElement&&"INPUT"===e.target.activeElement.nodeName||(document.removeEventListener("mouseleave",exitIntentCallback),e.preventDefault(),show(widget,"",10))},document.addEventListener("mouseleave",exitIntentCallback)):show(widget,"",2e3))},inject:function(widget,hasLogo){var showWidgetFunction=this.showWidgetFunction.bind(this),getFormFieldsData=ap3c.getFormFieldsData.bind(this),showAfterSubmit=this.showAfterSubmit.bind(this),spinTheWheel=this.spinTheWheel.bind(this),handleCountDown=this.handleCountDown.bind(this),injectVideo=this.injectVideo.bind(this),ttl=this.ttl,selectedOptions={},hide=this.hide.bind(this),requestPushPermission=this.requestPushPermission.bind(this),copyToClipboard=this.copyToClipboard.bind(this),existingWidgetContainer=document.getElementById(widget.id);if(!existingWidgetContainer){var container=document.getElementsByTagName(widget.use_slot)[0],widgetContainer=document.createElement("div");widgetContainer.innerHTML=widget.html,widgetContainer.firstChild&&(widgetContainer.firstChild.style.bottom=0,widgetContainer.firstChild.style.top=0,widgetContainer.firstChild.style.right=0,widgetContainer.firstChild.style.left=0,widget.is_gdpr&&(widgetContainer.firstChild.style.zIndex=99999)),widget.style&&"top"===widget.style.position?(widgetContainer.style.position="relative",widget.style.sticky&&(widgetContainer.style.position="sticky",widgetContainer.style.top=0),widgetContainer.style.zIndex=AP3_MAX_Z_INDEX):widget.style&&widget.style.sticky&&"bottom"===widget.style.position&&(widgetContainer.style.position="sticky",widgetContainer.style.bottom=0,widgetContainer.style.zIndex=AP3_MAX_Z_INDEX),existingWidgetContainer||container.insertAdjacentElement("afterbegin",widgetContainer),showWidgetFunction(widget);var couponButton=document.getElementById("ap3w-coupon-button-"+widget.id),couponCode=document.getElementById("ap3w-coupon-code-"+widget.id),couponCodeText=document.getElementById("ap3w-coupon-code-text-"+widget.id);couponButton&&couponCode&&couponButton.addEventListener("click",function(event){event.preventDefault();var discountId=event.target.dataset.discountId;discountId&&ap3c.track({apiPath:"-/events/generate-simple-coupon",cw:{widget_id:widget.id,type:"widget_coupon_generated",shown_on_url:window.location.href},discount_id:discountId},function(response){couponCodeText?couponCodeText.innerText=response.code:couponCode.innerText=response.code,localStorage.setItem(ap3c.localStorageKey+widget.id,JSON.stringify({expiry:(new Date).getTime()+ttl})),showAfterSubmit(widget,"greeting","thank-you")})});var submitFormCallback=function(response){response.code&&(couponCodeText?couponCodeText.innerText=response.code:couponCode.innerText=response.code),showAfterSubmit(widget,"greeting","thank-you")};if(couponCode)var discountId=couponCode.dataset.discountId;var form=document.getElementById("ap3w-form-"+widget.id);if(form){for(var inputs=form.querySelectorAll("input,textarea"),i=0;i>>n|x<<32-n},ap3c.Sha256.b0=function(x){return ap3c.Sha256.ROTR(2,x)^ap3c.Sha256.ROTR(13,x)^ap3c.Sha256.ROTR(22,x)},ap3c.Sha256.b1=function(x){return ap3c.Sha256.ROTR(6,x)^ap3c.Sha256.ROTR(11,x)^ap3c.Sha256.ROTR(25,x)},ap3c.Sha256.a0=function(x){return ap3c.Sha256.ROTR(7,x)^ap3c.Sha256.ROTR(18,x)^x>>>3},ap3c.Sha256.a1=function(x){return ap3c.Sha256.ROTR(17,x)^ap3c.Sha256.ROTR(19,x)^x>>>10},ap3c.Sha256.Ch=function(x,y,z){return x&y^~x&z},ap3c.Sha256.Maj=function(x,y,z){return x&y^x&z^y&z},ap3c.Sha256.toHexStr=function(n){for(var s="",i=7;0<=i;)s+=(n>>>4*i&15).toString(16),i--;return s},ap3c.scanForm=function(window,options){function __guard__(value,transform){return null!=value?transform(value):void 0}null==options&&(options={});options.findAllVersions&&(options.hashVersions=function(left,right,inclusive){for(var range=[],ascending=left