window.rhScheduledMaintenance=!1,window.rhCurrentScript=document.currentScript.src,window.rhVersion="1.0.0",window.rhDate=new Date;var scriptUrl=new URL(window.rhCurrentScript),prqParams=new URLSearchParams(scriptUrl.search);function prqSetCookie(o,t,n){console_log("embed.js - prqSetCookie - "+o+" - "+t+" - "+n);var e,r="";n&&((e=new Date).setTime(e.getTime()+24*n*60*60*1e3),r="; expires="+e.toUTCString());try{document.cookie=o+"="+(t||"")+r+"; sameSite=Lax; path=/"}catch(e){console.warn("Failed to set cookie:",e),console.warn("cookie details:",o,t,n)}}function prqGetCookie(o){try{for(var e=o+"=",t=document.cookie.split(";"),n=0;n{try{function O(e){"function"==typeof prqAddedAllToCartCallback&&prqAddedAllToCartCallback(e)}window.addingToCart=!1,console_log("console_log enabled // "+window.rhVersion+" // "+window.rhDate);let n=(e,o)=>{let t=new XMLHttpRequest;t.onreadystatechange=()=>{4===t.readyState&&200===t.status&&o(JSON.parse(t.responseText))},t.open("GET",e,!0),t.send(null)},j=(e,o,t)=>{let n=new XMLHttpRequest;n.onreadystatechange=()=>{4===n.readyState&&200===n.status&&t(JSON.parse(n.responseText))},n.open("POST",e,!0),n.setRequestHeader("Content-Type","application/json;charset=UTF-8"),n.send(JSON.stringify(o))};function S(t){t&&0"+e.item_count+"",0===e.item_count?o.classList.add("hide"):o.classList.remove("hide")});S(document.getElementsByClassName("cart-item-count-header"));var e=document.getElementsByClassName("cart_count");S(e)}function F(e){console_log("embed.js - addProductsToCartBigCommerce"),console_log(e),window.addingToCart=!0;var o,r=[];for(o in e){var a="/cart.php?action=add&sku="+encodeURIComponent(JSON.parse(o).sku)+"&qty="+encodeURIComponent(e[o]);r.push(a)}console_log(r);!function o(t){var n;n=r[t],new Promise(function(e,o){var t=new XMLHttpRequest;t.open("GET",n,!0),t.onreadystatechange=function(){4==t.readyState&&(200==t.status?e(!0):o(Error(t.statusText)))},t.onerror=function(){o(Error("network error"))},t.send()}).then(function(e){console_log(r[t]),console_log(e),++t{console_log("embed.js - addWindowEventListenerMessage"),window.addEventListener("message",function(e){if("https://admin.revenuehunt.com"===e.origin||"https://admin-staging.revenuehunt.com"===e.origin||"http://localhost:9528"===e.origin||"admin-dev.revenuehunt.com"===e.origin){var o,t,n,r,a,i,l,d,c,s="object"==typeof e.data?e.data:JSON.parse(e.data);try{"gtag_event"===s.action&&(console_log("gtag_event"),console_log(s),b=s.gtag_id,v=s.gtag_action,q=s.gtag_category,l=s.gtag_label,"undefined"==typeof gtag?console.warn("RevenueHunt: make sure to load gtag, before the embed.js script"):(console_log("trigger gtag"),q={event_category:q,event_label:l},void 0!==b&&(console_log("set user defined gtag"),q.send_to=b),gtag("event",v,q)))}catch(s){console_log(s)}try{"fbpixel_event"===s.action&&(o=s.facebook_pixel,t=s.fbq_action,n=s.fbq_event,r=s.fbq_params,void 0===window.fbq&&o&&(C=window,c=document,C.fbq||(a=C.fbq=function(){a.callMethod?a.callMethod.apply(a,arguments):a.queue.push(arguments)},C._fbq||(C._fbq=a),(a.push=a).loaded=!0,a.version="2.0",a.queue=[],(C=c.createElement("script")).async=!0,C.src="https://connect.facebook.net/en_US/fbevents.js",(c=c.getElementsByTagName("script")[0]).parentNode.insertBefore(C,c)),window.fbq("init",o)),void 0!==window.fbq)&&(r?window.fbq(t,n,r):window.fbq(t,n))}catch(s){console_log(s)}if("iframe_height"===s.action){if(0===(i=document.querySelectorAll(".rh-inline")).length)return;for(let e=0;e{console_log(e.response),"function"==typeof prqAddedOneToCartCallback&&prqAddedOneToCartCallback(_)},e.send()}if("add_all"===s.action&&"function"==typeof prqAddAllToCartCallback&&(console_log("embed.js - add_all"),prqAddAllToCartCallback(s)),"add_all"===s.action&&"ShopifyShop"===s.platform&&(console_log("embed.js - add_all Shopify"),window.addingToCart=!0,y=s.variantId.split("||"),d={},y.forEach(function(e){d[parseInt(e)]=1}),j("/cart/update.js",{updates:d},function(e){window.addingToCart=!1,M(),O(s)})),"add_all"===s.action&&"WoocommerceShop"===s.platform&&(console_log("embed.js - add_all WooCommerce"),window.addingToCart=!0,y=s.variantId.split("||"),function o(t){H({quantity:1,product_id:y[t]}).then(function(e){++t{console_log(o.response),iFrameEvent({action:"added_all"}),O(s)},o.send()}if("change_variant"===s.action){console_log("embed.js - change_variant");var y,b=(y=s.variantId.split("||"))[0],v=y[1];if(console_log(b),console_log(v),"ShopifyShop"===s.platform){var q,b=JSON.parse(b),v=JSON.parse(v);if(b.recharge)return console_log("ReCharge product"),console_log(q={id:b.variant_id,sellingPlanId:b.recharge.external_plan_id,sellingPlanGroupId:b.recharge.external_plan_group_id,isSubscription:!0}),void window.ReChargeWidget.api.postToCart(q);var C={};C[v.variant_id]=0,C[b.variant_id]=s.quantity,console_log("/cart/update.js"),console_log(C),j("/cart/update.js",{updates:C},function(e){console_log(e)})}"WoocommerceShop"===s.platform&&H(_={quantity:1,product_id:b})}if("remove_one"===s.action&&"function"==typeof prqRemoveOneFromCartCallback&&(console_log("remove_one callback"),prqRemoveOneFromCartCallback(s)),"remove_one"===s.action&&"ShopifyShop"===s.platform&&(console_log("remove_one Shopify"),c={},void 0!==s.quantity&&s.quantity||(s.quantity=0),c[s.variantId]=s.quantity,console_log("/cart/update.js"),console_log(c),j("/cart/update.js",{updates:c},function(e){console_log(e),M(),"function"==typeof prqRemovedOneFromCartCallback&&prqRemovedOneFromCartCallback(e)})),"remove_one"===s.action&&"WoocommerceShop"===s.platform){console_log("embed.js - remove_one WooCommerce");var S,x=new XMLHttpRequest,k=(x.open("POST","/?wc-ajax=remove_from_cart"),x.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),{cart_item_key:s.originId}),E=[];for(S in k){var A=encodeURIComponent(S),T=encodeURIComponent(k[S]);E.push(A+"="+T)}E=E.join("&"),x.onload=function(){console_log(x)},x.send(E)}if("remove_one"===s.action&&"MagentoShop"===s.platform){console_log("embed.js - remove_one Magento");var z,_={quantity:1,product_id:z=s.variantId||s.originId,product_sku:s.sku};let e=new XMLHttpRequest;e.responseType="json",e.open("GET","/productquiz/index/removequizproductstocart/product_id/"+z+"?"+B()),e.onload=()=>{console_log(e.response),"function"==typeof prqRemovedOneFromCartCallback&&prqRemovedOneFromCartCallback(_)},e.send()}}},!1)},p=()=>{for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",o="",t=0;t<6;t++)o+=e.charAt(Math.floor(Math.random()*e.length));return o};function B(){return"cachebuster="+p()}let c=e=>"[object Object]"===Object.prototype.toString.call(e),h=(e,o=!1,t=!1,n=!1,r=!1)=>{o=a(o,t,n,r),t=new URLSearchParams(o).toString();return e+(""===t?"":"?"+t)},s=e=>{var o=e.indexOf("#quiz-");return-1!==o?e.substring(0,o)+e.substring(o+6):e},g=e=>{var o,t;return console_log("shopifyCurrency"),console_log(e),"undefined"!=typeof Shopify&&Shopify&&Shopify.currency?({active:t,rate:o}=Shopify.currency,t=`currency_code=${t}¤cy_rate=`+o,e.includes("?")?e+"&"+t:e+"?"+t):e},a=function(e,o,t,n){console_log("embed.js - quizParameters");var r,a,i,l=new URLSearchParams(window.location.search),d={};e&&(o=d.popup="true"),t&&(d.popupWidth=t),n&&(d.popupHeight=n),o||(d.autoscroll="false"),c(window.prq_vars)&&(d=Object.assign(d,window.prq_vars)),console_log("URLSearchParams");for(r of l.entries())r[0].startsWith("prq_")&&(a=r[0].replace("prq_",""),i=r[1],console_log(r),d[a]=i);return d},r=function(e){return console_log("embed.js - isAutoScroll"),console_log(e),!e||"false"!==e.toLowerCase()},I=()=>null!==document.querySelector("body.smart-cart--enabled")&&"undefined"!=typeof Rebuy&&void 0!==Rebuy?.SmartCart,o=function(){document.querySelectorAll(".rh-widget iframe")&&document.querySelectorAll(".rh-widget iframe").forEach(function(e){e.remove()}),document.querySelectorAll(".rh-widget").forEach(function(e){e.style.backgroundColor="#aaa";var o=document.createElement("div"),t=(o.style.textAlign="center",o.style.display="flex",o.style.flexDirection="column",o.style.justifyContent="center",o.style.height="calc(100% - 60px)",o.style.width="calc(100% - 60px)",o.style.padding="30px",o.style.color="#fff",document.createElement("h2")),t=(t.textContent="Quiz Temporarily Unavailable",o.appendChild(t),document.createElement("p"));t.textContent="We're currently improving your experience! Please check back shortly after our brief maintenance period.",o.appendChild(t),e.appendChild(o)})},m=function(){document.querySelectorAll(".rh-widget iframe")&&document.querySelectorAll(".rh-widget iframe").forEach(function(e){e.remove()}),document.querySelectorAll(".rh-widget").forEach(function(e){var o=p(),t=e.dataset.url,t=s(t),t=h(t,!1,r(e.dataset.autoscroll)),t=g(t),n=(console_log("RenderInlineEmbed - shopifyCurrency"),console_log(t),document.createElement("iframe"));n.name="Product Recommendation Quiz",n.src=t,n.id=o,n.style.cssText="transform-style: preserve-3d; padding: 0; border: none; margin: 0 auto; height: 100%; flex-grow: 1; background: url(https://admin.revenuehunt.com/rolling.svg) no-repeat center;",n.setAttribute("data-hj-allow-iframe","true"),e.appendChild(n),document.getElementById(o).onload=function(){document.getElementById(o).contentWindow.focus()}})},t=function(){document.querySelectorAll("a").forEach(function(e){var o;e&&e.href&&"string"==typeof e.href&&e.href.match(/\#quiz\-/)&&(o=e.href.split("#quiz-")[1],e.addEventListener("click",function(e){e.preventDefault(),document.getElementById(o)&&document.getElementById(o).remove(),w(o,!1,"true")}))})},f=()=>{var e,o,t=window.rhCurrentScript,n=document.URL;for({regex:e,domain:o}of[{regex:/admin\-staging\.revenuehunt\.com/,domain:"https://admin-staging.revenuehunt.com"},{regex:/admin\-dev\.revenuehunt\.com/,domain:"https://admin-dev.revenuehunt.com"},{regex:/localhost|productrecommendationquizforwoocommerce|productrecommendationquiz.local/,domain:"http://localhost:9528"}])if(e.test(t)||e.test(n))return o;return"https://admin.revenuehunt.com"},d=function(){var e=f(),e='.rh-chat { width: 50px; height: 50px; bottom: 20px; right: 20px; cursor: pointer; position: fixed; border-radius: 25px; -webkit-border-radius: 25px; -moz-border-radius: 25px; -webkit-box-shadow: 0 0 3px 0 rgba(0,0,0,0.1); -moz-box-shadow: 0 0 3px 0 rgba(0,0,0,0.1); box-shadow: 0 0 3px 0 rgba(0,0,0,0.1); } .rh-greeting { padding: 8px; background-color: white; bottom: 29px; right: 80px; position: fixed; color: #666; font-size: 12px; border: 1px solid #eee; border-radius: 6px; -webkit-border-radius: 6px; -moz-border-radius: 6px; -webkit-box-shadow: 0 0 3px 0 rgba(0,0,0,0.1); -moz-box-shadow: 0 0 3px 0 rgba(0,0,0,0.1); box-shadow: 0 0 3px 0 rgba(0,0,0,0.1); font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; } span.rh-close { cursor: pointer; font-weight: bold; background-image: url(\''+e+"/close-x.svg'); background-size: cover; background-position: center; opacity: 0.25; width: 10px; height: 10px; margin-left: 4px; display: inline-block !important; } .rh-dot { width: 10px; height: 10px; background-color: #FF5500; border: 2px solid white; float: right; box-sizing: content-box; border-radius: 10px; -webkit-border-radius: 10px; -moz-border-radius: 10px; display: block !important; } .rh-icon { width: 25px; height: 25px; position: absolute; margin: 12px; background-image: url('"+e+"/chat-quiz-white.svg'); background-size: cover; background-position: center; display: inline-block !important; }",o=document.createElement("style");o.innerText=e.replace(/[\r\n]+/gm,""),document.head.appendChild(o)},u=(window.rhCloseGreeting=function(){console_log("rhCloseGreeting"),document.getElementById("rh-greeting")&&(document.getElementById("rh-greeting").outerHTML="")},window.rhCloseNotification=function(){console_log("rhCloseNotification"),document.getElementById("rh-dot")&&(document.getElementById("rh-dot").outerHTML="")},window.rhClickChat=function(e,o,t){console_log("rhClickChat"),console_log(e),window.rhCloseGreeting(),window.rhCloseNotification(),window.openQuizPopup(e,o,t)},function(e,o,t,n,r,a){var i=document.createElement("div"),l=document.createElement("div"),d=document.createElement("div");l.classList.add("rh-chat"),l.style.backgroundColor=o,l.addEventListener("click",function(){window.rhClickChat(e,r,a)}),d.classList.add("rh-icon"),l.appendChild(d),t&&((o=document.createElement("div")).classList.add("rh-dot"),o.setAttribute("id","rh-dot"),l.appendChild(o)),i.appendChild(l),n&&(d=document.createElement("div"),t=document.createElement("span"),d.classList.add("rh-greeting"),d.setAttribute("id","rh-greeting"),d.textContent=n,t.classList.add("rh-close"),t.addEventListener("click",window.rhCloseGreeting),d.appendChild(t),i.appendChild(d)),document.body.appendChild(i)}),i=function(){var o=document.getElementById("rh-chat");if(null!==o){console_log("--------------------------------"),console_log("RenderChatEmbed");var t=o.getAttribute("data-quiz-id"),t=s(t),n=o.getAttribute("data-chat-color"),r=o.getAttribute("data-chat-dot")&&"true"===o.getAttribute("data-chat-dot").toLocaleLowerCase(),a=o.getAttribute("data-chat-hide")&&"true"===o.getAttribute("data-chat-hide").toLocaleLowerCase(),i=o.getAttribute("data-popup-width"),l=o.getAttribute("data-popup-height");let e=!1;o.getAttribute("data-chat-greeting")&&(e=o.getAttribute("data-chat-greeting"));o=prqGetCookie("prq-responseId-"+t);console_log(o),a&&o||(d(),u(t,n,r,e,i,l))}},l=function(){console_log("embed.js - GetAutomaticPopupData");var e,o,t,n,r,a,i=prqGetCookie("data-timeout"),l=Date.now(),d=!1,c=!1;i&&(console_log("data-timeout cookie set:"),c=i.split("||")[0],d=parseInt(i.split("||")[1])),null!==document.getElementById("auto-popup")&&(e=document.getElementById("auto-popup"),o=parseFloat(e.getAttribute("data-timeout")),t=e.getAttribute("data-exit-intent")&&"true"===e.getAttribute("data-exit-intent").toLocaleLowerCase(),n=e.getAttribute("data-aggressive")&&"true"===e.getAttribute("data-aggressive").toLocaleLowerCase(),window.popupWidth=e.getAttribute("data-popup-width"),window.popupHeight=e.getAttribute("data-popup-height"),c=e.getAttribute("data-quiz-id"),r=prqGetCookie("auto-popup-"+(c=s(c))),n&&(r=prqGetCookie("prq-responseId-"+c)),d=1e3*(o=o&&o<=0?.5:o)+l),i||prqSetCookie("data-timeout",c+"||"+d,7),c&&t&&!r&&document.addEventListener("mouseout",e=>{e.toElement||e.relatedTarget||r||window.popupAlreadyShown||(window.popupAlreadyShown=c,w(c,!1,"true",window.popupWidth,window.popupHeight))}),console_log("timeTimeout:"),console_log((d-l)/1e3),console_log(c),c&&!r&&0{var o=document.createElement("link");o.rel="dns-prefetch",o.href=e,document.head.appendChild(o)},y=function(){var o=window.location.hash;if(console_log("checkHash"),console_log("hash"),o.match(/\#quiz\-/)){let e=o.split("#quiz-")[1];var t=document.querySelector(".rh-widget span"),n=()=>w(e,!1,"true");t?(t.click(),setTimeout(n,200)):n()}if(o.match(/\#results\-/)){let t=o.split("#results-")[1].split("-");console_log("#results"),console_log(t),w(t[0],t[1],!1),document.querySelectorAll(".rh-inline").forEach(e=>{var o=e.dataset.url.split("/").pop();t[0]===o&&(document.querySelector("body").style.overflow=null,e.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"}))})}},L=e=>{document.querySelector(`[id='${e}'] span`).click()},R=e=>{if(!e||!e.dataset||"false"===e.dataset.autoscroll)return!1;var e=e.getBoundingClientRect(),o=e.y+window.pageYOffset;e&&e.y<0&&(console_log("scroll_to: "+o),window.scrollTo({top:o,left:0,behavior:"smooth"}))},b=()=>{window.addEventListener("hashchange",()=>{console_log("embed.js - detectHashChange"),y()})},v=()=>{/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&window.addEventListener("pageshow",function(){document.querySelectorAll(".rh-widget iframe").forEach(function(e){console_log("embed.js - is Safari, reload iframe"),e.src=e.src})})},q=e=>{var o=document.createElement("style");o.textContent=e,document.head.append(o)},C=(window.openQuizPopup=function(e,o,t){w(e,!1,"true",o,t)},` .rh-inline, .rh-inline iframe{-webkit-transition: height 0.5s; -moz-transition: height 0.5s; -ms-transition: height 0.5s; -o-transition: height 0.5s; transition: height 0.5s;} .mtop-20 { margin-top: 20px; } .mbot-20 { margin-bottom: 20px; } .rh-quiz-list { display: none; } .rh-info-box { background-color: #D8F0FE; color: #2c81b2; border: 1px dotted #2c81b2; padding: 15px; border-radius: 8px; -webkit-border-radius: 8px; -moz-border-radius: 8px; } .rh-inline { width: 100%; display: flex; } .rh-inline iframe { width: 100%; } .rh-fullwidth { width: 100vw; max-width: 100vw; margin-left: calc(50% - 50vw); } `);function x(){console_log("embed.js # prqApp # 2024-01-24 # v001"),console_log("rhScheduledMaintenance: "+window.rhScheduledMaintenance),q(C),["https://api.revenuehunt.com","https://space.revenuehunt.com"].forEach(_)}function k(){setTimeout(function(){if(x(),l(),m(),t(),i(),v(),y(),b(),"undefined"!=typeof Shopify&&Shopify&&Shopify.designMode){var o=document.querySelectorAll(".rh-quiz-list");for(let e=0;e{console.error("Error sending event data to Ahoy:",e)})}var o})();