!function(t){vare={};functionr(n){if(e[n])returne[n].exports;vari=e[n]={i:n,l:!1,exports:{}};returnt[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeofSymbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)returnt;if(4&e&&"object"==typeoft&&t&&t.__esModule)returnt;varn=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeoft)for(variint)r.d(n,i,function(e){returnt[e]}.bind(null,i));returnn},r.n=function(t){vare=t&&t.__esModule?function(){returnt.default}:function(){returnt};returnr.d(e,"a",e),e},r.o=function(t,e){returnObject.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){(function(t){conste=r(6),n=r(7),o=r(8);addEventListener("fetch",t=>{t.respondWith(asyncfunction(t){constr=newe;r.get("/track/.*",()=>u("track",t)),r.get("/album/.*",()=>u("album",t)),r.get("/playlist/.*",()=>u("playlist",t));returnawaitr.route(t)}(t.request))});consts=[106,111,54,97,101,121,54,104,97,105,100,50,84,101,105,104];consta={64:"10",128:"1",320:"3",flac:"9",misc:"0"};asyncfunctionu(e,r){if(access_token=awaitKV.get("access_token"),null===access_token){constt=awaitfetch("https://connect.deezer.com/oauth/access_token.php?grant_type=client_credentials&client_id=447462&client_secret=a83bf7f38ad2f137e444727cfc3775cf&output=json"),e=awaitt.json();if(void0!==e.error)returnnewResponse("Couldn't get access token from Deezer",{status:500,headers:{"content-type":"text/plain"}});access_token=e.access_token,awaitKV.put("access_token",access_token,{expirationTtl:Number(e.expires)})}constn=newURL(r.url),i=n.pathname.split("/")[2];if(""===i)returnnewResponse("ID needs to be specified",{status:400,headers:{"content-type":"text/plain"}});if(format=n.searchParams.get("f"),null===format)format="320";elseif(format=format.toLowerCase(),void0===a[format]){if(index=Object.values(a).indexOf(format),-1===index)returnnewResponse("Invalid format",{status:400,headers:{"content-type":"text/plain"}});format=Object.keys(a)[index]}switch(tagging="true"===n.searchParams.get("t")&&("128"===format||"320"===format||"misc"===format),e){case"track":returnawaitasyncfunction(e,r,n,i){consts=awaitfetch(`https://api.deezer.com/track/${e}?access_token=${n}`),a=awaits.json();if(void0!==a.error)returnnewResponse(JSON.stringify(a.error),{status:403,headers:{"content-type":"application/json"}});if(result=awaith(a,r),"object"==typeofresult)returnresult;if(i){conste=awaitfetch(result);if(200!==e.status)returnnewResponse("Couldn't get track stream",{status:403,headers:{"content-type":"text/plain"}});constr=newo(t.alloc(0));if(r.padding=0,r.setFrame("TIT2",a.title).setFrame("TALB",a.album.title),void0!==a.contributors){contr_list=[];for(consttofa.contributors)contr_list.push(t.name);r.setFrame("TPE1",contr_list)}if(void0!==a.release_date&&r.setFrame("TYER",a.release_date.split("-")[0]),void0!==a.album.cover_xl){constt=awaitfetch(a.album.cover_xl),e=awaitt.arrayBuffer();r.setFrame("APIC",{type:3,data:e,description:"cover"})}r.addTag();let{readable:n,writable:i}=newTransformStream;consts=i.getWriter();returns.write(r.arrayBuffer),s.releaseLock(),e.body.pipeTo(i),newResponse(n,{status:200,headers:{"content-type":"audio/mpeg"}})}returnnewResponse(null,{status:302,headers:{location:result}})}(i,format,access_token,tagging);case"album":case"playlist":returnawaitasyncfunction(t,e,r,n,i){consto=awaitfetch(`https://api.deezer.com/${t}/${e}?access_token=${n}&limit=-1`),s=awaito.json();if(void0!==s.error)returnnewResponse(JSON.stringify(s.error),{status:403,headers:{"content-type":"application/json"}});vara="#EXTM3U\n";for(consttofs.tracks.data){lete;if(i)e=`https://dz.uhwot.workers.dev/track/${t.id}?f=${r}&t=true`;elseif(e=awaith(t,r),"object"==typeofe)returne;a+=`#EXTINF:${t.duration},
varn=r(3),i=r(4),o=r(5);functions(){returnu.TYPED_ARRAY_SUPPORT?2147483647:1073741823}functiona(t,e){if(s()<e)thrownewRangeError("Invalid typed array length");returnu.TYPED_ARRAY_SUPPORT?(t=newUint8Array(e)).__proto__=u.prototype:(null===t&&(t=newu(e)),t.length=e),t}functionu(t,e,r){if(!(u.TYPED_ARRAY_SUPPORT||thisinstanceofu))returnnewu(t,e,r);if("number"==typeoft){if("string"==typeofe)thrownewError("If encoding is specified then the first argument must be a string");returnc(this,t)}returnh(this,t,e,r)}functionh(t,e,r,n){if("number"==typeofe)thrownewTypeError('"value" argument must not be a number');return"undefined"!=typeofArrayBuffer&&einstanceofArrayBuffer?function(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)thrownewRangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))thrownewRangeError("'length' is out of bounds");e=void0===r&&void0===n?newUint8Array(e):void0===n?newUint8Array(e,r):newUint8Array(e,r,n);u.TYPED_ARRAY_SUPPORT?(t=e).__proto__=u.prototype:t=l(t,e);returnt}(t,e,r,n):"string"==typeofe?function(t,e,r){"string"==typeofr&&""!==r||(r="utf8");if(!u.isEncoding(r))thrownewTypeError('"encoding" must be a valid string encoding');varn=0|g(e,r),i=(t=a(t,n)).write(e,r);i!==n&&(t=t.slice(0,i));returnt}(t,e,r):function(t,e){if(u.isBuffer(e)){varr=0|p(e.length);return0===(t=a(t,r)).length||e.copy(t,0,0,r),t}if(e){if("undefined"!=typeofArrayBuffer&&e.bufferinstanceofArrayBuffer||"length"ine)return"number"!=typeofe.length||(n=e.length)!=n?a(t,0):l(t,e);if("Buffer"===e.type&&o(e.data))returnl(t,e.data)}varn;thrownewTypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}functionf(t){if("number"!=typeoft)thrownewTypeError('"size" argument must be a number');if(t<0)thrownewRangeError('"size" argument must not be negative')}functionc(t,e){if(f(e),t=a(t,e<0?0:0|p(e)),!u.TYPED_ARRAY_SUPPORT)for(varr=0;r<e;++r)t[r]=0;returnt}functionl(t,e){varr=e.length<0?0:0|p(e.length);t=a(t,r);for(varn=0;n<r;n+=1)t[n]=255&e[n];returnt}functionp(t){if(t>=s())thrownewRangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return0|t}functiong(t,e){if(u.isBuffer(t))returnt.length;if("undefined"!=typeofArrayBuffer&&"function"==typeofArrayBuffer.isView&&(ArrayBuffer.isView(t)||tinstanceofArrayBuffer))returnt.byteLength;"string"!=typeoft&&(t=""+t);varr=t.length;if(0===r)return0;for(varn=!1;;)switch(e){case"ascii":case"latin1":case"binary":returnr;case"utf8":case"utf-8":casevoid0:returnF(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return2*r;case"hex":returnr>>>1;case"base64":returnD(t).length;default:if(n)returnF(t).length;e=(""+e).toLowerCase(),n=!0}}functiond(t,e,r){varn=!1;if((void0===e||e<0)&&(e=0),e>this.length)return"";if((void0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":returnC(this,e,r);case"utf8":case"utf-8":returnP(this,e,r);case"ascii":returnS(this,e,r);case"latin1":case"binary":returnU(this,e,r);case"base64":returnR(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":returnB(this,e,r);default:if(n)thrownewTypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}functiony(t,e,r){varn=t[e];t[e]=t[r],t[r]=n}functionw(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeofr?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}elseif(r<0){if(!i)return-1;r=0}if("string"==typeofe&&(e=u.from(e,n)),u.isBuffer(e))return0===e.length?-1:m(t,e,r,n,i);if("number"==typeofe)returne&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeofUint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):m(t,[e],r,n,i);thrownewTypeError("val must be string, number or Buffer")}functionm(t,e,r,n,i){varo,s=1,a=t.length,u=e.length;if(void0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"
e.read=function(t,e,r,n,i){varo,s,a=8*i-n-1,u=(1<<a)-1,h=u>>1,f=-7,c=r?i-1:0,l=r?-1:1,p=t[e+c];for(c+=l,o=p&(1<<-f)-1,p>>=-f,f+=a;f>0;o=256*o+t[e+c],c+=l,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+t[e+c],c+=l,f-=8);if(0===o)o=1-h;else{if(o===u)returns?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=h}return(p?-1:1)*s*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){vars,a,u,h=8*o-i-1,f=(1<<h)-1,c=f>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,g=n?1:-1,d=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+c>=1?l/u:l*Math.pow(2,1-c))*u>=2&&(s++,u/=2),s+c>=f?(a=0,s=f):s+c>=1?(a=(e*u-1)*Math.pow(2,i),s+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,i),s=0));i>=8;t[r+p]=255&a,p+=g,a/=256,i-=8);for(s=s<<i|a,h+=i;h>0;t[r+p]=255&s,p+=g,s/=256,h-=8);t[r+p-g]|=128*d}},function(t,e){varr={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},function(t,e){constr=t=>e=>e.method.toLowerCase()===t.toLowerCase(),n=r("connect"),i=r("delete"),o=r("get"),s=r("head"),a=r("options"),u=r("patch"),h=r("post"),f=r("put"),c=r("trace"),l=t=>e=>{constr=newURL(e.url).pathname;return(r.match(t)||[])[0]===r};t.exports=class{constructor(){this.routes=[]}handle(t,e){returnthis.routes.push({conditions:t,handler:e}),this}connect(t,e){returnthis.handle([n,l(t)],e)}delete(t,e){returnthis.handle([i,l(t)],e)}get(t,e){returnthis.handle([o,l(t)],e)}head(t,e){returnthis.handle([s,l(t)],e)}options(t,e){returnthis.handle([a,l(t)],e)}patch(t,e){returnthis.handle([u,l(t)],e)}post(t,e){returnthis.handle([h,l(t)],e)}put(t,e){returnthis.handle([f,l(t)],e)}trace(t,e){returnthis.handle([c,l(t)],e)}all(t){returnthis.handle([],t)}route(t){conste=this.resolve(t);returne?e.handler(t):newResponse("resource not found",{status:404,statusText:"not found",headers:{"content-type":"text/plain"}})}resolve(t){returnthis.routes.find(e=>!(e.conditions&&(!Array.isArray(e)||e.conditions.length))||("function"==typeofe.conditions?e.conditions(t):e.conditions.every(e=>e(t))))}}},function(t,e,r){