news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
!function(){"use strict";var e={d:function(t,a){for(var i in a)e.o(a,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:a[i]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{BrockmanAutoTimeZone:function(){return a},BrockmanCarousel:function(){return i},BrockmanCommentCountLoad:function(){return r},BrockmanForYou:function(){return n},BrockmanGallery:function(){return s},BrockmanImageLightbox:function(){return c},BrockmanInterestsStorage:function(){return l},BrockmanLazyLoad:function(){return u},BrockmanLightbox:function(){return o},BrockmanMyPop:function(){return A},BrockmanPoll:function(){return f},BrockmanPollLoader:function(){return S},BrockmanSearchHistories:function(){return y},BrockmanTableCheckboxes:function(){return b},BrockmanTabs:function(){return E},BrockmanThemes:function(){return T},BrockmanTwitchPlayer:function(){return v},BrockmanVideoPlayer:function(){return F},getCountryCode:function(){return D}});class a{constructor(e){this.selector=e.selector?e.selector:"time",this.language=void 0!==e.language?e.language:"en",this.rtf=new Intl.RelativeTimeFormat(this.language,{numeric:"auto"}),this.militaryTime=!!e.militaryTime,this.showTimeZone=void 0===e.showTimeZone||e.showTimeZone,this.loc=e.loc?e.loc:{justNow:"Just now"},this.event=new Event("BrockmanAutoTimeZone")}static getOptions(e){const{year:t,month:a,day:i,weekday:r,hour:n,minute:s,second:o}=e.dataset;let c={year:t,month:a,day:i,weekday:r,hour:n,minute:s,second:o};return Object.keys(c).forEach((e=>null==c[e]&&delete c[e])),Object.keys(c).length||(c={hour:"numeric",minute:"numeric"}),c.hour12=!this.militaryTime,c}static getTimeZone(e){const t=new Intl.DateTimeFormat("default",{year:"numeric",timeZoneName:"short"}),a=new Date(e);return t.format(a).split(" ")[1]}static getLocalDateTime(e,t){const a=new Intl.DateTimeFormat("default",t),i=new Date(e);return a.format(i)}static getLocalDate(e){const t=new Intl.DateTimeFormat("default",{year:"numeric"}),a=new Intl.DateTimeFormat("default",{month:"numeric"}),i=new Intl.DateTimeFormat("default",{day:"numeric"}),r=new Date(e);return`${t.format(r)}-${a.format(r).padStart(2,"0")}-${i.format(r).padStart(2,"0")}`}getRelativeDate(e,t){const i=new Date,r=new Intl.DateTimeFormat("default",{month:"long"}),n=new Intl.DateTimeFormat("default",{day:"numeric"}),s=new Date(t),o=`${n.format(s)} ${r.format(s)}`;let c=a.getTimeDisplay(e,t);this.showTimeZone&&(c+=` ${a.getTimeZone(t)}`),c+=this.dateString(o);const l=i-s;return this.generateRelativeDate(l,c)}getYesterday(e,t){const a=this.rtf.format(-Math.round(e/t),"day");return a.charAt(0).toUpperCase()+a.slice(1)}generateRelativeDate(e,t){const a=36e5,i=24*a;switch(!0){case e<6e4:return this.dateString(this.loc.justNow);case e${e}`}static fixNoonAndMidnight(e){return e.replace(/^0:(\d\d) (am|pm)/,"12:$1 $2")}static getTimeDisplay(e,t){const i=a.getOptions(e),r=a.getLocalDateTime(t,i);return`${a.fixNoonAndMidnight(r)}`}run(e){(e||document).querySelectorAll(`${this.selector}[datetime]`).forEach((e=>{const{init:t}=e.dataset;t||(this.updateElementDateTimeToLocal(e),e.dataset.init=!0)})),globalThis.dispatchEvent(this.event),this.onUpdatedCallback&&this.onUpdatedCallback()}updateElementDateTimeToLocal(e){const t=e,{autoTimeZone:i,autoRelativeDate:r}=t.dataset,n=t.getAttribute("datetime");let s;if(r)s=this.getRelativeDate(t,n);else{if(!i)return;s=a.getTimeDisplay(t,n),this.showTimeZone&&(s+=` ${a.getTimeZone(n)}`)}t.innerHTML=s,t.dataset.localDate=a.getLocalDate(n)}}class i{constructor({target:e,containerSelector:t,itemSelector:a,indicatorSelector:i,previousButtonSelector:r,nextButtonSelector:n,scrollEndLeeway:s,maxIndicators:o}){this.target=e,this.containerSelector=t||".carousel_items",this.itemSelector=a||".carousel_items > *",this.indicatorSelector=i||".carousel_indicator",this.previousButtonSelector=r||".button.left",this.nextButtonSelector=n||".button.right",this.scrollEndLeeway=s||50,this.maxIndicators=o||8,this.container=this.target.querySelector(this.containerSelector),this.previous=this.target.querySelector(this.previousButtonSelector),this.next=this.target.querySelector(this.nextButtonSelector),this.items=[...this.container.querySelectorAll(this.itemSelector)],this.indicators=[...this.target.querySelectorAll(this.indicatorSelector)],this.maxIndex=0,this.currentIndex=0,this.paginationButtons=[],this.observer=null,this.scrollTimeoutHandler=null,this.register(),this.observe()}register(){this.container.addEventListener("scroll",(()=>this.onScroll()),{passive:!0}),this.next&&this.next.addEventListener("click",(()=>this.scrollTo(this.currentIndex+1))),this.previous&&this.previous.addEventListener("click",(()=>this.scrollTo(this.currentIndex-1))),this.indicators.forEach((e=>e.addEventListener("click",(()=>this.scrollTo(parseInt(e.dataset.index,10))))))}scrollTo(e){e<0||e>this.maxIndex||(this.container.scrollLeft=this.items[e].offsetLeft)}onScroll(){this.scrollTimeoutHandler&&clearTimeout(this.scrollTimeoutHandler),this.scrollTimeoutHandler=setTimeout((()=>this.onScrollEnd()),this.scrollEndLeeway)}onScrollEnd(){this.currentIndex=this.getFirstVisibleIndex(),this.updateButtons()}updateButtons(){this.updateStepButtons(),this.updateIndicators()}updateStepButtons(){this.previous&&(this.previous.disabled=0===this.currentIndex),this.next&&(this.next.disabled=this.currentIndex===this.maxIndex)}updateIndicators(){this.indicators.forEach((e=>{const t=parseInt(e.dataset.index,10),a=e.querySelector(".button");t>this.maxIndex?e.classList.add("hidden"):e.classList.remove("hidden"),t===this.currentIndex?a.classList.add("active"):a.classList.remove("active")})),this.target.dataset.hideIndicators=this.maxIndex>=this.maxIndicators}onResize(){this.maxIndex=this.getMaxIndex(),this.target.dataset.maxIndex=this.maxIndex,this.updateButtons()}observe(){"ResizeObserver"in window?(this.observer=new ResizeObserver((e=>e.forEach((()=>this.onResize())))),this.observer.observe(this.container)):(this.onResize(),globalThis.addEventListener("resize",(()=>this.onResize())))}getMaxIndex(){let e=this.items.length-1;for(let t=e;t>=0;t-=1){if(this.container.scrollWidth-this.items[t].offsetLeft>this.container.offsetWidth)return e;e=t}return 0}getFirstVisibleIndex(){const{scrollLeft:e}=this.container;return this.items.findIndex((t=>t.offsetLeft>=e))}}class r{constructor(e){this.endpoint=e.endpoint,this.run()}run(){const e=[],t={};if(document.querySelectorAll(".comment-count-load").forEach((a=>{const{thread:i}=a.dataset;-1===e.indexOf(i)&&e.push(i),i in t||(t[i]=[]),t[i].push(a)})),0===e.length)return;e.sort(((e,t)=>e-t));const a=new URL(this.endpoint,globalThis.location.origin);a.searchParams.set("threads",e.join(",")),fetch(new Request(a),{headers:{"X-Requested-With":"XMLHttpRequest"}}).then((e=>e.json())).then((e=>{Object.entries(e).forEach((([e,a])=>{t[e].forEach((e=>{e.querySelector(".comments__count").textContent=parseInt(a,10).toLocaleString(),0!==a&&e.classList.remove("skeleton")}))}))})).catch((()=>{document.querySelectorAll(".comment-count-load").forEach((e=>{e.classList.remove("skeleton")}))}))}}class n{constructor(e){this.csrf=e.csrf,this.site=e.site,this.forYouEndpoint=e.for_you_endpoint,this.forYouStartEndpoint=e.for_you_start_endpoint,this.hasPersonalisedHomepageEndpoint=e.has_personalised_homepage_endpoint,this.setPersonalisedHomepageEndpoint=e.set_personalised_homepage_endpoint,this.loggedIn=e.logged_in,this.loading=!1,this.homepageLoaded=!1,this.mypop=e.mypop,this.interestsStorage=e.interests_storage,this.loc=e.loc||{error:"Something went wrong."},this.initialize()}initialize(){this.loadingSpinner=document.querySelector("#for-you-loading-spinner"),this.contentWrapper=document.querySelector(".for-you-content-wrapper")}loadForYouEntry(){this.homepageLoaded||(this.startLoad(),this.interestsStorage.getFollows().then((e=>{this.loggedIn?this.loadForYouEntryLoggedIn(e):this.loadForYouEntryLoggedOut(e)})))}loadForYouEntryLoggedIn(e){this.userHasCustomisedHomepage().then((t=>{t?this.loadForYouHomepage(e):this.loadForYouStep(this.forYouStartEndpoint)}))}loadForYouEntryLoggedOut(e){e.length>0?this.loadForYouHomepage(e):this.loadForYouStep(this.forYouStartEndpoint)}userHasCustomisedHomepage(){const e=new URL(this.hasPersonalisedHomepageEndpoint,globalThis.location.origin);return e.searchParams.append("site",this.site),fetch(new Request(e),{method:"GET",headers:{"X-Requested-With":"XMLHttpRequest"}}).then((e=>e.json())).then((e=>"personalised_homepage"in e&&e.personalised_homepage))}setPersonalisedHomepage(){const e=new FormData;e.append("site",this.site),fetch(new Request(this.setPersonalisedHomepageEndpoint),{method:"POST",headers:{"X-Requested-With":"XMLHttpRequest","X-CSRFToken":this.csrf},body:e})}getSelectedFromForm(e){const t=[],a=e.querySelectorAll("input:checked");for(let e=0;e${this.loc.error}`,this.stopLoad()}loadForYouStep(e){fetch(new Request(e),{method:"GET",headers:{"X-Requested-With":"XMLHttpRequest"}}).then((e=>this.checkStatus(e))).then((e=>e.text())).then((e=>{this.contentWrapper.innerHTML=e,this.contentWrapper.style.minHeight=`${this.contentWrapper.clientHeight}px`,this.stopLoad();const t=this.contentWrapper.querySelector(".for-you-button");"end"===t.dataset.action?t.addEventListener("click",this.followFromForm.bind(this)):t.addEventListener("click",this.clickNext.bind(this));const a=this.contentWrapper.querySelector("button.back");a&&a.addEventListener("click",this.clickBack.bind(this))})).catch((()=>this.renderError()))}followFromForm(){const e=this.contentWrapper.querySelector("form"),t=this.getSelectedFromForm(e);this.interestsStorage.followUUIDs(t).then((()=>{this.loadForYouHomepage(t)}))}loadForYouHomepage(e){this.startLoad(),this.contentWrapper.innerHTML="",this.getForYouHomepageHTML(e).then((e=>this.checkStatus(e))).then((e=>e.text())).then((e=>{this.contentWrapper.innerHTML=e,this.loggedIn&&this.setPersonalisedHomepage(),this.mypop.loadForElement(this.contentWrapper),globalThis.brockmanMogrify?.delayedAutosize(this.contentWrapper),this.homepageLoaded=!0,this.stopLoad()})).catch((()=>this.renderError()))}getForYouHomepageHTML(e){return this.loggedIn?this.getForYouHomepageHTMLLoggedIn(e):this.getForYouHomepageHTMLLoggedOut(e)}getForYouHomepageHTMLLoggedOut(e){const t=new URL(this.forYouEndpoint,globalThis.location.origin);return t.searchParams.append("tags",e),fetch(new Request(t.toString()),{method:"GET",headers:{"X-Requested-With":"XMLHttpRequest"}})}getForYouHomepageHTMLLoggedIn(e){const t=new FormData;return t.append("tags",e.toString()),t.append("site",this.site),fetch(new Request(this.forYouEndpoint),{method:"POST",headers:{"X-Requested-With":"XMLHttpRequest","X-CSRFToken":this.csrf},body:t})}startLoad(){this.loadingSpinner.style.display="block"}stopLoad(){this.loadingSpinner.style.display="none"}}class s{constructor({target:e,minSwipe:t,adPosition:a}){this.gallery=e,this.minSwipe=t||100,this.adPosition=a||"gallery",this.keydownHandler=null,this.swipeXOrigin=null,this.currentCount=0,this.maxCount=0,this.caption=null,this.current=null,this.image=null,this.thumbnailsWrapper=null,this.figures=[],this.thumbnails=[],this.ad=null}run(){this.gallery&&(this.figures=this.getFigures(),this.maxCount=this.figures.length,this.setGalleryNumber(),this.buildInitial())}buildInitial(){this.image=this.gallery.querySelector(".image_wrapper img"),this.inlineCaption=this.gallery.querySelector(".inline-gallery-caption"),this.fullscreenCaption=this.gallery.querySelector(".fullscreen_info .caption"),this.fullscreenCaptionText=this.gallery.querySelector(".fullscreen_info .caption .text"),this.fullscreenAttribution=this.gallery.querySelector(".fullscreen_info .attribution"),this.fullscreenAttributionText=this.gallery.querySelector(".fullscreen_info .attribution .text"),this.current=this.gallery.querySelector(".current"),this.thumbnailsWrapper=this.gallery.querySelector(".thumbnails"),this.loading=this.gallery.querySelector(".loading.spinner.large"),this.adContainer=this.gallery.querySelector(".advert_container");const e=this.gallery.querySelector(".image_wrapper"),t=this.gallery.querySelector(".next"),a=this.gallery.querySelector(".previous"),i=this.gallery.querySelector(".close");this.toggle=this.gallery.querySelector(".toggle"),this.thumbnails=this.gallery.querySelectorAll(".thumbnail"),this.thumbnails.forEach(((e,t)=>{e.querySelector("img").setAttribute("index",t),e.addEventListener("click",this.click.bind(this))})),this.counter=this.gallery.querySelector(".counter"),this.counter.querySelector(".max").innerHTML=this.maxCount,a.addEventListener("click",this.previous.bind(this)),t.addEventListener("click",this.next.bind(this)),this.toggle.addEventListener("click",this.toggleMobileFullscreenCaption.bind(this)),i.addEventListener("click",this.toggleFullscreen.bind(this)),e.addEventListener("touchstart",this.swipeStart.bind(this)),e.addEventListener("touchend",this.swipeEnd.bind(this)),e.addEventListener("click",this.toggleFullscreen.bind(this)),this.image.addEventListener("load",this.imageLoaded.bind(this)),this.keydownHandler=this.keydown.bind(this),this.gallery.dataset.init=!0}getFigures(){const e=this.gallery.querySelectorAll(".thumbnail");return[].slice.call(e)}scrollThumbnails(){const e=this.thumbnails[this.currentCount].offsetLeft-this.thumbnailsWrapper.offsetLeft;this.thumbnailsWrapper.scrollLeft=e}click(e){this.clear(e);let t="-1";t="BUTTON"===e.target.tagName?e.target.firstElementChild.attributes.index.value:e.target.attributes.index.value,t&&(this.currentCount=parseInt(t,10)),e.target.blur(),this.activate(),this.onChange()}activate(){this.imageLoading(),this.updateImage(),this.updateThumbnails(),this.updateCounter(),this.updateInfo()}updateImage(){if(!globalThis.brockmanMogrify)return;const e=this.figures[this.currentCount],t=e.querySelector("img"),a=t?.alt||"",i=this.image.clientWidth,r=this.image.clientHeight,[n,s]=globalThis.brockmanMogrify.resize(i,r,e.dataset.uri,"bounds_lossy");this.startLoad(n,s,a)}updateCounter(){this.current.innerText=this.currentCount+1}updateInfo(){const{caption:e}=this.thumbnails[this.currentCount].dataset,{attribution:t}=this.thumbnails[this.currentCount].dataset;void 0===e?(this.inlineCaption.innerHTML="",this.fullscreenCaption.style.display="none",this.fullscreenCaptionText.innerHTML=""):(this.inlineCaption.innerHTML=e,this.fullscreenCaption.style.display="block",this.fullscreenCaptionText.innerHTML=e),void 0===t?(this.fullscreenAttribution.style.display="none",this.fullscreenAttributionText.innerHTML=""):(this.fullscreenAttribution.style.display="block",this.fullscreenAttributionText.innerHTML=t)}updateThumbnails(){this.thumbnails.forEach((e=>{e.classList.remove("active")})),this.thumbnails[this.currentCount].classList.add("active")}startLoad(e,t,a){this.image.srcset="",this.image.src="",this.image.srcset=t,this.image.src=e,this.image.alt=a}imageLoading(){this.image.classList.add("image--loading"),this.loading.style.display="block"}imageLoaded(){this.image.classList.remove("image--loading"),this.loading.style.display="none"}toggleFullscreen(){this.gallery.classList.toggle("fullscreen"),this.activate(),this.gallery.classList.contains("fullscreen")?(this.injectAd(),document.body.classList.add("overflow-hidden"),document.addEventListener("keydown",this.keydownHandler),this.scrollThumbnails(),globalThis.sendZDAnalyticsEvent("slideshow_open","Content","Slideshow","Open")):(this.destroyAd(),document.body.classList.remove("overflow-hidden"),document.removeEventListener("keydown",this.keydownHandler))}toggleMobileFullscreenCaption(e){this.clear(e),this.toggle.classList.toggle("active"),this.gallery.dataset.details="true"!==this.gallery.dataset.details}next(e){this.clear(e),this.currentCount+=1,this.currentCount>=this.maxCount&&(this.currentCount=0),this.activate(),this.scrollThumbnails(),this.onChange()}previous(e){this.clear(e),this.currentCount-=1,this.currentCount<0&&(this.currentCount=this.maxCount-1),this.activate(),this.scrollThumbnails(),this.onChange()}onChange(){globalThis.sendZDAnalyticsEvent("slideshow_changeslide","Content","Slideshow","Change Slide")}close(e){this.clear(e),this.destroy()}clear(e){e&&(e.preventDefault(),e.stopPropagation(),e.target.blur())}keydown(e){switch(e.keyCode){case 27:e.preventDefault(),this.gallery.classList.contains("fullscreen")&&this.toggleFullscreen();break;case 37:e.preventDefault(),this.previous();break;case 39:e.preventDefault(),this.next()}}swipeStart(e){this.swipeXOrigin=e.changedTouches[0].clientX}swipeEnd(e){const t=e.changedTouches[0];if(this.swipeXOrigin&&t){const a=t.clientX-this.swipeXOrigin,i=Math.sign(a);Math.abs(a)>this.minSwipe?i>0?this.previous():this.next():this.gallery.classList.contains("fullscreen")&&(this.clear(e),this.next())}this.swipeXOrigin=null}setGalleryNumber(){document.querySelectorAll("div.gallery").forEach(((e,t)=>{e===this.gallery&&(this.galleryNumber=t)}))}injectAd(){globalThis.injectLazyloadAd&&globalThis.injectLazyloadAd((e=>this.adContainer.append(e)),{adSizes:this.getAdSizes(),position:this.adPosition,prebidConfig:"SMALL_LEADER",label:""})}getAdSizes(){return 300===this.adContainer.getBoundingClientRect().width?["300x250"]:["320x50"]}destroyAd(){this.adContainer.innerHTML=""}}class o{constructor({closeCallback:e}={}){this.closeCallback=e||null,this.isOpen=!1,this.lightbox=null,this.keydownHandler=null}open(e){this.isOpen||(this.render(),this.keydownHandler=this.keydown.bind(this),document.addEventListener("keydown",this.keydownHandler),this.isOpen=!0,e&&this.inject(e))}close(){this.isOpen&&(this.isOpen=!1,this.image=null,this.lightbox.remove(),document.removeEventListener("keydown",this.keydownHandler),this.closeCallback&&this.closeCallback())}stopLoading(){const e=this.lightbox.querySelector(".spinner");e&&e.remove()}startLoading(){if(this.lightbox.querySelector(".spinner"))return;const e=document.createElement("span");e.classList.add("spinner","large"),this.inject(e)}render(){this.lightbox=document.createElement("div"),this.lightbox.classList.add("lightbox_fullscreen"),this.lightbox.addEventListener("click",(()=>this.close())),document.body.append(this.lightbox)}inject(e){this.lightbox&&e&&this.lightbox.append(e)}keydown(e){"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),this.close())}}class c{constructor({nextIcon:e,previousIcon:t,selector:a}={}){this.nextIcon=e||"→",this.previousIcon=t||"←",this.selector=a||"[data-lightbox][data-uri]",this.elements=[],this.lightbox=null,this.image=null,this.wrapper=null,this.keydownHandler=null,this.index=-1,this.maxIndex=-1}run(){this.lightbox=new o({closeCallback:()=>this.close()}),document.addEventListener("click",(e=>this.click(e)))}click(e){const t=e.target?.closest(this.selector);t&&this.open(t)}open(e){this.elements=[...document.querySelectorAll(this.selector)],this.index=this.elements.indexOf(e),this.maxIndex=this.elements.length-1,this.keydownHandler=this.keydown.bind(this),document.addEventListener("keydown",this.keydownHandler),this.wrapper=document.createElement("div"),this.wrapper.classList.add("wrapper"),this.image=document.createElement("img"),this.image.setAttribute("alt",""),this.image.addEventListener("load",(()=>this.lightbox.stopLoading())),this.wrapper.appendChild(this.image),this.lightbox.open(this.wrapper),this.renderPagination(),this.render(e)}close(){document.removeEventListener("keydown",this.keydownHandler)}render(e){if(!globalThis.brockmanMogrify)return;this.lightbox.startLoading(),this.image.src="",this.image.srcset="";const{uri:t}=e.dataset,a=this.wrapper.clientWidth,i=this.wrapper.clientHeight,[r,n]=globalThis.brockmanMogrify.resize(a,i,t,"bounds_lossy");this.image.src=r,this.image.srcset=n,this.image.setAttribute("alt",this.getAlt(e))}getAlt(e){const{alt:t}=e.dataset;if(t)return t;const a=e.querySelector("img");return a&&a.getAttribute("alt")||""}keydown(e){switch(e.key){case"ArrowLeft":this.paginate(e,-1);break;case"ArrowRight":this.paginate(e,1)}}paginate(e,t){e.preventDefault(),e.stopPropagation(),this.elements.length<=1||(this.index=this.getIndex(t),this.render(this.elements[this.index]))}getIndex(e){let{index:t}=this;return-1===t?null:(t+=e,t<0?this.maxIndex:t>this.maxIndex?0:t)}renderPagination(){if(this.maxIndex<=1)return;const e=document.createElement("nav");e.classList.add("pagination","pagination--hoverable"),e.innerHTML=`\n ${this.getPaginationButton("previous",this.previousIcon)}\n ${this.getPaginationButton("next",this.nextIcon)}\n `,this.lightbox.inject(e),e.querySelector(".previous").addEventListener("click",(e=>this.paginate(e,-1))),e.querySelector(".next").addEventListener("click",(e=>this.paginate(e,1)))}getPaginationButton(e,t){return`\n
\n \n
\n `}}class l{constructor(e){this.csrf=e.csrf,this.site=e.site,this.loggedIn=e.logged_in,this.allFollowsEndpoint=e.all_follows_url,this.followEndpoint=e.follow_url,this.followWithSuggestedEndpoint=e.follow_with_suggested_url,this.unfollowEndpoint=e.unfollow_url,this.loaded=!1,this.storage_key=this.getStorageKey(),this.initialize()}initialize(){if(!this.loggedIn)return this.loaded=!0,void this.resetStorageKey();sessionStorage.getItem(this.storage_key)&&(this.loaded=!0)}resetStorageKey(){sessionStorage.getItem(this.storage_key)||sessionStorage.setItem(this.storage_key,"")}getStorageKey(){return this.loggedIn?"interests_logged_in":"interests_logged_out"}getFollows(e=!0){if(e&&this.loaded){const e=sessionStorage.getItem(this.storage_key);return e.length>0?Promise.resolve(e.split(",")):Promise.resolve([])}return fetch(new Request(this.allFollowsEndpoint),{method:"GET",headers:{"X-Requested-With":"XMLHttpRequest"}}).then((e=>e.json())).then((e=>"following"in e&&(sessionStorage.setItem(this.storage_key,e.following.toString()),this.loaded=!0,e.following.length>0)?e.following:[])).catch((()=>(this.loaded=!0,[])))}getFollowEndpoint(e){return e?this.followWithSuggestedEndpoint:this.followEndpoint}followUUIDs(e,t=!1){if(!this.loaded)return this.getFollows().then((()=>{this.followUUIDs(e)}));if(!this.loggedIn)return Promise.resolve(this.addUUIDsToStorage(e));if(e.length>200){const t=e.reduce(((e,t,a)=>{const i=Math.floor(a/200);return e[i]=[].concat(e[i]||[],t),e}),[]);return Promise.all(t.map((e=>this.followUUIDs(e))))}const a=new FormData;a.append("tags",e.toString()),a.append("site",this.site);const i=this.getFollowEndpoint(t);return fetch(new Request(i),{method:"POST",headers:{"X-Requested-With":"XMLHttpRequest","X-CSRFToken":this.csrf},body:a}).then((e=>{if(e.ok)return e;throw new Error})).then((e=>e.json())).then((t=>{const{markup:a}=t;return this.addUUIDsToStorage(e),{uuids:e,markup:a}}))}unfollowUUID(e){if(!this.loaded)return this.getFollows().then((()=>{this.unfollow(e)}));if(!this.loggedIn)return Promise.resolve(this.removeUUIDFromStorage(e));const t=new FormData;return t.append("tags",e),t.append("site",this.site),fetch(new Request(this.unfollowEndpoint),{method:"POST",headers:{"X-Requested-With":"XMLHttpRequest","X-CSRFToken":this.csrf},body:t}).then((e=>{if(e.ok)return e;throw new Error})).then((()=>(this.removeUUIDFromStorage(e),[e])))}addUUIDsToStorage(e){const t=sessionStorage.getItem(this.storage_key).split(",").filter(Boolean);return this.loggedIn&&0===t.length&&this.toggleFirstFollowModal(),sessionStorage.setItem(this.storage_key,[...new Set(t.concat(e))].toString()),e}removeUUIDFromStorage(e){const t=sessionStorage.getItem(this.storage_key).split(","),a=t.indexOf(e);return a>-1&&t.splice(a,1),sessionStorage.setItem(this.storage_key,t.toString()),e}toggleFirstFollowModal(){this.firstFollowModal&&this.firstFollowModal.classList.toggle("show")}}class u{constructor(){this.selector="script[data-lazyload=true]",this.observer=null,this.observedElements=[]}init(){"IntersectionObserver"in window?(this.observer=new IntersectionObserver((e=>this.observe(e))),globalThis.addEventListener("BrockmanTargetingCookiesAllowed",(()=>this.refresh())),globalThis.addEventListener("BrockmanTargetingCookiesDisallowed",(()=>this.run()))):this.run()}run(){document.querySelectorAll(this.selector).forEach((e=>this.register(e.parentElement)))}register(e){if(!this.observer)return void this.load(e);if(this.observedElements.includes(e))return;const{cookiesSrc:t}=e.querySelector("script").dataset;t&&(this.observer.observe(e),this.observedElements.push(e))}deregister(e){this.observer.unobserve(e),this.observedElements.splice(this.observedElements.indexOf(e),1)}observe(e){e.forEach((e=>{if(!e.isIntersecting)return;const{target:t}=e;this.load(t)}))}refreshScripts(){document.querySelectorAll(this.selector).forEach((e=>{const t=e.parentElement,a=t.querySelector("script");if(a.hasAttribute("src")){const e=document.createElement("script");e.dataset.cookiesSrc=a.dataset.cookiesSrc,e.dataset.noCookiesSrc=a.dataset.noCookiesSrc,e.dataset.lazyload=!0,a.getAttribute("onload")&&e.setAttribute("onload",a.getAttribute("onload")),t.innerHTML="",t.append(e)}}))}refresh(){this.observedElements.forEach((e=>this.observer.unobserve(e))),this.observedElements=[],this.refreshScripts(),this.run()}load(e){const t=e.querySelector("script"),{cookiesSrc:a,nocookiesSrc:i}=t.dataset;a&&globalThis.BrockmanAllowedCookies?.targeting?t.src=a:i&&(t.src=i),this.observer&&this.deregister(e)}}const h="error",d="follow",m="unfollow",p="errorall",g="followall";class A{constructor(e){this.site=e.site,this.loggedIn=e.loggedIn,this.loginEndpoint=e.loginURL,this.interestsStorage=e.interests_storage,this.loc=e.loc||{error:"Error"},this.maxPopupOpens=e.maxPopupOpens||1,this.followButtonsByUUID={},this.popup=null,this.popupOpens=0,this.lightbox=null}run(){this.loadForElement(document.body),this.updateAllButtonStates()}redirectToLogin(){const e=new URL(this.loginEndpoint,globalThis.location.origin);globalThis.location.href=e}loadForElement(e){const t=e.querySelectorAll(".mypop-button:not([data-init])");this.registerFollowButtons(t)}updateAllButtonStates(){this.interestsStorage.getFollows().then((e=>this.setFollowButtonStateByUUID(e,!0)))}registerFollowButtons(e){e.forEach((e=>{const{uuid:t}=e.dataset;t in this.followButtonsByUUID?this.followButtonsByUUID[t].push(e):this.followButtonsByUUID[t]=[e],e.addEventListener("click",(()=>this.clickFollowButton(e))),e.dataset.init=!0}))}setFollowButtonState(e,t){const{ariaFollowText:a,ariaUnfollowText:i,followText:r,unfollowText:n}=e.dataset;switch(e.dataset.state=t,t){case d:case g:this.updateButtonText(e,r,a),e.classList.remove("outline");break;case m:this.updateButtonText(e,n,i),e.classList.add("outline");break;default:this.updateButtonText(e,this.loc.error,a)}}updateButtonText(e,t,a){const[i,r]=[t,a].map(this.parseJSON);e.innerHTML=i,e.ariaLabel=r,e.title=r}parseJSON(e){return JSON.parse(`"${e}"`)}setFollowButtonStateByUUID(e,t){e.forEach((e=>{const a=this.followButtonsByUUID[e]||[],i=t?m:d;a.forEach((e=>this.setFollowButtonState(e,i)))}))}clickFollowButton(e){if(this.loggedIn||!this.withForceLogin(e))switch(e.dataset.state){case m:this.unfollow(e);break;case g:case p:this.followAll(e);break;default:this.follow(e)}else this.redirectToLogin()}withForceLogin(e){return e&&"true"===e.dataset.forceLogin}followAll(e){const t=[];e.closest(".mypop-suggestions__item").querySelectorAll('.mypop-button[data-state="follow"]').forEach((e=>{t.push(e.dataset.uuid)})),t.length&&this.interestsStorage.followUUIDs(t).then((()=>this.updateAllButtonStates())).catch((()=>this.setFollowButtonState(e,p)))}follow(e){const{uuid:t}=e.dataset;this.interestsStorage.followUUIDs([t],this.withPopup(e)).then((e=>{const{markup:t,uuids:a}=e;return t&&this.openPopup(t),a||e})).then((e=>this.setFollowButtonStateByUUID(e,!0))).catch((()=>this.setFollowButtonState(e,h))),globalThis.sendZDAnalyticsEvent("follow","User Tools","Following","Follow Button")}unfollow(e){const{uuid:t}=e.dataset;this.interestsStorage.unfollowUUID(t).then((e=>this.setFollowButtonStateByUUID([e],!1))).catch((()=>this.setFollowButtonState(e,h)))}withPopup(e){return e&&"true"===e.dataset.popup&&this.popupOpens{this.closePopup(),this.closeLightbox()}))}showPopup(){setTimeout((()=>globalThis.requestAnimationFrame((()=>{this.popup&&this.popup.classList.add("visible")}))))}closePopup(){this.popup&&this.popup.remove()}openLightbox(){globalThis.BrockmanLightbox&&(this.lightbox||(this.lightbox=new globalThis.BrockmanLightbox({closeCallback:()=>this.closePopup()})),this.lightbox.open())}closeLightbox(){this.lightbox&&this.lightbox.close()}}class f{constructor(e){this.wrapper=e.wrapper,this.postEndpoint=e.postEndpoint,this.getEndpoint=e.getEndpoint,this.tags=e.tags,this.autoPoll=!1,this.fixedPoll=!1,this.storageValues=[],this.localStorageName="poll_answers",this.inputCheckedCounter=0,this.poll=null,this.inputs=null,this.submitButton=null,this.loc=e.loc||{genericError:"Sorry, but an error occurred. Please try again.",upNext:"Up next",votedMessage:"You've already voted on this poll."},this.submitVotesHandler=e=>this.submitVotes(e),this.changeButtonStateHandler=e=>this.changeButtonState(e)}run(){this.poll=this.wrapper.querySelector('slot[name="poll"]'),"false"===this.wrapper.dataset.fixed?this.runAutoPoll():"true"===this.wrapper.dataset.fixed?this.runFixedPoll():this.poll&&this.poll.innerHTML&&this.register(),this.wrapper.dataset.init=!0}register(){this.poll&&(this.regenerateLocalStorage(),this.getLocalStorage()&&this.checkStorageMatch(),this.inputs=this.poll.querySelectorAll(".poll_vote"),this.submitButton=this.poll.querySelector("button.vote"),this.inputs.forEach((e=>e.addEventListener("change",this.changeButtonState.bind(this)))),this.submitButton.addEventListener("click",this.submitVotes.bind(this)),globalThis.brockmanMogrify?.delayedAutosize(this.poll))}runAutoPoll(){this.autoPoll=!0,this.regenerateLocalStorage(),this.getNextPoll("","")}runFixedPoll(){this.fixedPoll=!0,this.regenerateLocalStorage(),this.getNextPoll(this.poll.dataset.hashid,"")}regenerateLocalStorage(){const e=this.getLocalStorage();if(e){const t=JSON.parse(e);this.storageValues=[...new Set(t)]}}checkStorageMatch(){if(this.storageValues){const e=[...this.inputs].filter((e=>this.storageValues.includes(e.dataset.hashid)));e&&e.length>1?e.forEach((e=>{this.showPreviouslyVoted(e)})):e.length&&this.showPreviouslyVoted(e.shift())}}changeButtonState(e){e.currentTarget.checked?this.inputCheckedCounter+=1:this.inputCheckedCounter-=1,this.submitButton.disabled=this.inputCheckedCounter<=0}submitVotes(e){e.preventDefault(),e.currentTarget.disabled=!0,this.removeErrors();const t=[],a=[],i=e.currentTarget.closest("form.poll");if(this.inputs.forEach((e=>{if(e.classList.remove("invalid"),e.checked){const{hashid:i}=e.dataset;i.length>0?(t.push(e),a.push(i),this.isFunctionalAllowed()&&this.setLocalStorage(i)):e.classList.add("invalid")}})),a.length>0&&t){const e=encodeURIComponent(a),r=`${this.postEndpoint}?hashes=${e}`;this.request(r,i,t),"false"!==this.poll.dataset.sponsored&&this.poll.querySelector(".cta_link")||this.getNextPoll("",a)}else this.renderError()}getExistingPollHashids(){return[...document.querySelectorAll(".poll[data-hashid]")].map((e=>e.dataset.hashid))}getNextPoll(e="",t=""){let a,i,r=this.storageValues;if("getCountryCode"in window&&(a=globalThis.getCountryCode()),e)i=`${this.getEndpoint}?poll=${e}&country=${a}`;else{t&&Array.isArray(t)&&t.length>1?t.forEach((e=>{r=this.duplicatesRemoved(r,e)})):r=this.duplicatesRemoved(r,t);const e=encodeURIComponent(t),n=encodeURIComponent(r),s=encodeURIComponent(this.tags),o=encodeURIComponent(this.getExistingPollHashids());i=`${this.getEndpoint}?answer=${e}&previous=${n}&country=${a}&tag_slugs=${s}&exclude=${o}`}this.fetchNextPoll(i)}duplicatesRemoved(e,t){if(e.includes(t)){const a=e.indexOf(t);e.splice(a,1)}return e}request(e,t,a){fetch(new Request(e),{method:"POST",headers:{"X-Requested-With":"XMLHttpRequest"},body:new FormData(t)}).then((e=>this.status(e))).then((e=>e.json())).then((e=>this.processVotes(e,a))).catch((()=>this.renderError()))}status(e){if(e.ok&&e.status>=200&&e.status<300)return e;throw new Error("Response not OK")}processVotes(e,t){const a=[];if(t.forEach((e=>{a.push(e.dataset.hashid),this.sendTrackingData(e)})),e.total_votes){const t=this.poll.querySelector(".vote_count"),a=parseInt(e.total_votes,10).toLocaleString();t.innerHTML=a}e.votes_by_answer&&this.inputs.forEach((t=>{e.votes_by_answer.forEach((i=>{if(t.dataset.hashid===i.hashid){const r=`${parseInt(i.vote_count/e.votes_by_session*100,10)}%`;a.includes(t.dataset.hashid)?this.updateVotes(t,r,!0):this.updateVotes(t,r)}}))})),"true"===this.poll.dataset.sponsored&&this.poll.querySelector(".cta_link")&&this.renderSponsorCTA(this.poll),globalThis.sendZDAnalyticsEvent("polls_vote","User Tools","Polls","Vote")}sendTrackingData(e){const t=this.poll.querySelector(".question"),a=e.closest(".poll_vote_wrapper").querySelector(".poll_vote_label"),{signals:i}=e.dataset;t&&a&&this.sendToZDCore(t.innerText,i,a.innerText)}updateVotes(e,t,a=!1){this.disableButtons();const i=e.closest(".poll_vote_wrapper");a&&(e.checked=!0),this.addPercentageValue(t,i)}showPreviouslyVoted(e){this.inputs.forEach((t=>{const a=t===e;this.updateVotes(t,t.dataset.votePercentage,a)}));const t=this.poll.closest(".poll_container").querySelector(".alert.info");"true"===this.poll.dataset.sponsored&&this.poll.querySelector(".cta_link")?this.renderSponsorCTA(this.poll):t||this.renderAlert(this.loc.votedMessage,"info")}async fetchNextPoll(e){const t=new URL(e,globalThis.location.origin);await fetch(t).then((e=>this.status(e))).then((e=>e.text())).then((e=>this.processNextPoll(e))).catch((()=>this.renderError()))}processNextPoll(e){if(!this.autoPoll&&!this.fixedPoll||e){if(!e)return}else this.processNoResult();const t=(new DOMParser).parseFromString(e,"text/html"),a=t.documentElement.querySelector(".poll"),{inactiveAnswers:i}=a.dataset;if(""!==i&&this.removeInactivePolls(i),this.autoPoll||this.fixedPoll)this.showNextPoll(e);else{const a=t.documentElement.querySelector(".question");this.renderUpNext(a).addEventListener("click",this.clickNextPoll.bind(this,e))}}removeInactivePolls(e){const t=[],{storageValues:a}=this;if(t.push(e),t.length>1)t.forEach((e=>{const t=a.indexOf(e);-1!==t&&a.splice(t,1)}));else{const t=a.indexOf(e);-1!==t&&a.splice(t,1)}this.storageValues=a,this.addLocalStorage(this.storageValues)}replacePollDetails(e){const t=(new DOMParser).parseFromString(e,"text/html").documentElement.querySelector(".poll").style.getPropertyValue("--poll-primary-color"),a=this.poll.closest(".poll_wrapper").style;a.setProperty("--poll-primary-color",t),a.setProperty("--poll-border-color",t);const i=document.createElement("div");i.innerHTML=e;const r=i.querySelector(".poll");this.poll.replaceWith(r),this.resetPoll(r),this.register()}clickNextPoll(e,t){t.preventDefault(),this.replacePollDetails(e)}showNextPoll(e){this.autoPoll=!1,this.fixedPoll=!1,this.replacePollDetails(e),this.wrapper.dataset.hydrated=!0}addPercentageValue(e,t){const a=t.querySelector(".poll_vote_label"),i=t.querySelector(".percentage_text");if(t.style.setProperty("--percentage-width",e),!i){const t=document.createElement("span");t.classList="percentage_text",t.innerHTML=e,this.insertElement(a,t)}}renderSponsorCTA(e){const t=e.querySelector(".cta_container");t&&t.classList.remove("hidden")}renderUpNext(e){const t=e,a=document.createElement("button");return a.classList="up_next",a.innerHTML=`\n
\n
\n ${this.loc.upNext}\n ${t.innerHTML}\n
\n `,this.poll.append(a),a}processNoResult(){this.wrapper.remove()}isFunctionalAllowed(){return!!globalThis.BrockmanAllowedCookies?.functional}resetPoll(e){this.poll=e,this.removeAds(this.poll);const t=this.poll.querySelector(".vote_count");t.innerHTML=parseInt(t.innerHTML,10).toLocaleString(),this.inputs=e.querySelectorAll(".poll_vote"),this.submitButton=e.querySelector("button.vote"),this.inputCheckedCounter=0,document.removeEventListener("click",this.submitVotesHandler),document.removeEventListener("change",this.changeButtonStateHandler)}removeAds(e){if("true"===e.dataset.sponsored){const e=this.wrapper.querySelector(".poll_leaderboard_container"),t=this.wrapper.querySelector(".poll_ad_container");e&&e.remove(),t&&t.remove()}}renderError(){this.removeErrors(),this.renderAlert(this.loc.genericError,"error")}renderAlert(e,t){const a=document.createElement("div");a.classList=`alert ${t}`,a.innerHTML=`${e}`,this.insertElement(this.poll,a)}removeErrors(){const e=this.wrapper.querySelectorAll(".alert.error");e.length>=1&&e.forEach((e=>e.remove()))}insertElement(e,t){e&&e.parentNode.insertBefore(t,e.nextSibling)}disableButtons(){this.inputs&&this.inputs.forEach((e=>{e.disabled=!0})),this.submitButton&&(this.submitButton.disabled=!0,this.submitButton.classList.add("hidden"))}getLocalStorage(){return localStorage.getItem(this.localStorageName)}setLocalStorage(e){this.regenerateLocalStorage(),this.storageValues.push(e),this.addLocalStorage(this.storageValues)}addLocalStorage(e){localStorage.setItem(this.localStorageName,JSON.stringify(e))}sendZDCoreSignal(e,t){globalThis.zd.core.signals.sendSignal("Generic KV Tracking",{namespace:"igne_polls",key:e,value:t})}sendToZDCore(e,t,a){globalThis.zd&&(t&&t.split(",").forEach((t=>{this.sendZDCoreSignal(e,t)})),this.sendZDCoreSignal(e,a),this.sendZDCoreSignal("poll_answered","yes"))}}class S{constructor({postEndpoint:e,getEndpoint:t,placeholderSelector:a,pollTemplateSelector:i,placeholderTemplateSelector:r,injectionPlaceholderSelector:n,parentSelector:s,pollSelector:o,loc:c,tags:l=[],autoInject:u=!1}){this.postEndpoint=e,this.getEndpoint=t,this.placeholderSelector=a||'.poll_wrapper[data-init="false"]',this.pollTemplate=document.querySelector(i||"#poll-template"),this.placeholderTemplate=document.querySelector(r||"#poll-placeholder-template"),this.injectionPlaceholderSelector=n||".injection_placeholder",this.parentSelector=s||".article_body_content",this.pollSelector=o||".poll_wrapper",this.loc=c||{upNext:"Up next",genericError:"Sorry, but an error occurred. Please try again.",votedMessage:"You've already voted on this poll."},this.tags=l,this.autoInject=u,this.adCounter=0}run(){globalThis.BrockmanPoll&&this.pollTemplate&&(this.autoInjectPolls(),document.querySelectorAll(this.placeholderSelector).forEach((e=>this.injectPoll(e))),globalThis.brockmanAds?.lazyloadAds())}injectPoll(e){const t=this.pollTemplate.content.firstElementChild.cloneNode(!0),{hashid:a,fixed:i,pollPosition:r}=e.dataset;t.dataset.fixed=i,t.dataset.pollPosition=r,t.querySelector('slot[name="poll"]').dataset.hashid=a,this.adCounter+=1;const n=t.querySelector(".poll_leaderboard");n&&(n.id=n.id.replace(/.$/,this.adCounter));const s=t.querySelector(".poll_ad_container .mpu");s&&(s.id=s.id.replace(/.$/,this.adCounter)),t.dataset.placed=!(n||s),e.replaceWith(t),new globalThis.BrockmanPoll({wrapper:t,postEndpoint:this.postEndpoint,getEndpoint:this.getEndpoint,tags:this.tags,loc:this.loc}).run()}autoInjectPolls(){this.autoInject&&this.placeholderTemplate&&document.querySelectorAll(this.parentSelector).forEach((e=>{if(e.querySelector(this.pollSelector))return;const t=[...e.querySelectorAll(this.injectionPlaceholderSelector)].pop(),a=this.placeholderTemplate.content.cloneNode(!0);t?t.replaceWith(a):e.append(a)}))}}class y{constructor(e){this.loc=e.loc,this.searchBox=document.querySelector(".search-box"),this.storageKey="search-history",this.run()}getSearches(){try{const e=JSON.parse(localStorage.getItem(this.storageKey));return Array.isArray(e)?this.clean(e):[]}catch{return[]}}clean(e){return e.map((e=>e.trim())).filter(Boolean)}setSearches(e){return e=(e=[...new Set(this.clean(e))]).slice(0,6),localStorage.setItem(this.storageKey,JSON.stringify(e))}removeSearchHistory(e){const t=e.currentTarget.getAttribute("data-value");e.currentTarget.parentNode.remove();const a=this.getSearches(),i=a.indexOf(t);a.splice(i,1),this.setSearches(a),0===a.length&&(this.container.innerHTML="")}renderSearchHistory(){const e=this.getSearches();if(this.container.innerHTML="",e.length>0){const t=document.createElement("p");t.innerHTML=this.loc.recent_searches;const a=document.createElement("ul"),i=e.length;for(let t=0;t{this.mainCheckbox.checked?this.checkboxes.forEach((e=>{e.checked=!0})):this.checkboxes.forEach((e=>{e.checked=!1}))}))}}class E{constructor({selector:e,container:t}){this.container=t||document;const a=e||".tabbed_button";this.buttons=this.container.querySelectorAll(a),this.callback=null}run(){this.buttons.forEach(((e,t)=>{0===t?this._setActive(e):this._setInactive(e);const{tab:a}=e.dataset;a&&e.addEventListener("click",(()=>this.click(e)))}))}_getTab(e){const{tab:t}=e.dataset;return t?this.container.querySelector(t):null}_setActive(e){const t=this._getTab(e);if(!t)return;t.classList.remove("hidden"),e.classList.add("active");const a=e.querySelector(".tabbed_button_count");a&&a.remove(),this.callback&&this.callback(t),globalThis.brockmanMogrify?.delayedAutosize(t)}_setInactive(e){const t=this._getTab(e);t&&(t.classList.add("hidden"),e.classList.remove("active"))}_setAllInactive(){this.buttons.forEach((e=>this._setInactive(e)))}registerCallback(e){this.callback=e}click(e){this._setAllInactive(),this._setActive(e)}setTab(e){const t=this.buttons[e];t&&this.click(t)}}class T{constructor({cacheTTL:e,defaultTheme:t,localStorageKey:a,queryString:i,stylesheetURL:r,switcherSelector:n}){this.cacheTTL=e||300,this.defaultTheme=t||"auto",this.localStorageKey=a||"BrockmanTheme",this.queryString=i||"theme",this.stylesheetURL=r||"",this.switcherSelector=n||".theme-switcher",this.darkModeMatch=globalThis.matchMedia("(prefers-color-scheme: dark)")}init(){this._registerSwitchers();const e=this._getPreviewTheme();e&&this.activate(e,0)}activate(e,t=this.cacheTTL){e&&(this.set(e),document.getElementById(this._getStylesheetID(e))||this._appendStylesheetLink(e,t))}set(e){document.documentElement.dataset.theme=e}_registerSwitchers(){const e=this._getSavedTheme(),t=this._getPreviewTheme();document.querySelectorAll(this.switcherSelector).forEach((a=>{if(a.addEventListener("change",(e=>{const t=e.target.value;this._setSavedTheme(t),this._updateTheme(t)})),t)return;const i=a.querySelector(`input[value="${e}"]`);i&&(i.checked=!0)})),this.darkModeMatch.addEventListener("change",(()=>{"auto"===this._getSavedTheme()&&this.set(this._getAutoTheme())}))}_updateTheme(e){this.set("auto"===e?this._getAutoTheme():e)}_getSavedTheme(){return localStorage.getItem(this.localStorageKey)||this.defaultTheme}_setSavedTheme(e){localStorage.setItem(this.localStorageKey,e)}_getAutoTheme(){return this.darkModeMatch.matches?"dark":"light"}_appendStylesheetLink(e,t){const a=document.createElement("link");a.rel="stylesheet",a.href=this._getStylesheetURL(e,t),a.id=this._getStylesheetID(e),document.head.appendChild(a)}_getStylesheetID(e){return`theme-${e}`}_getStylesheetURL(e,t){const a=new URL(this.stylesheetURL.replace("slug",e),globalThis.location.origin);return a.searchParams.set("v",this._getStylesheetVersion(t)),a}_getStylesheetVersion(e){return e?Math.floor(Date.now()/1e3/e):Math.floor(Date.now())}_getPreviewTheme(){const e=new URLSearchParams(globalThis.location.search);return e.has(this.queryString)?e.get(this.queryString):null}}class v{constructor(e){this.target=e.target,this.endpoint=e.endpoint,this.twitchEmbedId=e.twitchEmbedId||"twitch-embed",this.player=null,this.loc=e.loc||{label:"Live",playing:"playing"}}run(){this.fetchChannels()}destroy(){this.target.remove()}fetchChannels(){fetch(this.endpoint).then((e=>{if(!e.ok)throw new Error("Response status not ok");return e})).then((e=>e.json())).then((e=>{e&&"data"in e&&e.data.length?this.buildPlayer(e.data[0]):this.destroy()})).catch((()=>this.destroy()))}buildPlayer(e){if("Twitch"in window)this.createTwitchPlayer(e);else{const t=document.createElement("script");t.src="https://player.twitch.tv/js/embed/v1.js";const a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(t,a),t.onload=this.createTwitchPlayer.bind(this,e)}}createTwitchPlayer(e){["name","user_name","game_name"].every((t=>t in e))?(this.target.innerHTML=`\n

\n ${this.loc.label}: ${e.user_name} ${this.loc.playing} ${e.game_name}\n

\n
\n
\n
\n `,this.target.classList.add("loaded"),this.player=new globalThis.Twitch.Player(this.twitchEmbedId,{channel:e.name,layout:"video",autoplay:!0,muted:!0})):this.destroy()}}function M(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,i=Array(t);a1&&void 0!==arguments[1]?arguments[1]:{};return R[e]||(t=function(e,t){var a=e.countries[t];if(!a)return null;var i=function(e){return P||(P=function(e){return Object.keys(e.timezones).reduce((function(t,a){var i=e.timezones[a],r=i.c,n=i.a,s=e.timezones[n]||{},o=r||s.c;if(!o)return t;var c,l=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=C(e))){t&&(e=t);var a=0,i=function(){};return{s:i,n:function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,n=!0,s=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return n=e.done,e},e:function(e){s=!0,r=e},f:function(){try{n||null==t.return||t.return()}finally{if(s)throw r}}}}(o);try{for(l.s();!(c=l.n()).done;){var u=c.value;t[u]||Object.assign(t,L({},u,{current:[],all:[]})),void 0===i.r&&t[u].current.push(a),t[u].all.push(a)}}catch(e){l.e(e)}finally{l.f()}return t}),{})}(e)),P}(e)[t]||{};return{id:t,name:a,timezones:i.current||[],allTimezones:i.all||[]}}(I,e),t&&(R[t.id]=t)),function(e,t){if(!e)return null;var a=(t||{}).deprecated;e.allTimezones;var i=function(e,t){if(null==e)return{};var a,i,r=function(e,t){if(null==e)return{};var a={};for(var i in e)if({}.hasOwnProperty.call(e,i)){if(-1!==t.indexOf(i))continue;a[i]=e[i]}return a}(e,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(i=0;i1&&void 0!==arguments[1]?arguments[1]:{};return((t=e,U[t]||(a=function(e,t){var a=e.timezones[t];if(!a)return null;var i=a.a,r=void 0===i?null:i,n=k(k({},r?e.timezones[r]:{}),e.timezones[t]),s=n.c||[],o=n.u,c=Number.isInteger(n.d)?n.d:o,l={name:t,countries:s,utcOffset:o,utcOffsetStr:B(o),dstOffset:c,dstOffsetStr:B(c),aliasOf:r};return a.r&&(l.deprecated=!0),l}(I,t),a&&(U[a.name]=a,Object.keys(a).length)),(U[t]?k({},U[t]):null)||{}).countries||[]).map((function(e){return H(e,i)}))}function N(e){return(t=G(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}),a=1,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var i,r,n,s,o=[],c=!0,l=!1;try{if(n=(a=a.call(e)).next,0===t){if(Object(a)!==a)return;c=!1}else for(;!(c=(i=n.call(a)).done)&&(o.push(i.value),o.length!==t);c=!0);}catch(e){l=!0,r=e}finally{try{if(!c&&null!=a.return&&(s=a.return(),Object(s)!==s))return}finally{if(l)throw r}}return o}}(t,a)||C(t,a)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0]||null;var t,a}const D=()=>{if(Intl){const{timeZone:e}=Intl.DateTimeFormat().resolvedOptions(),t=N(e);if(t)return t.id}return"UNKNOWN"};class F{constructor(e){this.target=e.target,this.endpoint=e.endpoint,this.channelId=e.channelId,this.adsEnabled=e.adsEnabled,this.autoLoad=!!e.autoLoad,this.spinnerClassList=e.spinnerClassList||"spinner large",this.descriptionLength="number"==typeof e.descriptionLength?e.descriptionLength:500,this.loc={error:"Sorry, there was an error loading the video player.",loading:"Loading",seeMore:"See more %1% videos",subscribe:"Subscribe",thumbnail:"%1% thumbnail",title:"Video player"},e.loc&&Object.keys(this.loc).forEach((t=>{e.loc[t]&&(this.loc[t]=e.loc[t])})),this.observer=null,this.playlist=[],this.videoHolder=null,this.videoWrapper=null,this.channel={},this.videos=[]}static isTargetingAllowed(){return!!globalThis.BrockmanAllowedCookies&&globalThis.BrockmanAllowedCookies.targeting}run(){this.target&&this.channelId&&(this.renderSpinner(),this.autoLoad?this.fetch():this.observe())}renderSpinner(){this.target.innerHTML=``}observe(){"IntersectionObserver"in window?(this.observer=new IntersectionObserver((e=>this.intersect(e))),this.observer.observe(this.target)):this.fetch()}intersect(e){e[0].isIntersecting&&(this.fetch(),this.observer.disconnect())}fetch(){this.target.dataset.loaded=!1;const e=`${this.endpoint}?channel_id=${this.channelId}`;fetch(e).then((e=>{if(!e.ok)throw new Error("Response status not ok");return e})).then((e=>e.text())).then((e=>this.parse(e))).catch((()=>this.renderError()))}parse(e){const t=(new DOMParser).parseFromString(e,"text/xml"),a=t.getElementsByTagName("author")[0];this.channel={name:a.getElementsByTagName("name")[0].textContent,uri:a.getElementsByTagName("uri")[0].textContent};const i=t.getElementsByTagName("entry");for(let e=0;e\n
\n
\n \n
\n
\n

\n ${this.descriptionLength?'
':""}\n
\n ${this.getChannelButtonMarkup()}\n ${this.getSubscribeButtonMarkup()}\n
\n \n `}getVideoPlaylistMarkup(){let e="";return Object.keys(this.videos).forEach((t=>{e+=this.getVideoPlaylistItemMarkup(this.videos[t])})),`\n
\n ${e}\n
\n `}getVideoPlaylistItemMarkup(e){return`\n \n \n \n \n ${e.title}\n \n `}getChannelButtonMarkup(){return`\n \n ${this.loc.seeMore.replace("%1%",this.channel.name)}\n \n `}getSubscribeButtonMarkup(){return`\n