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