function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}var brandquizEmbed=brandquizEmbed||{};brandquizEmbed.baseurl="https://app.involve.me",brandquizEmbed.divSelector=".brandquiz_embed, .involveme_embed",brandquizEmbed.embeds=[],brandquizEmbed.init=function(){this.oneTimeInit(),this.polyfills();var e=document.querySelector(this.divSelector);e&&e.getAttribute("data-baseurl")&&(this.baseurl=e.getAttribute("data-baseurl")),this.embed()},brandquizEmbed.oneTimeInit=function(){if(!this.initialized){if(this.initialized=!0,document.getElementsByTagName("meta").viewport)document.getElementsByTagName("meta").viewport.content="width=device-width, initial-scale=1, maximum-scale=1";else{var e=document.createElement("meta");e.setAttribute("name","viewport"),e.setAttribute("content","width=device-width, initial-scale=1, maximum-scale=1"),document.querySelector("head").appendChild(e)}window.postMessage&&window.addEventListener("message",function(e){if("object"===_typeof(e.data)&&"involveme_embed"===e.data.source){var t=this.resolveEmbedIframe(e);if(null===t)return void this.sendFrameIds();switch(e.data.type){case"scrollToTop":(null===t.parentNode.getAttribute("data-autoscroll")||"true"===t.parentNode.getAttribute("data-autoscroll"))&&(this.scrollRequestedAt[t.id]=Date.now(),this.isElementInViewport(t,!0)||t.scrollIntoView());break;case"forceScrollToTop":this.isElementInViewport(t)||window.scrollTo({top:t.getBoundingClientRect().top+document.documentElement.scrollTop+(e.data.payload||0),behavior:"smooth"});break;case"outerHeight":this.setHeight(t,e.data.payload);break;case"visibleRectangle":this.updateVisibleRectangle(t);break;case"tracking":var i=e.data.payload,r=!1;"ga"===i.type&&"function"==typeof gtag?gtag("event",i.eventName,i.payload):"gtm"===i.type&&"object"===("undefined"==typeof dataLayer?"undefined":_typeof(dataLayer))?(i.ackId&&(i.payload.eventCallback=function(){brandquizEmbed.sendTrackingAck(t,i.ackId,!0)},i.payload.eventTimeout=1e3,r=!0),dataLayer.push(i.payload)):"fbq"===i.type&&"function"==typeof fbq?fbq("trackCustom",i.name,i.payload):"linkedin"===i.type&&"function"==typeof lintrk?lintrk("track",i.payload):"tiktok"===i.type&&"object"===("undefined"==typeof ttq?"undefined":_typeof(ttq))&&ttq.track(i.payload.eventName,i.payload),i.ackId&&!r&&brandquizEmbed.sendTrackingAck(t,i.ackId,!1);break;case"redirect":if(!brandquizEmbed.isSafeNavigationUrl(e.data.payload))break;var n=brandquizEmbed.getDivDataAttributes(t.parentNode),a=n.transparentEmbed,o=n.minHeight,d=n.noResize,s=n.loadColor,l=n.embedMode,u=n.noWatermark,c=new URL(e.data.payload,window.location.href);c.searchParams.set("embed",1),l&&c.searchParams.set("embedmode",l),d&&c.searchParams.set("noresize",1),o&&c.searchParams.set("minheight",1),a&&c.searchParams.set("transparent-embed",a),s&&c.searchParams.set("loadcolor",encodeURIComponent(s)),u&&c.searchParams.set("no-watermark",1),t.src=c.toString(),d||brandquizEmbed.makeResponsive(t);break;case"openPopup":var m=e.data.payload||{},b=m.url,h=m.target,p=m.features;if(!brandquizEmbed.isSafeNavigationUrl(b))break;var g=!h||"_self"===h||"_parent"===h||"_top"===h;try{g?window.top.location.assign(b):window.top.open(b,h,p)}catch(e){window.location.assign(b)}break;default:console.log("Parent received a message",e)}}}.bind(this),!1)}},brandquizEmbed.embed=function(){document.querySelectorAll(this.divSelector).forEach(function(e){if(null===e.querySelector("iframe")){var t=e.getAttribute("data-embed")||e.getAttribute("data-project"),i=e.getAttribute("data-baseurl"),r=e.querySelector("script.involve-embed-script");if(null===i&&r&&(i=new URL(r.src).origin),null===i&&(i=this.baseurl),-1===this.embeds.indexOf(t)){this.embeds.push(t);var n=e.getAttribute("data-width");e.style["max-width"]=n?n+"px":"100%";var a=brandquizEmbed.getDivDataAttributes(e),o=a.transparentEmbed,d=a.minHeight,s=a.noResize,l=a.loadColor,u=a.embedMode,c=a.embedTabPosition,m=a.isPreview,b=a.noWatermark;"fullscreen"===u&&(e.style.height="100%",e.style.width="100%",e.style.margin=0,e.style["line-height"]=0,e.style.position="fixed",e.style["z-index"]=2147483645,e.style.top=0,e.style.left=0,document.getElementsByTagName("body")[0].style="overflow: hidden",s=!0);var h=e.getAttribute("data-params"),p="";null!==h&&h.split(",").forEach(function(e){p+="&"+e.trim()});var g=["src","embed","embedmode","share","noresize","minheight","score","calculator","outcome","o","loadcolor","transparent-embed","title","no-watermark","_referrer"],f=this.getAllUrlParams();for(var y in f)f.hasOwnProperty(y)&&(g.includes(y)||(p+="&"+y+"="+f[y]));s&&(e.style.height="100%",e.style["-webkit-overflow-scrolling"]="touch",d||(e.style.height="100%"));var v=document.createElement("iframe");v.setAttribute("frameborder","0"),v.setAttribute("allow","web-share; fullscreen; autoplay"),v.style.width="100%",v.style.overflow="hidden",["popup","chatButton"].includes(u)&&(v.style["border-radius"]="0.5rem"),["sideTab"].includes(u)&&("left"===c?(v.style["border-top-right-radius"]="0.5rem",v.style["border-bottom-right-radius"]="0.5rem"):"right"===c&&(v.style["border-top-left-radius"]="0.5rem",v.style["border-bottom-left-radius"]="0.5rem")),v.id="_"+Math.random().toString(36).substr(2,9),s&&(v.style.height="100%"),d&&(v.style["min-height"]=d+"px"),m&&(v.style.transform="scale(0.6)",v.style["transform-origin"]="0 0",v.style.width="167%",v.style.height="167%"),e.getAttribute("data-loading")&&(v.loading=e.getAttribute("data-loading")),e.getAttribute("data-title")&&(v.title=e.getAttribute("data-title")),v.src=i+"/"+t+"?embed=1"+(u?"&embedmode="+u:"")+(s?"&noresize=1":"")+(d?"&minheight=1":"")+(o?"&transparent-embed="+o:"")+(l?"&loadcolor="+encodeURIComponent(l):"")+(b?"&no-watermark=1":"")+"&src="+encodeURIComponent(document.location.href)+(document.referrer?"&_referrer="+encodeURIComponent(document.referrer):"")+p,e.appendChild(v);var w=e.querySelector("iframe#"+v.id);w.onload=function(){brandquizEmbed.sendFrameId(w)},s||this.makeResponsive(e.querySelector("iframe#"+v.id))}}}.bind(this))},brandquizEmbed.sendFrameIds=function(){document.querySelectorAll(this.divSelector).forEach(function(e){var t=e.querySelector("iframe");t&&t.id&&this.sendFrameId(t)}.bind(this))},brandquizEmbed.sendFrameId=function(e){e.contentWindow.postMessage({source:"involveme_parent",type:"setId",payload:e.id},"*")},brandquizEmbed.resolveEmbedIframe=function(e){for(var t=document.querySelectorAll(this.divSelector),i=0;i<t.length;i++){var r=t[i].querySelector("iframe");if(r&&r.contentWindow===e.source&&this.embedIframeOrigin(r)===e.origin)return r}return null},brandquizEmbed.embedIframeOrigin=function(e){try{return new URL(e.src,window.location.href).origin}catch(e){return null}},brandquizEmbed.isSafeNavigationUrl=function(e){try{return"https:"===new URL(e,window.location.href).protocol}catch(e){return!1}},brandquizEmbed.sendTrackingAck=function(e,t,i){e.contentWindow.postMessage({source:"involveme_parent",type:"trackingAck",payload:{ackId:t,handled:i}},"*")},brandquizEmbed.ready=function(e){var t=new URL(document.currentScript.src).origin||null;t&&(this.baseurl=t,document.currentScript.className="involve-embed-script"),(document.attachEvent?"complete"===document.readyState:"loading"!==document.readyState)?e():document.addEventListener("DOMContentLoaded",e)},brandquizEmbed.polyfills=function(){window.NodeList&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),Array.prototype.includes||Object.defineProperty(Array.prototype,"includes",{value:function(e,t){if(null==this)throw new TypeError('"this" is null or not defined');var i=Object(this),r=i.length>>>0;if(0===r)return!1;var n=0|t,a=Math.max(n>=0?n:r-Math.abs(n),0);function o(e,t){return e===t||"number"==typeof e&&"number"==typeof t&&isNaN(e)&&isNaN(t)}for(;a<r;){if(o(i[a],e))return!0;a++}return!1}})},brandquizEmbed.bringIntoView=function(e){({started:0,ends:0,y:0,tick:function(){var e,t,i,r;(i=Date.now())<this.ends?(e=i-this.started,t=this.ends-this.started,r=(this.y-document.body.scrollTop)*(e/t),document.body.scrollTop+=r,window.requestAnimationFrame(this.tick.bind(this))):document.body.scrollTop=this.y},bringIntoView:function(e,t){this.started=Date.now(),this.ends=this.started+t,this.y=Math.min(document.body.scrollTop+e.getBoundingClientRect().top,document.body.scrollHeight-window.innerHeight),window.requestAnimationFrame(this.tick.bind(this))}}).bringIntoView(e,600)},brandquizEmbed.targetHeight={},brandquizEmbed.scrollRequestedAt={},brandquizEmbed.updateVisibleRectangle=function(e){var t={top:0,height:0},i=e.getBoundingClientRect();i.top<window.innerHeight&&i.bottom>0&&(i.top<0&&(t.top=Math.abs(i.top)),i.bottom<=window.innerHeight?t.height=i.height-t.top:i.top<0?t.height=window.innerHeight:t.height=window.innerHeight-i.top),e.contentWindow.postMessage({source:"involveme_parent",type:"visibleRectangle",payload:{top:Math.floor(t.top),height:Math.floor(t.height)}},"*")},brandquizEmbed.setHeight=function(e,t){var i=e.parentNode.getAttribute("data-min-height");i&&t<i&&(t=i),t!==this.targetHeight[e.id]&&(this.targetHeight[e.id]=t,e.style.height=t+"px",i&&e.contentWindow.postMessage({source:"involveme_parent",type:"setBodyClass",payload:"minheight"},"*"),this.updateVisibleRectangle(e))},brandquizEmbed.makeResponsive=function(e){e.style.height="300px",e.style["transition-duration"]="600ms",e.style["-webkit-transition-duration"]="600ms",e.ontransitionend=function(){Date.now()-brandquizEmbed.scrollRequestedAt[e.id]<3e3&&!brandquizEmbed.isElementInViewport(e,!0)&&e.scrollIntoView()},this.targetHeight[e.id]=0},brandquizEmbed.getAllUrlParams=function(e){var t=e?e.split("?")[1]:window.location.search.slice(1),i={};if(t)for(var r=(t=t.split("#")[0]).split("&"),n=0;n<r.length;n++){var a=r[n].split("="),o=a[0],d=void 0===a[1]||a[1];if((o=o.toLowerCase()).match(/\[(\d+)?\]$/)){var s=o.replace(/\[(\d+)?\]/,"");if(i[s]||(i[s]=[]),o.match(/\[\d+\]$/)){var l=/\[(\d+)\]/.exec(o)[1];i[s][l]=d}else i[s].push(d)}else i[o]?i[o]&&"string"==typeof i[o]?(i[o]=[i[o]],i[o].push(d)):i[o].push(d):i[o]=d}return i},brandquizEmbed.getDivDataAttributes=function(e){var t=e.getAttribute("data-transparent-embed");return{transparentEmbed:t,minHeight:e.getAttribute("data-min-height"),noResize:e.getAttribute("data-noresize"),loadColor:t?"transparent":e.getAttribute("data-loadcolor"),embedMode:e.getAttribute("data-embed-mode"),embedTabPosition:e.getAttribute("data-embed-tab-position"),isPreview:e.getAttribute("data-embed-is-preview"),noWatermark:e.getAttribute("data-no-watermark")}},brandquizEmbed.isElementInViewport=function(e,t){var i=e.getBoundingClientRect(),r=t?i.top+(Number(this.targetHeight[e.id])||i.height):i.top;return i.top>=0&&r<=(window.innerHeight||document.documentElement.clientHeight)},brandquizEmbed.ready(function(){brandquizEmbed.init()});
