/*! For license information please see icecast-metadata-player-1.17.2.main.min.js.LICENSE.txt */ /*! * Copyright 2021-2023 Ethan Halsall * https://github.com/eshaz/icecast-metadata-js * * This file is part of icecast-metadata-player. * * icecast-metadata-player free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * icecast-metadata-player distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see */ var IcecastMetadataPlayer;(()=>{"use strict";var t,s,i,e={273:(t,s,i)=>{i.d(s,{Ee:()=>he,IA:()=>re,aT:()=>ne,ZP:()=>ee,Fs:()=>ae,h$:()=>oe,j9:()=>le,lk:()=>ce,im:()=>ue});const e=Symbol,h=(()=>{const t="left",s="center",i="right";return["","front ","side ","rear "].map((e=>[[t,i],[t,i,s],[t,s,i],[s,t,i],[s]].flatMap((t=>t.map((t=>e+t)).join(", ")))))})(),r="LFE",n="monophonic (mono)",a="stereo",o="surround",c=(t,...s)=>`${[n,a,`linear ${o}`,"quadraphonic",`5.0 ${o}`,`5.1 ${o}`,`6.1 ${o}`,`7.1 ${o}`][t-1]} (${s.join(", ")})`,u=[n,c(2,h[0][0]),c(3,h[0][2]),c(4,h[1][0],h[3][0]),c(5,h[1][2],h[3][0]),c(6,h[1][2],h[3][0],r),c(7,h[1][2],h[2][0],h[3][4],r),c(8,h[1][2],h[2][0],h[3][0],r)],l=48e3,d=44100,y=32e3,f=24e3,m=22050,p=16e3,w=8e3,g="absoluteGranulePosition",b="bandwidth",S="bitDepth",q="bitrate",M=q+"Maximum",A=q+"Minimum",v=q+"Nominal",P="buffer",E=P+"Fullness",T="codec",_=T+"Frames",C="coupledStreamCount",I="crc",R=I+"16",x=I+"32",$="data",k="description",O="duration",D="emphasis",B="hasOpusPadding",F="header",L="isContinuedPacket",U="isCopyrighted",N="isFirstPage",j="isHome",W="isLastPage",G="isOriginal",H="isPrivate",Q="isVbr",V="layer",Y="length",z="mode",K=z+"Extension",Z="mpeg",J=Z+"Version",X="numberAACFrames",tt="outputGain",st="preSkip",it="profile",et=e(),ht="protection",rt="rawData",nt="segments",at="subarray",ot="version",ct="vorbis",ut=ct+"Comments",lt=ct+"Setup",dt="block",yt=dt+"ingStrategy",ft=e(),mt=dt+"Size",pt=dt+"size0",wt=dt+"size1",gt=e(),bt="channel",St=bt+"MappingFamily",qt=bt+"MappingTable",Mt=bt+"Mode",At=e(),vt=bt+"s",Pt="copyright",Et=Pt+"Id",Tt=Pt+"IdStart",_t="frame",Ct=_t+"Count",It=_t+"Length",Rt="Number",xt=_t+Rt,$t=_t+"Padding",kt=_t+"Size",Ot="Rate",Dt="inputSample"+Ot,Bt="page",Ft=Bt+"Checksum",Lt=e(),Ut=Bt+"SegmentTable",Nt=Bt+"Sequence"+Rt,jt="sample",Wt=jt+Rt,Gt=jt+Ot,Ht=e(),Qt=jt+"s",Vt="stream",Yt=Vt+"Count",zt=Vt+"Info",Kt=Vt+"Serial"+Rt,Zt=Vt+"StructureVersion",Jt="total",Xt=Jt+"BytesOut",ts=Jt+"Duration",ss=Jt+"Samples",is=e(),es=e(),hs=e(),rs=e(),ns=e(),as=e(),os=e(),cs=e(),us=e(),ls=e(),ds=e(),ys=e(),fs=e(),ms=e(),ps=e(),ws=e(),gs=e(),bs=e(),Ss=Uint8Array,qs=DataView,Ms="reserved",As="bad",vs="free",Ps="none",Es="16bit CRC",Ts=(t,s,i)=>{for(let e=0;e0;t--)h=i(h);t[e]=h}return t},_s=Ts(new Ss(256),(t=>t),(t=>128&t?7^t<<1:t<<1)),Cs=[Ts(new Uint16Array(256),(t=>t<<8),(t=>t<<1^(32768&t?32773:0)))],Is=[Ts(new Uint32Array(256),(t=>t),(t=>t>>>1^3988292384*(1&t)))];for(let t=0;t<15;t++){Cs.push(new Uint16Array(256)),Is.push(new Uint32Array(256));for(let s=0;s<=255;s++)Cs[t+1][s]=Cs[0][Cs[t][s]>>>8]^Cs[t][s]<<8,Is[t+1][s]=Is[t][s]>>>8^Is[0][255&Is[t][s]]}const Rs=t=>{const s=t[Y],i=s-16;let e=0,h=0;for(;h<=i;)e=Is[15][255&(t[h++]^e)]^Is[14][255&(t[h++]^e>>>8)]^Is[13][255&(t[h++]^e>>>16)]^Is[12][t[h++]^e>>>24]^Is[11][t[h++]]^Is[10][t[h++]]^Is[9][t[h++]]^Is[8][t[h++]]^Is[7][t[h++]]^Is[6][t[h++]]^Is[5][t[h++]]^Is[4][t[h++]]^Is[3][t[h++]]^Is[2][t[h++]]^Is[1][t[h++]]^Is[0][t[h++]];for(;h!==s;)e=Is[0][255&(e^t[h++])]^e>>>8;return-1^e},xs=(...t)=>{const s=new Ss(t.reduce(((t,s)=>t+s[Y]),0));return t.reduce(((t,i)=>(s.set(i,t),t+i[Y])),0),s},$s=t=>String.fromCharCode(...t),ks=[0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15],Os=t=>ks[15&t]<<4|ks[t>>4];class Ds{constructor(t){this.t=t,this.i=8*t[Y]}set position(t){this.i=t}get position(){return this.i}read(t){const s=Math.floor(this.i/8),i=this.i%8;this.i-=t;return(Os(this.t[s-1])<<8)+Os(this.t[s])>>7-i&255}}class Bs{constructor(t,s){this.h=t,this.S=s,this[ps]()}[ws](){this.q=!0}[ps](){this.M=new Map,this.A=new WeakMap,this.v=!1,this.P=!1,this.T=null,this.q=!1}[ms](t,s){if(this.S){this.T!==t&&(this.T=t,this.P=!0);const i=this.A.get(this.M.get(this._));this.P&&i&&this.S({bitrate:t,...i},s),this.P=!1}}[us](t){const s=this.M.get(t);return s&&this.C(t),s}[ls](t,s,i){this.q&&(this.v||(this.h({...s}),this.v=!0),this.C(t),this.M.set(t,s),this.A.set(s,i))}C(t){this.S&&t!==this._&&(this.P=!0,this._=t)}}const Fs=new WeakMap,Ls=new WeakMap;class Us{constructor(t,s){this.I=t,this.M=s}*[os](){let t;for(;;){if(t=yield*this.Frame[ds](this.I,this.M,0),t)return t;this.I[es](1)}}*[cs](t){let s=yield*this[os]();const i=Ls.get(s)[Y];if(t||this.I.R||(yield*this.Header[us](this.I,this.M,i)))return this.M[ws](),this.I[es](i),this.I[rs](s),s;this.I[ns](`Missing ${_t} at ${i} bytes from current position.`,`Dropping current ${_t} and trying again.`),this.M[ps](),this.I[es](1)}}class Ns{constructor(t,s){Ls.set(this,{[F]:t}),this[$]=s}}class js extends Ns{static*[ds](t,s,i,e,h){const r=yield*t[us](i,e,h);if(r){const t=Fs.get(r)[It],e=Fs.get(r)[Qt];return new s(r,(yield*i[is](t,h))[at](0,t),e)}return null}constructor(t,s,i){super(t,s),this[F]=t,this[Qt]=i,this[O]=i/t[Gt]*1e3,this[xt]=null,this[Xt]=null,this[ss]=null,this[ts]=null,Ls.get(this)[Y]=s[Y]}}const Ws="unsynchronizationFlag",Gs="extendedHeaderFlag",Hs="experimentalFlag",Qs="footerPresent";class Vs{static*getID3v2Header(t,s,i){const e={};let h=yield*t[is](3,i);if(73!==h[0]||68!==h[1]||51!==h[2])return null;if(h=yield*t[is](10,i),e[ot]=`id3v2.${h[3]}.${h[4]}`,15&h[5])return null;if(e[Ws]=!!(128&h[5]),e[Gs]=!!(64&h[5]),e[Hs]=!!(32&h[5]),e[Qs]=!!(16&h[5]),128&h[6]||128&h[7]||128&h[8]||128&h[9])return null;const r=h[6]<<21|h[7]<<14|h[8]<<7|h[9];return e[Y]=10+r,new Vs(e)}constructor(t){this[ot]=t[ot],this[Ws]=t[Ws],this[Gs]=t[Gs],this[Hs]=t[Hs],this[Qs]=t[Qs],this[Y]=t[Y]}}class Ys{constructor(t){Fs.set(this,t),this[S]=t[S],this[q]=null,this[vt]=t[vt],this[Mt]=t[Mt],this[Gt]=t[Gt]}}const zs={0:[vs,vs,vs,vs,vs],16:[32,32,32,32,8],240:[As,As,As,As,As]},Ks=(t,s,i)=>8*((t+i)%s+s)*(1<<(t+i)/s)-8*s*(s/8|0);for(let t=2;t<15;t++)zs[t<<4]=[32*t,Ks(t,4,0),Ks(t,4,-1),Ks(t,8,4),Ks(t,8,0)];const Zs="bands ",Js=" to 31",Xs={0:Zs+4+Js,16:Zs+8+Js,32:Zs+12+Js,48:Zs+16+Js},ti="bitrateIndex",si="v2",ii="v1",ei="Intensity stereo ",hi=", MS stereo ",ri="on",ni="off",ai={0:{[k]:Ms},2:{[k]:"Layer III",[$t]:1,[K]:{0:ei+ni+hi+ni,16:ei+ri+hi+ni,32:ei+ni+hi+ri,48:ei+ri+hi+ri},[ii]:{[ti]:2,[Qt]:1152},[si]:{[ti]:4,[Qt]:576}},4:{[k]:"Layer II",[$t]:1,[K]:Xs,[Qt]:1152,[ii]:{[ti]:1},[si]:{[ti]:4}},6:{[k]:"Layer I",[$t]:4,[K]:Xs,[Qt]:384,[ii]:{[ti]:0},[si]:{[ti]:3}}},oi="MPEG Version ",ci="ISO/IEC ",ui={0:{[k]:`${oi}2.5 (later extension of MPEG 2)`,[V]:si,[Gt]:{0:11025,4:12e3,8:w,12:Ms}},8:{[k]:Ms},16:{[k]:`${oi}2 (${ci}13818-3)`,[V]:si,[Gt]:{0:m,4:f,8:p,12:Ms}},24:{[k]:`${oi}1 (${ci}11172-3)`,[V]:ii,[Gt]:{0:d,4:l,8:y,12:Ms}},length:Y},li={0:Es,1:Ps},di={0:Ps,1:"50/15 ms",2:Ms,3:"CCIT J.17"},yi={0:{[vt]:2,[k]:a},64:{[vt]:2,[k]:"joint "+a},128:{[vt]:2,[k]:"dual channel"},192:{[vt]:1,[k]:n}};class fi extends Ys{static*[us](t,s,i){const e={},h=yield*Vs.getID3v2Header(t,s,i);h&&(yield*t[is](h[Y],i),t[es](h[Y]));const r=yield*t[is](4,i),n=$s(r[at](0,4)),a=s[us](n);if(a)return new fi(a);if(255!==r[0]||r[1]<224)return null;const o=ui[24&r[1]];if(o[k]===Ms)return null;const c=6&r[1];if(ai[c][k]===Ms)return null;const u={...ai[c],...ai[c][o[V]]};if(e[J]=o[k],e[V]=u[k],e[Qt]=u[Qt],e[ht]=li[1&r[1]],e[Y]=4,e[q]=zs[240&r[2]][u[ti]],e[q]===As)return null;if(e[Gt]=o[Gt][12&r[2]],e[Gt]===Ms)return null;if(e[$t]=2&r[2]&&u[$t],e[H]=!!(1&r[2]),e[It]=Math.floor(125*e[q]*e[Qt]/e[Gt]+e[$t]),!e[It])return null;const l=192&r[3];if(e[Mt]=yi[l][k],e[vt]=yi[l][vt],e[K]=u[K][48&r[3]],e[U]=!!(8&r[3]),e[G]=!!(4&r[3]),e[D]=di[3&r[3]],e[D]===Ms)return null;e[S]=16;{const{length:t,frameLength:i,samples:h,...r}=e;s[ls](n,e,r)}return new fi(e)}constructor(t){super(t),this[q]=t[q],this[D]=t[D],this[$t]=t[$t],this[U]=t[U],this[G]=t[G],this[H]=t[H],this[V]=t[V],this[K]=t[K],this[J]=t[J],this[ht]=t[ht]}}class mi extends js{static*[ds](t,s,i){return yield*super[ds](fi,mi,t,s,i)}constructor(t,s,i){super(t,s,i)}}class pi extends Us{constructor(t,s,i){super(t,s),this.Frame=mi,this.Header=fi,i(this[T])}get[T](){return Z}*[ys](){return yield*this[cs]()}}const wi={0:"MPEG-4",8:"MPEG-2"},gi={0:"valid",2:As,4:As,6:As},bi={0:Es,1:Ps},Si={0:"AAC Main",64:"AAC LC (Low Complexity)",128:"AAC SSR (Scalable Sample Rate)",192:"AAC LTP (Long Term Prediction)"},qi={0:96e3,4:88200,8:64e3,12:l,16:d,20:y,24:f,28:m,32:p,36:12e3,40:11025,44:w,48:7350,52:Ms,56:Ms,60:"frequency is written explicitly"},Mi={0:{[vt]:0,[k]:"Defined in AOT Specific Config"},64:{[vt]:1,[k]:n},128:{[vt]:2,[k]:c(2,h[0][0])},192:{[vt]:3,[k]:c(3,h[1][3])},256:{[vt]:4,[k]:c(4,h[1][3],h[3][4])},320:{[vt]:5,[k]:c(5,h[1][3],h[3][0])},384:{[vt]:6,[k]:c(6,h[1][3],h[3][0],r)},448:{[vt]:8,[k]:c(8,h[1][3],h[2][0],h[3][0],r)}};class Ai extends Ys{static*[us](t,s,i){const e={},h=yield*t[is](7,i),r=$s([h[0],h[1],h[2],252&h[3]|3&h[6]]),n=s[us](r);if(n)Object.assign(e,n);else{if(255!==h[0]||h[1]<240)return null;if(e[J]=wi[8&h[1]],e[V]=gi[6&h[1]],e[V]===As)return null;const t=1&h[1];e[ht]=bi[t],e[Y]=t?7:9,e[et]=192&h[2],e[Ht]=60&h[2];const i=2&h[2];if(e[it]=Si[e[et]],e[Gt]=qi[e[Ht]],e[Gt]===Ms)return null;e[H]=!!i,e[At]=448&(h[2]<<8|h[3]),e[Mt]=Mi[e[At]][k],e[vt]=Mi[e[At]][vt],e[G]=!!(32&h[3]),e[j]=!!(8&h[3]),e[Et]=!!(8&h[3]),e[Tt]=!!(4&h[3]),e[S]=16,e[Qt]=1024,e[X]=3&h[6];{const{length:t,channelModeBits:i,profileBits:h,sampleRateBits:n,frameLength:a,samples:o,numberAACFrames:c,...u}=e;s[ls](r,e,u)}}if(e[It]=8191&(h[3]<<11|h[4]<<3|h[5]>>5),!e[It])return null;const a=2047&(h[5]<<6|h[6]>>2);return e[E]=2047===a?"VBR":a,new Ai(e)}constructor(t){super(t),this[Et]=t[Et],this[Tt]=t[Tt],this[E]=t[E],this[j]=t[j],this[G]=t[G],this[H]=t[H],this[V]=t[V],this[Y]=t[Y],this[J]=t[J],this[X]=t[X],this[it]=t[it],this[ht]=t[ht]}get audioSpecificConfig(){const t=Fs.get(this),s=t[et]+64<<5|t[Ht]<<5|t[At]>>3,i=new Ss(2);return new qs(i[P]).setUint16(0,s,!1),i}}class vi extends js{static*[ds](t,s,i){return yield*super[ds](Ai,vi,t,s,i)}constructor(t,s,i){super(t,s,i)}}class Pi extends Us{constructor(t,s,i){super(t,s),this.Frame=vi,this.Header=Ai,i(this[T])}get[T](){return"aac"}*[ys](){return yield*this[cs]()}}class Ei extends js{static $(t){return(t[t[Y]-2]<<8)+t[t[Y]-1]}static[bs](t){const s=Ei.$(t),i=(t=>{const s=t[Y],i=s-16;let e=0,h=0;for(;h<=i;)e^=t[h++]<<8|t[h++],e=Cs[15][e>>8]^Cs[14][255&e]^Cs[13][t[h++]]^Cs[12][t[h++]]^Cs[11][t[h++]]^Cs[10][t[h++]]^Cs[9][t[h++]]^Cs[8][t[h++]]^Cs[7][t[h++]]^Cs[6][t[h++]]^Cs[5][t[h++]]^Cs[4][t[h++]]^Cs[3][t[h++]]^Cs[2][t[h++]]^Cs[1][t[h++]]^Cs[0][t[h++]];for(;h!==s;)e=(255&e)<<8^Cs[0][e>>8^t[h++]];return e})(t[at](0,-2));return s===i}constructor(t,s,i){s[zt]=i,s[R]=Ei.$(t),super(s,t,Fs.get(s)[Qt])}}const Ti="get from STREAMINFO metadata block",_i={0:"Fixed",1:"Variable"},Ci={0:Ms,16:192};for(let t=2;t<16;t++)Ci[t<<4]=t<6?576*2**(t-2):2**t;const Ii={0:Ti,1:88200,2:176400,3:192e3,4:w,5:p,6:m,7:f,8:y,9:d,10:l,11:96e3,15:As},Ri={0:{[vt]:1,[k]:n},16:{[vt]:2,[k]:c(2,h[0][0])},32:{[vt]:3,[k]:c(3,h[0][1])},48:{[vt]:4,[k]:c(4,h[1][0],h[3][0])},64:{[vt]:5,[k]:c(5,h[1][1],h[3][0])},80:{[vt]:6,[k]:c(6,h[1][1],r,h[3][0])},96:{[vt]:7,[k]:c(7,h[1][1],r,h[3][4],h[2][0])},112:{[vt]:8,[k]:c(8,h[1][1],r,h[3][0],h[2][0])},128:{[vt]:2,[k]:`${a} (left, diff)`},144:{[vt]:2,[k]:`${a} (diff, right)`},160:{[vt]:2,[k]:`${a} (avg, diff)`},176:Ms,192:Ms,208:Ms,224:Ms,240:Ms},xi={0:Ti,2:8,4:12,6:Ms,8:16,10:20,12:24,14:Ms};class $i extends Ys{static k(t){if(t[0]>254)return null;if(t[0]<128)return{value:t[0],length:1};let s=1;for(let i=64;i&t[0];i>>=1)s++;let i=s-1,e=0,h=0;for(;i>0;h+=6,i--){if(128!=(192&t[i]))return null;e|=(63&t[i])<>s)<{let s=0;const i=t[Y];for(let e=0;e!==i;e++)s=_s[s^t[e]];return s})(e[at](0,h[Y]-1)))return null;if(!n){const{blockingStrategyBits:t,frameNumber:i,sampleNumber:e,samples:n,sampleRateBits:a,blockSizeBits:o,crc:c,length:u,...l}=h;s[ls](r,h,l)}return new $i(h)}constructor(t){super(t),this[R]=null,this[yt]=t[yt],this[mt]=t[mt],this[xt]=t[xt],this[Wt]=t[Wt],this[zt]=null}}class ki extends Us{constructor(t,s,i){super(t,s),this.Frame=Ei,this.Header=$i,i(this[T])}get[T](){return"flac"}*D(t){const s=yield*this.I[is](2,0),i=s[Y]-2;for(;t{const s=$i[gs](t,this.M);if(s)return new Ei(t,s,this.B);this.I[ns]("Failed to parse Ogg FLAC frame","Skipping invalid FLAC frame")})).filter((t=>!!t))),t}}class Oi{static*[us](t,s,i){const e={};let h=yield*t[is](28,i);if(79!==h[0]||103!==h[1]||103!==h[2]||83!==h[3])return null;e[Zt]=h[4];if(248&h[5])return null;e[W]=!!(4&h[5]),e[N]=!!(2&h[5]),e[L]=!!(1&h[5]);const r=new qs(Ss.from(h[at](0,28))[P]);try{e[g]=r.getBigInt64(6,!0)}catch{}e[Kt]=r.getInt32(14,!0),e[Nt]=r.getInt32(18,!0),e[Ft]=r.getInt32(22,!0);const n=h[26];e[Y]=n+27,h=yield*t[is](e[Y],i),e[It]=0,e[Ut]=[],e[Lt]=Ss.from(h[at](27,e[Y]));for(let t=0,s=0;t{const s=Yi[gs](this.L,t,this.M);if(s)return new Bi(t,s);this.I[as]("Failed to parse Ogg Opus Header","Not a valid Ogg Opus file")}))),t}}class Ki extends js{constructor(t,s,i){super(s,t,i)}}const Zi={};for(let t=0;t<8;t++)Zi[t+6]=2**(6+t);class Ji extends Ys{static[gs](t,s,i,e){if(t[Y]<30)throw new Error("Out of data while inside an Ogg Page");const h=$s(t[at](0,30)),r=s[us](h);if(r)return new Ji(r);const n={[Y]:30};if("vorbis"!==h.substr(0,7))return null;n[$]=Ss.from(t[at](0,30));const a=new qs(n[$][P]);if(n[ot]=a.getUint32(7,!0),0!==n[ot])return null;if(n[vt]=t[11],n[Mt]=u[n[vt]-1]||"application defined",n[Gt]=a.getUint32(12,!0),n[M]=a.getInt32(16,!0),n[v]=a.getInt32(20,!0),n[A]=a.getInt32(24,!0),n[wt]=Zi[(240&t[28])>>4],n[pt]=Zi[15&t[28]],n[pt]>n[wt])return null;if(1!==t[29])return null;n[S]=32,n[lt]=e,n[ut]=i;{const{length:t,data:i,version:e,vorbisSetup:r,vorbisComments:a,...o}=n;s[ls](h,n,o)}return new Ji(n)}constructor(t){super(t),this[M]=t[M],this[A]=t[A],this[v]=t[v],this[pt]=t[pt],this[wt]=t[wt],this[$]=t[$],this[ut]=t[ut],this[lt]=t[lt]}}class Xi extends Us{constructor(t,s,i){super(t,s),this.Frame=Ki,i(this[T]),this.L=null,this.U=!1,this.N=null}get[T](){return ct}[fs](t){t[_]=[];for(const s of Ls.get(t)[nt])if(1===s[0])this.M[ws](),this.L=t[$],this.U=!1;else if(3===s[0])this.W=s;else if(5===s[0])this.G=s,this.H=this.V(s),this.U=!0;else if(this.U){const i=Ji[gs](this.L,this.M,this.W,this.G);i?t[_].push(new Ki(s,i,this.Y(s,i))):this.I[logError]("Failed to parse Ogg Vorbis Header","Not a valid Ogg Vorbis file")}return t}Y(t,s){const i=this.H.blockFlags[t[0]>>1&this.H.mask]?s[wt]:s[pt],e=null===this.N?0:(this.N+i)/4;return this.N=i,e}V(t){const s=new Ds(t),i={count:0,blockFlags:[]};for(;1!=(1&s.read(1)););let e;for(;i.count<64&&s.position>0;){Os(s.read(8));let t=0;for(;0===s.read(8)&&t++<3;);if(4!==t){1+((126&Os(e))>>1)!==i.count&&this.I[ns]("vorbis derived mode count did not match actual mode count");break}e=s.read(7),i.blockFlags.unshift(1&e),s.position+=6,i.count++}return i.mask=(1<1&&t[Nt]>1&&this.I[ns]("Unexpected gap in Ogg Page Sequence Number.",`Expected: ${this.ht+1}, Got: ${t[Nt]}`),this.ht=t[Nt]}rt(t){null===this.X&&(this.ht=t[Nt],this.X=this.it(t)),this.et(t);const s=Ls.get(t),i=Fs.get(s[F]);let e=0;if(s[nt]=i[Ut].map((s=>t[$][at](e,e+=s))),this.Z[Y]&&(s[nt][0]=xs(this.Z,s[nt][0]),this.Z=new Ss),255===i[Lt][i[Lt][Y]-1]&&(this.Z=xs(this.Z,s[nt].pop())),this.X){const s=this.st[fs](t);return this.I[rs](s),s}return t}}class se extends Us{constructor(t,s,i){super(t,s),this.K=i,this.Frame=Di,this.Header=Oi,this.nt=new Map,this.ot=null}get[T](){const t=this.nt.get(this.ot);return t?t.codec:""}*[ys](){const t=yield*this[cs](!0);this.ot=t[Kt];let s=this.nt.get(this.ot);return s||(s=new te(this.I,this.M,this.K),this.nt.set(this.ot,s)),t[W]&&this.nt.delete(this.ot),s.rt(t)}}const ie=()=>{};const ee=class{constructor(t,{onCodec:s,onCodecHeader:i,onCodecUpdate:e,enableLogging:h=!1,enableFrameCRC32:r=!0}={}){this.ct=t,this.K=s||ie,this.h=i||ie,this.S=e,this.ut=h,this.lt=r?Rs:ie,this[ps]()}get[T](){return this.st?this.st[T]:""}[ps](){this.M=new Bs(this.h,this.S),this.dt=this.yt(),this.dt.next()}*flush(){this.R=!0;for(let t=this.dt.next();t.value;t=this.dt.next())yield t.value;this.R=!1,this[ps]()}*parseChunk(t){for(let s=this.dt.next(t);s.value;s=this.dt.next())yield s.value}parseAll(t){return[...this.parseChunk(t),...this.flush()]}*yt(){if(this.ct.match(/aac/))this.st=new Pi(this,this.M,this.K);else if(this.ct.match(/mpeg/))this.st=new pi(this,this.M,this.K);else if(this.ct.match(/flac/))this.st=new ki(this,this.M,this.K);else{if(!this.ct.match(/ogg/))throw new Error(`Unsupported Codec ${mimeType}`);this.st=new se(this,this.M,this.K)}for(this.ft=0,this.wt=0,this.gt=0,this.bt=0,this.St=0,this.qt=void 0,this.Mt=new Uint8Array(0);;){const t=yield*this.st[ys]();t&&(yield t)}}*[is](t=0,s=0){let i;for(;this.Mt[Y]<=t+s;){if(i=yield,this.R)return this.Mt[at](s);i&&(this.gt+=i[Y],this.Mt=xs(this.Mt,i))}return this.Mt[at](s)}[es](t){this.wt+=t,this.Mt=this.Mt[at](t)}[hs](t){this.qt=t[F][Gt],t[F][q]=t[O]>0?8*Math.round(t[$][Y]/t[O]):0,t[xt]=this.ft++,t[Xt]=this.bt,t[ss]=this.St,t[ts]=this.St/this.qt*1e3,t[x]=this.lt(t[$]),this.M[ms](t[F][q],t[ts]),this.bt+=t[$][Y],this.St+=t[Qt]}[rs](t){t[_]?(t[_].forEach((s=>{t[O]+=s[O],t[Qt]+=s[Qt],this[hs](s)})),t[ss]=this.St,t[ts]=this.St/this.qt*1e3||0,t[Xt]=this.bt):this[hs](t)}At(t,s){if(this.ut){const i=[`${T}: ${this[T]}`,`inputMimeType: ${this.ct}`,`readPosition: ${this.wt}`,`totalBytesIn: ${this.gt}`,`${Xt}: ${this.bt}`],e=Math.max(...i.map((t=>t[Y])));s.push(`--stats--${"-".repeat(e-9)}`,...i,"-".repeat(e)),t("codec-parser",s.reduce(((t,s)=>t+"\n "+s),""))}}[ns](...t){this.At(console.warn,t)}[as](...t){this.At(console.error,t)}},he=g,re=_,ne=$,ae=F,oe=W,ce=ut,ue=lt,le=Qt}},h={};function r(t){var s=h[t];if(void 0!==s)return s.exports;var i=h[t]={exports:{}};return e[t](i,i.exports,r),i.exports}r.m=e,t=[],r.O=(s,i,e,h)=>{if(!i){var n=1/0;for(u=0;u=h)&&Object.keys(r.O).every((t=>r.O[t](i[o])))?i.splice(o--,1):(a=!1,h0&&t[u-1][2]>h;u--)t[u]=t[u-1];t[u]=[i,e,h]},r.F={},r.E=t=>{Object.keys(r.F).map((s=>{r.F[s](t)}))},r.d=(t,s)=>{for(var i in s)r.o(s,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:s[i]})},r.f={},r.e=t=>Promise.all(Object.keys(r.f).reduce(((s,i)=>(r.f[i](t,s),s)),[])),r.u=t=>968===t?"icecast-metadata-player-1.17.2.common.min.js":"icecast-metadata-player-1.17.2."+{122:"vorbis",388:"mpeg",390:"opus",496:"synaudio",756:"mediasource",983:"flac"}[t]+".min.js",r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r.o=(t,s)=>Object.prototype.hasOwnProperty.call(t,s),s={},i="IcecastMetadataPlayer:",r.l=(t,e,h,n)=>{if(s[t])s[t].push(e);else{var a,o;if(void 0!==h)for(var c=document.getElementsByTagName("script"),u=0;u{a.onerror=a.onload=null,clearTimeout(y);var h=s[t];if(delete s[t],a.parentNode&&a.parentNode.removeChild(a),h&&h.forEach((t=>t(e))),i)return i(e)},y=setTimeout(d.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=d.bind(null,a.onerror),a.onload=d.bind(null,a.onload),o&&document.head.appendChild(a)}},r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"vt",{value:!0})},(()=>{var t;r.g.importScripts&&(t=r.g.location+"");var s=r.g.document;if(!t&&s&&(s.currentScript&&(t=s.currentScript.src),!t)){var i=s.getElementsByTagName("script");if(i.length)for(var e=i.length-1;e>-1&&!t;)t=i[e--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r.p=t})(),(()=>{var t={179:0};r.f.j=(s,i)=>{var e=r.o(t,s)?t[s]:void 0;if(0!==e)if(e)i.push(e[2]);else{var h=new Promise(((i,h)=>e=t[s]=[i,h]));i.push(e[2]=h);var n=r.p+r.u(s),a=new Error;r.l(n,(i=>{if(r.o(t,s)&&(0!==(e=t[s])&&(t[s]=void 0),e)){var h=i&&("load"===i.type?"missing":i.type),n=i&&i.target&&i.target.src;a.message="Loading chunk "+s+" failed.\n("+h+": "+n+")",a.name="ChunkLoadError",a.type=h,a.request=n,e[1](a)}}),"chunk-"+s,s)}},r.F.j=s=>{if(!r.o(t,s)||void 0===t[s]){t[s]=null;var i=document.createElement("link");r.nc&&i.setAttribute("nonce",r.nc),i.rel="prefetch",i.as="script",i.href=r.p+r.u(s),document.head.appendChild(i)}},r.O.j=s=>0===t[s];var s=(s,i)=>{var e,h,[n,a,o]=i,c=0;if(n.some((s=>0!==t[s]))){for(e in a)r.o(a,e)&&(r.m[e]=a[e]);if(o)var u=o(r)}for(s&&s(i);c{r.E(496),r.E(756)}),5);var n={};(()=>{r.d(n,{default:()=>gt});const t=()=>{},s=new WeakMap,i={LOADING:"loading",PLAYING:"playing",STOPPING:"stopping",STOPPED:"stopped",RETRYING:"retrying",SWITCHING:"switching"},e={BUFFER:"buffer",PLAY:"play",PLAY_READY:"playready",LOAD:"load",STREAM_START:"streamstart",STREAM:"stream",STREAM_END:"streamend",METADATA:"metadata",METADATA_ENQUEUE:"metadataenqueue",CODEC_UPDATE:"codecupdate",STOP:"stop",RETRY:"retry",RETRY_TIMEOUT:"retrytimeout",SWITCH:"switch",WARN:"warn",ERROR:"error",PLAYBACK_ERROR:"playbackerror"},h=Symbol(),a=Symbol(),o=Symbol(),c=Symbol(),u=Symbol(),l=Symbol(),d=Symbol(),y=Symbol(),f=Symbol(),m=Symbol(),p=Symbol(),w=Symbol(),g=Symbol(),b=Symbol(),S=Symbol(),q=Symbol(),M=Symbol(),A=Symbol(),v=Symbol(),P=Symbol(),E=Symbol(),T=Symbol(),_=Symbol(),C=Symbol(),I=Symbol(),R=Symbol(),x=Symbol(),$=Symbol("synced"),k=Symbol("syncing"),O=Symbol("pcm_synced"),D=Symbol("not_synced"),B=t=>{const s=new Uint8Array(t.reduce(((t,s)=>t+s.length),0));return t.reduce(((t,i)=>(s.set(i,t),t+i.length)),0),s};class F{constructor(){this.Pt=[]}hasEventListener(t,s){return this.Pt.some((i=>i.type===t&&i.listener===s))}addEventListener(t,s,i={}){return this.hasEventListener(t,s)||this.Pt.push({type:t,listener:s,options:i}),this}removeEventListener(t,s){const i=this.Pt.findIndex((i=>i.type===t&&i.listener===s));return i>=0&&this.Pt.splice(i,1),this}removeEventListeners(){return this.Pt=[],this}dispatchEvent(t){return this.Pt.filter((s=>s.type===t.type)).forEach((s=>{const{type:i,listener:e,options:{once:h}}=s;e.call(this,t),!0===h&&this.removeEventListener(i,e)})),this}}class L{constructor(){this.Et=0,this.Tt=0,this._t=0,this.Ct=0,this.It=0,this.Rt=0,this.xt=0}get stats(){return{totalBytesRead:this.Et,streamBytesRead:this.Tt,metadataLengthBytesRead:this._t,metadataBytesRead:this.Ct,currentBytesRemaining:this.It,currentStreamBytesRemaining:this.Rt,currentMetadataBytesRemaining:this.xt}}set currentStreamBytesRemaining(t){this.Rt+=t}set currentMetadataBytesRemaining(t){this.xt=t}addBytes(t){this.Et+=t,this.It-=t}addStreamBytes(t){this.Tt+=t,this.Rt-=t}addMetadataLengthBytes(t){this._t+=t}addMetadataBytes(t){this.Ct+=t,this.xt-=t}addCurrentBytesRemaining(t){this.It+=t}}const U=()=>{};class N{constructor(t){this.$t=0,this.kt=0,this.Ot=new Uint8Array(0),this.Dt=[],this.Bt=0,this.Ft=new L,this.Lt=t.onStream||U,this.Ut=t.onMetadata||U,this.Nt=t.onMetadataFailed||U,this.jt=t.onError||U,this.ut=t.enableLogging||!1,this.Wt=Promise.resolve(),this.Gt=Promise.resolve(),this.dt=this.Ht(),this.dt.next()}*Ht(){for(this.$t=1/0;;)this.Qt(yield*this.Vt()),yield*this.Yt()}static zt(...t){const s=t.reduce(((t,s)=>t+s.length),0);return this.Kt(t,s)}static Kt(t,s){const i=new Uint8Array(s);return t.reduce(((t,s)=>(i.set(s,t),t+s.length)),0),i}*iterator(t){for(let s=this.dt.next(t);s.value;s=this.dt.next())yield s.value}readAll(t){for(let s=this.dt.next(t);s.value;s=this.dt.next());}async*asyncIterator(t){for(let s=this.dt.next(t);s.value;s=this.dt.next())await this.Wt,await this.Gt,yield s.value}async asyncReadAll(t){for(let s=this.dt.next(t);s.value;s=this.dt.next())await this.Wt,await this.Gt}Zt(...t){this.ut&&console.warn("icecast-metadata-js",t.reduce(((t,s)=>t+"\n "+s),"")),this.jt(...t)}Qt(t){this.Dt.push(t),this.Bt+=t.length}*Yt(){if(this.Dt.length){const t=N.Kt(this.Dt,this.Bt);this.Dt=[],this.Bt=0,this.Ft.addStreamBytes(t.length);const s={stream:t,stats:this.Ft.stats};this.Wt=this.Lt(s),yield s}}*Jt(t){yield*this.Yt();const s={metadata:t,stats:this.Ft.stats};this.Gt=this.Ut(s),yield s}*Vt(t=0){for(this.kt===this.Ot.length&&(this.Ot=yield*this.Xt(),this.kt=0);this.Ot.length-this.kt[^\0]+?)='(?[^\0]*?)(;$|';|'$|$)/,i={};for(const e of t.match(new RegExp(s,"g"))||[]){const t=e.match(s);t&&(i[t.groups.key]=t.groups.val)}return i}get icyMetaInt(){return this.ss}*rs(){if(this.ss>0)return!0;if(!this.es)return!1;this.Zt("Passed in Icy-MetaInt is invalid. Attempting to detect ICY Metadata.","See https://github.com/eshaz/icecast-metadata-js for information on how to properly request ICY Metadata.");const t=[null,83,116,114,101,97,109,84,105,116,108,101,61],s=Date.now();let i=0;for(;s+this.es>Date.now();){this.Ot=N.zt(this.Ot,yield*this.Xt());t:for(;i65307)return this.Zt("This stream is not an Ogg stream. No Ogg metadata will be returned.","See https://github.com/eshaz/icecast-metadata-js for information on Ogg metadata."),this.Nt("ogg"),!1;const s=yield*this.Vt(27),i=yield*this.Vt(s[26]);return this.$t=i.reduce(((t,s)=>t+s),0),!0}*ys(){const t=yield*this.Vt(8);return yield*this.ns(),this.ps(/\x7fFLAC/,t.subarray(0,5))?{regex:/^[\x84|\x04]/,length:4}:this.ps(/OpusHead/,t.subarray(0,8))?{regex:/OpusTags/,length:8}:this.ps(/\x01vorbis/,t.subarray(0,7))?{regex:/\x03vorbis/,length:7}:void 0}*cs({regex:t,length:s}){this.ps(t,yield*this.Vt(s))&&(yield*this.Jt(yield*this.ws()))}*ns(){for(;this.$t;)yield*this.Vt()}*Vt(t){const s=yield*super.Vt(t);return this.Qt(s),s}*Xt(){const t=yield*super.Xt();return this.Ft.currentStreamBytesRemaining=t.length,t}*ws(){const t=this.fs(yield*this.Vt(4));this.Ft.addMetadataBytes(4);const s=this.ts.decode(yield*this.Vt(t));this.Ft.addMetadataBytes(t);const i=this.fs(yield*this.Vt(4));this.Ft.addMetadataBytes(4);const e=[];for(let t=0;t{const i=s.indexOf(61),e=String.fromCharCode(...s.subarray(0,i)).toUpperCase(),h=this.ts.decode(s.subarray(i+1));return t[e]=t[e]?`${t[e]}; ${h}`:h,t}),{VENDOR_STRING:s})}}class G{constructor(t){const{onStream:s,...i}=t;this.gs=new W(t),this.bs=new j(i)}get icyMetaInt(){return this.bs.icyMetaInt}*iterator(t){for(const s of this.bs.iterator(t))s.stream?yield*this.gs.iterator(s.stream):yield s}readAll(t){for(const s of this.bs.iterator(t))s.stream&&this.gs.readAll(s.stream)}async*asyncIterator(t){for await(const s of this.bs.asyncIterator(t))if(s.stream)for await(const t of this.gs.asyncIterator(s.stream))yield t;else yield s}async asyncReadAll(t){for await(const s of this.bs.iterator(t))s.stream&&await this.gs.asyncReadAll(s.stream)}}class H{constructor({metadataTypes:t=["icy"],...s}={}){const i=t.includes("icy"),e=t.includes("ogg");this.Ss=i&&e?new G(s):e?new W(s):i?new j(s):new N(s)}static parseIcyMetadata(t){return j.parseIcyMetadata(t)}get icyMetaInt(){return this.Ss.icyMetaInt}*iterator(t){yield*this.Ss.iterator(t)}readAll(t){this.Ss.readAll(t)}async*asyncIterator(t){return yield*this.Ss.asyncIterator(t)}async asyncReadAll(t){return this.Ss.asyncReadAll(t)}}const Q=()=>{};class V{constructor(t,{onStream:s=Q,...i}){let e;this.qs=new ReadableStream({async start(h){e=new H({icyMetaInt:parseInt(t.headers.get("Icy-MetaInt")),...i,onStream:async t=>(h.enqueue(t.stream),s(t))});for await(const s of V.asyncIterator(t.body))await e.asyncReadAll(s);h.close()}}),this.Ms=e}get icyMetaInt(){return this.Ms.icyMetaInt}get readableStream(){return this.qs}async startReading(){try{for await(const t of V.asyncIterator(this.qs));}catch(t){if("AbortError"!==t.name)throw t}}static asyncIterator(t){const s=t.getReader();return{[Symbol.asyncIterator]:()=>({next:()=>s.read()})}}}const Y=()=>{};class z{constructor({icyBr:t,onMetadataUpdate:s=Y,onMetadataEnqueue:i=Y,paused:e=!1}){this.As=t,this.vs=s,this.Ps=i,this.Es=e,this.Ts=e,this._s=!0,this.Cs=[],this.Is=[]}get metadataQueue(){return this.Is.map((({Rs:t,...s})=>s))}addMetadata({metadata:t,stats:s},i,e=0){const h={metadata:t,timestampOffset:i,timestamp:e+=s?this.getTimeByBytes(s.currentStreamPosition):0};this.Ts?this.Cs.push(h):this.xs(h)}getTimeByBytes(t){return this.As?t/(125*this.As):0}startQueue(t){this.Ts&&(this.Cs.forEach((s=>{void 0!==t&&(s.timestamp=t),(void 0===t||s.timestampOffset>=s.timestamp)&&this.xs(s)})),this.Cs=[],this.Ts=!1)}purgeMetadataQueue(){this.Is.forEach((t=>clearTimeout(t.Rs))),this.Is=[],this.Cs=[],this.Ts=this.Es,this._s=!0}xs(t){this.Is.push(t),this.Ps(t.metadata,t.timestampOffset,t.timestamp),this._s?(this.$s(),this._s=!1):t.Rs=setTimeout((()=>{this.$s()}),1e3*(t.timestampOffset-t.timestamp))}$s(){if(this.Is.length){const{metadata:t,timestampOffset:s,timestamp:i}=this.Is.shift();this.vs(t,s,i)}}}var K=r(273);let Z;const J=new Worker(URL.createObjectURL(new Blob(["self.onmessage = () => self.postMessage(!!self.Worker)"],{type:"text/javascript"})));J.onmessage=t=>{Z=t.data,J.terminate()},J.postMessage(null);class X{constructor(t,s){this.CRC_DURATION=3e5,this.PCM_DURATION=6e4,this.Ms=t,this.ks=s,this.initSync(),this.initQueue()}initSync(){clearTimeout(this.Os),this.Os=null,this.Ds=null,this.Bs=!0,this.Ls=[],this.Us=0,this.Ns=null,this.js=null,this.Ws=null}initQueue(){this.Gs=0,this.Hs=0,this.Qs=0,this.Vs=[],this.Ys=0,this.zs={},this.Ks=[],this.Zs=0}get buffered(){return this.Hs/this.Qs-this.ks.currentTime||0}add(t){const{crc32:s,duration:i,samples:e}=t;this.Hs+=e,this.Qs=t.header.sampleRate,this.Vs.push({crc32:s,duration:i}),this.Ys+=i;let h=this.zs[s];if(h||(h=[],this.zs[s]=h),h.push(this.Gs++),this.Ys>=this.CRC_DURATION){const{crc32:t,duration:s}=this.Vs.shift();this.Ys-=s;const i=this.zs[t];i.shift(),i.length||delete this.zs[t]}this.Ks.push(t),this.Zs+=i,this.Zs>=this.PCM_DURATION&&(this.Zs-=this.Ks.shift().duration)}addAll(t){t.forEach((t=>this.add(t)))}Js(t){for(const s of t)this.Us+=s.duration,this.Ls.push(s)}async sync(s){if(null===this.Os){const s=this.buffered;this.Xs=t,this.Os=setTimeout((()=>{this.Ds=`Buffer underrun after syncing for ${s.toFixed(2)} seconds.`,this.Xs(this.Ds)}),1e3*s)}return this.Js(s),new Promise((async(t,s)=>{let i;null!==this.Ds?s(this.Ds):this.Xs=s,this.Bs&&(i=this.ti()),i||(this.Bs=!1,i=await this.si()),i?t(i):s("Old and new request do not match.")})).catch((t=>{this.Ms.state!==i.STOPPING&&this.Ms.state!==i.STOPPED&&this.Ms[P](e.WARN,`Reconnected successfully after ${this.Ms.state}.`,"Unable to sync old and new request.",t);const s=this.Ls;return this.initSync(),this.initQueue(),[s,D]})).then((t=>([$,O].includes(t[1])&&this.initSync(),t)))}ti(){if(!this.Ls.length)return[[],k];const t=this.Ls[0].crc32,s=this.zs[t];let i,h,r;if(s){t:for(const t of s){r=t-(this.Gs-this.Vs.length);for(let t=0;tt+s),0)/1e3).toFixed(3)} seconds) of overlapping audio data in new request.`,"Synchronized old and new request."),[this.Ls.slice(t),$]}}}async si(){try{const t=1,s=16,i=(t,s)=>t/s;if(!this.Ns){let h;try{h=(await r.e(496).then(r.bind(r,420))).default}catch(t){return void this.Ms[P](e.WARN,"Failed to synchronize old and new stream","Missing `synaudio` dependency.")}const[n,a,o]=await this.ii(),c=o*t;if(a.samplesDecoded<=c)return[[],k];const u=new h({correlationSampleSize:c,initialGranularity:s});this.Ns=await(Z?u.syncWorkerConcurrent(n,a,Math.max(navigator.hardwareConcurrency-1,1)):u.syncWorker(n,a)),this.Ns.offsetFromEnd=i(n.samplesDecoded-this.Ns.sampleOffset,o)}const{correlation:h,offsetFromEnd:n}=this.Ns;let a=1e3*(this.buffered-n);if(-a>this.Us)return[[],k];const o=0;if(a<0){let t=0;for(let s=0;ta;t++)s-=this.Ls[t].duration;this.Ls=this.Ls.slice(t-o)}else for(let t=0;t{let i=t.length-1;for(let e=0;e0;i--)e+=t[i].duration;return this.Ms[u].decodeAudioData(B(t.slice(i).map((({data:t})=>t))).buffer)};[this.js,this.Ws]=await Promise.all([this.js?this.js:t(this.Ks,2e3*this.buffered),t(this.Ls,1/0)]);const s=t=>{const s={channelData:[],samplesDecoded:t.length};for(let i=0;i{this.syncState=D}}static parseMimeType(t){return t.match(/^(?:application\/|audio\/|)(?[a-zA-Z]+)(?:$|;[ ]*codecs=(?:\'|\")(?[a-zA-Z,]+)(?:\'|\"))/)}static canPlayType(t,s,i){const e=tt.parseMimeType(s),h=s=>s.reduce(((s,i)=>{if(""===s)return"";const e=t(i);return e?"maybe"===e||"maybe"===s?"maybe":!0===e||"probably"===e?"probably":void 0:""}),null);if(e){const{mime:t,codecs:r}=e.groups,n=i&&i[t];if(!n||Array.isArray(n))return h(n||[s])||h([`audio/${t}`]);if("object"==typeof n){if(r){const t=r.split(",");return t.length>1?"":n[t[0]]?h(n[t[0]]):""}return"maybe"}}return""}enablePlayButton(t){this.ri.removeAttribute("src"),this.ri.srcObject=null,t.includes("mediasource")?this.ri.src=URL.createObjectURL(new MediaSource):t.includes("webaudio")?(this.ui=new MediaStream,this.ri.srcObject=this.ui):t.includes("html5")&&(this.ri.src="data:audio/mpeg;base64,//sQxAAABFgC/SCEYACCgB9AAAAAppppVCAHBAEIgBByw9WD5+J8ufwxiDEDsMfE+D4fwG/RUGCx6VO4awVxV3qDtQNPiXKnZUNSwKuUDR6IgaeoGg7Fg6pMQU1FMy4xMDCqqqqqqqr/+xLEB4PAAAGkAAAAIAAANIAAAASqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqo=",this.ri.loop=!0)}get syncStateUpdate(){return this.li}get syncState(){return this.di}set syncState(t){this.di=t,this.yi&&this.yi(t),this.li=new Promise((t=>{this.yi=t}))}get isSupported(){return!1}get isAudioPlayer(){return!1}get metadataTimestamp(){return 0}get currentTime(){return 0}get waiting(){return Promise.resolve()}get icecastMetadataQueue(){return this.fi}set icecastMetadataQueue(t){this.fi=t}get codecUpdateQueue(){return this.mi}set codecUpdateQueue(t){this.mi=t}get metadataQueue(){return this.fi?this.fi.metadataQueue:[]}pi(){this.fi.startQueue(this.wi),this.mi.startQueue(this.wi)}async gi(){this.syncState=$,this.syncFrames=[],this.syncDelay=null,this.bi=new X(this.Ms,this)}async start(t){let s;this.wi=t,[e.RETRY,e.SWITCH].forEach((t=>this.Ms.addEventListener(t,this.ci)));const h=new Promise((t=>{s=t,[i.PLAYING,i.STOPPING].forEach((t=>this.Ms.addEventListener(t,s,{once:!0})))})).finally((()=>{[i.PLAYING,i.STOPPING].forEach((t=>this.Ms.removeEventListener(t,s)))}));await h}async end(){[e.RETRY,e.SWITCH].forEach((t=>this.Ms.removeEventListener(t,this.ci))),this.fi.purgeMetadataQueue(),this.mi.purgeMetadataQueue()}onStream(t){return t}onMetadata(t){this.fi.addMetadata(t,this.metadataTimestamp,this.currentTime)}onCodecUpdate(t,s){const i=this.currentTime;s{this.Si||this.end()})),this.gi()}static canPlayType(t){return st.isSupported?super.canPlayType((t=>(new Audio).canPlayType(t)),t):""}static get isSupported(){return Boolean(window.Audio)}static get name(){return"html5"}get isAudioPlayer(){return!0}get metadataTimestamp(){return this.qi?(this.qi.totalDuration+this.Mi)/1e3:0}get currentTime(){return this.Ai&&(performance.now()-this.Ai)/1e3}get waiting(){return new Promise((t=>{this.ri.addEventListener("waiting",t,{once:!0})}))}async gi(){super.gi(),this.qi=null,this.Ai=0,this.Mi=0,this.Si=!1}async start(t){const s=super.start(t);this.vi=performance.now(),this.ri.src=null,this.ri.srcObject=null,this.ri.src=this.ei,this.Ms.state!==i.STOPPING&&this.Ms.state!==i.STOPPED&&(this.ri.addEventListener("playing",(()=>{this.Ai=performance.now(),this.Mi=performance.now()-this.vi,this.pi(),this.Ms[P](e.PLAY)}),{once:!0}),this.Ms[P](e.PLAY_READY),this.Si=!0),await s}async end(){super.end(),this.ri.src=null,this.ri.srcObject=null,this.gi()}onStream(t){this.qi=t[t.length-1]||this.qi,this.syncState===D&&(this.syncState=D)}}class it extends tt{constructor(t,s,i,e,h){super(t,s,i,e,h),this.Pi=r.e(756).then(r.bind(r,910)),this.gi()}static canPlayType(t){return it.isSupported?MediaSource.isTypeSupported(t)?"probably":super.canPlayType(MediaSource.isTypeSupported,t,{mpeg:['audio/mp4;codecs="mp3"'],aac:['audio/mp4;codecs="mp4a.40.2"'],aacp:['audio/mp4;codecs="mp4a.40.2"'],flac:['audio/mp4;codecs="flac"'],ogg:{flac:['audio/mp4;codecs="flac"'],opus:['audio/mp4;codecs="opus"','audio/webm;codecs="opus"'],vorbis:['audio/webm;codecs="vorbis"']}}):""}static get isSupported(){return Boolean(window.MediaSource)}static get name(){return"mediasource"}get isAudioPlayer(){return!0}get metadataTimestamp(){return this.Ei&&this.Ei.sourceBuffers.length&&Math.max(this.Ei.sourceBuffers[0].timestampOffset,this.Ei.sourceBuffers[0].buffered.length?this.Ei.sourceBuffers[0].buffered.end(0):0)||0}get currentTime(){return this.ri.currentTime}get waiting(){return new Promise((t=>{this.ri.addEventListener("waiting",t,{once:!0})}))}async gi(){super.gi(),this.Ti=[],this.Si=!1,this._i=!1,this.Ci=new Promise((t=>{this.Ii=t})),this.Ri=new Promise((t=>{this.xi=t})),this.$i=this.ki(this.ct,this.J),await this.Ri}async start(t){const s=super.start(t);await this.Ci,await this.Oi(),await s}async end(){super.end(),await this.gi()}async onStream(t){if((t=t.flatMap((t=>t.codecFrames?t.codecFrames.map((s=>(s.isLastPage=t.isLastPage,s))):t))).length){switch(this.syncState){case D:this.bi.initSync(),this.syncState=k;case k:[this.syncFrames,this.syncState,this.syncDelay]=await this.bi.sync(t),t=this.syncFrames}switch(this.syncState){case O:break;case $:await this.Ri,await this.$i(t),this.bi.addAll(t)}}}ki(t,s){return MediaSource.isTypeSupported(t)?(this.Di(t),async t=>this.Bi(B(t.map((t=>t.data))))):(this.hi.then((i=>this.Fi(t,s,i.channels))).then((()=>{this.Di(this.Li.mimeType)})),t.match(/ogg/)?async i=>{let e=[];for await(const h of i){if(this._i!==h.isLastPage)if(h.isLastPage)this._i=!0;else{await this.Bi(B(e)),e=[];const i=await this.hi;await this.Fi(t,s,i.channels),this._i=!1}e.push(...this.Li.iterator([h]))}await this.Bi(B(e))}:async t=>this.Bi(B([...this.Li.iterator(t)])))}async Fi(t,s,i){this.Li=new(await this.Pi).default(t,{codec:s,preferredContainer:i>2?"webm":"fmp4"}),MediaSource.isTypeSupported(this.Li.mimeType)||this.Ms[P](e.PLAYBACK_ERROR,`Media Source Extensions API in your browser does not support ${t} or ${this.Li.mimeType}.See: https://caniuse.com/mediasource and https://developer.mozilla.org/en-US/docs/Web/API/Media_Source_Extensions_API`)}Di(t){this.Ei=new MediaSource,this.Ii(),this.Ei.addEventListener("sourceopen",(()=>{this.Ms.state!==i.STOPPED&&this.Ms.state!==i.STOPPING&&(this.Ei.addSourceBuffer(t).mode="sequence"),this.Ui=0,this.xi()}),{once:!0})}async Oi(){this.ri.loop=!1,this.ri.src=URL.createObjectURL(this.Ei),await this.Ri}async Ni(){return new Promise((t=>{const s=this.Ei.sourceBuffers[0];s.updating?s.addEventListener("updateend",t,{once:!0}):t()}))}async Bi(t){if(this.Ms[P](e.STREAM,t),this.Ei.sourceBuffers.length||this.Ms[P](e.WARN,"Attempting to append audio, but MediaSource has not been or is no longer initialized","Please be sure that `detachAudioElement()` was called and awaited before reusing the element with a new IcecastMetadataPlayer instance"),this.Ms.state!==i.STOPPING&&this.Ei.sourceBuffers.length){this.Ti.push(t);try{for(;this.Ti.length;)this.Ei.sourceBuffers[0].appendBuffer(this.Ti.shift()),await this.Ni()}catch(t){if("QuotaExceededError"!==t.name)throw t}this.Si||(this.ni<=this.metadataTimestamp?(this.ri.addEventListener("playing",(()=>{this.pi(),this.Ms[P](e.PLAY)}),{once:!0}),this.Ms[P](e.PLAY_READY),this.Si=!0):this.Ms[P](e.BUFFER,this.metadataTimestamp)),this.ri.currentTime>5+this.ni&&this.Ui+5e3'audio/ogg;codecs="opus"'===t||'audio/ogg;codecs="flac"'===t||'audio/ogg;codecs="vorbis"'===t||"audio/mpeg"===t||"audio/flac"===t),t,{flac:["audio/flac"],mpeg:["audio/mpeg"],ogg:{flac:['audio/ogg;codecs="flac"'],opus:['audio/ogg;codecs="opus"'],vorbis:['audio/ogg;codecs="vorbis"']}}):""}static get isSupported(){return Boolean(window.WebAssembly&&(window.AudioContext||window.webkitAudioContext)&&window.MediaStream)}static get name(){return"webaudio"}get isAudioPlayer(){return!0}get metadataTimestamp(){return this.Wi/1e3}get currentTime(){return(performance.now()-this.Gi)/1e3||0}get waiting(){return this.Hi}Qi(t){let s;this.Vi+=t,s=setTimeout((()=>{this.Vi-=t,this.Yi.delete(s),this.Yi.size||this.zi()}),this.Vi),this.Yi.add(s)}zi(){this.Ki&&this.Ki(),this.Hi=new Promise((t=>{this.Ki=t}))}Zi(){this.Yi&&this.Yi.forEach((t=>clearTimeout(t))),this.Yi=new Set,this.Vi=0,this.zi()}async Ji(){let t;this.Xi=new Promise((t=>{this.te=t}));try{switch(this.J){case"mpeg":const{MPEGDecoderWebWorker:s}=await Promise.all([r.e(968),r.e(388)]).then(r.bind(r,775));t=s;break;case"opus":const{OpusDecoderWebWorker:i}=await Promise.all([r.e(968),r.e(390)]).then(r.bind(r,879));t=i;break;case"flac":const{FLACDecoderWebWorker:e}=await Promise.all([r.e(968),r.e(983)]).then(r.bind(r,259));t=e;break;case"vorbis":const{OggVorbisDecoderWebWorker:h}=await Promise.all([r.e(968),r.e(122)]).then(r.bind(r,115));t=h}}catch(t){return void this.Ms[P](e.PLAYBACK_ERROR,`Missing \`webaudio-${this.J}\` dependency.`,`Unable to playback playback \`${this.J}\` audio.`)}if(t){const s=await this.hi;this.te(),this.se=new t(s)}else this.Ms[P](e.PLAYBACK_ERROR,"Unsupported `webaudio` playback codec: "+this.J)}async gi(){super.gi(),this.Wi=0,this.ie=0,this.ee=0,this.qt=0,this.Gi=void 0,this.Si=!1,this.Zi(),this.he=new Promise((t=>{this.re=t}))}async start(t){this.se||await this.Ji();const s=super.start(t);this.re(),await s}async end(){super.end(),this.se&&(this.se.terminate(),this.se=null),this.ui&&this.ui.stream.getTracks().forEach((t=>this.ui.stream.removeTrack(t))),this.gi()}async onStream(t){if("vorbis"!==this.J)switch(t=t.flatMap((t=>t.codecFrames||t)),this.syncState){case D:this.bi.initSync(),this.syncState=k;case k:[this.syncFrames,this.syncState,this.syncDelay]=await this.bi.sync(t),t=this.syncFrames}switch(this.syncState){case O:break;case $:t.length&&(this.Wi=t[t.length-1].totalDuration,this.ne(t))}}async ne(t){if(await this.Xi,this.se){let s;await this.se.ready,"vorbis"===this.J?s=this.se.decodeOggPages(t):(s=this.se.decodeFrames(t.map((t=>t.data))),this.bi.addAll(t)),s.then((t=>this.ae(t)))}}async ae({channelData:t,samplesDecoded:s,sampleRate:h}){if(await this.he,this.Ms.state!==i.STOPPING&&this.Ms.state!==i.STOPPED&&s){this.Ms[P](e.STREAM,{channelData:t,samplesDecoded:s,sampleRate:h}),this.qt||(this.qt=h,this.ui=this.ji.createMediaStreamDestination(),this.ui.channelCount=this.ji.destination.maxChannelCount,this.ri.srcObject=this.ui.stream);const i=this.ji.createBuffer(t.length,s,this.qt);t.forEach(((t,s)=>i.getChannelData(s).set(t)));const r=this.ji.createBufferSource();r.buffer=i,r.connect(this.ui);const n=100,a=this.ie*n+this.ee,o=Math.round(this.ji.currentTime*this.qt*n);at.isSupported?t.name:""))}static canPlayType(t){return{mediasource:it.canPlayType(t),html5:st.canPlayType(t),webaudio:et.canPlayType(t)}}get endpoint(){return this.ei}get player(){return this.ks}get playbackMethod(){return this.ce}get icyMetaInt(){return this.fe&&this.fe.icyMetaInt}async playStream(){return this.fetchStream().then((async t=>(this.Ms[P](e.STREAM_START),this.readIcecastResponse(t).finally((()=>{this.Ms[P](e.STREAM_END)}))))).catch((t=>{if(this.Ms.state!==i.SWITCHING)throw t}))}async switchStream(){this.Ms.state!==i.PLAYING&&(this.ye(),await this.de);const t=s.get(this.Ms);t[x]=i.SWITCHING,t[R].abort(),t[R]=new AbortController}async fetchStream(){const t=s.get(this.Ms);this.ei=t[C].next().value;const i=t[I]?{"Icy-MetaData":1}:{};if(t[M]){const s=t[M];i.Authorization="Basic "+btoa(s.user+":"+s.password)}const e=await fetch(this.ei,{method:"GET",headers:i,signal:t[R].signal});if(!e.ok){const t=new Error(`${e.status} received from ${e.url}`);throw t.name="HTTP Response Error",t}return e}async readIcecastResponse(t){const i=t.headers.get("content-type"),h=s.get(this.Ms);let r;const n=new Promise((t=>{r=t})),a=new Promise((t=>{this.I=new K.ZP(i,{onCodec:t,onCodecHeader:r,onCodecUpdate:this.oe&&((...t)=>this.ks.onCodecUpdate(...t)),enableLogging:this.ut})}));this.fe=new V(t,{onMetadata:async t=>{this.ks.onMetadata(t)},onStream:async({stream:t})=>{this.Ms[P](e.STREAM,t);const s=[...this.I.parseChunk(t)];if(this.ks.isAudioPlayer){const t=[...this.le,...s];this.le=[],await this.ks.onStream(t)}else this.le.push(...s)},onError:(...t)=>this.Ms[P](e.WARN,...t),metadataTypes:h[o],icyCharacterEncoding:h[f],icyDetectionTimeout:h[m],...h[y]?{icyMetaInt:h[y]}:{}});const c=this.fe.startReading(),u=await a;this.ks.isAudioPlayer||([this.ks,this.ce]=this.me(i,u,n)),this.ks.syncState===$?this.ks.start():await this.pe(i,u,n),await c}async pe(t,s,e){let h,r,n=!1,a=!1;const o=this.ks,c=this.ks.icecastMetadataQueue,u=this.ks.codecUpdateQueue;this.ue(),o.icecastMetadataQueue=this.fi,o.codecUpdateQueue=this.mi;const l=()=>{a=!0,this.Ms.state===i.STOPPING&&this.Ms.state===i.STOPPED||(o.icecastMetadataQueue.purgeMetadataQueue(),o.codecUpdateQueue.purgeMetadataQueue(),this.ks.start(Math.max(0,o.syncDelay/1e3)).then((()=>o.end())).then(r))};this.ye=()=>{n=!0,this.fi.purgeMetadataQueue(),this.mi.purgeMetadataQueue(),this.ks.icecastMetadataQueue=c,this.ks.codecUpdateQueue=u,void 0===h||a||(clearTimeout(h),l())};const d=()=>this.ks.syncStateUpdate.then((a=>{if(n)r();else switch(a){case k:return d();case $:this.fi.purgeMetadataQueue(),this.mi.purgeMetadataQueue(),this.ks.icecastMetadataQueue=c,this.ks.codecUpdateQueue=u,this.Ms.state===i.STOPPING&&this.Ms.state===i.STOPPED||(this.Ms[x]=i.PLAYING),r();break;case O:case D:o.icecastMetadataQueue=c,o.codecUpdateQueue=u,[this.ks,this.ce]=this.me(t,s,e),this.le.push(...o.syncFrames),h=setTimeout(l,Math.max(o.syncDelay,0))}}));let y;this.de=new Promise((t=>{r=t,y=()=>{this.ye(),r()},this.Ms.addEventListener(i.STOPPING,y,{once:!0}),d()})).finally((()=>{this.Ms.removeEventListener(i.STOPPING,y)}))}ue(){this.fi=new z({onMetadataUpdate:(...t)=>this.Ms[P](e.METADATA,...t),onMetadataEnqueue:(...t)=>this.Ms[P](e.METADATA_ENQUEUE,...t),paused:!0}),this.mi=new z({onMetadataUpdate:(...t)=>this.Ms[P](e.CODEC_UPDATE,...t),paused:!0})}me(t,i,e){const{[s.get(this.Ms)[c]]:h,...r}={mediasource:it,webaudio:et,html5:st};let n,a;for(const s of Object.values({firstMethod:h,...r})){const h=s.canPlayType(`${t};codecs="${i}"`);if("probably"===h||"maybe"===h){a=s.name,n=new s(this.Ms,this.ei,t,i,e),n.icecastMetadataQueue=this.fi,n.codecUpdateQueue=this.mi;break}}if(!n)throw new Error(`Your browser does not support this audio codec ${t}${i&&`;codecs="${i}"`}`);return[n,a]}}let rt;try{new window.EventTarget,rt=window.EventTarget}catch{rt=F}const nt=Symbol(),at=Symbol(),ot=Symbol(),ct=Symbol(),ut=Symbol(),lt=Symbol(),dt=Symbol(),yt=Symbol(),ft=Symbol(),mt=Symbol(),pt=Symbol(),wt=Symbol();class gt extends rt{static*[A](t){for(;;){const i=s.get(t)[h];for(const e of i)if(yield e,s.get(t)[h]!==i)break}}static[v](t,s,i={}){const e={[h]:(t&&(Array.isArray(t)?t:[t]))??i[h],[d]:s.bufferLength??i[d]??1,[y]:s.icyMetaInt??i[y],[f]:s.icyCharacterEncoding??i[f],[m]:s.icyDetectionTimeout??i[m],[o]:(s.metadataTypes??i[o])||["icy"],[I]:((s.metadataTypes??i[o])||["icy"]).includes("icy"),[p]:s.enableLogging??i[p]??!1,[q]:Boolean(s.enableCodecUpdate??i[q]??s.onCodecUpdate),[a]:s.endpointOrder??i[a]??"ordered",[w]:s.retryDelayRate??i[w]??.1,[g]:s.retryDelayMin??i[g]??.5,[b]:s.retryDelayMax??i[b]??2,[S]:s.retryTimeout??i[S]??30,[c]:(s.playbackMethod??i[c])||"mediasource",[M]:s.authentication??i[M]};return e[h]!==i[h]&&"random"===e[a]&&(e[h]=e[h].sort((()=>.5-Math.random()))),e}constructor(h,r={}){super(),s.set(this,{[C]:gt[A](this),[l]:r.audioElement||new Audio,...gt[v](h,r),[ot]:{[e.PLAY]:r.onPlay||t,[e.PLAY_READY]:t,[e.LOAD]:r.onLoad||t,[e.STREAM_START]:r.onStreamStart||t,[e.BUFFER]:r.onBuffer||t,[e.STREAM]:r.onStream||t,[e.STREAM_END]:r.onStreamEnd||t,[e.METADATA]:r.onMetadata||t,[e.METADATA_ENQUEUE]:r.onMetadataEnqueue||t,[e.CODEC_UPDATE]:r.onCodecUpdate||t,[e.STOP]:r.onStop||t,[e.RETRY]:r.onRetry||t,[e.RETRY_TIMEOUT]:r.onRetryTimeout||t,[e.SWITCH]:r.onSwitch||t,[e.WARN]:(...t)=>{this[_](console.warn,r.onWarn,t)},[e.ERROR]:(...t)=>{this[_](console.error,r.onError,t)},[e.PLAYBACK_ERROR]:(...t)=>{this.state!==i.RETRYING?(this[P](e.ERROR,...t),this.stop()):s.get(this)[mt]()}},[mt]:()=>{clearTimeout(s.get(this)[wt]),this.removeEventListener(e.STREAM_START,s.get(this)[mt]),s.get(this)[l].removeEventListener("waiting",s.get(this)[yt]);try{s.get(this)[l].pause()}catch(t){s.get(this)[dt](t)}try{s.get(this)[at]=s.get(this)[nt].player.end()}catch{}},[ut]:()=>{this.play()},[ct]:()=>{this.stop()},[dt]:t=>{const s=t?.target?.error||t;this[P](e.PLAYBACK_ERROR,"The audio element encountered an error."+({1:" MEDIA_ERR_ABORTED The fetching of the associated resource was aborted by the user's request.",2:" MEDIA_ERR_NETWORK Some kind of network error occurred which prevented the media from being successfully fetched, despite having previously been available.",3:" MEDIA_ERR_DECODE Despite having previously been determined to be usable, an error occurred while trying to decode the media resource, resulting in an error.",4:" MEDIA_ERR_SRC_NOT_SUPPORTED The associated resource or media provider object (such as a MediaStream) has been found to be unsuitable.",5:" MEDIA_ERR_ENCRYPTED"}[s?.code]||""))},[lt]:()=>{const t=s.get(this)[l];(this.state===i.LOADING||!t.loop&&this.state!==i.STOPPING&&this.state!==i.STOPPED)&&t.play().then((()=>{this[x]=i.PLAYING})).catch((t=>{this[P](e.PLAYBACK_ERROR,t,"Playback failed.")}))},[ft]:t}),this[E](),this[x]=i.STOPPED,s.get(this)[nt]=new ht(this)}static canPlayType(t){return ht.canPlayType(t)}get audioElement(){return s.get(this)[l]}get[u](){return gt.constructor[u]}get endpoint(){return s.get(this)[nt].endpoint}get icyMetaInt(){return s.get(this)[nt].icyMetaInt}get metadataQueue(){return s.get(this)[nt].player.metadataQueue}get state(){return s.get(this)[x]}get playbackMethod(){return s.get(this)[nt].playbackMethod}set[x](t){this.dispatchEvent(new CustomEvent(t)),s.get(this)[x]=t}[E](){const t=s.get(this)[l];t.addEventListener("pause",s.get(this)[ct]),t.addEventListener("play",s.get(this)[ut]),t.addEventListener("error",s.get(this)[dt]),this.addEventListener(e.PLAY_READY,s.get(this)[lt])}async detachAudioElement(){const t=s.get(this)[l];t.removeEventListener("pause",s.get(this)[ct]),t.removeEventListener("play",s.get(this)[ut]),t.removeEventListener("error",s.get(this)[dt]),this.removeEventListener(e.PLAY_READY,s.get(this)[lt]),await this.stop()}async play(){if(this.state===i.STOPPED){const t=new Promise((t=>{this.addEventListener(e.PLAY,t,{once:!0})})),h=new Promise((t=>{this.addEventListener(e.STREAM_END,t,{once:!0})}));s.get(this)[R]=new AbortController,this[x]=i.LOADING,this[P](e.LOAD);const r=async()=>s.get(this)[nt].playStream().then((async()=>{if(this.state===i.SWITCHING)return this[P](e.SWITCH),r();this.state!==i.STOPPING&&this.state!==i.STOPPED&&(await t,await h,await s.get(this)[nt].player.waiting)})).catch((async t=>{if(t&&"AbortError"!==t.name){if(await this[T](t))return this[P](e.RETRY),r();s.get(this)[R].abort(),this.state!==i.STOPPING&&this.state!==i.STOPPED&&this[P](e.ERROR,t.message.match(/network|fetch|offline|codec/i)?t:t.stack,t)}}));new Promise(((t,i)=>{s.get(this)[ft]=i,r().then(t)})).catch((t=>{if(this.state!==i.STOPPING)throw t})).finally((()=>{s.get(this)[mt](),this[P](e.STOP),this[x]=i.STOPPED})),await t}}async stop(){this.state!==i.STOPPED&&this.state!==i.STOPPING&&(this[x]=i.STOPPING,s.get(this)[R].abort(),s.get(this)[ft](),await new Promise((t=>{this.addEventListener(e.STOP,t,{once:!0})})))}async switchEndpoint(t,e){if(this.state!==i.STOPPED&&this.state!==i.STOPPING){const i=s.get(this);return Object.assign(i,gt[v](t,e,i)),i[nt].switchStream()}}async[T](t){if(0===s.get(this)[S])return!1;if(s.get(this)[x]===i.RETRYING)return await new Promise((t=>{this.addEventListener(i.STOPPING,t,{once:!0});const e=Math.min(1e3*s.get(this)[g]*(s.get(this)[w]+1)**s.get(this)[pt]++,1e3*s.get(this)[b]);setTimeout((()=>{this.removeEventListener(i.STOPPING,t),t()}),e+.3*e*Math.random())})),s.get(this)[x]===i.RETRYING;if(s.get(this)[x]!==i.STOPPING&&s.get(this)[x]!==i.STOPPED&&(t.message.match(/network|fetch|offline|Error in body stream/i)||"HTTP Response Error"===t.name)){this[P](e.ERROR,t.name,t),this[x]=i.RETRYING,s.get(this)[I]&&this[P](e.WARN,"This stream was requested with ICY metadata.",'If there is a CORS preflight failure, try removing "icy" from the metadataTypes option.',"See https://github.com/eshaz/icecast-metadata-js#cors for more details.");const h=new Promise((t=>{s.get(this)[yt]=t,s.get(this)[l].addEventListener("waiting",s.get(this)[yt],{once:!0})}));return s.get(this)[wt]=setTimeout((()=>{h.then((()=>{s.get(this)[x]===i.RETRYING&&(this[P](e.RETRY_TIMEOUT),this.stop())}))}),1e3*s.get(this)[S]),s.get(this)[pt]=0,!0}return!1}[P](t,...i){this.dispatchEvent(new CustomEvent(t,{detail:i})),s.get(this)[ot][t](...i)}[_](t,i,e){s.get(this)[p]&&t("icecast-metadata-js",e.reduce(((t,s)=>t+"\n "+s),"")),i&&i(...e)}}const bt=window.AudioContext||window.webkitAudioContext;if(bt&&!gt.constructor[u]){gt.constructor[u]="audio context pending";const t=t=>{console.error("icecast-metadata-js","Failed to start the AudioContext. WebAudio playback will not be possible.",t)},s=["touchstart","touchend","mousedown","keydown"],i=()=>{s.forEach((t=>document.removeEventListener(t,i)));const e=new bt({latencyHint:"interactive"});e.destination.channelCount=e.destination.maxChannelCount,e.resume().then((()=>{e.createScriptProcessor(16384,2,2).connect(e.destination),e.onstatechange=()=>{"running"!==e.state&&e.resume().catch(t)}})).catch(t),gt.constructor[u]=e};s.forEach((t=>document.addEventListener(t,i)))}})(),n=r.O(n),IcecastMetadataPlayer=n.default})(); //# sourceMappingURL=icecast-metadata-player-1.17.2.main.min.js.map