PageSourceSearch

https://mijn.bumastemra.nl/assets/vendor_music_metadata-D3xMkSJ4.js

js bumastemra.nl collected 2026-09-24 09:27:19 UTC 215,595 bytes, 5 lines download raw bytes

1var Ji=Object.defineProperty;var Qi=(a,e,t)=>e in a?Ji(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var Bt=(a,e,t)=>Qi(a,typeof e!="symbol"?e+"":e,t);import{bu as xe,bv as C,bw as en}from"./vendor-Pp8zYbt5.js";import{_ as K}from"./vendor_tanstack-BeOc0gtu.js";import"./vendor_react-Df7YFFEC.js";import"./vendor_wry-D7cCfN0i.js";import"./vendor_babel-KcPfSZrU.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};a.SENTRY_RELEASE={id:"57166"};var e=new a.Error().stack;e&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[e]="e31714cd-4f35-49b5-9761-9742dfacc5aa",a._sentryDebugIdIdentifier="sentry-dbid-e31714cd-4f35-49b5-9761-9742dfacc5aa")}catch(t){}})();const tn="End-Of-Stream";class E extends Error{constructor(){super(tn),this.name="EndOfStreamError"}}class an extends Error{constructor(e="The operation was aborted"){super(e),this.name="AbortError"}}class vi{constructor(){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(e,t=!1){const i=await this.read(e,t);return this.peekQueue.push(e.subarray(0,i)),i}async read(e,t=!1){if(e.length===0)return 0;let i=this.readFromPeekBuffer(e);if(this.endOfStream||(i+=await this.readRemainderFromStream(e.subarray(i),t)),i===0&&!t)throw new E;return i}readFromPeekBuffer(e){let t=e.length,i=0;for(;this.peekQueue.length>0&&t>0;){const n=this.peekQueue.pop();if(!n)throw new Error("peekData should be defined");const r=Math.min(n.length,t);e.set(n.subarray(0,r),i),i+=r,t-=r,r<n.length&&this.peekQueue.push(n.subarray(r))}return i}async readRemainderFromStream(e,t){let i=0;for(;i<e.length&&!this.endOfStream;){if(this.interrupted)throw new an;const n=await this.readFromStream(e.subarray(i),t);if(n===0)break;i+=n}if(!t&&i<e.length)throw new E;return i}}class nn extends vi{constructor(e){super(),this.reader=e}async abort(){return this.close()}async close(){this.reader.releaseLock()}}class rn extends nn{async readFromStream(e,t){if(e.length===0)return 0;const i=await this.reader.read(new Uint8Array(e.length),{min:t?void 0:e.length});return i.done&&(this.endOfStream=i.done),i.value?(e.set(i.value),i.value.length):0}}class Da extends vi{constructor(e){super(),this.reader=e,this.buffer=null}writeChunk(e,t){const i=Math.min(t.length,e.length);return e.set(t.subarray(0,i)),i<t.length?this.buffer=t.subarray(i):this.buffer=null,i}async readFromStream(e,t){if(e.length===0)return 0;let i=0;for(this.buffer&&(i+=this.writeChunk(e,this.buffer));i<e.length&&!this.endOfStream;){const n=await this.reader.read();if(n.done){this.endOfStream=!0;break}n.value&&(i+=this.writeChunk(e.subarray(i),n.value))}if(!t&&i===0&&this.endOfStream)throw new E;return i}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}}function sn(a){try{const e=a.getReader({mode:"byob"});return e instanceof ReadableStreamDefaultReader?new Da(e):new rn(e)}catch(e){if(e instanceof TypeError)return new Da(a.getReader());throw e}}class pa{constructor(e){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=e==null?void 0:e.onClose,e!=null&&e.abortSignal&&e.abortSignal.addEventListener("abort",()=>{this.abort()})}async readToken(e,t=this.position){const i=new Uint8Array(e.len);if(await this.readBuffer(i,{position:t})<e.len)throw new E;return e.get(i,0)}async peekToken(e,t=this.position){const i=new Uint8Array(e.len);if(await this.peekBuffer(i,{position:t})<e.len)throw new E;return e.get(i,0)}async readNumber(e){if(await this.readBuffer(this.numBuffer,{length:e.len})<e.len)throw new E;return e.get(this.numBuffer,0)}async peekNumber(e){if(await this.peekBuffer(this.numBuffer,{length:e.len})<e.len)throw new E;return e.get(this.numBuffer,0)}async ignore(e){if(this.fileInfo.size!==void 0){const t=this.fileInfo.size-this.position;if(e>t)return this.position+=t,t}return this.position+=e,e}async close(){var e;await this.abort(),await((e=this.onClose)==null?void 0:e.call(this))}normalizeOptions(e,t){if(!this.supportsRandomAccess()&&t&&t.position!==void 0&&t.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");return{mayBeLess:!1,offset:0,length:e.length,position:this.position,...t}}abort(){return Promise.resolve()}}const on=256e3;class cn extends pa{constructor(e,t){var i;super(t),this.streamReader=e,this.fileInfo=(i=t==null?void 0:t.fileInfo)!=null?i:{}}async readBuffer(e,t){const i=this.normalizeOptions(e,t),n=i.position-this.position;if(n>0)return await this.ignore(n),this.readBuffer(e,t);if(n<0)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");if(i.length===0)return 0;const r=await this.streamReader.read(e.subarray(0,i.length),i.mayBeLess);if(this.position+=r,(!t||!t.mayBeLess)&&r<i.length)throw new E;return r}async peekBuffer(e,t){const i=this.normalizeOptions(e,t);let n=0;if(i.position){const r=i.position-this.position;if(r>0){const s=new Uint8Array(i.length+r);return n=await this.peekBuffer(s,{mayBeLess:i.mayBeLess}),e.set(s.subarray(r)),n-r}if(r<0)throw new Error("Cannot peek from a negative offset in a stream")}if(i.length>0){try{n=await this.streamReader.peek(e.subarray(0,i.length),i.mayBeLess)}catch(r){if(t!=null&&t.mayBeLess&&r instanceof E)return 0;throw r}if(!i.mayBeLess&&n<i.length)throw new E}return n}async ignore(e){const t=Math.min(on,e),i=new Uint8Array(t);let n=0;for(;n<e;){const r=e-n,s=await this.readBuffer(i,{length:Math.min(t,r)});if(s<0)return s;n+=s}return n}abort(){return this.streamReader.abort()}async close(){return this.streamReader.close()}supportsRandomAccess(){return!1}}class ln extends pa{constructor(e,t){var i;super(t),this.uint8Array=e,this.fileInfo={...(i=t==null?void 0:t.fileInfo)!=null?i:{},size:e.length}}async readBuffer(e,t){t!=null&&t.position&&(this.position=t.position);const i=await this.peekBuffer(e,t);return this.position+=i,i}async peekBuffer(e,t){const i=this.normalizeOptions(e,t),n=Math.min(this.uint8Array.length-i.position,i.length);if(!i.mayBeLess&&n<i.length)throw new E;return e.set(this.uint8Array.subarray(i.position,i.position+n)),n}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}}class dn extends pa{constructor(e,t){var i;super(t),this.blob=e,this.fileInfo={...(i=t==null?void 0:t.fileInfo)!=null?i:{},size:e.size,mimeType:e.type}}async readBuffer(e,t){t!=null&&t.position&&(this.position=t.position);const i=await this.peekBuffer(e,t);return this.position+=i,i}async peekBuffer(e,t){const i=this.normalizeOptions(e,t),n=Math.min(this.blob.size-i.position,i.length);if(!i.mayBeLess&&n<i.length)throw new E;const r=await this.blob.slice(i.position,i.position+n).arrayBuffer();return e.set(new Uint8Array(r)),n}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}}function Ci(a,e){const t=sn(a),i=e!=null?e:{},n=i.onClose;return i.onClose=async()=>
1{if(await t.close(),n)return n()},new cn(t,i)}function Ce(a,e){return new ln(a,e)}function Ei(a,e){return new dn(a,e)}const Ai={128:"€",130:"‚",131:"ƒ",132:"„",133:"…",134:"†",135:"‡",136:"ˆ",137:"‰",138:"Š",139:"‹",140:"Œ",142:"Ž",145:"‘",146:"’",147:"“",148:"”",149:"•",150:"–",151:"—",152:"˜",153:"™",154:"š",155:"›",156:"œ",158:"ž",159:"Ÿ"},Kt={};for(const[a,e]of Object.entries(Ai))Kt[e]=Number.parseInt(a,10);let Je,Qe;function mn(){if(!(typeof globalThis.TextDecoder>"u"))return Je!=null?Je:Je=new globalThis.TextDecoder("utf-8")}function un(){if(!(typeof globalThis.TextEncoder>"u"))return Qe!=null?Qe:Qe=new globalThis.TextEncoder}const Oe=32*1024,M=65533;function te(a,e="utf-8"){switch(e.toLowerCase()){case"utf-8":case"utf8":{const t=mn();return t?t.decode(a):gn(a)}case"utf-16le":return fn(a);case"us-ascii":case"ascii":return xn(a);case"latin1":case"iso-8859-1":return kn(a);case"windows-1252":return wn(a);default:throw new RangeError("Encoding '".concat(e,"' not supported"))}}function hn(a="",e="utf-8"){switch(e.toLowerCase()){case"utf-8":case"utf8":{const t=un();return t?t.encode(a):Tn(a)}case"utf-16le":return bn(a);case"us-ascii":case"ascii":return yn(a);case"latin1":case"iso-8859-1":return Sn(a);case"windows-1252":return In(a);default:throw new RangeError("Encoding '".concat(e,"' not supported"))}}function ga(a,e){e.length!==0&&(a.push(String.fromCharCode.apply(null,e)),e.length=0)}function P(a,e,t){e.push(t),e.length>=Oe&&ga(a,e)}function pn(a,e,t){if(t<=65535){P(a,e,t);return}t-=65536,P(a,e,55296+(t>>10)),P(a,e,56320+(t&1023))}function gn(a){const e=[],t=[];let i=0;for(a.length>=3&&a[0]===239&&a[1]===187&&a[2]===191&&(i=3);i<a.length;){const n=a[i];if(n<=127){P(e,t,n),i++;continue}if(n<194||n>244){P(e,t,M),i++;continue}if(n<=223){if(i+1>=a.length){P(e,t,M),i++;continue}const d=a[i+1];if((d&192)!==128){P(e,t,M),i++;continue}const m=(n&31)<<6|d&63;P(e,t,m),i+=2;continue}if(n<=239){if(i+2>=a.length){P(e,t,M),i++;continue}const d=a[i+1],m=a[i+2];if(!((d&192)===128&&(m&192)===128&&!(n===224&&d<160)&&!(n===237&&d>=160))){P(e,t,M),i++;continue}const y=(n&15)<<12|(d&63)<<6|m&63;P(e,t,y),i+=3;continue}if(i+3>=a.length){P(e,t,M),i++;continue}const r=a[i+1],s=a[i+2],o=a[i+3];if(!((r&192)===128&&(s&192)===128&&(o&192)===128&&!(n===240&&r<144)&&!(n===244&&r>143))){P(e,t,M),i++;continue}const l=(n&7)<<18|(r&63)<<12|(s&63)<<6|o&63;pn(e,t,l),i+=4}return ga(e,t),e.join("")}function fn(a){const e=[],t=[],i=a.length;let n=0;for(;n+1<i;){const r=a[n]|a[n+1]<<8;if(n+=2,r>=55296&&r<=56319){if(n+1<i){const s=a[n]|a[n+1]<<8;s>=56320&&s<=57343?(P(e,t,r),P(e,t,s),n+=2):P(e,t,M)}else P(e,t,M);continue}if(r>=56320&&r<=57343){P(e,t,M);continue}P(e,t,r)}return n<i&&P(e,t,M),ga(e,t),e.join("")}function xn(a){const e=[];for(let t=0;t<a.length;t+=Oe){const i=Math.min(a.length,t+Oe),n=new Array(i-t);for(let r=t,s=0;r<i;r++,s++)n[s]=a[r]&127;e.push(String.fromCharCode.apply(null,n))}return e.join("")}function kn(a){const e=[];for(let t=0;t<a.length;t+=Oe){const i=Math.min(a.length,t+Oe),n=new Array(i-t);for(let r=t,s=0;r<i;r++,s++)n[s]=a[r];e.push(String.fromCharCode.apply(null,n))}return e.join("")}function wn(a){const e=[];let t="";for(let i=0;i<a.length;i++){const n=a[i],r=n>=128&&n<=159?Ai[n]:void 0;t+=r!=null?r:String.fromCharCode(n),t.length>=Oe&&(e.push(t),t="")}return t&&e.push(t),e.join("")}function Tn(a){const e=[];for(let t=0;t<a.length;t++){let i=a.charCodeAt(t);if(i>=55296&&i<=56319)if(t+1<a.length){const n=a.charCodeAt(t+1);n>=56320&&n<=57343?(i=65536+(i-55296<<10)+(n-56320),t++):i=M}else i=M;else i>=56320&&i<=57343&&(i=M);i<128?e.push(i):i<2048?e.push(192|i>>6,128|i&63):i<65536?e.push(224|i>>12,128|i>>6&63,128|i&63):e.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|i&63)}return new Uint8Array(e)}function bn(a){const e=[];for(let i=0;i<a.length;i++){const n=a.charCodeAt(i);if(n>=55296&&n<=56319){if(i+1<a.length){const r=a.charCodeAt(i+1);r>=56320&&r<=57343?(e.push(n,r),i++):e.push(M)}else e.push(M);continue}if(n>=56320&&n<=57343){e.push(M);continue}e.push(n)}const t=new Uint8Array(e.length*2);for(let i=0;i<e.length;i++){const n=e[i],r=i*2;t[r]=n&255,t[r+1]=n>>>8}return t}function yn(a){const e=new Uint8Array(a.length);for(let t=0;t<a.length;
1t++)e[t]=a.charCodeAt(t)&127;return e}function Sn(a){const e=new Uint8Array(a.length);for(let t=0;t<a.length;t++)e[t]=a.charCodeAt(t)&255;return e}function In(a){const e=new Uint8Array(a.length);for(let t=0;t<a.length;t++){const i=a[t],n=i.charCodeAt(0);if(Kt[i]!==void 0){e[t]=Kt[i];continue}if(n>=0&&n<=127||n>=160&&n<=255){e[t]=n;continue}e[t]=63}return e}function b(a){return new DataView(a.buffer,a.byteOffset)}const T={len:1,get(a,e){return b(a).getUint8(e)},put(a,e,t){return b(a).setUint8(e,t),e+1}},w={len:2,get(a,e){return b(a).getUint16(e,!0)},put(a,e,t){return b(a).setUint16(e,t,!0),e+2}},v={len:2,get(a,e){return b(a).getUint16(e)},put(a,e,t){return b(a).setUint16(e,t),e+2}},ht={len:3,get(a,e){const t=b(a);return t.getUint8(e)+(t.getUint16(e+1,!0)<<8)},put(a,e,t){const i=b(a);return i.setUint8(e,t&255),i.setUint16(e+1,t>>8,!0),e+3}},B={len:3,get(a,e){const t=b(a);return(t.getUint16(e)<<8)+t.getUint8(e+2)},put(a,e,t){const i=b(a);return i.setUint16(e,t>>8),i.setUint8(e+2,t&255),e+3}},f={len:4,get(a,e){return b(a).getUint32(e,!0)},put(a,e,t){return b(a).setUint32(e,t,!0),e+4}},x={len:4,get(a,e){return b(a).getUint32(e)},put(a,e,t){return b(a).setUint32(e,t),e+4}},ke={len:1,get(a,e){return b(a).getInt8(e)},put(a,e,t){return b(a).setInt8(e,t),e+1}},se={len:2,get(a,e){return b(a).getInt16(e)},put(a,e,t){return b(a).setInt16(e,t),e+2}},vn={len:2,get(a,e){return b(a).getInt16(e,!0)},put(a,e,t){return b(a).setInt16(e,t,!0),e+2}},Cn={len:3,get(a,e){const t=ht.get(a,e);return t>8388607?t-16777216:t},put(a,e,t){const i=b(a);return i.setUint8(e,t&255),i.setUint16(e+1,t>>8,!0),e+3}},fa={len:3,get(a,e){const t=B.get(a,e);return t>8388607?t-16777216:t},put(a,e,t){const i=b(a);return i.setUint16(e,t>>8),i.setUint8(e+2,t&255),e+3}},Y={len:4,get(a,e){return b(a).getInt32(e)},put(a,e,t){return b(a).setInt32(e,t),e+4}},D={len:4,get(a,e){return b(a).getInt32(e,!0)},put(a,e,t){return b(a).setInt32(e,t,!0),e+4}},$={len:8,get(a,e){return b(a).getBigUint64(e,!0)},put(a,e,t){return b(a).setBigUint64(e,t,!0),e+8}},pt={len:8,get(a,e){return b(a).getBigInt64(e,!0)},put(a,e,t){return b(a).setBigInt64(e,t,!0),e+8}},Et={len:8,get(a,e){return b(a).getBigUint64(e)},put(a,e,t){return b(a).setBigUint64(e,t),e+8}},Fi={len:8,get(a,e){return b(a).getBigInt64(e)},put(a,e,t){return b(a).setBigInt64(e,t),e+8}},En={len:2,get(a,e){return xe.read(a,e,!1,10,this.len)},put(a,e,t){return xe.write(a,t,e,!1,10,this.len),e+this.len}},An={len:2,get(a,e){return xe.read(a,e,!0,10,this.len)},put(a,e,t){return xe.write(a,t,e,!0,10,this.len),e+this.len}},Di={len:4,get(a,e){return b(a).getFloat32(e)},put(a,e,t){return b(a).setFloat32(e,t),e+4}},Fn={len:4,get(a,e){return b(a).getFloat32(e,!0)},put(a,e,t){return b(a).setFloat32(e,t,!0),e+4}},Jt={len:8,get(a,e){return b(a).getFloat64(e)},put(a,e,t){return b(a).setFloat64(e,t),e+8}},Dn={len:8,get(a,e){return b(a).getFloat64(e,!0)},put(a,e,t){return b(a).setFloat64(e,t,!0),e+8}},Pn={len:10,get(a,e){return xe.read(a,e,!1,63,this.len)},put(a,e,t){return xe.write(a,t,e,!1,63,this.len),e+this.len}},zn={len:10,get(a,e){return xe.read(a,e,!0,63,this.len)},put(a,e,t){return xe.write(a,t,e,!0,63,this.len),e+this.len}};class _n{constructor(e){this.len=e}get(e,t){}}class U{constructor(e){this.len=e}get(e,t){return e.subarray(t,t+this.len)}}class k{constructor(e,t){this.len=e,this.encoding=t}get(e,t=0){const i=e.subarray(t,t+this.len);return te(i,this.encoding)}}class Mn extends k{constructor(e){super(e,"windows-1252")}}const Bn=Object.freeze(Object.defineProperty({__proto__:null,AnsiStringType:Mn,Float16_BE:En,Float16_LE:An,Float32_BE:Di,Float32_LE:Fn,Float64_BE:Jt,Float64_LE:Dn,Float80_BE:Pn,Float80_LE:zn,INT16_BE:se,INT16_LE:vn,INT24_BE:fa,INT24_LE:Cn,INT32_BE:Y,INT32_LE:D,INT64_BE:Fi,INT64_LE:pt,INT8:ke,IgnoreType:_n,StringType:k,UINT16_BE:v,UINT16_LE:w,UINT24_BE:B,UINT24_LE:ht,UINT32_BE:x,UINT32_LE:f,UINT64_BE:Et,UINT64_LE:$,UINT8:T,Uint8ArrayType:U},Symbol.toStringTag,{value:"Module"})),Me={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},Pa={get(a){return{signature:f.get(a,0),compressedSize:f.get(a,8),uncompressedSize:f.get(a,12)}},len:16},On={get(a){const e=w.get(a,6);return{signature:f.get(a,0),minVersion:w.get(a,4),dataDescriptor:!!(e&8),compressedMethod:w.get(a,8),compressedSize:f.get(a,18),uncompressedSize:f.get(a,22),filenameLength:w.get(a,26),extraFieldLength:w.get(a,28),filename:null}},len:30},Rn={get(a){return{signature:f.get(a,0),nrOfThisDisk:w.get(a,4),nrOfThisDiskWithTheStart:w.get(a,6),nrOfEntriesOnThisDisk:w.get(a,8),nrOfEntriesOfSize:w.get(a,10),sizeOfCd:f.get(a,12),offsetOfStartOfCd:f.get(a,16),zipFileCommentLength:w.get(a,20)}},len:22},Ln={get(a){const e=w.get(a,8);return{signature:f.get(a,0),minVersion:w.get(a,6),dataDescriptor:!!(e&8),compressedMethod:w.get(a,10),compressedSize:f.get(a,20),uncompressedSize:f.get(a,24),filenameLength:w.get(a,28),extraFieldLength:w.get(a,30
1),fileCommentLength:w.get(a,32),relativeOffsetOfLocalHeader:f.get(a,42),filename:null}},len:46};function Pi(a){const e=new Uint8Array(f.len);return f.put(e,0,a),e}const ae=C("tokenizer:inflate"),Ot=256*1024,Nn=Pi(Me.DataDescriptor),et=Pi(Me.EndOfCentralDirectory);class Xe{constructor(e){this.tokenizer=e,this.syncBuffer=new Uint8Array(Ot)}async isZip(){return await this.peekSignature()===Me.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken(f)}async findEndOfCentralDirectoryLocator(){const e=this.tokenizer,t=Math.min(16*1024,e.fileInfo.size),i=this.syncBuffer.subarray(0,t);await this.tokenizer.readBuffer(i,{position:e.fileInfo.size-t});for(let n=i.length-4;n>=0;n--)if(i[n]===et[0]&&i[n+1]===et[1]&&i[n+2]===et[2]&&i[n+3]===et[3])return e.fileInfo.size-t+n;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess()){ae("Cannot reading central-directory without random-read support");return}ae("Reading central-directory...");const e=this.tokenizer.position,t=await this.findEndOfCentralDirectoryLocator();if(t>0){ae("Central-directory 32-bit signature found");const i=await this.tokenizer.readToken(Rn,t),n=[];this.tokenizer.setPosition(i.offsetOfStartOfCd);for(let r=0;r<i.nrOfEntriesOfSize;++r){const s=await this.tokenizer.readToken(Ln);if(s.signature!==Me.CentralFileHeader)throw new Error("Expected Central-File-Header signature");s.filename=await this.tokenizer.readToken(new k(s.filenameLength,"utf-8")),await this.tokenizer.ignore(s.extraFieldLength),await this.tokenizer.ignore(s.fileCommentLength),n.push(s),ae("Add central-directory file-entry: n=".concat(r+1,"/").concat(n.length,": filename=").concat(n[r].filename))}return this.tokenizer.setPosition(e),n}this.tokenizer.setPosition(e)}async unzip(e){const t=await this.readCentralDirectory();if(t)return this.iterateOverCentralDirectory(t,e);let i=!1;do{const n=await this.readLocalFileHeader();if(!n)break;const r=e(n);i=!!r.stop;let s;if(await this.tokenizer.ignore(n.extraFieldLength),n.dataDescriptor&&n.compressedSize===0){const o=[];let c=Ot;ae("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let l=-1;for(;l<0&&c===Ot;){c=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),l=$n(this.syncBuffer.subarray(0,c),Nn);const d=l>=0?l:c;if(r.handler){const m=new Uint8Array(d);await this.tokenizer.readBuffer(m),o.push(m)}else await this.tokenizer.ignore(d)}ae("Found data-descriptor-signature at pos=".concat(this.tokenizer.position)),r.handler&&await this.inflate(n,Un(o),r.handler)}else r.handler?(ae("Reading compressed-file-data: ".concat(n.compressedSize," bytes")),s=new Uint8Array(n.compressedSize),await this.tokenizer.readBuffer(s),await this.inflate(n,s,r.handler)):(ae("Ignoring compressed-file-data: ".concat(n.compressedSize," bytes")),await this.tokenizer.ignore(n.compressedSize));if(ae("Reading data-descriptor at pos=".concat(this.tokenizer.position)),n.dataDescriptor&&(await this.tokenizer.readToken(Pa)).signature!==134695760)throw new Error("Expected data-descriptor-signature at position ".concat(this.tokenizer.position-Pa.len))}while(!i)}async iterateOverCentralDirectory(e,t){for(const i of e){const n=t(i);if(n.handler){this.tokenizer.setPosition(i.relativeOffsetOfLocalHeader);const r=await this.readLocalFileHeader();if(r){await this.tokenizer.ignore(r.extraFieldLength);const s=new Uint8Array(i.compressedSize);await this.tokenizer.readBuffer(s),await this.inflate(r,s,n.handler)}}
1if(n.stop)break}}async inflate(e,t,i){if(e.compressedMethod===0)return i(t);if(e.compressedMethod!==8)throw new Error("Unsupported ZIP compression method: ".concat(e.compressedMethod));ae("Decompress filename=".concat(e.filename,", compressed-size=").concat(t.length));const n=await Xe.decompressDeflateRaw(t);return i(n)}static async decompressDeflateRaw(e){const t=new ReadableStream({start(r){r.enqueue(e),r.close()}}),i=new DecompressionStream("deflate-raw"),n=t.pipeThrough(i);try{const s=await new Response(n).arrayBuffer();return new Uint8Array(s)}catch(r){const s=r instanceof Error?"Failed to deflate ZIP entry: ".concat(r.message):"Unknown decompression error in ZIP entry";throw new TypeError(s)}}async readLocalFileHeader(){const e=await this.tokenizer.peekToken(f);if(e===Me.LocalFileHeader){const t=await this.tokenizer.readToken(On);return t.filename=await this.tokenizer.readToken(new k(t.filenameLength,"utf-8")),t}if(e===Me.CentralFileHeader)return!1;throw e===3759263696?new Error("Encrypted ZIP"):new Error("Unexpected signature")}}function $n(a,e){const t=a.length,i=e.length;if(i>t)return-1;for(let n=0;n<=t-i;n++){let r=!0;for(let s=0;s<i;s++)if(a[n+s]!==e[s]){r=!1;break}if(r)return n}return-1}function Un(a){const e=a.reduce((n,r)=>n+r.length,0),t=new Uint8Array(e);let i=0;for(const n of a)t.set(n,i),i+=n.length;return t}class jn{constructor(e){this.tokenizer=e}inflate(){const e=this.tokenizer;return new ReadableStream({async pull(t){const i=new Uint8Array(1024),n=await e.readBuffer(i,{mayBeLess:!0});if(n===0){t.close();return}t.enqueue(i.subarray(0,n))}}).pipeThrough(new DecompressionStream("gzip"))}}const Gn=Object.prototype.toString,Wn="[object Uint8Array]";function Hn(a,e,t){return a?a.constructor===e?!0:Gn.call(a)===t:!1}function Xn(a){return Hn(a,Uint8Array,Wn)}function Vn(a){if(!Xn(a))throw new TypeError("Expected `Uint8Array`, got `".concat(typeof a,"`"))}new globalThis.TextDecoder("utf8");new globalThis.TextEncoder;const qn=Array.from({length:256},(a,e)=>e.toString(16).padStart(2,"0"));function zi(a){Vn(a);let e="";for(let t=0;t<a.length;t++)e+=qn[a[t]];return e}function Qt(a){const{byteLength:e}=a;if(e===6)return a.getUint16(0)*2**32+a.getUint32(2);if(e===5)return a.getUint8(0)*2**32+a.getUint32(1);if(e===4)return a.getUint32(0);if(e===3)return a.getUint8(0)*2**16+a.getUint16(1);if(e===2)return a.getUint16(0);if(e===1)return a.getUint8(0)}function Zn(a,e){if(e==="utf-16le"){const t=[];for(let i=0;i<a.length;i++){const n=a.charCodeAt(i);t.push(n&255,n>>8&255)}return t}if(e==="utf-16be"){const t=[];for(let i=0;i<a.length;i++){const n=a.charCodeAt(i);t.push(n>>8&255,n&255)}return t}return[...a].map(t=>t.charCodeAt(0))}function Yn(a,e=0){const t=Number.parseInt(new k(6).get(a,148).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(t))return!1;let i=256;for(let n=e;n<e+148;n++)i+=a[n];for(let n=e+156;n<e+512;n++)i+=a[n];return t===i}const Kn={get:(a,e)=>a[e+3]&127|a[e+2]<<7|a[e+1]<<14|a[e]<<21,len:4},Jn=["jpg","png","apng","gif","webp","flif","xcf","cr2","cr3","orf","arw","dng","nef","rw2","raf","tif","bmp","icns","jxr","psd","indd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","mpg","mp2","mp3","m4a","oga","ogg","ogv","opus","flac","wav","spx","amr","pdf","epub","elf","macho","exe","swf","rtf","wasm","woff","woff2","eot","ttf","otf","ttc","ico","flv","ps","xz","sqlite","nes","crx","xpi","cab","deb","ar","rpm","Z","lz","cfb","mxf","mts","blend","bpg","docx","pptx","xlsx","3gp","3g2","j2c","jp2","jpm","jpx","mj2","aif","qcp","odt","ods","odp","xml","mobi","heic","cur","ktx","ape","wv","dcm","ics","glb","pcap","dsf","lnk","alias","voc","ac3","m4v","m4p","m4b","f4v","f4p","f4b","f4a","mie","asf","ogm","ogx","mpc","arrow","shp","aac","mp1","it","s3m","xm","skp","avif","eps","lzh","pgp","asar","stl","chm","3mf","zst","jxl","vcf","jls","pst","dwg","parquet","class","arj","cpio","ace","avro","icc","fbx","vsdx","vtt","apk","drc","lz4","potx","xltx","dotx","xltm","ott","ots","otp","odg","otg","xlsm","docm","dotm","potm","pptm","jar","jmp","rm","sav","ppsm","ppsx","tar.gz","reg","dat"],Qn=["image/jpeg","image/png","image/gif","
1image/webp","image/flif","image/x-xcf","image/x-canon-cr2","image/x-canon-cr3","image/tiff","image/bmp","image/vnd.ms-photo","image/vnd.adobe.photoshop","application/x-indesign","application/epub+zip","application/x-xpinstall","application/vnd.ms-powerpoint.slideshow.macroenabled.12","application/vnd.oasis.opendocument.text","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.slideshow","application/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","application/vnd.apache.arrow.file","video/mp4","audio/midi","video/matroska","video/webm","video/quicktime","video/vnd.avi","audio/wav","audio/qcelp","audio/x-ms-asf","video/x-ms-asf","application/vnd.ms-asf","video/mpeg","video/3gpp","audio/mpeg","audio/mp4","video/ogg","audio/ogg","audio/ogg; codecs=opus","application/ogg","audio/flac","audio/ape","audio/wavpack","audio/amr","application/pdf","application/x-elf","application/x-mach-binary","application/x-msdownload","application/x-shockwave-flash","application/rtf","application/wasm","font/woff","font/woff2","application/vnd.ms-fontobject","font/ttf","font/otf","font/collection","image/x-icon","video/x-flv","application/postscript","application/eps","application/x-xz","application/x-sqlite3","application/x-nintendo-nes-rom","application/x-google-chrome-extension","application/vnd.ms-cab-compressed","application/x-deb","application/x-unix-archive","application/x-rpm","application/x-compress","application/x-lzip","application/x-cfb","application/x-mie","application/mxf","video/mp2t","application/x-blender","image/bpg","image/j2c","image/jp2","image/jpx","image/jpm","image/mj2","audio/aiff","application/xml","application/x-mobipocket-ebook","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/icns","image/ktx","application/dicom","audio/x-musepack","text/calendar","text/vcard","text/vtt","model/gltf-binary","application/vnd.tcpdump.pcap","audio/x-dsf","application/x.ms.shortcut","application/x.apple.alias","audio/x-voc","audio/vnd.dolby.dd-raw","audio/x-m4a","image/apng","image/x-olympus-orf","image/x-sony-arw","image/x-adobe-dng","image/x-nikon-nef","image/x-panasonic-rw2","image/x-fujifilm-raf","video/x-m4v","video/3gpp2","application/x-esri-shape","audio/aac","audio/x-it","audio/x-s3m","audio/x-xm","video/MP1S","video/MP2P","application/vnd.sketchup.skp","image/avif","application/x-lzh-compressed","application/pgp-encrypted","application/x-asar","model/stl","application/vnd.ms-htmlhelp","model/3mf","image/jxl","application/zstd","image/jls","application/vnd.ms-outlook","image/vnd.dwg","application/vnd.apache.parquet","application/java-vm","application/x-arj","application/x-cpio","application/x-ace-compressed","application/avro","application/vnd.iccprofile","application/x.autodesk.fbx","application/vnd.visio","application/vnd.android.package-archive","application/vnd.google.draco","application/x-lz4","application/vnd.openxmlformats-officedocument.presentationml.template","application/vnd.openxmlformats-officedocument.spreadsheetml.template","application/vnd.openxmlformats-officedocument.wordprocessingml.template","application/vnd.ms-excel.template.macroenabled.12","application/vnd.oasis.opendocument.text-template","application/vnd.oasis.opendocument.spreadsheet-template","application/vnd.oasis.opendocument.presentation-template","application/vnd.oasis.opendocument.graphics","application/vnd.oasis.opendocument.graphics-template","application/vnd.ms-excel.sheet.macroenabled.12","application/vnd.ms-word.document.macroenabled.12","application/vnd.ms-word.template.macroenabled.12","application/vnd.ms-powerpoint.template.macroenabled.12","application/vnd.ms-powerpoint.presentation.macroenabled.12","application/java-archive","application/vnd.rn-realmedia","application/x-spss-sav","application/x-ms-regedit","application/x-ft-windows-registry-hive","application/x-jmp-data"],je=4100,er=je-2,ce=1024*1024,za=1024,tr=2**31-1,ee=16*1024*1024,At=ce,_a=ce,ar=ee,ir=1,Ma=100,Rt=ee,Ba=64,Oa=At,nr=256,rr=512,sr=ee,or=512,cr=512,Ra=256,La=At,Na=At,lr=At,$a=ee,dr=new Set(["Unexpected signature","Encrypted ZIP","Expected Central-File-Header signature"]),mr=["ZIP entry count exceeds ","Unsupported ZIP compression method:","ZIP entry compressed data exceeds ","ZIP entry decompressed data exceeds ","Expected data-descriptor-signature at position "],ur=new Set(["Z_BUF_ER
1ROR","Z_DATA_ERROR","ERR_INVALID_STATE"]);class ve extends Error{}function hr(a){var n;const e=a==null?void 0:a.streamReader;if(((n=e==null?void 0:e.constructor)==null?void 0:n.name)!=="WebStreamByobReader")return a;const{reader:t}=e,i=async()=>{await t.cancel(),t.releaseLock()};return e.close=i,e.abort=async()=>{e.interrupted=!0,await i()},a}function xa(a,e,t){if(!Number.isFinite(a)||a<0||a>e)throw new ve("".concat(t," has invalid size ").concat(a," (maximum ").concat(e," bytes)"));return a}async function he(a,e,{maximumLength:t=ee,reason:i="skip"}={}){const n=xa(e,t,i);await a.ignore(n)}async function Lt(a,e,t,{maximumLength:i=e.length,reason:n="read"}={}){const r=e.length,s=xa(r,i,n);return a.readBuffer(e,{...t,length:s})}async function pr(a,{maximumLength:e=ce}={}){const n=new ReadableStream({start(l){l.enqueue(a),l.close()}}).pipeThrough(new DecompressionStream("deflate-raw")).getReader(),r=[];let s=0;try{for(;;){const{done:l,value:d}=await n.read();if(l)break;if(s+=d.length,s>e)throw await n.cancel(),new Error("ZIP entry decompressed data exceeds ".concat(e," bytes"));r.push(d)}}finally{n.releaseLock()}const o=new Uint8Array(s);let c=0;for(const l of r)o.set(l,c),c+=l.length;return o}const _i=134695760,gt=16,gr=gt-1;function fr(a,e){if(a.length<gt)return-1;const t=a.length-gt;for(let i=0;i<=t;i++)if(f.get(a,i)===_i&&f.get(a,i+8)===e+i)return i;return-1}function xr(a){return(a.codePointAt(0)&32)!==0}function kr(a,e){const t=new Uint8Array(e);let i=0;for(const n of a)t.set(n,i),i+=n.length;return t}async function wr(a,{shouldBuffer:e,maximumLength:t=ce}={}){const{syncBuffer:i}=a,{length:n}=i,r=[];let s=0;for(;;){const o=await a.tokenizer.peekBuffer(i,{mayBeLess:!0}),c=fr(i.subarray(0,o),s),l=c>=0?0:o===n?Math.min(gr,o-1):0,d=c>=0?c:o-l;if(d===0)break;if(s+=d,s>t)throw new Error("ZIP entry compressed data exceeds ".concat(t," bytes"));if(e){const m=new Uint8Array(d);await a.tokenizer.readBuffer(m),r.push(m)}else await a.tokenizer.ignore(d);if(c>=0)break}if(L(a.tokenizer)||(a.knownSizeDescriptorScannedBytes+=s),!!e)return kr(r,s)}function Tr(a,e){return L(a.tokenizer)?Math.max(0,ee-(a.tokenizer.position-e)):Math.max(0,ce-a.knownSizeDescriptorScannedBytes)}async function br(a,e,{shouldBuffer:t,maximumDescriptorLength:i=ce}={}){if(e.dataDescriptor&&e.compressedSize===0)return wr(a,{shouldBuffer:t,maximumLength:i});if(!t){await he(a.tokenizer,e.compressedSize,{maximumLength:L(a.tokenizer)?ce:a.tokenizer.fileInfo.size,reason:"ZIP entry compressed data"});return}const n=Er(a.tokenizer);if(!Number.isFinite(e.compressedSize)||e.compressedSize<0||e.compressedSize>n)throw new Error("ZIP entry compressed data exceeds ".concat(n," bytes"));const r=new Uint8Array(e.compressedSize);return await a.tokenizer.readBuffer(r),r}Xe.prototype.inflate=async function(a,e,t){if(a.compressedMethod===0)return t(e);if(a.compressedMethod!==8)throw new Error("Unsupported ZIP compression method: ".concat(a.compressedMethod));const i=await pr(e,{maximumLength:ce});return t(i)};Xe.prototype.unzip=async function(a){let e=!1,t=0;const i=this.tokenizer.position;this.knownSizeDescriptorScannedBytes=0;do{if(Ge(this.tokenizer,i,ee))throw new ve("ZIP stream probing exceeds ".concat(ee," bytes"));const n=await this.readLocalFileHeader();if(!n)break;if(t++,t>za)throw new Error("ZIP entry count exceeds ".concat(za));const r=a(n);e=!!r.stop,await this.tokenizer.ignore(n.extraFieldLength);const s=await br(this,n,{shouldBuffer:!!r.handler,maximumDescriptorLength:Math.min(ce,Tr(this,i))});if(r.handler&&await this.inflate(n,s,r.handler),n.dataDescriptor){const o=new Uint8Array(gt);if(await this.tokenizer.readBuffer(o),f.get(o,0)!==_i)throw new Error("Expected data-descriptor-signature at position ".concat(this.tokenizer.position-o.length))}if(Ge(this.tokenizer,i,ee))throw new ve("ZIP stream probing exceeds ".concat(ee," bytes"))}while(!e)};function yr(a,e){const t=a.getReader();let i=0,n=!1,r=!1;const s=async o=>{n||r||(r=!0,await t.cancel(o))};return new ReadableStream({async pull(o){if(i>=e){o.close(),await s();return}const{done:c,value:l}=await t.read();if(c||!l){n=!0,o.close();return}const d=e-i;if(l.length>d){o.enqueue(l.subarray(0,d)),i+=d,o.close(),await s();return}o.enqueue(l),i+=l.length},async cancel(o){await s(o)}})}async function Mi(a,e){return new ka(e).fromBuffer(a)}function Ua(a){switch(a=a.toLowerCase(),a){case"application/epub+zip":return{ext:"epub",mime:a};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:a};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:a};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:a};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:a};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:a};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:a};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:a};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:a};case"application/vnd.openxmlformats-officedocument.presentationml.slideshow":return{ext:"ppsx",mime:a};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:a};case"application/vnd.ms-excel.sheet.macroenabled":return{ext:"xlsm",mime:"application/vnd.ms-excel.sheet.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.spreadsheetml.template":return{ext:"xltx",mime:a};case"application/vnd.ms-excel.template.macroenabled":return{ext:"xltm",mime:"application/vnd.ms-excel.template.macroenabled.12"};case"application/vnd.ms-powerpoint.slideshow.macroenabled":return{ext:"ppsm",mime:"application/vnd.ms-powerpoint.slideshow.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return{ext:"docx",mime:a};case"application/vnd.ms-word.document.macroenabled":return{ext:"docm",mime:"application/vnd.ms-word.document.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.template":return{ext:"dotx",mime:a};case"application/vnd.ms-word.template.macroenabledtemplate":return{ext:"dotm",mime:"application/vnd.ms-word.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.template":return{ext:"potx",mime:a};case"application/vnd.ms-powerpoint.template.macroenabled":return{ext:"potm",mime:"application/vnd.ms-powerpoint.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.presentation":return{ext:"pptx",mime:a};case"application/vnd.ms-powerpoint.presentation.macroenabled":return{ext:"pptm",mime:"application/vnd.ms-powerpoint.presentation.macroenabled.12"};case"application/vnd.ms-visio.drawing":return{ext:"vsdx",mime:"application/vnd.visio"};case"application/vnd.ms-package.3dmanufacturing-3dmodel+xml":return{ext:"3mf",mime:"model/3mf"}}}function ie(a,e,t){t={offset:0,...t};for(const[i,n]of e.entries())if(t.mask){if(n!==(t.mask[i]&a[i+t.offset]))return!1}else if(n!==a[i+t.offset])return!1;return!0}function Sr(a){return Number.isFinite(a)?Math.max(1,Math.trunc(a)):je}function Ir(a,e,t){return t===void 0?a.read(e):(t.throwIfAborted(),new Promise((i,n)=>{const r=()=>{t.removeEventListener("abort",s)},s=()=>{const o=t.reason;r(),(async()=>{try{await a.cancel(o)}catch(c){}})(),n(o)};t.addEventListener("abort",s,{once:!0}),(async()=>{try{const o=await a.read(e);r(),i(o)}catch(o){r(),n(o)}})()}))}function vr(a){return Number.isFinite(a)?Math.max(0,Math.min(er,Math.trunc(a))):0}function Cr(a){return Number.isFinite(a)?Math.max(0,a):Number.MAX_SAFE_INTEGER}function L(a){const e=a.fileInfo.size;return!Number.isFinite(e)||e===Number.MAX_SAFE_INTEGER}function Ge(a,e,t){return L(a)&&a.position-e>t}function Er(a){const e=a.fileInfo.size,t=Number.isFinite(e)?Math.max(0,e-a.position):Number.MAX_SAFE_INTEGER;return Math.min(t,tr)}function Ar(a){if(a instanceof E||a instanceof ve)return!0;
1if(!(a instanceof Error))return!1;if(dr.has(a.message)||ur.has(a.code))return!0;for(const e of mr)if(a.message.startsWith(e))return!0;return!1}function ja(a,e=ce){const t=[a.compressedSize,a.uncompressedSize];for(const i of t)if(!Number.isFinite(i)||i<0||i>e)return!1;return!0}function Fr(){return{hasContentTypesEntry:!1,hasParsedContentTypesEntry:!1,isParsingContentTypes:!1,hasUnparseableContentTypes:!1,hasWordDirectory:!1,hasPresentationDirectory:!1,hasSpreadsheetDirectory:!1,hasThreeDimensionalModelEntry:!1}}function Dr(a,e){e.startsWith("word/")&&(a.hasWordDirectory=!0),e.startsWith("ppt/")&&(a.hasPresentationDirectory=!0),e.startsWith("xl/")&&(a.hasSpreadsheetDirectory=!0),e.startsWith("3D/")&&e.endsWith(".model")&&(a.hasThreeDimensionalModelEntry=!0)}function Ga(a){if(!(!a.hasContentTypesEntry||a.hasUnparseableContentTypes||a.isParsingContentTypes||a.hasParsedContentTypesEntry)){if(a.hasWordDirectory)return{ext:"docx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"};if(a.hasPresentationDirectory)return{ext:"pptx",mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation"};if(a.hasSpreadsheetDirectory)return{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"};if(a.hasThreeDimensionalModelEntry)return{ext:"3mf",mime:"model/3mf"}}}function Pr(a){const e=a.indexOf('.main+xml"');if(e===-1){const n="application/vnd.ms-package.3dmanufacturing-3dmodel+xml";return a.includes('ContentType="'.concat(n,'"'))?n:void 0}const t=a.slice(0,e),i=t.lastIndexOf('"');return t.slice(i+1)}class ka{constructor(e){Bt(this,"detectConfident",async e=>{var t;if(this.buffer=new Uint8Array(je),e.fileInfo.size===void 0&&(e.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=e,L(e)&&(await e.peekBuffer(this.buffer,{length:3,mayBeLess:!0}),this.check([31,139,8])))return this.detectGzip(e);if(await e.peekBuffer(this.buffer,{length:32,mayBeLess:!0}),this.check([66,77]))return{ext:"bmp",mime:"image/bmp"};if(this.check([11,119]))return{ext:"ac3",mime:"audio/vnd.dolby.dd-raw"};if(this.check([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(this.check([77,90]))return{ext:"exe",mime:"application/x-msdownload"};if(this.check([37,33]))return await e.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString("PS-Adobe-",{offset:2})&&this.checkString(" EPSF-",{offset:14})?{ext:"eps",mime:"application/eps"}:{ext:"ps",mime:"application/postscript"};if(this.check([31,160])||this.check([31,157]))return{ext:"Z",mime:"application/x-compress"};if(this.check([199,113]))return{ext:"cpio",mime:"application/x-cpio"};if(this.check([96,234]))return{ext:"arj",mime:"application/x-arj"};if(this.check([239,187,191]))return this.detectionReentryCount>=Ra?void 0:(this.detectionReentryCount++,await this.tokenizer.ignore(3),this.detectConfident(e));if(this.check([71,73,70]))return{ext:"gif",mime:"image/gif"};if(this.check([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(this.check([31,139,8]))return this.detectGzip(e);if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await he(e,6,{maximumLength:6,reason:"ID3 header prefix"});const i=await e.readToken(Kn),n=L(e);if(!Number.isFinite(i)||i<0||n&&(i>Rt||e.position+i>Rt))return;if(e.position+i>e.fileInfo.size)return n?void 0:{ext:"mp3",mime:"audio/mpeg"};try{await he(e,i,{maximumLength:n?Rt:e.fileInfo.size,reason:"ID3 payload"})}catch(r){if(r instanceof E)return;throw r}return this.detectionReentryCount>=Ra?void 0:(this.detectionReentryCount++,this.parseTokenizer(e,this.detectionReentryCount))}if(this.checkString("MP+"))return{ext:"mpc",mime:"audio/x-musepack"};if((this.buffer[0]===67||this.buffer[0]===70)&&this.check([87,83],{offset:1}))return{ext:"swf",mime:"application/x-shockwave-flash"};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:"jls",mime:"image/jls"}:{ext:"jpg",mime:"image/jpeg"};if(this.check([79,98,106,1]))return{ext:"avro",mime:"application/avro"};if(this.checkString("FLIF"))return{ext:"flif",mime:"image/flif"};if(this.checkString("8BPS"))return{ext:"psd",mime:"image/vnd.adobe.photoshop"};if(this.checkString("MPCK"))return{ext:"mpc",mime:"audio/x-musepack"};if(this.checkString("FORM"))return{ext:"aif",mime:"audio/aiff"};if(this.checkString("icns",{offset:0}))return{ext:"icns",mime:"image/icns"};
1if(this.check([80,75,3,4])){let i;const n=Fr();try{await new Xe(e).unzip(r=>{Dr(n,r.filename);const s=r.filename==="[Content_Types].xml",o=Ga(n);if(!s&&o)return i=o,{stop:!0};switch(r.filename){case"META-INF/mozilla.rsa":return i={ext:"xpi",mime:"application/x-xpinstall"},{stop:!0};case"META-INF/MANIFEST.MF":return i={ext:"jar",mime:"application/java-archive"},{stop:!0};case"mimetype":return ja(r,_a)?{async handler(c){const l=new TextDecoder("utf-8").decode(c).trim();i=Ua(l)},stop:!0}:{};case"[Content_Types].xml":return n.hasContentTypesEntry=!0,ja(r,_a)?(n.isParsingContentTypes=!0,{async handler(c){const l=new TextDecoder("utf-8").decode(c),d=Pr(l);d&&(i=Ua(d)),n.hasParsedContentTypesEntry=!0,n.isParsingContentTypes=!1},stop:!0}):(n.hasUnparseableContentTypes=!0,{});default:return/classes\d*\.dex/.test(r.filename)?(i={ext:"apk",mime:"application/vnd.android.package-archive"},{stop:!0}):{}}})}catch(r){if(!Ar(r))throw r;n.isParsingContentTypes&&(n.isParsingContentTypes=!1,n.hasUnparseableContentTypes=!0)}return(t=i!=null?i:Ga(n))!=null?t:{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await e.ignore(28);const i=new Uint8Array(8);return await e.readBuffer(i),ie(i,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:ie(i,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:ie(i,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:ie(i,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:ie(i,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:ie(i,[1,118,111,114,98,105,115])?{ext:"ogg",mime:"audio/ogg"}:{ext:"ogx",mime:"application/ogg"}}if(this.check([80,75])&&(this.buffer[2]===3||this.buffer[2]===5||this.buffer[2]===7)&&(this.buffer[3]===4||this.buffer[3]===6||this.buffer[3]===8))return{ext:"zip",mime:"application/zip"};if(this.checkString("MThd"))return{ext:"mid",mime:"audio/midi"};if(this.checkString("wOFF")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff",mime:"font/woff"};if(this.checkString("wOF2")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff2",mime:"font/woff2"};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:"pcap",mime:"application/vnd.tcpdump.pcap"};if(this.checkString("DSD "))return{ext:"dsf",mime:"audio/x-dsf"};if(this.checkString("LZIP"))return{ext:"lz",mime:"application/x-lzip"};if(this.checkString("fLaC"))return{ext:"flac",mime:"audio/flac"};if(this.check([66,80,71,251]))return{ext:"bpg",mime:"image/bpg"};if(this.checkString("wvpk"))return{ext:"wv",mime:"audio/wavpack"};if(this.checkString("%PDF"))return{ext:"pdf",mime:"application/pdf"};if(this.check([0,97,115,109]))return{ext:"wasm",mime:"application/wasm"};if(this.check([73,73])){const i=await this.readTiffHeader(!1);if(i)return i}if(this.check([77,77])){const i=await this.readTiffHeader(!0);if(i)return i}if(this.checkString("MAC "))return{ext:"ape",mime:"audio/ape"};if(this.check([26,69,223,163])){async function i(){const l=await e.peekNumber(T);let d=128,m=0;for(;(l&d)===0&&d!==0;)++m,d>>=1;const p=new Uint8Array(m+1);return await Lt(e,p,void 0,{maximumLength:p.length,reason:"EBML field"}),p}async function n(){const l=await i(),d=await i();d[0]^=128>>d.length-1;const m=Math.min(6,d.length),p=new DataView(l.buffer),y=new DataView(d.buffer,d.length-m,m);return{id:Qt(p),len:Qt(y)}}async function r(l){let d=0;for(;l>0;){if(d++,d>nr||Ge(e,o,ee))return;const m=e.position,p=await n();if(p.id===17026){if(p.len>Ba)return;const y=xa(p.len,Ba,"EBML DocType");return(await e.readToken(new k(y))).replaceAll(/\00.*$/g,"")}if(L(e)&&(!Number.isFinite(p.len)||p.len<0||p.len>Oa)||(await he(e,p.len,{maximumLength:L(e)?Oa:e.fileInfo.size,reason:"EBML payload"}),--l,e.position<=m))return}}const s=await n(),o=e.position;switch(await r(s.len)){case"webm":return{ext:"webm",mime:"video/webm"};case"matroska":return{ext:"mkv",mime:"video/matroska"};default:return}}if(this.checkString("SQLi"))return{ext:"sqlite",mime:"application/x-sqlite3"};if(this.check([78,69,83,26]))return{ext:"nes",mime:"application/x-nintendo-nes-rom"};if(this.checkString("Cr24"))return{ext:"crx",mime:"application/x-google-chrome-extension"};if(this.checkString("MSCF")||this.checkString("ISc("))return{ext:"cab",mime:"application/vnd.ms-cab-compressed"};
1if(this.check([237,171,238,219]))return{ext:"rpm",mime:"application/x-rpm"};if(this.check([197,208,211,198]))return{ext:"eps",mime:"application/eps"};if(this.check([40,181,47,253]))return{ext:"zst",mime:"application/zstd"};if(this.check([127,69,76,70]))return{ext:"elf",mime:"application/x-elf"};if(this.check([33,66,68,78]))return{ext:"pst",mime:"application/vnd.ms-outlook"};if(this.checkString("PAR1")||this.checkString("PARE"))return{ext:"parquet",mime:"application/vnd.apache.parquet"};if(this.checkString("ttcf"))return{ext:"ttc",mime:"font/collection"};if(this.check([254,237,250,206])||this.check([254,237,250,207])||this.check([206,250,237,254])||this.check([207,250,237,254]))return{ext:"macho",mime:"application/x-mach-binary"};if(this.check([4,34,77,24]))return{ext:"lz4",mime:"application/x-lz4"};if(this.checkString("regf"))return{ext:"dat",mime:"application/x-ft-windows-registry-hive"};if(this.checkString("$FL2")||this.checkString("$FL3"))return{ext:"sav",mime:"application/x-spss-sav"};if(this.check([79,84,84,79,0]))return{ext:"otf",mime:"font/otf"};if(this.checkString("#!AMR"))return{ext:"amr",mime:"audio/amr"};if(this.checkString("{\\rtf"))return{ext:"rtf",mime:"application/rtf"};if(this.check([70,76,86,1]))return{ext:"flv",mime:"video/x-flv"};if(this.checkString("IMPM"))return{ext:"it",mime:"audio/x-it"};if(this.checkString("-lh0-",{offset:2})||this.checkString("-lh1-",{offset:2})||this.checkString("-lh2-",{offset:2})||this.checkString("-lh3-",{offset:2})||this.checkString("-lh4-",{offset:2})||this.checkString("-lh5-",{offset:2})||this.checkString("-lh6-",{offset:2})||this.checkString("-lh7-",{offset:2})||this.checkString("-lzs-",{offset:2})||this.checkString("-lz4-",{offset:2})||this.checkString("-lz5-",{offset:2})||this.checkString("-lhd-",{offset:2}))return{ext:"lzh",mime:"application/x-lzh-compressed"};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:"mpg",mime:"video/MP1S"};if(this.check([68],{offset:4,mask:[196]}))return{ext:"mpg",mime:"video/MP2P"}}if(this.checkString("ITSF"))return{ext:"chm",mime:"application/vnd.ms-htmlhelp"};if(this.check([202,254,186,190])){const i=x.get(this.buffer,4),n=v.get(this.buffer,6);if(i>0&&i<=30)return{ext:"macho",mime:"application/x-mach-binary"};if(n>30)return{ext:"class",mime:"application/java-vm"}}if(this.checkString(".RMF"))return{ext:"rm",mime:"application/vnd.rn-realmedia"};if(this.checkString("DRACO"))return{ext:"drc",mime:"application/vnd.google.draco"};if(this.check([253,55,122,88,90,0]))return{ext:"xz",mime:"application/x-xz"};if(this.checkString("<?xml "))return{ext:"xml",mime:"application/xml"};if(this.check([55,122,188,175,39,28]))return{ext:"7z",mime:"application/x-7z-compressed"};if(this.check([82,97,114,33,26,7])&&(this.buffer[6]===0||this.buffer[6]===1))return{ext:"rar",mime:"application/x-rar-compressed"};if(this.checkString("solid "))return{ext:"stl",mime:"model/stl"};if(this.checkString("AC")){const i=new k(4,"latin1").get(this.buffer,2);if(i.match("^d*")&&i>=1e3&&i<=1050)return{ext:"dwg",mime:"image/vnd.dwg"}}if(this.checkString("070707"))return{ext:"cpio",mime:"application/x-cpio"};if(this.checkString("BLENDER"))return{ext:"blend",mime:"application/x-blender"};if(this.checkString("!<arch>"))return await e.ignore(8),await e.readToken(new k(13,"ascii"))==="debian-binary"?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.checkString("WEBVTT")&&["\n","\r","	"," ","\0"].some(i=>this.checkString(i,{offset:6})))return{ext:"vtt",mime:"text/vtt"};if(this.check([137,80,78,71,13,10,26,10])){const i={ext:"png",mime:"image/png"},n={ext:"apng",mime:"image/apng"};await e.ignore(8);async function r(){return{length:await e.readToken(Y),type:await e.readToken(new k(4,"latin1"))}}const s=L(e),o=e.position;let c=0,l=!1;do{if(c++,c>rr||Ge(e,o,sr))break;const d=e.position,m=await r();if(m.length<0)return;if(m.type==="IHDR"){if(m.length!==13)return;l=!0}switch(m.type){case"IDAT":return i;case"acTL":return n;default:if(!l&&m.type!=="CgBI")return;if(s&&m.length>La)return l&&xr(m.type)?i:void 0;try{await he(e,m.length+4,{maximumLength:s?La+4:e.fileInfo.size,reason:"PNG chunk payload"})}catch(p){if(!s&&(p instanceof ve||p instanceof E))return i;throw p}}if(e.position<=d)break}while(e.position+8<e.fileInfo.size);return i}if(this.check([65,82,82,79,87,49,0,0]))return{ext:"arrow",mime:"application/vnd.apache.arrow.file"};if(this.check([103,108,84,70,2,0,0,0]))return{ext:"glb",mime:"model/gltf-binary"};if(this.check([102,114,101,101],{offset:4})||this.check([109,100,97,116],{offset:4})||this.check([109,111,111,118],{offset:4})||this.check([119,105,100,101],{offset:4}))return{ext:"mov",mime:"video/quicktime"};if(this.check([73,73,82,79,8,0,0,0,24]))return{ext:"orf",mime:"image/x-olympus-orf"};if(this.checkString("gimp xcf "))return{ext:"xcf",mime:"image/x-xcf"};if(this.checkString("ftyp",{offset:4})&&(this.buffer[8]&96)!==0){const i=new k(4,"latin1").get(this.buffer,8).replace("\0"," ").trim();switch(i){case"avif":case"avis":return{ext:"avif",mime:"image/avif"};case"mif1":return{ext:"heic",mime:"image/heif"};case"msf1":return{ext:"heic",mime:"image/heif-sequence"};case"heic":case"heix":return{ext:"heic",mime:"image/heic"};case"hevc":case"hevx":return{ext:"heic",mime:"image/heic-sequence"};case"qt":return{ext:"mov",mime:"video/quicktime"};case"M4V":case"M4VH":case"M4VP":return{ext:"m4v",mime:"video/x-m4v"};case"M4P":return{ext:"m4p",mime:"video/mp4"};case"M4B":return{ext:"m4b",mime:"audio/mp4"};case"M4A":return{ext:"m4a",mime:"audio/x-m4a"};case"F4V":return{ext:"f4v",mime:"video/mp4"};case"F4P":return{ext:"f4p",mime:"video/mp4"};case"F4A":return{ext:"f4a",mime:"audio/mp4"};case"F4B":return{ext:"f4b",mime:"audio/mp4"};case"crx":return{ext:"cr3",mime:"image/x-canon-cr3"};default:return i.startsWith("3g")?i.startsWith("3g2")?{ext:"3g2",mime:"video/3gpp2"}:{ext:"3gp",mime:"video/3gpp"}:{ext:"mp4",mime:"video/mp4"}}}if(this.checkString("REGEDIT4\r\n"))return{ext:"reg",mime:"application/x-ms-regedit"};if(this.check([82,73,70,70])){if(this.checkString("WEBP",{offset:8}))return{ext:"webp",mime:"image/webp"};if(this.check([65,86,73],{offset:8}))return{ext:"avi",mime:"video/vnd.avi"};if(this.check([87,65,86,69],{offset:8}))return{ext:"wav",mime:"audio/wav"};if(this.check([81,76,67,77],{offset:8}))return{ext:"qcp",mime:"audio/qcelp"}}if(this.check([73,73,85,0,24,0,0,0,136,231,116,216]))return{ext:"rw2",mime:"image/x-p
1anasonic-rw2"};if(this.check([48,38,178,117,142,102,207,17,166,217])){let i=!1;try{async function n(){const c=new Uint8Array(16);return await Lt(e,c,void 0,{maximumLength:c.length,reason:"ASF header GUID"}),{id:c,size:Number(await e.readToken($))}}await he(e,30,{maximumLength:30,reason:"ASF header prelude"});const r=L(e),s=e.position;let o=0;for(;e.position+24<e.fileInfo.size&&(o++,!(o>or||Ge(e,s,ee)));){const c=e.position,l=await n();let d=l.size-24;if(!Number.isFinite(d)||d<0){i=!0;break}if(ie(l.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){const m=new Uint8Array(16);if(d-=await Lt(e,m,void 0,{maximumLength:m.length,reason:"ASF stream type GUID"}),ie(m,[64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"audio/x-ms-asf"};if(ie(m,[192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"video/x-ms-asf"};break}if(r&&d>Na){i=!0;break}if(await he(e,d,{maximumLength:r?Na:e.fileInfo.size,reason:"ASF header payload"}),e.position<=c){i=!0;break}}}catch(n){if(n instanceof E||n instanceof ve)L(e)&&(i=!0);else throw n}return i?void 0:{ext:"asf",mime:"application/vnd.ms-asf"}}if(this.check([171,75,84,88,32,49,49,187,13,10,26,10]))return{ext:"ktx",mime:"image/ktx"};if((this.check([126,16,4])||this.check([126,24,4]))&&this.check([48,77,73,69],{offset:4}))return{ext:"mie",mime:"application/x-mie"};if(this.check([39,10,0,0,0,0,0,0,0,0,0,0],{offset:2}))return{ext:"shp",mime:"application/x-esri-shape"};if(this.check([255,79,255,81]))return{ext:"j2c",mime:"image/j2c"};if(this.check([0,0,0,12,106,80,32,32,13,10,135,10]))switch(await e.ignore(20),await e.readToken(new k(4,"ascii"))){case"jp2 ":return{ext:"jp2",mime:"image/jp2"};case"jpx ":return{ext:"jpx",mime:"image/jpx"};case"jpm ":return{ext:"jpm",mime:"image/jpm"};case"mjp2":return{ext:"mj2",mime:"image/mj2"};default:return}if(this.check([255,10])||this.check([0,0,0,12,74,88,76,32,13,10,135,10]))return{ext:"jxl",mime:"image/jxl"};if(this.check([254,255]))return this.checkString("<?xml ",{offset:2,encoding:"utf-16be"})?{ext:"xml",mime:"application/xml"}:void 0;if(this.check([208,207,17,224,161,177,26,225]))return{ext:"cfb",mime:"application/x-cfb"};if(await e.peekBuffer(this.buffer,{length:Math.min(256,e.fileInfo.size),mayBeLess:!0}),this.check([97,99,115,112],{offset:36}))return{ext:"icc",mime:"application/vnd.iccprofile"};if(this.checkString("**ACE",{offset:7})&&this.checkString("**",{offset:12}))return{ext:"ace",mime:"application/x-ace-compressed"};if(this.checkString("BEGIN:")){if(this.checkString("VCARD",{offset:6}))return{ext:"vcf",mime:"text/vcard"};if(this.checkString("VCALENDAR",{offset:6}))return{ext:"ics",mime:"text/calendar"}}if(this.checkString("FUJIFILMCCD-RAW"))return{ext:"raf",mime:"image/x-fujifilm-raf"};if(this.checkString("Extended Module:"))return{ext:"xm",mime:"audio/x-xm"};if(this.checkString("Creative Voice File"))return{ext:"voc",mime:"audio/x-voc"};if(this.check([4,0,0,0])&&this.buffer.length>=16){const i=new DataView(this.buffer.buffer).getUint32(12,!0);if(i>12&&this.buffer.length>=i+16)try{const n=new TextDecoder().decode(this.buffer.subarray(16,i+16));if(JSON.parse(n).files)return{ext:"asar",mime:"application/x-asar"}}catch(n){}}if(this.check([6,14,43,52,2,5,1,1,13,1,2,1,1,2]))return{ext:"mxf",mime:"application/mxf"};if(this.checkString("SCRM",{offset:44}))return{ext:"s3m",mime:"audio/x-s3m"};if(this.check([71])&&this.check([71],{offset:188}))return{ext:"mts",mime:"video/mp2t"};if(this.check([71],{offset:4})&&this.check([71],{offset:196}))return{ext:"mts",mime:"video/mp2t"};if(this.check([66,79,79,75,77,79,66,73],{offset:60}))return{ext:"mobi",mime:"application/x-mobipocket-ebook"};if(this.check([68,73,67,77],{offset:128}))return{ext:"dcm",mime:"application/dicom"};if(this.check([76,0,0,0,1,20,2,0,0,0,0,0,192,0,0,0,0,0,0,70]))return{ext:"lnk",mime:"application/x.ms.shortcut"};if(this.check([98,111,111,107,0,0,0,0,109,97,114,107,0,0,0,0]))return{ext:"alias",mime:"application/x.apple.alias"};if(this.checkString("Kaydara FBX Binary  \0"))return{ext:"fbx",mime:"application/x.autodesk.fbx"};if(this.check([76,80],{offset:34})&&(this.check([0,0,1],{offset:8})||this.check([1,0,2],{offset:8})||this.check([2,0,2],{offset:8})))return{ext:"eot",mime:"application/vnd.ms-fontobject"};if(this.check([6,6,237,245,216,29,70,229,189,49,239,231,254,116,183,29]))return{ext:"indd",mime:"application/x-indesign"};if(this.check([255,255,0,0,7,0,0,0,4,0,0,0,1,0,1,0])||this.check([0,0,255,255,0,0,0,7,0,0,0,4,0,1,0,1]))return{ext:"jmp",mime:"application/x-jmp-data"};if(await e.peekBuffer(this.buffer,{length:Math.min(512,e.fileInfo.size),mayBeLess:!0}),this.checkString("ustar",{offset:257})&&(this.checkString("\0",{offset:262})||this.checkString(" ",{offset:262}))||this.check([0,0,0,0,0,0],{offset:257})&&Yn(this.buffer))return{ext:"tar",mime:"application/x-tar"};if(this.check([255,254])){const i="utf-16le";return this.checkString("<?xml ",{offset:2,encoding:i})?{ext:"xml",mime:"application/xml"}:this.check([255,14],{offset:2})&&this.checkString("SketchUp Model",{offset:4,encoding:i})?{ext:"skp",mime:"application/vnd.sketchup.skp"}:this.checkString("Windows Registry Editor Version 5.00\r\n",{offset:2,encoding:i})?{ext:"reg",mime:"application/x-ms-regedit"}:void 0}if(this.checkString("-----BEGIN PGP MESSAGE-----"))return{ext:"pgp",mime:"application/pgp-encrypted"}});Bt(this,"detectImprecise",async e=>{this.buffer=new Uint8Array(je);const t=Cr(e.fileInfo.size);if(await e.peekBuffer(this.buffer,{length:Math.min(8,t),mayBeLess:!0}),this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};if(this.check([0,1,0,0,0]))return{ext:"ttf",mime:"font/ttf"};if(this.check([0,0,1,0]))return{ext:"ico",mime:"image/x-icon"};if(this.check([0,0,2,0]))return{ext:"cur",mime:"image/x-icon"};if(await e.peekBuffer(this.buffer,{length:Math.min(2+this.options.mpegOffsetTolerance,t),mayBeLess:!0}),this.buffer.length>=2+this.options.mpegOffsetTolerance)for(let i=0;i<=this.options.mpegOffsetTolerance;++i){const n=this.scanMpeg(i);if(n)return n}});var i;const t=vr(e==null?void 0:e.mpegOffsetTolerance);this.options={...e,mpegOffsetTolerance:t},this.detectors=[...(i=this.options.customDetectors)!=null?i:[],{id:"core",detect:this.detectConfident},{id:"core.imprecise",detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:this.options.signal},this.gzipProbeDepth=0}getTokenizerOptions(){return{...this.tokenizerOptions}}createTokenizerFromWebStream(e){return hr(Ci(e,this.getTokenizerOptions()))}async parseTokenizer(e,t=0){this.detectionReentryCount=t;const i=e.position;for(const n of this.detectors){let r;try{r=await n.detect(e)}catch(s){if(s instanceof E||s instanceof ve)return;throw s}if(r)return r;if(i!==e.position)return}}async fromTokenizer(e){try{return await this.parseTokenizer(e)}finally{await e.close()}}async fromBuffer(e){if(!(e instanceof Uint8Array||e instanceof ArrayBuffer))throw new TypeError("Expected the `input` argument to be of type `Uint8Array` or `ArrayBuffer`, got `".concat(typeof e,"`"));const t=e instanceof Uint8Array?e:new Uint8Array(e);if((t==null?void 0:t.length)>1)return this.fromTokenizer(Ce(t,this.getTokenizerOptions()))}async fromBlob(e){var i;(i=this.options.signal)==null||i.throwIfAborted();const t=Ei(e,this.getTokenizerOptions());return this.fromTokenizer(t)}async fromStream(e){var i;(i=this.options.signal)==null||i.throwIfAborted();const t=this.createTokenizerFromWebStream(e);return this.fromTokenizer(t)}async toDetectionStream(e,t){var l;const i=Sr((l=t==null?void 0:t.sampleSize)!=null?l:je);let n,r;const s=e.getReader({mode:"byob"});try{const{value:d,done:m}=await Ir(s,new Uint8Array(i),this.options.signal);if(r=d,!m&&d)try{n=await this.fromBuffer(d.subarray(0,i))}catch(p){if(!(p instanceof E))throw p;n=void 0}r=d}finally{s.releaseLock()}const o=new TransformStream({async start(d){d.enqueue(r)},transform(d,m){m.enqueue(d)}}),c=e.pipeThrough(o);return c.fileType=n,c}async detectGzip(e){var l;if(this.gzipProbeDepth>=ir)return{ext:"gz",mime:"application/gzip"};const t=new jn(e),i=yr(t.inflate(),ar),n=L(e);
1let r,s,o,c;if(n){const d=new AbortController;r=setTimeout(()=>{d.abort(new DOMException("Operation timed out after ".concat(Ma," ms"),"TimeoutError"))},Ma),s=this.options.signal===void 0?d.signal:AbortSignal.any([this.options.signal,d.signal]),o=new ka({...this.options,signal:s}),o.gzipProbeDepth=this.gzipProbeDepth+1}else this.gzipProbeDepth++;try{c=await(o!=null?o:this).fromStream(i)}catch(d){if((d==null?void 0:d.name)==="AbortError"&&((l=s==null?void 0:s.reason)==null?void 0:l.name)!=="TimeoutError")throw d}finally{clearTimeout(r),n||this.gzipProbeDepth--}return(c==null?void 0:c.ext)==="tar"?{ext:"tar.gz",mime:"application/gzip"}:{ext:"gz",mime:"application/gzip"}}check(e,t){return ie(this.buffer,e,t)}checkString(e,t){return this.check(Zn(e,t==null?void 0:t.encoding),t)}async readTiffTag(e){const t=await this.tokenizer.readToken(e?v:w);switch(await this.tokenizer.ignore(10),t){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"}}}async readTiffIFD(e){const t=await this.tokenizer.readToken(e?v:w);if(!(t>cr)&&!(L(this.tokenizer)&&2+t*12>$a))for(let i=0;i<t;++i){const n=await this.readTiffTag(e);if(n)return n}}async readTiffHeader(e){const t={ext:"tif",mime:"image/tiff"},i=(e?v:w).get(this.buffer,2),n=(e?x:f).get(this.buffer,4);if(i===42){if(n>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(n>=8){const o=(e?v:w).get(this.buffer,8),c=(e?v:w).get(this.buffer,10);if(o===28&&c===254||o===31&&c===11)return{ext:"nef",mime:"image/x-nikon-nef"}}}if(L(this.tokenizer)&&n>lr)return t;const r=L(this.tokenizer)?$a:this.tokenizer.fileInfo.size;try{await he(this.tokenizer,n,{maximumLength:r,reason:"TIFF IFD offset"})}catch(o){if(o instanceof E)return;throw o}let s;try{s=await this.readTiffIFD(e)}catch(o){if(o instanceof E)return;throw o}return s!=null?s:t}if(i===43)return t}scanMpeg(e){if(this.check([255,224],{offset:e,mask:[255,224]})){if(this.check([16],{offset:e+1,mask:[22]}))return this.check([8],{offset:e+1,mask:[8]})?{ext:"aac",mime:"audio/aac"}:{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:e+1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:e+1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:e+1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}}new Set(Jn);new Set(Qn);var Ne={};/*!
2 * media-typer
3 * Copyright(c) 2014-2017 Douglas Christopher Wilson
4 * MIT Licensed
5 */var Wa;function zr(){if(Wa)return Ne;Wa=1;var a=/^[A-Za-z0-9][A-Za-z0-9!#$&^_.-]{0,126}$/,e=/^[A-Za-z0-9][A-Za-z0-9!#$&^_-]{0,126}$/,t=/^ *([A-Za-z0-9][A-Za-z0-9!#$&^_-]{0,126})\/([A-Za-z0-9][A-Za-z0-9!#$&^_.+-]{0,126}) *$/;Ne.format=i,Ne.parse=r,Ne.test=n;function i(o){if(!o||typeof o!="object")throw new TypeError("argument obj is required");var c=o.subtype,l=o.suffix,d=o.type;if(!d||!e.test(d))throw new TypeError("invalid type");if(!c||!a.test(c))throw new TypeError("invalid subtype");var m=d+"/"+c;if(l){if(!e.test(l))throw new TypeError("invalid suffix");m+="+"+l}return m}function n(o){if(!o)throw new TypeError("argument string is required");if(typeof o!="string")throw new TypeError("argument string is required to be a string");return t.test(o.toLowerCase())}function r(o){if(!o)throw new TypeError("argument string is required");if(typeof o!="string")throw new TypeError("argument string is required to be a string");var c=t.exec(o.toLowerCase());if(!c)throw new TypeError("invalid media type");var l=c[1],d=c[2],m,p=d.lastIndexOf("+");return p!==-1&&(m=d.substr(p+1),d=d.substr(0,p)),new s(l,d,m)}function s(o,c,l){this.type=o,this.subtype=c,this.suffix=l}return Ne}var _r=zr();const Mr={10:"shot",20:"scene",30:"track",40:"part",50:"album",60:"edition",70:"collection"},X={video:1,audio:2,complex:3,logo:4,subtitle:17,button:18,control:32},Br={[X.video]:"video",[X.audio]:"audio",[X.complex]:"complex",[X.logo]:"logo",[X.subtitle]:"subtitle",[X.button]:"button",[X.control]:"control"},Ve=a=>class extends Error{constructor(t){super(t),this.name=a}};class Or extends Ve("CouldNotDetermineFileTypeError"){}class Rr extends Ve("UnsupportedFileTypeError"){}class Lr extends Ve("UnexpectedFileContentError"){constructor(e,t){super(t),this.fileType=e}
5toString(){return"".concat(this.name," (FileType: ").concat(this.fileType,"): ").concat(this.message)}}class wa extends Ve("FieldDecodingError"){}class Bi extends Ve("InternalParserError"){}const O=a=>class extends Lr{constructor(e){super(a,e)}};function I(a,e,t){return(a[e]&1<<t)!==0}function pe(a,e){const t=a.length;if(e==="utf-16le"){for(let i=0;i+1<t;i+=2)if(a[i]===0&&a[i+1]===0)return i;return t}for(let i=0;i<t;i++)if(a[i]===0)return i;return t}function Oi(a){const e=a.indexOf("\0");return e===-1?a:a.substring(0,e)}function Nr(a){const e=a.length;if((e&1)!==0)throw new wa("Buffer length must be even");for(let t=0;t<e;t+=2){const i=a[t];a[t]=a[t+1],a[t+1]=i}return a}function N(a,e){if(a[0]===255&&a[1]===254)return N(a.subarray(2),e);if(e==="utf-16le"&&a[0]===254&&a[1]===255){if((a.length&1)!==0)throw new wa("Expected even number of octets for 16-bit unicode string");return N(Nr(a),e)}return new k(a.length,e).get(a,0)}function ge(a){return a=a.replace(/^\x00+/g,""),a=a.replace(/\x00+$/g,""),a}function S(a,e,t,i){const n=e+~~(t/8),r=t%8;let s=a[n];s&=255>>r;const o=8-r,c=i-o;return c<0?s>>=8-r-i:c>0&&(s<<=c,s|=S(a,e,t+o,c)),s}function q(a,e,t){return S(a,e,t,1)===1}function $r(a){const e=[];for(let t=0,i=a.length;t<i;t++){const n=Number(a.charCodeAt(t)).toString(16);e.push(n.length===1?"0".concat(n):n)}return e.join(" ")}function Ur(a){return 10*Math.log10(a)}function jr(a){return 10**(a/10)}function Gr(a){const e=a.split(" ").map(t=>t.trim().toLowerCase());if(e.length>=1){const t=Number.parseFloat(e[0]);return e.length===2&&e[1]==="db"?{dB:t,ratio:jr(t)}:{dB:Ur(t),ratio:t}}}function Ha(a){if(a.length===0)throw new Error("decodeUintBE: empty Uint8Array");const e=new DataView(a.buffer,a.byteOffset,a.byteLength);return Qt(e)}const Ta={0:"Other",1:"32x32 pixels 'file icon' (PNG only)",2:"Other file icon",3:"Cover (front)",4:"Cover (back)",5:"Leaflet page",6:"Media (e.g. label side of CD)",7:"Lead artist/lead performer/soloist",8:"Artist/performer",9:"Conductor",10:"Band/Orchestra",11:"Composer",12:"Lyricist/text writer",13:"Recording Location",14:"During recording",15:"During performance",16:"Movie/video screen capture",17:"A bright coloured fish",18:"Illustration",19:"Band/artist logotype",20:"Publisher/Studio logotype"},Ri={other:0,lyrics:1,text:2,movement_part:3,events:4,chord:5,trivia_pop:6},Li={notSynchronized:0,mpegFrameNumber:1,milliseconds:2},Ni={get:(a,e)=>a[e+3]&127|a[e+2]<<7|a[e+1]<<14|a[e]<<21,len:4},ea={len:10,get:(a,e)=>({fileIdentifier:new k(3,"ascii").get(a,e),version:{major:ke.get(a,e+3),revision:ke.get(a,e+4)},flags:{unsynchronisation:I(a,e+5,7),isExtendedHeader:I(a,e+5,6),expIndicator:I(a,e+5,5),footer:I(a,e+5,4)},size:Ni.get(a,e+6)})},Xa={len:10,get:(a,e)=>({size:x.get(a,e),extendedFlags:v.get(a,e+4),sizeOfPadding:x.get(a,e+6),crcDataPresent:I(a,e+4,31)})},Ue={len:1,get:(a,e)=>{switch(a[e]){case 0:return{encoding:"latin1"};case 1:return{encoding:"utf-16le",bom:!0};case 2:return{encoding:"utf-16le",bom:!1};case 3:return{encoding:"utf8",bom:!1};default:return{encoding:"utf8",bom:!1}}}},ta={len:4,get:(a,e)=>({encoding:Ue.get(a,e),language:new k(3,"latin1").get(a,e+1)})},Va={len:6,get:(a,e)=>{const t=ta.get(a,e);return{encoding:t.encoding,language:t.language,timeStampFormat:T.get(a,e+4),contentType:T.get(a,e+5)}}},g={multiple:!1},ft={year:g,track:g,disk:g,title:g,artist:g,artists:{multiple:!0,unique:!0},albumartist:g,albumartists:{multiple:!0,unique:!0},album:g,date:g,originaldate:g,originalyear:g,releasedate:g,comment:{multiple:!0,unique:!1},genre:{multiple:!0,unique:!0},picture:{multiple:!0,unique:!0},composer:{multiple:!0,unique:!0},lyrics:{multiple:!0,unique:!1},albumsort:{multiple:!1,unique:!0},titlesort:{multiple:!1,unique:!0},work:{multiple:!1,unique:!0},artistsort:{multiple:!1,unique:!0},albumartistsort:{multiple:!1,unique:!0},composersort:{multiple:!1,unique:!0},lyricist:{multiple:!0,unique:!0},writer:{multiple:!0,unique:!0},conductor:{multiple:!0,unique:!0},remixer:{multiple:!0,unique:!0},arranger:{multiple:!0,unique:!0},engineer:{multiple:!0,unique:!0},producer:{multiple:!0,unique:!0},technician:{multiple:!0,unique:!0},djmixer:{multiple:!0,unique:!0},mixer:{multiple:!0,unique:!0},label:{multiple:!0,unique:!0},grouping:g,subtitle:{multiple:!0},discsubtitle:g,totaltracks:g,totaldiscs:g,compilation:g,rating:{multiple:!0},bpm:g,mood:g,media:g,catalognumber:{multiple:!0,unique:!0},tvShow:g,tvShowSort:g,tvSeason:g,tvEpisode:g,tvEpisodeId:g,tvNetwork:g,podcast:g,podcasturl:g,releasestatus:g,releasetype:{multiple:!0},releasecountry:g,script:g,language:g,copyright:g,license:g,encodedby:g,encodersettings:g,gapless:g,barcode:g,isrc:{multiple:!0},asin:g,musicbrainz_recordingid:g,musicbrainz_trackid:g,musicbrainz_albumid:g,musicbrainz_artistid:{multiple:!0},musicbrainz_albumartistid:{multiple:!0},musicbrainz_releasegroupid:g,musicbrainz_workid:g,musicbrainz_trmid:g,musicbrainz_discid:g,acoustid_id:g,acoustid_fingerprint:g,musicip_puid:g,musicip_fingerprint:g,website:g,"performer:instrument":{multiple:!0,unique:!0},averageLevel:g,peakLevel:g,notes:{multiple:!0,unique:!1},key:g,originalalbum:g,originalartist:g,discogs_artist_id:{multiple:!0,unique:!0},discogs_release_id:g,discogs_label_id:g,discogs_master_release_id:g,discogs_votes:g,discogs_rating:g,replaygain_track_peak:g,replaygain_track_gain:g,replaygain_album_peak:g,replaygain_album_gain:g,replaygain_track_minmax:g,replaygain_album_minmax:g,replaygain_undo:g,description:{multiple:!0},longDescription:g,category:{multiple:!0},hdVideo:g,keywords:{multiple:!0},movement:g,movementIndex:g,movementTotal:g,podcastId:g,showMovement:g,stik:g,playCounter:g};function Wr(a){return ft[a]&&!ft[a].multiple}function Hr(a){return!ft[a].multiple||ft[a].unique||!1}class Z{static toIntOrNull(e){const t=Number.parseInt(e,10);return Number.isNaN(t)?null:t}static normalizeTrack(e){const t=e.toString().split("/");return{no:Number.parseInt(t[0],10)||null,of:Number.parseInt(t[1],10)||null}}constructor(e,t){this.tagTypes=e,this.tagMap=t}mapGenericTag(e,t){e={id:e.id,value:e.value},this.postMap(e,t);const i=this.getCommonName(e.id);return i?{id:i,value:e.value}:null}getCommonName(e){return this.tagMap[e]}postMap(e,t){}}Z.maxRatingScore=1;const Xr={title:"title",artist:"artist",album:"album",year:"year",comment:"comment",track:"track",genre:"genre"};class Vr extends Z{constructor(){super(["ID3v1"],Xr)}}class qe extends Z{constructor(e,t){const i={};for(const n of Object.keys(t))i[n.toUpperCase()]=t[n];super(e,i)}getCommonName(e){return this.tagMap[e.toUpperCase()]}}const qr={TIT2:"title",TPE1:"artist","TXXX:Artists":"artists",TPE2:"albumartist",TALB:"album",TDRV:"date",TORY:"originalyear",TPOS:"disk",TCON:"genre",APIC:"picture",TCOM:"composer",USLT:"lyrics",TSOA:"albumsort",TSOT:"titlesort",TOAL:"originalalbum",TSOP:"artistsort",TSO2:"albumartistsort",TSOC:"c
5omposersort",TEXT:"lyricist","TXXX:Writer":"writer",TPE3:"conductor",TPE4:"remixer","IPLS:arranger":"arranger","IPLS:engineer":"engineer","IPLS:producer":"producer","IPLS:DJ-mix":"djmixer","IPLS:mix":"mixer",TPUB:"label",TIT1:"grouping",TIT3:"subtitle",TRCK:"track",TCMP:"compilation",POPM:"rating",TBPM:"bpm",TMED:"media","TXXX:CATALOGNUMBER":"catalognumber","TXXX:MusicBrainz Album Status":"releasestatus","TXXX:MusicBrainz Album Type":"releasetype","TXXX:MusicBrainz Album Release Country":"releasecountry","TXXX:RELEASECOUNTRY":"releasecountry","TXXX:SCRIPT":"script",TLAN:"language",TCOP:"copyright",WCOP:"license",TENC:"encodedby",TSSE:"encodersettings","TXXX:BARCODE":"barcode","TXXX:ISRC":"isrc",TSRC:"isrc","TXXX:ASIN":"asin","TXXX:originalyear":"originalyear","UFID:http://musicbrainz.org":"musicbrainz_recordingid","TXXX:MusicBrainz Release Track Id":"musicbrainz_trackid","TXXX:MusicBrainz Album Id":"musicbrainz_albumid","TXXX:MusicBrainz Artist Id":"musicbrainz_artistid","TXXX:MusicBrainz Album Artist Id":"musicbrainz_albumartistid","TXXX:MusicBrainz Release Group Id":"musicbrainz_releasegroupid","TXXX:MusicBrainz Work Id":"musicbrainz_workid","TXXX:MusicBrainz TRM Id":"musicbrainz_trmid","TXXX:MusicBrainz Disc Id":"musicbrainz_discid","TXXX:ACOUSTID_ID":"acoustid_id","TXXX:Acoustid Id":"acoustid_id","TXXX:Acoustid Fingerprint":"acoustid_fingerprint","TXXX:MusicIP PUID":"musicip_puid","TXXX:MusicMagic Fingerprint":"musicip_fingerprint",WOAR:"website",TDRC:"date",TYER:"year",TDOR:"originaldate","TIPL:arranger":"arranger","TIPL:engineer":"engineer","TIPL:producer":"producer","TIPL:DJ-mix":"djmixer","TIPL:mix":"mixer",TMOO:"mood",SYLT:"lyrics",TSST:"discsubtitle",TKEY:"key",COMM:"comment",TOPE:"originalartist","PRIV:AverageLevel":"averageLevel","PRIV:PeakLevel":"peakLevel","TXXX:DISCOGS_ARTIST_ID":"discogs_artist_id","TXXX:DISCOGS_ARTISTS":"artists","TXXX:DISCOGS_ARTIST_NAME":"artists","TXXX:DISCOGS_ALBUM_ARTISTS":"albumartist","TXXX:DISCOGS_CATALOG":"catalognumber","TXXX:DISCOGS_COUNTRY":"releasecountry","TXXX:DISCOGS_DATE":"originaldate","TXXX:DISCOGS_LABEL":"label","TXXX:DISCOGS_LABEL_ID":"discogs_label_id","TXXX:DISCOGS_MASTER_RELEASE_ID":"discogs_master_release_id","TXXX:DISCOGS_RATING":"discogs_rating","TXXX:DISCOGS_RELEASED":"date","TXXX:DISCOGS_RELEASE_ID":"discogs_release_id","TXXX:DISCOGS_VOTES":"discogs_votes","TXXX:CATALOGID":"catalognumber","TXXX:STYLE":"genre","TXXX:REPLAYGAIN_TRACK_PEAK":"replaygain_track_peak","TXXX:REPLAYGAIN_TRACK_GAIN":"replaygain_track_gain","TXXX:REPLAYGAIN_ALBUM_PEAK":"replaygain_album_peak","TXXX:REPLAYGAIN_ALBUM_GAIN":"replaygain_album_gain","TXXX:MP3GAIN_MINMAX":"replaygain_track_minmax","TXXX:MP3GAIN_ALBUM_MINMAX":"replaygain_album_minmax","TXXX:MP3GAIN_UNDO":"replaygain_undo",MVNM:"movement",MVIN:"movementIndex",PCST:"podcast",TCAT:"category",TDES:"description",TDRL:"releasedate",TGID:"podcastId",TKWD:"keywords",WFED:"podcasturl",GRP1:"grouping",PCNT:"playCounter"};class ba extends qe{static toRating(e){return{source:e.email,rating:e.rating>0?(e.rating-1)/254*Z.maxRatingScore:void 0}}constructor(){super(["ID3v2.3","ID3v2.4"],qr)}postMap(e,t){switch(e.id){case"UFID":{const i=e.value;i.owner_identifier==="http://musicbrainz.org"&&(e.id+=":".concat(i.owner_identifier),e.value=N(i.identifier,"latin1"))}break;case"PRIV":{const i=e.value;switch(i.owner_identifier){case"AverageLevel":case"PeakValue":e.id+=":".concat(i.owner_identifier),e.value=i.data.length===4?f.get(i.data,0):null,e.value===null&&t.addWarning("Failed to parse PRIV:PeakValue");break;default:t.addWarning("Unknown PRIV owner-identifier: ".concat(i.data))}}break;case"POPM":e.value=ba.toRating(e.value);break}}}const Zr={Title:"title",Author:"artist","WM/AlbumArtist":"albumartist","WM/AlbumTitle":"album","WM/Year":"date","WM/OriginalReleaseTime":"originaldate","WM/OriginalReleaseYear":"originalyear",Description:"comment","WM/TrackNumber":"track","WM/PartOfSet":"disk","WM/Genre":"genre","WM/Composer":"composer","WM/Lyrics":"lyrics","WM/AlbumSortOrder":"albumsort","WM/TitleSortOrder":"titlesort","WM/ArtistSortOrder":"artistsort","WM/AlbumArtistSortOrder":"albumartistsort","WM/ComposerSortOrder":"composersort","WM/Writer":"lyricist","WM/Conductor":"conductor","WM/ModifiedBy":"remixer","WM/Engineer":"engineer","WM/Producer":"producer","WM/DJMixer":"djmixer","WM/Mixer":"mixer","WM/Publisher":"label","WM/ContentGroupDescription":"grouping","WM/SubTitle":"subtitle","WM/SetSubTitle":"discsubtitle","WM/IsCompilation":"compilation","WM/SharedUserRating":"rating","WM/BeatsPerMinute":"bpm","WM/Mood":"mood","WM/
5Media":"media","WM/CatalogNo":"catalognumber","MusicBrainz/Album Status":"releasestatus","MusicBrainz/Album Type":"releasetype","MusicBrainz/Album Release Country":"releasecountry","WM/Script":"script","WM/Language":"language",Copyright:"copyright",LICENSE:"license","WM/EncodedBy":"encodedby","WM/EncodingSettings":"encodersettings","WM/Barcode":"barcode","WM/ISRC":"isrc","MusicBrainz/Track Id":"musicbrainz_recordingid","MusicBrainz/Release Track Id":"musicbrainz_trackid","MusicBrainz/Album Id":"musicbrainz_albumid","MusicBrainz/Artist Id":"musicbrainz_artistid","MusicBrainz/Album Artist Id":"musicbrainz_albumartistid","MusicBrainz/Release Group Id":"musicbrainz_releasegroupid","MusicBrainz/Work Id":"musicbrainz_workid","MusicBrainz/TRM Id":"musicbrainz_trmid","MusicBrainz/Disc Id":"musicbrainz_discid","Acoustid/Id":"acoustid_id","Acoustid/Fingerprint":"acoustid_fingerprint","MusicIP/PUID":"musicip_puid","WM/ARTISTS":"artists","WM/InitialKey":"key",ASIN:"asin","WM/Work":"work","WM/AuthorURL":"website","WM/Picture":"picture"};class ya extends Z{static toRating(e){return{rating:Number.parseFloat(e+1)/5}}constructor(){super(["asf"],Zr)}postMap(e){switch(e.id){case"WM/SharedUserRating":{const t=e.id.split(":");e.value=ya.toRating(e.value),e.id=t[0];break}}}}const Yr={TT2:"title",TP1:"artist",TP2:"albumartist",TAL:"album",TYE:"year",COM:"comment",TRK:"track",TPA:"disk",TCO:"genre",PIC:"picture",TCM:"composer",TOR:"originaldate",TOT:"originalalbum",TXT:"lyricist",TP3:"conductor",TPB:"label",TT1:"grouping",TT3:"subtitle",TLA:"language",TCR:"c
5opyright",WCP:"license",TEN:"encodedby",TSS:"encodersettings",WAR:"website",PCS:"podcast",TCP:"compilation",TDR:"date",TS2:"albumartistsort",TSA:"albumsort",TSC:"composersort",TSP:"artistsort",TST:"titlesort",WFD:"podcasturl",TBP:"bpm",GP1:"grouping"};class Kr extends qe{constructor(){super(["ID3v2.2"],Yr)}}const Jr={Title:"title",Artist:"artist",Artists:"artists","Album Artist":"albumartist",Album:"album",Year:"date",Originalyear:"originalyear",Originaldate:"originaldate",Releasedate:"releasedate",Comment:"comment",Track:"track",Disc:"disk",DISCNUMBER:"disk",Genre:"genre","Cover Art (Front)":"picture","Cover Art (Back)":"picture",Composer:"composer",Lyrics:"lyrics",ALBUMSORT:"albumsort",TITLESORT:"titlesort",WORK:"work",ARTISTSORT:"artistsort",ALBUMARTISTSORT:"albumartistsort",COMPOSERSORT:"composersort",Lyricist:"lyricist",Writer:"writer",Conductor:"conductor",MixArtist:"remixer",Arranger:"arranger",Engineer:"engineer",Producer:"producer",DJMixer:"djmixer",Mixer:"mixer",Label:"label",Grouping:"grouping",Subtitle:"subtitle",DiscSubtitle:"discsubtitle",Compilation:"compilation",BPM:"bpm",Mood:"mood",Media:"media",CatalogNumber:"catalognumber",MUSICBRAINZ_ALBUMSTATUS:"releasestatus",MUSICBRAINZ_ALBUMTYPE:"releasetype",RELEASECOUNTRY:"releasecountry",Script:"script",Language:"language",Copyright:"copyright",LICENSE:"license",EncodedBy:"encodedby",EncoderSettings:"encodersettings",Barcode:"barcode",ISRC:"isrc",ASIN:"asin",musicbrainz_trackid:"musicbrainz_recordingid",musicbrainz_releasetrackid:"musicbrainz_trackid",MUSICBRAINZ_ALBUMID:"musicbrainz_albumid",MUSICBRAINZ_ARTISTID:"musicbrainz_artistid",MUSICBRAINZ_ALBUMARTISTID:"musicbrainz_albumartistid",MUSICBRAINZ_RELEASEGROUPID:"musicbrainz_releasegroupid",MUSICBRAINZ_WORKID:"musicbrainz_workid",MUSICBRAINZ_TRMID:"musicbrainz_trmid",MUSICBRAINZ_DISCID:"musicbrainz_discid",Acoustid_Id:"acoustid_id",ACOUSTID_FINGERPRINT:"acoustid_fingerprint",MUSICIP_PUID:"musicip_puid",Weblink:"website",REPLAYGAIN_TRACK_GAIN:"replaygain_track_gain",REPLAYGAIN_TRACK_PEAK:"replaygain_track_peak",MP3GAIN_MINMAX:"replaygain_track_minmax",MP3GAIN_UNDO:"replaygain_undo"};class Qr extends qe{constructor(){super(["APEv2"],Jr)}}const es={"©nam":"title","©ART":"artist",aART:"albumartist","----:com.apple.iTunes:Band":"albumartist","©alb":"album","©day":"date","©cmt":"comment","©com":"comment",trkn:"track",disk:"disk","©gen":"genre",covr:"picture","©wrt":"composer","©lyr":"lyrics",soal:"albumsort",sonm:"titlesort",soar:"artistsort",soaa:"albumartistsort",soco:"composersort","----:com.apple.iTunes:LYRICIST":"lyricist","----:com.apple.iTunes:CONDUCTOR":"conductor","----:com.apple.iTunes:REMIXER":"remixer","----:com.apple.iTunes:ENGINEER":"engineer","----:com.apple.iTunes:PRODUCER":"producer","----:com.apple.iTunes:DJMIXER":"djmixer","----:com.apple.iTunes:MIXER":"mixer","----:com.apple.iTunes:LABEL":"label","©grp":"grouping","----:com.apple.iTunes:SUBTITLE":"subtitle","----:com.apple.iTunes:DISCSUBTITLE":"discsubtitle",cpil:"compilation",tmpo:"bpm","----:com.apple.iTunes:MOOD":"mood","----:com.apple.iTunes:MEDIA":"media","----:com.apple.iTunes:CATALOGNUMBER":"catalognumber",tvsh:"tvShow",tvsn:"tvSeason",tves:"tvEpisode",sosn:"tvShowSort",tven:"tvEpisodeId",tvnn:"tvNetwork",pcst:"podcast",purl:"podcasturl","----:com.apple.iTunes:MusicBrainz Album Status":"releasestatus","----:com.apple.iTunes:MusicBrainz Album Type":"releasetype","----:com.apple.iTunes:MusicBrainz Album Release Country":"releasecountry","----:com.apple.iTunes:SCRIPT":"script","----:com.apple.iTunes:LANGUAGE":"language",cprt:"copyright","©cpy":"copyright","----:com.apple.iTunes:LICENSE":"license","©too":"encodedby",pgap:"gapless","----:com.apple.iTunes:BARCODE":"barcode","----:com.apple.iTunes:ISRC":"isrc","----:com.apple.iTunes:ASIN":"asin","----:com.apple.iTunes:NOTES":"comment","----:com.apple.iTunes:MusicBrainz Track Id":"musicbrainz_recordingid","----:com.apple.iTunes:MusicBrainz Release Track Id":"musicbrainz_trackid","----:com.apple.iTunes:MusicBrainz Album Id":"musicbrainz_albumid","----:com.apple.iTunes:MusicBrainz Artist Id":"musicbrainz_artistid","----:com.apple.iTunes:MusicBrainz Album Artist Id":"musicbrainz_albumartistid","----:com.apple.iTunes:MusicBrainz Release Group Id":"musicbrainz_releasegroupid","----:com.apple.iTunes:MusicBrainz Work Id":"musicbrainz_workid","----:com.apple.iTunes:MusicBrainz TRM Id":"musicbrainz_trmid","----:com.apple.iTunes:MusicBrainz Disc Id":"musicbrainz_discid","----:com.apple.iTunes:Acoustid Id":"acoustid_id","----:com.apple.iTunes:Acoustid Fingerprint":"acoustid_fingerprint","----:com.apple.iTunes:MusicIP PUID":"musicip_puid","----:com.apple.iTunes:fingerprint":"musicip_fingerprint","----:com.apple.iTunes:replaygain_track_gain":"replaygain_track_gain","----:com.apple.iTunes:replaygain_track_peak":"replaygain_track_peak","----:com.apple.iTunes:replaygain_album_gain":"replaygain_album_gain","----:com.apple.iTunes:replaygain_album_peak":"replaygain_album_peak","----:com.apple.iTunes:replaygain_track_minmax":"replaygain_track_minmax","----:com.apple.iTunes:replaygain_album_minmax":"replaygain_album_minmax","----:com.apple.iTunes:replaygain_undo":"replaygain_undo",gnre:"genre","----:com.apple.iTunes:ALBUMARTISTSORT":"albumartistsort","----:com.apple.iTunes:ARTISTS":"artists","----:com.apple.iTunes:ORIGINALDATE":"originaldate","----:com.apple.iTunes:ORIGINALYEAR":"originalyear","----:com.apple.iTunes:RELEASEDATE":"releasedate",desc:"description",ldes:"longDescription","©mvn":"movement","©mvi":"movementIndex","©mvc":"movementTotal","©wrk":"work",catg:"category",egid:"podcastId",hdvd:"hdVideo",keyw:"keywords",shwm:"showMovement",stik:"stik",rate:"rating"},ts="iTunes";class qa extends qe{constructor(){super([ts],es)}postMap(e,t){switch(e.id){case"rate":e.value={source:void 0,rating:Number.parseFloat(e.value)/100};break}}}
5const as={TITLE:"title",ARTIST:"artist",ARTISTS:"artists",ALBUMARTIST:"albumartist","ALBUM ARTIST":"albumartist",ALBUM:"album",DATE:"date",ORIGINALDATE:"originaldate",ORIGINALYEAR:"originalyear",RELEASEDATE:"releasedate",COMMENT:"comment",TRACKNUMBER:"track",DISCNUMBER:"disk",GENRE:"genre",METADATA_BLOCK_PICTURE:"picture",COMPOSER:"composer",LYRICS:"lyrics",ALBUMSORT:"albumsort",TITLESORT:"titlesort",WORK:"work",ARTISTSORT:"artistsort",ALBUMARTISTSORT:"albumartistsort",COMPOSERSORT:"composersort",LYRICIST:"lyricist",WRITER:"writer",CONDUCTOR:"conductor",REMIXER:"remixer",ARRANGER:"arranger",ENGINEER:"engineer",PRODUCER:"producer",DJMIXER:"djmixer",MIXER:"mixer",LABEL:"label",GROUPING:"grouping",SUBTITLE:"subtitle",DISCSUBTITLE:"discsubtitle",TRACKTOTAL:"totaltracks",DISCTOTAL:"totaldiscs",COMPILATION:"compilation",RATING:"rating",BPM:"bpm",KEY:"key",MOOD:"mood",MEDIA:"media",CATALOGNUMBER:"catalognumber",RELEASESTATUS:"releasestatus",RELEASETYPE:"releasetype",RELEASECOUNTRY:"releasecountry",SCRIPT:"script",LANGUAGE:"language",COPYRIGHT:"copyright",LICENSE:"license",ENCODEDBY:"encodedby",ENCODERSETTINGS:"encodersettings",BARCODE:"barcode",ISRC:"isrc",ASIN:"asin",MUSICBRAINZ_TRACKID:"musicbrainz_recordingid",MUSICBRAINZ_RELEASETRACKID:"musicbrainz_trackid",MUSICBRAINZ_ALBUMID:"musicbrainz_albumid",MUSICBRAINZ_ARTISTID:"musicbrainz_artistid",MUSICBRAINZ_ALBUMARTISTID:"musicbrainz_albumartistid",MUSICBRAINZ_RELEASEGROUPID:"musicbrainz_releasegroupid",MUSICBRAINZ_WORKID:"musicbrainz_workid",MUSICBRAINZ_TRMID:"musicbrainz_trmid",MUSICBRAINZ_DISCID:"musicbrainz_discid",ACOUSTID_ID:"acoustid_id",ACOUSTID_ID_FINGERPRINT:"acoustid_fingerprint",MUSICIP_PUID:"musicip_puid",WEBSITE:"website",NOTES:"notes",TOTALTRACKS:"totaltracks",TOTALDISCS:"totaldiscs",DISCOGS_ARTIST_ID:"discogs_artist_id",DISCOGS_ARTISTS:"artists",DISCOGS_ARTIST_NAME:"artists",DISCOGS_ALBUM_ARTISTS:"albumartist",DISCOGS_CATALOG:"catalognumber",DISCOGS_COUNTRY:"releasecountry",DISCOGS_DATE:"originaldate",DISCOGS_LABEL:"label",DISCOGS_LABEL_ID:"discogs_label_id",DISCOGS_MASTER_RELEASE_ID:"discogs_master_release_id",DISCOGS_RATING:"discogs_rating",DISCOGS_RELEASED:"date",DISCOGS_RELEASE_ID:"discogs_release_id",DISCOGS_VOTES:"discogs_votes",CATALOGID:"catalognumber",STYLE:"genre",REPLAYGAIN_TRACK_GAIN:"replaygain_track_gain",REPLAYGAIN_TRACK_PEAK:"replaygain_track_peak",REPLAYGAIN_ALBUM_GAIN:"replaygain_album_gain",REPLAYGAIN_ALBUM_PEAK:"replaygain_album_peak",REPLAYGAIN_MINMAX:"replaygain_track_minmax",REPLAYGAIN_ALBUM_MINMAX:"replaygain_album_minmax",REPLAYGAIN_UNDO:"replaygain_undo"};class xt extends Z{static toRating(e,t,i){return{source:e?e.toLowerCase():void 0,rating:Number.parseFloat(t)/i*Z.maxRatingScore}}constructor(){super(["vorbis"],as)}postMap(e){if(e.id==="RATING")e.value=xt.toRating(void 0,e.value,100);else if(e.id.indexOf("RATING:")===0){const t=e.id.split(":");e.value=xt.toRating(t[1],e.value,1),e.id=t[0]}}}const is={IART:"artist",ICRD:"date",INAM:"title",TITL:"title",IPRD:"album",ITRK:"track",IPRT:"track",COMM:"comment",ICMT:"comment",ICNT:"releasecountry",GNRE:"genre",IWRI:"writer",RATE:"rating",YEAR:"year",ISFT:"encodedby",CODE:"encodedby",TURL:"website",IGNR:"genre",IENG:"engineer",ITCH:"technician",IMED:"media",IRPD:"album"};class ns extends Z{constructor(){super(["exif"],is)}}const rs={"segment:title":"title","album:ARTIST":"albumartist","album:ARTISTSORT":"albumartistsort","album:TITLE":"album","album:DATE_RECORDED":"originaldate","album:DATE_RELEASED":"releasedate","album:PART_NUMBER":"disk","album:TOTAL_PARTS":"totaltracks","track:ARTIST":"artist","track:ARTISTSORT":"artistsort","track:TITLE":"title","track:PART_NUMBER":"track","track:MUSICBRAINZ_TRACKID":"musicbrainz_recordingid","track:MUSICBRAINZ_ALBUMID":"musicbrainz_albumid","track:MUSICBRAINZ_ARTISTID":"musicbrainz_artistid","track:PUBLISHER":"label","track:GENRE":"genre","track:ENCODER":"encodedby","track:ENCODER_OPTIONS":"encodersettings","edition:TOTAL_PARTS":"totaldiscs",picture:"picture"};class ss extends qe{constructor(){super(["matroska"],rs)}}
5const os={NAME:"title",AUTH:"artist","(c) ":"copyright",ANNO:"comment"};class cs extends Z{constructor(){super(["AIFF"],os)}}class ls{constructor(){this.tagMappers={},[new Vr,new Kr,new ba,new qa,new qa,new xt,new Qr,new ya,new ns,new ss,new cs].forEach(e=>{this.registerTagMapper(e)})}mapTag(e,t,i){if(this.tagMappers[e])return this.tagMappers[e].mapGenericTag(t,i);throw new Bi("No generic tag mapper defined for tag-format: ".concat(e))}registerTagMapper(e){for(const t of e.tagTypes)this.tagMappers[t]=e}}const aa=/\[(\d{2}):(\d{2})\.(\d{2,3})]/;function ds(a){return aa.test(a)?us(a):ms(a)}function ms(a){return{contentType:Ri.lyrics,timeStampFormat:Li.notSynchronized,text:a.trim(),syncText:[]}}function us(a){const e=a.split("\n"),t=[];for(const i of e){const n=i.match(aa);if(n){const r=Number.parseInt(n[1],10),s=Number.parseInt(n[2],10),o=n[3].length===3?Number.parseInt(n[3],10):Number.parseInt(n[3],10)*10,c=(r*60+s)*1e3+o,l=i.replace(aa,"").trim();t.push({timestamp:c,text:l})}}return{contentType:Ri.lyrics,timeStampFormat:Li.milliseconds,text:t.map(i=>i.text).join("\n"),syncText:t}}const Te=C("music-metadata:collector"),hs=["matroska","APEv2","vorbis","ID3v2.4","ID3v2.3","ID3v2.2","exif","asf","iTunes","AIFF","ID3v1"];class ps{constructor(e){this.format={tagTypes:[],trackInfo:[]},this.native={},this.common={track:{no:null,of:null},disk:{no:null,of:null},movementIndex:{no:null,of:null}},this.quality={warnings:[]},this.commonOrigin={},this.originPriority={},this.tagMapper=new ls,this.opts=e;let t=1;for(const i of hs)this.originPriority[i]=t++;this.originPriority.artificial=500,this.originPriority.id3v1=600}hasAny(){return Object.keys(this.native).length>0}addStreamInfo(e){Te("streamInfo: type=".concat(e.type?Br[e.type]:"?",", codec=").concat(e.codecName)),this.format.trackInfo.push(e)}setFormat(e,t){var i;Te("format: ".concat(e," = ").concat(t)),this.format[e]=t,(i=this.opts)!=null&&i.observer&&this.opts.observer({metadata:this,tag:{type:"format",id:e,value:t}})}setAudioOnly(){this.setFormat("hasAudio",!0),this.setFormat("hasVideo",!1)}async addTag(e,t,i){Te("tag ".concat(e,".").concat(t," = ").concat(i)),this.native[e]||(this.format.tagTypes.push(e),this.native[e]=[]),this.native[e].push({id:t,value:i}),await this.toCommon(e,t,i)}addWarning(e){this.quality.warnings.push({message:e})}async postMap(e,t){switch(t.id){case"artist":return this.handleSingularArtistTag(e,t,"artist","artists");case"albumartist":return this.handleSingularArtistTag(e,t,"albumartist","albumartists");case"artists":return this.handlePluralArtistTag(e,t,"artist","artists");case"albumartists":return this.handlePluralArtistTag(e,t,"albumartist","albumartists");case"picture":return this.postFixPicture(t.value).then(i=>{i!==null&&(t.value=i,this.setGenericTag(e,t))});case"totaltracks":this.common.track.of=Z.toIntOrNull(t.value);return;case"totaldiscs":this.common.disk.of=Z.toIntOrNull(t.value);return;case"movementTotal":this.common.movementIndex.of=Z.toIntOrNull(t.value);return;case"track":case"disk":case"movementIndex":{const i=this.common[t.id].of;this.common[t.id]=Z.normalizeTrack(t.value),this.common[t.id].of=i!=null?i:this.common[t.id].of;return}case"bpm":case"year":case"originalyear":t.value=Number.parseInt(t.value,10);break;case"date":{const i=Number.parseInt(t.value.substr(0,4),10);Number.isNaN(i)||(this.common.year=i);break}case"discogs_label_id":case"discogs_release_id":case"discogs_master_release_id":case"discogs_artist_id":case"discogs_votes":t.value=typeof t.value=="string"?Number.parseInt(t.value,10):t.value;break;case"replaygain_track_gain":case"replaygain_track_peak":case"replaygain_album_gain":case"replaygain_album_peak":t.value=Gr(t.value);break;case"replaygain_track_minmax":t.value=t.value.split(",").map(i=>Number.parseInt(i,10));break;case"replaygain_undo":{const i=t.value.split(",").map(n=>Number.parseInt(n,10));t.value={leftChannel:i[0],rightChannel:i[1]};break}case"gapless":case"compilation":case"podcast":case"showMovement":t.value=t.value==="1"||t.value===1;break;case"isrc":{const i=this.common[t.id];if(i&&i.indexOf(t.value)!==-1)return;break}case"comment":typeof t.value=="string"&&(t.value={text:t.value}),t.value.descriptor==="iTunPGAP"&&this.setGenericTag(e,{id:"gapless",value:t.value.text==="1"});break;case"lyrics":typeof t.value=="string"&&(t.value=ds(t.value));break}t.value!==null&&this.setGenericTag(e,t)}toCommonMetadata(){return{format:this.format,native:this.native,quality:this.qual
5ity,common:this.common}}handleSingularArtistTag(e,t,i,n){if(this.commonOrigin[i]===this.originPriority[e])return this.postMap("artificial",{id:n,value:t.value});this.common[n]||this.setGenericTag("artificial",{id:n,value:t.value}),this.setGenericTag(e,t)}handlePluralArtistTag(e,t,i,n){if((!this.common[i]||this.commonOrigin[i]===this.originPriority.artificial)&&(!this.common[n]||this.common[n].indexOf(t.value)===-1)){const r=(this.common[n]||[]).concat([t.value]),s=gs(r);this.setGenericTag("artificial",{id:i,value:s})}this.setGenericTag(e,t)}async postFixPicture(e){if(e.data&&e.data.length>0){if(!e.format){const t=await Mi(Uint8Array.from(e.data));if(t)e.format=t.mime;else return null}switch(e.format=e.format.toLocaleLowerCase(),e.format){case"image/jpg":e.format="image/jpeg"}return e}return this.addWarning("Empty picture tag found"),null}async toCommon(e,t,i){const n={id:t,value:i},r=this.tagMapper.mapTag(e,n,this);r&&await this.postMap(e,r)}setGenericTag(e,t){var r;Te("common.".concat(t.id," = ").concat(t.value));const i=this.commonOrigin[t.id]||1e3,n=this.originPriority[e];if(Wr(t.id))if(n<=i)this.common[t.id]=t.value,this.commonOrigin[t.id]=n;else return Te("Ignore native tag (singleton): ".concat(e,".").concat(t.id," = ").concat(t.value));else if(n===i)!Hr(t.id)||this.common[t.id].indexOf(t.value)===-1?this.common[t.id].push(t.value):Te("Ignore duplicate value: ".concat(e,".").concat(t.id," = ").concat(t.value));else if(n<i)this.common[t.id]=[t.value],this.commonOrigin[t.id]=n;else return Te("Ignore native tag (list): ".concat(e,".").concat(t.id," = ").concat(t.value));(r=this.opts)!=null&&r.observer&&this.opts.observer({metadata:this,tag:{type:"common",id:t.id,value:t.value}})}}function gs(a){return a.length>2?"".concat(a.slice(0,a.length-1).join(", ")," & ").concat(a[a.length-1]):a.join(" & ")}const fs={parserType:"mpeg",extensions:[".mp2",".mp3",".m2a",".aac","aacp"],mimeTypes:["audio/mpeg","audio/mp3","audio/aacs","audio/aacp"],async load(){return(await K(async()=>{const{MpegParser:a}=await Promise.resolve().then(()=>Ys);return{MpegParser:a}},void 0)).MpegParser}},xs={parserType:"apev2",extensions:[".ape"],mimeTypes:["audio/ape","audio/monkeys-audio"],async load(){return(await K(async()=>{const{APEv2Parser:a}=await Promise.resolve().then(()=>_s);return{APEv2Parser:a}},void 0)).APEv2Parser}},ks={parserType:"asf",extensions:[".asf",".wma",".wmv"],mimeTypes:["audio/ms-wma","video/ms-wmv","audio/ms-asf","video/ms-asf","application/vnd.ms-asf"],async load(){return(await K(async()=>{const{AsfParser:a}=await Promise.resolve().then(()=>lo);return{AsfParser:a}},void 0)).AsfParser}},ws={parserType:"dsdiff",extensions:[".dff"],mimeTypes:["audio/dsf","audio/dsd"],async load(){return(await K(async()=>{const{DsdiffParser:a}=await Promise.resolve().then(()=>uo);return{DsdiffParser:a}},void 0)).DsdiffParser}},Ts={parserType:"aiff",extensions:[".aif","aiff","aifc"],mimeTypes:["audio/aiff","audio/aif","audio/aifc","application/aiff"],async load(){return(await K(async()=>{const{AIFFParser:a}=await Promise.resolve().then(()=>fo);return{AIFFParser:a}},void 0)).AIFFParser}},bs={parserType:"dsf",extensions:[".dsf"],mimeTypes:["audio/dsf"],async load(){return(await K(async()=>{const{DsfParser:a}=await Promise.resolve().then(()=>To);return{DsfParser:a}},void 0)).DsfParser}},ys={parserType:"flac",extensions:[".flac"],mimeTypes:["audio/flac"],async load(){return(await K(async()=>{const{FlacParser:a}=await Promise.resolve().then(()=>So);return{FlacParser:a}},void 0)).FlacParser}},Ss={parserType:"matroska",extensions:[".mka",".mkv",".mk3d",".mks","webm"],mimeTypes:["audio/matroska","video/matroska","audio/webm","video/webm"],async load(){return(await K(async()=>{const{MatroskaParser:a}=await Promise.resolve().then(()=>Ao);return{MatroskaParser:a}},void 0)).MatroskaParser}},Is={parserType:"mp4",extensions:[".mp4",".m4a",".m4b",".m4pa","m4v","m4r","3gp",".mov",".movie",".qt"],mimeTypes:["audio/mp4","audio/m4a","video/m4v","video/mp4","video/quicktime"],async load(){return(await K(async()=>{const{MP4Parser:a}=await Promise.resolve().then(()=>qo);return{MP4Parser:a}},void 0)).MP4Parser}},vs={parserType:"musepack",extensions:[".mpc"],mimeTypes:["audio/musepack"],async load(){return(await K(async()=>{const{MusepackParser:a}=await Promise.resolve().then(()=>ic);return{MusepackParser:a}},void 0)).MusepackParser}},Cs={parserType:"ogg",extensions:[".ogg",".ogv",".oga",".ogm",".ogx",".opus",".spx"],mimeTypes:["audio/ogg","audio/opus","audio/speex","video/ogg"],async load(){return(await K(async()=>{const{OggParser:a}=await Promise.resolve().then(()=>gc);return{OggParser:a}},void 0)).OggParser}},Es={parserType:"wavpack",extensions:[".wv",".wvp"],mimeTypes:["audio/wavpack"],async load(){return(await K(async()=>{const{WavPackParser:a}=await Promise.resolve().then(()=>kc);return{WavPackParser:a}},void 0)).WavPackParser}},As={parserType:"riff",extensions:[".wav","wave",".bwf"],mimeTypes:["audio/vnd.wave","audio/wav","audio/wave"],async load(){return(await K(async()=>{const{WaveParser:a}=await Promise.resolve().then(()=>Ic);return{WaveParser:a}},void 0)).WaveParser}},be=C("music-metadata:parser:factory");function Fs(a){const e=en.parse(a),t=_r.parse(e.type);return{type:t.type,subtype:t.subtype,suffix:t.suffix,parameters:e.parameters}}class $i{constructor(){this.parsers=[],[ys,fs,xs,Is,Ss,As,Cs,ks,Ts,Es,vs,bs,ws].forEac
5h(e=>{this.registerParser(e)})}registerParser(e){this.parsers.push(e)}async parse(e,t,i){if(e.supportsRandomAccess()?(be("tokenizer supports random-access, scanning for appending headers"),await Rs(e,i)):be("tokenizer does not support random-access, cannot scan for appending headers"),!t){const o=new Uint8Array(4100);if(e.fileInfo.mimeType&&(t=this.findLoaderForContentType(e.fileInfo.mimeType)),!t&&e.fileInfo.path&&(t=this.findLoaderForExtension(e.fileInfo.path)),!t){be("Guess parser on content..."),await e.peekBuffer(o,{mayBeLess:!0});const c=await Mi(o,{mpegOffsetTolerance:10});if(!c||!c.mime)throw new Or("Failed to determine audio format");if(be("Guessed file type is mime=".concat(c.mime,", extension=").concat(c.ext)),t=this.findLoaderForContentType(c.mime),!t)throw new Rr("Guessed MIME-type not supported: ".concat(c.mime))}}be("Loading ".concat(t.parserType," parser..."));const n=new ps(i),r=await t.load(),s=new r(n,e,i!=null?i:{});return be("Parser ".concat(t.parserType," loaded")),await s.parse(),n.format.trackInfo&&(n.format.hasAudio===void 0&&n.setFormat("hasAudio",!!n.format.trackInfo.find(o=>o.type===X.audio)),n.format.hasVideo===void 0&&n.setFormat("hasVideo",!!n.format.trackInfo.find(o=>o.type===X.video))),n.toCommonMetadata()}findLoaderForExtension(e){if(!e)return;const t=Ds(e).toLocaleLowerCase()||e;return this.parsers.find(i=>i.extensions.indexOf(t)!==-1)}findLoaderForContentType(e){let t;if(!e)return;try{t=Fs(e)}catch(n){be("Invalid HTTP Content-Type header value: ".concat(e));return}const i=t.subtype.indexOf("x-")===0?t.subtype.substring(2):t.subtype;return this.parsers.find(n=>n.mimeTypes.find(r=>r.indexOf("".concat(t.type,"/").concat(i))!==-1))}getSupportedMimeTypes(){const e=new Set;return this.parsers.forEach(t=>{t.mimeTypes.forEach(i=>{e.add(i),e.add(i.replace("/","/x-"))})}),Array.from(e)}}function Ds(a){const e=a.lastIndexOf(".");return e===-1?"":a.substring(e)}class J{constructor(e,t,i){this.metadata=e,this.tokenizer=t,this.options=i}}const Ps=/^[\x21-\x7e©][\x20-\x7e\x00()]{3}/,F={len:4,get:(a,e)=>{const t=te(a.subarray(e,e+F.len),"latin1");if(!t.match(Ps))throw new wa("FourCC contains invalid characters: ".concat($r(t),' "').concat(t,'"'));return t},put:(a,e,t)=>{const i=hn(t,"latin1");if(i.length!==4)throw new Bi("Invalid length");return a.set(i,e),e+4}},tt={text_utf8:0,binary:1,external_info:2,reserved:3},Za={len:52,get:(a,e)=>({ID:F.get(a,e),version:f.get(a,e+4)/1e3,descriptorBytes:f.get(a,e+8),headerBytes:f.get(a,e+12),seekTableBytes:f.get(a,e+16),headerDataBytes:f.get(a,e+20),apeFrameDataBytes:f.get(a,e+24),apeFrameDataBytesHigh:f.get(a,e+28),terminatingDataBytes:f.get(a,e+32),fileMD5:new U(16).get(a,e+36)})},zs={len:24,get:(a,e)=>({compressionLevel:w.get(a,e),formatFlags:w.get(a,e+2),blocksPerFrame:f.get(a,e+4),finalFrameBlocks:f.get(a,e+8),totalFrames:f.get(a,e+12),bitsPerSample:w.get(a,e+16),channel:w.get(a,e+18),sampleRate:f.get(a,e+20)})},G={len:32,get:(a,e)=>({ID:new k(8,"ascii").get(a,e),version:f.get(a,e+8),size:f.get(a,e+12),fields:f.get(a,e+16),flags:Ui(f.get(a,e+20))})},Nt={len:8,get:(a,e)=>({size:f.get(a,e),flags:Ui(f.get(a,e+4))})};function Ui(a){return{containsHeader:at(a,31),containsFooter:at(a,30),isHeader:at(a,29),readOnly:at(a,0),dataType:(a&6)>>1}}function at(a,e){return(a&1<<e)!==0}const me=C("music-metadata:parser:APEv2"),Ya="APEv2",Ka="APETAGEX";class dt extends O("APEv2"){}function Ft(a,e,t){return new fe(a,e,t).tryParseApeHeader()}class fe extends J{constructor(){super(...arguments),this.ape={}}static calculateDuration(e){let t=e.totalFrames>1?e.blocksPerFrame*(e.totalFrames-1):0;return t+=e.finalFrameBlocks,t/e.sampleRate}static async findApeFooterOffset(e,t){const i=new Uint8Array(G.len),n=e.position;if(t<=G.len){me("Offset is too small to read APE footer: offset=".concat(t));return}if(t>G.len){await e.readBuffer(i,{position:t-G.len}),e.setPosition(n);const r=G.get(i,0);if(r.ID==="APETAGEX")return r.flags.isHeader?me("APE Header found at offset=".concat(t-G.len)):(me("APE Footer found at offset=".concat(t-G.len)),t-=r.size),{footer:r,offset:t}}}static parseTagFooter(e,t,i){const n=G.get(t,t.length-G.len);if(n.ID!==Ka)throw new dt("Unexpected APEv2 Footer ID preamble value");return Ce(t),new fe(e,Ce(t),i).parseTags(n)}
5async tryParseApeHeader(){if(this.tokenizer.fileInfo.size&&this.tokenizer.fileInfo.size-this.tokenizer.position<G.len){me("No APEv2 header found, end-of-file reached");return}const e=await this.tokenizer.peekToken(G);if(e.ID===Ka)return await this.tokenizer.ignore(G.len),this.parseTags(e);if(me("APEv2 header not found at offset=".concat(this.tokenizer.position)),this.tokenizer.fileInfo.size){const t=this.tokenizer.fileInfo.size-this.tokenizer.position,i=new Uint8Array(t);return await this.tokenizer.readBuffer(i),fe.parseTagFooter(this.metadata,i,this.options)}}async parse(){const e=await this.tokenizer.readToken(Za);if(e.ID!=="MAC ")throw new dt("Unexpected descriptor ID");this.ape.descriptor=e;const t=e.descriptorBytes-Za.len,i=await(t>0?this.parseDescriptorExpansion(t):this.parseHeader());return this.metadata.setAudioOnly(),await this.tokenizer.ignore(i.forwardBytes),this.tryParseApeHeader()}async parseTags(e){const t=new Uint8Array(256);let i=e.size-G.len;me("Parse APE tags at offset=".concat(this.tokenizer.position,", size=").concat(i));for(let n=0;n<e.fields;n++){if(i<Nt.len){this.metadata.addWarning("APEv2 Tag-header: ".concat(e.fields-n," items remaining, but no more tag data to read."));break}const r=await this.tokenizer.readToken(Nt);i-=Nt.len+r.size,await this.tokenizer.peekBuffer(t,{length:Math.min(t.length,i)});let s=pe(t);const o=await this.tokenizer.readToken(new k(s,"ascii"));switch(await this.tokenizer.ignore(1),i-=o.length+1,r.flags.dataType){case tt.text_utf8:{const l=(await this.tokenizer.readToken(new k(r.size,"utf8"))).split(/\x00/g);await Promise.all(l.map(d=>this.metadata.addTag(Ya,o,d)));break}case tt.binary:if(this.options.skipCovers)await this.tokenizer.ignore(r.size);else{const c=new Uint8Array(r.size);await this.tokenizer.readBuffer(c),s=pe(c);const l=te(c.subarray(0,s),"utf-8"),d=c.subarray(s+1);await this.metadata.addTag(Ya,o,{description:l,data:d})}break;case tt.external_info:me("Ignore external info ".concat(o)),await this.tokenizer.ignore(r.size);break;case tt.reserved:me("Ignore external info ".concat(o)),this.metadata.addWarning('APEv2 header declares a reserved datatype for "'.concat(o,'"')),await this.tokenizer.ignore(r.size);break}}}async parseDescriptorExpansion(e){return await this.tokenizer.ignore(e),this.parseHeader()}async parseHeader(){const e=await this.tokenizer.readToken(zs);if(this.metadata.setFormat("lossless",!0),this.metadata.setFormat("container","Monkey's Audio"),this.metadata.setFormat("bitsPerSample",e.bitsPerSample),this.metadata.setFormat("sampleRate",e.sampleRate),this.metadata.setFormat("numberOfChannels",e.channel),this.metadata.setFormat("duration",fe.calculateDuration(e)),!this.ape.descriptor)throw new dt("Missing APE descriptor");return{forwardBytes:this.ape.descriptor.seekTableBytes+this.ape.descriptor.headerDataBytes+this.ape.descriptor.apeFrameDataBytes+this.ape.descriptor.terminatingDataBytes}}}const _s=Object.freeze(Object.defineProperty({__proto__:null,APEv2Parser:fe,ApeContentError:dt,tryParseApeHeader:Ft},Symbol.toStringTag,{value:"Module"})),it=C("music-metadata:parser:ID3v1"),kt=["Blues","Classic Rock","Country","Dance","Disco","Funk","Grunge","Hip-Hop","Jazz","Metal","New Age","Oldies","Other","Pop","R&B","Rap","Reggae","Rock","Techno","Industrial","Alternative","Ska","Death Metal","Pranks","Soundtrack","Euro-Techno","Ambient","Trip-Hop","Vocal","Jazz+Funk","Fusion","Trance","Classical","Instrumental","Acid","House","Game","Sound Clip","Gospel","Noise","Alt. Rock","Bass","Soul","Punk","Space","Meditative","Instrumental Pop","Instrumental Rock","Ethnic","Gothic","Darkwave","Techno-Industrial","Electronic","Po
5p-Folk","Eurodance","Dream","Southern Rock","Comedy","Cult","Gangsta Rap","Top 40","Christian Rap","Pop/Funk","Jungle","Native American","Cabaret","New Wave","Psychedelic","Rave","Showtunes","Trailer","Lo-Fi","Tribal","Acid Punk","Acid Jazz","Polka","Retro","Musical","Rock & Roll","Hard Rock","Folk","Folk/Rock","National Folk","Swing","Fast-Fusion","Bebob","Latin","Revival","Celtic","Bluegrass","Avantgarde","Gothic Rock","Progressive Rock","Psychedelic Rock","Symphonic Rock","Slow Rock","Big Band","Chorus","Easy Listening","Acoustic","Humour","Speech","Chanson","Opera","Chamber Music","Sonata","Symphony","Booty Bass","Primus","Porn Groove","Satire","Slow Jam","Club","Tango","Samba","Folklore","Ballad","Power Ballad","Rhythmic Soul","Freestyle","Duet","Punk Rock","Drum Solo","A Cappella","Euro-House","Dance Hall","Goa","Drum & Bass","Club-House","Hardcore","Terror","Indie","BritPop","Negerpunk","Polsk Punk","Beat","Christian Gangsta Rap","Heavy Metal","Black Metal","Crossover","Contemporary Christian","Christian Rock","Merengue","Salsa","Thrash Metal","Anime","JPop","Synthpop","Abstract","Art Rock","Baroque","Bhangra","Big Beat","Breakbeat","Chillout","Downtempo","Dub","EBM","Eclectic","Electro","Electroclash","Emo","Experimental","Garage","Global","IDM","Illbient","Industro-Goth","Jam Band","Krautrock","Leftfield","Lounge","Math Rock","New Romantic","Nu-Breakz","Post-Punk","Post-Rock","Psytrance","Shoegaze","Space Rock","Trop Rock","World Music","Neoclassical","Audiobook","Audio Theatre","Neue Deutsche Welle","Podcast","Indie Rock","G-Funk","Dubstep","Garage Rock","Psybient"],nt={len:128,get:(a,e)=>{const t=new De(3).get(a,e);return t==="TAG"?{header:t,title:new De(30).get(a,e+3),artist:new De(30).get(a,e+33),album:new De(30).get(a,e+63),year:new De(4).get(a,e+93),comment:new De(28).get(a,e+97),zeroByte:T.get(a,e+127),track:T.get(a,e+126),genre:T.get(a,e+127)}:null}};class De{constructor(e){this.len=e,this.stringType=new k(e,"latin1")}get(e,t){let i=this.stringType.get(e,t);return i=Oi(i),i=i.trim(),i.length>0?i:void 0}}class Sa extends J{constructor(e,t,i){super(e,t,i),this.apeHeader=i.apeHeader}static getGenre(e){if(e<kt.length)return kt[e]}async parse(){if(!this.tokenizer.fileInfo.size){it("Skip checking for ID3v1 because the file-size is unknown");return}this.apeHeader&&(this.tokenizer.ignore(this.apeHeader.offset-this.tokenizer.position),await new fe(this.metadata,this.tokenizer,this.options).parseTags(this.apeHeader.footer));const e=this.tokenizer.fileInfo.size-nt.len;if(this.tokenizer.position>e){it("Already consumed the last 128 bytes");return}const t=await this.tokenizer.readToken(nt,e);if(t){it("ID3v1 header found at: pos=%s",this.tokenizer.fileInfo.size-nt.len);const i=["title","artist","album","comment","track","year"];for(const r of i)t[r]&&t[r]!==""&&await this.addTag(r,t[r]);const n=Sa.getGenre(t.genre);n&&await this.addTag("genre",n)}else it("ID3v1 header not found at: pos=%s",this.tokenizer.fileInfo.size-nt.len)}async addTag(e,t){await this.metadata.addTag("ID3v1",e,t)}}async function Ms(a){if(a.fileInfo.size>=128){const e=new Uint8Array(3),t=a.position;return await a.readBuffer(e,{position:a.fileInfo.size-128}),a.setPosition(t),te(e,"latin1")==="TAG"}return!1}const Bs="LYRICS200";async function Os(a){const e=a.fileInfo.size;if(e>=143){const t=new Uint8Array(15),i=a.position;await a.readBuffer(t,{position:e-143}),a.setPosition(i);const n=te(t,"latin1");if(n.substring(6)===Bs)return Number.parseInt(n.substring(0,6),10)+15}return 0}async function zc(a,e={}){const t=Ei(a);try{return await Ia(t,e)}finally{await t.close()}}async function _c(a,e,t={}){const i=Ci(a,{fileInfo:typeof e=="string"?{mimeType:e}:e});try{return await Ia(i,t)}finally{await i.close()}}async function Mc(a,e,t={}){const i=Ce(a,{fileInfo:typeof e=="string"?{mimeType:e}:e});return Ia(i,t)}function Ia(a,e){return new $i().parse(a,void 0,e)}function Bc(a){const e={};for(const{id:t,value:i}of a)(e[t]||(e[t]=[])).push(i);return e}function Oc(a){return a===void 0?0:1+Math.round(a*4)}function Rc(a){return a?a.reduce((e,t)=>t.name&&t.name.toLowerCase()in["front","cover","cover (front)"]?t:e):null}async function Rs(a,e={}){let t=a.fileInfo.size;if(await Ms(a)){t-=128;
5const i=await Os(a);t-=i}e.apeHeader=await fe.findApeFooterOffset(a,t)}async function Lc(a,e={}){throw new Error("This function require a Node engine. To load Web API File objects use parseBlob instead.")}async function Nc(a,e,t={}){throw new Error("This function require a Node engine.")}function $c(){return new $i().getSupportedMimeTypes()}const Ja={len:16,get:(a,e)=>{const t=x.get(a,e+8),i=x.get(a,e+12);return{startTime:x.get(a,e),endTime:x.get(a,e+4),startOffset:t===4294967295?void 0:t,endOffset:i===4294967295?void 0:i}}};function ia(a){switch(a){case 2:return 6;case 3:case 4:return 10;default:throw ji(a)}}function Ls(a){return{status:{tag_alter_preservation:I(a,0,6),file_alter_preservation:I(a,0,5),read_only:I(a,0,4)},format:{grouping_identity:I(a,1,7),compression:I(a,1,3),encryption:I(a,1,2),unsynchronisation:I(a,1,1),data_length_indicator:I(a,1,0)}}}function na(a,e,t){switch(e){case 2:return Ns(a,e,t);case 3:case 4:return $s(a,e,t);default:throw ji(e)}}function Ns(a,e,t){const i={id:te(a.subarray(0,3),"ascii"),length:B.get(a,3)};return i.id.match(/^[A-Z0-9]{3}$/)||t.addWarning("Invalid ID3v2.".concat(e," frame-header-ID: ").concat(i.id)),i}function $s(a,e,t){const i={id:te(a.subarray(0,4),"ascii"),length:(e===4?Ni:x).get(a,4),flags:Ls(a.subarray(8,10))};return i.id.match(/^[A-Z0-9]{4}$/)||t.addWarning("Invalid ID3v2.".concat(e," frame-header-ID: ").concat(i.id)),i}function ji(a){throw new Dt("Unexpected majorVer: ".concat(a))}const rt=C("music-metadata:id3v2:frame-parser"),Q="latin1",$t={encoding:Q,bom:!1};function Us(a){const e=[];let t,i="";for(const n of a)if(typeof t=="string")if(n==="("&&t==="")i+="(",t=void 0;else if(n===")"){i!==""&&(e.push(i),i="");const r=Qa(t);r&&e.push(r),t=void 0}else t+=n;else n==="("?t="":i+=n;return i&&(e.length===0&&i.match(/^\d*$/)&&(i=Qa(i)),i&&e.push(i)),e}function Qa(a){if(a==="RX")return"Remix";if(a==="CR")return"Cover";if(a.match(/^\d*$/))return kt[Number.parseInt(a,10)]}class A{constructor(e,t){this.major=e,this.warningCollector=t}readData(e,t,i){if(e.length===0){this.warningCollector.addWarning("id3v2.".concat(this.major," header has empty tag type=").concat(t));return}const{encoding:n,bom:r}=Ue.get(e,0),s=e.length;let o=0,c=[];const l=A.getNullTerminatorLength(n);let d;switch(rt("Parsing tag type=".concat(t,", encoding=").concat(n,", bom=").concat(r)),t!=="TXXX"&&t[0]==="T"?"T*":t){case"T*":case"GRP1":case"GP1":case"IPLS":case"MVIN":case"MVNM":case"PCS":case"PCST":{let m;try{m=A.trimNullPadding(N(e.subarray(1),n))}catch(p){if(p instanceof Error){this.warningCollector.addWarning("id3v2.".concat(this.major," type=").concat(t," header has invalid string value: ").concat(p.message));break}throw p}switch(t){case"TMCL":case"TIPL":case"IPLS":c=A.functionList(this.splitValue(t,m));break;case"TRK":case"TRCK":case"TPOS":case"TIT1":case"TIT2":case"TIT3":c=m;break;case"TCOM":case"TEXT":case"TOLY":case"TOPE":case"TPE1":case"TSRC":c=this.splitValue(t,m);break;case"TCO":case"TCON":c=this.splitValue(t,m).map(p=>Us(p)).reduce((p,y)=>p.concat(y),[]);break;case"PCS":case"PCST":c=this.major>=4?this.splitValue(t,m):[m],c=Array.isArray(c)&&c[0]===""?1:0;break;default:c=this.major>=4?this.splitValue(t,m):[m]}break}case"TXXX":{const m=A.readIdentifierAndData(e.subarray(1),n);c={description:m.id,text:this.splitValue(t,N(m.data,n).replace(/\x00+$/,""))};break}case"PIC":case"APIC":if(i){const m={};switch(e=e.subarray(1),this.major){case 2:m.format=N(e.subarray(0,3),"latin1"),e=e.subarray(3);break;case 3:case 4:d=pe(e,Q),m.format=N(e.subarray(0,d),Q),e=e.subarray(d+1);break;default:throw js(this.major)}m.format=A.fixPictureMimeType(m.format),m.type=Ta[e[0]],e=e.subarray(1),d=pe(e,n),m.description=N(e.subarray(0,d),n),e=e.subarray(d+l),m.data=e,c=m}break;case"CNT":case"PCNT":c=Ha(e);break;case"SYLT":{const m=Va.get(e,0);e=e.subarray(Va.len);const p={descriptor:"",language:m.language,contentType:m.contentType,timeStampFormat:m.timeStampFormat,syncText:[]};let y=!1;for(;e.length>0;){const z=A.readNullTerminatedString(e,m.encoding);if(e=e.subarray(z.len),y){const de=x.get(e,0);e=e.subarray(x.len),p.syncText.push({text:z.text,timestamp:de})}else p.descriptor=z.text,y=!0}c=p;break}case"ULT":case"USLT":case"COM":case"COMM":{const m=ta.get(e,o);o+=ta.len;const p=A.readNullTerminatedString(e.subarray(o),m.encoding);o+=p.len;const y=A.readNullTerminatedString(e.subarray(o),m.encoding);
5c={language:m.language,descriptor:p.text,text:y.text};break}case"UFID":{const m=A.readIdentifierAndData(e,Q);c={owner_identifier:m.id,identifier:m.data};break}case"PRIV":{const m=A.readIdentifierAndData(e,Q);c={owner_identifier:m.id,data:m.data};break}case"POPM":{e=e.subarray(o);const m=A.readNullTerminatedString(e,$t),p=m.text;if(e=e.subarray(m.len),e.length===0){this.warningCollector.addWarning("id3v2.".concat(this.major," type=").concat(t," POPM frame missing rating byte")),c={email:p,rating:0,counter:void 0};break}const y=T.get(e,0),z=e.subarray(T.len);c={email:p,rating:y,counter:z.length>0?Ha(z):void 0};break}case"GEOB":{const m=Ue.get(e,0);e=e.subarray(1);const p=A.readNullTerminatedString(e,$t),y=p.text;e=e.subarray(p.len);const z=A.readNullTerminatedString(e,m),de=z.text;e=e.subarray(z.len);const Ze=A.readNullTerminatedString(e,m),Ye=Ze.text;e=e.subarray(Ze.len),c={type:y,filename:de,description:Ye,data:e};break}case"WCOM":case"WCOP":case"WOAF":case"WOAR":case"WOAS":case"WORS":case"WPAY":case"WPUB":c=A.readNullTerminatedString(e,$t).text;break;case"WXXX":{const m=Ue.get(e,0);e=e.subarray(1);const p=A.readNullTerminatedString(e,m),y=p.text;e=e.subarray(p.len),c={description:y,url:A.trimNullPadding(N(e,Q))};break}case"WFD":case"WFED":{const m=Ue.get(e,0);e=e.subarray(1),c=A.readNullTerminatedString(e,m).text;break}case"MCDI":{c=e.subarray(0,s);break}case"CHAP":{rt("Reading CHAP"),d=pe(e,Q);const m={label:N(e.subarray(0,d),Q),info:Ja.get(e,d+1),frames:new Map};for(o+=d+1+Ja.len;o<s;){const p=na(e.subarray(o),this.major,this.warningCollector),y=ia(this.major);o+=y;const z=this.readData(e.subarray(o,o+p.length),p.id,i);o+=p.length,m.frames.set(p.id,z)}c=m;break}case"CTOC":{rt("Reading CTOC");const m=pe(e,Q),p=N(e.subarray(0,m),Q);o=m+1;const y=e[o++],z=(y&2)!==0,de=(y&1)!==0,Ze=e[o++],Ye=[];for(let we=0;we<Ze&&o<s;we++){const Ke=pe(e.subarray(o),Q),Mt=N(e.subarray(o,o+Ke),Q);Ye.push(Mt),o+=Ke+1}const _t={label:p,flags:{topLevel:z,ordered:de},childElementIds:Ye,frames:new Map};for(;o<s;){const we=na(e.subarray(o),this.major,this.warningCollector),Ke=ia(this.major);o+=Ke;const Mt=this.readData(e.subarray(o,o+we.length),we.id,i);o+=we.length,_t.frames.set(we.id,Mt)}c=_t;break}default:rt("Warning: unsupported id3v2-tag-type: ".concat(t));break}return c}static readNullTerminatedString(e,t){const i=t.bom?2:0,n=e.length,r=e.subarray(i),s=pe(r,t.encoding);if(s>=r.length)return{text:N(r,t.encoding),len:n};const o=r.subarray(0,s);return{text:N(o,t.encoding),len:i+s+A.getNullTerminatorLength(t.encoding)}}static fixPictureMimeType(e){switch(e=e.toLocaleLowerCase(),e){case"jpg":return"image/jpeg";case"png":return"image/png"}return e}static functionList(e){const t={};for(let i=0;i+1<e.length;i+=2){const n=e[i+1].split(",");t[e[i]]=t[e[i]]?t[e[i]].concat(n):n}return t}splitValue(e,t){let i;return this.major<4?(i=t.split(/\x00/g),i.length>1?this.warningCollector.addWarning("ID3v2.".concat(this.major," ").concat(e," uses non standard null-separator.")):i=t.split(/\//g)):i=t.split(/\x00/g),A.trimArray(i)}static trimArray(e){return e.map(t=>A.trimNullPadding(t).trim())}static trimNullPadding(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===0;)t--;return t===e.length?e:e.slice(0,t)}static readIdentifierAndData(e,t){const i=A.readNullTerminatedString(e,{encoding:t,bom:!1});return{id:i.text,data:e.subarray(i.len)}}static getNullTerminatorLength(e){return e.startsWith("utf-16")?2:1}}class Dt extends O("id3v2"){}function js(a){throw new Dt("Unexpected majorVer: ".concat(a))}class oe{constructor(){this.tokenizer=void 0,this.id3Header=void 0,this.metadata=void 0,this.headerType=void 0,this.options=void 0}static removeUnsyncBytes(e){let t=0,i=0;for(;t<e.length-1;)t!==i&&(e[i]=e[t]),t+=e[t]===255&&e[t+1]===0?2:1,i++;return t<e.length&&(e[i++]=e[t]),e.subarray(0,i)}static readFrameData(e,t,i,n,r){var o,c;const s=new A(i,r);switch(i){case 2:return s.readData(e,t.id,n);case 3:case 4:return(o=t.flags)!=null&&o.format.unsynchronisation&&(e=oe.removeUnsyncBytes(e)),(c=t.flags)!=null&&c.format.data_length_indicator&&(e=e.subarray(4,e.length)),s.readData(e,t.id,n);default:throw Gs(i)}}static makeDescriptionTagName(e,t){return e+(t?":".concat(t):"")}async parse(e,t,i){this.tokenizer=t,this.metadata=e,this.options=i;const n=await this.tokenizer.readToken(ea);if(n.fileIdentifier!=="ID3")throw new Dt("expected ID3-header file-identifier 'ID3' was not found");this.id3Header=n,this.headerType="ID3v2.".concat(n.version.major),await(n.flags.isExtendedHeader?this.parseExtendedHeader():this.parseId3Data(n.size));const r=oe.mapId3v2Chapters(this.metadata.native[this.headerType]);this.metadata.setFormat("chapters",r)}async parseExtendedHeader(){const e=await this.tokenizer.readToken(Xa),t=e.size-Xa.len;return t>0?this.parseExtendedHeaderData(t,e.size):this.parseId3Data(this.id3Header.size-e.size)}async parseExtendedHeaderData(e,t){return await this.tokenizer.ignore(e),this.parseId3Data(this.id3Header.size-t)}async parseId3Data(e){const t=await this.tokenizer.readToken(new U(e));for(const i of this.parseMetadata(t))switch(i.id){case"TXXX":i.value&&await this.handleTag(i,i.value.text,()=>i.value.description);break;default:await(Array.isArray(i.value)?Promise.all(i.value.map(n=>this.addTag(i.id,n))):this.addTag(i.id,i.value))}}async handleTag(e,t,i,n=r=>r){await Promise.all(t.map(r=>this.addTag(oe.makeDescriptionTagName(e.id,i(r)),n(r))))}async addTag(e,t){await this.metadata.addTag(this.headerType,e,t)}parseMetadata(e){let t=0;const i=[];for(;t!==e.length;){const n=ia(this.id3Header.version.major);if(t+n>e.length){this.metadata.addWarning("Illegal ID3v2 tag length");break}const r=e.subarray(t,t+n);t+=n;const s=na(r,this.id3Header.version.major,this.metadata),o=e.subarray(t,t+s.length);t+=s.length;const c=oe.readFrameData(o,s,this.id3Header.version.major,!this.options.skipCovers,this.metadata);c&&i.push({id:s.id,value:c})}return i}static mapId3v2Chapters(e){if(!e)return;const t=e.filter(l=>l.id==="CHAP");if(!(t!=null&&t.length))return;const i=e.filter(l=>l.id==="CTOC"),n=i==null?void 0:i.find(l=>{var d;return(d=l.value.flags)==null?void 0:d.topLevel}),r=new Map;for(const l of t)r.set(l.value.label,l.value);const s=n==null?void 0:n.value.childElementIds,o=[],c=s!=null?s:[...r.keys()];for(const l of c){const d=r.get(l);if(!d)continue;const m=d.frames,p=m.get("TIT2");p&&o.push({id:l,title:p,url:m.get("WXXX"),start:d.info.startTime/1e3,end:d.info.endTime/1e3,image:m.get("APIC")})}return s||o.sort((l,d)=>l.start-d.start),o.length?o:void 0}}function Gs(a){throw new Dt("Unexpected majorVer: ".concat(a))}const Ut=C("music-metadata:parser:ID3");class Pt extends J{constructor(){super(...arguments),this.id3parser=new oe}static async startsWithID3v2Header(e){return(await e.peekToken(ea)).fileIdentifier==="ID3"}async parse(){try{await this.parseID3v2()}catch(e){if(e instanceof E)Ut("End-of-stream");else throw e}}finalize(){}async parseID3v2(){await this.tryReadId3v2Headers(),Ut("End of ID3v2 header, go to MPEG-parser: pos=%s",this.tokenizer.position),await this.postId3v2Parse(),this.options.skipPostHeaders&&this.metadata.hasAny()?this.finalize():(await new Sa(this.metadata,this.tokenizer,this.options).parse(),this.finalize())}async tryReadId3v2Headers(){if((await this.tokenizer.peekToken(ea)).fileIdentifier==="ID3")return Ut("Found ID3v2 header, pos=%s",this.tokenizer.position),await this.id3parser.parse(this.metadata,this.tokenizer,this.options),this.tryReadId3v2Headers()}}const ei={len:2,get:(a,e)=>{const t=S(a,e,0,3),i=S(a,e,6,1),n=S(a,e,7,9)/10;if(t>0)return{type:S(a,e,0,3),origin:S(a,e,3,3),adjustment:i?-n:n}}},Ws={len:27,get:(a,e)=>{const t=x.get(a,e+2);return{revision:S(a,e,0,4),vbr_method:S(a,e,4,4),lowpass_filter:100*T.get(a,e+1),track_peak:t===0?null:t/2**23,track_gain:ei.get(a,6),album_gain:ei.get(a,8),music_length:x.get(a,e+20),music_crc:T.get(a,e+24),header_crc:v.get(a,e+24)}}}
5,ti=new k(4,"ascii"),jt=new k(6,"ascii"),Hs={len:4,get:(a,e)=>({frames:q(a,e,31),bytes:q(a,e,30),toc:q(a,e,29),vbrScale:q(a,e,28)})};async function Xs(a){const e=await a.readToken(Hs),t={numFrames:null,streamSize:null,vbrScale:null};if(e.frames&&(t.numFrames=await a.readToken(x)),e.bytes&&(t.streamSize=await a.readToken(x)),e.toc&&(t.toc=new Uint8Array(100),await a.readBuffer(t.toc)),e.vbrScale&&(t.vbrScale=await a.readToken(x)),await a.peekToken(new k(4,"ascii"))==="LAME"){await a.ignore(4),t.lame={version:await a.readToken(new k(5,"ascii"))};const n=t.lame.version.match(/\d+.\d+/g);if(n!==null){const s=n[0].split(".").map(o=>Number.parseInt(o,10));s[0]>=3&&s[1]>=90&&(t.lame.extended=await a.readToken(Ws))}}return t}const H=C("music-metadata:parser:mpeg");class He extends O("MPEG"){}const ai=1024,ii={AudioObjectTypes:["AAC Main","AAC LC","AAC SSR","AAC LTP"],SamplingFrequencies:[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350,null,null,-1]},Vs=[void 0,["front-center"],["front-left","front-right"],["front-center","front-left","front-right"],["front-center","front-left","front-right","back-center"],["front-center","front-left","front-right","back-left","back-right"],["front-center","front-left","front-right","back-left","back-right","LFE-channel"],["front-center","front-left","front-right","side-left","side-right","back-left","back-right","LFE-channel"]];class _{constructor(e,t){this.bitrateIndex=null,this.sampRateFreqIndex=null,this.padding=null,this.privateBit=null,this.channelModeIndex=null,this.modeExtension=null,this.isOriginalMedia=null,this.version=null,this.bitrate=null,this.samplingRate=null,this.frameLength=0,this.versionIndex=S(e,t+1,3,2),this.layer=_.LayerDescription[S(e,t+1,5,2)],this.versionIndex>1&&this.layer===0?this.parseAdtsHeader(e,t):this.parseMpegHeader(e,t),this.isProtectedByCRC=!q(e,t+1,7)}calcDuration(e){return this.samplingRate==null?null:e*this.calcSamplesPerFrame()/this.samplingRate}calcSamplesPerFrame(){return _.samplesInFrameTable[this.version===1?0:1][this.layer]}calculateSideInfoLength(){if(this.layer!==3)return 2;if(this.channelModeIndex===3){if(this.version===1)return 17;if(this.version===2||this.version===2.5)return 9}else{if(this.version===1)return 32;if(this.version===2||this.version===2.5)return 17}return null}calcSlotSize(){return[null,4,1,1][this.layer]}parseMpegHeader(e,t){this.container="MPEG",this.bitrateIndex=S(e,t+2,0,4),this.sampRateFreqIndex=S(e,t+2,4,2),this.padding=q(e,t+2,6),this.privateBit=q(e,t+2,7),this.channelModeIndex=S(e,t+3,0,2),this.modeExtension=S(e,t+3,2,2),this.isCopyrighted=q(e,t+3,4),this.isOriginalMedia=q(e,t+3,5),this.emphasis=S(e,t+3,7,2),this.version=_.VersionID[this.versionIndex],this.channelMode=_.ChannelMode[this.channelModeIndex],this.codec="MPEG ".concat(this.version," Layer ").concat(this.layer);const i=this.calcBitrate();if(!i)throw new He("Cannot determine bit-rate");if(this.bitrate=i*1e3,this.samplingRate=this.calcSamplingRate(),this.samplingRate==null)throw new He("Cannot determine sampling-rate")}parseAdtsHeader(e,t){H("layer=0 => ADTS"),this.version=this.versionIndex===2?4:2,this.container="ADTS/MPEG-".concat(this.version);const i=S(e,t+2,0,2);this.codec="AAC",this.codecProfile=ii.AudioObjectTypes[i],H("MPEG-4 audio-codec=".concat(this.codec));const n=S(e,t+2,2,4);this.samplingRate=ii.SamplingFrequencies[n],H("sampling-rate=".concat(this.samplingRate));const r=S(e,t+2,7,3);this.mp4ChannelConfig=Vs[r],H("channel-config=".concat(this.mp4ChannelConfig?this.mp4ChannelConfig.join("+"):"?")),this.frameLength=S(e,t+3,6,2)<<11}calcBitrate(){if(this.bitrateIndex===0||this.bitrateIndex===15)return null;if(this.version&&this.bitrateIndex){const e=10*Math.floor(this.version)+this.layer;return _.bitrate_index[this.bitrateIndex][e]}return null}calcSamplingRate(){return this.sampRateFreqIndex===3||this.version===null||this.sampRateFreqIndex==null?null:_.sampling_rate_freq_index[this.version][this.sampRateFreqIndex]}}_.SyncByte1=255;_.SyncByte2=224;_.VersionID=[2.5,null,2,1];_.LayerDescription=[0,3,2,1];_.ChannelMode=["stereo","joint_stereo","dual_channel","mono"];_.bitrate_index={1:{11:32,12:32,13:32,21:32,22:8,23:8},2:{11:64,12:48,13:40,21:48,22:16,23:16},3:{11:96,12:56,13:48,21:56,22:24,23:24},4:{11:128,12:64,13:56,21:64,22:32,23:32},5:{11:160,12:80,13:64,21:80,22:40,23:40},6:{11:192,12:96,13:80,21:96,22:48,23:48},7:{11:224,12:112,13:96,21:112,22:56,23:56},8:{11:256,12:128,13:112,21:128,22:64,23:64},9:{11:288,12:160,13:128,21:144,22:80,23:80},10:{11:320,12:192,13:160,21:160,22:96,23:96},11:{11:352,12:224,13:192,21:176,22:112,23:112},12:{11:384,12:256,13:224,21:192,22:128,23:128},13:{11:416,12:320,13:256,21:224,22:144,23:144},14:{11:448,12:384,13:320,21:256,22:160,23:160}};_.sampling_rate_freq_index={1:{0:44100,1:48e3,2:32e3},2:{0:22050,1:24e3,2:16e3},2.5:{0:11025,1:12e3,2:8e3}};_.samplesInFrameTable=[[0,384,1152,1152],[0,384,1152,576]];const ni={len:4,get:(a,e)=>new _(a,e)};function qs(a){return"V".concat(Math.floor((100-a)/10))}class Zs extends Pt{constructor(){super(...arguments),this.frameCount=0,this.syncFrameCount=-1,this.totalDataLength=0,this.bitrates=[],this.offset=0,this.frame_size=0,this.calculateEofDuration=!1,this.samplesPerFrame=null,this.buf_frame_header=new Uint8Array(4),this.mpegOffset=null,this.syncPeek={buf:new Uint8Array(ai),len:0}}async postId3v2Parse(){this.metadata.setFormat("lossless",!1),this.metadata.setAudioOnly();try{let e=!1;for(;!e;)await this.sync(),e=await this.parseCommonMpegHeader()}catch(e){if(e instanceof E){if(H("End-of-stream"),this.calculateEofDuration&&this.samplesPerFrame!==null){const t=this.frameCount*this.samplesPerFrame;if(this.metadata.setFormat("numberOfSamples",t),this.metadata.format.sampleRate){const i=t/this.metadata.format.sampleRate;H("Calculate duration at EOF: ".concat(i," sec."),i),this.metadata.setFormat("duration",i)}}}else throw e}}finalize(){const e=this.metadata.format,t=!!this.metadata.native.ID3v1;if(this.mpegOffset!==null){if(e.duration&&this.tokenizer.fileInfo.size){const i=this.tokenizer.fileInfo.size-this.mpegOffset-(t?128:0);e.codecProfile&&e.codecProfile[0]==="V"&&this.metadata.setFormat("bitrate",i*8/e.duration)}if(this.tokenizer.fileInfo.size&&e.codecProfile==="CBR"){const i=this.tokenizer.fileInfo.size-this.mpegOffset-(t?128:0);if(this.frame_size!==null&&this.samplesPerFrame!==null){const n=Math.round(i/this.frame_size)*this.samplesPerFrame;if(this.metadata.setFormat("numberOfSamples",n),e.sampleRate&&!e.duration){const r=n/e.sampleRate;H("Calculate CBR duration based on file size: %s",r),this.metadata.setFormat("duration",r)}}}}}async sync(){let e=!1;for(;;){let t=0;if(this.syncPeek.len=await this.tokenizer.peekBuffer(this.syncPeek.buf,{length:ai,mayBeLess:!0}),this.syncPeek.len<=163)throw new E;for(;;){if(e&&(this.syncPeek.buf[t]&224)===224){this.buf_frame_header[0]=_.SyncByte1,this.buf_frame_header[1]=this.syncPeek.buf[t],await this.tokenizer.ignore(t),H("Sync at offset=".concat(this.tokenizer.position-1,", frameCount=").concat(this.frameCount)),this.syncFrameCount===this.frameCount&&(H("Re-synced MPEG stream, frameCount=".concat(this.frameCount)),this.frameCount=0,this.frame_size=0),this.syncFrameCount=this.frameCount;return}if(e=!1,t=this.syncPeek.buf.indexOf(_.SyncByte1,t),t===-1){if(this.syncPeek.len<this.syncPeek.buf.length)throw new E;await this.tokenizer.ignore(this.syncPeek.len);break}++t,e=!0}}}async parseCommonMpegHeader(){this.frameCount===0&&(this.mpegOffset=this.tokenizer.position-1),await this.tokenizer.peekBuffer(this.buf_frame_header.subarray(1),{length:3});let e;try{e=ni.get(this.buf_frame_header,0)}catch(t){if(await this.tokenizer.ignore(1),t instanceof Error)return this.metadata.addWarning("Parse error: ".concat(t.message)),!1;throw t}return await this.tokenizer.ignore(3),this.metadata.setFormat("container",e.container),this.metadata.setFormat("codec",e.codec),this.metadata.setFormat("lossless",!1),this.metadata.setFormat("sampleRate",e.samplingRate),this.frameCount++,e.version!==null&&e.version>=2&&e.layer===0?this.parseAdts(e):this.parseAudioFrameHeader(e)}async parseAudioFrameHeader(e){this.metadata.setFormat("numberOfChannels",e.channelMode==="mono"?1:2),this.metadata.setFormat("bitrate",e.bitrate),this.frameCount<20*1e4&&H("offset=%s MP%s bitrate=%s sample-rate=%s",this.tokenizer.position-4,e.layer,e.bitrate,e.samplingRate);const t=e.calcSlotSize();if(t===null)throw new He("invalid slot_size");
5const i=e.calcSamplesPerFrame();H("samples_per_frame=".concat(i));const n=i/8;if(e.bitrate!==null&&e.samplingRate!=null){const r=n*e.bitrate/e.samplingRate+(e.padding?t:0);this.frame_size=Math.floor(r)}if(this.audioFrameHeader=e,e.bitrate!==null&&this.bitrates.push(e.bitrate),this.frameCount===1)return this.offset=ni.len,await this.skipSideInformation(),!1;if(this.frameCount===4){if(this.areAllSame(this.bitrates)){if(this.samplesPerFrame=i,this.metadata.setFormat("codecProfile","CBR"),this.tokenizer.fileInfo.size)return!0}else if(this.metadata.format.duration)return!0;if(!this.options.duration)return!0}return this.options.duration&&this.frameCount===4&&(this.samplesPerFrame=i,this.calculateEofDuration=!0),this.offset=4,e.isProtectedByCRC?(await this.parseCrc(),!1):(await this.skipSideInformation(),!1)}async parseAdts(e){const t=new Uint8Array(3);if(await this.tokenizer.readBuffer(t),e.frameLength+=S(t,0,0,11),this.totalDataLength+=e.frameLength,this.samplesPerFrame=1024,e.samplingRate!==null){const i=e.samplingRate/this.samplesPerFrame,r=8*(this.frameCount===0?0:this.totalDataLength/this.frameCount)*i+.5;this.metadata.setFormat("bitrate",r),H("frame-count=".concat(this.frameCount,", size=").concat(e.frameLength," bytes, bit-rate=").concat(r))}if(await this.tokenizer.ignore(e.frameLength>7?e.frameLength-7:1),this.frameCount===3)if(this.metadata.setFormat("codecProfile",e.codecProfile),e.mp4ChannelConfig&&this.metadata.setFormat("numberOfChannels",e.mp4ChannelConfig.length),this.options.duration)this.calculateEofDuration=!0;else return!0;return!1}async parseCrc(){return await this.tokenizer.ignore(se.len),this.offset+=se.len,this.skipSideInformation()}async skipSideInformation(){if(this.audioFrameHeader){const e=this.audioFrameHeader.calculateSideInfoLength();if(e!==null){await this.tokenizer.readToken(new U(e)),this.offset+=e,await this.readXtraInfoHeader();return}}}async readXtraInfoHeader(){const e=await this.tokenizer.readToken(ti);switch(this.offset+=ti.len,e){case"Info":return this.metadata.setFormat("codecProfile","CBR"),this.readXingInfoHeader();case"Xing":{const i=await this.readXingInfoHeader();if(i.vbrScale!==null){const n=qs(i.vbrScale);this.metadata.setFormat("codecProfile",n)}return null}case"Xtra":break;case"LAME":{const i=await this.tokenizer.readToken(jt);if(this.frame_size!==null&&this.frame_size>=this.offset+jt.len)return this.offset+=jt.len,this.metadata.setFormat("tool","LAME ".concat(i)),await this.skipFrameData(this.frame_size-this.offset),null;this.metadata.addWarning("Corrupt LAME header");break}}const t=this.frame_size-this.offset;return t<0?this.metadata.addWarning("Frame ".concat(this.frameCount,"corrupt: negative frameDataLeft")):await this.skipFrameData(t),null}async readXingInfoHeader(){const e=this.tokenizer.position,t=await Xs(this.tokenizer);if(this.offset+=this.tokenizer.position-e,t.lame&&(this.metadata.setFormat("tool","LAME ".concat(ge(t.lame.version))),t.lame.extended&&(this.metadata.setFormat("trackPeakLevel",t.lame.extended.track_peak),t.lame.extended.track_gain&&this.metadata.setFormat("trackGain",t.lame.extended.track_gain.adjustment),t.lame.extended.album_gain&&this.metadata.setFormat("albumGain",t.lame.extended.album_gain.adjustment),this.metadata.setFormat("duration",t.lame.extended.music_length/1e3))),t.streamSize&&this.audioFrameHeader&&t.numFrames!==null){const n=this.audioFrameHeader.calcDuration(t.numFrames);return this.metadata.setFormat("duration",n),H("Get duration from Xing header: %s",this.metadata.format.duration),t}const i=this.frame_size-this.offset;return await this.skipFrameData(i),t}async skipFrameData(e){if(e<0)throw new He("frame-data-left cannot be negative");await this.tokenizer.ignore(e)}areAllSame(e){const t=e[0];return e.every(i=>i===t)}}const Ys=Object.freeze(Object.defineProperty({__proto__:null,MpegContentError:He,MpegParser:Zs},Symbol.toStringTag,{value:"Module"}));function Gi(a){let e=a.trim();if(e.length!==36||e[8]!=="-"||e[13]!=="-"||e[18]!=="-"||e[23]!=="-")throw new Error("Invalid GUID format: ".concat(a));let t;const i=new Uint8Array(16);t=parseInt(e.slice(0,8),16),i[0]=t&255,i[1]=t>>>8&255,i[2]=t>>>16&255,i[3]=t>>>24&255,t=parseInt(e.slice(9,13),16),i[4]=t&255,i[5]=t>>>8&255,t=parseInt(e.slice(14,18),16),i[6]=t&255,i[7]=t>>>8&255,t=parseInt(e.slice(19,23),16),i[8]=t>>>8&255,i[9]=t&255,t=parseInt(e.slice(24,32),16),i[10]=t>>>24&255,i[11]=t>>>16&255,i[12]=t>>>8&255,i[13]=t&255,t=parseInt(e.slice(32,36),16),i[14]=t>>>8&255,i[15]=t&255;for(let n=0;n<16;n++)if(!Number.isFinite(i[n]))throw new Error("Invalid GUID format: ".concat(a));if(!/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(e))throw new Error("Invalid GUID format: ".concat(a));return i}class va{constructor(e){if(e.length!==16)throw new Error("GUID must be exactly 16 bytes");this.bytes=e}static fromString(e){return new va(Gi(e))}toString(){const e=this.bytes,t=c=>c.toString(16).padStart(2,"0"),i=t(e[3])+t(e[2])+t(e[1])+t(e[0]),n=t(e[5])+t(e[4]),r=t(e[7])+t(e[6]),s=t(e[8])+t(e[9]),o=t(e[10])+t(e[11])+t(e[12])+t(e[13])+t(e[14])+t(e[15]);return"".concat(i,"-").concat(n,"-").concat(r,"-").concat(s,"-").concat(o).toUpperCase()}equals(e,t=0){if(t<0||e.length-t<16)return!1;const i=this.bytes;for(let n=0;n<16;n++)if(e[t+n]!==i[n])return!1;return!0}}class u{static fromBin(e,t=0){return new u(u.decode(e,t))}static decode(e,t=0){return new va(e.subarray(t,t+16)).toString()}static decodeMediaType(e){switch(e.str){case u.AudioMedia.str:return"audio";case u.VideoMedia.str:return"video";case u.CommandMedia.str:return"command";case u.Degradable_JPEG_Media.str:return"degradable-jpeg";case u.FileTransferMedia.str:return"file-transfer";case u.BinaryMedia.str:return"binary"}}static encode(e){return Gi(e)}constructor(e){this.str=e}equals(e){return this.str===e.str}toBin(){return u.encode(this.str)}}
5u.HeaderObject=new u("75B22630-668E-11CF-A6D9-00AA0062CE6C");u.DataObject=new u("75B22636-668E-11CF-A6D9-00AA0062CE6C");u.SimpleIndexObject=new u("33000890-E5B1-11CF-89F4-00A0C90349CB");u.IndexObject=new u("D6E229D3-35DA-11D1-9034-00A0C90349BE");u.MediaObjectIndexObject=new u("FEB103F8-12AD-4C64-840F-2A1D2F7AD48C");u.TimecodeIndexObject=new u("3CB73FD0-0C4A-4803-953D-EDF7B6228F0C");u.FilePropertiesObject=new u("8CABDCA1-A947-11CF-8EE4-00C00C205365");u.StreamPropertiesObject=new u("B7DC0791-A9B7-11CF-8EE6-00C00C205365");u.HeaderExtensionObject=new u("5FBF03B5-A92E-11CF-8EE3-00C00C205365");u.CodecListObject=new u("86D15240-311D-11D0-A3A4-00A0C90348F6");u.ScriptCommandObject=new u("1EFB1A30-0B62-11D0-A39B-00A0C90348F6");u.MarkerObject=new u("F487CD01-A951-11CF-8EE6-00C00C205365");u.BitrateMutualExclusionObject=new u("D6E229DC-35DA-11D1-9034-00A0C90349BE");u.ErrorCorrectionObject=new u("75B22635-668E-11CF-A6D9-00AA0062CE6C");u.ContentDescriptionObject=new u("75B22633-668E-11CF-A6D9-00AA0062CE6C");u.ExtendedContentDescriptionObject=new u("D2D0A440-E307-11D2-97F0-00A0C95EA850");u.ContentBrandingObject=new u("2211B3FA-BD23-11D2-B4B7-00A0C955FC6E");u.StreamBitratePropertiesObject=new u("7BF875CE-468D-11D1-8D82-006097C9A2B2");u.ContentEncryptionObject=new u("2211B3FB-BD23-11D2-B4B7-00A0C955FC6E");u.ExtendedContentEncryptionObject=new u("298AE614-2622-4C17-B935-DAE07EE9289C");
5u.DigitalSignatureObject=new u("2211B3FC-BD23-11D2-B4B7-00A0C955FC6E");u.PaddingObject=new u("1806D474-CADF-4509-A4BA-9AABCB96AAE8");u.ExtendedStreamPropertiesObject=new u("14E6A5CB-C672-4332-8399-A96952065B5A");u.AdvancedMutualExclusionObject=new u("A08649CF-4775-4670-8A16-6E35357566CD");u.GroupMutualExclusionObject=new u("D1465A40-5A79-4338-B71B-E36B8FD6C249");u.StreamPrioritizationObject=new u("D4FED15B-88D3-454F-81F0-ED5C45999E24");u.BandwidthSharingObject=new u("A69609E6-517B-11D2-B6AF-00C04FD908E9");u.LanguageListObject=new u("7C4346A9-EFE0-4BFC-B229-393EDE415C85");u.MetadataObject=new u("C5F8CBEA-5BAF-4877-8467-AA8C44FA4CCA");u.MetadataLibraryObject=new u("44231C94-9498-49D1-A141-1D134E457054");u.IndexParametersObject=new u("D6E229DF-35DA-11D1-9034-00A0C90349BE");u.MediaObjectIndexParametersObject=new u("6B203BAD-3F11-48E4-ACA8-D7613DE2CFA7");u.TimecodeIndexParametersObject=new u("F55E496D-9797-4B5D-8C8B-604DFE9BFB24");u.CompatibilityObject=new u("26F18B5D-4584-47EC-9F5F-0E651F0452C9");u.AdvancedContentEncryptionObject=new u("43058533-6981-49E6-9B74-AD12CB86D58C");u.AudioMedia=new u("F8699E40-5B4D-11CF-A8FD-00805F5C442B");u.VideoMedia=new u("BC19EFC0-5B4D-11CF-A8FD-00805F5C442B");u.CommandMedia=new u("59DACFC0-59E6-11D0-A3AC-00A0C90348F6");u.JFIF_Media=new u("B61BE100-5B4E-11CF-A8FD-00805F5C442B");u.Degradable_JPEG_Media=new u("35907DE0-E415-11CF-A917-00805F5C442B");u.FileTransferMedia=new u("91BD222C-F21C-497A-8B6D-5AA86BFC0185");u.BinaryMedia=new u("3AFB65E2-47EF-40F2-AC2C-70A90D71D343");u.ASF_Index_Placeholder_Object=new u("D9AADE20-7C17-4F9C-BC28-8555DD98E2A2");function Ks(a){return Js[a]}function zt(a){return ge(N(a,"utf-16le"))}const Js=[zt,ri,Qs,eo,to,Wi,ri];function ri(a){return new Uint8Array(a)}function Qs(a,e=0){return Wi(a,e)===1}function eo(a,e=0){return f.get(a,e)}function to(a,e=0){return $.get(a,e)}function Wi(a,e=0){return w.get(a,e)}class ra extends O("ASF"){}const ao={len:30,get:(a,e)=>({objectId:u.fromBin(a,e),objectSize:Number($.get(a,e+16)),numberOfHeaderObjects:f.get(a,e+24)})},Se={len:24,get:(a,e)=>({objectId:u.fromBin(a,e),objectSize:Number($.get(a,e+16))})};class Fe{constructor(e){this.len=Number(e.objectSize)-Se.len}postProcessTag(e,t,i,n){if(t==="WM/Picture")e.push({id:t,value:Ca.fromBuffer(n)});else{const r=Ks(i);if(!r)throw new ra("unexpected value headerType: ".concat(i));e.push({id:t,value:r(n)})}}}class si extends Fe{get(e,t){return null}}class sa extends Fe{get(e,t){return{fileId:u.fromBin(e,t),fileSize:$.get(e,t+16),creationDate:$.get(e,t+24),dataPacketsCount:$.get(e,t+32),playDuration:$.get(e,t+40),sendDuration:$.get(e,t+48),preroll:$.get(e,t+56),flags:{broadcast:I(e,t+64,24),seekable:I(e,t+64,25)},minimumDataPacketSize:f.get(e,t+68),maximumDataPacketSize:f.get(e,t+72),maximumBitrate:f.get(e,t+76)}}}sa.guid=u.FilePropertiesObject;class oa extends Fe{get(e,t){return{streamType:u.decodeMediaType(u.fromBin(e,t)),errorCorrectionType:u.fromBin(e,t+8)}}}oa.guid=u.StreamPropertiesObject;class ca{constructor(){this.len=22}get(e,t){const i=new DataView(e.buffer,t);return{reserved1:u.fromBin(e,t),reserved2:i.getUint16(16,!0),extensionDataSize:i.getUint16(18,!0)}}}ca.guid=u.HeaderExtensionObject;const io={len:20,get:(a,e)=>({entryCount:new DataView(a.buffer,e).getUint16(16,!0)})};async function oi(a){const e=await a.readNumber(w);return(await a.readToken(new k(e*2,"utf-16le"))).replace("\0","")}async function no(a){const e=await a.readToken(io),t=[];for(let i=0;i<e.entryCount;++i)t.push(await so(a));return t}async function ro(a){const e=await a.readNumber(w),t=new Uint8Array(e);return await a.readBuffer(t),t}async function so(a){const e=await a.readNumber(w);return{type:{videoCodec:(e&1)===1,audioCodec:(e&2)===2},codecName:await oi(a),description:await oi(a),information:await ro(a)}}class Ee extends Fe{get(e,t){const i=[],n=new DataView(e.buffer,t);let r=10;for(let s=0;s<Ee.contentDescTags.length;++s){const o=n.getUint16(s*2,!0);if(o>0){const c=Ee.contentDescTags[s],l=r+o;i.push({id:c,value:zt(e.subarray(t+r,t+l))}),r=l}}return i}}Ee.guid=u.ContentDescriptionObject;Ee.contentDescTags=["Title","Author","Copyright","Description","Rating"];class la extends Fe{get(e,t){const i=[],n=new DataView(e.buffer,t),r=n.getUint16(0,!0);let s=2;
5for(let o=0;o<r;o+=1){const c=n.getUint16(s,!0);s+=2;const l=zt(e.subarray(t+s,t+s+c));s+=c;const d=n.getUint16(s,!0);s+=2;const m=n.getUint16(s,!0);s+=2;const p=e.subarray(t+s,t+s+m);s+=m,this.postProcessTag(i,l,d,p)}return i}}la.guid=u.ExtendedContentDescriptionObject;class da extends Fe{get(e,t){const i=new DataView(e.buffer,t);return{startTime:$.get(e,t),endTime:$.get(e,t+8),dataBitrate:i.getInt32(12,!0),bufferSize:i.getInt32(16,!0),initialBufferFullness:i.getInt32(20,!0),alternateDataBitrate:i.getInt32(24,!0),alternateBufferSize:i.getInt32(28,!0),alternateInitialBufferFullness:i.getInt32(32,!0),maximumObjectSize:i.getInt32(36,!0),flags:{reliableFlag:I(e,t+40,0),seekableFlag:I(e,t+40,1),resendLiveCleanpointsFlag:I(e,t+40,2)},streamNumber:i.getInt16(42,!0),streamLanguageId:i.getInt16(44,!0),averageTimePerFrame:i.getInt32(52,!0),streamNameCount:i.getInt32(54,!0),payloadExtensionSystems:i.getInt32(56,!0),streamNames:[],streamPropertiesObject:null}}}da.guid=u.ExtendedStreamPropertiesObject;class wt extends Fe{get(e,t){const i=[],n=new DataView(e.buffer,t),r=n.getUint16(0,!0);let s=2;for(let o=0;o<r;o+=1){s+=4;const c=n.getUint16(s,!0);s+=2;const l=n.getUint16(s,!0);s+=2;const d=n.getUint32(s,!0);s+=4;const m=zt(e.subarray(t+s,t+s+c));s+=c;const p=e.subarray(t+s,t+s+d);s+=d,this.postProcessTag(i,m,l,p)}return i}}wt.guid=u.MetadataObject;class ma extends wt{}ma.guid=u.MetadataLibraryObject;class Ca{static fromBuffer(e){return new Ca(e.length).get(e,0)}constructor(e){this.len=e}get(e,t){const i=new DataView(e.buffer,t),n=i.getUint8(0),r=i.getInt32(1,!0);let s=5;for(;i.getUint16(s)!==0;)s+=2;const o=new k(s-5,"utf-16le").get(e,5);for(;i.getUint16(s)!==0;)s+=2;const c=new k(s-5,"utf-16le").get(e,5);return{type:Ta[n],format:o,description:c,size:r,data:e.slice(s+4)}}}const Gt=C("music-metadata:parser:ASF"),oo="asf";class co extends J{async parse(){const e=await this.tokenizer.readToken(ao);if(!e.objectId.equals(u.HeaderObject))throw new ra("expected asf header; but was not found; got: ".concat(e.objectId.str));await this.parseObjectHeader(e.numberOfHeaderObjects)}async parseObjectHeader(e){let t;do{const i=await this.tokenizer.readToken(Se);switch(Gt("header GUID=%s",i.objectId.str),i.objectId.str){case sa.guid.str:{const n=await this.tokenizer.readToken(new sa(i));this.metadata.setFormat("duration",Number(n.playDuration/BigInt(1e3))/1e4-Number(n.preroll)/1e3),this.metadata.setFormat("bitrate",n.maximumBitrate);break}case oa.guid.str:{const n=await this.tokenizer.readToken(new oa(i));this.metadata.setFormat("container","ASF/".concat(n.streamType));break}case ca.guid.str:{const n=await this.tokenizer.readToken(new ca);await this.parseExtensionObject(n.extensionDataSize);break}case Ee.guid.str:t=await this.tokenizer.readToken(new Ee(i)),await this.addTags(t);break;case la.guid.str:t=await this.tokenizer.readToken(new la(i)),await this.addTags(t);break;case u.CodecListObject.str:{const n=await no(this.tokenizer);n.forEach(s=>{this.metadata.addStreamInfo({type:s.type.videoCodec?X.video:X.audio,codecName:s.codecName})});const r=n.filter(s=>s.type.audioCodec).map(s=>s.codecName).join("/");this.metadata.setFormat("codec",r);break}case u.StreamBitratePropertiesObject.str:await this.tokenizer.ignore(i.objectSize-Se.len);break;case u.PaddingObject.str:Gt("Padding: %s bytes",i.objectSize-Se.len),await this.tokenizer.ignore(i.objectSize-Se.len);break;default:this.metadata.addWarning("Ignore ASF-Object-GUID: ".concat(i.objectId.str)),Gt("Ignore ASF-Object-GUID: %s",i.objectId.str),await this.tokenizer.readToken(new si(i))}}while(--e)}async addTags(e){await Promise.all(e.map(({id:t,value:i})=>this.metadata.addTag(oo,t,i)))}async parseExtensionObject(e){do{const t=await this.tokenizer.readToken(Se),i=t.objectSize-Se.len;if(i<0)throw new ra("Invalid ASF header object size: ".concat(t.objectSize));switch(t.objectId.str){case da.guid.str:await this.tokenizer.readToken(new da(t));break;case wt.guid.str:{const n=await this.tokenizer.readToken(new wt(t));await this.addTags(n);break}case ma.guid.str:{const n=await this.tokenizer.readToken(new ma(t));await this.addTags(n);break}
5case u.PaddingObject.str:await this.tokenizer.ignore(i);break;case u.CompatibilityObject.str:await this.tokenizer.ignore(i);break;case u.ASF_Index_Placeholder_Object.str:await this.tokenizer.ignore(i);break;default:this.metadata.addWarning("Ignore ASF-Object-GUID: ".concat(t.objectId.str)),await this.tokenizer.readToken(new si(t));break}e-=t.objectSize}while(e>0)}}const lo=Object.freeze(Object.defineProperty({__proto__:null,AsfParser:co},Symbol.toStringTag,{value:"Module"})),Pe={len:12,get:(a,e)=>({chunkID:F.get(a,e),chunkSize:Fi.get(a,e+4)})},R=C("music-metadata:parser:aiff");class mt extends O("DSDIFF"){}class mo extends J{async parse(){const e=await this.tokenizer.readToken(Pe);if(e.chunkID!=="FRM8")throw new mt("Unexpected chunk-ID");this.metadata.setAudioOnly();const t=(await this.tokenizer.readToken(F)).trim();switch(t){case"DSD":return this.metadata.setFormat("container","DSDIFF/".concat(t)),this.metadata.setFormat("lossless",!0),this.readFmt8Chunks(e.chunkSize-BigInt(F.len));default:throw new mt("Unsupported DSDIFF type: ".concat(t))}}async readFmt8Chunks(e){for(;e>=Pe.len;){const t=await this.tokenizer.readToken(Pe);R("Chunk id=".concat(t.chunkID)),await this.readData(t),e-=BigInt(Pe.len)+t.chunkSize}}async readData(e){R("Reading data of chunk[ID=".concat(e.chunkID,", size=").concat(e.chunkSize,"]"));const t=this.tokenizer.position;switch(e.chunkID.trim()){case"FVER":{const n=await this.tokenizer.readToken(f);R("DSDIFF version=".concat(n));break}case"PROP":{if(await this.tokenizer.readToken(F)!=="SND ")throw new mt("Unexpected PROP-chunk ID");await this.handleSoundPropertyChunks(e.chunkSize-BigInt(F.len));break}case"ID3":{const n=await this.tokenizer.readToken(new U(Number(e.chunkSize))),r=Ce(n);await new oe().parse(this.metadata,r,this.options);break}case"DSD":this.metadata.format.numberOfChannels&&this.metadata.setFormat("numberOfSamples",Number(e.chunkSize*BigInt(8)/BigInt(this.metadata.format.numberOfChannels))),this.metadata.format.numberOfSamples&&this.metadata.format.sampleRate&&this.metadata.setFormat("duration",this.metadata.format.numberOfSamples/this.metadata.format.sampleRate);break;default:R("Ignore chunk[ID=".concat(e.chunkID,", size=").concat(e.chunkSize,"]"));break}const i=e.chunkSize-BigInt(this.tokenizer.position-t);i>0&&(R("After Parsing chunk, remaining ".concat(i," bytes")),await this.tokenizer.ignore(Number(i)))}async handleSoundPropertyChunks(e){for(R("Parsing sound-property-chunks, remainingSize=".concat(e));e>0;){const t=await this.tokenizer.readToken(Pe);R("Sound-property-chunk[ID=".concat(t.chunkID,", size=").concat(t.chunkSize,"]"));const i=this.tokenizer.position;switch(t.chunkID.trim()){case"FS":{const r=await this.tokenizer.readToken(x);this.metadata.setFormat("sampleRate",r);break}case"CHNL":{const r=await this.tokenizer.readToken(v);this.metadata.setFormat("numberOfChannels",r),await this.handleChannelChunks(t.chunkSize-BigInt(v.len));break}case"CMPR":{const r=(await this.tokenizer.readToken(F)).trim(),s=await this.tokenizer.readToken(T),o=await this.tokenizer.readToken(new k(s,"ascii"));r==="DSD"&&(this.metadata.setFormat("lossless",!0),this.metadata.setFormat("bitsPerSample",1)),this.metadata.setFormat("codec","".concat(r," (").concat(o,")"));break}case"ABSS":{const r=await this.tokenizer.readToken(v),s=await this.tokenizer.readToken(T),o=await this.tokenizer.readToken(T),c=await this.tokenizer.readToken(x);R("ABSS ".concat(r,":").concat(s,":").concat(o,".").concat(c));break}case"LSCO":{const r=await this.tokenizer.readToken(v);R("LSCO lsConfig=".concat(r));break}default:R("Unknown sound-property-chunk[ID=".concat(t.chunkID,", size=").concat(t.chunkSize,"]")),await this.tokenizer.ignore(Number(t.chunkSize))}const n=t.chunkSize-BigInt(this.tokenizer.position-i);n>0&&(R("After Parsing sound-property-chunk ".concat(t.chunkSize,", remaining ").concat(n," bytes")),await this.tokenizer.ignore(Number(n))),e-=BigInt(Pe.len)+t.chunkSize,R("Parsing sound-property-chunks, remainingSize=".concat(e))}if(this.metadata.format.lossless&&this.metadata.format.sampleRate&&this.metadata.format.numberOfChannels&&this.metadata.format.bitsPerSample){const t=this.metadata.format.sampleRate*this.metadata.format.numberOfChannels*this.metadata.format.bitsPerSample;this.metadata.setFormat("bitrate",t)}}async handleChannelChunks(e){R("Parsing channel-chunks, remainingSize=".concat(e));const t=[];for(;e>=F.len;){const i=await this.tokenizer.readToken(F);
5R("Channel[ID=".concat(i,"]")),t.push(i),e-=BigInt(F.len)}return R("Channels: ".concat(t.join(", "))),t}}const uo=Object.freeze(Object.defineProperty({__proto__:null,DsdiffContentParseError:mt,DsdiffParser:mo},Symbol.toStringTag,{value:"Module"})),ho={NONE:"not compressed	PCM	Apple Computer",sowt:"PCM (byte swapped)",fl32:"32-bit floating point IEEE 32-bit float",fl64:"64-bit floating point IEEE 64-bit float	Apple Computer",alaw:"ALaw 2:1	8-bit ITU-T G.711 A-law",ulaw:"µLaw 2:1	8-bit ITU-T G.711 µ-law	Apple Computer",ULAW:"CCITT G.711 u-law 8-bit ITU-T G.711 µ-law",ALAW:"CCITT G.711 A-law 8-bit ITU-T G.711 A-law",FL32:"Float 32	IEEE 32-bit float "};class We extends O("AIFF"){}class po{constructor(e,t){this.isAifc=t;const i=t?22:18;if(e.chunkSize<i)throw new We("COMMON CHUNK size should always be at least ".concat(i));this.len=e.chunkSize}get(e,t){const i=v.get(e,t+8)-16398,n=v.get(e,t+8+2),r={numChannels:v.get(e,t),numSampleFrames:x.get(e,t+2),sampleSize:v.get(e,t+6),sampleRate:i<0?n>>Math.abs(i):n<<i};if(this.isAifc){if(r.compressionType=F.get(e,t+18),this.len>22){const s=T.get(e,t+22);if(s>0){const o=(s+1)%2;if(23+s+o===this.len)r.compressionName=new k(s,"latin1").get(e,t+23);else throw new We("Illegal pstring length")}else r.compressionName=void 0}}else r.compressionName="PCM";return r}}const Wt={len:8,get:(a,e)=>({chunkID:F.get(a,e),chunkSize:Number(BigInt(x.get(a,e+4)))})},Ht=C("music-metadata:parser:aiff");class go extends J{constructor(){super(...arguments),this.isCompressed=null}async parse(){if((await this.tokenizer.readToken(Wt)).chunkID!=="FORM")throw new We("Invalid Chunk-ID, expected 'FORM'");const t=await this.tokenizer.readToken(F);switch(t){case"AIFF":this.metadata.setFormat("container",t),this.isCompressed=!1;break;case"AIFC":this.metadata.setFormat("container","AIFF-C"),this.isCompressed=!0;break;default:throw new We("Unsupported AIFF type: ".concat(t))}this.metadata.setFormat("lossless",!this.isCompressed),this.metadata.setAudioOnly();try{for(;!this.tokenizer.fileInfo.size||this.tokenizer.fileInfo.size-this.tokenizer.position>=Wt.len;){Ht("Reading AIFF chunk at offset=".concat(this.tokenizer.position));const i=await this.tokenizer.readToken(Wt),n=2*Math.round(i.chunkSize/2),r=await this.readData(i);await this.tokenizer.ignore(n-r)}}catch(i){if(i instanceof E)Ht("End-of-stream");else throw i}}async readData(e){var t;switch(e.chunkID){case"COMM":{if(this.isCompressed===null)throw new We("Failed to parse AIFF.COMM chunk when compression type is unknown");const i=await this.tokenizer.readToken(new po(e,this.isCompressed));return this.metadata.setFormat("bitsPerSample",i.sampleSize),this.metadata.setFormat("sampleRate",i.sampleRate),this.metadata.setFormat("numberOfChannels",i.numChannels),this.metadata.setFormat("numberOfSamples",i.numSampleFrames),this.metadata.setFormat("duration",i.numSampleFrames/i.sampleRate),(i.compressionName||i.compressionType)&&this.metadata.setFormat("codec",(t=i.compressionName)!=null?t:ho[i.compressionType]),e.chunkSize}case"ID3 ":{const i=await this.tokenizer.readToken(new U(e.chunkSize)),n=Ce(i);return await new oe().parse(this.metadata,n,this.options),e.chunkSize}case"SSND":return this.metadata.format.duration&&this.metadata.setFormat("bitrate",8*e.chunkSize/this.metadata.format.duration),0;case"NAME":case"AUTH":case"(c) ":case"ANNO":return this.readTextChunk(e);default:return Ht("Ignore chunk id=".concat(e.chunkID,", size=").concat(e.chunkSize)),0}}async readTextChunk(e){const i=(await this.tokenizer.readToken(new k(e.chunkSize,"ascii"))).split("\0").map(n=>n.trim()).filter(n=>n==null?void 0:n.length);return await Promise.all(i.map(n=>this.metadata.addTag("AIFF",e.chunkID,n))),e.chunkSize}}const fo=Object.freeze(Object.defineProperty({__proto__:null,AIFFParser:go},Symbol.toStringTag,{value:"Module"})),st={len:12,get:(a,e)=>({id:F.get(a,e),size:$.get(a,e+4)})},xo={len:16,get:(a,e)=>({fileSize:pt.get(a,e),metadataPointer:pt.get(a,e+8)})},ko={len:40,get:(a,e)=>({formatVersion:D.get(a,e),formatID:D.get(a,e+4),channelType:D.get(a,e+8),channelNum:D.get(a,e+12),samplingFrequency:D.get(a,e+16),bitsPerSample:D.get(a,e+20),sampleCount:pt.get(a,e+24),blockSizePerChannel:D.get(a,e+32)})},Xt=C("music-metadata:parser:DSF");class Hi extends O("DSD"){}class wo extends Pt{async postId3v2Parse(){const e=this.tokenizer.position,t=await this.tokenizer.readToken(st);if(t.id!=="DSD ")throw new Hi("Invalid chunk signature");this.metadata.setFormat("container","DSF"),this.metadata.setFormat("lossless",!0),this.metadata.setAudioOnly();const i=await this.tokenizer.readToken(xo);if(i.metadataPointer===BigInt(0))Xt("No ID3v2 tag present");else return Xt("expect ID3v2 at offset=".concat(i.metadataPointer)),await this.parseChunks(i.fileSize-t.size),await this.tokenizer.ignore(Number(i.metadataPointer)-this.tokenizer.position-e),new oe().parse(this.metadata,this.tokenizer,this.options)}async parseChunks(e){for(;e>=st.len;){const t=await this.tokenizer.readToken(st);switch(Xt("Parsing chunk name=".concat(t.id," size=").concat(t.size)),t.id){case"fmt ":{const i=await this.tokenizer.readToken(ko);this.metadata.setFormat("numberOfChannels",i.channelNum),this.metadata.setFormat("sampleRate",i.samplingFrequency),this.metadata.setFormat("bitsPerSample",i.bitsPerSample),this.metadata.setFormat("numberOfSamples",i.sampleCount),this.metadata.setFormat("duration",Number(i.sampleCount)/i.samplingFrequency);const n=i.bitsPerSample*i.samplingFrequency*i.channelNum;this.metadata.setFormat("bitrate",n);return}default:this.tokenizer.ignore(Number(t.size)-st.len);break}e-=t.size}}}const To=Object.freeze(Object.defineProperty({__proto__:null,DsdContentParseError:Hi,DsfParser:wo},Symbol.toStringTag,{value:"Module"}));class Re{static fromBase64(e){return Re.fromBuffer(Uint8Array.from(atob(e),t=>t.charCodeAt(0)))}static fromBuffer(e){return new Re(e.length).get(e,0)}constructor(e){this.len=e}get(e,t){const i=Ta[x.get(e,t)];t+=4;const n=x.get(e,t);t+=4;const r=new k(n,"utf-8").get(e,t);t+=n;const s=x.get(e,t);t+=4;const o=new k(s,"utf-8").get(e,t);t+=s;const c=x.get(e,t);t+=4;const l=x.get(e,t);t+=4;const d=x.get(e,t);t+=4;const m=x.get(e,t);t+=4;const p=x.get(e,t);t+=4;const y=e.slice(t,t+p);
5return{type:i,format:r,description:o,width:c,height:l,colour_depth:d,indexed_color:m,data:y}}}const ot={len:7,get:(a,e)=>({packetType:T.get(a,e),vorbis:new k(6,"ascii").get(a,e+1)})},bo={len:23,get:(a,e)=>({version:f.get(a,e+0),channelMode:T.get(a,e+4),sampleRate:f.get(a,e+5),bitrateMax:f.get(a,e+9),bitrateNominal:f.get(a,e+13),bitrateMin:f.get(a,e+17)})};class Xi{constructor(e,t){this.data=e,this.offset=t}readInt32(){const e=f.get(this.data,this.offset);return this.offset+=4,e}readStringUtf8(){const e=this.readInt32(),t=te(this.data.subarray(this.offset,this.offset+e),"utf-8");return this.offset+=e,t}parseUserComment(){const e=this.offset,t=this.readStringUtf8(),i=t.indexOf("=");return{key:t.substring(0,i).toUpperCase(),value:t.substring(i+1),len:this.offset-e}}}const ze=C("music-metadata:parser:ogg:vorbis1");class Vt extends O("Vorbis"){}class Ae{constructor(e,t){this.pageSegments=[],this.durationOnLastPage=!0,this.metadata=e,this.options=t}async parsePage(e,t){if(this.lastPageHeader=e,e.headerType.firstPage)this.parseFirstPage(e,t);else{if(e.headerType.continued){if(this.pageSegments.length===0)throw new Vt("Cannot continue on previous page");this.pageSegments.push(t)}if(e.headerType.lastPage||!e.headerType.continued){if(this.pageSegments.length>0){const i=Ae.mergeUint8Arrays(this.pageSegments);await this.parseFullPage(i)}this.pageSegments=e.headerType.lastPage?[]:[t]}}}static mergeUint8Arrays(e){const t=e.reduce((n,r)=>n+r.length,0),i=new Uint8Array(t);return e.forEach((n,r,s)=>{const o=s.slice(0,r).reduce((c,l)=>c+l.length,0);i.set(n,o)}),i}async flush(){await this.parseFullPage(Ae.mergeUint8Arrays(this.pageSegments))}async parseUserComment(e,t){const n=new Xi(e,t).parseUserComment();return await this.addTag(n.key,n.value),n.len}async addTag(e,t){if(e==="METADATA_BLOCK_PICTURE"&&typeof t=="string"){if(this.options.skipCovers){ze("Ignore picture");return}t=Re.fromBase64(t),ze("Push picture: id=".concat(e,", format=").concat(t.format))}else ze("Push tag: id=".concat(e,", value=").concat(t));await this.metadata.addTag("vorbis",e,t)}calculateDuration(e){this.lastPageHeader&&(e||this.lastPageHeader.headerType.lastPage)&&this.metadata.format.sampleRate&&this.lastPageHeader.absoluteGranulePosition>=0&&(this.metadata.setFormat("numberOfSamples",this.lastPageHeader.absoluteGranulePosition),this.metadata.setFormat("duration",this.lastPageHeader.absoluteGranulePosition/this.metadata.format.sampleRate))}parseFirstPage(e,t){this.metadata.setFormat("codec","Vorbis I"),this.metadata.setFormat("hasAudio",!0),ze("Parse first page");const i=ot.get(t,0);if(i.vorbis!=="vorbis")throw new Vt("Metadata does not look like Vorbis");if(i.packetType===1){const n=bo.get(t,ot.len);this.metadata.setFormat("sampleRate",n.sampleRate),this.metadata.setFormat("bitrate",n.bitrateNominal),this.metadata.setFormat("numberOfChannels",n.channelMode),ze("sample-rate=%s[hz], bitrate=%s[b/s], channel-mode=%s",n.sampleRate,n.bitrateNominal,n.channelMode)}else throw new Vt("First Ogg page should be type 1: the identification header")}async parseFullPage(e){const t=ot.get(e,0);switch(ze("Parse full page: type=%s, byteLength=%s",t.packetType,e.byteLength),t.packetType){case 3:return this.parseUserCommentList(e,ot.len)}}async parseUserCommentList(e,t){const i=f.get(e,t);t+=4,t+=i;let n=f.get(e,t);for(t+=4;n-- >0;)t+=await this.parseUserComment(e,t)}}const V={STREAMINFO:0,PADDING:1,APPLICATION:2,SEEKTABLE:3,VORBIS_COMMENT:4,CUESHEET:5,PICTURE:6},ua={len:4,get:(a,e)=>({lastBlock:I(a,e,7),type:S(a,e,1,7),length:B.get(a,e+1)})},ha={len:34,get:(a,e)=>({minimumBlockSize:v.get(a,e),maximumBlockSize:v.get(a,e+2)/1e3,minimumFrameSize:B.get(a,e+4),maximumFrameSize:B.get(a,e+7),sampleRate:B.get(a,e+10)>>4,channels:S(a,e+12,4,3)+1,bitsPerSample:S(a,e+12,7,5)+1,totalSamples:S(a,e+13,4,36),fileMD5:new U(16).get(a,e+18)})},yo=C("music-metadata:parser:FLAC");class ci extends O("FLAC"){}class Vi extends Pt{constructor(){super(...arguments),this.vorbisParser=new Ae(this.metadata,this.options)}async postId3v2Parse(){if((await this.tokenizer.readToken(F)).toString()!=="fLaC")throw new ci("Invalid FLAC preamble");let t;do t=await this.tokenizer.readToken(ua),await this.parseDataBlock(t);while(!t.lastBlock);if(this.tokenizer.fileInfo.size&&this.metadata.format.duration){const i=this.tokenizer.fileInfo.size-this.tokenizer.position;this.metadata.setFormat("bitrate",8*i/this.metadata.format.duration)}}async parseDataBlock(e){switch(yo("blockHeader type=".concat(e.type,", length=").concat(e.length)),e.type){case V.STREAMINFO:return this.readBlockStreamInfo(e.length);case V.PADDING:break;case V.APPLICATION:break;case V.SEEKTABLE:break;case V.VORBIS_COMMENT:return this.readComment(e.length);case V.CUESHEET:break;
5case V.PICTURE:await this.parsePicture(e.length);return;default:this.metadata.addWarning("Unknown block type: ".concat(e.type))}return this.tokenizer.ignore(e.length).then()}async readBlockStreamInfo(e){if(e!==ha.len)throw new ci("Unexpected block-stream-info length");const t=await this.tokenizer.readToken(ha);this.metadata.setFormat("container","FLAC"),this.processsStreamInfo(t)}processsStreamInfo(e){this.metadata.setFormat("codec","FLAC"),this.metadata.setFormat("hasAudio",!0),this.metadata.setFormat("lossless",!0),this.metadata.setFormat("numberOfChannels",e.channels),this.metadata.setFormat("bitsPerSample",e.bitsPerSample),this.metadata.setFormat("sampleRate",e.sampleRate),e.totalSamples>0&&this.metadata.setFormat("duration",e.totalSamples/e.sampleRate)}async readComment(e){const t=await this.tokenizer.readToken(new U(e));return this.parseComment(t)}async parseComment(e){const t=new Xi(e,0),i=t.readStringUtf8();i.length>0&&this.metadata.setFormat("tool",i);const n=t.readInt32(),r=new Array(n);for(let s=0;s<n;s++)r[s]=t.parseUserComment();await Promise.all(r.map(s=>(s.key==="ENCODER"&&this.metadata.setFormat("tool",s.value),this.addTag(s.key,s.value))))}async parsePicture(e){return this.options.skipCovers?this.tokenizer.ignore(e):this.addPictureTag(await this.tokenizer.readToken(new Re(e)))}addPictureTag(e){return this.addTag("METADATA_BLOCK_PICTURE",e)}addTag(e,t){return this.vorbisParser.addTag(e,t)}}const So=Object.freeze(Object.defineProperty({__proto__:null,FlacParser:Vi},Symbol.toStringTag,{value:"Module"})),h={string:0,uint:1,uid:2,bool:3,binary:4,float:5},Io={name:"dtd",container:{440786851:{name:"ebml",container:{17030:{name:"ebmlVersion",value:h.uint},17143:{name:"ebmlReadVersion",value:h.uint},17138:{name:"ebmlMaxIDWidth",value:h.uint},17139:{name:"ebmlMaxSizeWidth",value:h.uint},17026:{name:"docType",value:h.string},17031:{name:"docTypeVersion",value:h.uint},17029:{name:"docTypeReadVersion",value:h.uint}}},408125543:{name:"segment",container:{290298740:{name:"seekHead",container:{19899:{name:"seek",multiple:!0,container:{21419:{name:"id",value:h.binary},21420:{name:"position",value:h.uint}}}}},357149030:{name:"info",container:{29604:{name:"uid",value:h.uid},29572:{name:"filename",value:h.string},3979555:{name:"prevUID",value:h.uid},3965867:{name:"prevFilename",value:h.string},4110627:{name:"nextUID",value:h.uid},4096955:{name:"nextFilename",value:h.string},2807729:{name:"timecodeScale",value:h.uint},17545:{name:"duration",value:h.float},17505:{name:"dateUTC",value:h.uint},31657:{name:"title",value:h.string},19840:{name:"muxingApp",value:h.string},22337:{name:"writingApp",value:h.string}}},524531317:{name:"cluster",multiple:!0,container:{231:{name:"timecode",value:h.uid},22743:{name:"silentTracks ",multiple:!0},167:{name:"position",value:h.uid},171:{name:"prevSize",value:h.uid},160:{name:"blockGroup"},163:{name:"simpleBlock"}}},374648427:{name:"tracks",container:{174:{name:"entries",multiple:!0,container:{215:{name:"trackNumber",value:h.uint},29637:{name:"uid",value:h.uid},131:{name:"trackType",value:h.uint},185:{name:"flagEnabled",value:h.bool},136:{name:"flagDefault",value:h.bool},21930:{name:"flagForced",value:h.bool},156:{name:"flagLacing",value:h.bool},28135:{name:"minCache",value:h.uint},28136:{name:"maxCache",value:h.uint},2352003:{name:"defaultDuration",value:h.uint},2306383:{name:"timecodeScale",value:h.float},21358:{name:"name",value:h.string},2274716:{name:"language",value:h.string},134:{name:"codecID",value:h.string},25506:{name:"codecPrivate",value:h.binary},2459272:{name:"codecName",value:h.string},3839639:{name:"codecSettings",value:h.string},3883072:{name:"codecInfoUrl",value:h.string},2536e3:{name:"codecDownloadUrl",value:h.string},170:{name:"codecDecodeAll",value:h.bool},28587:{name:"trackOverlay",value:h.uint},224:{name:"video",container:{154:{name:"flagInterlaced",value:h.bool},21432:{name:"stereoMode",value:h.uint},176:{name:"pixelWidth",value:h.uint},186:{name:"pixelHeight",value:h.uint},21680:{name:"displayWidth",value:h.uint},21690:{name:"displayHeight",value:h.uint},21683:{name:"aspectRatioType",value:h.uint},3061028:{name:"colourSpace",value:h.uint},3126563:{name:"gammaValue",value:h.float}}},225:{name:"audio",container:{181:{name:"samplingFrequency",value:h.float},30901:{name:"outputSamplingFrequency",value:h.float}
5,159:{name:"channels",value:h.uint},148:{name:"channels",value:h.uint},32123:{name:"channelPositions",value:h.binary},25188:{name:"bitDepth",value:h.uint}}},28032:{name:"contentEncodings",container:{25152:{name:"contentEncoding",container:{20529:{name:"order",value:h.uint},20530:{name:"scope",value:h.bool},20531:{name:"type",value:h.uint},20532:{name:"contentEncoding",container:{16980:{name:"contentCompAlgo",value:h.uint},16981:{name:"contentCompSettings",value:h.binary}}},20533:{name:"contentEncoding",container:{18401:{name:"contentEncAlgo",value:h.uint},18402:{name:"contentEncKeyID",value:h.binary},18403:{name:"contentSignature ",value:h.binary},18404:{name:"ContentSigKeyID  ",value:h.binary},18405:{name:"contentSigAlgo ",value:h.uint},18406:{name:"contentSigHashAlgo ",value:h.uint}}},25188:{name:"bitDepth",value:h.uint}}}}}}}}},475249515:{name:"cues",container:{187:{name:"cuePoint",container:{179:{name:"cueTime",value:h.uid},183:{name:"positions",container:{247:{name:"track",value:h.uint},241:{name:"clusterPosition",value:h.uint},21368:{name:"blockNumber",value:h.uint},234:{name:"codecState",value:h.uint},219:{name:"reference",container:{150:{name:"time",value:h.uint},151:{name:"cluster",value:h.uint},21343:{name:"number",value:h.uint},235:{name:"codecState",value:h.uint}}},240:{name:"relativePosition",value:h.uint}}}}}}},423732329:{name:"attachments",container:{24999:{name:"attachedFiles",multiple:!0,container:{18046:{name:"description",value:h.string},18030:{name:"name",value:h.string},18016:{name:"mimeType",value:h.string},18012:{name:"data",value:h.binary},18094:{name:"uid",value:h.uid}}}}},272869232:{name:"chapters",container:{17849:{name:"editionEntry",container:{182:{name:"chapterAtom",container:{29636:{name:"uid",value:h.uid},145:{name:"timeStart",value:h.uint},146:{name:"timeEnd",value:h.uid},152:{name:"hidden",value:h.bool},17816:{name:"enabled",value:h.uid},143:{name:"track",container:{137:{name:"trackNumber",value:h.uid},128:{name:"display",container:{133:{name:"string",value:h.string},17276:{name:"language ",value:h.string},17278:{name:"country ",value:h.string}}}}}}}}}}},307544935:{name:"tags",container:{29555:{name:"tag",multiple:!0,container:{25536:{name:"target",container:{25541:{name:"tagTrackUID",value:h.uid},25540:{name:"tagChapterUID",value:h.uint},25542:{name:"tagAttachmentUID",value:h.uid},25546:{name:"targetType",value:h.string},26826:{name:"targetTypeValue",value:h.uint},25545:{name:"tagEditionUID",value:h.uid}}},26568:{name:"simpleTags",multiple:!0,container:{17827:{name:"name",value:h.string},17543:{name:"string",value:h.string},17541:{name:"binary",value:h.binary},17530:{name:"language",value:h.string},17531:{name:"languageIETF",value:h.string},17540:{name:"default",value:h.bool}}}}}}}}}}},_e=C("music-metadata:parser:ebml");class li extends O("EBML"){}const le={ReadNext:0,IgnoreElement:2,SkipSiblings:3,TerminateParsing:4,SkipElement:5};class vo{constructor(e){this.parserMap=new Map,this.ebmlMaxIDLength=4,this.ebmlMaxSizeLength=8,this.tokenizer=e,this.parserMap.set(h.uint,t=>this.readUint(t)),this.parserMap.set(h.string,t=>this.readString(t)),this.parserMap.set(h.binary,t=>this.readBuffer(t)),this.parserMap.set(h.uid,async t=>this.readBuffer(t)),this.parserMap.set(h.bool,t=>this.readFlag(t)),this.parserMap.set(h.float,t=>this.readFloat(t))}async iterate(e,t,i){return this.parseContainer(qi(e),t,i)}async parseContainer(e,t,i){const n={};for(;this.tokenizer.position<t;){let r;const s=this.tokenizer.position;try{r=await this.readElement()}catch(c){if(c instanceof E)break;throw c}const o=e.container[r.id];if(o)switch(i.startNext(o)){case le.ReadNext:if(r.id,_e("Read element: name=".concat(Ie(o),"{id=0x").concat(r.id.toString(16),", container=").concat(!!o.container,"} at position=").concat(s)),o.container){const l=await this.parseContainer(o,r.len>=0?this.tokenizer.position+r.len:-1,i);o.multiple?(n[o.name]||(n[o.name]=[]),n[o.name].push(l)):n[o.name]=l,await i.elementValue(o,l,s)}else{const l=this.parserMap.get(o.value);if(typeof l=="function"){const d=await l(r);n[o.name]=d,await i.elementValue(o,d,s)}}break;case le.SkipElement:_e("Go to next element: name=".concat(Ie(o),", element.i
5d=0x").concat(r.id,", container=").concat(!!o.container," at position=").concat(s));break;case le.IgnoreElement:_e("Ignore element: name=".concat(Ie(o),", element.id=0x").concat(r.id,", container=").concat(!!o.container," at position=").concat(s)),await this.tokenizer.ignore(r.len);break;case le.SkipSiblings:_e("Ignore remaining container, at: name=".concat(Ie(o),", element.id=0x").concat(r.id,", container=").concat(!!o.container," at position=").concat(s)),await this.tokenizer.ignore(t-this.tokenizer.position);break;case le.TerminateParsing:return _e("Terminate parsing at element: name=".concat(Ie(o),", element.id=0x").concat(r.id,", container=").concat(!!o.container," at position=").concat(s)),n}else switch(r.id){case 236:await this.tokenizer.ignore(r.len);break;default:_e("parseEbml: parent=".concat(Ie(e),", unknown child: id=").concat(r.id.toString(16)," at position=").concat(s)),await this.tokenizer.ignore(r.len)}}return n}async readVintData(e){const t=await this.tokenizer.peekNumber(T);let i=128,n=1;for(;(t&i)===0;){if(n>e)throw new li("VINT value exceeding maximum size");++n,i>>=1}const r=new Uint8Array(n);return await this.tokenizer.readBuffer(r),r}async readElement(){const e=await this.readVintData(this.ebmlMaxIDLength),t=await this.readVintData(this.ebmlMaxSizeLength);return t[0]^=128>>t.length-1,{id:qt(e,e.length),len:qt(t,t.length)}}async readFloat(e){switch(e.len){case 0:return 0;case 4:return this.tokenizer.readNumber(Di);case 8:return this.tokenizer.readNumber(Jt);case 10:return this.tokenizer.readNumber(Jt);default:throw new li("Invalid IEEE-754 float length: ".concat(e.len))}}async readFlag(e){return await this.readUint(e)===1}async readUint(e){const t=await this.readBuffer(e);return qt(t,e.len)}async readString(e){return(await this.tokenizer.readToken(new k(e.len,"utf-8"))).replace(/\x00.*$/g,"")}async readBuffer(e){const t=new Uint8Array(e.len);return await this.tokenizer.readBuffer(t),t}}function qt(a,e){return Number(Co(a,e))}function Co(a,e){const t=new Uint8Array(8),i=a.subarray(0,e);try{return t.set(i,8-e),Et.get(t,0)}catch(n){return BigInt(-1)}}function qi(a){return a.container&&Object.keys(a.container).map(e=>{const t=a.container[e];return t.id=Number.parseInt(e,10),t}).forEach(e=>{e.parent=a,qi(e)}),a}function Ie(a){let e="";return a.parent&&a.parent.name!=="dtd"&&(e+="".concat(Ie(a.parent),"/")),e+a.name}const ct=C("music-metadata:parser:matroska");class Eo extends J{constructor(){var e;super(...arguments),this.seekHeadOffset=0,this.flagUseIndexToSkipClusters=(e=this.options.mkvUseIndex)!=null?e:!1}async parse(){var i;const e=(i=this.tokenizer.fileInfo.size)!=null?i:Number.MAX_SAFE_INTEGER,t=new vo(this.tokenizer);ct("Initializing DTD end MatroskaIterator"),await t.iterate(Io,e,{startNext:n=>{switch(n.id){case 475249515:return ct("Skip element: name=".concat(n.name,", id=0x").concat(n.id.toString(16))),le.IgnoreElement;case 524531317:if(this.flagUseIndexToSkipClusters&&this.seekHead){const r=this.seekHead.seek.find(s=>s.position+this.seekHeadOffset>this.tokenizer.position);if(r){const s=r.position+this.seekHeadOffset-this.tokenizer.position;return ct("Use index to go to next position, ignoring ".concat(s," bytes")),this.tokenizer.ignore(s),le.SkipElement}}return le.IgnoreElement;default:return le.ReadNext}},elementValue:async(n,r,s)=>{switch(ct("Received: name=".concat(n.name,", value=").concat(r)),n.id){case 17026:this.metadata.setFormat("container","EBML/".concat(r));break;case 290298740:this.seekHead=r,this.seekHeadOffset=s;break;case 357149030:{const o=r,c=o.timecodeScale?o.timecodeScale:1e6;if(typeof o.duration=="number"){const l=o.duration*c/1e9;await this.addTag("segment:title",o.title),this.metadata.setFormat("duration",Number(l))}}break;case 374648427:{const o=r;if(o!=null&&o.entries){o.entries.forEach(l=>{const d={codecName:l.codecID.replace("A_","").replace("V_",""),codecSettings:l.codecSettings,flagDefault:l.flagDefault,flagLacing:l.flagLacing,flagEnabled:l.flagEnabled,language:l.language,name:l.name,type:l.trackType,audio:l.audio,video:l.video};this.metadata.addStreamInfo(d)});const c=o.entries.filter(l=>l.trackType===X.audio).reduce((l,d)=>!l||d.flagDefault&&!l.flagDefault||d.trackNumber<l.trackNumber?d:l,null);c&&(this.metadata.setFormat("codec",c.codecID.replace("A_","")),this.metadata.setFormat("sampleRate",c.audio.samplingFrequency),this.metadata.setFormat("numberOfChannels",c.audio.channels))}}break;case 307544935:{const o=r;await Promise.all(o.tag.map(async c=>{const l=c.target,d=l!=null&&l.targetTypeValue?Mr[l.targetTypeValue]:l!=null&&l.targetType?l.targetType:"track";await Promise.all(c.simpleTags.map(async m=>{const p=m.string?m.string:m.binary;await this.addTag("".concat(d,":").concat(m.name),p)}))}))}break;case 423732329:{const o=r;await Promise.all(o.attachedFiles.filter(c=>c.mimeType.startsWith("image/")).map(c=>this.addTag("picture",{data:c.data,format:c.mimeType,description:c.description,name:c.name})))}break}}})}async addTag(e,t){await this.metadata.addTag("matroska",e,t)}}const Ao=Object.freeze(Object.defineProperty({__proto__:null,MatroskaParser:Eo},Symbol.toStringTag,{value:"Module"})),Ea=C("music-metadata:parser:MP4:atom");class Be extends O("MP4"){}const Tt={len:8,get:(a,e)=>{const t=x.get(a,e);
5if(t<0)throw new Be("Invalid atom header length");return{length:BigInt(t),name:new k(4,"latin1").get(a,e+4)}},put:(a,e,t)=>(x.put(a,e,Number(t.length)),F.put(a,e+4,t.name))},Fo=Et,di={len:4,get:(a,e)=>({type:new k(4,"ascii").get(a,e)})};class Zi{constructor(e,t,i){if(e<t)throw new Be("Atom ".concat(i," expected to be ").concat(t,", but specifies ").concat(e," bytes long."));e>t&&Ea("Warning: atom ".concat(i," expected to be ").concat(t,", but was actually ").concat(e," bytes long.")),this.len=e}}const Le={len:4,get:(a,e)=>{const t=x.get(a,e)-2082844800;return new Date(t*1e3)}};class Do extends Zi{constructor(e){super(e,24,"mdhd")}get(e,t){return{version:T.get(e,t+0),flags:B.get(e,t+1),creationTime:Le.get(e,t+4),modificationTime:Le.get(e,t+8),timeScale:x.get(e,t+12),duration:x.get(e,t+16),language:v.get(e,t+20),quality:v.get(e,t+22)}}}class Po extends Zi{constructor(e){super(e,100,"mvhd")}get(e,t){return{version:T.get(e,t),flags:B.get(e,t+1),creationTime:Le.get(e,t+4),modificationTime:Le.get(e,t+8),timeScale:x.get(e,t+12),duration:x.get(e,t+16),preferredRate:x.get(e,t+20),preferredVolume:v.get(e,t+24),previewTime:x.get(e,t+72),previewDuration:x.get(e,t+76),posterTime:x.get(e,t+80),selectionTime:x.get(e,t+84),selectionDuration:x.get(e,t+88),currentTime:x.get(e,t+92),nextTrackID:x.get(e,t+96)}}}class zo{constructor(e){this.len=e}get(e,t){return{type:{set:T.get(e,t+0),type:B.get(e,t+1)},locale:B.get(e,t+4),value:new U(this.len-8).get(e,t+8)}}}class _o{constructor(e){this.len=e}get(e,t){return{version:T.get(e,t),flags:B.get(e,t+1),name:new k(this.len-4,"utf-8").get(e,t+4)}}}class Mo{constructor(e){this.len=e}get(e,t){return{version:T.get(e,t),flags:B.get(e,t+1),creationTime:Le.get(e,t+4),modificationTime:Le.get(e,t+8),trackId:x.get(e,t+12),duration:x.get(e,t+20),layer:v.get(e,t+24),alternateGroup:v.get(e,t+26),volume:v.get(e,t+28)}}}const mi={len:8,get:(a,e)=>({version:T.get(a,e),flags:B.get(a,e+1),numberOfEntries:x.get(a,e+4)})};class Bo{constructor(e){this.len=e}get(e,t){const i=this.len-12;return{dataFormat:F.get(e,t),dataReferenceIndex:v.get(e,t+10),description:i>0?new U(i).get(e,t+12):void 0}}}class ui{constructor(e){this.len=e}get(e,t){const i=mi.get(e,t);t+=mi.len;const n=[];for(let r=0;r<i.numberOfEntries;++r){const s=x.get(e,t);t+=x.len,n.push(new Bo(s-x.len).get(e,t)),t+=s}return{header:i,table:n}}}const hi={len:8,get(a,e){return{version:se.get(a,e),revision:se.get(a,e+2),vendor:Y.get(a,e+4)}}},Oo={len:12,get(a,e){return{numAudioChannels:se.get(a,e+0),sampleSize:se.get(a,e+2),compressionId:se.get(a,e+4),packetSize:se.get(a,e+6),sampleRate:v.get(a,e+8)+v.get(a,e+10)/1e4}}};class Aa{constructor(e,t){this.len=e,this.token=t}get(e,t){const i=Y.get(e,t+4);return{version:ke.get(e,t+0),flags:fa.get(e,t+1),numberOfEntries:i,entries:Yi(e,this.token,t+8,this.len-8,i)}}}const Ro={len:8,get(a,e){return{count:Y.get(a,e+0),duration:Y.get(a,e+4)}}};class Lo extends Aa{constructor(e){super(e,Ro)}}const No={len:12,get(a,e){return{firstChunk:Y.get(a,e),samplesPerChunk:Y.get(a,e+4),sampleDescriptionId:Y.get(a,e+8)}}};class $o extends Aa{constructor(e){super(e,No)}}class pi{constructor(e){this.len=e}get(e,t){const i=Y.get(e,t+8);return{version:ke.get(e,t),flags:fa.get(e,t+1),sampleSize:Y.get(e,t+4),numberOfEntries:i,entries:Yi(e,Y,t+12,this.len-12,i)}}}class Uo extends Aa{constructor(e){super(e,Y),this.len=e}}class jo{constructor(e){this.len=e}get(e,t){const i=se.get(e,t+0);return new k(i,"utf-8").get(e,t+2)}}function Yi(a,e,t,i,n){if(Ea("remainingLen=".concat(i,", numberOfEntries=").concat(n," * token-len=").concat(e.len)),i===0)return[];if(i!==n*e.len)throw new Be("mismatch number-of-entries with remaining atom-length");const r=[];for(let s=0;s<n;++s)r.push(e.get(a,t)),t+=e.len;return r}class Go{constructor(e){this.len=e}get(e,t){const i=t+1,n={version:ke.get(e,t),flags:{baseDataOffsetPresent:I(e,i+2,0),sampleDescriptionIndexPresent:I(e,i+2,1),defaultSampleDurationPresent:I(e,i+2,3),defaultSampleSizePresent:I(e,i+2,4),defaultSampleFlagsPresent:I(e,i+2,5),defaultDurationIsEmpty:I(e,i,0),defaultBaseIsMoof:I(e,i,1)},trackId:x.get(e,4)};let r=8;return n.flags.baseDataOffsetPresent&&(n.baseDataOffset=Et.get(e,r),r+=8),n.flags.sampleDescriptionIndexPresent&&(n.sampleDescriptionIndex=x.get(e,r),r+=4),n.flags.defaultSampleDurationPresent&&(n.defaultSampleDuration=x.get(e,r),r+=4),n.flags.defaultSampleSizePresent&&(n.defaultSampleSize=x.get(e,r),r+=4),n.flags.defaultSampleFlagsPresent&&(n.defaultSampleFlags=x.get(e,r)),n}}class Wo{constructor(e){this.len=e}get(e,t){const i=t+1,n={version:ke.get(e,t),flags:{dataOffsetPresent:I(e,i+2,0),firstSampleFlagsPresent:I(e,i+2,2),sampleDurationPresent:I(e,i+1,0),sampleSizePresent:I(e,i+1,1),sampleFlagsPresent:I(e,i+1,2),sampleCompositionTimeOffsetsPresent:I(e,i+1,3)},sampleCount:x.get(e,t+4),samples:[]};let r=t+8;n.flags.dataOffsetPresent&&(n.dataOffset=x.get(e,r),r+=4),n.flags.firstSampleFlagsPresent&&(n.firstSampleFlags=x.get(e,r),r+=4);for(let s=0;s<n.sampleCount;++s){if(r>=this.len){Ea("TrackRunBox size mismatch");break}const o={};n.flags.sampleDurationPresent&&(o.sampleDuration=x.get(e,r),r+=4),n.flags.sampleSizePresent&&(o.sampleSize=x.get(e,r),r+=4),n.flags.sampleFlagsPresent&&(o.sampleFlags=x.get(e,r),r+=4),n.flags.sampleCompositionTimeOffsetsPresent&&(o.sampleCompositionTimeOffset=x.get(e,r),r+=4),n.samples.push(o)}return n}}class Ho{constructor(e){this.len=e}get(e,t){const i=new k(4,"utf-8");return{version:ke.get(e,t),flags:B.get(e,t+1),componentType:i.get(e,t+4),handlerType:i.get(e,t+8),componentName:new k(this.len-28,"utf-8").get(e,t+28)}}}class Xo{constructor(e){this.len=e}get(e,t){let i=0;const n=[];for(;i<this.len;)n.push(x.get(e,t+i)),i+=4;return n}}const gi=C("music-metadata:parser:MP4:Atom");class bt{static async readAtom(e,t,i,n){const r=e.position;gi("Reading next token on offset=".concat(r,"..."));const s=await e.readToken(Tt),o=s.length===BigInt(1);o&&(s.length=await e.readToken(Fo));const c=new bt(s,o,i),l=c.getPayloadLength(n);return gi("parse atom name=".concat(c.atomPath,", extended=").concat(c.extended,", offset=").concat(r,", len=").concat(c.header.length)),await c.readData(e,t,l),c}constructor(e,t,i){this.header=e,this.extended=t,this.parent=i,this.children=[],this.atomPath=(this.parent?"".concat(this.parent.atomPath,"."):"")+this.header.n
5ame}getHeaderLength(){return this.extended?16:8}getPayloadLength(e){return(this.header.length===BigInt(0)?e:Number(this.header.length))-this.getHeaderLength()}async readAtoms(e,t,i){for(;i>0;){const n=await bt.readAtom(e,t,this,i);this.children.push(n),i-=n.header.length===BigInt(0)?i:Number(n.header.length)}}async readData(e,t,i){switch(this.header.name){case"moov":case"udta":case"mdia":case"minf":case"stbl":case"<id>":case"ilst":case"tref":case"moof":return this.readAtoms(e,t,this.getPayloadLength(i));case"meta":{const r=(await e.peekToken(Tt)).name==="hdlr"?0:4;return await e.ignore(r),this.readAtoms(e,t,this.getPayloadLength(i)-r)}default:return t(this,i)}}}const j=C("music-metadata:parser:MP4"),Vo="iTunes",fi={raw:{lossy:!1,format:"raw"},MAC3:{lossy:!0,format:"MACE 3:1"},MAC6:{lossy:!0,format:"MACE 6:1"},ima4:{lossy:!0,format:"IMA 4:1"},ulaw:{lossy:!0,format:"uLaw 2:1"},alaw:{lossy:!0,format:"uLaw 2:1"},Qclp:{lossy:!0,format:"QUALCOMM PureVoice"},".mp3":{lossy:!0,format:"MPEG-1 layer 3"},alac:{lossy:!1,format:"ALAC"},"ac-3":{lossy:!0,format:"AC-3"},mp4a:{lossy:!0,format:"MPEG-4/AAC"},mp4s:{lossy:!0,format:"MP4S"},c608:{lossy:!0,format:"CEA-608"},c708:{lossy:!0,format:"CEA-708"}};function xi(a,e,t){return t.indexOf(a)===e}class yt extends J{constructor(){super(...arguments),this.tracks=new Map,this.hasVideoTrack=!1,this.hasAudioTrack=!0,this.atomParsers={mvhd:async e=>{const t=await this.tokenizer.readToken(new Po(e));this.metadata.setFormat("creationTime",t.creationTime),this.metadata.setFormat("modificationTime",t.modificationTime)},chap:async e=>{const t=this.getTrackDescription(),i=[];for(;e>=x.len;)i.push(await this.tokenizer.readNumber(x)),e-=x.len;t.chapterList=i},mdat:async e=>{if(this.options.includeChapters){const t=[...this.tracks.values()].filter(i=>i.chapterList);if(t.length===1){const i=t[0].chapterList,n=[...this.tracks.values()].filter(r=>i.indexOf(r.header.trackId)!==-1);if(n.length===1)return this.parseChapterTrack(n[0],t[0],e)}}await this.tokenizer.ignore(e)},ftyp:async e=>{const t=[];for(;e>0;){const n=await this.tokenizer.readToken(di);e-=di.len;const r=n.type.replace(/\W/g,"");r.length>0&&t.push(r)}j("ftyp: ".concat(t.join("/")));const i=t.filter(xi).join("/");this.metadata.setFormat("container",i)},stsd:async e=>{const t=await this.tokenizer.readToken(new ui(e)),i=this.getTrackDescription();i.soundSampleDescription=t.table.map(n=>this.parseSoundSampleDescription(n))},stsz:async e=>{const t=await this.tokenizer.readToken(new pi(e)),i=this.getTrackDescription();i.sampleSize=t.sampleSize,i.sampleSizeTable=t.entries},date:async e=>{const t=await this.tokenizer.readToken(new k(e,"utf-8"));await this.addTag("date",t)}}}static read_BE_Integer(e,t){const i=(t?"INT":"UINT")+e.length*8+(e.length>1?"_BE":""),n=Bn[i];if(!n)throw new Be('Token for integer type not found: "'.concat(i,'"'));return Number(n.get(e,0))}async parse(){var n,r,s,o;this.hasVideoTrack=!1,this.hasAudioTrack=!0,this.tracks.clear();let e=this.tokenizer.fileInfo.size||0;for(;!this.tokenizer.fileInfo.size||e>0;){try{if((await this.tokenizer.peekToken(Tt)).name==="\0\0\0\0"){const d="Error at offset=".concat(this.tokenizer.position,": box.id=0");j(d),this.addWarning(d);break}}catch(l){if(l instanceof Error){const d="Error at offset=".concat(this.tokenizer.position,": ").concat(l.message);j(d),this.addWarning(d)}else throw l;break}const c=await bt.readAtom(this.tokenizer,(l,d)=>this.handleAtom(l,d),null,e);e-=c.header.length===BigInt(0)?e:Number(c.header.length)}const t=[];this.tracks.forEach(c=>{const l=[];c.soundSampleDescription.forEach(d=>{const m={},p=fi[d.dataFormat];if(p?(l.push(p.format),m.codecName=p.format):m.codecName="<".concat(d.dataFormat,">"),d.description){const{description:y}=d;y.sampleRate>0&&(m.type=X.audio,m.audio={samplingFrequency:y.sampleRate,bitDepth:y.sampleSize,channels:y.numAudioChannels})}this.metadata.addStreamInfo(m)}),l.length>=1&&t.push(l.join("/"))}),t.length>0&&this.metadata.setFormat("codec",t.filter(xi).join("+"));const i=[...this.tracks.values()].filter(c=>c.soundSampleDescription.length>=1&&c.soundSampleDescription[0].description&&c.soundSampleDescription[0].description.numAudioChannels>0);for(const c of i){if(c.media.header&&c.media.header.timeScale>0)if(c.sampleRate=c.media.header.timeScale,c.media.header.duration>
50&&(j("Using duration defined on audio track"),c.samples=c.media.header.duration,c.duration=c.samples/c.sampleRate),c.fragments.length>0){j("Calculate duration defined in track fragments");let m=0;c.sizeInBytes=0;for(const p of c.fragments)for(const y of p.trackRun.samples){const z=(r=(n=y.sampleDuration)!=null?n:p.header.defaultSampleDuration)!=null?r:0,de=(o=(s=y.sampleSize)!=null?s:p.header.defaultSampleSize)!=null?o:0;if(z===0)throw new Error("Missing sampleDuration and no defaultSampleDuration in track fragment header");if(de===0)throw new Error("Missing sampleSize and no defaultSampleSize in track fragment header");m+=z,c.sizeInBytes+=de}c.samples||(c.samples=m),c.duration||(c.duration=m/c.sampleRate)}else c.sampleSizeTable.length>0&&(c.sizeInBytes=c.sampleSizeTable.reduce((m,p)=>m+p,0));const l=c.soundSampleDescription[0];if(l.description&&c.media.header&&(this.metadata.setFormat("sampleRate",l.description.sampleRate),this.metadata.setFormat("bitsPerSample",l.description.sampleSize),this.metadata.setFormat("numberOfChannels",l.description.numAudioChannels),c.media.header.timeScale===0&&c.timeToSampleTable.length>0)){const m=c.timeToSampleTable.map(p=>p.count*p.duration).reduce((p,y)=>p+y);c.duration=m/l.description.sampleRate}const d=fi[l.dataFormat];d&&this.metadata.setFormat("lossless",!d.lossy)}if(i.length>=1){const c=i[0];c.duration&&(this.metadata.setFormat("duration",c.duration),c.sizeInBytes&&this.metadata.setFormat("bitrate",8*c.sizeInBytes/c.duration))}this.metadata.setFormat("hasAudio",this.hasAudioTrack),this.metadata.setFormat("hasVideo",this.hasVideoTrack)}async handleAtom(e,t){if(e.parent)switch(e.parent.header.name){case"ilst":case"<id>":return this.parseMetadataItemData(e);case"moov":switch(e.header.name){case"trak":return this.parseTrackBox(e);case"udta":return this.parseTrackBox(e)}break;case"moof":switch(e.header.name){case"traf":return this.parseTrackFragmentBox(e)}}if(this.atomParsers[e.header.name])return this.atomParsers[e.header.name](t);j("No parser for atom path=".concat(e.atomPath,", payload-len=").concat(t,", ignoring atom")),await this.tokenizer.ignore(t)}getTrackDescription(){const e=[...this.tracks.values()];return e[e.length-1]}async addTag(e,t){await this.metadata.addTag(Vo,e,t)}addWarning(e){j("Warning: ".concat(e)),this.metadata.addWarning(e)}parseMetadataItemData(e){let t=e.header.name;return e.readAtoms(this.tokenizer,async(i,n)=>{const r=i.getPayloadLength(n);switch(i.header.name){case"data":return this.parseValueAtom(t,i);case"name":case"mean":case"rate":{const s=await this.tokenizer.readToken(new _o(r));t+=":".concat(s.name);break}default:{const s=await this.tokenizer.readToken(new U(r));this.addWarning("Unsupported meta-item: ".concat(t,"[").concat(i.header.name,"] => value=").concat(zi(s)," ascii=").concat(te(s,"ascii")))}}},e.getPayloadLength(0))}async parseValueAtom(e,t){const i=await this.tokenizer.readToken(new zo(Number(t.header.length)-Tt.len));if(i.type.set!==0)throw new Be("Unsupported type-set != 0: ".concat(i.type.set));switch(i.type.type){case 0:switch(e){case"trkn":case"disk":{const n=T.get(i.value,3),r=T.get(i.value,5);await this.addTag(e,"".concat(n,"/").concat(r));break}case"gnre":{const n=T.get(i.value,1),r=kt[n-1];await this.addTag(e,r);break}case"rate":{const n=te(i.value,"ascii");await this.addTag(e,n);break}default:j("unknown proprietary value type for: ".concat(t.atomPath))}break;case 1:case 18:await this.addTag(e,te(i.value));break;case 13:if(this.options.skipCovers)break;await this.addTag(e,{format:"image/jpeg",data:Uint8Array.from(i.value)});break;case 14:if(this.options.skipCovers)break;await this.addTag(e,{format:"image/png",data:Uint8Array.from(i.value)});break;case 21:await this.addTag(e,yt.read_BE_Integer(i.value,!0));break;case 22:await this.addTag(e,yt.read_BE_Integer(i.value,!1));break;case 65:await this.addTag(e,T.get(i.value,0));break;case 66:await this.addTag(e,v.get(i.value,0));break;case 67:await this.addTag(e,x.get(i.value,0));break;default:this.addWarning("atom key=".concat(e,", has unknown well-known-type (data-type): ").concat(i.type.type))}}async parseTrackBox(e){const t={media:{},fragments:[]};await e.readAtoms(this.tokenizer,async(i,n)=>{const r=i.getPayloadLength(n);
5switch(i.header.name){case"chap":{const s=await this.tokenizer.readToken(new Xo(n));t.chapterList=s;break}case"tkhd":t.header=await this.tokenizer.readToken(new Mo(r));break;case"hdlr":t.handler=await this.tokenizer.readToken(new Ho(r)),t.isAudio=()=>t.handler.handlerType==="audi"||t.handler.handlerType==="soun",t.isVideo=()=>t.handler.handlerType==="vide",t.isAudio()?this.hasAudioTrack=!0:t.isVideo()&&(this.hasVideoTrack=!0);break;case"mdhd":{const s=await this.tokenizer.readToken(new Do(r));t.media.header=s;break}case"stco":{const s=await this.tokenizer.readToken(new Uo(r));t.chunkOffsetTable=s.entries;break}case"stsc":{const s=await this.tokenizer.readToken(new $o(r));t.sampleToChunkTable=s.entries;break}case"stsd":{const s=await this.tokenizer.readToken(new ui(r));t.soundSampleDescription=s.table.map(o=>this.parseSoundSampleDescription(o));break}case"stts":{const s=await this.tokenizer.readToken(new Lo(r));t.timeToSampleTable=s.entries;break}case"stsz":{const s=await this.tokenizer.readToken(new pi(r));t.sampleSize=s.sampleSize,t.sampleSizeTable=s.entries;break}case"dinf":case"vmhd":case"smhd":j("Ignoring: ".concat(i.header.name)),await this.tokenizer.ignore(r);break;default:j("Unexpected track box: ".concat(i.header.name)),await this.tokenizer.ignore(r)}},e.getPayloadLength(0)),this.tracks.set(t.header.trackId,t)}parseTrackFragmentBox(e){let t;return e.readAtoms(this.tokenizer,async(i,n)=>{const r=i.getPayloadLength(n);switch(i.header.name){case"tfhd":{const s=new Go(i.getPayloadLength(n));t=await this.tokenizer.readToken(s);break}case"tfdt":await this.tokenizer.ignore(r);break;case"trun":{const s=new Wo(r),o=await this.tokenizer.readToken(s);if(t){const c=this.tracks.get(t.trackId);c==null||c.fragments.push({header:t,trackRun:o})}break}default:j("Unexpected box: ".concat(i.header.name)),await this.tokenizer.ignore(r)}},e.getPayloadLength(0))}parseSoundSampleDescription(e){const t={dataFormat:e.dataFormat,dataReferenceIndex:e.dataReferenceIndex};let i=0;if(e.description){const n=hi.get(e.description,i);i+=hi.len,n.version===0||n.version===1?t.description=Oo.get(e.description,i):j("Warning: sound-sample-description ".concat(n," not implemented"))}return t}async parseChapterTrack(e,t,i){if(!e.sampleSize&&e.chunkOffsetTable.length!==e.sampleSizeTable.length)throw new Error("Expected equal chunk-offset-table & sample-size-table length.");const n=[];for(let r=0;r<e.chunkOffsetTable.length&&i>0;++r){const s=e.timeToSampleTable.slice(0,r).reduce((p,y)=>p+y.duration,0),c=e.chunkOffsetTable[r]-this.tokenizer.position,l=e.sampleSize>0?e.sampleSize:e.sampleSizeTable[r];if(i-=c+l,i<0)throw new Be("Chapter chunk exceeding token length");await this.tokenizer.ignore(c);const d=await this.tokenizer.readToken(new jo(l));j("Chapter ".concat(r+1,": ").concat(d));const m={title:d,timeScale:e.media.header?e.media.header.timeScale:0,start:s,sampleOffset:this.findSampleOffset(t,this.tokenizer.position)};j("Chapter title=".concat(m.title,", offset=").concat(m.sampleOffset,"/").concat(t.header.duration)),n.push(m)}this.metadata.setFormat("chapters",n),await this.tokenizer.ignore(i)}findSampleOffset(e,t){let i=0;for(;i<e.chunkOffsetTable.length&&e.chunkOffsetTable[i]<t;)++i;return this.getChunkDuration(i+1,e)}getChunkDuration(e,t){let i=0,n=t.timeToSampleTable[i].count,r=t.timeToSampleTable[i].duration,s=1,o=this.getSamplesPerChunk(s,t.sampleToChunkTable),c=0;for(;s<e;){const l=Math.min(n,o);c+=l*r,n-=l,o-=l,o===0?(++s,o=this.getSamplesPerChunk(s,t.sampleToChunkTable)):(++i,n=t.timeToSampleTable[i].count,r=t.timeToSampleTable[i].duration)}return c}getSamplesPerChunk(e,t){for(let i=0;i<t.length-1;++i)if(e>=t[i].firstChunk&&e<t[i+1].firstChunk)return t[i].samplesPerChunk;return t[t.length-1].samplesPerChunk}}const qo=Object.freeze(Object.defineProperty({__proto__:null,MP4Parser:yt},Symbol.toStringTag,{value:"Module"})),ki=C("music-metadata:parser:musepack:sv8"),Zo=new k(2,"latin1"),wi={len:5,get:(a,e)=>({crc:f.get(a,e),streamVersion:T.get(a,e+4)})},Ti={len:2,get:(a,e)=>({sampleFrequency:[44100,48e3,37800,32e3][S(a,e,0,3)],maxUsedBands:S(a,e,3,5),channelCount:S(a,e+1,0,4)+1,msUsed:q(a,e+1,4),audioBlockFrames:S(a,e+1,5,3)})};class Yo{get tokenizer(){return this._tokenizer}set tokenizer(e){this._tokenizer=e}constructor(e){this._tokenizer=e}async readPacketHeader(){const e=await this.tokenizer.readToken(Zo),t=await this.readVariableSizeField();return{key:e,payloadLength:t.value-2-t.len}}async readStreamHeader(e){const t={};ki("Reading SH at offset=".concat(this.tokenizer.position));const i=await this.tokenizer.readToken(wi);e-=wi.len,Object.assign(t,i),ki("SH.streamVersion = ".concat(i.streamVersion));const n=await this.readVariableSizeField();
5e-=n.len,t.sampleCount=n.value;const r=await this.readVariableSizeField();e-=r.len,t.beginningOfSilence=r.value;const s=await this.tokenizer.readToken(Ti);return e-=Ti.len,Object.assign(t,s),await this.tokenizer.ignore(e),t}async readVariableSizeField(e=1,t=0){let i=await this.tokenizer.readNumber(T);return(i&128)===0?{len:e,value:t+i}:(i&=127,i+=t,this.readVariableSizeField(e+1,i<<7))}}class St extends O("Musepack"){}const Ko=C("music-metadata:parser:musepack");class Jo extends J{constructor(){super(...arguments),this.audioLength=0}async parse(){if(await this.tokenizer.readToken(F)!=="MPCK")throw new St("Invalid Magic number");return this.metadata.setFormat("container","Musepack, SV8"),this.parsePacket()}async parsePacket(){const e=new Yo(this.tokenizer);do{const t=await e.readPacketHeader();switch(Ko("packet-header key=".concat(t.key,", payloadLength=").concat(t.payloadLength)),t.key){case"SH":{const i=await e.readStreamHeader(t.payloadLength);this.metadata.setFormat("numberOfSamples",i.sampleCount),this.metadata.setFormat("sampleRate",i.sampleFrequency),this.metadata.setFormat("duration",i.sampleCount/i.sampleFrequency),this.metadata.setFormat("numberOfChannels",i.channelCount);break}case"AP":this.audioLength+=t.payloadLength,await this.tokenizer.ignore(t.payloadLength);break;case"RG":case"EI":case"SO":case"ST":case"CT":await this.tokenizer.ignore(t.payloadLength);break;case"SE":return this.metadata.format.duration&&this.metadata.setFormat("bitrate",this.audioLength*8/this.metadata.format.duration),Ft(this.metadata,this.tokenizer,this.options);default:throw new St("Unexpected header: ".concat(t.key))}}while(!0)}}class Qo{constructor(e){this.pos=0,this.dword=null,this.tokenizer=e}async read(e){for(;this.dword===null;)this.dword=await this.tokenizer.readToken(f);let t=this.dword;return this.pos+=e,this.pos<32?(t>>>=32-this.pos,t&(1<<e)-1):(this.pos-=32,this.pos===0?(this.dword=null,t&(1<<e)-1):(this.dword=await this.tokenizer.readToken(f),this.pos&&(t<<=this.pos,t|=this.dword>>>32-this.pos),t&(1<<e)-1))}async ignore(e){if(this.pos>0){const n=32-this.pos;this.dword=null,e-=n,this.pos=0}const t=e%32,i=(e-t)/32;return await this.tokenizer.ignore(i*4),this.read(t)}}const ec={len:24,get:(a,e)=>{const t={signature:te(a.subarray(e,e+3),"latin1"),streamMinorVersion:S(a,e+3,0,4),streamMajorVersion:S(a,e+3,4,4),frameCount:f.get(a,e+4),maxLevel:w.get(a,e+8),sampleFrequency:[44100,48e3,37800,32e3][S(a,e+10,0,2)],link:S(a,e+10,2,2),profile:S(a,e+10,4,4),maxBand:S(a,e+11,0,6),intensityStereo:q(a,e+11,6),midSideStereo:q(a,e+11,7),titlePeak:w.get(a,e+12),titleGain:w.get(a,e+14),albumPeak:w.get(a,e+16),albumGain:w.get(a,e+18),lastFrameLength:f.get(a,e+20)>>>20&2047,trueGapless:q(a,e+23,0)};return t.lastFrameLength=t.trueGapless?f.get(a,20)>>>20&2047:0,t}},bi=C("music-metadata:parser:musepack");class tc extends J{constructor(){super(...arguments),this.bitreader=null,this.audioLength=0,this.duration=null}async parse(){const e=await this.tokenizer.readToken(ec);if(e.signature!=="MP+")throw new St("Unexpected magic number");bi("stream-version=".concat(e.streamMajorVersion,".").concat(e.streamMinorVersion)),this.metadata.setFormat("container","Musepack, SV7"),this.metadata.setFormat("sampleRate",e.sampleFrequency);const t=1152*(e.frameCount-1)+e.lastFrameLength;this.metadata.setFormat("numberOfSamples",t),this.duration=t/e.sampleFrequency,this.metadata.setFormat("duration",this.duration),this.bitreader=new Qo(this.tokenizer),this.metadata.setFormat("numberOfChannels",e.midSideStereo||e.intensityStereo?2:1);const i=await this.bitreader.read(8);return this.metadata.setFormat("codec",(i/100).toFixed(2)),await this.skipAudioData(e.frameCount),bi("End of audio stream, switching to APEv2, offset=".concat(this.tokenizer.position)),Ft(this.metadata,this.tokenizer,this.options)}async skipAudioData(e){for(;e-- >0;){const i=await this.bitreader.read(20);this.audioLength+=20+i,await this.bitreader.ignore(i)}const t=await this.bitreader.read(11);this.audioLength+=t,this.duration!==null&&this.metadata.setFormat("bitrate",this.audioLength/this.duration)}}const yi=C("music-metadata:parser:musepack");class ac extends Pt{async postId3v2Parse(){const e=await this.tokenizer.peekToken(new k(3,"latin1"));let t;switch(e){case"MP+":{yi("Stream-version 7"),t=new tc(this.metadata,this.tokenizer,this.options);break}case"MPC":{yi("Stream-version 8"),t=new Jo(this.metadata,this.tokenizer,this.options);break}default:throw new St("Invalid signature prefix")}return this.metadata.setAudioOnly(),t.parse()}}const ic=Object.freeze(Object.defineProperty({__proto__:null,MusepackParser:ac},Symbol.toStringTag,{value:"Module"}));class Ki extends O("Opus"){}class nc{constructor(e){if(e<19)throw new Ki("ID-header-page 0 should be at least 19 bytes long");this.len=e}get(e,t){return{magicSignature:new k(8,"ascii").get(e,t+0),version:T.get(e,t+8),channelCount:T.get(e,t+9),preSkip:w.get(e,t+10),inputSampleRate:f.get(e,t+12),outputGain:w.get(e,t+16),channelMapping:T.get(e,t+18)}}}class rc extends Ae{constructor(e,t,i){super(e,t),this.idHeader=null,this.lastPos=-1,this.tokenizer=i,this.durationOnLastPage=!0}parseFirstPage(e,t){if(this.metadata.setFormat("codec","Opus"),this.idHeader=new nc(t.length).get(t,0),this.idHeader.magicSignature!=="OpusHead")throw new Ki("Illegal ogg/Opus magic-signature");this.metadata.setFormat("sampleRate",this.idHeader.inputSampleRate),this.metadata.setFormat("numberOfChannels",this.idHeader.channelCount),this.metadata.setAudioOnly()}async parseFullPage(e){switch(new k(8,"ascii").get(e,0)){case"OpusTags":await this.parseUserCommentList(e,8),this.lastPos=this.tokenizer.position-e.length;break}}calculateDuration(e){if(this.lastPageHeader&&(e||this.lastPageHeader.headerType.lastPage)&&this.metadata.format.sampleRate&&this.lastPageHeader.absoluteGranulePosition>=0){const t=this.lastPageHeader.absoluteGranulePosition-this.idHeader.preSkip;if(this.metadata.setFormat("numberOfSamples",t),this.metadata.setFormat("duration",t/48e3),this.lastPos!==-1&&this.tokenizer.fileInfo.size&&this.metadata.format.duration){const i=this.tokenizer.fileInfo.size-this.lastPos;this.metadata.setFormat("bitrate",8*i/this.metadata.format.duration)}}}}const sc={len:80,get:(a,e)=>({speex:new k(8,"ascii").get(a,e+0),version:Oi(new k(20,"ascii").get(a,e+8)),version_id:D.get(a,e+28),header_size:D.get(a,e+32),rate:D.get(a,e+36),mode:D.get(a,e+40),mode_bitstream_version:D.get(a,e+44),nb_channels:D.get(a,e+48),bitrate:D.get(a,e+52),frame_size:D.get(a,e+56),vbr:D.get(a,e+60),frames_per_packet:D.get(a,e+64),extra_headers:D.get(a,e+68),reserved1:D.get(a,e+72),reserved2:D.get(a,e+76)})},oc=C("music-metadata:parser:ogg:speex");class cc extends Ae{constructor(e,t,i){super(e,t)}parseFirstPage(e,t){oc("First Ogg/Speex page");const i=sc.get(t,0);this.metadata.setFormat("codec","Speex ".concat(i.version)),this.metadata.setFormat("numberOfChannels",i.nb_channels),this.metadata.setFormat("sampleRate",i.rate),i.bitrate!==-1&&this.metadata.setFormat("bitrate",i.bitrate),this.metadata.setAudioOnly()}}const lc={len:42,get:(a,e)=>({id:new k(7,"ascii").get(a,e),vmaj:T.get(a,e+7),vmin:T.get(a,e+8),vrev:T.get(a,e+9),vmbw:v.get(a,e+10),vmbh:v.get(a,e+17),nombr:B.get(a,e+37),nqual:T.get(a,e+40)})},Si=C("music-metadata:parser:ogg:theora");class dc{constructor(e,t,i){this.durationOnLastPage=!1,this.metadata=e}async parsePage(e,t){e.headerType.firstPage&&await this.parseFirstPage(e,t)}calculateDuration(){Si("duration calculation not implemented")}async parseFirstPage(e,t){Si("First Ogg/Theora page"),this.metadata.setFormat("codec","Theora");const i=lc.get(t,0);this.metadata.setFormat("bitrate",i.nombr),this.metadata.setFormat("hasVideo",!0)}flush(){return Promise.resolve()}}const mc={len:27,get:(a,e)=>({capturePattern:new k(4,"latin1").get(a,e),version:T.get(a,e+4),headerType:{continued:I(a,e+5,0),firstPage:I(a,e+5,1),lastPage:I(a,e+5,2)},absoluteGranulePosition:Number($.get(a,e+6)),streamSerialNumber:f.get(a,e+14),pageSequenceNo:f.get(a,e+18),pageChecksum:f.get(a,e+22),page_segments:T.get(a,e+26)})};class Fa{static sum(e,t,i){const n=new DataView(e.buffer,0);let r=0;for(let s=t;s<t+i;++s)r+=n.getUint8(s);return r}constructor(e){this.len=e.page_segments}get(e,t){return{totalPageSize:Fa.sum(e,t,this.len)}}}const Zt=C("music-metadata:parser:ogg:theora");class uc{constructor(e,t,i){this.durationOnLastPage=!1,this.metadata=e,this.options=t,this.tokenizer=i,this.flacParser=new Vi(this.metadata,this.tokenizer,t)}async parsePage(e,t){e.headerType.firstPage&&await this.parseFirstPage(e,t)}calculateDuration(){Zt("duration calculation not implemented")}async parseFirstPage(e,t){if(Zt("First Ogg/FLAC page"),(await F.get(t,9)).toString()!=="fLaC")throw new Error("Invalid FLAC preamble");const n=await ua.get(t,13);await this.parseDataBlock(n,t.subarray(13+ua.len))}async parseDataBlock(e,t){switch(Zt("blockHeader type=".concat(e.type,", length=").concat(e.length)),e.type){case V.STREAMINFO:{const i=ha.get(t,0);return this.flacParser.processsStreamInfo(i)}case V.PADDING:break;case V.APPLICATION:break;case V.SEEKTABLE:break;case V.VORBIS_COMMENT:return this.flacParser.parseComment(t);case V.PICTURE:if(!this.options.skipCovers){const i=new Re(t.length).get(t,0);return this.flacParser.addPictureTag(i)}break;default:this.metadata.addWarning("Unknown block type: ".concat(e.type))}return this.tokenizer.ignore(e.length).then()}flush(){return Promise.resolve()}}class It extends O("Ogg"){}const ne=C("music-metadata:parser:ogg");class hc{constructor(e,t,i){this.pageNumber=0,this.closed=!1,this.metadata=e,this.streamSerial=t,this.options=i}async parsePage(e,t){this.pageNumber=t.pageSequenceNo,ne("serial=%s page#=%s, Ogg.id=%s",t.streamSerialNumber,t.pageSequenceNo,t.capturePattern);const i=await e.readToken(new Fa(t));ne("totalPageSize=%s",i.totalPageSize);const n=await e.readToken(new U(i.totalPageSize));if(ne("firstPage=%s, lastPage=%s, continued=%s",t.headerType.firstPage,t.headerType.lastPage,t.headerType.continued),t.headerType.firstPage){this.metadata.setFormat("container","Ogg");const r=n.subarray(0,7),s=Array.from(r).filter(o=>o>=32&&o<=126).map(o=>String.fromCharCode(o)).join("");
5switch(s){case"vorbis":ne("Set Ogg stream serial ".concat(t.streamSerialNumber,", codec=Vorbis")),this.pageConsumer=new Ae(this.metadata,this.options);break;case"OpusHea":ne("Set page consumer to Ogg/Opus"),this.pageConsumer=new rc(this.metadata,this.options,e);break;case"Speex  ":ne("Set page consumer to Ogg/Speex"),this.pageConsumer=new cc(this.metadata,this.options,e);break;case"fishead":case"theora":ne("Set page consumer to Ogg/Theora"),this.pageConsumer=new dc(this.metadata,this.options,e);break;case"FLAC":ne("Set page consumer to Vorbis"),this.pageConsumer=new uc(this.metadata,this.options,e);break;default:throw new It("Ogg codec not recognized (id=".concat(s))}}if(t.headerType.lastPage&&(this.closed=!0),this.pageConsumer)await this.pageConsumer.parsePage(t,n);else throw new Error("pageConsumer should be initialized")}}class pc extends J{constructor(){super(...arguments),this.streams=new Map}async parse(){var i,n;this.streams=new Map;let e=!1,t;try{do{if(t=await this.tokenizer.readToken(mc),t.capturePattern!=="OggS")throw new It("Invalid Ogg capture pattern");let r=this.streams.get(t.streamSerialNumber);if(r||(r=new hc(this.metadata,t.streamSerialNumber,this.options),this.streams.set(t.streamSerialNumber,r)),await r.parsePage(this.tokenizer,t),r.pageNumber>12&&!(this.options.duration&&[...this.streams.values()].find(s=>{var o;return(o=s.pageConsumer)==null?void 0:o.durationOnLastPage}))){ne("Stop processing Ogg stream");break}}while(![...this.streams.values()].every(r=>r.closed))}catch(r){if(r instanceof E)ne("Reached end-of-stream"),e=!0;else if(r instanceof It)this.metadata.addWarning("Corrupt Ogg content at ".concat(this.tokenizer.position));else throw r}for(const r of this.streams.values())r.closed||(this.metadata.addWarning("End-of-stream reached before reaching last page in Ogg stream serial=".concat(r.streamSerial)),await((i=r.pageConsumer)==null?void 0:i.flush())),(n=r.pageConsumer)==null||n.calculateDuration(e)}}const gc=Object.freeze(Object.defineProperty({__proto__:null,OggContentError:It,OggParser:pc},Symbol.toStringTag,{value:"Module"})),fc=[6e3,8e3,9600,11025,12e3,16e3,22050,24e3,32e3,44100,48e3,64e3,88200,96e3,192e3,-1],lt={len:32,get:(a,e)=>{const t=f.get(a,e+24),i={BlockID:F.get(a,e),blockSize:f.get(a,e+4),version:w.get(a,e+8),totalSamples:f.get(a,e+12),blockIndex:f.get(a,e+16),blockSamples:f.get(a,e+20),flags:{bitsPerSample:(1+vt(t,0,2))*8,isMono:re(t,2),isHybrid:re(t,3),isJointStereo:re(t,4),crossChannel:re(t,5),hybridNoiseShaping:re(t,6),floatingPoint:re(t,7),samplingRate:fc[vt(t,23,4)],isDSD:re(t,31)},crc:new U(4).get(a,e+28)};return i.flags.isDSD&&(i.totalSamples*=8),i}},Yt={len:1,get:(a,e)=>({functionId:vt(a[e],0,6),isOptional:re(a[e],5),isOddSize:re(a[e],6),largeBlock:re(a[e],7)})};function re(a,e){return vt(a,e,1)===1}function vt(a,e,t){return a>>>e&4294967295>>>32-t}const ye=C("music-metadata:parser:WavPack");class ut extends O("WavPack"){}class xc extends J{constructor(){super(...arguments),this.audioDataSize=0}async parse(){return this.metadata.setAudioOnly(),this.audioDataSize=0,await this.parseWavPackBlocks(),Ft(this.metadata,this.tokenizer,this.options)}async parseWavPackBlocks(){do{if(await this.tokenizer.peekToken(F)!=="wvpk")break;const t=await this.tokenizer.readToken(lt);if(t.BlockID!=="wvpk")throw new ut("Invalid WavPack Block-ID");ye("WavPack header blockIndex=".concat(t.blockIndex,", len=").concat(lt.len)),t.blockIndex===0&&!this.metadata.format.container&&(this.metadata.setFormat("container","WavPack"),this.metadata.setFormat("lossless",!t.flags.isHybrid),this.metadata.setFormat("bitsPerSample",t.flags.bitsPerSample),t.flags.isDSD||(this.metadata.setFormat("sampleRate",t.flags.samplingRate),this.metadata.setFormat("duration",t.totalSamples/t.flags.samplingRate)),this.metadata.setFormat("numberOfChannels",t.flags.isMono?1:2),this.metadata.setFormat("numberOfSamples",t.totalSamples),this.metadata.setFormat("codec",t.flags.isDSD?"DSD":"PCM"));const i=t.blockSize-(lt.len-8);await(t.blockIndex===0?this.parseMetadataSubBlock(t,i):this.tokenizer.ignore(i)),t.blockSamples>0&&(this.audioDataSize+=t.blockSize)}while(!this.tokenizer.fileInfo.size||this.tokenizer.fileInfo.size-this.tokenizer.position>=lt.len);this.metadata.format.duration&&this.metadata.setFormat("bitrate",this.audioDataSize*8/this.metadata.format.duration)}async parseMetadataSubBlock(e,t){let i=t;for(;i>Yt.len;){const n=await this.tokenizer.readToken(Yt),r=await this.tokenizer.readNumber(n.largeBlock?ht:T),s=new Uint8Array(r*2-(n.isOddSize?1:0));switch(await this.tokenizer.readBuffer(s),ye("Metadata Sub-Blocks functionId=0x".concat(n.functionId.toString(16),", id.largeBlock=").concat(n.largeBlock,",data-size=").concat(s.length)),n.functionId){case 0:break;case 14:{ye("ID_DSD_BLOCK");const o=1<<T.get(s,0),c=e.flags.samplingRate*o*8;
5if(!e.flags.isDSD)throw new ut("Only expect DSD block if DSD-flag is set");this.metadata.setFormat("sampleRate",c),this.metadata.setFormat("duration",e.totalSamples/c);break}case 36:ye("ID_ALT_TRAILER: trailer for non-wav files");break;case 38:this.metadata.setFormat("audioMD5",s);break;case 47:ye("ID_BLOCK_CHECKSUM: checksum=".concat(zi(s)));break;default:ye("Ignore unsupported meta-sub-block-id functionId=0x".concat(n.functionId.toString(16)));break}i-=Yt.len+(n.largeBlock?ht.len:T.len)+r*2,ye("remainingLength=".concat(i)),n.isOddSize&&this.tokenizer.ignore(1)}if(i!==0)throw new ut("metadata-sub-block should fit it remaining length")}}const kc=Object.freeze(Object.defineProperty({__proto__:null,WavPackContentError:ut,WavPackParser:xc},Symbol.toStringTag,{value:"Module"})),$e={len:8,get:(a,e)=>({chunkID:new k(4,"latin1").get(a,e),chunkSize:f.get(a,e+4)})};class wc{constructor(e){this.tagHeader=e,this.len=e.chunkSize,this.len+=this.len&1}get(e,t){return new k(this.tagHeader.chunkSize,"ascii").get(e,t)}}class Ct extends O("Wave"){}const W={PCM:1,ADPCM:2,IEEE_FLOAT:3,MPEG_ADTS_AAC:5632,MPEG_LOAS:5634,RAW_AAC1:255,DOLBY_AC3_SPDIF:146,DVM:8192,RAW_SPORT:576,ESST_AC3:577,DRM:9,DTS2:8193,MPEG:80},Tc={[W.PCM]:"PCM",[W.ADPCM]:"ADPCM",[W.IEEE_FLOAT]:"IEEE_FLOAT",[W.MPEG_ADTS_AAC]:"MPEG_ADTS_AAC",[W.MPEG_LOAS]:"MPEG_LOAS",[W.RAW_AAC1]:"RAW_AAC1",[W.DOLBY_AC3_SPDIF]:"DOLBY_AC3_SPDIF",[W.DVM]:"DVM",[W.RAW_SPORT]:"RAW_SPORT",[W.ESST_AC3]:"ESST_AC3",[W.DRM]:"DRM",[W.DTS2]:"DTS2",[W.MPEG]:"MPEG"};class bc{constructor(e){if(e.chunkSize<16)throw new Ct("Invalid chunk size");this.len=e.chunkSize}get(e,t){return{wFormatTag:w.get(e,t),nChannels:w.get(e,t+2),nSamplesPerSec:f.get(e,t+4),nAvgBytesPerSec:f.get(e,t+8),nBlockAlign:w.get(e,t+12),wBitsPerSample:w.get(e,t+14)}}}class yc{constructor(e){if(e.chunkSize<4)throw new Ct("Invalid fact chunk size.");this.len=e.chunkSize}get(e,t){return{dwSampleLength:f.get(e,t)}}}const Ii={len:420,get:(a,e)=>({description:ge(new k(256,"ascii").get(a,e)).trim(),originator:ge(new k(32,"ascii").get(a,e+256)).trim(),originatorReference:ge(new k(32,"ascii").get(a,e+288)).trim(),originationDate:ge(new k(10,"ascii").get(a,e+320)).trim(),originationTime:ge(new k(8,"ascii").get(a,e+330)).trim(),timeReferenceLow:f.get(a,e+338),timeReferenceHigh:f.get(a,e+342),version:w.get(a,e+346),umid:new U(64).get(a,e+348),loudnessValue:w.get(a,e+412),maxTruePeakLevel:w.get(a,e+414),maxMomentaryLoudness:w.get(a,e+416),maxShortTermLoudness:w.get(a,e+418)})},ue=C("music-metadata:parser:RIFF");class Sc extends J{constructor(){super(...arguments),this.blockAlign=0}
5async parse(){const e=await this.tokenizer.readToken($e);if(ue("pos=".concat(this.tokenizer.position,", parse: chunkID=").concat(e.chunkID)),e.chunkID==="RIFF")return this.metadata.setAudioOnly(),this.parseRiffChunk(e.chunkSize).catch(t=>{if(!(t instanceof E))throw t})}async parseRiffChunk(e){const t=await this.tokenizer.readToken(F);switch(this.metadata.setFormat("container",t),t){case"WAVE":return this.readWaveChunk(e-F.len);default:throw new Ct("Unsupported RIFF format: RIFF/".concat(t))}}async readWaveChunk(e){for(;e>=$e.len;){const t=await this.tokenizer.readToken($e);switch(e-=$e.len+t.chunkSize,t.chunkSize>e&&this.metadata.addWarning("Data chunk size exceeds file size"),this.header=t,ue("pos=".concat(this.tokenizer.position,", readChunk: chunkID=RIFF/WAVE/").concat(t.chunkID)),t.chunkID){case"LIST":await this.parseListTag(t);break;case"fact":this.metadata.setFormat("lossless",!1),this.fact=await this.tokenizer.readToken(new yc(t));break;case"fmt ":{const i=await this.tokenizer.readToken(new bc(t));let n=Tc[i.wFormatTag];n||(ue("WAVE/non-PCM format=".concat(i.wFormatTag)),n="non-PCM (".concat(i.wFormatTag,")")),this.metadata.setFormat("codec",n),this.metadata.setFormat("bitsPerSample",i.wBitsPerSample),this.metadata.setFormat("sampleRate",i.nSamplesPerSec),this.metadata.setFormat("numberOfChannels",i.nChannels),this.metadata.setFormat("bitrate",i.nBlockAlign*i.nSamplesPerSec*8),this.blockAlign=i.nBlockAlign;break}case"id3 ":case"ID3 ":{const i=await this.tokenizer.readToken(new U(t.chunkSize)),n=Ce(i);await new oe().parse(this.metadata,n,this.options);break}case"data":{this.metadata.format.lossless!==!1&&this.metadata.setFormat("lossless",!0);let i=t.chunkSize;if(this.tokenizer.fileInfo.size){const r=this.tokenizer.fileInfo.size-this.tokenizer.position;r<i&&(this.metadata.addWarning("data chunk length exceeding file length"),i=r)}const n=this.fact?this.fact.dwSampleLength:i===4294967295?void 0:i/this.blockAlign;n&&(this.metadata.setFormat("numberOfSamples",n),this.metadata.format.sampleRate&&this.metadata.setFormat("duration",n/this.metadata.format.sampleRate)),this.metadata.format.codec==="ADPCM"?this.metadata.setFormat("bitrate",352e3):this.metadata.format.sampleRate&&this.metadata.setFormat("bitrate",this.blockAlign*this.metadata.format.sampleRate*8),await this.tokenizer.ignore(t.chunkSize);break}case"bext":{const i=await this.tokenizer.readToken(Ii);
5Object.keys(i).forEach(r=>{this.metadata.addTag("exif","bext.".concat(r),i[r])});const n=t.chunkSize-Ii.len;await this.tokenizer.ignore(n);break}case"\0\0\0\0":ue("Ignore padding chunk: RIFF/".concat(t.chunkID," of ").concat(t.chunkSize," bytes")),this.metadata.addWarning("Ignore chunk: RIFF/".concat(t.chunkID)),await this.tokenizer.ignore(t.chunkSize);break;default:ue("Ignore chunk: RIFF/".concat(t.chunkID," of ").concat(t.chunkSize," bytes")),this.metadata.addWarning("Ignore chunk: RIFF/".concat(t.chunkID)),await this.tokenizer.ignore(t.chunkSize)}this.header.chunkSize%2===1&&(ue("Read odd padding byte"),await this.tokenizer.ignore(1))}}async parseListTag(e){const t=await this.tokenizer.readToken(new k(4,"latin1"));switch(ue("pos=%s, parseListTag: chunkID=RIFF/WAVE/LIST/%s",this.tokenizer.position,t),t){case"INFO":return this.parseRiffInfoTags(e.chunkSize-4);default:return this.metadata.addWarning("Ignore chunk: RIFF/WAVE/LIST/".concat(t)),ue("Ignoring chunkID=RIFF/WAVE/LIST/".concat(t)),this.tokenizer.ignore(e.chunkSize-4).then()}}async parseRiffInfoTags(e){for(;e>=8;){const t=await this.tokenizer.readToken($e),i=new wc(t),n=await this.tokenizer.readToken(i);this.addTag(t.chunkID,ge(n)),e-=8+i.len}if(e!==0)throw new Ct("Illegal remaining size: ".concat(e))}addTag(e,t){this.metadata.addTag("exif",e,t)}}const Ic=Object.freeze(Object.defineProperty({__proto__:null,WaveParser:Sc},Symbol.toStringTag,{value:"Module"}));export{Or as CouldNotDetermineFileTypeError,wa as FieldDecodingError,Bi as InternalParserError,Ri as LyricsContentType,Li as TimestampFormat,Rr as UnsupportedFileTypeError,$c as getSupportedMimeTypes,Ve as makeParseError,O as makeUnexpectedFileContentError,Bc as orderTags,zc as parseBlob,Mc as parseBuffer,Lc as parseFile,Ia as parseFromTokenizer,Nc as parseStream,_c as parseWebStream,Oc as ratingToStars,Rs as scanAppendingHeaders,Rc as selectCover};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.