/*! For license information please see icecast-metadata-player-1.17.13.main.min.js.LICENSE.txt */
/*! 
 * Copyright 2021-2024 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={317:(t,s,i)=>{i.d(s,{HQ:()=>re,p:()=>ne,Ay:()=>he,wx:()=>ae,we:()=>oe,GA:()=>ue,Er:()=>ce,$:()=>le});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(", ")})`,l=[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)],u=48e3,d=44100,y=32e3,f=24e3,m=22050,p=16e3,w=8e3,g="absoluteGranulePosition",b="bandwidth",S="bitDepth",q="bitrate",A=q+"Maximum",M=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",O="description",k="duration",D="emphasis",B="hasOpusPadding",L="header",F="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",lt=ct+"Comments",ut=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",At=bt+"Mode",Mt=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",Ot=_t+"Size",kt="Rate",Dt="inputSample"+kt,Bt="page",Lt=Bt+"Checksum",Ft=e(),Ut=Bt+"SegmentTable",Nt=Bt+"Sequence"+Rt,jt="sample",Wt=jt+Rt,Gt=jt+kt,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(),ls=e(),us=e(),ds=e(),ys=e(),fs=e(),ms=e(),ps=e(),ws=e(),gs=e(),bs=e(),Ss=Uint8Array,qs=DataView,As="reserved",Ms="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),Os=[0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15],ks=t=>Os[15&t]<<4|Os[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(ks(this.t[s-1])<<8)+ks(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.A=new Map,this.M=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.M.get(this.A.get(this._));this.P&&i&&this.S({bitrate:t,...i},s),this.P=!1}}[ls](t){const s=this.A.get(t);return s&&this.C(t),s}[us](t,s,i){this.q&&(this.v||(this.h({...s}),this.v=!0),this.C(t),this.A.set(t,s),this.M.set(s,i))}C(t){this.S&&t!==this._&&(this.P=!0,this._=t)}}const Ls=new WeakMap,Fs=new WeakMap;class Us{constructor(t,s){this.I=t,this.A=s}*[os](){let t;for(;;){if(t=yield*this.Frame[ds](this.I,this.A,0),t)return t;this.I[es](1)}}*[cs](t){let s=yield*this[os]();const i=Fs.get(s)[Y];if(t||this.I.R||(yield*this.Header[ls](this.I,this.A,i)))return this.A[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.A[ps](),this.I[es](1)}}class Ns{constructor(t,s){Fs.set(this,{[L]:t}),this[$]=s}}class js extends Ns{static*[ds](t,s,i,e,h){const r=yield*t[ls](i,e,h);if(r){const t=Ls.get(r)[It],e=Ls.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[L]=t,this[Qt]=i,this[k]=i/t[Gt]*1e3,this[xt]=null,this[Xt]=null,this[ss]=null,this[ts]=null,Fs.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){Ls.set(this,t),this[S]=t[S],this[q]=null,this[vt]=t[vt],this[At]=t[At],this[Gt]=t[Gt]}}const zs={0:[vs,vs,vs,vs,vs],16:[32,32,32,32,8],240:[Ms,Ms,Ms,Ms,Ms]},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:ei+ni+hi+ni,16:ei+ri+hi+ni,32:ei+ni+hi+ri,48:ei+ri+hi+ri},oi={0:{[O]:As},2:{[O]:"Layer III",[$t]:1,[K]:ai,[ii]:{[ti]:2,[Qt]:1152},[si]:{[ti]:4,[Qt]:576}},4:{[O]:"Layer II",[$t]:1,[K]:Xs,[Qt]:1152,[ii]:{[ti]:1},[si]:{[ti]:4}},6:{[O]:"Layer I",[$t]:4,[K]:Xs,[Qt]:384,[ii]:{[ti]:0},[si]:{[ti]:3}}},ci="MPEG Version ",li="ISO/IEC ",ui={0:{[O]:`${ci}2.5 (later extension of MPEG 2)`,[V]:si,[Gt]:{0:11025,4:12e3,8:w,12:As}},8:{[O]:As},16:{[O]:`${ci}2 (${li}13818-3)`,[V]:si,[Gt]:{0:m,4:f,8:p,12:As}},24:{[O]:`${ci}1 (${li}11172-3)`,[V]:ii,[Gt]:{0:d,4:u,8:y,12:As}},length:Y},di={0:Es,1:Ps},yi={0:Ps,1:"50/15 ms",2:As,3:"CCIT J.17"},fi={0:{[vt]:2,[O]:a},64:{[vt]:2,[O]:"joint "+a},128:{[vt]:2,[O]:"dual channel"},192:{[vt]:1,[O]:n}};class mi extends Ys{static*[ls](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[ls](n);if(a)return new mi(a);if(255!==r[0]||r[1]<224)return null;const o=ui[24&r[1]];if(o[O]===As)return null;const c=6&r[1];if(oi[c][O]===As)return null;const l={...oi[c],...oi[c][o[V]]};if(e[J]=o[O],e[V]=l[O],e[Qt]=l[Qt],e[ht]=di[1&r[1]],e[Y]=4,e[q]=zs[240&r[2]][l[ti]],e[q]===Ms)return null;if(e[Gt]=o[Gt][12&r[2]],e[Gt]===As)return null;if(e[$t]=2&r[2]&&l[$t],e[H]=!!(1&r[2]),e[It]=Math.floor(125*e[q]*e[Qt]/e[Gt]+e[$t]),!e[It])return null;const u=192&r[3];if(e[At]=fi[u][O],e[vt]=fi[u][vt],e[K]=l[K][48&r[3]],e[U]=!!(8&r[3]),e[G]=!!(4&r[3]),e[D]=yi[3&r[3]],e[D]===As)return null;e[S]=16;{const{length:t,frameLength:i,samples:h,...r}=e;s[us](n,e,r)}return new mi(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 pi extends js{static*[ds](t,s,i){return yield*super[ds](mi,pi,t,s,i)}constructor(t,s,i){super(t,s,i)}}class wi extends Us{constructor(t,s,i){super(t,s),this.Frame=pi,this.Header=mi,i(this[T])}get[T](){return Z}*[ys](){return yield*this[cs]()}}const gi={0:"MPEG-4",8:"MPEG-2"},bi={0:"valid",2:Ms,4:Ms,6:Ms},Si={0:Es,1:Ps},qi={0:"AAC Main",64:"AAC LC (Low Complexity)",128:"AAC SSR (Scalable Sample Rate)",192:"AAC LTP (Long Term Prediction)"},Ai={0:96e3,4:88200,8:64e3,12:u,16:d,20:y,24:f,28:m,32:p,36:12e3,40:11025,44:w,48:7350,52:As,56:As,60:"frequency is written explicitly"},Mi={0:{[vt]:0,[O]:"Defined in AOT Specific Config"},64:{[vt]:1,[O]:n},128:{[vt]:2,[O]:c(2,h[0][0])},192:{[vt]:3,[O]:c(3,h[1][3])},256:{[vt]:4,[O]:c(4,h[1][3],h[3][4])},320:{[vt]:5,[O]:c(5,h[1][3],h[3][0])},384:{[vt]:6,[O]:c(6,h[1][3],h[3][0],r)},448:{[vt]:8,[O]:c(8,h[1][3],h[2][0],h[3][0],r)}};class vi extends Ys{static*[ls](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[ls](r);if(n)Object.assign(e,n);else{if(255!==h[0]||h[1]<240)return null;if(e[J]=gi[8&h[1]],e[V]=bi[6&h[1]],e[V]===Ms)return null;const t=1&h[1];e[ht]=Si[t],e[Y]=t?7:9,e[et]=192&h[2],e[Ht]=60&h[2];const i=2&h[2];if(e[it]=qi[e[et]],e[Gt]=Ai[e[Ht]],e[Gt]===As)return null;e[H]=!!i,e[Mt]=448&(h[2]<<8|h[3]),e[At]=Mi[e[Mt]][O],e[vt]=Mi[e[Mt]][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,...l}=e;s[us](r,e,l)}}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 vi(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=Ls.get(this),s=t[et]+64<<5|t[Ht]<<5|t[Mt]>>3,i=new Ss(2);return new qs(i[P]).setUint16(0,s,!1),i}}class Pi extends js{static*[ds](t,s,i){return yield*super[ds](vi,Pi,t,s,i)}constructor(t,s,i){super(t,s,i)}}class Ei extends Us{constructor(t,s,i){super(t,s),this.Frame=Pi,this.Header=vi,i(this[T])}get[T](){return"aac"}*[ys](){return yield*this[cs]()}}class Ti extends js{static k(t){return(t[t[Y]-2]<<8)+t[t[Y]-1]}static[bs](t){const s=Ti.k(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]=Ti.k(t),super(s,t,Ls.get(s)[Qt])}}const _i="get from STREAMINFO metadata block",Ci={0:"Fixed",1:"Variable"},Ii={0:As,16:192};for(let t=2;t<16;t++)Ii[t<<4]=t<6?576*2**(t-2):2**t;const Ri={0:_i,1:88200,2:176400,3:192e3,4:w,5:p,6:m,7:f,8:y,9:d,10:u,11:96e3,15:Ms},xi={0:{[vt]:1,[O]:n},16:{[vt]:2,[O]:c(2,h[0][0])},32:{[vt]:3,[O]:c(3,h[0][1])},48:{[vt]:4,[O]:c(4,h[1][0],h[3][0])},64:{[vt]:5,[O]:c(5,h[1][1],h[3][0])},80:{[vt]:6,[O]:c(6,h[1][1],r,h[3][0])},96:{[vt]:7,[O]:c(7,h[1][1],r,h[3][4],h[2][0])},112:{[vt]:8,[O]:c(8,h[1][1],r,h[3][0],h[2][0])},128:{[vt]:2,[O]:`${a} (left, diff)`},144:{[vt]:2,[O]:`${a} (diff, right)`},160:{[vt]:2,[O]:`${a} (avg, diff)`},176:As,192:As,208:As,224:As,240:As},$i={0:_i,2:8,4:12,6:As,8:16,10:20,12:24,14:As};class Oi extends Ys{static D(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:l,...u}=h;s[us](r,h,u)}return new Oi(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=Ti,this.Header=Oi,i(this[T])}get[T](){return"flac"}*B(t){const s=yield*this.I[is](2,0),i=s[Y]-2;for(;t{const s=Oi[gs](t,this.A);if(s)return new Ti(t,s,this.L);this.I[ns]("Failed to parse Ogg FLAC frame","Skipping invalid FLAC frame")}).filter(t=>!!t)),t}}class Di{static*[ls](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[F]=!!(1&h[5]);const r=new qs(Ss.from(h[at](0,28))[P]);e[g]=((t,s)=>{try{return t.getBigInt64(s,!0)}catch{const i=128&t.getUint8(s+7)?-1:1;let e=t.getUint32(s,!0),h=t.getUint32(s+4,!0);return-1===i&&(e=1+~e,h=1+~h),h>1048575&&console.warn("This platform does not support BigInt"),i*(e+h*2**32)}})(r,6),e[Kt]=r.getInt32(14,!0),e[Nt]=r.getInt32(18,!0),e[Lt]=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[Ft]=Ss.from(h[at](27,e[Y]));for(let t=0,s=0;t{const s=zi[gs](this.U,t,this.A);if(s){null===this.N&&(this.N=s[st]);let i=s[Ot]*s[Ct]/1e3*s[Gt];return this.N>0&&(this.N-=i,i=this.N<0?-this.N:0),new Li(t,s,i)}this.I[as]("Failed to parse Ogg Opus Header","Not a valid Ogg Opus file")})),t}}class Zi extends js{constructor(t,s,i){super(s,t,i)}}const Ji={};for(let t=0;t<8;t++)Ji[t+6]=2**(6+t);class Xi 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[ls](h);if(r)return new Xi(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[At]=l[n[vt]-1]||"application defined",n[Gt]=a.getUint32(12,!0),n[A]=a.getInt32(16,!0),n[v]=a.getInt32(20,!0),n[M]=a.getInt32(24,!0),n[wt]=Ji[(240&t[28])>>4],n[pt]=Ji[15&t[28]],n[pt]>n[wt])return null;if(1!==t[29])return null;n[S]=32,n[ut]=e,n[lt]=i;{const{length:t,data:i,version:e,vorbisSetup:r,vorbisComments:a,...o}=n;s[us](h,n,o)}return new Xi(n)}constructor(t){super(t),this[A]=t[A],this[M]=t[M],this[v]=t[v],this[pt]=t[pt],this[wt]=t[wt],this[$]=t[$],this[lt]=t[lt],this[ut]=t[ut]}}class te extends Us{constructor(t,s,i){super(t,s),this.Frame=Zi,i(this[T]),this.U=null,this.W=!1,this.G=null}get[T](){return ct}[fs](t){t[_]=[];for(const s of Fs.get(t)[nt])if(1===s[0])this.A[ws](),this.U=t[$],this.W=!1;else if(3===s[0])this.H=s;else if(5===s[0])this.V=s,this.Y=this.K(s),this.W=!0;else if(this.W){const i=Xi[gs](this.U,this.A,this.H,this.V);i?t[_].push(new Zi(s,i,this.Z(s,i))):this.I[logError]("Failed to parse Ogg Vorbis Header","Not a valid Ogg Vorbis file")}return t}Z(t,s){const i=this.Y.blockFlags[t[0]>>1&this.Y.mask]?s[wt]:s[pt],e=null===this.G?0:(this.G+i)/4;return this.G=i,e}K(t){const s=new Ds(t),i={count:0,blockFlags:[]};for(;1&~s.read(1););let e;for(;i.count<64&&s.position>0;){ks(s.read(8));let t=0;for(;0===s.read(8)&&t++<3;);if(4!==t){1+((126&ks(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.ot+1}, Got: ${t[Nt]}`),this.ot=t[Nt]}ct(t){null===this.st&&(this.ot=t[Nt],this.st=this.rt(t)),this.nt(t);const s=Fs.get(t),i=Ls.get(s[L]);let e=0;if(s[nt]=i[Ut].map(s=>t[$][at](e,e+=s)),this.X[Y]&&(s[nt][0]=xs(this.X,s[nt][0]),this.X=new Ss),255===i[Ft][i[Ft][Y]-1]&&(this.X=xs(this.X,s[nt].pop())),null!==this.it&&(t[Qt]=Number(t[g]-this.it)),this.it=t[g],this.st){const s=this.ht[fs](t);return this.I[rs](s),s}return t}}class ie extends Us{constructor(t,s,i){super(t,s),this.J=i,this.Frame=Bi,this.Header=Di,this.lt=new Map,this.ut=null}get[T](){const t=this.lt.get(this.ut);return t?t.codec:""}*[ys](){const t=yield*this[cs](!0);this.ut=t[Kt];let s=this.lt.get(this.ut);return s||(s=new se(this.I,this.A,this.J),this.lt.set(this.ut,s)),t[W]&&this.lt.delete(this.ut),s.ct(t)}}const ee=()=>{};const he=class{constructor(t,{onCodec:s,onCodecHeader:i,onCodecUpdate:e,enableLogging:h=!1,enableFrameCRC32:r=!0}={}){this.dt=t,this.J=s||ee,this.h=i||ee,this.S=e,this.yt=h,this.ft=r?Rs:ee,this[ps]()}get[T](){return this.ht?this.ht[T]:""}[ps](){this.A=new Bs(this.h,this.S),this.wt=this.gt(),this.wt.next()}*flush(){this.R=!0;for(let t=this.wt.next();t.value;t=this.wt.next())yield t.value;this.R=!1,this[ps]()}*parseChunk(t){for(let s=this.wt.next(t);s.value;s=this.wt.next())yield s.value}parseAll(t){return[...this.parseChunk(t),...this.flush()]}*gt(){if(this.dt.match(/aac/))this.ht=new Ei(this,this.A,this.J);else if(this.dt.match(/mpeg/))this.ht=new wi(this,this.A,this.J);else if(this.dt.match(/flac/))this.ht=new ki(this,this.A,this.J);else{if(!this.dt.match(/ogg/))throw new Error(`Unsupported Codec ${mimeType}`);this.ht=new ie(this,this.A,this.J)}for(this.bt=0,this.St=0,this.qt=0,this.At=0,this.Mt=0,this.vt=void 0,this.Pt=new Uint8Array(0);;){const t=yield*this.ht[ys]();t&&(yield t)}}*[is](t=0,s=0){let i;for(;this.Pt[Y]<=t+s;){if(i=yield,this.R)return this.Pt[at](s);i&&(this.qt+=i[Y],this.Pt=xs(this.Pt,i))}return this.Pt[at](s)}[es](t){this.St+=t,this.Pt=this.Pt[at](t)}[hs](t){this.vt=t[L][Gt],t[L][q]=t[k]>0?8*Math.round(t[$][Y]/t[k]):0,t[xt]=this.bt++,t[Xt]=this.At,t[ss]=this.Mt,t[ts]=this.Mt/this.vt*1e3,t[x]=this.ft(t[$]),this.A[ms](t[L][q],t[ts]),this.At+=t[$][Y],this.Mt+=t[Qt]}[rs](t){if(t[_]){if(t[W]){let s=t[Qt];t[_].forEach(t=>{const i=t[Qt];s0?s:0,t[k]=t[Qt]/t[L][Gt]*1e3),s-=i,this[hs](t)})}else t[Qt]=0,t[_].forEach(s=>{t[Qt]+=s[Qt],this[hs](s)});t[k]=t[Qt]/this.vt*1e3||0,t[ss]=this.Mt,t[ts]=this.Mt/this.vt*1e3||0,t[Xt]=this.At}else this[hs](t)}Et(t,s){if(this.yt){const i=[`${T}:         ${this[T]}`,`inputMimeType: ${this.dt}`,`readPosition:  ${this.St}`,`totalBytesIn:  ${this.qt}`,`${Xt}: ${this.At}`],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.Et(console.warn,t)}[as](...t){this.Et(console.error,t)}},re=_,ne=$,ae=L,oe=W,ce=lt,le=ut,ue=ss}},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(l=0;l=h)&&Object.keys(r.O).every(t=>r.O[t](i[o]))?i.splice(o--,1):(a=!1,h0&&t[l-1][2]>h;l--)t[l]=t[l-1];t[l]=[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=>385===t?"icecast-metadata-player-1.17.13.common.min.js":"icecast-metadata-player-1.17.13."+{88:"mpeg",398:"vorbis",694:"opus",731:"synaudio",762:"mediasource",993:"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"),l=0;l{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,"Tt",{value:!0})},(()=>{var t;r.g.importScripts&&(t=r.g.location+"");var s=r.g.document;if(!t&&s&&(s.currentScript&&"SCRIPT"===s.currentScript.tagName.toUpperCase()&&(t=s.currentScript.src),!t)){var i=s.getElementsByTagName("script");if(i.length)for(var e=i.length-1;e>-1&&(!t||!/^http(s?):/.test(t));)t=i[e--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r.p=t})(),(()=>{var t={792: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");i.charset="utf-8",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 l=o(r)}for(s&&s(i);c{r.E(731),r.E(762)},5);var n={};(()=>{r.d(n,{default:()=>bt});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(),l=Symbol(),u=Symbol(),d=Symbol(),y=Symbol(),f=Symbol(),m=Symbol(),p=Symbol(),w=Symbol(),g=Symbol(),b=Symbol(),S=Symbol(),q=Symbol(),A=Symbol(),M=Symbol(),v=Symbol(),P=Symbol(),E=Symbol(),T=Symbol(),_=Symbol(),C=Symbol(),I=Symbol(),R=Symbol(),x=Symbol(),$=Symbol("synced"),O=Symbol("syncing"),k=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 L{constructor(){this._t=[]}hasEventListener(t,s){return this._t.some(i=>i.type===t&&i.listener===s)}addEventListener(t,s,i={}){return this.hasEventListener(t,s)||this._t.push({type:t,listener:s,options:i}),this}removeEventListener(t,s){const i=this._t.findIndex(i=>i.type===t&&i.listener===s);return i>=0&&this._t.splice(i,1),this}removeEventListeners(){return this._t=[],this}dispatchEvent(t){return this._t.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 F{constructor(){this.Ct=0,this.It=0,this.Rt=0,this.xt=0,this.$t=0,this.Ot=0,this.kt=0}get stats(){return{totalBytesRead:this.Ct,streamBytesRead:this.It,metadataLengthBytesRead:this.Rt,metadataBytesRead:this.xt,currentBytesRemaining:this.$t,currentStreamBytesRemaining:this.Ot,currentMetadataBytesRemaining:this.kt}}set currentStreamBytesRemaining(t){this.Ot+=t}set currentMetadataBytesRemaining(t){this.kt=t}addBytes(t){this.Ct+=t,this.$t-=t}addStreamBytes(t){this.It+=t,this.Ot-=t}addMetadataLengthBytes(t){this.Rt+=t}addMetadataBytes(t){this.xt+=t,this.kt-=t}addCurrentBytesRemaining(t){this.$t+=t}}const U=()=>{};class N{constructor(t){this.Dt=0,this.Bt=0,this.Lt=new Uint8Array(0),this.Ft=[],this.Ut=0,this.Nt=new F,this.jt=t.onStream||U,this.Wt=t.onMetadata||U,this.Gt=t.onMetadataFailed||U,this.Ht=t.onError||U,this.yt=t.enableLogging||!1,this.Qt=Promise.resolve(),this.Vt=Promise.resolve(),this.wt=this.Yt(),this.wt.next()}*Yt(){for(this.Dt=1/0;;)this.zt(yield*this.Kt()),yield*this.Zt()}static Jt(...t){const s=t.reduce((t,s)=>t+s.length,0);return this.Xt(t,s)}static Xt(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.wt.next(t);s.value;s=this.wt.next())yield s.value}readAll(t){for(let s=this.wt.next(t);s.value;s=this.wt.next());}async*asyncIterator(t){for(let s=this.wt.next(t);s.value;s=this.wt.next())await this.Qt,await this.Vt,yield s.value}async asyncReadAll(t){for(let s=this.wt.next(t);s.value;s=this.wt.next())await this.Qt,await this.Vt}ts(...t){this.yt&&console.warn("icecast-metadata-js",t.reduce((t,s)=>t+"\n  "+s,"")),this.Ht(...t)}zt(t){this.Ft.push(t),this.Ut+=t.length}*Zt(){if(this.Ft.length){const t=N.Xt(this.Ft,this.Ut);this.Ft=[],this.Ut=0,this.Nt.addStreamBytes(t.length);const s={stream:t,stats:this.Nt.stats};this.Qt=this.jt(s),yield s}}*ss(t){yield*this.Zt();const s={metadata:t,stats:this.Nt.stats};this.Vt=this.Wt(s),yield s}*Kt(t=0){for(this.Bt===this.Lt.length&&(this.Lt=yield*this.es(),this.Bt=0);this.Lt.length-this.Bt[^\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.rs}*ls(){if(this.rs>0)return!0;if(!this.ns)return!1;this.ts("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.ns>Date.now();){this.Lt=N.Jt(this.Lt,yield*this.es());t:for(;i65307)return this.ts("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.Gt("ogg"),!1;const s=yield*this.Kt(27),i=yield*this.Kt(s[26]);return this.Dt=i.reduce((t,s)=>t+s,0),!0}*gs(){const t=yield*this.Kt(8);return yield*this.us(),this.Ss(/\x7fFLAC/,t.subarray(0,5))?{regex:/^[\x84|\x04]/,length:4}:this.Ss(/OpusHead/,t.subarray(0,8))?{regex:/OpusTags/,length:8}:this.Ss(/\x01vorbis/,t.subarray(0,7))?{regex:/\x03vorbis/,length:7}:void 0}*ys({regex:t,length:s}){this.Ss(t,yield*this.Kt(s))&&(yield*this.ss(yield*this.qs()))}*us(){for(;this.Dt;)yield*this.Kt()}*Kt(t){const s=yield*super.Kt(t);return this.zt(s),s}*es(){const t=yield*super.es();return this.Nt.currentStreamBytesRemaining=t.length,t}*qs(){const t=this.bs(yield*this.Kt(4));this.Nt.addMetadataBytes(4);const s=this.hs.decode(yield*this.Kt(t));this.Nt.addMetadataBytes(t);const i=this.bs(yield*this.Kt(4));this.Nt.addMetadataBytes(4);const e=[];for(let t=0;t{const i=s.indexOf(61),e=String.fromCharCode(...s.subarray(0,i)).toUpperCase(),h=this.hs.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.As=new W(t),this.Ms=new j(i)}get icyMetaInt(){return this.Ms.icyMetaInt}*iterator(t){for(const s of this.Ms.iterator(t))s.stream?yield*this.As.iterator(s.stream):yield s}readAll(t){for(const s of this.Ms.iterator(t))s.stream&&this.As.readAll(s.stream)}async*asyncIterator(t){for await(const s of this.Ms.asyncIterator(t))if(s.stream)for await(const t of this.As.asyncIterator(s.stream))yield t;else yield s}async asyncReadAll(t){for await(const s of this.Ms.iterator(t))s.stream&&await this.As.asyncReadAll(s.stream)}}class H{constructor({metadataTypes:t=["icy"],...s}={}){const i=t.includes("icy"),e=t.includes("ogg");this.vs=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.vs.icyMetaInt}*iterator(t){yield*this.vs.iterator(t)}readAll(t){this.vs.readAll(t)}async*asyncIterator(t){return yield*this.vs.asyncIterator(t)}async asyncReadAll(t){return this.vs.asyncReadAll(t)}}const Q=()=>{};class V{constructor(t,{onStream:s=Q,...i}){let e;this.Ps=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.Es=e}get icyMetaInt(){return this.Es.icyMetaInt}get readableStream(){return this.Ps}async startReading(){try{for await(const t of V.asyncIterator(this.Ps));}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.Ts=t,this._s=s,this.Cs=i,this.Is=e,this.Rs=e,this.xs=!0,this.$s=[],this.Os=[]}get metadataQueue(){return this.Os.map(({ks: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.Rs?this.$s.push(h):this.Ds(h)}getTimeByBytes(t){return this.Ts?t/(125*this.Ts):0}startQueue(t){this.Rs&&(this.$s.forEach(s=>{void 0!==t&&(s.timestamp=t),(void 0===t||s.timestampOffset>=s.timestamp)&&this.Ds(s)}),this.$s=[],this.Rs=!1)}purgeMetadataQueue(){this.Os.forEach(t=>clearTimeout(t.ks)),this.Os=[],this.$s=[],this.Rs=this.Is,this.xs=!0}Ds(t){this.Os.push(t),this.Cs(t.metadata,t.timestampOffset,t.timestamp),this.xs?(this.Bs(),this.xs=!1):t.ks=setTimeout(()=>{this.Bs()},1e3*(t.timestampOffset-t.timestamp))}Bs(){if(this.Os.length){const{metadata:t,timestampOffset:s,timestamp:i}=this.Os.shift();this._s(t,s,i)}}}var K=r(317);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.Es=t,this.Ls=s,this.initSync(),this.initQueue()}initSync(){clearTimeout(this.Fs),this.Fs=null,this.Us=null,this.Ns=!0,this.js=[],this.Ws=0,this.Gs=null,this.Hs=null,this.Qs=null}initQueue(){this.Vs=0,this.Ys=0,this.zs=0,this.Ks=[],this.Zs=0,this.Js={},this.Xs=[],this.ti=0}get buffered(){return this.Ys/this.zs-this.Ls.currentTime||0}add(t){const{crc32:s,duration:i,samples:e}=t;this.Ys+=e,this.zs=t.header.sampleRate,this.Ks.push({crc32:s,duration:i}),this.Zs+=i;let h=this.Js[s];if(h||(h=[],this.Js[s]=h),h.push(this.Vs++),this.Zs>=this.CRC_DURATION){const{crc32:t,duration:s}=this.Ks.shift();this.Zs-=s;const i=this.Js[t];i.shift(),i.length||delete this.Js[t]}this.Xs.push(t),this.ti+=i,this.ti>=this.PCM_DURATION&&(this.ti-=this.Xs.shift().duration)}addAll(t){t.forEach(t=>this.add(t))}si(t){for(const s of t)this.Ws+=s.duration,this.js.push(s)}async sync(s){if(null===this.Fs){const s=this.buffered;this.ii=t,this.Fs=setTimeout(()=>{this.Us=`Buffer underrun after syncing for ${s.toFixed(2)} seconds.`,this.ii(this.Us)},1e3*s)}return this.si(s),new Promise(async(t,s)=>{let i;null!==this.Us?s(this.Us):this.ii=s,this.Ns&&(i=this.ei()),i||(this.Ns=!1,i=await this.hi()),i?t(i):s("Old and new request do not match.")}).catch(t=>{this.Es.state!==i.STOPPING&&this.Es.state!==i.STOPPED&&this.Es[P](e.WARN,`Reconnected successfully after ${this.Es.state}.`,"Unable to sync old and new request.",t);const s=this.js;return this.initSync(),this.initQueue(),[s,D]}).then(t=>([$,k].includes(t[1])&&this.initSync(),t))}ei(){if(!this.js.length)return[[],O];const t=this.js[0].crc32,s=this.Js[t];let i,h,r;if(s){t:for(const t of s){r=t-(this.Vs-this.Ks.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.js.slice(t),$]}}}async hi(){try{const t=1,s=16,i=(t,s)=>t/s;if(!this.Gs){let h;try{h=(await r.e(731).then(r.bind(r,875))).default}catch(t){return void this.Es[P](e.WARN,"Failed to synchronize old and new stream","Missing `synaudio` dependency.")}const[n,a,o]=await this.ri(),c=o*t;if(a.samplesDecoded<=c)return[[],O];const l=new h({correlationSampleSize:c,initialGranularity:s});this.Gs=await(Z?l.syncWorkerConcurrent(n,a,Math.max(navigator.hardwareConcurrency-1,1)):l.syncWorker(n,a)),this.Gs.offsetFromEnd=i(n.samplesDecoded-this.Gs.sampleOffset,o)}const{correlation:h,offsetFromEnd:n}=this.Gs;let a=1e3*(this.buffered-n);if(-a>this.Ws)return[[],O];const o=0;if(a<0){let t=0;for(let s=0;ta;t++)s-=this.js[t].duration;this.js=this.js.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.Es[l].decodeAudioData(B(t.slice(i).map(({data:t})=>t)).buffer)};[this.Hs,this.Qs]=await Promise.all([this.Hs?this.Hs:t(this.Xs,2e3*this.buffered),t(this.js,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(){this.oi.removeAttribute("src"),this.oi.src=null,this.oi.srcObject=null,this.oi.src="data:audio/mpeg;base64,//sQxAAABFgC/SCEYACCgB9AAAAAppppVCAHBAEIgBByw9WD5+J8ufwxiDEDsMfE+D4fwG/RUGCx6VO4awVxV3qDtQNPiXKnZUNSwKuUDR6IgaeoGg7Fg6pMQU1FMy4xMDCqqqqqqqr/+xLEB4PAAAGkAAAAIAAANIAAAASqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqo=",this.oi.loop=!0}get syncStateUpdate(){return this.yi}get syncState(){return this.fi}set syncState(t){this.fi=t,this.mi&&this.mi(t),this.yi=new Promise(t=>{this.mi=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.pi}set icecastMetadataQueue(t){this.pi=t}get codecUpdateQueue(){return this.wi}set codecUpdateQueue(t){this.wi=t}get metadataQueue(){return this.pi?this.pi.metadataQueue:[]}gi(){this.pi.startQueue(this.bi),this.wi.startQueue(this.bi)}async Si(){this.syncState=$,this.syncFrames=[],this.syncDelay=null,this.qi=new X(this.Es,this)}async start(t){let s;this.bi=t,[e.RETRY,e.SWITCH].forEach(t=>this.Es.addEventListener(t,this.di));const h=new Promise(t=>{s=t,[i.PLAYING,i.STOPPING].forEach(t=>this.Es.addEventListener(t,s,{once:!0}))}).finally(()=>{[i.PLAYING,i.STOPPING].forEach(t=>this.Es.removeEventListener(t,s))});await h}async end(){[e.RETRY,e.SWITCH].forEach(t=>this.Es.removeEventListener(t,this.di)),this.pi.purgeMetadataQueue(),this.wi.purgeMetadataQueue()}onStream(t){return t}onMetadata(t){this.pi.addMetadata(t,this.metadataTimestamp,this.currentTime)}onCodecUpdate(t,s){const i=this.currentTime;s{this.Ai||this.end()}),this.Si()}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.Mi?(this.Mi.totalDuration+this.Pi)/1e3:0}get currentTime(){return this.Ei&&(performance.now()-this.Ei)/1e3}get waiting(){return new Promise(t=>{this.oi.addEventListener("waiting",t,{once:!0})})}async Si(){super.Si(),this.Mi=null,this.Ei=0,this.Pi=0,this.Ai=!1}async start(t){const s=super.start(t);this.Ti=performance.now(),this.oi.loop=!1,this.oi.src=null,this.oi.srcObject=null,this.oi.src=this.ni,this.Es.state!==i.STOPPING&&this.Es.state!==i.STOPPED&&(this.oi.addEventListener("playing",()=>{this.Ei=performance.now(),this.Pi=performance.now()-this.Ti,this.gi(),this.Es[P](e.PLAY)},{once:!0}),this.Es[P](e.PLAY_READY),this.Ai=!0),await s}async end(){super.end(),this.oi.src=null,this.oi.srcObject=null,this.Si()}onStream(t){this.Mi=t[t.length-1]||this.Mi,this.syncState===D&&(this.syncState=D)}}class it extends tt{constructor(t,s,i,e,h){super(t,s,i,e,h),this._i=r.e(762).then(r.bind(r,448)),this.Ci(),this.Si()}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"'],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.Ii&&this.Ii.sourceBuffers.length&&Math.max(this.Ii.sourceBuffers[0].timestampOffset,this.Ii.sourceBuffers[0].buffered.length?this.Ii.sourceBuffers[0].buffered.end(0):0)||0}get currentTime(){return this.oi.currentTime}get waiting(){return new Promise(t=>{this.oi.addEventListener("waiting",t,{once:!0})})}get changingContainer(){return this.Ri}useNextContainer(){const t=this.xi.indexOf(this.$i)+1;this.$i=this.xi[t],this.Ri=!0,this.enablePlayButton(),this.Si(),this.start().then(()=>this.Ri=!1)}async Ci(){const t=new Set;let s;this.xi=[],this.Ri=!1,this.$i=new Promise(t=>{s=t});const i=[[()=>this.dt,"raw"],[async()=>(await this._i).getWrappedMimeType(this.tt,"fmp4"),"fmp4"],[async()=>(await this._i).getWrappedMimeType(this.tt,"webm"),"webm"]];for await(const e of i){const i=await e[0](),h=e[1];MediaSource.isTypeSupported(i)&&!t.has(i)&&(s&&(s(h),s=null),t.add(i),this.xi.push(h))}}async Si(){super.Si(),this.Oi=[],this.Ai=!1,this.ki=!1,this.Di=new Promise(t=>{this.Bi=t}),this.Li=new Promise(t=>{this.Fi=t});const t=await this.$i;this.$i=t,this.Ui=this.Ni(this.dt,this.tt),await this.Li}async start(t){const s=super.start(t);await this.Di,await this.ji(),await s}async end(){super.end(),await this.Si()}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.qi.initSync(),this.syncState=O;case O:[this.syncFrames,this.syncState,this.syncDelay]=await this.qi.sync(t),t=this.syncFrames}switch(this.syncState){case k:break;case $:await this.Li,await this.Ui(t),this.qi.addAll(t)}}}Ni(t,s){if(this.$i)return"raw"===this.$i?(this.Wi(t),async t=>this.Gi(B(t.map(t=>t.data)))):(this.Hi(t,s,this.$i).then(()=>this.Wi(this.Qi.mimeType)),t.match(/ogg/)?async i=>{let e=[];for await(const h of i){if(this.ki!==h.isLastPage)if(h.isLastPage)this.ki=!0;else{await this.Gi(B(e)),e=[];await this.ai;await this.Hi(t,s,this.$i),this.ki=!1}e.push(...this.Qi.iterator([h]))}await this.Gi(B(e))}:async t=>this.Gi(B([...this.Qi.iterator(t)])));this.Es[P](e.PLAYBACK_ERROR,`Media Source Extensions API in your browser does not support ${t} or ${this.Qi.mimeType}.See: https://caniuse.com/mediasource and https://developer.mozilla.org/en-US/docs/Web/API/Media_Source_Extensions_API`)}async Hi(t,s,i){this.Qi=new(await this._i).default(t,{codec:s,preferredContainer:i})}Wi(t){this.Ii=new MediaSource,this.Bi(),this.Ii.addEventListener("sourceopen",()=>{this.Es.state!==i.STOPPED&&this.Es.state!==i.STOPPING&&(this.Ii.addSourceBuffer(t).mode="sequence"),this.Vi=0,this.Fi()},{once:!0})}async ji(){this.oi.loop=!1,this.oi.src=URL.createObjectURL(this.Ii),await this.Li}async Yi(){return new Promise(t=>{const s=this.Ii.sourceBuffers[0];s.updating?s.addEventListener("updateend",t,{once:!0}):t()})}async Gi(t){if(this.Es[P](e.STREAM,t),this.Ii.sourceBuffers.length||this.Es[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.Es.state!==i.STOPPING&&this.Ii.sourceBuffers.length){this.Oi.push(t);try{for(;this.Oi.length;)this.Ii.sourceBuffers[0].appendBuffer(this.Oi.shift()),await this.Yi()}catch(t){if("QuotaExceededError"!==t.name)throw t}this.Ai||(this.ci<=this.metadataTimestamp?(this.oi.addEventListener("playing",()=>{this.gi(),this.Es[P](e.PLAY)},{once:!0}),this.Es[P](e.PLAY_READY),this.Ai=!0):this.Es[P](e.BUFFER,this.metadataTimestamp)),this.oi.currentTime>5+this.ci&&this.Vi+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.Ki/1e3}get currentTime(){return(performance.now()-this.Zi)/1e3||0}get waiting(){return this.Ji}Xi(t){let s;this.te+=t,s=setTimeout(()=>{this.te-=t,this.se.delete(s),this.se.size||this.ie()},this.te),this.se.add(s)}ie(){this.ee&&this.ee(),this.Ji=new Promise(t=>{this.ee=t})}he(){this.se&&this.se.forEach(t=>clearTimeout(t)),this.se=new Set,this.te=0,this.ie()}async re(){let t;this.ne=new Promise(t=>{this.ae=t});try{switch(this.tt){case"mpeg":const{MPEGDecoderWebWorker:s}=await Promise.all([r.e(385),r.e(88)]).then(r.bind(r,121));t=s;break;case"opus":const{OpusDecoderWebWorker:i}=await Promise.all([r.e(385),r.e(694)]).then(r.bind(r,978));t=i;break;case"flac":const{FLACDecoderWebWorker:e}=await Promise.all([r.e(385),r.e(993)]).then(r.bind(r,655));t=e;break;case"vorbis":const{OggVorbisDecoderWebWorker:h}=await Promise.all([r.e(385),r.e(398)]).then(r.bind(r,994));t=h}}catch(t){return void this.Es[P](e.PLAYBACK_ERROR,`Missing \`webaudio-${this.tt}\` dependency.`,`Unable to playback playback \`${this.tt}\` audio.`)}if(t){const s=await this.ai;this.ae(),this.oe=new t(s)}else this.Es[P](e.PLAYBACK_ERROR,"Unsupported `webaudio` playback codec: "+this.tt)}async Si(){super.Si(),this.Ki=0,this.ce=0,this.le=0,this.vt=0,this.Zi=void 0,this.Ai=!1,this.he(),this.ue=new Promise(t=>{this.de=t})}async start(t){this.oe||await this.re();const s=super.start(t);this.de(),await s}async end(){super.end(),this.oe&&(this.oe.terminate(),this.oe=null),this.ye&&this.ye.stream.getTracks().forEach(t=>this.ye.stream.removeTrack(t)),this.Si()}async onStream(t){if("vorbis"!==this.tt)switch(t=t.flatMap(t=>t.codecFrames||t),this.syncState){case D:this.qi.initSync(),this.syncState=O;case O:[this.syncFrames,this.syncState,this.syncDelay]=await this.qi.sync(t),t=this.syncFrames}switch(this.syncState){case k:break;case $:t.length&&(this.Ki=t[t.length-1].totalDuration,this.fe(t))}}async fe(t){if(await this.ne,this.oe){let s;await this.oe.ready,"vorbis"===this.tt?s=this.oe.decodeOggPages(t):(s=this.oe.decodeFrames(t.map(t=>t.data)),this.qi.addAll(t)),s.then(t=>this.me(t))}}async me({channelData:t,samplesDecoded:s,sampleRate:h}){if(await this.ue,this.Es.state!==i.STOPPING&&this.Es.state!==i.STOPPED&&s){this.Es[P](e.STREAM,{channelData:t,samplesDecoded:s,sampleRate:h}),this.vt||(this.vt=h,this.ye=this.zi.createMediaStreamDestination(),this.ye.channelCount=this.zi.destination.maxChannelCount,this.oi.loop=!1,this.oi.srcObject=this.ye.stream);const i=this.zi.createBuffer(t.length,s,this.vt);t.forEach((t,s)=>i.getChannelData(s).set(t));const r=this.zi.createBufferSource();r.buffer=i,r.connect(this.ye);const n=100,a=this.ce*n+this.le,o=Math.round(this.zi.currentTime*this.vt*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.ni}get player(){return this.Ls}get playbackMethod(){return this.ge}get icyMetaInt(){return this.Me&&this.Me.icyMetaInt}async playStream(){return this.fetchStream().then(async t=>(this.Es[P](e.STREAM_START),this.readIcecastResponse(t).finally(()=>{this.Es[P](e.STREAM_END)}))).catch(t=>{if(this.Es.state!==i.SWITCHING)throw t})}async switchStream(){this.Es.state!==i.PLAYING&&(this.Ae(),await this.qe);const t=s.get(this.Es);t[x]=i.SWITCHING,t[R].abort(),t[R]=new AbortController}async fetchStream(){const t=s.get(this.Es);this.ni=t[C].next().value;const i=t[I]?{"Icy-MetaData":1}:{};if(i.Range="bytes=0-",t[A]){const s=t[A];i.Authorization="Basic "+btoa(s.user+":"+s.password)}const e=()=>fetch(this.ni,{method:"GET",headers:i,signal:t[R].signal}),h=await e().catch(t=>{if("TypeError"===t.name&&("Load failed"===t.message||"Request header field Range is not allowed by Access-Control-Allow-Headers."===t.message))return delete i.Range,e();throw t});if(!h.ok){const t=new Error(`${h.status} received from ${h.url}`);throw t.name="HTTP Response Error",t}return h}async readIcecastResponse(t){const i=t.headers.get("content-type"),h=s.get(this.Es);let r;const n=new Promise(t=>{r=t}),a=new Promise(t=>{this.I=new K.Ay(i,{onCodec:t,onCodecHeader:r,onCodecUpdate:this.pe&&((...t)=>this.Ls.onCodecUpdate(...t)),enableLogging:this.yt})});this.Me=new V(t,{onMetadata:async t=>{this.Ls.onMetadata(t)},onStream:async({stream:t})=>{this.Es[P](e.STREAM,t);const s=[...this.I.parseChunk(t)];if(this.Ls.isAudioPlayer){const t=[...this.Se,...s];this.Se=[],await this.Ls.onStream(t)}else this.Se.push(...s)},onError:(...t)=>this.Es[P](e.WARN,...t),metadataTypes:h[o],icyCharacterEncoding:h[f],icyDetectionTimeout:h[m],...h[y]?{icyMetaInt:h[y]}:{}});const c=this.Me.startReading(),l=await a;this.Ls.isAudioPlayer||([this.Ls,this.ge]=this.ve(i,l,n)),this.Ls.syncState===$?this.Ls.start():await this.Pe(i,l,n),await c}async Pe(t,s,e){let h,r,n=!1,a=!1;const o=this.Ls,c=this.Ls.icecastMetadataQueue,l=this.Ls.codecUpdateQueue;this.be(),o.icecastMetadataQueue=this.pi,o.codecUpdateQueue=this.wi;const u=()=>{a=!0,this.Es.state===i.STOPPING&&this.Es.state===i.STOPPED||(o.icecastMetadataQueue.purgeMetadataQueue(),o.codecUpdateQueue.purgeMetadataQueue(),this.Ls.start(Math.max(0,o.syncDelay/1e3)).then(()=>o.end()).then(r))};this.Ae=()=>{n=!0,this.pi.purgeMetadataQueue(),this.wi.purgeMetadataQueue(),this.Ls.icecastMetadataQueue=c,this.Ls.codecUpdateQueue=l,void 0===h||a||(clearTimeout(h),u())};const d=()=>this.Ls.syncStateUpdate.then(a=>{if(n)r();else switch(a){case O:return d();case $:this.pi.purgeMetadataQueue(),this.wi.purgeMetadataQueue(),this.Ls.icecastMetadataQueue=c,this.Ls.codecUpdateQueue=l,this.Es.state===i.STOPPING&&this.Es.state===i.STOPPED||(this.Es[x]=i.PLAYING),r();break;case k:case D:o.icecastMetadataQueue=c,o.codecUpdateQueue=l,[this.Ls,this.ge]=this.ve(t,s,e),this.Se.push(...o.syncFrames),h=setTimeout(u,Math.max(o.syncDelay,0))}});let y;this.qe=new Promise(t=>{r=t,y=()=>{this.Ae(),r()},this.Es.addEventListener(i.STOPPING,y,{once:!0}),d()}).finally(()=>{this.Es.removeEventListener(i.STOPPING,y)})}be(){this.pi=new z({onMetadataUpdate:(...t)=>this.Es[P](e.METADATA,...t),onMetadataEnqueue:(...t)=>this.Es[P](e.METADATA_ENQUEUE,...t),paused:!0}),this.wi=new z({onMetadataUpdate:(...t)=>this.Es[P](e.CODEC_UPDATE,...t),paused:!0})}ve(t,i,e){const{[s.get(this.Es)[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.Es,this.ni,t,i,e),n.icecastMetadataQueue=this.pi,n.codecUpdateQueue=this.wi;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=L}const nt=Symbol(),at=Symbol(),ot=Symbol(),ct=Symbol(),lt=Symbol(),ut=Symbol(),dt=Symbol(),yt=Symbol(),ft=Symbol(),mt=Symbol(),pt=Symbol(),wt=Symbol(),gt=Symbol();class bt extends rt{static*[M](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",[A]:s.authentication??i[A]};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]:bt[M](this),[u]:r.audioElement||new Audio,...bt[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)[u].removeEventListener("waiting",s.get(this)[yt]);try{s.get(this)[u].pause()}catch(t){s.get(this)[dt](t)}try{s.get(this)[at]=s.get(this)[nt].player.end()}catch{}},[lt]:()=>{this[gt](lt)},[ct]:()=>{this.stop()},[dt]:t=>{const h={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"},r=t?.target?.error||t,n=s.get(this)[nt].player;n?.useNextContainer&&!n?.changingContainer&&r?.code>2&&this.state!==i.STOPPING&&this.state!==i.STOPPED&&n.useNextContainer(),this.state===i.STOPPED||n?.changingContainer||this[P](e.PLAYBACK_ERROR,"The audio element encountered an error.",h[r?.code]||t)},[ut]:()=>{const t=s.get(this)[u];(this.state===i.LOADING||!t.loop&&this.state!==i.STOPPING&&this.state!==i.STOPPED)&&t.play().then(()=>{this[x]=i.PLAYING}).catch(t=>{s.get(this)[dt](t)})},[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)[u]}get[l](){return bt.constructor[l]}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)[u];t.addEventListener("pause",s.get(this)[ct]),t.addEventListener("play",s.get(this)[lt]),t.addEventListener("error",s.get(this)[dt]),this.addEventListener(e.PLAY_READY,s.get(this)[ut])}async detachAudioElement(){const t=s.get(this)[u];t.removeEventListener("pause",s.get(this)[ct]),t.removeEventListener("play",s.get(this)[lt]),t.removeEventListener("error",s.get(this)[dt]),this.removeEventListener(e.PLAY_READY,s.get(this)[ut]),await this.stop()}async play(){return this[gt]()}async[gt](t){if(this.state===i.STOPPED){t!==lt&&this.audioElement.paused&&this.audioElement.play();const h=new Promise(t=>{this.addEventListener(e.PLAY,t,{once:!0})}),r=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 n=async()=>s.get(this)[nt].playStream().then(async()=>{if(this.state===i.SWITCHING)return this[P](e.SWITCH),n();this.state!==i.STOPPING&&this.state!==i.STOPPED&&(await h,await r,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),n();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,n().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 h}}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})}),s.get(this)[nt].player.enablePlayButton())}async switchEndpoint(t,e){if(this.state!==i.STOPPED&&this.state!==i.STOPPING){const i=s.get(this);return Object.assign(i,bt[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)[u].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 St=window.AudioContext||window.webkitAudioContext;if(St&&!bt.constructor[l]){bt.constructor[l]="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 St({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),bt.constructor[l]=e};s.forEach(t=>document.addEventListener(t,i))}})(),n=r.O(n),IcecastMetadataPlayer=n.default})();
//# sourceMappingURL=icecast-metadata-player-1.17.13.main.min.js.map