console.log("loading config for wegotthiscovered");window.gamursInfScrollCustomSiteConfig={site:"wegotthiscovered",useCategories:true,useTags:true,categories:undefined,tags:undefined,sameCategory:false};window.gamursInfScroll={infScrollURL:"https://infinity-api.wegotthiscovered.com"};"use strict";console.log("Infinite scroll initialised");(function(){var P,D,J,H,W;if(typeof window>"u")return;let n=window.gamursInfScrollCustomSiteConfig,U=window.gamursInfScroll,q=n&&(P=n.categories)!=null?P:"",L=n&&(D=n.tags)!=null?D:"",T=!(n&&n.useCategories===!1),M=!(n&&n.useTags===!1),N=!!(n&&n.sameCategory),y=U&&(J=U.infScrollURL)!=null?J:"",v=document.getElementsByClassName("gamurs-inf-scroll-post")[0].attributes["data-categories"].value,$=document.getElementsByClassName("gamurs-inf-scroll-post")[0].attributes["data-tags"].value,m=(H=document.getElementsByClassName("gamurs-inf-scroll-post")[0].attributes["data-experiments"])==null?void 0:H.value,F=window.location.href;window.gamurs_inf_scroll_data=window.gamurs_inf_scroll_data||{};let C=document.getElementsByClassName("gamurs-inf-scroll-post")[0].dataset.id,s=window.location.hostname.split(".")[window.location.hostname.split(".").length-2];s==="lndo"?s=window.location.hostname.split(".")[0]:s==="go-vip"&&(s=window.location.hostname.split(".")[0],s=s.split("-")[0],(s==="www"||s==="cms")&&(s=window.location.hostname.split(".")[0].split("-")[1])),window.gamurs_inf_scroll_data.nextUrl=`${y}/infscroll/${s}/${C}?categories=${v}&tags=${$}&useCategories=${T}&useTags=${M}&forceCategories=${q}&forceTags=${L}&sameCategory=${N}${m?`&experiments="${m}"`:""}`;let V={root:document.querySelector("#scroll-area"),rootMargin:"0px",threshold:.5},Y={rootMargin:"-50% 0% -50% 0%",threshold:0},z={rootMargin:"-50% 0% -10% 0%",threshold:0},Z={rootMargin:"-75% 0% -25% 0%",threshold:0},G={rootMargin:"-87.5% 0% -12.5% 0%",threshold:0};function B(e,l,o){let t;return o==="middle"?(t=new IntersectionObserver(l,Y),t=g(e,t,!1)):o==="middleofmiddle"?(t=new IntersectionObserver(l,z),t=g(e,t,!0)):o==="middlelower"?(t=new IntersectionObserver(l,G),t=g(e,t,!1)):(t=new IntersectionObserver(l,V),t=g(e,t,!1)),t}function K(e){if(typeof window.gamursInfScrollOnInfiniteScrollAppend=="function")try{window.gamursInfScrollOnInfiniteScrollAppend(e)}catch(l){console.log(l)}}function Q(e,l){e[0].isIntersecting&&(E(),l.unobserve(e[0].target))}function g(e,l,o){let t;return o?(e.style.position="relative",t=document.createElement("div"),t.style.position="absolute",t.style.top="50%",t.style.width="100%",t.style.height="50%",t.style.pointerEvents="none",e.appendChild(t)):t=e,l.observe(t),l}let p=[],w=document.querySelector(".gamurs-inf-scroll-post");p[w&&(W=w.dataset.id)!=null?W:0]=document.URL;let R=!1;history.scrollRestoration="manual";let S=!0,_="down",b=0;document.addEventListener("scroll",function(){let e=window.pageYOffset||document.documentElement.scrollTop;e>b?_="down":e<b&&(_="up"),b=e<=0?0:e});function X(e,l){e.forEach(o=>{if(o.isIntersecting&&window.location.href!==o.target.dataset.url){let t=p[o.target.dataset.id];if(_==="down"?document.getElementsByClassName("gamurs-inf-scroll-post")[0].dataset.id!==o.target.dataset.id&&history.pushState(null,"",t):window.location.href!==F&&(S=!1,history.back()),document.title=o.target.dataset.title,typeof window.gamursInfScrollOnUrlChange=="function")try{window.gamursInfScrollOnUrlChange(t)}catch(A){console.log(A)}window.snowplow&&window.snowplow("trackStructEvent",{category:"gamurs-infinite-scroll",action:"impression"})}}),Array.from(document.getElementsByClassName("gamurs-inf-scroll-post")).map(o=>l.observe(o))}addEventListener("popstate",e=>{try{S&&document.querySelector(`[data-url="${e.target.location.href.split("?")[0]}"]`).scrollIntoView()}catch(l){console.log(l)}S=!0});function E(){R?j(!1,p,x,O):(R=!0,j(!0,p,x,O))}async function j(e,l,o,t){let A=e?`${y}/campaign/${s}/${C}?categories=${v}&tags=${$}${m?`&experiments="${m}"`:""}`:window.gamurs_inf_scroll_data.nextUrl;await fetch(A).then(a=>{if(a.status!==200)throw e?"No Campaign":`request failed: ${a.text()}`;return a.json()}).then(function(h){let r=h;if(r.html!=null){l[r.id]=r.url,e||(window.gamurs_inf_scroll_data.nextUrl=r.nextUrl);let c=document.createElement("div");c.innerHTML=r.html;let u=c.firstElementChild,d=document.querySelector("#gamurs-inf-scroll-main");if(d&&u)d.appendChild(u);else throw"did not find #gamurs-inf-scroll-main";window.snowplow&&window.snowplow("trackStructEvent",{category:"gamurs-infinite-scroll",action:"append-article",label:r.id}),[c,u].forEach(k=>{Array.from(k.querySelectorAll("script")).forEach(f=>{try{if(f.src){let i=document.createElement("script");i.src=f.src,i.type=f.type,i.id=f.id,i.async=!0,u&&k===u&&f.parentElement&&f.parentElement.removeChild(f),i.id?document.getElementById(i.id)||d==null||d.appendChild(i):d==null||d.appendChild(i)}else(0,eval)(f.innerText)}catch(i){console.log(i)}})}),K(r.id),g(document.querySelectorAll(".gamurs-inf-scroll-post")[document.querySelectorAll(".gamurs-inf-scroll-post").length-1],o,!0),g(document.querySelectorAll(".gamurs-inf-scroll-post")[document.querySelectorAll(".gamurs-inf-scroll-post").length-1],t,!1),o.unobserve(document.querySelectorAll(".gamurs-inf-scroll-post")[document.querySelectorAll(".gamurs-inf-scroll-post").length-2].lastChild)}}).catch(a=>{if(e)console.log(a),a!=="did not find #gamurs-inf-scroll-main"&&E();else{let h=window.gamurs_inf_scroll_data.nextUrl.split("?")[1].split("&").filter(c=>c.slice(0,5)==="page="),r=h.length?parseInt(h[0].split("=")[1]):1;if(r<20){if(a.slice(0,15)==="request failed:"){let c=window.gamurs_inf_scroll_data.nextUrl.split("?");window.gamurs_inf_scroll_data.nextUrl=c[0]+"?page="+(r+1).toString()+"&"+c[1].split("&").filter(u=>u.slice(0,5)!=="page=").join("&")}a!=="did not find #gamurs-inf-scroll-main"&&E()}}})}let O,x;function I(){O=B(w,X,"middlelower"),x=B(w,Q,"middleofmiddle")}s==="dotesports"?fetch("/wp-json/gamurs/v1/infscroll/multisites").then(e=>e.json()).then(e=>{let l=new URL(window.location.href).pathname.split("/")[1];e.includes(l)&&(s=`${s}|${l}`,window.gamurs_inf_scroll_data.nextUrl=`${y}/infscroll/${s}/${C}?categories=${v}&tags=${$}&useCategories=${T}&useTags=${M}&forceCategories=${q}&forceTags=${L}&sameCategory=${N}`),I()}).catch(e=>{console.log(e),I()}):I()})();
