var e,t,a,o,i,n,r,l;import{m as s,a as c,b as d,c as m,d as f}from"./vendor-DH-HcC7C.js";import{s as u,i as v}from"./Nav/Nav.ts-CuXyNR-H.js";import{g as p,s as h}from"./cookies-Btke1V1y.js";import{i as g}from"./lazy-iframe-DxRpt_oy.js";import{r as w}from"./reduxStore-iLD4WOR5.js";import{o as E}from"./observeStore-BF0SmwAT.js";import"./debouncer-DovBpx4g.js";const y=36e5,S=24*y,j=7*S,x=30*S,D=365*S,F=()=>"undefined"!=typeof window&&window.ffte&&window.ffte.lang?window.ffte.lang:"en-US",b=(e,t=null,a=new Date)=>e>new Date(a).setDate(a.getDate()-3)&&e{const o=a?{timeStyle:"short"}:{};return new Intl.DateTimeFormat(t||F(),{dateStyle:"long",...o}).format(e)},A=(e,t=null,a=Date.now())=>{const o=a-e,i=new Intl.RelativeTimeFormat(t||F(),{numeric:"auto"});return o<6e4?i.format(-Math.round(o/1e3),"second"):o{Array.prototype.forEach.call(e,(function(e){e.innerHTML=t(new Date(e.getAttribute("datetime")))}))},M=Object.freeze(Object.defineProperty({__proto__:null,formatAbsoluteDate:z,formatDate:b,formatRelativeDate:A,updateRelativeDates:()=>{L(document.querySelectorAll("time.relative-date"),(e=>b(e))),L(document.querySelectorAll("time.live-feed-date"),(e=>z(e,null,!0)))}},Symbol.toStringTag,{value:"Module"})),I=["application/javascript","application/ecmascript","application/x-ecmascript","application/x-javascript","text/ecmascript","text/javascript","text/javascript1.0","text/javascript1.1","text/javascript1.2","text/javascript1.3","text/javascript1.4","text/javascript1.5","text/jscript","text/livescript","text/x-ecmascript","text/x-javascript"],C=Object.freeze(Object.defineProperty({__proto__:null,loadLazyIframes:function(e){e.querySelectorAll("iframe[data-lazy-src]").forEach((e=>{!e.src&&e.dataset&&e.dataset.lazySrc&&(e.src=e.dataset.lazySrc)}))},runScripts:function(e){e.querySelectorAll("script").forEach((function(e){const t=e.getAttribute("type");t&&!I.includes(t)||function(e){const t=document.createElement("script");t.type="text/javascript",e.src?t.src=e.src:t.textContent=e.innerText,document.head.appendChild(t),e.parentNode.removeChild(e)}(e)}))}},Symbol.toStringTag,{value:"Module"}));class k{constructor(e){if(this.faviconLinkElements=[],this.processedFaviconData=[],this.options={faviconEl:e.faviconEl,dotSize:e.dotSize??"small",dotColor:e.dotColor??"#ff0000"},null===e.faviconEl)throw new Error("The favicon elements you have specified are not valid.");e.faviconEl instanceof NodeList?this.faviconLinkElements=Array.from(e.faviconEl):e.faviconEl instanceof HTMLLinkElement&&(this.faviconLinkElements=[e.faviconEl]),this.faviconLinkElements.forEach((e=>{this.processedFaviconData.push({originalFaviconHref:e.href,faviconElement:e})}))}getFaviconImages(){if(this.hasAlreadyLoadedImages())return new Promise((e=>{e(this.processedFaviconData)}));const e=this.processedFaviconData.map((e=>new Promise(((t,a)=>{const o=new Image;o.src=e.originalFaviconHref,o.crossOrigin="anonymous",o.onload=()=>{e.imgElement=o,t(e)},o.onerror=()=>a({reason:`The image url: ${e.originalFaviconHref} could not be loaded.`})}))));return Promise.all(e)}hasAlreadyLoadedImages(){return this.processedFaviconData.every((e=>e.imgElement instanceof HTMLImageElement))}getDotScaleDivider(){switch(this.options.dotSize){case"small":default:return 4.5;case"medium":return 3;case"large":return 2.5}}show(){this.getFaviconImages().then((e=>{e.forEach((e=>{if(e.imgElement){const t=document.createElement("canvas"),a=t.getContext("2d"),o=e.imgElement.naturalWidth,i=e.imgElement.naturalHeight;if(t.width=o,t.height=i,a){a.drawImage(e.imgElement,0,0,o,i);const n=this.getDotScaleDivider();a.beginPath(),a.arc(t.width-o/n,i/n,i/n,0,2*Math.PI),a.fillStyle=this.options.dotColor,a.fill(),e.faviconElement.href=t.toDataURL("image/png")}}}))}))}hide(){this.getFaviconImages().then((e=>{e.forEach((e=>{e.faviconElement.href=e.originalFaviconHref}))}))}}let T=!0,H=null;const _=(null==(t=null==(e=window.vanilla.featureFlags.notifications)?void 0:e.title)?void 0:t.enabled)??!1;if(null==(o=null==(a=window.vanilla.featureFlags.notifications)?void 0:a.favicon)?void 0:o.enabled){const e=document.querySelectorAll("head link[rel=icon]");e.length>0&&(H=new k({faviconEl:e,dotColor:(null==(n=null==(i=window.vanilla.featureFlags.notifications)?void 0:i.favicon)?void 0:n.dotColor)??"#ff0000",dotSize:(null==(l=null==(r=window.vanilla.featureFlags.notifications)?void 0:r.favicon)?void 0:l.dotSize)??"small"}))}s.plugin(c),s.plugin(d),s.plugin(m),s.plugin(f),window.Alpine=s,window.utils={screenSizes:u,getCookieValue:p,setCookie:h,scripts:C,dates:M},E(w,(e=>e.tabNotifications.count),(e=>{T&&0===e?T=!1:(H&&(0===e?H.hide():H.show()),_&&function(e){const t=new RegExp(/^\(\d+\)/),a=document.title;t.test(a)&&e>0?document.title=a.replace(t,`(${e})`):t.test(a)&&0===e?document.title=a.replace(t,""):e>0&&(document.title=`(${e}) ${a}`)}(e))})),g(),v();