/*! * artplayer-proxy-mediabunny.js v1.0.0 * Github: https://github.com/zhw2590582/ArtPlayer * (c) 2017-2025 Harvey Zack * Released under the MIT License. */ !function(e,r,n,a,i,s,o,c){var u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},l="function"==typeof u[a]&&u[a],d=l.i||{},f=l.cache||{},h="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function m(r,n){if(!f[r]){if(!e[r]){if(i[r])return i[r];var s="function"==typeof u[a]&&u[a];if(!n&&s)return s(r,!0);if(l)return l(r,!0);if(h&&"string"==typeof r)return h(r);var o=Error("Cannot find module '"+r+"'");throw o.code="MODULE_NOT_FOUND",o}d.resolve=function(n){var a=e[r][1][n];return null!=a?a:n},d.cache={};var c=f[r]=new m.Module(r);e[r][0].call(c.exports,d,c,c.exports,u)}return f[r].exports;function d(e){var r=d.resolve(e);if(!1===r)return{};if(Array.isArray(r)){var n={__esModule:!0};return r.forEach(function(e){var r=e[0],a=e[1],i=e[2]||e[0],s=m(a);"*"===r?Object.keys(s).forEach(function(e){"default"===e||"__esModule"===e||Object.prototype.hasOwnProperty.call(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:function(){return s[e]}})}):"*"===i?Object.defineProperty(n,r,{enumerable:!0,value:s}):Object.defineProperty(n,r,{enumerable:!0,get:function(){return"default"===i?s.__esModule?s.default:s:s[i]}})}),n}return m(r)}}m.isParcelRequire=!0,m.Module=function(e){this.id=e,this.bundle=m,this.require=h,this.exports={}},m.modules=e,m.cache=f,m.parent=l,m.distDir=void 0,m.publicUrl=void 0,m.devServer=void 0,m.i=d,m.register=function(r,n){e[r]=[function(e,r){r.exports=n},{}]},Object.defineProperty(m,"root",{get:function(){return u[a]}}),u[a]=m;for(var p=0;p0&&void 0!==arguments[0]?arguments[0]:{};return function(r){return(0,o.default)(r,e)}}"undefined"!=typeof window&&(window.artplayerProxyMediabunny=c)},{"./proxy/canvasProxy.js":"hTxiw","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],hTxiw:[function(e,r,n,a){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(n),i.export(n,"default",function(){return u});var s=e("@swc/helpers/cjs/_to_consumable_array.cjs"),o=e("../shim/mediabunnyVideoShim.js"),c=i.interopDefault(o);function u(e,r){var n,a=function(e){e in o||Object.defineProperty(o,e,{get:function(){var r=l[e];return"function"==typeof r?r.bind(l):r},set:function(r){l[e]=r},configurable:!0,enumerable:!0})},i=function(e){o[e]=function(){for(var r=arguments.length,a=Array(r),i=0;ie.length)&&(r=e.length);for(var n=0,a=Array(r);n0?new Promise(function(e,r){a=setTimeout(function(){return r(Error("Load timeout"))},n)}):null,c=(0,s._)(function(){var n,i,s,c;return(0,o._)(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,3,4]),n=!1,i=!1,s=function(){n&&i&&(w=1,m.emit("loadedmetadata"),m.emit("durationchange"))},[4,Promise.all([k.load(e,function(){r===I&&(n=!0,s())}),b.load(e,function(){r===I&&(i=!0,s())})])];case 1:if(o.sent(),r!==I)return[2];return w=4,S=1,m.emit("loadeddata"),m.emit("canplay"),m.emit("canplaythrough"),[3,4];case 2:if(c=o.sent(),r!==I)return[2];return T={code:4,message:c.message},S=3,m.emit("error"),console.error(c),[3,4];case 3:return a&&clearTimeout(a),[7];case 4:return[2]}})})(),!i)return[3,5];l.label=1;case 1:return l.trys.push([1,3,,4]),[4,Promise.race([c,i])];case 2:return l.sent(),[3,4];case 3:if(u=l.sent(),r!==I)return[2];return I++,T={code:4,message:u.message},S=3,m.emit("error"),[3,4];case 4:return[3,7];case 5:return[4,c];case 6:l.sent(),l.label=7;case 7:return[2]}})})()},play:E,pause:j,seek:function(e){return(0,s._)(function(){var r;return(0,o._)(this,function(n){switch(n.label){case 0:return r=!_,y=!1,x=!0,m.emit("seeking"),m.emit("waiting"),j(),[4,b.seek(e)];case 1:return n.sent(),[4,k.seek(e)];case 2:if(n.sent(),x=!1,m.emit("seeked"),!(r&&!y))return[3,4];return[4,E()];case 3:n.sent(),n.label=4;case 4:return[2]}})})()},destroy:function(){j(),b.destroy(),k.destroy()},setVolume:b.setVolume,setPlaybackRate:function(e){b.setPlaybackRate(e),k.setPlaybackRate(e)},get currentTime(){return b.currentTime},get duration(){return b.duration||k.duration},get paused(){return _},get seeking(){return x},get ended(){return y},get readyState(){return w},get networkState(){return S},get error(){return T},get videoWidth(){return k.width},get videoHeight(){return k.height}}}},{"@swc/helpers/cjs/_async_to_generator.cjs":"cZn0e","@swc/helpers/cjs/_ts_generator.cjs":"eltGh","./audioEngine.js":"avNjw","./videoEngine.js":"iWP57","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],cZn0e:[function(e,r,n,a){"use strict";function i(e,r,n,a,i,s,o){try{var c=e[s](o),u=c.value}catch(e){n(e);return}c.done?r(u):Promise.resolve(u).then(a,i)}n._=function(e){return function(){var r=this,n=arguments;return new Promise(function(a,s){var o=e.apply(r,n);function c(e){i(o,a,s,c,u,"next",e)}function u(e){i(o,a,s,c,u,"throw",e)}c(void 0)})}}},{}],eltGh:[function(e,r,n,a){"use strict";n._=e("eb260df52bffddd").__generator},{eb260df52bffddd:"6yrAu"}],"6yrAu":[function(e,r,n,a){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(n),i.export(n,"__extends",function(){return c}),i.export(n,"__assign",function(){return u}),i.export(n,"__rest",function(){return l}),i.export(n,"__decorate",function(){return d}),i.export(n,"__param",function(){return f}),i.export(n,"__esDecorate",function(){return h}),i.export(n,"__runInitializers",function(){return m}),i.export(n,"__propKey",function(){return p}),i.export(n,"__setFunctionName",function(){return g}),i.export(n,"__metadata",function(){return b}),i.export(n,"__awaiter",function(){return k}),i.export(n,"__generator",function(){return _}),i.export(n,"__createBinding",function(){return y}),i.export(n,"__exportStar",function(){return w}),i.export(n,"__values",function(){return S}),i.export(n,"__read",function(){return T}),i.export(n,"__spread",function(){return x}),i.export(n,"__spreadArrays",function(){return I}),i.export(n,"__spreadArray",function(){return E}),i.export(n,"__await",function(){return j}),i.export(n,"__asyncGenerator",function(){return P}),i.export(n,"__asyncDelegator",function(){return C}),i.export(n,"__asyncValues",function(){return A}),i.export(n,"__makeTemplateObject",function(){return B}),i.export(n,"__importStar",function(){return F}),i.export(n,"__importDefault",function(){return R}),i.export(n,"__classPrivateFieldGet",function(){return U}),i.export(n,"__classPrivateFieldSet",function(){return O}),i.export(n,"__classPrivateFieldIn",function(){return L}),i.export(n,"__addDisposableResource",function(){return N}),i.export(n,"__disposeResources",function(){return V}),i.export(n,"__rewriteRelativeImportExtension",function(){return H});var s=e("@swc/helpers/cjs/_type_of.cjs"),o=function(e,r){return(o=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])})(e,r)};function c(e,r){if("function"!=typeof r&&null!==r)throw TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}o(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var u=function(){return(u=Object.assign||function(e){for(var r,n=1,a=arguments.length;nr.indexOf(a)&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,a=Object.getOwnPropertySymbols(e);ir.indexOf(a[i])&&Object.prototype.propertyIsEnumerable.call(e,a[i])&&(n[a[i]]=e[a[i]]);return n}function d(e,r,n,a){var i,o=arguments.length,c=o<3?r:null===a?a=Object.getOwnPropertyDescriptor(r,n):a;if(("undefined"==typeof Reflect?"undefined":(0,s._)(Reflect))==="object"&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,r,n,a);else for(var u=e.length-1;u>=0;u--)(i=e[u])&&(c=(o<3?i(c):o>3?i(r,n,c):i(r,n))||c);return o>3&&c&&Object.defineProperty(r,n,c),c}function f(e,r){return function(n,a){r(n,a,e)}}function h(e,r,n,a,i,o){function c(e){if(void 0!==e&&"function"!=typeof e)throw TypeError("Function expected");return e}for(var u,l=a.kind,d="getter"===l?"get":"setter"===l?"set":"value",f=!r&&e?a.static?e:e.prototype:null,h=r||(f?Object.getOwnPropertyDescriptor(f,a.name):{}),m=!1,p=n.length-1;p>=0;p--){var g={};for(var b in a)g[b]="access"===b?{}:a[b];for(var b in a.access)g.access[b]=a.access[b];g.addInitializer=function(e){if(m)throw TypeError("Cannot add initializers after decoration has completed");o.push(c(e||null))};var k=(0,n[p])("accessor"===l?{get:h.get,set:h.set}:h[d],g);if("accessor"===l){if(void 0===k)continue;if(null===k||(void 0===k?"undefined":(0,s._)(k))!=="object")throw TypeError("Object expected");(u=c(k.get))&&(h.get=u),(u=c(k.set))&&(h.set=u),(u=c(k.init))&&i.unshift(u)}else(u=c(k))&&("field"===l?i.unshift(u):h[d]=u)}f&&Object.defineProperty(f,a.name,h),m=!0}function m(e,r,n){for(var a=arguments.length>2,i=0;i0&&i[i.length-1])&&(6===l[0]||2===l[0])){s=0;continue}if(3===l[0]&&(!i||l[1]>i[0]&&l[1]=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function T(e,r){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var a,i,s=n.call(e),o=[];try{for(;(void 0===r||r-- >0)&&!(a=s.next()).done;)o.push(a.value)}catch(e){i={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return o}function x(){for(var e=[],r=0;r1||c(e,r)})},r&&(a[e]=r(a[e])))}function c(e,r){try{var n;(n=i[e](r)).value instanceof j?Promise.resolve(n.value.v).then(u,l):d(s[0][2],n)}catch(e){d(s[0][3],e)}}function u(e){c("next",e)}function l(e){c("throw",e)}function d(e,r){e(r),s.shift(),s.length&&c(s[0][0],s[0][1])}}function C(e){var r,n;return r={},a("next"),a("throw",function(e){throw e}),a("return"),r[Symbol.iterator]=function(){return this},r;function a(a,i){r[a]=e[a]?function(r){return(n=!n)?{value:j(e[a](r)),done:!1}:i?i(r):r}:i}}function A(e){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var r,n=e[Symbol.asyncIterator];return n?n.call(e):(e=S(e),r={},a("next"),a("throw"),a("return"),r[Symbol.asyncIterator]=function(){return this},r);function a(n){r[n]=e[n]&&function(r){return new Promise(function(a,i){var s,o,c;s=a,o=i,c=(r=e[n](r)).done,Promise.resolve(r.value).then(function(e){s({value:e,done:c})},o)})}}}function B(e,r){return Object.defineProperty?Object.defineProperty(e,"raw",{value:r}):e.raw=r,e}var M=Object.create?function(e,r){Object.defineProperty(e,"default",{enumerable:!0,value:r})}:function(e,r){e.default=r},D=function(e){return(D=Object.getOwnPropertyNames||function(e){var r=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[r.length]=n);return r})(e)};function F(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var n=D(e),a=0;a=m-.2&&(a.suspend(),e.emit("waiting"))},50),o=void 0,c.label=1;case 1:return c.trys.push([1,3,4,5]),[4,n];case 2:return o=c.sent(),[3,5];case 3:return console.error(c.sent()),[2,"break"];case 4:return clearInterval(s),[7];case 5:if(r!==y||g)return[2,{v:void 0}];if("suspended"!==a.state)return[3,7];return[4,a.resume()];case 6:c.sent(),e.emit("canplay"),e.emit("playing"),c.label=7;case 7:if(o.done)return[2,"break"];return l=(u=o.value).buffer,p=u.timestamp,(b=a.createBufferSource()).buffer=l,b.connect(i),b.playbackRate.value=_,(S=(k=f+(p-h)/_)+l.duration/_)>m&&(m=S),k>=a.currentTime?b.start(k):b.start(a.currentTime,(a.currentTime-k)*_),w.add(b),b.onended=function(){return w.delete(b)},[2]}})},!n)return[2];return[4,E()];case 1:p.sent(),d=n.buffers(S()),p.label=2;case 2:return[5,(0,u._)(s())];case 3:if(l=p.sent(),"object"===(0,o._)(l))return[2,l.v];if("break"===l)return[3,4];return[3,2];case 4:return[2]}})})()}function P(){g||(h=S(),g=!0,E(),I())}return{load:function(e,a){return(0,s._)(function(){var i,s,o,u;return(0,c._)(this,function(c){switch(c.label){case 0:return i=++y,[4,E()];case 1:if(c.sent(),I(),g=!0,h=0,f=0,!(s="string"==typeof e?new(0,l.UrlSource)(e):e instanceof Blob?new(0,l.BlobSource)(e):"undefined"!=typeof ReadableStream&&e instanceof ReadableStream?new(0,l.ReadableStreamSource)(e):e))return[2];return[4,(r=new(0,l.Input)({source:s,formats:l.ALL_FORMATS})).computeDuration()];case 2:if(p=c.sent(),i!==y)return[2];return[4,r.getPrimaryAudioTrack()];case 3:if(!(o=c.sent()))return n=null,x(),a&&a(),[2];if(u=null===o.codec)return[3,5];return[4,o.canDecode()];case 4:u=!c.sent(),c.label=5;case 5:if(u)return n=null,x(),a&&a(),[2];return x(o.sampleRate),n=new(0,l.AudioBufferSink)(o),a&&a(),[2]}})})()},play:function(){return(0,s._)(function(){return(0,c._)(this,function(e){switch(e.label){case 0:if(!g)return[2];if(a||x(),"suspended"!==a.state)return[3,2];return[4,a.resume()];case 1:e.sent(),e.label=2;case 2:return m=f=a.currentTime,g=!1,j(++y),[2]}})})()},pause:P,seek:function(e){return(0,s._)(function(){return(0,c._)(this,function(r){return h=Math.max(0,e),m=f=a.currentTime,y++,g||j(y),[2]})})()},destroy:function(){y++,P(),null==a||a.close(),a=null,r=null,n=null},setVolume:function(e,r){b=e,k=r,T()},setPlaybackRate:function(e){e!==_&&(g||(h=S(),f=a.currentTime),_=e,g||j(++y))},get currentTime(){return S()},get duration(){return p},get paused(){return g}}}},{"@swc/helpers/cjs/_async_to_generator.cjs":"cZn0e","@swc/helpers/cjs/_type_of.cjs":"iXhRw","@swc/helpers/cjs/_ts_generator.cjs":"eltGh","@swc/helpers/cjs/_ts_values.cjs":"94P5Q",mediabunny:[["ALL_FORMATS","1jhAI"],["AudioBufferSink","k0V9R"],["BlobSource","7vKle"],["ReadableStreamSource","7vKle"],["UrlSource","7vKle"],["Input","3sapy"]],"@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],"94P5Q":[function(e,r,n,a){"use strict";n._=e("2ed00358a4809745").__values},{"2ed00358a4809745":"6yrAu"}],"1jhAI":[function(e,r,n,a){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(n),i.export(n,"InputFormat",function(){return I}),i.export(n,"IsobmffInputFormat",function(){return E}),i.export(n,"Mp4InputFormat",function(){return j}),i.export(n,"QuickTimeInputFormat",function(){return P}),i.export(n,"MatroskaInputFormat",function(){return C}),i.export(n,"WebMInputFormat",function(){return A}),i.export(n,"Mp3InputFormat",function(){return B}),i.export(n,"WaveInputFormat",function(){return M}),i.export(n,"OggInputFormat",function(){return D}),i.export(n,"FlacInputFormat",function(){return F}),i.export(n,"AdtsInputFormat",function(){return R}),i.export(n,"MP4",function(){return U}),i.export(n,"QTFF",function(){return O}),i.export(n,"MATROSKA",function(){return L}),i.export(n,"WEBM",function(){return N}),i.export(n,"MP3",function(){return z}),i.export(n,"WAVE",function(){return V}),i.export(n,"OGG",function(){return H}),i.export(n,"ADTS",function(){return G}),i.export(n,"FLAC",function(){return q}),i.export(n,"ALL_FORMATS",function(){return W});var s=e("@swc/helpers/cjs/_async_to_generator.cjs"),o=e("@swc/helpers/cjs/_call_super.cjs"),c=e("@swc/helpers/cjs/_class_call_check.cjs"),u=e("@swc/helpers/cjs/_create_class.cjs"),l=e("@swc/helpers/cjs/_inherits.cjs"),d=e("@swc/helpers/cjs/_ts_generator.cjs"),f=e("./isobmff/isobmff-demuxer.js"),h=e("./matroska/ebml.js"),m=e("./matroska/matroska-demuxer.js"),p=e("./mp3/mp3-demuxer.js"),g=e("../shared/mp3-misc.js"),b=e("./id3.js"),k=e("./mp3/mp3-reader.js"),_=e("./ogg/ogg-demuxer.js"),y=e("./wave/wave-demuxer.js"),w=e("./adts/adts-reader.js"),S=e("./adts/adts-demuxer.js"),T=e("./reader.js"),x=e("./flac/flac-demuxer.js"),I=function e(){"use strict";(0,c._)(this,e)},E=function(e){"use strict";function r(){return(0,c._)(this,r),(0,o._)(this,r,arguments)}return(0,l._)(r,e),(0,u._)(r,[{key:"_getMajorBrand",value:function(e){return(0,s._)(function(){var r;return(0,d._)(this,function(n){switch(n.label){case 0:if(!((r=e._reader.requestSlice(0,12))instanceof Promise))return[3,2];return[4,r];case 1:r=n.sent(),n.label=2;case 2:if(!r||(r.skip(4),"ftyp"!==(0,T.readAscii)(r,4)))return[2,null];return[2,(0,T.readAscii)(r,4)]}})})()}},{key:"_createDemuxer",value:function(e){return new(0,f.IsobmffDemuxer)(e)}}]),r}(I),j=function(e){"use strict";function r(){return(0,c._)(this,r),(0,o._)(this,r,arguments)}return(0,l._)(r,e),(0,u._)(r,[{key:"_canReadInput",value:function(e){return(0,s._)(function(){var r;return(0,d._)(this,function(n){switch(n.label){case 0:return[4,this._getMajorBrand(e)];case 1:return[2,!!(r=n.sent())&&"qt "!==r]}})}).call(this)}},{key:"name",get:function(){return"MP4"}},{key:"mimeType",get:function(){return"video/mp4"}}]),r}(E),P=function(e){"use strict";function r(){return(0,c._)(this,r),(0,o._)(this,r,arguments)}return(0,l._)(r,e),(0,u._)(r,[{key:"_canReadInput",value:function(e){return(0,s._)(function(){return(0,d._)(this,function(r){switch(r.label){case 0:return[4,this._getMajorBrand(e)];case 1:return[2,"qt "===r.sent()]}})}).call(this)}},{key:"name",get:function(){return"QuickTime File Format"}},{key:"mimeType",get:function(){return"video/quicktime"}}]),r}(E),C=function(e){"use strict";function r(){return(0,c._)(this,r),(0,o._)(this,r,arguments)}return(0,l._)(r,e),(0,u._)(r,[{key:"isSupportedEBMLOfDocType",value:function(e,r){return(0,s._)(function(){var n,a,i,s,o,c,u,l,f;return(0,d._)(this,function(d){switch(d.label){case 0:if(!((n=e._reader.requestSlice(0,h.MAX_HEADER_SIZE))instanceof Promise))return[3,2];return[4,n];case 1:n=d.sent(),d.label=2;case 2:if(!n||null===(a=(0,h.readVarIntSize)(n))||a<1||a>8||(0,h.readUnsignedInt)(n,a)!==h.EBMLId.EBML||null===(i=(0,h.readElementSize)(n)))return[2,!1];if(!((s=e._reader.requestSlice(n.filePos,i))instanceof Promise))return[3,4];return[4,s];case 3:s=d.sent(),d.label=4;case 4:if(!s)return[2,!1];for(o=n.filePos;s.filePos<=o+i-h.MIN_HEADER_SIZE&&(c=(0,h.readElementHeader)(s));){if(u=c.id,l=c.size,f=s.filePos,null===l)return[2,!1];switch(u){case h.EBMLId.EBMLVersion:case h.EBMLId.EBMLReadVersion:if(1!==(0,h.readUnsignedInt)(s,l))return[2,!1];break;case h.EBMLId.DocType:if((0,h.readAsciiString)(s,l)!==r)return[2,!1];break;case h.EBMLId.DocTypeVersion:if((0,h.readUnsignedInt)(s,l)>4)return[2,!1]}s.filePos=f+l}return[2,!0]}})})()}},{key:"_canReadInput",value:function(e){return this.isSupportedEBMLOfDocType(e,"matroska")}},{key:"_createDemuxer",value:function(e){return new(0,m.MatroskaDemuxer)(e)}},{key:"name",get:function(){return"Matroska"}},{key:"mimeType",get:function(){return"video/x-matroska"}}]),r}(I),A=function(e){"use strict";function r(){return(0,c._)(this,r),(0,o._)(this,r,arguments)}return(0,l._)(r,e),(0,u._)(r,[{key:"_canReadInput",value:function(e){return this.isSupportedEBMLOfDocType(e,"webm")}},{key:"name",get:function(){return"WebM"}},{key:"mimeType",get:function(){return"video/webm"}}]),r}(C),B=function(e){"use strict";function r(){return(0,c._)(this,r),(0,o._)(this,r,arguments)}return(0,l._)(r,e),(0,u._)(r,[{key:"_canReadInput",value:function(e){return(0,s._)(function(){var r,n,a,i,s,o,c,u,l;return(0,d._)(this,function(d){switch(d.label){case 0:if(!((r=e._reader.requestSlice(0,10))instanceof Promise))return[3,2];return[4,r];case 1:r=d.sent(),d.label=2;case 2:if(!r)return[2,!1];n=0,a=!1,d.label=3;case 3:if(!((i=e._reader.requestSlice(n,b.ID3_V2_HEADER_SIZE))instanceof Promise))return[3,5];return[4,i];case 4:i=d.sent(),d.label=5;case 5:if(!i||!(s=(0,b.readId3V2Header)(i)))return[3,6];return a=!0,n=i.filePos+s.size,[3,3];case 6:return[4,(0,k.readNextFrameHeader)(e._reader,n,n+4096)];case 7:if(!(o=d.sent()))return[2,!1];if(a)return[2,!0];return n=o.startPos+o.header.totalSize,[4,(0,k.readNextFrameHeader)(e._reader,n,n+g.FRAME_HEADER_SIZE)];case 8:if(!(c=d.sent())||(u=o.header,l=c.header,u.channel!==l.channel||u.sampleRate!==l.sampleRate))return[2,!1];return[2,!0]}})})()}},{key:"_createDemuxer",value:function(e){return new(0,p.Mp3Demuxer)(e)}},{key:"name",get:function(){return"MP3"}},{key:"mimeType",get:function(){return"audio/mpeg"}}]),r}(I),M=function(e){"use strict";function r(){return(0,c._)(this,r),(0,o._)(this,r,arguments)}return(0,l._)(r,e),(0,u._)(r,[{key:"_canReadInput",value:function(e){return(0,s._)(function(){var r,n;return(0,d._)(this,function(a){switch(a.label){case 0:if(!((r=e._reader.requestSlice(0,12))instanceof Promise))return[3,2];return[4,r];case 1:r=a.sent(),a.label=2;case 2:if(!r||"RIFF"!==(n=(0,T.readAscii)(r,4))&&"RIFX"!==n&&"RF64"!==n)return[2,!1];return r.skip(4),[2,"WAVE"===(0,T.readAscii)(r,4)]}})})()}},{key:"_createDemuxer",value:function(e){return new(0,y.WaveDemuxer)(e)}},{key:"name",get:function(){return"WAVE"}},{key:"mimeType",get:function(){return"audio/wav"}}]),r}(I),D=function(e){"use strict";function r(){return(0,c._)(this,r),(0,o._)(this,r,arguments)}return(0,l._)(r,e),(0,u._)(r,[{key:"_canReadInput",value:function(e){return(0,s._)(function(){var r;return(0,d._)(this,function(n){switch(n.label){case 0:if(!((r=e._reader.requestSlice(0,4))instanceof Promise))return[3,2];return[4,r];case 1:r=n.sent(),n.label=2;case 2:if(!r)return[2,!1];return[2,"OggS"===(0,T.readAscii)(r,4)]}})})()}},{key:"_createDemuxer",value:function(e){return new(0,_.OggDemuxer)(e)}},{key:"name",get:function(){return"Ogg"}},{key:"mimeType",get:function(){return"application/ogg"}}]),r}(I),F=function(e){"use strict";function r(){return(0,c._)(this,r),(0,o._)(this,r,arguments)}return(0,l._)(r,e),(0,u._)(r,[{key:"_canReadInput",value:function(e){return(0,s._)(function(){var r;return(0,d._)(this,function(n){switch(n.label){case 0:if(!((r=e._reader.requestSlice(0,4))instanceof Promise))return[3,2];return[4,r];case 1:r=n.sent(),n.label=2;case 2:if(!r)return[2,!1];return[2,"fLaC"===(0,T.readAscii)(r,4)]}})})()}},{key:"name",get:function(){return"FLAC"}},{key:"mimeType",get:function(){return"audio/flac"}},{key:"_createDemuxer",value:function(e){return new(0,x.FlacDemuxer)(e)}}]),r}(I),R=function(e){"use strict";function r(){return(0,c._)(this,r),(0,o._)(this,r,arguments)}return(0,l._)(r,e),(0,u._)(r,[{key:"_canReadInput",value:function(e){return(0,s._)(function(){var r,n,a;return(0,d._)(this,function(i){switch(i.label){case 0:if(!((r=e._reader.requestSliceRange(0,w.MIN_FRAME_HEADER_SIZE,w.MAX_FRAME_HEADER_SIZE))instanceof Promise))return[3,2];return[4,r];case 1:r=i.sent(),i.label=2;case 2:if(!r||!(n=(0,w.readFrameHeader)(r)))return[2,!1];if(!((r=e._reader.requestSliceRange(n.frameLength,w.MIN_FRAME_HEADER_SIZE,w.MAX_FRAME_HEADER_SIZE))instanceof Promise))return[3,4];return[4,r];case 3:r=i.sent(),i.label=4;case 4:if(!r||!(a=(0,w.readFrameHeader)(r)))return[2,!1];return[2,n.objectType===a.objectType&&n.samplingFrequencyIndex===a.samplingFrequencyIndex&&n.channelConfiguration===a.channelConfiguration]}})})()}},{key:"_createDemuxer",value:function(e){return new(0,S.AdtsDemuxer)(e)}},{key:"name",get:function(){return"ADTS"}},{key:"mimeType",get:function(){return"audio/aac"}}]),r}(I),U=new j,O=new P,L=new C,N=new A,z=new B,V=new M,H=new D,G=new R,q=new F,W=[U,O,L,N,V,H,q,z,G]},{"@swc/helpers/cjs/_async_to_generator.cjs":"cZn0e","@swc/helpers/cjs/_call_super.cjs":"clpdF","@swc/helpers/cjs/_class_call_check.cjs":"4Uf9M","@swc/helpers/cjs/_create_class.cjs":"igUuK","@swc/helpers/cjs/_inherits.cjs":"jtSwf","@swc/helpers/cjs/_ts_generator.cjs":"eltGh","./isobmff/isobmff-demuxer.js":"1Dw1A","./matroska/ebml.js":"fq2QE","./matroska/matroska-demuxer.js":"kY1ME","./mp3/mp3-demuxer.js":"ifShX","../shared/mp3-misc.js":"gcure","./id3.js":"42Y2c","./mp3/mp3-reader.js":"gFWvE","./ogg/ogg-demuxer.js":"hRJRs","./wave/wave-demuxer.js":"cokSU","./adts/adts-reader.js":"5AUBv","./adts/adts-demuxer.js":"3t0bF","./reader.js":"8KRfO","./flac/flac-demuxer.js":"e0w8C","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],clpdF:[function(e,r,n,a){"use strict";var i=e("feddc910f69a01a6"),s=e("b644f6b72647b399"),o=e("ba991daace2b8ed9");n._=function(e,r,n){return r=i._(r),o._(e,s._()?Reflect.construct(r,n||[],i._(e).constructor):r.apply(e,n))}},{feddc910f69a01a6:"NOGHw",b644f6b72647b399:"83nDe",ba991daace2b8ed9:"hd12h"}],NOGHw:[function(e,r,n,a){"use strict";function i(e){return n._=i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},i(e)}n._=i},{}],"83nDe":[function(e,r,n,a){"use strict";function i(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(n._=i=function(){return!!e})()}n._=i},{}],hd12h:[function(e,r,n,a){"use strict";var i=e("f7151fe13994d2aa"),s=e("f18e81760bb14899");n._=function(e,r){return r&&("object"===s._(r)||"function"==typeof r)?r:i._(e)}},{f7151fe13994d2aa:"1tlYe",f18e81760bb14899:"iXhRw"}],"1tlYe":[function(e,r,n,a){"use strict";n._=function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}},{}],"4Uf9M":[function(e,r,n,a){"use strict";n._=function(e,r){if(!(e instanceof r))throw TypeError("Cannot call a class as a function")}},{}],igUuK:[function(e,r,n,a){"use strict";function i(e,r){for(var n=0;n=0&&b<=this.reader.fileSize-S.MAX_BOX_HEADER_SIZE))return[3,15];if(!((k=this.reader.requestSliceRange(b,S.MIN_BOX_HEADER_SIZE,S.MAX_BOX_HEADER_SIZE))instanceof Promise))return[3,12];return[4,k];case 11:k=m.sent(),m.label=12;case 12:if(!k||!((y=(0,S.readBoxHeader)(k))&&"mfra"===y.name))return[3,15];if(!((w=this.reader.requestSlice(k.filePos,y.contentSize))instanceof Promise))return[3,14];return[4,w];case 13:w=m.sent(),m.label=14;case 14:w&&this.readContiguousBoxes(w),m.label=15;case 15:return[2]}})}).call(this)}},{key:"getSampleTableForTrack",value:function(e){if(e.sampleTable)return e.sampleTable;var r={sampleTimingEntries:[],sampleCompositionTimeOffsets:[],sampleSizes:[],keySampleIndices:null,chunkOffsets:[],sampleToChunk:[],presentationTimestamps:null,presentationTimestampIndexMap:null};e.sampleTable=r,(0,_.assert)(this.moovSlice);var n=this.moovSlice.slice(e.sampleTableByteOffset);if(this.currentTrack=e,this.traverseBox(n),this.currentTrack=null,(null==(a=e.info)?void 0:a.type)==="audio"&&e.info.codec&&p.PCM_AUDIO_CODECS.includes(e.info.codec)&&0===r.sampleCompositionTimeOffsets.length){(0,_.assert)((null==(i=e.info)?void 0:i.type)==="audio");for(var a,i,s=(0,p.parsePcmCodec)(e.info.codec),o=[],c=[],u=0;u0){r.presentationTimestamps=[];var E=!0,j=!1,P=void 0;try{for(var C,A=r.sampleTimingEntries[Symbol.iterator]();!(E=(C=A.next()).done);E=!0)for(var B=C.value,M=0;M0){M.languageCode="";for(var O=0;O<3;O++)M.languageCode=String.fromCharCode(96+(31&U))+M.languageCode,U>>=5;(0,_.isIso639Dash2LanguageCode)(M.languageCode)||(M.languageCode=_.UNDETERMINED_LANGUAGE)}break;case"hdlr":var L=this.currentTrack;if(!L)break;e.skip(8);var N=(0,T.readAscii)(e,4);"vide"===N?L.info={type:"video",width:-1,height:-1,codec:null,codecDescription:null,colorSpace:null,avcType:null,avcCodecInfo:null,hevcCodecInfo:null,vp9CodecInfo:null,av1CodecInfo:null}:"soun"===N&&(L.info={type:"audio",numberOfChannels:-1,sampleRate:-1,codec:null,codecDescription:null,aacCodecInfo:null});break;case"stbl":var z=this.currentTrack;if(!z)break;z.sampleTableByteOffset=r,this.readContiguousBoxes(e.slice(a,n.contentSize));break;case"stsd":var V=this.currentTrack;if(!V||null===V.info||V.sampleTable)break;var H=(0,T.readU8)(e);e.skip(3);for(var G=(0,T.readU32Be)(e),q=0;q0){if(1===Z)e.skip(4),Y=8*(0,T.readU32Be)(e),e.skip(8);else if(2===Z){e.skip(4),J=(0,T.readF64Be)(e),Q=(0,T.readU32Be)(e),e.skip(4),Y=(0,T.readU32Be)(e);var $=(0,T.readU32Be)(e);if(e.skip(8),"lpcm"===X){var ee=Y+7>>3,et=!!(1&$),er=!!(2&$),en=4&$?-1:0;Y>0&&Y<=64&&(et?32===Y&&(V.info.codec=er?"pcm-f32be":"pcm-f32"):en&1<>4,chromaSubsampling:el>>1&7,videoFullRangeFlag:1&el,colourPrimaries:ed,transferCharacteristics:ef,matrixCoefficients:eh};break;case"av1C":var em,ep=this.currentTrack;if(!ep)break;(0,_.assert)((null==(em=ep.info)?void 0:em.type)==="video"),e.skip(1);var eg=(0,T.readU8)(e),ev=eg>>5,eb=(0,T.readU8)(e),ek=eb>>6&1;ep.info.av1CodecInfo={profile:ev,level:31&eg,tier:eb>>7,bitDepth:2===ev&&ek?eb>>5&1?12:10:ek?10:8,monochrome:eb>>4&1,chromaSubsamplingX:eb>>3&1,chromaSubsamplingY:eb>>2&1,chromaSamplePosition:3&eb};break;case"colr":var e_,ey=this.currentTrack;if(!ey||((0,_.assert)((null==(e_=ey.info)?void 0:e_.type)==="video"),"nclx"!==(0,T.readAscii)(e,4)))break;var ew=(0,T.readU16Be)(e),eS=(0,T.readU16Be)(e),eT=(0,T.readU16Be)(e),ex=!!(128&(0,T.readU8)(e));ey.info.colorSpace={primaries:_.COLOR_PRIMARIES_MAP_INVERSE[ew],transfer:_.TRANSFER_CHARACTERISTICS_MAP_INVERSE[eS],matrix:_.MATRIX_COEFFICIENTS_MAP_INVERSE[eT],fullRange:ex};break;case"esds":var eI,eE=this.currentTrack;if(!eE)break;(0,_.assert)((null==(eI=eE.info)?void 0:eI.type)==="audio"),e.skip(4);var ej=(0,T.readU8)(e);(0,_.assert)(3===ej),(0,S.readIsomVariableInteger)(e),e.skip(2);var eP=(0,T.readU8)(e);if((128&eP)!=0&&e.skip(2),(64&eP)!=0){var eC=(0,T.readU8)(e);e.skip(eC)}(32&eP)!=0&&e.skip(2);var eA=(0,T.readU8)(e);(0,_.assert)(4===eA);var eB=(0,S.readIsomVariableInteger)(e),eM=e.filePos,eD=(0,T.readU8)(e);if(64===eD||103===eD?(eE.info.codec="aac",eE.info.aacCodecInfo={isMpeg2:103===eD}):105===eD||107===eD?eE.info.codec="mp3":221===eD?eE.info.codec="vorbis":console.warn("Unsupported audio codec (objectTypeIndication ".concat(eD,") - discarding track.")),e.skip(12),eB>e.filePos-eM){var eF=(0,T.readU8)(e);(0,_.assert)(5===eF);var eR=(0,S.readIsomVariableInteger)(e);if(eE.info.codecDescription=(0,T.readBytes)(e,eR),"aac"===eE.info.codec){var eU=(0,p.parseAacAudioSpecificConfig)(eE.info.codecDescription);null!==eU.numberOfChannels&&(eE.info.numberOfChannels=eU.numberOfChannels),null!==eU.sampleRate&&(eE.info.sampleRate=eU.sampleRate)}}break;case"enda":var eO,eL=this.currentTrack;if(!eL)break;(0,_.assert)((null==(eO=eL.info)?void 0:eO.type)==="audio"),255&(0,T.readU16Be)(e)&&("pcm-s16be"===eL.info.codec?eL.info.codec="pcm-s16":"pcm-s24be"===eL.info.codec?eL.info.codec="pcm-s24":"pcm-s32be"===eL.info.codec?eL.info.codec="pcm-s32":"pcm-f32be"===eL.info.codec?eL.info.codec="pcm-f32":"pcm-f64be"===eL.info.codec&&(eL.info.codec="pcm-f64"));break;case"pcmC":var eN,ez=this.currentTrack;if(!ez)break;(0,_.assert)((null==(eN=ez.info)?void 0:eN.type)==="audio"),e.skip(4);var eV=!!(1&(0,T.readU8)(e)),eH=(0,T.readU8)(e);"pcm-s16be"===ez.info.codec?eV?16===eH?ez.info.codec="pcm-s16":24===eH?ez.info.codec="pcm-s24":32===eH?ez.info.codec="pcm-s32":(console.warn("Invalid ipcm sample size ".concat(eH,".")),ez.info.codec=null):16===eH?ez.info.codec="pcm-s16be":24===eH?ez.info.codec="pcm-s24be":32===eH?ez.info.codec="pcm-s32be":(console.warn("Invalid ipcm sample size ".concat(eH,".")),ez.info.codec=null):"pcm-f32be"===ez.info.codec&&(eV?32===eH?ez.info.codec="pcm-f32":64===eH?ez.info.codec="pcm-f64":(console.warn("Invalid fpcm sample size ".concat(eH,".")),ez.info.codec=null):32===eH?ez.info.codec="pcm-f32be":64===eH?ez.info.codec="pcm-f64be":(console.warn("Invalid fpcm sample size ".concat(eH,".")),ez.info.codec=null));break;case"dOps":var eG,eq,eW=this.currentTrack;if(!eW)break;(0,_.assert)((null==(eG=eW.info)?void 0:eG.type)==="audio"),e.skip(1);var eK=(0,T.readU8)(e),eX=(0,T.readU16Be)(e),eZ=(0,T.readU32Be)(e),eQ=(0,T.readI16Be)(e),eY=(0,T.readU8)(e);eq=0!==eY?(0,T.readBytes)(e,2+eK):new Uint8Array(0);var eJ=new Uint8Array(19+eq.byteLength),e$=new DataView(eJ.buffer);e$.setUint32(0,0x4f707573,!1),e$.setUint32(4,0x48656164,!1),e$.setUint8(8,1),e$.setUint8(9,eK),e$.setUint16(10,eX,!0),e$.setUint32(12,eZ,!0),e$.setInt16(16,eQ,!0),e$.setUint8(18,eY),eJ.set(eq,19),eW.info.codecDescription=eJ,eW.info.numberOfChannels=eK;break;case"dfLa":var e0,e1=this.currentTrack;if(!e1)break;(0,_.assert)((null==(e0=e1.info)?void 0:e0.type)==="audio"),e.skip(4);for(var e2=e.filePos;e.filePos>>12,e5=(e8>>9&7)+1;e1.info.sampleRate=e6,e1.info.numberOfChannels=e5,e.skip(20)}else e.skip(e4);if(128&e3)break}var e7=e.filePos;e.filePos=e2;var e9=(0,T.readBytes)(e,e7-e2),te=new Uint8Array(4+e9.byteLength);new DataView(te.buffer).setUint32(0,0x664c6143,!1),te.set(e9,4),e1.info.codecDescription=te;break;case"stts":var tt=this.currentTrack;if(!tt||!tt.sampleTable)break;e.skip(4);for(var tr=(0,T.readU32Be)(e),tn=0,ta=0,ti=0;ti>4],t8=t3[(12&t2)>>2],t6=t3[3&t2],t5=(0,T.readU32Be)(e),t7=0;t70&&(null!=(nD=this.metadataTags).trackNumber||(nD.trackNumber=nU)),nO&&Number.isInteger(nO)&&nO>0&&(null!=(nF=this.metadataTags).tracksTotal||(nF.tracksTotal=nO))}break;case"trkn":if(nb instanceof Uint8Array&&nb.length>=6){var nL,nN,nz=(0,_.toDataView)(nb),nV=nz.getUint16(2,!1),nH=nz.getUint16(4,!1);nV>0&&(null!=(nL=this.metadataTags).trackNumber||(nL.trackNumber=nV)),nH>0&&(null!=(nN=this.metadataTags).tracksTotal||(nN.tracksTotal=nH))}break;case"disc":case"disk":if(nb instanceof Uint8Array&&nb.length>=6){var nG,nq,nW=(0,_.toDataView)(nb),nK=nW.getUint16(2,!1),nX=nW.getUint16(4,!1);nK>0&&(null!=(nG=this.metadataTags).discNumber||(nG.discNumber=nK)),nX>0&&(null!=(nq=this.metadataTags).discsTotal||(nq.discsTotal=nX))}}}}catch(e){nu=!0,nl=e}finally{try{nc||null==nf.return||nf.return()}finally{if(nu)throw nl}}}return e.filePos=i,!0}}]),r}(b.Demuxer),E=function(){"use strict";function e(r){(0,c._)(this,e),this.internalTrack=r,this.packetToSampleIndex=new WeakMap,this.packetToFragmentLocation=new WeakMap}return(0,u._)(e,[{key:"getId",value:function(){return this.internalTrack.id}},{key:"getCodec",value:function(){throw Error("Not implemented on base class.")}},{key:"getInternalCodecId",value:function(){return this.internalTrack.internalCodecId}},{key:"getName",value:function(){return this.internalTrack.name}},{key:"getLanguageCode",value:function(){return this.internalTrack.languageCode}},{key:"getTimeResolution",value:function(){return this.internalTrack.timescale}},{key:"getDisposition",value:function(){return this.internalTrack.disposition}},{key:"computeDuration",value:function(){return(0,s._)(function(){var e,r,n;return(0,m._)(this,function(a){switch(a.label){case 0:return[4,this.getPacket(1/0,{metadataOnly:!0})];case 1:return[2,(null!=(r=null==(e=a.sent())?void 0:e.timestamp)?r:0)+(null!=(n=null==e?void 0:e.duration)?n:0)]}})}).call(this)}},{key:"getFirstTimestamp",value:function(){return(0,s._)(function(){var e,r;return(0,m._)(this,function(n){switch(n.label){case 0:return[4,this.getFirstPacket({metadataOnly:!0})];case 1:return[2,null!=(r=null==(e=n.sent())?void 0:e.timestamp)?r:0]}})}).call(this)}},{key:"getFirstPacket",value:function(e){return(0,s._)(function(){var r,n;return(0,m._)(this,function(a){switch(a.label){case 0:return r=this,[4,this.fetchPacketForSampleIndex(0,e)];case 1:if((n=a.sent())||!this.internalTrack.demuxer.isFragmented)return[2,n];return[2,this.performFragmentedLookup(null,function(e){return e.trackData.get(r.internalTrack.id)?{sampleIndex:0,correctSampleFound:!0}:{sampleIndex:-1,correctSampleFound:!1}},-1/0,1/0,e)]}})}).call(this)}},{key:"mapTimestampIntoTimescale",value:function(e){return(0,_.roundIfAlmostInteger)(e*this.internalTrack.timescale)+this.internalTrack.editListOffset}},{key:"getPacket",value:function(e,r){return(0,s._)(function(){var n,a,i,s,o;return(0,m._)(this,function(c){switch(c.label){case 0:return n=this,a=this.mapTimestampIntoTimescale(e),s=C(i=this.internalTrack.demuxer.getSampleTableForTrack(this.internalTrack),a),[4,this.fetchPacketForSampleIndex(s,r)];case 1:if(o=c.sent(),!R(i)||!this.internalTrack.demuxer.isFragmented)return[2,o];return[2,this.performFragmentedLookup(null,function(e){var r=e.trackData.get(n.internalTrack.id);if(!r)return{sampleIndex:-1,correctSampleFound:!1};var i=(0,_.binarySearchLessOrEqual)(r.presentationTimestamps,a,function(e){return e.presentationTimestamp});return{sampleIndex:-1!==i?r.presentationTimestamps[i].sampleIndex:-1,correctSampleFound:-1!==i&&as.sampleIndex});if(-1!==r)return{sampleIndex:r,correctSampleFound:!0}}else{var a=e.trackData.get(n.internalTrack.id);if(a&&null!==a.firstKeyFrameTimestamp){var i=a.samples.findIndex(function(e){return e.isKeyFrame});return(0,_.assert)(-1!==i),{sampleIndex:i,correctSampleFound:!0}}}return{sampleIndex:-1,correctSampleFound:!1}},-1/0,1/0,r)]})}).call(this)}},{key:"fetchPacketForSampleIndex",value:function(e,r){return(0,s._)(function(){var n,a,i,s,o,c;return(0,m._)(this,function(u){switch(u.label){case 0:if(-1===e||!(n=B(this.internalTrack.demuxer.getSampleTableForTrack(this.internalTrack),e)))return[2,null];if(!r.metadataOnly)return[3,1];return a=y.PLACEHOLDER_DATA,[3,4];case 1:if(!((i=this.internalTrack.demuxer.reader.requestSlice(n.sampleOffset,n.sampleSize))instanceof Promise))return[3,3];return[4,i];case 2:i=u.sent(),u.label=3;case 3:(0,_.assert)(i),a=(0,T.readBytes)(i,n.sampleSize),u.label=4;case 4:return s=(n.presentationTimestamp-this.internalTrack.editListOffset)/this.internalTrack.timescale,o=n.duration/this.internalTrack.timescale,c=new(0,y.EncodedPacket)(a,n.isKeyFrame?"key":"delta",s,o,e,n.sampleSize),this.packetToSampleIndex.set(c,e),[2,c]}})}).call(this)}},{key:"fetchPacketInFragment",value:function(e,r,n){return(0,s._)(function(){var a,i,s,o,c,u;return(0,m._)(this,function(l){switch(l.label){case 0:if(-1===r)return[2,null];if(a=e.trackData.get(this.internalTrack.id).samples[r],(0,_.assert)(a),!n.metadataOnly)return[3,1];return i=y.PLACEHOLDER_DATA,[3,4];case 1:if(!((s=this.internalTrack.demuxer.reader.requestSlice(a.byteOffset,a.byteSize))instanceof Promise))return[3,3];return[4,s];case 2:s=l.sent(),l.label=3;case 3:(0,_.assert)(s),i=(0,T.readBytes)(s,a.byteSize),l.label=4;case 4:return o=(a.presentationTimestamp-this.internalTrack.editListOffset)/this.internalTrack.timescale,c=a.duration/this.internalTrack.timescale,u=new(0,y.EncodedPacket)(i,a.isKeyFrame?"key":"delta",o,c,e.moofOffset+r,a.byteSize),this.packetToFragmentLocation.set(u,{fragment:e,sampleIndex:r}),[2,u]}})}).call(this)}},{key:"performFragmentedLookup",value:function(e,r,n,a,i){return(0,s._)(function(){var s,o,c,u,l,d,f,h,p,g,b,k,y,w,T,x,I,E,j,P,C,A,B;return(0,m._)(this,function(m){switch(m.label){case 0:if(s=this.internalTrack.demuxer,o=null,c=null,u=-1,e){if(d=(l=r(e)).sampleIndex,l.correctSampleFound)return[2,this.fetchPacketInFragment(e,d,i)];-1!==d&&(c=e,u=d)}h=-1!==(f=(0,_.binarySearchLessOrEqual)(this.internalTrack.fragmentLookupTable,n,function(e){return e.timestamp}))?this.internalTrack.fragmentLookupTable[f]:null,g=-1!==(p=(0,_.binarySearchLessOrEqual)(this.internalTrack.fragmentPositionCache,n,function(e){return e.startTimestamp}))?this.internalTrack.fragmentPositionCache[p]:null,y=Math.max(null!=(b=null==h?void 0:h.moofOffset)?b:0,null!=(k=null==g?void 0:g.moofOffset)?k:0)||null,e?null===y||e.moofOffset>=y?(w=e.moofOffset+e.moofSize,o=e):w=y:w=null!=y?y:0,m.label=1;case 1:if(o&&(T=o.trackData.get(this.internalTrack.id))&&T.startTimestamp>a)return[3,6];if(!((x=s.reader.requestSliceRange(w,S.MIN_BOX_HEADER_SIZE,S.MAX_BOX_HEADER_SIZE))instanceof Promise))return[3,3];return[4,x];case 2:x=m.sent(),m.label=3;case 3:if(!x||(I=w,!(E=(0,S.readBoxHeader)(x))))return[3,6];if("moof"!==E.name)return[3,5];return[4,s.readFragment(I)];case 4:if(P=(j=r(o=m.sent())).sampleIndex,j.correctSampleFound)return[2,this.fetchPacketInFragment(o,P,i)];-1!==P&&(c=o,u=P),m.label=5;case 5:return w=I+E.totalSize,[3,1];case 6:if(h&&(!c||c.moofOffset=0;a--){var i=e.presentationTimestamps[a].sampleIndex;if(-1!==(0,_.binarySearchExact)(e.keySampleIndices,i,function(e){return e}))return i}return -1}var s,o=C(e,r),c=(0,_.binarySearchLessOrEqual)(e.keySampleIndices,o,function(e){return e});return null!=(s=e.keySampleIndices[c])?s:-1},B=function(e,r){var n=(0,_.binarySearchLessOrEqual)(e.sampleTimingEntries,r,function(e){return e.startIndex}),a=e.sampleTimingEntries[n];if(!a||a.startIndex+a.count<=r)return null;var i=a.startDecodeTimestamp+(r-a.startIndex)*a.delta,s=(0,_.binarySearchLessOrEqual)(e.sampleCompositionTimeOffsets,r,function(e){return e.startIndex}),o=e.sampleCompositionTimeOffsets[s];o&&r-o.startIndex>6&3,h=31&S,m=(0,c.reverseBitsU32)(w.getUint32(2)),p=S>>5&1,b=w.getUint8(12),y=[];for(var T=0;T<6;T++)y.push(w.getUint8(6+T))}var x="hev1.";for(x+=["","A","B","C"][f]+h,x+=".",x+=m.toString(16).toUpperCase(),x+=".",x+=0===p?"L":"H",x+=b;y.length>0&&0===y[y.length-1];)y.pop();return y.length>0&&(x+=".",x+=y.map(function(e){return e.toString(16).toUpperCase()}).join(".")),x}if("vp8"===r)return"vp8";if("vp9"===r){if(!u){var I=e.width*e.height,E=(0,c.last)(g).level,j=!0,P=!1,C=void 0;try{for(var A,B=g[Symbol.iterator]();!(j=(A=B.next()).done);j=!0){var M=A.value;if(I<=M.maxPictureSize){E=M.level;break}}}catch(e){P=!0,C=e}finally{try{j||null==B.return||B.return()}finally{if(P)throw C}}return"vp09.00.".concat(E.toString().padStart(2,"0"),".08")}var D=u.profile.toString().padStart(2,"0"),F=u.level.toString().padStart(2,"0"),R=u.bitDepth.toString().padStart(2,"0"),U=u.chromaSubsampling.toString().padStart(2,"0"),O=u.colourPrimaries.toString().padStart(2,"0"),L=u.transferCharacteristics.toString().padStart(2,"0"),N=u.matrixCoefficients.toString().padStart(2,"0"),z=u.videoFullRangeFlag.toString().padStart(2,"0"),V="vp09.".concat(D,".").concat(F,".").concat(R,".").concat(U);return(V+=".".concat(O,".").concat(L,".").concat(N,".").concat(z)).endsWith(k)&&(V=V.slice(0,-k.length)),V}if("av1"===r){if(!l){var H=e.width*e.height,G=(0,c.last)(g).level,q=!0,W=!1,K=void 0;try{for(var X,Z=g[Symbol.iterator]();!(q=(X=Z.next()).done);q=!0){var Q=X.value;if(H<=Q.maxPictureSize){G=Q.level;break}}}catch(e){W=!0,K=e}finally{try{q||null==Z.return||Z.return()}finally{if(W)throw K}}return"av01.0.".concat(G.toString().padStart(2,"0"),"M.08")}var Y=l.profile,J=l.level.toString().padStart(2,"0"),$=l.tier?"H":"M",ee=l.bitDepth.toString().padStart(2,"0"),et=l.monochrome?"1":"0",er=100*l.chromaSubsamplingX+10*l.chromaSubsamplingY+ +(l.chromaSubsamplingX&&l.chromaSubsamplingY?l.chromaSamplePosition:0),en=(null==a?void 0:a.primaries)?c.COLOR_PRIMARIES_MAP[a.primaries]:1,ea=(null==a?void 0:a.transfer)?c.TRANSFER_CHARACTERISTICS_MAP[a.transfer]:1,ei=(null==a?void 0:a.matrix)?c.MATRIX_COEFFICIENTS_MAP[a.matrix]:1,es=+(null!=a&&!!a.fullRange),eo="av01.".concat(Y,".").concat(J).concat($,".").concat(ee);return eo+=".".concat(et,".").concat(er.toString().padStart(3,"0")),eo+=".".concat(en.toString().padStart(2,"0")),eo+=".".concat(ea.toString().padStart(2,"0")),eo+=".".concat(ei.toString().padStart(2,"0")),(eo+=".".concat(es)).endsWith(_)&&(eo=eo.slice(0,-_.length)),eo}throw TypeError("Unhandled codec '".concat(r,"'."))},x=function(e,r,n){if("aac"===e)return r>=2&&n<=24e3?"mp4a.40.29":n<=24e3?"mp4a.40.5":"mp4a.40.2";if("mp3"===e)return"mp3";if("opus"===e)return"opus";if("vorbis"===e)return"vorbis";if("flac"===e)return"flac";else if(l.includes(e))return e;throw TypeError("Unhandled codec '".concat(e,"'."))},I=function(e){var r=e.codec,n=e.codecDescription,a=e.aacCodecInfo;if("aac"===r){if(!a)throw TypeError("AAC codec info must be provided.");if(a.isMpeg2)return"mp4a.67";var i=P(n);return"mp4a.40.".concat(i.objectType)}if("mp3"===r)return"mp3";if("opus"===r)return"opus";if("vorbis"===r)return"vorbis";if("flac"===r)return"flac";else if(r&&l.includes(r))return r;throw TypeError("Unhandled codec '".concat(r,"'."))},E=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],j=[-1,1,2,3,4,5,6,8],P=function(e){if(!e||e.byteLength<2)throw TypeError("AAC description must be at least 2 bytes long.");var r=new(0,c.Bitstream)(e),n=r.readBits(5);31===n&&(n=32+r.readBits(6));var a=r.readBits(4),i=null;15===a?i=r.readBits(24):a=1&&s<=7&&(o=j[s]),{objectType:n,frequencyIndex:a,sampleRate:i,channelConfiguration:s,numberOfChannels:o}},C=function(e){var r=E.indexOf(e.sampleRate),n=null;-1===r&&(r=15,n=e.sampleRate);var a=j.indexOf(e.numberOfChannels);if(-1===a)throw TypeError("Unsupported number of channels: ".concat(e.numberOfChannels));var i=13;e.objectType>=32&&(i+=6),15===r&&(i+=24);var s=new Uint8Array(Math.ceil(i/8)),o=new(0,c.Bitstream)(s);return e.objectType<32?o.writeBits(5,e.objectType):(o.writeBits(5,31),o.writeBits(6,e.objectType-32)),o.writeBits(4,r),15===r&&o.writeBits(24,n),o.writeBits(4,a),s},A=48e3,B=/^pcm-([usf])(\d+)+(be)?$/,M=function(e){if((0,c.assert)(l.includes(e)),"ulaw"===e)return{dataType:"ulaw",sampleSize:1,littleEndian:!0,silentValue:255};if("alaw"===e)return{dataType:"alaw",sampleSize:1,littleEndian:!0,silentValue:213};var r=B.exec(e);return(0,c.assert)(r),{dataType:"u"===r[1]?"unsigned":"s"===r[1]?"signed":"float",sampleSize:Number(r[2])/8,littleEndian:"be"!==r[3],silentValue:128*("pcm-u8"===e)}},D=function(e){if(e.startsWith("avc1")||e.startsWith("avc3"))return"avc";if(e.startsWith("hev1")||e.startsWith("hvc1"))return"hevc";if("vp8"===e)return"vp8";if(e.startsWith("vp09"))return"vp9";if(e.startsWith("av01"))return"av1";if(e.startsWith("mp4a.40")||"mp4a.67"===e)return"aac";if("mp3"===e||"mp4a.69"===e||"mp4a.6B"===e||"mp4a.6b"===e)return"mp3";if("opus"===e)return"opus";if("vorbis"===e)return"vorbis";if("flac"===e)return"flac";else if("ulaw"===e)return"ulaw";else if("alaw"===e)return"alaw";else if(B.test(e))return e;return"webvtt"===e?"webvtt":null},F=function(e){return"avc"===e?{avc:{format:"avc"}}:"hevc"===e?{hevc:{format:"hevc"}}:{}},R=function(e){return"aac"===e?{aac:{format:"aac"}}:"opus"===e?{opus:{format:"opus"}}:{}},U=["avc1","avc3","hev1","hvc1","vp8","vp09","av01"],O=/^(avc1|avc3)\.[0-9a-fA-F]{6}$/,L=/^(hev1|hvc1)\.(?:[ABC]?\d+)\.[0-9a-fA-F]{1,8}\.[LH]\d+(?:\.[0-9a-fA-F]{1,2}){0,6}$/,N=/^vp09(?:\.\d{2}){3}(?:(?:\.\d{2}){5})?$/,z=/^av01\.\d\.\d{2}[MH]\.\d{2}(?:\.\d\.\d{3}\.\d{2}\.\d{2}\.\d{2}\.\d)?$/,V=function(e){if(!e)throw TypeError("Video chunk metadata must be provided.");if((void 0===e?"undefined":(0,o._)(e))!=="object")throw TypeError("Video chunk metadata must be an object.");if(!e.decoderConfig)throw TypeError("Video chunk metadata must include a decoder configuration.");if("object"!==(0,o._)(e.decoderConfig))throw TypeError("Video chunk metadata decoder configuration must be an object.");if("string"!=typeof e.decoderConfig.codec)throw TypeError("Video chunk metadata decoder configuration must specify a codec string.");if(!U.some(function(r){return e.decoderConfig.codec.startsWith(r)}))throw TypeError("Video chunk metadata decoder configuration codec string must be a valid video codec string as specified in the WebCodecs Codec Registry.");if(!Number.isInteger(e.decoderConfig.codedWidth)||e.decoderConfig.codedWidth<=0)throw TypeError("Video chunk metadata decoder configuration must specify a valid codedWidth (positive integer).");if(!Number.isInteger(e.decoderConfig.codedHeight)||e.decoderConfig.codedHeight<=0)throw TypeError("Video chunk metadata decoder configuration must specify a valid codedHeight (positive integer).");if(void 0!==e.decoderConfig.description&&!(0,c.isAllowSharedBufferSource)(e.decoderConfig.description))throw TypeError("Video chunk metadata decoder configuration description, when defined, must be an ArrayBuffer or an ArrayBuffer view.");if(void 0!==e.decoderConfig.colorSpace){var r=e.decoderConfig.colorSpace;if((void 0===r?"undefined":(0,o._)(r))!=="object")throw TypeError("Video chunk metadata decoder configuration colorSpace, when provided, must be an object.");var n=Object.keys(c.COLOR_PRIMARIES_MAP);if(null!=r.primaries&&!n.includes(r.primaries))throw TypeError("Video chunk metadata decoder configuration colorSpace primaries, when defined, must be one of"+" ".concat(n.join(", "),"."));var a=Object.keys(c.TRANSFER_CHARACTERISTICS_MAP);if(null!=r.transfer&&!a.includes(r.transfer))throw TypeError("Video chunk metadata decoder configuration colorSpace transfer, when defined, must be one of"+" ".concat(a.join(", "),"."));var i=Object.keys(c.MATRIX_COEFFICIENTS_MAP);if(null!=r.matrix&&!i.includes(r.matrix))throw TypeError("Video chunk metadata decoder configuration colorSpace matrix, when defined, must be one of"+" ".concat(i.join(", "),"."));if(null!=r.fullRange&&"boolean"!=typeof r.fullRange)throw TypeError("Video chunk metadata decoder configuration colorSpace fullRange, when defined, must be a boolean.")}if(e.decoderConfig.codec.startsWith("avc1")||e.decoderConfig.codec.startsWith("avc3")){if(!O.test(e.decoderConfig.codec))throw TypeError("Video chunk metadata decoder configuration codec string for AVC must be a valid AVC codec string as specified in Section 3.4 of RFC 6381.")}else if(e.decoderConfig.codec.startsWith("hev1")||e.decoderConfig.codec.startsWith("hvc1")){if(!L.test(e.decoderConfig.codec))throw TypeError("Video chunk metadata decoder configuration codec string for HEVC must be a valid HEVC codec string as specified in Section E.3 of ISO 14496-15.")}else if(e.decoderConfig.codec.startsWith("vp8")){if("vp8"!==e.decoderConfig.codec)throw TypeError('Video chunk metadata decoder configuration codec string for VP8 must be "vp8".')}else if(e.decoderConfig.codec.startsWith("vp09")){if(!N.test(e.decoderConfig.codec))throw TypeError('Video chunk metadata decoder configuration codec string for VP9 must be a valid VP9 codec string as specified in Section "Codecs Parameter String" of https://www.webmproject.org/vp9/mp4/.')}else if(e.decoderConfig.codec.startsWith("av01")&&!z.test(e.decoderConfig.codec))throw TypeError('Video chunk metadata decoder configuration codec string for AV1 must be a valid AV1 codec string as specified in Section "Codecs Parameter String" of https://aomediacodec.github.io/av1-isobmff/.')},H=["mp4a","mp3","opus","vorbis","flac","ulaw","alaw","pcm"],G=function(e){if(!e)throw TypeError("Audio chunk metadata must be provided.");if((void 0===e?"undefined":(0,o._)(e))!=="object")throw TypeError("Audio chunk metadata must be an object.");if(!e.decoderConfig)throw TypeError("Audio chunk metadata must include a decoder configuration.");if("object"!==(0,o._)(e.decoderConfig))throw TypeError("Audio chunk metadata decoder configuration must be an object.");if("string"!=typeof e.decoderConfig.codec)throw TypeError("Audio chunk metadata decoder configuration must specify a codec string.");if(!H.some(function(r){return e.decoderConfig.codec.startsWith(r)}))throw TypeError("Audio chunk metadata decoder configuration codec string must be a valid audio codec string as specified in the WebCodecs Codec Registry.");if(!Number.isInteger(e.decoderConfig.sampleRate)||e.decoderConfig.sampleRate<=0)throw TypeError("Audio chunk metadata decoder configuration must specify a valid sampleRate (positive integer).");if(!Number.isInteger(e.decoderConfig.numberOfChannels)||e.decoderConfig.numberOfChannels<=0)throw TypeError("Audio chunk metadata decoder configuration must specify a valid numberOfChannels (positive integer).");if(void 0!==e.decoderConfig.description&&!(0,c.isAllowSharedBufferSource)(e.decoderConfig.description))throw TypeError("Audio chunk metadata decoder configuration description, when defined, must be an ArrayBuffer or an ArrayBuffer view.");if(e.decoderConfig.codec.startsWith("mp4a")&&"mp4a.69"!==e.decoderConfig.codec&&"mp4a.6B"!==e.decoderConfig.codec&&"mp4a.6b"!==e.decoderConfig.codec){if(!["mp4a.40.2","mp4a.40.02","mp4a.40.5","mp4a.40.05","mp4a.40.29","mp4a.67"].includes(e.decoderConfig.codec))throw TypeError("Audio chunk metadata decoder configuration codec string for AAC must be a valid AAC codec string as specified in https://www.w3.org/TR/webcodecs-aac-codec-registration/.");if(!e.decoderConfig.description)throw TypeError("Audio chunk metadata decoder configuration for AAC must include a description, which is expected to be an AudioSpecificConfig as specified in ISO 14496-3.")}else if(e.decoderConfig.codec.startsWith("mp3")||e.decoderConfig.codec.startsWith("mp4a")){if("mp3"!==e.decoderConfig.codec&&"mp4a.69"!==e.decoderConfig.codec&&"mp4a.6B"!==e.decoderConfig.codec&&"mp4a.6b"!==e.decoderConfig.codec)throw TypeError('Audio chunk metadata decoder configuration codec string for MP3 must be "mp3", "mp4a.69" or "mp4a.6B".')}else if(e.decoderConfig.codec.startsWith("opus")){if("opus"!==e.decoderConfig.codec)throw TypeError('Audio chunk metadata decoder configuration codec string for Opus must be "opus".');if(e.decoderConfig.description&&e.decoderConfig.description.byteLength<18)throw TypeError("Audio chunk metadata decoder configuration description, when specified, is expected to be an Identification Header as specified in Section 5.1 of RFC 7845.")}else if(e.decoderConfig.codec.startsWith("vorbis")){if("vorbis"!==e.decoderConfig.codec)throw TypeError('Audio chunk metadata decoder configuration codec string for Vorbis must be "vorbis".');if(!e.decoderConfig.description)throw TypeError("Audio chunk metadata decoder configuration for Vorbis must include a description, which is expected to adhere to the format described in https://www.w3.org/TR/webcodecs-vorbis-codec-registration/.")}else if(e.decoderConfig.codec.startsWith("flac")){if("flac"!==e.decoderConfig.codec)throw TypeError('Audio chunk metadata decoder configuration codec string for FLAC must be "flac".');if(!e.decoderConfig.description||e.decoderConfig.description.byteLength<42)throw TypeError("Audio chunk metadata decoder configuration for FLAC must include a description, which is expected to adhere to the format described in https://www.w3.org/TR/webcodecs-flac-codec-registration/.")}else if((e.decoderConfig.codec.startsWith("pcm")||e.decoderConfig.codec.startsWith("ulaw")||e.decoderConfig.codec.startsWith("alaw"))&&!l.includes(e.decoderConfig.codec))throw TypeError("Audio chunk metadata decoder configuration codec string for PCM must be one of the supported PCM"+" codecs (".concat(l.join(", "),")."))},q=function(e){if(!e)throw TypeError("Subtitle metadata must be provided.");if((void 0===e?"undefined":(0,o._)(e))!=="object")throw TypeError("Subtitle metadata must be an object.");if(!e.config)throw TypeError("Subtitle metadata must include a config object.");if("object"!==(0,o._)(e.config))throw TypeError("Subtitle metadata config must be an object.");if("string"!=typeof e.config.description)throw TypeError("Subtitle metadata config description must be a string.")}},{"@swc/helpers/cjs/_to_consumable_array.cjs":"i81N6","@swc/helpers/cjs/_type_of.cjs":"iXhRw","./misc.js":"j7iGm","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],j7iGm:[function(e,r,n,a){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(n),i.export(n,"assert",function(){return _}),i.export(n,"normalizeRotation",function(){return y}),i.export(n,"last",function(){return w}),i.export(n,"isU32",function(){return S}),i.export(n,"Bitstream",function(){return T}),i.export(n,"readExpGolomb",function(){return x}),i.export(n,"readSignedExpGolomb",function(){return I}),i.export(n,"writeBits",function(){return E}),i.export(n,"toUint8Array",function(){return j}),i.export(n,"toDataView",function(){return P}),i.export(n,"textDecoder",function(){return C}),i.export(n,"textEncoder",function(){return A}),i.export(n,"isIso88591Compatible",function(){return B}),i.export(n,"COLOR_PRIMARIES_MAP",function(){return D}),i.export(n,"COLOR_PRIMARIES_MAP_INVERSE",function(){return F}),i.export(n,"TRANSFER_CHARACTERISTICS_MAP",function(){return R}),i.export(n,"TRANSFER_CHARACTERISTICS_MAP_INVERSE",function(){return U}),i.export(n,"MATRIX_COEFFICIENTS_MAP",function(){return O}),i.export(n,"MATRIX_COEFFICIENTS_MAP_INVERSE",function(){return L}),i.export(n,"colorSpaceIsComplete",function(){return N}),i.export(n,"isAllowSharedBufferSource",function(){return z}),i.export(n,"AsyncMutex",function(){return V}),i.export(n,"bytesToHexString",function(){return H}),i.export(n,"reverseBitsU32",function(){return G}),i.export(n,"binarySearchExact",function(){return q}),i.export(n,"binarySearchLessOrEqual",function(){return W}),i.export(n,"insertSorted",function(){return K}),i.export(n,"promiseWithResolvers",function(){return X}),i.export(n,"removeItem",function(){return Z}),i.export(n,"findLast",function(){return Q}),i.export(n,"findLastIndex",function(){return Y}),i.export(n,"toAsyncIterator",function(){return J}),i.export(n,"validateAnyIterable",function(){return $}),i.export(n,"assertNever",function(){return ee}),i.export(n,"getUint24",function(){return et}),i.export(n,"getInt24",function(){return er}),i.export(n,"setUint24",function(){return en}),i.export(n,"setInt24",function(){return ea}),i.export(n,"setInt64",function(){return ei}),i.export(n,"mapAsyncGenerator",function(){return es}),i.export(n,"clamp",function(){return eo}),i.export(n,"UNDETERMINED_LANGUAGE",function(){return ec}),i.export(n,"roundIfAlmostInteger",function(){return eu}),i.export(n,"roundToMultiple",function(){return el}),i.export(n,"ilog",function(){return ed}),i.export(n,"isIso639Dash2LanguageCode",function(){return eh}),i.export(n,"SECOND_TO_MICROSECOND_FACTOR",function(){return em}),i.export(n,"mergeRequestInit",function(){return ep}),i.export(n,"retriedFetch",function(){return ev}),i.export(n,"computeRationalApproximation",function(){return eb}),i.export(n,"CallSerializer",function(){return ek}),i.export(n,"isWebKit",function(){return ey}),i.export(n,"isFirefox",function(){return eS}),i.export(n,"isChromium",function(){return ex}),i.export(n,"getChromiumVersion",function(){return eE}),i.export(n,"coalesceIndex",function(){return ej}),i.export(n,"closedIntervalsOverlap",function(){return eP}),i.export(n,"keyValueIterator",function(){return eC}),i.export(n,"imageMimeTypeToExtension",function(){return eA}),i.export(n,"base64ToBytes",function(){return eB}),i.export(n,"bytesToBase64",function(){return eM}),i.export(n,"uint8ArraysAreEqual",function(){return eD}),i.export(n,"polyfillSymbolDispose",function(){return eF}),i.export(n,"isNumber",function(){return eR});var s=e("@swc/helpers/cjs/_async_generator_delegate.cjs"),o=e("@swc/helpers/cjs/_async_iterator.cjs"),c=e("@swc/helpers/cjs/_async_to_generator.cjs"),u=e("@swc/helpers/cjs/_class_call_check.cjs"),l=e("@swc/helpers/cjs/_create_class.cjs"),d=e("@swc/helpers/cjs/_define_property.cjs"),f=e("@swc/helpers/cjs/_object_spread.cjs"),h=e("@swc/helpers/cjs/_sliced_to_array.cjs"),m=e("@swc/helpers/cjs/_to_consumable_array.cjs"),p=e("@swc/helpers/cjs/_type_of.cjs"),g=e("@swc/helpers/cjs/_wrap_async_generator.cjs"),b=e("@swc/helpers/cjs/_ts_generator.cjs"),k=e("@swc/helpers/cjs/_ts_values.cjs");function _(e){if(!e)throw Error("Assertion failed.")}var y=function(e){var r=(e%360+360)%360;if(0===r||90===r||180===r||270===r)return r;throw Error("Invalid rotation ".concat(e,"."))},w=function(e){return e&&e[e.length-1]},S=function(e){return e>=0&&e<0x100000000},T=function(){"use strict";function e(r){(0,u._)(this,e),this.bytes=r,this.pos=0}return(0,l._)(e,[{key:"seekToByte",value:function(e){this.pos=8*e}},{key:"readBit",value:function(){var e,r=Math.floor(this.pos/8),n=null!=(e=this.bytes[r])?e:0,a=7-(7&this.pos);return this.pos++,(n&1<>a}},{key:"readBits",value:function(e){if(1===e)return this.readBit();for(var r=0,n=0;n>n-a-1<=32)throw Error("Invalid exponential-Golomb code.");return(1<>1):r+1>>1},E=function(e,r,n,a){for(var i=r;i>n-i-1<255)return!1;return!0},M=function(e){return Object.fromEntries(Object.entries(e).map(function(e){var r=(0,h._)(e,2),n=r[0];return[r[1],n]}))},D={bt709:1,bt470bg:5,smpte170m:6,bt2020:9,smpte432:12},F=M(D),R={bt709:1,smpte170m:6,linear:8,"iec61966-2-1":13,pq:16,hlg:18},U=M(R),O={rgb:0,bt709:1,bt470bg:5,smpte170m:6,"bt2020-ncl":9},L=M(O),N=function(e){return!!e&&!!e.primaries&&!!e.transfer&&!!e.matrix&&void 0!==e.fullRange},z=function(e){return e instanceof ArrayBuffer||"undefined"!=typeof SharedArrayBuffer&&e instanceof SharedArrayBuffer||ArrayBuffer.isView(e)},V=function(){"use strict";function e(){(0,u._)(this,e),this.currentPromise=Promise.resolve()}return(0,l._)(e,[{key:"acquire",value:function(){return(0,c._)(function(){var e,r,n;return(0,b._)(this,function(a){switch(a.label){case 0:return r=new Promise(function(r){e=r}),n=this.currentPromise,this.currentPromise=r,[4,n];case 1:return a.sent(),[2,e]}})}).call(this)}}]),e}(),H=function(e){return(0,m._)(e).map(function(e){return e.toString(16).padStart(2,"0")}).join("")},G=function(e){return(e=(e=(e=(e=(e=e>>1&0x55555555|(0x55555555&e)<<1)>>2&0x33333333|(0x33333333&e)<<2)>>4&0xf0f0f0f|(0xf0f0f0f&e)<<4)>>8&0xff00ff|(0xff00ff&e)<<8)>>16&65535|(65535&e)<<16)>>>0},q=function(e,r,n){for(var a=0,i=e.length-1,s=-1;a<=i;){var o=a+i>>1,c=n(e[o]);c===r?(s=o,i=o-1):c=0;n--)if(r(e[n]))return e[n]},Y=function(e,r){for(var n=e.length-1;n>=0;n--)if(r(e[n]))return n;return -1},J=function(e){return(0,g._)(function(){return(0,b._)(this,function(r){switch(r.label){case 0:if(!(Symbol.iterator in e))return[3,2];return[5,(0,k._)((0,s._)((0,o._)(e[Symbol.iterator]())))];case 1:return r.sent(),[3,4];case 2:return[5,(0,k._)((0,s._)((0,o._)(e[Symbol.asyncIterator]())))];case 3:r.sent(),r.label=4;case 4:return[2]}})})()},$=function(e){if(!(Symbol.iterator in e)&&!(Symbol.asyncIterator in e))throw TypeError("Argument must be an iterable or async iterable.")},ee=function(e){throw Error("Unexpected value: ".concat(e))},et=function(e,r,n){var a=e.getUint8(r),i=e.getUint8(r+1),s=e.getUint8(r+2);return n?a|i<<8|s<<16:a<<16|i<<8|s},er=function(e,r,n){return et(e,r,n)<<8>>8},en=function(e,r,n,a){n>>>=0,n&=0xffffff,a?(e.setUint8(r,255&n),e.setUint8(r+1,n>>>8&255),e.setUint8(r+2,n>>>16&255)):(e.setUint8(r,n>>>16&255),e.setUint8(r+1,n>>>8&255),e.setUint8(r+2,255&n))},ea=function(e,r,n,a){(n=eo(n,-8388608,8388607))<0&&(n=n+0x1000000&0xffffff),en(e,r,n,a)},ei=function(e,r,n,a){a?(e.setUint32(r+0,n,!0),e.setInt32(r+4,Math.floor(n/0x100000000),!0)):(e.setInt32(r+0,Math.floor(n/0x100000000),!0),e.setUint32(r+4,n,!0))},es=function(e,r){return(0,d._)({next:function(){return(0,c._)(function(){var n;return(0,b._)(this,function(a){switch(a.label){case 0:return[4,e.next()];case 1:if((n=a.sent()).done)return[2,{value:void 0,done:!0}];return[2,{value:r(n.value),done:!1}]}})})()},return:function(){return e.return()},throw:function(r){return e.throw(r)}},Symbol.asyncIterator,function(){return this})},eo=function(e,r,n){return Math.max(r,Math.min(n,e))},ec="und",eu=function(e){var r=Math.round(e);return Math.abs(e/r-1)<10*Number.EPSILON?r:e},el=function(e,r){return Math.round(e/r)*r},ed=function(e){for(var r=0;e;)r++,e>>=1;return r},ef=/^[a-z]{3}$/,eh=function(e){return ef.test(e)},em=1e6*(1+Number.EPSILON),ep=function(e,r){var n=(0,f._)({},e,r);if(e.headers||r.headers){var a=e.headers?eg(e.headers):{},i=r.headers?eg(r.headers):{},s=(0,f._)({},a);Object.entries(i).forEach(function(e){var r=(0,h._)(e,2),n=r[0],a=r[1],i=Object.keys(s).find(function(e){return e.toLowerCase()===n.toLowerCase()});i&&delete s[i],s[n]=a}),n.headers=s}return n},eg=function(e){if(e instanceof Headers){var r={};return e.forEach(function(e,n){r[n]=e}),r}if(Array.isArray(e)){var n={};return e.forEach(function(e){var r=(0,h._)(e,2),a=r[0],i=r[1];n[a]=i}),n}return e},ev=function(e,r,n,a,i){return(0,c._)(function(){var s,o,c;return(0,b._)(this,function(u){switch(u.label){case 0:s=function(){var s,c,u;return(0,b._)(this,function(l){switch(l.label){case 0:return l.trys.push([0,2,,5]),s={},[4,e(r,n)];case 1:return[2,(s.v=l.sent(),s)];case 2:if(c=l.sent(),i()||null===(u=a(++o,c,r)))throw c;if(console.error("Retrying failed fetch. Error:",c),!Number.isFinite(u)||u<0)throw TypeError("Retry delay must be a non-negative finite number.");if(!(u>0))return[3,4];return[4,new Promise(function(e){return setTimeout(e,1e3*u)})];case 3:l.sent(),l.label=4;case 4:if(i())throw c;return[3,5];case 5:return[2]}})},o=0,u.label=1;case 1:return[5,(0,k._)(s())];case 2:if(c=u.sent(),"object"===(0,p._)(c))return[2,c.v];return[3,1];case 3:return[2]}})})()},eb=function(e,r){for(var n=e<0?-1:1,a=0,i=1,s=1,o=0,c=e=Math.abs(e);;){var u=Math.floor(c),l=u*s+a,d=u*o+i;if(d>r||(a=s,i=o,s=l,o=d,!isFinite(c=1/(c-u))))break}return{numerator:n*s,denominator:o}},ek=function(){"use strict";function e(){(0,u._)(this,e),this.currentPromise=Promise.resolve()}return(0,l._)(e,[{key:"call",value:function(e){return this.currentPromise=this.currentPromise.then(e)}}]),e}(),e_=null,ey=function(){var e;return null!==e_?e_:e_=!!("undefined"!=typeof navigator&&((null==(e=navigator.vendor)?void 0:e.match(/apple/i))||/AppleWebKit/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)||/\b(iPad|iPhone|iPod)\b/.test(navigator.userAgent)))},ew=null,eS=function(){var e;return null!==ew?ew:ew="undefined"!=typeof navigator&&(null==(e=navigator.userAgent)?void 0:e.includes("Firefox"))},eT=null,ex=function(){var e;return null!==eT?eT:eT=!!("undefined"!=typeof navigator&&((null==(e=navigator.vendor)?void 0:e.includes("Google Inc"))||/Chrome/.test(navigator.userAgent)))},eI=null,eE=function(){if(null!==eI)return eI;if("undefined"==typeof navigator)return null;var e=/\bChrome\/(\d+)/.exec(navigator.userAgent);return e?eI=Number(e[1]):null},ej=function(e,r){return -1!==e?e:r},eP=function(e,r,n,a){return e<=a&&n<=r},eC=function(e){var r,n,a,i,s;return(0,b._)(this,function(o){switch(o.label){case 0:for(n in r=[],e)r.push(n);a=0,o.label=1;case 1:if(!(a0&&a>n){var o=e.subarray(n,a);o.length>0&&r.push(o)}n=a+i}if(n0&&r.push(c)}return r},b=function(e,r){for(var n=[],a=0,i=new DataView(e.buffer,e.byteOffset,e.byteLength);a+r<=e.length;){var s=void 0;1===r?s=i.getUint8(a):2===r?s=i.getUint16(a,!1):3===r?s=(0,p.getUint24)(i,a,!1):4===r?s=i.getUint32(a,!1):((0,p.assertNever)(r),(0,p.assert)(!1)),a+=r;var o=e.subarray(a,a+s);n.push(o),a+=s}return n},k=function(e){for(var r=[],n=e.length,a=0;a>8),r.push(255&u);for(var l=0;l>8),r.push(255&k);for(var _=0;_>8),r.push(255&E);for(var j=0;j>1&63},P=function(e){try{var r=g(e),n=r.filter(function(e){return j(e)===u.VPS_NUT}),a=r.filter(function(e){return j(e)===u.SPS_NUT}),i=r.filter(function(e){return j(e)===u.PPS_NUT}),s=r.filter(function(e){return j(e)===u.PREFIX_SEI_NUT||j(e)===u.SUFFIX_SEI_NUT});if(0===a.length||0===i.length)return null;var o=a[0],c=new(0,p.Bitstream)(k(o));c.skipBits(16),c.readBits(4);var l=c.readBits(3),d=c.readBits(1),h=C(c,l),m=h.general_profile_space,b=h.general_tier_flag,_=h.general_profile_idc,y=h.general_profile_compatibility_flags,w=h.general_constraint_indicator_flags,S=h.general_level_idc;(0,p.readExpGolomb)(c);var T=(0,p.readExpGolomb)(c);3===T&&c.skipBits(1),(0,p.readExpGolomb)(c),(0,p.readExpGolomb)(c),c.readBits(1)&&((0,p.readExpGolomb)(c),(0,p.readExpGolomb)(c),(0,p.readExpGolomb)(c),(0,p.readExpGolomb)(c));var x=(0,p.readExpGolomb)(c),I=(0,p.readExpGolomb)(c);(0,p.readExpGolomb)(c);for(var E=c.readBits(1)?0:l,P=E;P<=l;P++)(0,p.readExpGolomb)(c),(0,p.readExpGolomb)(c),(0,p.readExpGolomb)(c);(0,p.readExpGolomb)(c),(0,p.readExpGolomb)(c),(0,p.readExpGolomb)(c),(0,p.readExpGolomb)(c),(0,p.readExpGolomb)(c),(0,p.readExpGolomb)(c),c.readBits(1)&&c.readBits(1)&&A(c),c.skipBits(1),c.skipBits(1),c.readBits(1)&&(c.skipBits(4),c.skipBits(4),(0,p.readExpGolomb)(c),(0,p.readExpGolomb)(c),c.skipBits(1));var M=(0,p.readExpGolomb)(c);if(B(c,M),c.readBits(1))for(var F=(0,p.readExpGolomb)(c),R=0;R0){var L=i[0],N=new(0,p.Bitstream)(k(L));N.skipBits(16),(0,p.readExpGolomb)(N),(0,p.readExpGolomb)(N),N.skipBits(1),N.skipBits(1),N.skipBits(3),N.skipBits(1),N.skipBits(1),(0,p.readExpGolomb)(N),(0,p.readExpGolomb)(N),(0,p.readSignedExpGolomb)(N),N.skipBits(1),N.skipBits(1),N.readBits(1)&&(0,p.readExpGolomb)(N),(0,p.readSignedExpGolomb)(N),(0,p.readSignedExpGolomb)(N),N.skipBits(1),N.skipBits(1),N.skipBits(1),N.skipBits(1);var z=N.readBits(1),V=N.readBits(1);O=z||V?z&&!V?2:!z&&V?3:0:0}var H=(0,f._)(n.length?[{arrayCompleteness:1,nalUnitType:u.VPS_NUT,nalUnits:n}]:[]).concat((0,f._)(a.length?[{arrayCompleteness:1,nalUnitType:u.SPS_NUT,nalUnits:a}]:[]),(0,f._)(i.length?[{arrayCompleteness:1,nalUnitType:u.PPS_NUT,nalUnits:i}]:[]),(0,f._)(s.length?[{arrayCompleteness:1,nalUnitType:j(s[0]),nalUnits:s}]:[]));return{configurationVersion:1,generalProfileSpace:m,generalTierFlag:b,generalProfileIdc:_,generalProfileCompatibilityFlags:y,generalConstraintIndicatorFlags:w,generalLevelIdc:S,minSpatialSegmentationIdc:U,parallelismType:O,chromaFormatIdc:T,bitDepthLumaMinus8:x,bitDepthChromaMinus8:I,avgFrameRate:0,constantFrameRate:0,numTemporalLayers:l+1,temporalIdNested:d,lengthSizeMinusOne:3,arrays:H}}catch(e){return console.error("Error building HEVC Decoder Configuration Record:",e),null}},C=function(e,r){for(var n=e.readBits(2),a=e.readBits(1),i=e.readBits(5),s=0,o=0;o<32;o++)s=s<<1|e.readBits(1);for(var c=new Uint8Array(6),u=0;u<6;u++)c[u]=e.readBits(8);for(var l=e.readBits(8),d=[],f=[],h=0;h0)for(var m=r;m<8;m++)e.skipBits(2);for(var p=0;p1&&(0,p.readSignedExpGolomb)(e);for(var i=0;i>>24&255),r.push(e.generalProfileCompatibilityFlags>>>16&255),r.push(e.generalProfileCompatibilityFlags>>>8&255),r.push(255&e.generalProfileCompatibilityFlags),r.push.apply(r,(0,f._)(e.generalConstraintIndicatorFlags)),r.push(255&e.generalLevelIdc),r.push(240|e.minSpatialSegmentationIdc>>8&15),r.push(255&e.minSpatialSegmentationIdc),r.push(252|3&e.parallelismType),r.push(252|3&e.chromaFormatIdc),r.push(248|7&e.bitDepthLumaMinus8),r.push(248|7&e.bitDepthChromaMinus8),r.push(e.avgFrameRate>>8&255),r.push(255&e.avgFrameRate),r.push((3&e.constantFrameRate)<<6|(7&e.numTemporalLayers)<<3|(1&e.temporalIdNested)<<2|3&e.lengthSizeMinusOne),r.push(255&e.arrays.length);var n=!0,a=!1,i=void 0;try{for(var s,o=e.arrays[Symbol.iterator]();!(n=(s=o.next()).done);n=!0){var c=s.value;r.push((1&c.arrayCompleteness)<<7|63&c.nalUnitType),r.push(c.nalUnits.length>>8&255),r.push(255&c.nalUnits.length);var u=!0,l=!1,d=void 0;try{for(var h,m=c.nalUnits[Symbol.iterator]();!(u=(h=m.next()).done);u=!0){var p=h.value;r.push(p.length>>8&255),r.push(255&p.length);for(var g=0;g=2&&(i=r.readBits(1)?12:10);var s=r.readBits(3),o=0,c=0;if(7!==s)if(c=r.readBits(1),1===a||3===a){var u=r.readBits(1),l=r.readBits(1);o=u||l?u&&!l?2:1:3,r.skipBits(1)}else o=1;else o=3,c=1;var d=(r.readBits(16)+1)*(r.readBits(16)+1),f=(0,p.last)(m.VP9_LEVEL_TABLE).level,h=!0,g=!1,b=void 0;try{for(var k,_=m.VP9_LEVEL_TABLE[Symbol.iterator]();!(h=(k=_.next()).done);h=!0){var y=k.value;if(d<=y.maxPictureSize){f=y.level;break}}}catch(e){g=!0,b=e}finally{try{h||null==_.return||_.return()}finally{if(g)throw b}}return{profile:a,level:f,bitDepth:i,chromaSubsampling:o,videoFullRangeFlag:c,colourPrimaries:2===s?1:1===s?6:2,transferCharacteristics:2===s?1:1===s?6:2,matrixCoefficients:7===s?0:2===s?1:1===s?6:2}},L=function(e){var r,n,a,i,s,o,c;return(0,h._)(this,function(u){switch(u.label){case 0:r=new(0,p.Bitstream)(e),n=function(){for(var e=0,n=0;n<8;n++){var a=r.readAlignedByte();if(e|=(127&a)<<7*n,!(128&a))break;if(7===n&&128&a)return null}return e>=0xffffffff?null:e},u.label=1;case 1:if(!(r.getBitsLeft()>=8))return[3,3];if(r.skipBits(1),a=r.readBits(4),i=r.readBits(1),s=r.readBits(1),r.skipBits(1),i&&r.skipBits(8),o=void 0,s){if(null===(c=n()))return[2];o=c}else o=Math.floor(r.getBitsLeft()/8);return(0,p.assert)(r.pos%8==0),[4,{type:a,data:e.subarray(r.pos/8,r.pos/8+o)}];case 2:return u.sent(),r.skipBits(8*o),[3,1];case 3:return[2]}})},N=function(e){var r=!0,n=!1,a=void 0;try{for(var i,s=L(e)[Symbol.iterator]();!(r=(i=s.next()).done);r=!0){var o=i.value,c=o.type,u=o.data;if(1===c){var l=new(0,p.Bitstream)(u),d=l.readBits(3);l.readBits(1);var f=l.readBits(1),h=0,m=0,g=0;if(f)h=l.readBits(5);else{if(l.readBits(1)&&(l.skipBits(32),l.skipBits(32),l.readBits(1)))return null;var b=l.readBits(1);b&&(g=l.readBits(5),l.skipBits(32),l.skipBits(5),l.skipBits(5));for(var k=l.readBits(5),_=0;_<=k;_++){l.skipBits(12);var y=l.readBits(5);if(0===_&&(h=y),y>7){var w=l.readBits(1);0===_&&(m=w)}if(b&&l.readBits(1)){var S=g+1;l.skipBits(S),l.skipBits(S),l.skipBits(1)}l.readBits(1)&&l.skipBits(4)}}var T=l.readBits(4),x=l.readBits(4),I=T+1;l.skipBits(I);var E=x+1;l.skipBits(E);if((f?0:l.readBits(1))&&(l.skipBits(4),l.skipBits(3)),l.skipBits(1),l.skipBits(1),l.skipBits(1),!f){l.skipBits(1),l.skipBits(1),l.skipBits(1),l.skipBits(1);var j=l.readBits(1);j&&(l.skipBits(1),l.skipBits(1));var P=l.readBits(1);(P?2:l.readBits(1))>0&&(l.readBits(1)||l.skipBits(1)),j&&l.skipBits(3)}l.skipBits(1),l.skipBits(1),l.skipBits(1);var C=l.readBits(1),A=8;2===d&&C?A=l.readBits(1)?12:10:d<=2&&(A=C?10:8);var B=0;1!==d&&(B=l.readBits(1));var M=1,D=1,F=0;return!B&&(0===d?(M=1,D=1):1===d?(M=0,D=0):12===A&&(M=l.readBits(1))&&(D=l.readBits(1)),M&&D&&(F=l.readBits(2))),{profile:d,level:h,tier:m,bitDepth:A,monochrome:B,chromaSubsamplingX:M,chromaSubsamplingY:D,chromaSamplePosition:F}}}}catch(e){n=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(n)throw a}}return null},z=function(e){var r=(0,p.toDataView)(e),n=r.getUint8(9),a=r.getUint16(10,!0),i=r.getUint32(12,!0),s=r.getInt16(16,!0),o=r.getUint8(18),c=null;return o&&(c=e.subarray(19,21+n)),{outputChannelCount:n,preSkip:a,inputSampleRate:i,outputGain:s,channelMappingFamily:o,channelMappingTable:c}},V=[480,960,1920,2880,480,960,1920,2880,480,960,1920,2880,480,960,480,960,120,240,480,960,120,240,480,960,120,240,480,960,120,240,480,960],H=function(e){return{durationInSamples:V[e[0]>>3]}},G=function(e){if(e.length<7)throw Error("Setup header is too short.");if(5!==e[0])throw Error("Wrong packet type in Setup header.");if("vorbis"!==(r=String).fromCharCode.apply(r,(0,f._)(e.slice(1,7))))throw Error("Invalid packet signature in Setup header.");for(var r,n=e.length,a=new Uint8Array(n),i=0;i97;)if(1===s.readBits(1)){o=s.pos;break}if(0===o)throw Error("Invalid Setup header: framing bit not found.");for(var c=0,u=!1,l=0;s.getBitsLeft()>=97;){var d=s.pos,h=s.readBits(8),m=s.readBits(16),g=s.readBits(16);if(h>63||0!==m||0!==g){s.pos=d;break}if(s.skipBits(1),++c>64)break;s.clone().readBits(6)+1===c&&(u=!0,l=c)}if(!u)throw Error("Invalid Setup header: mode header not found.");if(l>63)throw Error("Unsupported mode count: ".concat(l,"."));var b=l;s.pos=0,s.skipBits(o);for(var k=Array(b).fill(0),_=b-1;_>=0;_--)s.skipBits(40),k[_]=s.readBits(1);return{modeBlockflags:k}},q=function(e,r,n){switch(e){case"avc":var a=y(n,r),i=a.some(function(e){return w(e)===c.IDR}),s=!0,o=!1,l=void 0;if(!i&&(!(0,p.isChromium)()||(0,p.getChromiumVersion)()>=144))try{for(var d,f=a[Symbol.iterator]();!(s=(d=f.next()).done);s=!0){var h=d.value;if(w(h)===c.SEI){var m=k(h),g=1;do{for(var b=0;;){var _=m[g++];if(void 0===_||(b+=_,_<255))break}for(var S=0;;){var T=m[g++];if(void 0===T||(S+=T,T<255))break}if(6===b){var x=new(0,p.Bitstream)(m);x.pos=8*g;var I=(0,p.readExpGolomb)(x),P=x.readBits(1);if(0===I&&1===P){i=!0;break}}g+=S}while(g0&&(null!=r.raw||(r.raw={}),null!=(g=r.raw)[b="vendor"]||(g[b]=s));var o=n.getUint32(a,!0);a+=4;for(var c=0;c0&&(null!=r.trackNumber||(r.trackNumber=y)),w&&Number.isInteger(w)&&w>0&&(null!=r.tracksTotal||(r.tracksTotal=w));break;case"TRACKTOTAL":var S=Number.parseInt(m,10);Number.isInteger(S)&&S>0&&(null!=r.tracksTotal||(r.tracksTotal=S));break;case"DISCNUMBER":var T=m.split("/"),x=Number.parseInt(T[0],10),I=T[1]&&Number.parseInt(T[1],10);Number.isInteger(x)&&x>0&&(null!=r.discNumber||(r.discNumber=x)),I&&Number.isInteger(I)&&I>0&&(null!=r.discsTotal||(r.discsTotal=I));break;case"DISCTOTAL":var E=Number.parseInt(m,10);Number.isInteger(E)&&E>0&&(null!=r.discsTotal||(r.discsTotal=E));break;case"DATE":var j=new Date(m);Number.isNaN(j.getTime())||null!=r.date||(r.date=j);break;case"GENRE":null!=r.genre||(r.genre=m);break;case"METADATA_BLOCK_PICTURE":var P,C=(0,p.base64ToBytes)(m),A=(0,p.toDataView)(C),B=A.getUint32(0,!1),M=A.getUint32(4,!1),D=(P=String).fromCharCode.apply(P,(0,f._)(C.subarray(8,8+M))),F=A.getUint32(8+M,!1),R=p.textDecoder.decode(C.subarray(12+M,12+M+F)),U=A.getUint32(M+F+28),O=C.subarray(M+F+32,M+F+32+U);null!=r.images||(r.images=[]),r.images.push({data:O,mimeType:D,kind:3===B?"coverFront":4===B?"coverBack":"unknown",name:void 0,description:R||void 0})}}}},K=function(e,r,n){var a=[e],i=p.textEncoder.encode("Mediabunny"),s=new Uint8Array(4+i.length),o=new DataView(s.buffer);o.setUint32(0,i.length,!0),s.set(i,4),a.push(s);var c=new Set,u=function(e,r){var n="".concat(e,"=").concat(r),i=p.textEncoder.encode(n);(o=new DataView((s=new Uint8Array(4+i.length)).buffer)).setUint32(0,i.length,!0),s.set(i,4),a.push(s),c.add(e)},l=!0,d=!1,f=void 0;try{for(var h,m=(0,p.keyValueIterator)(r)[Symbol.iterator]();!(l=(h=m.next()).done);l=!0){var g=h.value,b=g.key,k=g.value;switch(b){case"title":u("TITLE",k);break;case"description":u("DESCRIPTION",k);break;case"artist":u("ARTIST",k);break;case"album":u("ALBUM",k);break;case"albumArtist":u("ALBUMARTIST",k);break;case"genre":u("GENRE",k);break;case"date":var _,y,w,S=null!=(w=null==(_=r.raw)?void 0:_.DATE)?w:null==(y=r.raw)?void 0:y.date;u("DATE",S&&"string"==typeof S?S:k.toISOString().slice(0,10));break;case"comment":u("COMMENT",k);break;case"lyrics":u("LYRICS",k);break;case"trackNumber":u("TRACKNUMBER",k.toString());break;case"tracksTotal":u("TRACKTOTAL",k.toString());break;case"discNumber":u("DISCNUMBER",k.toString());break;case"discsTotal":u("DISCTOTAL",k.toString());break;case"images":if(!n)break;var T=!0,x=!1,I=void 0;try{for(var E,j=k[Symbol.iterator]();!(T=(E=j.next()).done);T=!0){for(var P,C=E.value,A="coverFront"===C.kind?3:4*("coverBack"===C.kind),B=new Uint8Array(C.mimeType.length),M=0;M0&&void 0!==b[0]?b[0]:1/0,r=new(0,p.EncodedPacketSink)(this),n=1/0,a=-1/0,i=0,o=0,c=!1,u=!1,f.label=1;case 1:f.trys.push([1,6,7,12]),d=(0,s._)(r.packets(void 0,void 0,{metadataOnly:!0})),f.label=2;case 2:return[4,d.next()];case 3:if(!(c=!(h=f.sent()).done)||(m=h.value,i>=e&&m.timestamp>=a))return[3,5];n=Math.min(n,m.timestamp),a=Math.max(a,m.timestamp+m.duration),i++,o+=m.byteLength,f.label=4;case 4:return c=!1,[3,2];case 5:return[3,12];case 6:return g=f.sent(),u=!0,l=g,[3,12];case 7:if(f.trys.push([7,,10,11]),!(c&&null!=d.return))return[3,9];return[4,d.return()];case 8:f.sent(),f.label=9;case 9:return[3,11];case 10:if(u)throw l;return[7];case 11:return[7];case 12:return[2,{packetCount:i,averagePacketRate:i?Number((i/(a-n)).toPrecision(16)):0,averageBitrate:i?Number((8*o/(a-n)).toPrecision(16)):0}]}})}).apply(this,arguments)}}]),e}(),_=function(e){"use strict";function r(e,n){var a;return(0,u._)(this,r),(a=(0,c._)(this,r,[e,n]))._backing=n,a}return(0,d._)(r,e),(0,l._)(r,[{key:"type",get:function(){return"video"}},{key:"codec",get:function(){return this._backing.getCodec()}},{key:"codedWidth",get:function(){return this._backing.getCodedWidth()}},{key:"codedHeight",get:function(){return this._backing.getCodedHeight()}},{key:"rotation",get:function(){return this._backing.getRotation()}},{key:"displayWidth",get:function(){return this._backing.getRotation()%180==0?this._backing.getCodedWidth():this._backing.getCodedHeight()}},{key:"displayHeight",get:function(){return this._backing.getRotation()%180==0?this._backing.getCodedHeight():this._backing.getCodedWidth()}},{key:"getColorSpace",value:function(){return this._backing.getColorSpace()}},{key:"hasHighDynamicRange",value:function(){return(0,o._)(function(){var e;return(0,f._)(this,function(r){switch(r.label){case 0:return[4,this._backing.getColorSpace()];case 1:return[2,"bt2020"===(e=r.sent()).primaries||"smpte432"===e.primaries||"pg"===e.transfer||"hlg"===e.transfer||"bt2020-ncl"===e.matrix]}})}).call(this)}},{key:"canBeTransparent",value:function(){return this._backing.canBeTransparent()}},{key:"getDecoderConfig",value:function(){return this._backing.getDecoderConfig()}},{key:"getCodecParameterString",value:function(){return(0,o._)(function(){var e,r;return(0,f._)(this,function(n){switch(n.label){case 0:return[4,this._backing.getDecoderConfig()];case 1:return[2,null!=(r=null==(e=n.sent())?void 0:e.codec)?r:null]}})}).call(this)}},{key:"canDecode",value:function(){return(0,o._)(function(){var e,r;return(0,f._)(this,function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),[4,this._backing.getDecoderConfig()];case 1:if(!(e=n.sent()))return[2,!1];if(r=this._backing.getCodec(),(0,g.assert)(null!==r),m.customVideoDecoders.some(function(n){return n.supports(r,e)}))return[2,!0];if("undefined"==typeof VideoDecoder)return[2,!1];return[4,VideoDecoder.isConfigSupported(e)];case 2:return[2,!0===n.sent().supported];case 3:return console.error("Error during decodability check:",n.sent()),[2,!1];case 4:return[2]}})}).call(this)}},{key:"determinePacketType",value:function(e){return(0,o._)(function(){var r;return(0,f._)(this,function(n){switch(n.label){case 0:if(!(e instanceof b.EncodedPacket))throw TypeError("packet must be an EncodedPacket.");if(e.isMetadataOnly)throw TypeError("packet must not be metadata-only to determine its type.");if(null===this.codec)return[2,null];return[4,this.getDecoderConfig()];case 1:return r=n.sent(),(0,g.assert)(r),[2,(0,h.determineVideoPacketType)(this.codec,r,e.data)]}})}).call(this)}}]),r}(k),y=function(e){"use strict";function r(e,n){var a;return(0,u._)(this,r),(a=(0,c._)(this,r,[e,n]))._backing=n,a}return(0,d._)(r,e),(0,l._)(r,[{key:"type",get:function(){return"audio"}},{key:"codec",get:function(){return this._backing.getCodec()}},{key:"numberOfChannels",get:function(){return this._backing.getNumberOfChannels()}},{key:"sampleRate",get:function(){return this._backing.getSampleRate()}},{key:"getDecoderConfig",value:function(){return this._backing.getDecoderConfig()}},{key:"getCodecParameterString",value:function(){return(0,o._)(function(){var e,r;return(0,f._)(this,function(n){switch(n.label){case 0:return[4,this._backing.getDecoderConfig()];case 1:return[2,null!=(r=null==(e=n.sent())?void 0:e.codec)?r:null]}})}).call(this)}},{key:"canDecode",value:function(){return(0,o._)(function(){var e,r;return(0,f._)(this,function(n){switch(n.label){case 0:return n.trys.push([0,5,,6]),[4,this._backing.getDecoderConfig()];case 1:if(!(e=n.sent()))return[2,!1];if(r=this._backing.getCodec(),(0,g.assert)(null!==r),m.customAudioDecoders.some(function(n){return n.supports(r,e)}))return[2,!0];if(!e.codec.startsWith("pcm-"))return[3,2];return[2,!0];case 2:if("undefined"==typeof AudioDecoder)return[2,!1];return[4,AudioDecoder.isConfigSupported(e)];case 3:return[2,!0===n.sent().supported];case 4:return[3,6];case 5:return console.error("Error during decodability check:",n.sent()),[2,!1];case 6:return[2]}})}).call(this)}},{key:"determinePacketType",value:function(e){return(0,o._)(function(){return(0,f._)(this,function(r){if(!(e instanceof b.EncodedPacket))throw TypeError("packet must be an EncodedPacket.");return null===this.codec?[2,null]:[2,"key"]})}).call(this)}}]),r}(k)},{"@swc/helpers/cjs/_async_iterator.cjs":"f3IhJ","@swc/helpers/cjs/_async_to_generator.cjs":"cZn0e","@swc/helpers/cjs/_call_super.cjs":"clpdF","@swc/helpers/cjs/_class_call_check.cjs":"4Uf9M","@swc/helpers/cjs/_create_class.cjs":"igUuK","@swc/helpers/cjs/_inherits.cjs":"jtSwf","@swc/helpers/cjs/_ts_generator.cjs":"eltGh","./codec-data.js":"kWTYV","./custom-coder.js":"hAl48","./media-sink.js":"k0V9R","./misc.js":"j7iGm","./packet.js":"QfqGG","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],hAl48:[function(e,r,n,a){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(n),i.export(n,"CustomVideoDecoder",function(){return c}),i.export(n,"CustomAudioDecoder",function(){return u}),i.export(n,"CustomVideoEncoder",function(){return l}),i.export(n,"CustomAudioEncoder",function(){return d}),i.export(n,"customVideoDecoders",function(){return f}),i.export(n,"customAudioDecoders",function(){return h}),i.export(n,"customVideoEncoders",function(){return m}),i.export(n,"customAudioEncoders",function(){return p}),i.export(n,"registerDecoder",function(){return g}),i.export(n,"registerEncoder",function(){return b});var s=e("@swc/helpers/cjs/_class_call_check.cjs"),o=e("@swc/helpers/cjs/_create_class.cjs"),c=function(){"use strict";function e(){(0,s._)(this,e)}return(0,o._)(e,null,[{key:"supports",value:function(e,r){return!1}}]),e}(),u=function(){"use strict";function e(){(0,s._)(this,e)}return(0,o._)(e,null,[{key:"supports",value:function(e,r){return!1}}]),e}(),l=function(){"use strict";function e(){(0,s._)(this,e)}return(0,o._)(e,null,[{key:"supports",value:function(e,r){return!1}}]),e}(),d=function(){"use strict";function e(){(0,s._)(this,e)}return(0,o._)(e,null,[{key:"supports",value:function(e,r){return!1}}]),e}(),f=[],h=[],m=[],p=[],g=function(e){if(e.prototype instanceof c){if(f.includes(e))return void console.warn("Video decoder already registered.");f.push(e)}else if(e.prototype instanceof u){if(h.includes(e))return void console.warn("Audio decoder already registered.");h.push(e)}else throw TypeError("Decoder must be a CustomVideoDecoder or CustomAudioDecoder.")},b=function(e){if(e.prototype instanceof l){if(m.includes(e))return void console.warn("Video encoder already registered.");m.push(e)}else if(e.prototype instanceof d){if(p.includes(e))return void console.warn("Audio encoder already registered.");p.push(e)}else throw TypeError("Encoder must be a CustomVideoEncoder or CustomAudioEncoder.")}},{"@swc/helpers/cjs/_class_call_check.cjs":"4Uf9M","@swc/helpers/cjs/_create_class.cjs":"igUuK","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],k0V9R:[function(e,r,n,a){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(n),i.export(n,"EncodedPacketSink",function(){return A}),i.export(n,"BaseMediaSampleSink",function(){return M}),i.export(n,"VideoSampleSink",function(){return U}),i.export(n,"CanvasSink",function(){return O}),i.export(n,"AudioSampleSink",function(){return z}),i.export(n,"AudioBufferSink",function(){return V});var s=e("@swc/helpers/cjs/_async_iterator.cjs"),o=e("@swc/helpers/cjs/_async_to_generator.cjs"),c=e("@swc/helpers/cjs/_call_super.cjs"),u=e("@swc/helpers/cjs/_class_call_check.cjs"),l=e("@swc/helpers/cjs/_create_class.cjs"),d=e("@swc/helpers/cjs/_define_property.cjs"),f=e("@swc/helpers/cjs/_inherits.cjs"),h=e("@swc/helpers/cjs/_object_spread.cjs"),m=e("@swc/helpers/cjs/_object_spread_props.cjs"),p=e("@swc/helpers/cjs/_sliced_to_array.cjs"),g=e("@swc/helpers/cjs/_type_of.cjs"),b=e("@swc/helpers/cjs/_ts_generator.cjs"),k=e("./codec.js"),_=e("./codec-data.js"),y=e("./custom-coder.js"),w=e("./input.js"),S=e("./input-track.js"),T=e("./misc.js"),x=e("./packet.js"),I=e("./pcm.js"),E=e("./sample.js"),j=function(e){if(!e||(void 0===e?"undefined":(0,g._)(e))!=="object")throw TypeError("options must be an object.");if(void 0!==e.metadataOnly&&"boolean"!=typeof e.metadataOnly)throw TypeError("options.metadataOnly, when defined, must be a boolean.");if(void 0!==e.verifyKeyPackets&&"boolean"!=typeof e.verifyKeyPackets)throw TypeError("options.verifyKeyPackets, when defined, must be a boolean.");if(e.verifyKeyPackets&&e.metadataOnly)throw TypeError("options.verifyKeyPackets and options.metadataOnly cannot be enabled together.")},P=function(e){if(!(0,T.isNumber)(e))throw TypeError("timestamp must be a number.")},C=function(e,r,n){return n.verifyKeyPackets?r.then(function(r){return(0,o._)(function(){var n;return(0,b._)(this,function(a){switch(a.label){case 0:if(!r||"delta"===r.type)return[2,r];return[4,e.determinePacketType(r)];case 1:return(n=a.sent())&&(r.type=n),[2,r]}})})()}):r},A=function(){"use strict";function e(r){if((0,u._)(this,e),!(r instanceof S.InputTrack))throw TypeError("track must be an InputTrack.");this._track=r}return(0,l._)(e,[{key:"getFirstPacket",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(j(e),this._track.input._disposed)throw new(0,w.InputDisposedError);return C(this._track,this._track._backing.getFirstPacket(e),e)}},{key:"getPacket",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(P(e),j(r),this._track.input._disposed)throw new(0,w.InputDisposedError);return C(this._track,this._track._backing.getPacket(e,r),r)}},{key:"getNextPacket",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(e instanceof x.EncodedPacket))throw TypeError("packet must be an EncodedPacket.");if(j(r),this._track.input._disposed)throw new(0,w.InputDisposedError);return C(this._track,this._track._backing.getNextPacket(e,r),r)}},{key:"getKeyPacket",value:function(e){return(0,o._)(function(e){var r,n,a=arguments;return(0,b._)(this,function(i){switch(i.label){case 0:if(r=a.length>1&&void 0!==a[1]?a[1]:{},P(e),j(r),this._track.input._disposed)throw new(0,w.InputDisposedError);if(!r.verifyKeyPackets)return[2,this._track._backing.getKeyPacket(e,r)];return[4,this._track._backing.getKeyPacket(e,r)];case 1:if(!(n=i.sent()))return[2,n];return(0,T.assert)("key"===n.type),[4,this._track.determinePacketType(n)];case 2:if("delta"===i.sent())return[2,this.getKeyPacket(n.timestamp-1/this._track.timeResolution,r)];return[2,n]}})}).apply(this,arguments)}},{key:"getNextKeyPacket",value:function(e){return(0,o._)(function(e){var r,n,a=arguments;return(0,b._)(this,function(i){switch(i.label){case 0:if(r=a.length>1&&void 0!==a[1]?a[1]:{},!(e instanceof x.EncodedPacket))throw TypeError("packet must be an EncodedPacket.");if(j(r),this._track.input._disposed)throw new(0,w.InputDisposedError);if(!r.verifyKeyPackets)return[2,this._track._backing.getNextKeyPacket(e,r)];return[4,this._track._backing.getNextKeyPacket(e,r)];case 1:if(!(n=i.sent()))return[2,n];return(0,T.assert)("key"===n.type),[4,this._track.determinePacketType(n)];case 2:if("delta"===i.sent())return[2,this.getNextKeyPacket(n,r)];return[2,n]}})}).apply(this,arguments)}},{key:"packets",value:function(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(void 0!==e&&!(e instanceof x.EncodedPacket))throw TypeError("startPacket must be an EncodedPacket.");if(void 0!==e&&e.isMetadataOnly&&!(null==n?void 0:n.metadataOnly))throw TypeError("startPacket can only be metadata-only if options.metadataOnly is enabled.");if(void 0!==r&&!(r instanceof x.EncodedPacket))throw TypeError("endPacket must be an EncodedPacket.");if(j(n),this._track.input._disposed)throw new(0,w.InputDisposedError);var a=[],i=(0,T.promiseWithResolvers)(),s=i.promise,c=i.resolve,u=(0,T.promiseWithResolvers)(),l=u.promise,f=u.resolve,h=!1,m=!1,p=null,g=[];(0,o._)(function(){var i,o,u,d;return(0,b._)(this,function(p){switch(p.label){case 0:if(null==e)return[3,1];return o=e,[3,3];case 1:return[4,this.getFirstPacket(n)];case 2:o=p.sent(),p.label=3;case 3:i=o,p.label=4;case 4:if(!(i&&!m&&!this._track.input._disposed)||r&&i.sequenceNumber>=(null==r?void 0:r.sequenceNumber))return[3,8];if(!(a.length>Math.max(2,g.length)))return[3,6];return l=(u=(0,T.promiseWithResolvers)()).promise,f=u.resolve,[4,l];case 5:return p.sent(),[3,4];case 6:return a.push(i),c(),s=(d=(0,T.promiseWithResolvers)()).promise,c=d.resolve,[4,this.getNextPacket(i,n)];case 7:return i=p.sent(),[3,4];case 8:return h=!0,c(),[2]}})}).call(this).catch(function(e){p||(p=e,c())});var k=this._track;return(0,d._)({next:function(){return(0,o._)(function(){var e,r;return(0,b._)(this,function(n){switch(n.label){case 0:if(!k.input._disposed)return[3,1];throw new(0,w.InputDisposedError);case 1:if(!m)return[3,2];return[2,{value:void 0,done:!0}];case 2:if(!p)return[3,3];throw p;case 3:if(!(a.length>0))return[3,4];for(e=a.shift(),r=performance.now(),g.push(r);g.length>0&&r-g[0]>=1e3;)g.shift();return f(),[2,{value:e,done:!1}];case 4:if(!h)return[3,5];return[2,{value:void 0,done:!0}];case 5:return[4,s];case 6:n.sent(),n.label=7;case 7:return[3,0];case 8:return[2]}})})()},return:function(){return(0,o._)(function(){return(0,b._)(this,function(e){return m=!0,f(),c(),[2,{value:void 0,done:!0}]})})()},throw:function(e){return(0,o._)(function(){return(0,b._)(this,function(r){throw e})})()}},Symbol.asyncIterator,function(){return this})}}]),e}(),B=function e(r,n){"use strict";(0,u._)(this,e),this.onSample=r,this.onError=n},M=function(){"use strict";function e(){(0,u._)(this,e)}return(0,l._)(e,[{key:"mediaSamplesInRange",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1/0;P(e),P(r);var n=[],a=!1,i=null,s=(0,T.promiseWithResolvers)(),c=s.promise,u=s.resolve,l=(0,T.promiseWithResolvers)(),f=l.promise,h=l.resolve,m=!1,p=!1,g=!1,k=null;(0,o._)(function(){var s,o,l,d,_,y,w,S,x,I,E,j,P,C,A,B;return(0,b._)(this,function(b){switch(b.label){case 0:return s=Error(),[4,this._createDecoder(function(s){if(h(),s.timestamp>=r&&(p=!0),p)return void s.close();if(i&&(s.timestamp>e?(n.push(i),a=!0):i.close()),s.timestamp>=e&&(n.push(s),a=!0),i=a?null:s,n.length>0){var o;u(),c=(o=(0,T.promiseWithResolvers)()).promise,u=o.resolve}},function(e){k||(e.stack=s.stack,k=e,u())})];case 1:return o=b.sent(),[4,(l=this._createPacketSink()).getKeyPacket(e,{verifyKeyPackets:!0})];case 2:if(null==(d=b.sent()))return[3,3];return y=d,[3,5];case 3:return[4,l.getFirstPacket()];case 4:y=b.sent(),b.label=5;case 5:if(w=_=y,S=void 0,!(r<1/0))return[3,12];return[4,l.getPacket(r)];case 6:if(x=b.sent())return[3,7];return E=null,[3,11];case 7:if("key"!==x.type||x.timestamp!==r)return[3,8];return j=x,[3,10];case 8:return[4,l.getNextKeyPacket(x,{verifyKeyPackets:!0})];case 9:j=b.sent(),b.label=10;case 10:E=j,b.label=11;case 11:(I=E)&&(S=I),b.label=12;case 12:return[4,(P=l.packets(null!=_?_:void 0,S)).next()];case 13:b.sent(),b.label=14;case 14:if(!(w&&!p&&!this._track.input._disposed))return[3,18];if(C=D(n.length),!(n.length+o.getDecodeQueueSize()>C))return[3,16];return f=(A=(0,T.promiseWithResolvers)()).promise,h=A.resolve,[4,f];case 15:return b.sent(),[3,14];case 16:return o.decode(w),[4,P.next()];case 17:if((B=b.sent()).done)return[3,18];return w=B.value,[3,14];case 18:return[4,P.return()];case 19:if(b.sent(),!(!g&&!this._track.input._disposed))return[3,21];return[4,o.flush()];case 20:b.sent(),b.label=21;case 21:return o.close(),!a&&i&&n.push(i),m=!0,u(),[2]}})}).call(this).catch(function(e){k||(k=e,u())});var _=this._track,y=function(){null==i||i.close();var e=!0,r=!1,a=void 0;try{for(var s,o=n[Symbol.iterator]();!(e=(s=o.next()).done);e=!0)s.value.close()}catch(e){r=!0,a=e}finally{try{e||null==o.return||o.return()}finally{if(r)throw a}}};return(0,d._)({next:function(){return(0,o._)(function(){var e;return(0,b._)(this,function(r){switch(r.label){case 0:if(!_.input._disposed)return[3,1];throw y(),new(0,w.InputDisposedError);case 1:if(!g)return[3,2];return[2,{value:void 0,done:!0}];case 2:if(!k)return[3,3];throw y(),k;case 3:if(!(n.length>0))return[3,4];return e=n.shift(),h(),[2,{value:e,done:!1}];case 4:if(m)return[3,6];return[4,c];case 5:return r.sent(),[3,7];case 6:return[2,{value:void 0,done:!0}];case 7:return[3,0];case 8:return[2]}})})()},return:function(){return(0,o._)(function(){return(0,b._)(this,function(e){return g=!0,p=!0,h(),u(),y(),[2,{value:void 0,done:!0}]})})()},throw:function(e){return(0,o._)(function(){return(0,b._)(this,function(r){throw e})})()}},Symbol.asyncIterator,function(){return this})}},{key:"mediaSamplesAtTimestamps",value:function(e){(0,T.validateAnyIterable)(e);var r=(0,T.toAsyncIterator)(e),n=[],a=[],i=(0,T.promiseWithResolvers)(),c=i.promise,u=i.resolve,l=(0,T.promiseWithResolvers)(),f=l.promise,h=l.resolve,m=!1,p=!1,g=null,k=function(e){var r;a.push(e),u(),c=(r=(0,T.promiseWithResolvers)()).promise,u=r.resolve};(0,o._)(function(){var e,i,c,l,d,_,y,w,S,x,I,E,j,C,A,B,M,F;return(0,b._)(this,function(R){switch(R.label){case 0:return e=Error(),[4,this._createDecoder(function(e){if(h(),p)return void e.close();for(var r=0;n.length>0&&e.timestamp-n[0]>-1e-10;)r++,n.shift();if(r>0)for(var a=0;ar&&!p))return[3,4];return f=(n=(0,T.promiseWithResolvers)()).promise,h=n.resolve,[4,f];case 3:return o.sent(),[3,2];case 4:if(p)return[3,6];return[4,c.getNextPacket(e)];case 5:return s=o.sent(),(0,T.assert)(s),i.decode(s),e=s,[3,1];case 6:return _=-1,[2]}})})()},w=function(){return(0,o._)(function(){var e;return(0,b._)(this,function(r){switch(r.label){case 0:return[4,i.flush()];case 1:for(r.sent(),e=0;e0))return[3,4];return e=a.shift(),(0,T.assert)(void 0!==e),h(),[2,{value:e,done:!1}];case 4:if(m)return[3,6];return[4,c];case 5:return r.sent(),[3,7];case 6:return[2,{value:void 0,done:!0}];case 7:return[3,0];case 8:return[2]}})})()},return:function(){return(0,o._)(function(){return(0,b._)(this,function(e){return p=!0,h(),u(),y(),[2,{value:void 0,done:!0}]})})()},throw:function(e){return(0,o._)(function(){return(0,b._)(this,function(r){throw e})})()}},Symbol.asyncIterator,function(){return this})}}]),e}(),D=function(e){return 0===e?40:8},F=function(e){"use strict";function r(e,n,a,i,s,o){(0,u._)(this,r),(l=(0,c._)(this,r,[e,n])).codec=a,l.decoderConfig=i,l.rotation=s,l.timeResolution=o,l.decoder=null,l.customDecoder=null,l.customDecoderCallSerializer=new(0,T.CallSerializer),l.customDecoderQueueSize=0,l.inputTimestamps=[],l.sampleQueue=[],l.currentPacketIndex=0,l.raslSkipped=!1,l.alphaDecoder=null,l.alphaHadKeyframe=!1,l.colorQueue=[],l.alphaQueue=[],l.merger=null,l.mergerCreationFailed=!1,l.decodedAlphaChunkCount=0,l.alphaDecoderQueueSize=0,l.nullAlphaFrameQueue=[],l.currentAlphaPacketIndex=0,l.alphaRaslSkipped=!1;var l,d=y.customVideoDecoders.find(function(e){return e.supports(a,i)});if(d)l.customDecoder=new d,l.customDecoder.codec=a,l.customDecoder.config=i,l.customDecoder.onSample=function(e){if(!(e instanceof E.VideoSample))throw TypeError("The argument passed to onSample must be a VideoSample.");l.finalizeAndEmitSample(e)},l.customDecoderCallSerializer.call(function(){return l.customDecoder.init()});else{var f=function(e){if(l.alphaQueue.length>0){var r=l.alphaQueue.shift();(0,T.assert)(void 0!==r),l.mergeAlpha(e,r)}else l.colorQueue.push(e)};if("avc"===a&&l.decoderConfig.description&&(0,T.isChromium)()){var p=(0,_.deserializeAvcDecoderConfigurationRecord)((0,T.toUint8Array)(l.decoderConfig.description));if(p&&p.sequenceParameterSets.length>0){var g=(0,_.parseAvcSps)(p.sequenceParameterSets[0]);g&&0===g.frameMbsOnlyFlag&&(l.decoderConfig=(0,m._)((0,h._)({},l.decoderConfig),{hardwareAcceleration:"prefer-software"}))}}l.decoder=new VideoDecoder({output:function(e){try{f(e)}catch(e){l.onError(e)}},error:n}),l.decoder.configure(l.decoderConfig)}return l}return(0,f._)(r,e),(0,l._)(r,[{key:"getDecodeQueueSize",value:function(){var e,r;return this.customDecoder?this.customDecoderQueueSize:((0,T.assert)(this.decoder),Math.max(this.decoder.decodeQueueSize,null!=(r=null==(e=this.alphaDecoder)?void 0:e.decodeQueueSize)?r:0))}},{key:"decode",value:function(e){var r=this;if("hevc"===this.codec&&this.currentPacketIndex>0&&!this.raslSkipped){if(this.hasHevcRaslPicture(e.data))return;this.raslSkipped=!0}this.currentPacketIndex++,this.customDecoder?(this.customDecoderQueueSize++,this.customDecoderCallSerializer.call(function(){return r.customDecoder.decode(e)}).then(function(){return r.customDecoderQueueSize--})):((0,T.assert)(this.decoder),(0,T.isWebKit)()||(0,T.insertSorted)(this.inputTimestamps,e.timestamp,function(e){return e}),this.decoder.decode(e.toEncodedVideoChunk()),this.decodeAlphaData(e))}},{key:"decodeAlphaData",value:function(e){var r=this;if(!e.sideData.alpha||this.mergerCreationFailed)return void this.pushNullAlphaFrame();if(!this.merger)try{this.merger=new R}catch(r){console.error("Due to an error, only color data will be decoded.",r),this.mergerCreationFailed=!0,this.decodeAlphaData(e);return}if(!this.alphaDecoder){var n=function(e){if(r.alphaDecoderQueueSize--,r.colorQueue.length>0){var n=r.colorQueue.shift();(0,T.assert)(void 0!==n),r.mergeAlpha(n,e)}else r.alphaQueue.push(e);for(r.decodedAlphaChunkCount++;r.nullAlphaFrameQueue.length>0&&r.nullAlphaFrameQueue[0]===r.decodedAlphaChunkCount;)if(r.nullAlphaFrameQueue.shift(),r.colorQueue.length>0){var a=r.colorQueue.shift();(0,T.assert)(void 0!==a),r.mergeAlpha(a,null)}else r.alphaQueue.push(null)};this.alphaDecoder=new VideoDecoder({output:function(e){try{n(e)}catch(e){r.onError(e)}},error:this.onError}),this.alphaDecoder.configure(this.decoderConfig)}var a=(0,_.determineVideoPacketType)(this.codec,this.decoderConfig,e.sideData.alpha);if(this.alphaHadKeyframe||(this.alphaHadKeyframe="key"===a),this.alphaHadKeyframe){if("hevc"===this.codec&&this.currentAlphaPacketIndex>0&&!this.alphaRaslSkipped){if(this.hasHevcRaslPicture(e.sideData.alpha))return void this.pushNullAlphaFrame();this.alphaRaslSkipped=!0}this.currentAlphaPacketIndex++,this.alphaDecoder.decode(e.alphaToEncodedVideoChunk(null!=a?a:e.type)),this.alphaDecoderQueueSize++}else this.pushNullAlphaFrame()}},{key:"pushNullAlphaFrame",value:function(){0===this.alphaDecoderQueueSize?this.alphaQueue.push(null):this.nullAlphaFrameQueue.push(this.decodedAlphaChunkCount+this.alphaDecoderQueueSize)}},{key:"hasHevcRaslPicture",value:function(e){return(0,_.extractHevcNalUnits)(e,this.decoderConfig).some(function(e){var r=(0,_.extractNalUnitTypeForHevc)(e);return r===_.HevcNalUnitType.RASL_N||r===_.HevcNalUnitType.RASL_R})}},{key:"sampleHandler",value:function(e){if((0,T.isWebKit)()){if(this.sampleQueue.length>0&&e.timestamp>=(0,T.last)(this.sampleQueue).timestamp){var r=!0,n=!1,a=void 0;try{for(var i,s=this.sampleQueue[Symbol.iterator]();!(r=(i=s.next()).done);r=!0){var o=i.value;this.finalizeAndEmitSample(o)}}catch(e){n=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(n)throw a}}this.sampleQueue.length=0}(0,T.insertSorted)(this.sampleQueue,e,function(e){return e.timestamp})}else{var c=this.inputTimestamps.shift();(0,T.assert)(void 0!==c),e.setTimestamp(c),this.finalizeAndEmitSample(e)}}},{key:"finalizeAndEmitSample",value:function(e){e.setTimestamp(Math.round(e.timestamp*this.timeResolution)/this.timeResolution),e.setDuration(Math.round(e.duration*this.timeResolution)/this.timeResolution),e.setRotation(this.rotation),this.onSample(e)}},{key:"mergeAlpha",value:function(e,r){if(!r){var n,a=new(0,E.VideoSample)(e);this.sampleHandler(a);return}(0,T.assert)(this.merger),this.merger.update(e,r),e.close(),r.close();var i=new VideoFrame(this.merger.canvas,{timestamp:e.timestamp,duration:null!=(n=e.duration)?n:void 0}),s=new(0,E.VideoSample)(i);this.sampleHandler(s)}},{key:"flush",value:function(){return(0,o._)(function(){var e,r,n,a,i,s,o,c;return(0,b._)(this,function(u){switch(u.label){case 0:if(e=this,!this.customDecoder)return[3,2];return[4,this.customDecoderCallSerializer.call(function(){return e.customDecoder.flush()})];case 1:return u.sent(),[3,4];case 2:return(0,T.assert)(this.decoder),[4,Promise.all([this.decoder.flush(),null==(r=this.alphaDecoder)?void 0:r.flush()])];case 3:u.sent(),this.colorQueue.forEach(function(e){return e.close()}),this.colorQueue.length=0,this.alphaQueue.forEach(function(e){return null==e?void 0:e.close()}),this.alphaQueue.length=0,this.alphaHadKeyframe=!1,this.decodedAlphaChunkCount=0,this.alphaDecoderQueueSize=0,this.nullAlphaFrameQueue.length=0,this.currentAlphaPacketIndex=0,this.alphaRaslSkipped=!1,u.label=4;case 4:if((0,T.isWebKit)()){n=!0,a=!1,i=void 0;try{for(s=this.sampleQueue[Symbol.iterator]();!(n=(o=s.next()).done);n=!0)c=o.value,this.finalizeAndEmitSample(c)}catch(e){a=!0,i=e}finally{try{n||null==s.return||s.return()}finally{if(a)throw i}}this.sampleQueue.length=0}return this.currentPacketIndex=0,this.raslSkipped=!1,[2]}})}).call(this)}},{key:"close",value:function(){var e=this;this.customDecoder?this.customDecoderCallSerializer.call(function(){return e.customDecoder.close()}):((0,T.assert)(this.decoder),this.decoder.close(),null==(i=this.alphaDecoder)||i.close(),this.colorQueue.forEach(function(e){return e.close()}),this.colorQueue.length=0,this.alphaQueue.forEach(function(e){return null==e?void 0:e.close()}),this.alphaQueue.length=0,null==(s=this.merger)||s.close());var r=!0,n=!1,a=void 0;try{for(var i,s,o,c=this.sampleQueue[Symbol.iterator]();!(r=(o=c.next()).done);r=!0)o.value.close()}catch(e){n=!0,a=e}finally{try{r||null==c.return||c.return()}finally{if(n)throw a}}this.sampleQueue.length=0}}]),r}(B),R=function(){"use strict";function e(){(0,u._)(this,e),"undefined"!=typeof OffscreenCanvas?this.canvas=new OffscreenCanvas(300,150):this.canvas=document.createElement("canvas");var r=this.canvas.getContext("webgl2",{premultipliedAlpha:!1});if(!r)throw Error("Couldn't acquire WebGL 2 context.");this.gl=r,this.program=this.createProgram(),this.vao=this.createVAO(),this.colorTexture=this.createTexture(),this.alphaTexture=this.createTexture(),this.gl.useProgram(this.program),this.gl.uniform1i(this.gl.getUniformLocation(this.program,"u_colorTexture"),0),this.gl.uniform1i(this.gl.getUniformLocation(this.program,"u_alphaTexture"),1)}return(0,l._)(e,[{key:"createProgram",value:function(){var e=this.createShader(this.gl.VERTEX_SHADER,"#version 300 es\n in vec2 a_position;\n in vec2 a_texCoord;\n out vec2 v_texCoord;\n \n void main() {\n gl_Position = vec4(a_position, 0.0, 1.0);\n v_texCoord = a_texCoord;\n }\n "),r=this.createShader(this.gl.FRAGMENT_SHADER,"#version 300 es\n precision highp float;\n \n uniform sampler2D u_colorTexture;\n uniform sampler2D u_alphaTexture;\n in vec2 v_texCoord;\n out vec4 fragColor;\n \n void main() {\n vec3 color = texture(u_colorTexture, v_texCoord).rgb;\n float alpha = texture(u_alphaTexture, v_texCoord).r;\n fragColor = vec4(color, alpha);\n }\n "),n=this.gl.createProgram();return this.gl.attachShader(n,e),this.gl.attachShader(n,r),this.gl.linkProgram(n),n}},{key:"createShader",value:function(e,r){var n=this.gl.createShader(e);return this.gl.shaderSource(n,r),this.gl.compileShader(n),n}},{key:"createVAO",value:function(){var e=this.gl.createVertexArray();this.gl.bindVertexArray(e);var r=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,1,1,1,0]),n=this.gl.createBuffer();this.gl.bindBuffer(this.gl.ARRAY_BUFFER,n),this.gl.bufferData(this.gl.ARRAY_BUFFER,r,this.gl.STATIC_DRAW);var a=this.gl.getAttribLocation(this.program,"a_position"),i=this.gl.getAttribLocation(this.program,"a_texCoord");return this.gl.enableVertexAttribArray(a),this.gl.vertexAttribPointer(a,2,this.gl.FLOAT,!1,16,0),this.gl.enableVertexAttribArray(i),this.gl.vertexAttribPointer(i,2,this.gl.FLOAT,!1,16,8),e}},{key:"createTexture",value:function(){var e=this.gl.createTexture();return this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),e}},{key:"update",value:function(e,r){(e.displayWidth!==this.canvas.width||e.displayHeight!==this.canvas.height)&&(this.canvas.width=e.displayWidth,this.canvas.height=e.displayHeight),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,this.colorTexture),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,e),this.gl.activeTexture(this.gl.TEXTURE1),this.gl.bindTexture(this.gl.TEXTURE_2D,this.alphaTexture),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,r),this.gl.viewport(0,0,this.canvas.width,this.canvas.height),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this.gl.bindVertexArray(this.vao),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4)}},{key:"close",value:function(){var e;null==(e=this.gl.getExtension("WEBGL_lose_context"))||e.loseContext(),this.gl=null}}]),e}(),U=function(e){"use strict";function r(e){var n;if((0,u._)(this,r),!(e instanceof S.InputVideoTrack))throw TypeError("videoTrack must be an InputVideoTrack.");return(n=(0,c._)(this,r))._track=e,n}return(0,f._)(r,e),(0,l._)(r,[{key:"_createDecoder",value:function(e,r){return(0,o._)(function(){var n,a,i,s;return(0,b._)(this,function(o){switch(o.label){case 0:return[4,this._track.canDecode()];case 1:if(!o.sent())throw Error("This video track cannot be decoded by this browser. Make sure to check decodability before using a track.");return n=this._track.codec,a=this._track.rotation,[4,this._track.getDecoderConfig()];case 2:return i=o.sent(),s=this._track.timeResolution,(0,T.assert)(n&&i),[2,new F(e,r,n,i,a,s)]}})}).call(this)}},{key:"_createPacketSink",value:function(){return new A(this._track)}},{key:"getSample",value:function(e){return(0,o._)(function(){var r,n,a,i,o,c;return(0,b._)(this,function(u){switch(u.label){case 0:P(e),r=!1,n=!1,u.label=1;case 1:u.trys.push([1,6,7,12]),i=(0,s._)(this.mediaSamplesAtTimestamps([e])),u.label=2;case 2:return[4,i.next()];case 3:if(!(r=!(o=u.sent()).done))return[3,5];return[2,o.value];case 4:return r=!1,[3,2];case 5:return[3,12];case 6:return c=u.sent(),n=!0,a=c,[3,12];case 7:if(u.trys.push([7,,10,11]),!(r&&null!=i.return))return[3,9];return[4,i.return()];case 8:u.sent(),u.label=9;case 9:return[3,11];case 10:if(n)throw a;return[7];case 11:return[7];case 12:throw Error("Internal error: Iterator returned nothing.")}})}).call(this)}},{key:"samples",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1/0;return this.mediaSamplesInRange(e,r)}},{key:"samplesAtTimestamps",value:function(e){return this.mediaSamplesAtTimestamps(e)}}]),r}(M),O=function(){"use strict";function e(r){var n,a,i,s,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if((0,u._)(this,e),this._nextCanvasIndex=0,!(r instanceof S.InputVideoTrack))throw TypeError("videoTrack must be an InputVideoTrack.");if(o&&(void 0===o?"undefined":(0,g._)(o))!=="object")throw TypeError("options must be an object.");if(void 0!==o.alpha&&"boolean"!=typeof o.alpha)throw TypeError("options.alpha, when provided, must be a boolean.");if(void 0!==o.width&&(!Number.isInteger(o.width)||o.width<=0))throw TypeError("options.width, when defined, must be a positive integer.");if(void 0!==o.height&&(!Number.isInteger(o.height)||o.height<=0))throw TypeError("options.height, when defined, must be a positive integer.");if(void 0!==o.fit&&!["fill","contain","cover"].includes(o.fit))throw TypeError('options.fit, when provided, must be one of "fill", "contain", or "cover".');if(void 0!==o.width&&void 0!==o.height&&void 0===o.fit)throw TypeError("When both options.width and options.height are provided, options.fit must also be provided.");if(void 0!==o.rotation&&![0,90,180,270].includes(o.rotation))throw TypeError("options.rotation, when provided, must be 0, 90, 180 or 270.");if(void 0!==o.crop&&(0,E.validateCropRectangle)(o.crop,"options."),void 0!==o.poolSize&&("number"!=typeof o.poolSize||!Number.isInteger(o.poolSize)||o.poolSize<0))throw TypeError("poolSize must be a non-negative integer.");var c=null!=(n=o.rotation)?n:r.rotation,l=(0,p._)(c%180==0?[r.codedWidth,r.codedHeight]:[r.codedHeight,r.codedWidth],2),d=l[0],f=l[1],h=o.crop;h&&(0,E.clampCropRectangle)(h,d,f);var m=(0,p._)(h?[h.width,h.height]:[d,f],2),b=m[0],k=m[1],_=b/k;void 0!==o.width&&void 0===o.height?k=Math.round((b=o.width)/_):void 0===o.width&&void 0!==o.height?b=Math.round((k=o.height)*_):void 0!==o.width&&void 0!==o.height&&(b=o.width,k=o.height),this._videoTrack=r,this._alpha=null!=(a=o.alpha)&&a,this._width=b,this._height=k,this._rotation=c,this._crop=h,this._fit=null!=(i=o.fit)?i:"fill",this._videoSampleSink=new U(r),this._canvasPool=Array.from({length:null!=(s=o.poolSize)?s:0},function(){return null})}return(0,l._)(e,[{key:"_videoSampleToWrappedCanvas",value:function(e){var r=this._canvasPool[this._nextCanvasIndex],n=!1;r||("undefined"!=typeof document?((r=document.createElement("canvas")).width=this._width,r.height=this._height):r=new OffscreenCanvas(this._width,this._height),this._canvasPool.length>0&&(this._canvasPool[this._nextCanvasIndex]=r),n=!0),this._canvasPool.length>0&&(this._nextCanvasIndex=(this._nextCanvasIndex+1)%this._canvasPool.length);var a=r.getContext("2d",{alpha:this._alpha||(0,T.isFirefox)()});(0,T.assert)(a),a.resetTransform(),n||(!this._alpha&&(0,T.isFirefox)()?(a.fillStyle="black",a.fillRect(0,0,this._width,this._height)):a.clearRect(0,0,this._width,this._height)),e.drawWithFit(a,{fit:this._fit,rotation:this._rotation,crop:this._crop});var i={canvas:r,timestamp:e.timestamp,duration:e.duration};return e.close(),i}},{key:"getCanvas",value:function(e){return(0,o._)(function(){var r;return(0,b._)(this,function(n){switch(n.label){case 0:return P(e),[4,this._videoSampleSink.getSample(e)];case 1:return[2,(r=n.sent())&&this._videoSampleToWrappedCanvas(r)]}})}).call(this)}},{key:"canvases",value:function(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1/0;return(0,T.mapAsyncGenerator)(this._videoSampleSink.samples(r,n),function(r){return e._videoSampleToWrappedCanvas(r)})}},{key:"canvasesAtTimestamps",value:function(e){var r=this;return(0,T.mapAsyncGenerator)(this._videoSampleSink.samplesAtTimestamps(e),function(e){return e&&r._videoSampleToWrappedCanvas(e)})}}]),e}(),L=function(e){"use strict";function r(e,n,a,i){(0,u._)(this,r),(s=(0,c._)(this,r,[e,n])).decoder=null,s.customDecoder=null,s.customDecoderCallSerializer=new(0,T.CallSerializer),s.customDecoderQueueSize=0,s.currentTimestamp=null;var s,o=function(r){(null===s.currentTimestamp||Math.abs(r.timestamp-s.currentTimestamp)>=r.duration)&&(s.currentTimestamp=r.timestamp);var n=s.currentTimestamp;if(s.currentTimestamp+=r.duration,0===r.numberOfFrames)return void r.close();var a=i.sampleRate;r.setTimestamp(Math.round(n*a)/a),e(r)},l=y.customAudioDecoders.find(function(e){return e.supports(a,i)});return l?(s.customDecoder=new l,s.customDecoder.codec=a,s.customDecoder.config=i,s.customDecoder.onSample=function(e){if(!(e instanceof E.AudioSample))throw TypeError("The argument passed to onSample must be an AudioSample.");o(e)},s.customDecoderCallSerializer.call(function(){return s.customDecoder.init()})):(s.decoder=new AudioDecoder({output:function(e){try{o(new(0,E.AudioSample)(e))}catch(e){s.onError(e)}},error:n}),s.decoder.configure(i)),s}return(0,f._)(r,e),(0,l._)(r,[{key:"getDecodeQueueSize",value:function(){return this.customDecoder?this.customDecoderQueueSize:((0,T.assert)(this.decoder),this.decoder.decodeQueueSize)}},{key:"decode",value:function(e){var r=this;this.customDecoder?(this.customDecoderQueueSize++,this.customDecoderCallSerializer.call(function(){return r.customDecoder.decode(e)}).then(function(){return r.customDecoderQueueSize--})):((0,T.assert)(this.decoder),this.decoder.decode(e.toEncodedAudioChunk()))}},{key:"flush",value:function(){var e=this;return this.customDecoder?this.customDecoderCallSerializer.call(function(){return e.customDecoder.flush()}):((0,T.assert)(this.decoder),this.decoder.flush())}},{key:"close",value:function(){var e=this;this.customDecoder?this.customDecoderCallSerializer.call(function(){return e.customDecoder.close()}):((0,T.assert)(this.decoder),this.decoder.close())}}]),r}(B),N=function(e){"use strict";function r(e,n,a){(0,u._)(this,r),(i=(0,c._)(this,r,[e,n])).decoderConfig=a,i.currentTimestamp=null,(0,T.assert)(k.PCM_AUDIO_CODECS.includes(a.codec)),i.codec=a.codec;var i,s=(0,k.parsePcmCodec)(i.codec),o=s.dataType,l=s.sampleSize,d=s.littleEndian;switch(i.inputSampleSize=l,l){case 1:"unsigned"===o?i.readInputValue=function(e,r){return e.getUint8(r)-128}:"signed"===o?i.readInputValue=function(e,r){return e.getInt8(r)}:"ulaw"===o?i.readInputValue=function(e,r){return(0,I.fromUlaw)(e.getUint8(r))}:"alaw"===o?i.readInputValue=function(e,r){return(0,I.fromAlaw)(e.getUint8(r))}:(0,T.assert)(!1);break;case 2:"unsigned"===o?i.readInputValue=function(e,r){return e.getUint16(r,d)-32768}:"signed"===o?i.readInputValue=function(e,r){return e.getInt16(r,d)}:(0,T.assert)(!1);break;case 3:"unsigned"===o?i.readInputValue=function(e,r){return(0,T.getUint24)(e,r,d)-8388608}:"signed"===o?i.readInputValue=function(e,r){return(0,T.getInt24)(e,r,d)}:(0,T.assert)(!1);break;case 4:"unsigned"===o?i.readInputValue=function(e,r){return e.getUint32(r,d)-0x80000000}:"signed"===o?i.readInputValue=function(e,r){return e.getInt32(r,d)}:"float"===o?i.readInputValue=function(e,r){return e.getFloat32(r,d)}:(0,T.assert)(!1);break;case 8:"float"===o?i.readInputValue=function(e,r){return e.getFloat64(r,d)}:(0,T.assert)(!1);break;default:(0,T.assertNever)(l),(0,T.assert)(!1)}switch(l){case 1:"ulaw"===o||"alaw"===o?(i.outputSampleSize=2,i.outputFormat="s16",i.writeOutputValue=function(e,r,n){return e.setInt16(r,n,!0)}):(i.outputSampleSize=1,i.outputFormat="u8",i.writeOutputValue=function(e,r,n){return e.setUint8(r,n+128)});break;case 2:i.outputSampleSize=2,i.outputFormat="s16",i.writeOutputValue=function(e,r,n){return e.setInt16(r,n,!0)};break;case 3:i.outputSampleSize=4,i.outputFormat="s32",i.writeOutputValue=function(e,r,n){return e.setInt32(r,n<<8,!0)};break;case 4:i.outputSampleSize=4,"float"===o?(i.outputFormat="f32",i.writeOutputValue=function(e,r,n){return e.setFloat32(r,n,!0)}):(i.outputFormat="s32",i.writeOutputValue=function(e,r,n){return e.setInt32(r,n,!0)});break;case 8:i.outputSampleSize=4,i.outputFormat="f32",i.writeOutputValue=function(e,r,n){return e.setFloat32(r,n,!0)};break;default:(0,T.assertNever)(l),(0,T.assert)(!1)}return i}return(0,f._)(r,e),(0,l._)(r,[{key:"getDecodeQueueSize",value:function(){return 0}},{key:"decode",value:function(e){for(var r=(0,T.toDataView)(e.data),n=e.byteLength/this.decoderConfig.numberOfChannels/this.inputSampleSize,a=new ArrayBuffer(n*this.decoderConfig.numberOfChannels*this.outputSampleSize),i=new DataView(a),s=0;s=l)&&(this.currentTimestamp=e.timestamp);var d=this.currentTimestamp;this.currentTimestamp+=l;var f=new(0,E.AudioSample)({format:this.outputFormat,data:a,numberOfChannels:this.decoderConfig.numberOfChannels,sampleRate:this.decoderConfig.sampleRate,numberOfFrames:n,timestamp:d});this.onSample(f)}},{key:"flush",value:function(){return(0,o._)(function(){return(0,b._)(this,function(e){return[2]})})()}},{key:"close",value:function(){}}]),r}(B),z=function(e){"use strict";function r(e){var n;if((0,u._)(this,r),!(e instanceof S.InputAudioTrack))throw TypeError("audioTrack must be an InputAudioTrack.");return(n=(0,c._)(this,r))._track=e,n}return(0,f._)(r,e),(0,l._)(r,[{key:"_createDecoder",value:function(e,r){return(0,o._)(function(){var n,a;return(0,b._)(this,function(i){switch(i.label){case 0:return[4,this._track.canDecode()];case 1:if(!i.sent())throw Error("This audio track cannot be decoded by this browser. Make sure to check decodability before using a track.");return n=this._track.codec,[4,this._track.getDecoderConfig()];case 2:if(a=i.sent(),(0,T.assert)(n&&a),k.PCM_AUDIO_CODECS.includes(a.codec))return[2,new N(e,r,a)];return[2,new L(e,r,n,a)]}})}).call(this)}},{key:"_createPacketSink",value:function(){return new A(this._track)}},{key:"getSample",value:function(e){return(0,o._)(function(){var r,n,a,i,o,c;return(0,b._)(this,function(u){switch(u.label){case 0:P(e),r=!1,n=!1,u.label=1;case 1:u.trys.push([1,6,7,12]),i=(0,s._)(this.mediaSamplesAtTimestamps([e])),u.label=2;case 2:return[4,i.next()];case 3:if(!(r=!(o=u.sent()).done))return[3,5];return[2,o.value];case 4:return r=!1,[3,2];case 5:return[3,12];case 6:return c=u.sent(),n=!0,a=c,[3,12];case 7:if(u.trys.push([7,,10,11]),!(r&&null!=i.return))return[3,9];return[4,i.return()];case 8:u.sent(),u.label=9;case 9:return[3,11];case 10:if(n)throw a;return[7];case 11:return[7];case 12:throw Error("Internal error: Iterator returned nothing.")}})}).call(this)}},{key:"samples",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1/0;return this.mediaSamplesInRange(e,r)}},{key:"samplesAtTimestamps",value:function(e){return this.mediaSamplesAtTimestamps(e)}}]),r}(M),V=function(){"use strict";function e(r){if((0,u._)(this,e),!(r instanceof S.InputAudioTrack))throw TypeError("audioTrack must be an InputAudioTrack.");this._audioSampleSink=new z(r)}return(0,l._)(e,[{key:"_audioSampleToWrappedArrayBuffer",value:function(e){var r={buffer:e.toAudioBuffer(),timestamp:e.timestamp,duration:e.duration};return e.close(),r}},{key:"getBuffer",value:function(e){return(0,o._)(function(){var r;return(0,b._)(this,function(n){switch(n.label){case 0:return P(e),[4,this._audioSampleSink.getSample(e)];case 1:return[2,(r=n.sent())&&this._audioSampleToWrappedArrayBuffer(r)]}})}).call(this)}},{key:"buffers",value:function(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1/0;return(0,T.mapAsyncGenerator)(this._audioSampleSink.samples(r,n),function(r){return e._audioSampleToWrappedArrayBuffer(r)})}},{key:"buffersAtTimestamps",value:function(e){var r=this;return(0,T.mapAsyncGenerator)(this._audioSampleSink.samplesAtTimestamps(e),function(e){return e&&r._audioSampleToWrappedArrayBuffer(e)})}}]),e}()},{"@swc/helpers/cjs/_async_iterator.cjs":"f3IhJ","@swc/helpers/cjs/_async_to_generator.cjs":"cZn0e","@swc/helpers/cjs/_call_super.cjs":"clpdF","@swc/helpers/cjs/_class_call_check.cjs":"4Uf9M","@swc/helpers/cjs/_create_class.cjs":"igUuK","@swc/helpers/cjs/_define_property.cjs":"ltU3W","@swc/helpers/cjs/_inherits.cjs":"jtSwf","@swc/helpers/cjs/_object_spread.cjs":"kyoEj","@swc/helpers/cjs/_object_spread_props.cjs":"3G1wX","@swc/helpers/cjs/_sliced_to_array.cjs":"gIQTH","@swc/helpers/cjs/_type_of.cjs":"iXhRw","@swc/helpers/cjs/_ts_generator.cjs":"eltGh","./codec.js":"fXWqW","./codec-data.js":"kWTYV","./custom-coder.js":"hAl48","./input.js":"3sapy","./input-track.js":"b22CJ","./misc.js":"j7iGm","./packet.js":"QfqGG","./pcm.js":"501Zr","./sample.js":"1oMH7","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],"3G1wX":[function(e,r,n,a){"use strict";n._=function(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):(function(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n.push.apply(n,a)}return n})(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))}),e}},{}],"3sapy":[function(e,r,n,a){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(n),i.export(n,"Input",function(){return k}),i.export(n,"InputDisposedError",function(){return _});var s=e("@swc/helpers/cjs/_async_to_generator.cjs"),o=e("@swc/helpers/cjs/_call_super.cjs"),c=e("@swc/helpers/cjs/_class_call_check.cjs"),u=e("@swc/helpers/cjs/_create_class.cjs"),l=e("@swc/helpers/cjs/_inherits.cjs"),d=e("@swc/helpers/cjs/_type_of.cjs"),f=e("@swc/helpers/cjs/_wrap_native_super.cjs"),h=e("@swc/helpers/cjs/_ts_generator.cjs"),m=e("./input-format.js"),p=e("./misc.js"),g=e("./reader.js"),b=e("./source.js");(0,p.polyfillSymbolDispose)();var k=function(){"use strict";function e(r){if((0,c._)(this,e),this._demuxerPromise=null,this._format=null,this._disposed=!1,!r||(void 0===r?"undefined":(0,d._)(r))!=="object")throw TypeError("options must be an object.");if(!Array.isArray(r.formats)||r.formats.some(function(e){return!(e instanceof m.InputFormat)}))throw TypeError("options.formats must be an array of InputFormat.");if(!(r.source instanceof b.Source))throw TypeError("options.source must be a Source.");if(r.source._disposed)throw Error("options.source must not be disposed.");this._formats=r.formats,this._source=r.source,this._reader=new(0,g.Reader)(r.source)}return(0,u._)(e,[{key:"disposed",get:function(){return this._disposed}},{key:"_getDemuxer",value:function(){var e;return null!=(e=this._demuxerPromise)?e:this._demuxerPromise=(0,s._)(function(){var e,r,n,a,i,s,o,c;return(0,h._)(this,function(u){switch(u.label){case 0:return e=this._reader,[4,this._source.getSizeOrNull()];case 1:e.fileSize=u.sent(),r=!0,n=!1,a=void 0,u.label=2;case 2:u.trys.push([2,7,8,9]),i=this._formats[Symbol.iterator](),u.label=3;case 3:if(r=(s=i.next()).done)return[3,6];return[4,(o=s.value)._canReadInput(this)];case 4:if(u.sent())return this._format=o,[2,o._createDemuxer(this)];u.label=5;case 5:return r=!0,[3,3];case 6:return[3,9];case 7:return c=u.sent(),n=!0,a=c,[3,9];case 8:try{r||null==i.return||i.return()}finally{if(n)throw a}return[7];case 9:throw Error("Input has an unsupported or unrecognizable format.")}})}).call(this)}},{key:"source",get:function(){return this._source}},{key:"getFormat",value:function(){return(0,s._)(function(){return(0,h._)(this,function(e){switch(e.label){case 0:return[4,this._getDemuxer()];case 1:return e.sent(),(0,p.assert)(this._format),[2,this._format]}})}).call(this)}},{key:"computeDuration",value:function(){return(0,s._)(function(){return(0,h._)(this,function(e){switch(e.label){case 0:return[4,this._getDemuxer()];case 1:return[2,e.sent().computeDuration()]}})}).call(this)}},{key:"getTracks",value:function(){return(0,s._)(function(){return(0,h._)(this,function(e){switch(e.label){case 0:return[4,this._getDemuxer()];case 1:return[2,e.sent().getTracks()]}})}).call(this)}},{key:"getVideoTracks",value:function(){return(0,s._)(function(){return(0,h._)(this,function(e){switch(e.label){case 0:return[4,this.getTracks()];case 1:return[2,e.sent().filter(function(e){return e.isVideoTrack()})]}})}).call(this)}},{key:"getAudioTracks",value:function(){return(0,s._)(function(){return(0,h._)(this,function(e){switch(e.label){case 0:return[4,this.getTracks()];case 1:return[2,e.sent().filter(function(e){return e.isAudioTrack()})]}})}).call(this)}},{key:"getPrimaryVideoTrack",value:function(){return(0,s._)(function(){var e;return(0,h._)(this,function(r){switch(r.label){case 0:return[4,this.getTracks()];case 1:return[2,null!=(e=r.sent().find(function(e){return e.isVideoTrack()}))?e:null]}})}).call(this)}},{key:"getPrimaryAudioTrack",value:function(){return(0,s._)(function(){var e;return(0,h._)(this,function(r){switch(r.label){case 0:return[4,this.getTracks()];case 1:return[2,null!=(e=r.sent().find(function(e){return e.isAudioTrack()}))?e:null]}})}).call(this)}},{key:"getMimeType",value:function(){return(0,s._)(function(){return(0,h._)(this,function(e){switch(e.label){case 0:return[4,this._getDemuxer()];case 1:return[2,e.sent().getMimeType()]}})}).call(this)}},{key:"getMetadataTags",value:function(){return(0,s._)(function(){return(0,h._)(this,function(e){switch(e.label){case 0:return[4,this._getDemuxer()];case 1:return[2,e.sent().getMetadataTags()]}})}).call(this)}},{key:"dispose",value:function(){this._disposed||(this._disposed=!0,this._source._disposed=!0,this._source._dispose())}},{key:Symbol.dispose,value:function(){this.dispose()}}]),e}(),_=function(e){"use strict";function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Input has been disposed.";return(0,c._)(this,r),(e=(0,o._)(this,r,[n])).name="InputDisposedError",e}return(0,l._)(r,e),r}((0,f._)(Error))},{"@swc/helpers/cjs/_async_to_generator.cjs":"cZn0e","@swc/helpers/cjs/_call_super.cjs":"clpdF","@swc/helpers/cjs/_class_call_check.cjs":"4Uf9M","@swc/helpers/cjs/_create_class.cjs":"igUuK","@swc/helpers/cjs/_inherits.cjs":"jtSwf","@swc/helpers/cjs/_type_of.cjs":"iXhRw","@swc/helpers/cjs/_wrap_native_super.cjs":"j8pRR","@swc/helpers/cjs/_ts_generator.cjs":"eltGh","./input-format.js":"1jhAI","./misc.js":"j7iGm","./reader.js":"8KRfO","./source.js":"7vKle","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],j8pRR:[function(e,r,n,a){"use strict";var i=e("c8857d56f4968279"),s=e("2ed7bdf1701f2d07"),o=e("5c5ad8846076b9cd"),c=e("2db6fa09e8a5be4c");function u(e){var r="function"==typeof Map?new Map:void 0;return n._=u=function(e){if(null===e||!o._(e))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,n)}function n(){return i._(e,arguments,s._(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c._(n,e)},u(e)}n._=u},{c8857d56f4968279:"bC52X","2ed7bdf1701f2d07":"NOGHw","5c5ad8846076b9cd":"1mpbk","2db6fa09e8a5be4c":"7ubVA"}],bC52X:[function(e,r,n,a){"use strict";var i=e("62fc231ae2e75266"),s=e("3f98bf9d4f706151");function o(e,r,a){return i._()?n._=o=Reflect.construct:n._=o=function(e,r,n){var a=[null];a.push.apply(a,r);var i=new(Function.bind.apply(e,a));return n&&s._(i,n.prototype),i},o.apply(null,arguments)}n._=o},{"62fc231ae2e75266":"83nDe","3f98bf9d4f706151":"7ubVA"}],"1mpbk":[function(e,r,n,a){"use strict";n._=function(e){return -1!==Function.toString.call(e).indexOf("[native code]")}},{}],"8KRfO":[function(e,r,n,a){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(n),i.export(n,"Reader",function(){return l}),i.export(n,"FileSlice",function(){return d}),i.export(n,"readBytes",function(){return h}),i.export(n,"readU8",function(){return m}),i.export(n,"readU16",function(){return p}),i.export(n,"readU16Be",function(){return g}),i.export(n,"readU24Be",function(){return b}),i.export(n,"readI16Be",function(){return k}),i.export(n,"readU32",function(){return _}),i.export(n,"readU32Be",function(){return y}),i.export(n,"readU32Le",function(){return w}),i.export(n,"readI32Be",function(){return S}),i.export(n,"readI32Le",function(){return T}),i.export(n,"readU64",function(){return x}),i.export(n,"readU64Be",function(){return I}),i.export(n,"readI64Be",function(){return E}),i.export(n,"readI64Le",function(){return j}),i.export(n,"readF32Be",function(){return P}),i.export(n,"readF64Be",function(){return C}),i.export(n,"readAscii",function(){return A});var s=e("@swc/helpers/cjs/_class_call_check.cjs"),o=e("@swc/helpers/cjs/_create_class.cjs"),c=e("./input.js"),u=e("./misc.js"),l=function(){"use strict";function e(r){(0,s._)(this,e),this.source=r}return(0,o._)(e,[{key:"requestSlice",value:function(e,r){if(this.source._disposed)throw new(0,c.InputDisposedError);if(null!==this.fileSize&&e+r>this.fileSize)return null;var n=e+r,a=this.source._read(e,n);return a instanceof Promise?a.then(function(r){return r?new d(r.bytes,r.view,r.offset,e,n):null}):a?new d(a.bytes,a.view,a.offset,e,n):null}},{key:"requestSliceRange",value:function(e,r,n){var a=this;if(this.source._disposed)throw new(0,c.InputDisposedError);if(null!==this.fileSize)return this.requestSlice(e,(0,u.clamp)(this.fileSize-e,r,n));var i=this.requestSlice(e,n),s=function(i){if(i)return i;var s=function(i){return(0,u.assert)(null!==i),a.requestSlice(e,(0,u.clamp)(i-e,r,n))},o=a.source._retrieveSize();return o instanceof Promise?o.then(s):s(o)};return i instanceof Promise?i.then(s):s(i)}}]),e}(),d=function(){"use strict";function e(r,n,a,i,o){(0,s._)(this,e),this.bytes=r,this.view=n,this.offset=a,this.start=i,this.end=o,this.bufferPos=i-a}return(0,o._)(e,[{key:"length",get:function(){return this.end-this.start}},{key:"filePos",get:function(){return this.offset+this.bufferPos},set:function(e){this.bufferPos=e-this.offset}},{key:"remainingLength",get:function(){return Math.max(this.end-this.filePos,0)}},{key:"skip",value:function(e){this.bufferPos+=e}},{key:"slice",value:function(r){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.end-r;if(rthis.end)throw RangeError("Slicing outside of original slice.");return new e(this.bytes,this.view,this.offset,r,r+n)}}],[{key:"tempFromBytes",value:function(r){return new e(r,(0,u.toDataView)(r),0,0,r.length)}}]),e}(),f=function(e,r){if(e.filePose.end)throw RangeError("Tried reading [".concat(e.filePos,", ").concat(e.filePos+r,"), but slice is")+" [".concat(e.start,", ").concat(e.end,"). This is likely an internal error, please report it alongside the file")+" that caused it.")},h=function(e,r){f(e,r);var n=e.bytes.subarray(e.bufferPos,e.bufferPos+r);return e.bufferPos+=r,n},m=function(e){return f(e,1),e.view.getUint8(e.bufferPos++)},p=function(e,r){f(e,2);var n=e.view.getUint16(e.bufferPos,r);return e.bufferPos+=2,n},g=function(e){f(e,2);var r=e.view.getUint16(e.bufferPos,!1);return e.bufferPos+=2,r},b=function(e){f(e,3);var r=(0,u.getUint24)(e.view,e.bufferPos,!1);return e.bufferPos+=3,r},k=function(e){f(e,2);var r=e.view.getInt16(e.bufferPos,!1);return e.bufferPos+=2,r},_=function(e,r){f(e,4);var n=e.view.getUint32(e.bufferPos,r);return e.bufferPos+=4,n},y=function(e){f(e,4);var r=e.view.getUint32(e.bufferPos,!1);return e.bufferPos+=4,r},w=function(e){f(e,4);var r=e.view.getUint32(e.bufferPos,!0);return e.bufferPos+=4,r},S=function(e){f(e,4);var r=e.view.getInt32(e.bufferPos,!1);return e.bufferPos+=4,r},T=function(e){f(e,4);var r=e.view.getInt32(e.bufferPos,!0);return e.bufferPos+=4,r},x=function(e,r){var n,a;return r?(n=_(e,!0),a=_(e,!0)):(a=_(e,!1),n=_(e,!1)),0x100000000*a+n},I=function(e){return 0x100000000*y(e)+y(e)},E=function(e){return 0x100000000*S(e)+y(e)},j=function(e){var r=w(e);return 0x100000000*T(e)+r},P=function(e){f(e,4);var r=e.view.getFloat32(e.bufferPos,!1);return e.bufferPos+=4,r},C=function(e){f(e,8);var r=e.view.getFloat64(e.bufferPos,!1);return e.bufferPos+=8,r},A=function(e,r){f(e,r);for(var n="",a=0;a1&&void 0!==arguments[1]?arguments[1]:{};if((0,c._)(this,r),!(e instanceof Blob))throw TypeError("blob must be a Blob.");if(!i||(void 0===i?"undefined":(0,d._)(i))!=="object")throw TypeError("options must be an object.");if(void 0!==i.maxCacheSize&&(!(0,m.isNumber)(i.maxCacheSize)||i.maxCacheSize<0))throw TypeError("options.maxCacheSize, when provided, must be a non-negative number.");return(n=(0,o._)(this,r))._readers=new WeakMap,n._blob=e,n._orchestrator=new j({maxCacheSize:null!=(a=i.maxCacheSize)?a:8388608,maxWorkerCount:4,runWorker:n._runWorker.bind(n),prefetchProfile:E.fileSystem}),n}return(0,l._)(r,e),(0,u._)(r,[{key:"_retrieveSize",value:function(){var e=this._blob.size;return this._orchestrator.fileSize=e,e}},{key:"_read",value:function(e,r){return this._orchestrator.read(e,r)}},{key:"_runWorker",value:function(e){return(0,s._)(function(){var r,n,a,i,s,o,c,u,l;return(0,f._)(this,function(d){switch(d.label){case 0:void 0===(r=this._readers.get(e))&&(r="stream"in this._blob&&!(0,m.isWebKit)()?this._blob.slice(e.currentPos).stream().getReader():null,this._readers.set(e,r)),d.label=1;case 1:if(!(e.currentPos1&&void 0!==arguments[1]?arguments[1]:{};if((0,c._)(this,r),"string"!=typeof e&&!(e instanceof URL)&&!("undefined"!=typeof Request&&e instanceof Request))throw TypeError("url must be a string, URL or Request.");if(!s||(void 0===s?"undefined":(0,d._)(s))!=="object")throw TypeError("options must be an object.");if(void 0!==s.requestInit&&(!s.requestInit||"object"!==(0,d._)(s.requestInit)))throw TypeError("options.requestInit, when provided, must be an object.");if(void 0!==s.getRetryDelay&&"function"!=typeof s.getRetryDelay)throw TypeError("options.getRetryDelay, when provided, must be a function.");if(void 0!==s.maxCacheSize&&(!(0,m.isNumber)(s.maxCacheSize)||s.maxCacheSize<0))throw TypeError("options.maxCacheSize, when provided, must be a non-negative number.");if(void 0!==s.fetchFn&&"function"!=typeof s.fetchFn)throw TypeError("options.fetchFn, when provided, must be a function.");return(n=(0,o._)(this,r))._existingResponses=new WeakMap,n._url=e,n._options=s,n._getRetryDelay=null!=(a=s.getRetryDelay)?a:w,n._orchestrator=new j({maxCacheSize:null!=(i=s.maxCacheSize)?i:0x4000000,maxWorkerCount:2,runWorker:n._runWorker.bind(n),prefetchProfile:E.network}),n}return(0,l._)(r,e),(0,u._)(r,[{key:"_retrieveSize",value:function(){return(0,s._)(function(){var e,r,n,a,i,s,o,c;return(0,f._)(this,function(u){switch(u.label){case 0:return e=this,r=new AbortController,[4,(0,m.retriedFetch)(null!=(n=this._options.fetchFn)?n:fetch,this._url,(0,m.mergeRequestInit)(null!=(a=this._options.requestInit)?a:{},{headers:{Range:"bytes=0-"},signal:r.signal}),this._getRetryDelay,function(){return e._disposed})];case 1:if(!(i=u.sent()).ok)throw Error("Error fetching ".concat(String(this._url),": ").concat(i.status," ").concat(i.statusText));if(206===i.status)o=this._getTotalLengthFromRangeResponse(i),s=this._orchestrator.createWorker(0,Math.min(o,524288));else if(c=i.headers.get("Content-Length"))o=Number(c),s=this._orchestrator.createWorker(0,o),this._orchestrator.options.maxCacheSize=1/0,console.warn("HTTP server did not respond with 206 Partial Content, meaning the entire remote resource now has to be downloaded. For efficient media file streaming across a network, please make sure your server supports range requests.");else throw Error("HTTP response (status ".concat(i.status,") must surface Content-Length header."));return this._orchestrator.fileSize=o,this._existingResponses.set(s,{response:i,abortController:r}),this._orchestrator.runWorker(s),[2,o]}})}).call(this)}},{key:"_read",value:function(e,r){return this._orchestrator.read(e,r)}},{key:"_runWorker",value:function(e){return(0,s._)(function(){var r,n,a,i,s,o,c,u,l,p;return(0,f._)(this,function(g){switch(g.label){case 0:r=this,g.label=1;case 1:if(a=function(){var r,a,i,o,c,u,d;return(0,f._)(this,function(f){switch(f.label){case 0:if(e.currentPos>=e.targetPos||e.aborted)return s.abort(),e.running=!1,[2,{v:void 0}];i=void 0,f.label=1;case 1:return f.trys.push([1,3,,7]),[4,l.read()];case 2:return i=f.sent(),[3,7];case 3:if(o=f.sent(),n._disposed)throw o;if(null===(c=n._getRetryDelay(1,o,n._url)))return[3,5];return console.error("Error while reading response stream. Attempting to resume.",o),[4,new Promise(function(e){return setTimeout(e,1e3*c)})];case 4:return f.sent(),[2,"break"];case 5:throw o;case 6:return[3,7];case 7:if(e.aborted)return[2,"break"];if(u=i.done,d=i.value,u){if(e.currentPos>=e.targetPos)return n._orchestrator.forgetWorker(e),e.running=!1,[2,{v:void 0}];return[2,"break"]}return null==(r=(a=n).onread)||r.call(a,e.currentPos,e.currentPos+d.length),n._orchestrator.supplyWorkerData(e,d),[2]}})},i=this._existingResponses.get(e),this._existingResponses.delete(e),s=null==i?void 0:i.abortController,o=null==i?void 0:i.response,s)return[3,3];return s=new AbortController,[4,(0,m.retriedFetch)(null!=(c=this._options.fetchFn)?c:fetch,this._url,(0,m.mergeRequestInit)(null!=(u=this._options.requestInit)?u:{},{headers:{Range:"bytes=".concat(e.currentPos,"-")},signal:s.signal}),this._getRetryDelay,function(){return r._disposed})];case 2:o=g.sent(),g.label=3;case 3:if((0,m.assert)(o),!o.ok)throw Error("Error fetching ".concat(String(this._url),": ").concat(o.status," ").concat(o.statusText));if(e.currentPos>0&&206!==o.status)throw Error("HTTP server did not respond with 206 Partial Content to a range request. To enable efficient media file streaming across a network, please make sure your server supports range requests.");if(!o.body)throw Error("Missing HTTP response body stream. The used fetch function must provide the response body as a ReadableStream.");l=o.body.getReader(),g.label=4;case 4:return n=this,[5,(0,h._)(a())];case 5:if(p=g.sent(),"object"===(0,d._)(p))return[2,p.v];if("break"===p)return[3,6];return[3,4];case 6:if(e.aborted)return[3,7];return[3,1];case 7:return e.running=!1,[2]}})}).call(this)}},{key:"_getTotalLengthFromRangeResponse",value:function(e){var r=e.headers.get("Content-Range");if(r){var n=/\/(\d+)/.exec(r);if(n)return Number(n[1])}var a=e.headers.get("Content-Length");if(a)return Number(a);throw Error("Partial HTTP response (status 206) must surface either Content-Range or Content-Length header.")}},{key:"_dispose",value:function(){this._orchestrator.dispose()}}]),r}(k),T=function(e){"use strict";function r(e){var n,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if((0,c._)(this,r),"string"!=typeof e)throw TypeError("filePath must be a string.");if(!a||(void 0===a?"undefined":(0,d._)(a))!=="object")throw TypeError("options must be an object.");if(void 0!==a.maxCacheSize&&(!(0,m.isNumber)(a.maxCacheSize)||a.maxCacheSize<0))throw TypeError("options.maxCacheSize, when provided, must be a non-negative number.");return(n=(0,o._)(this,r))._fileHandle=null,n._streamSource=new x({getSize:function(){return(0,s._)(function(){return(0,f._)(this,function(r){switch(r.label){case 0:return[4,b.fs.open(e,"r")];case 1:return n._fileHandle=r.sent(),[4,n._fileHandle.stat()];case 2:return[2,r.sent().size]}})})()},read:function(e,r){return(0,s._)(function(){var a;return(0,f._)(this,function(i){switch(i.label){case 0:return(0,m.assert)(n._fileHandle),a=new Uint8Array(r-e),[4,n._fileHandle.read(a,0,r-e,e)];case 1:return i.sent(),[2,a]}})})()},maxCacheSize:a.maxCacheSize,prefetchProfile:"fileSystem"}),n}return(0,l._)(r,e),(0,u._)(r,[{key:"_read",value:function(e,r){return this._streamSource._read(e,r)}},{key:"_retrieveSize",value:function(){return this._streamSource._retrieveSize()}},{key:"_dispose",value:function(){var e;this._streamSource._dispose(),null==(e=this._fileHandle)||e.close(),this._fileHandle=null}}]),r}(k),x=function(e){"use strict";function r(e){var n,a,i;if((0,c._)(this,r),!e||(void 0===e?"undefined":(0,d._)(e))!=="object")throw TypeError("options must be an object.");if("function"!=typeof e.getSize)throw TypeError("options.getSize must be a function.");if("function"!=typeof e.read)throw TypeError("options.read must be a function.");if(void 0!==e.dispose&&"function"!=typeof e.dispose)throw TypeError("options.dispose, when provided, must be a function.");if(void 0!==e.maxCacheSize&&(!(0,m.isNumber)(e.maxCacheSize)||e.maxCacheSize<0))throw TypeError("options.maxCacheSize, when provided, must be a non-negative number.");if(e.prefetchProfile&&!["none","fileSystem","network"].includes(e.prefetchProfile))throw TypeError("options.prefetchProfile, when provided, must be one of 'none', 'fileSystem' or 'network'.");return(n=(0,o._)(this,r))._options=e,n._orchestrator=new j({maxCacheSize:null!=(a=e.maxCacheSize)?a:8388608,maxWorkerCount:2,prefetchProfile:E[null!=(i=e.prefetchProfile)?i:"none"],runWorker:n._runWorker.bind(n)}),n}return(0,l._)(r,e),(0,u._)(r,[{key:"_retrieveSize",value:function(){var e=this,r=this._options.getSize();if(r instanceof Promise)return r.then(function(r){if(!Number.isInteger(r)||r<0)throw TypeError("options.getSize must return or resolve to a non-negative integer.");return e._orchestrator.fileSize=r,r});if(!Number.isInteger(r)||r<0)throw TypeError("options.getSize must return or resolve to a non-negative integer.");return this._orchestrator.fileSize=r,r}},{key:"_read",value:function(e,r){return this._orchestrator.read(e,r)}},{key:"_runWorker",value:function(e){return(0,s._)(function(){var r,n,a,i,s,o,c,u,l,d,h,p;return(0,f._)(this,function(f){switch(f.label){case 0:if(!(e.currentPos1&&void 0!==arguments[1]?arguments[1]:{};if((0,c._)(this,r),!(e instanceof ReadableStream))throw TypeError("stream must be a ReadableStream.");if(!i||(void 0===i?"undefined":(0,d._)(i))!=="object")throw TypeError("options must be an object.");if(void 0!==i.maxCacheSize&&(!(0,m.isNumber)(i.maxCacheSize)||i.maxCacheSize<0))throw TypeError("options.maxCacheSize, when provided, must be a non-negative number.");return(n=(0,o._)(this,r))._reader=null,n._cache=[],n._pendingSlices=[],n._currentIndex=0,n._targetIndex=0,n._maxRequestedIndex=0,n._endIndex=null,n._pulling=!1,n._stream=e,n._maxCacheSize=null!=(a=i.maxCacheSize)?a:0x1000000,n}return(0,l._)(r,e),(0,u._)(r,[{key:"_retrieveSize",value:function(){return this._endIndex}},{key:"_read",value:function(e,r){var n=this;if(null!==this._endIndex&&r>this._endIndex)return null;this._maxRequestedIndex=Math.max(this._maxRequestedIndex,r);var a=(0,m.binarySearchLessOrEqual)(this._cache,e,function(e){return e.start}),i=-1!==a?this._cache[a]:null;if(i&&i.start<=e&&r<=i.end)return{bytes:i.bytes,view:i.view,offset:i.start};var s=e,o=new Uint8Array(r-e);if(-1!==a)for(var c=a;c=r)break;var l=Math.max(e,u.start);l>s&&this._throwDueToCacheMiss();var d=Math.min(r,u.end);ls&&this._throwDueToCacheMiss();var f=(0,m.promiseWithResolvers)(),h=f.promise,p=f.resolve,g=f.reject;return this._pendingSlices.push({start:e,end:r,bytes:o,resolve:p,reject:g}),this._targetIndex=Math.max(this._targetIndex,r),this._pulling||(this._pulling=!0,this._pull().catch(function(e){if(n._pulling=!1,n._pendingSlices.length>0)n._pendingSlices.forEach(function(r){return r.reject(e)}),n._pendingSlices.length=0;else throw e})),h}},{key:"_throwDueToCacheMiss",value:function(){throw Error("Read is before the cached region. With ReadableStreamSource, you must access the data more sequentially or increase the size of its cache.")}},{key:"_pull",value:function(){return(0,s._)(function(){var e,r,n,a,i,s,o,c,u,l,d,h,p,g,b;return(0,f._)(this,function(f){switch(f.label){case 0:null!=this._reader||(this._reader=this._stream.getReader()),f.label=1;case 1:if(!(this._currentIndex0&&(b=this._cache[0],!(this._maxRequestedIndex-b.end<=this._maxCacheSize));)this._cache.shift();return this._currentIndex+=n.byteLength,[3,1];case 3:return this._pulling=!1,[2]}})}).call(this)}},{key:"_dispose",value:function(){this._pendingSlices.length=0,this._cache.length=0}}]),r}(k),E={none:function(e,r){return{start:e,end:r}},fileSystem:function(e,r){return{start:e=65536*Math.floor((e-65536)/65536),end:r=65536*Math.ceil((r+65536)/65536)}},network:function(e,r,n){e=Math.max(0,65536*Math.floor((e-65536)/65536));var a=!0,i=!1,s=void 0;try{for(var o,c=n[Symbol.iterator]();!(a=(o=c.next()).done);a=!0){var u=o.value,l=Math.max((u.startPos+u.targetPos)/2,u.targetPos-8388608);if((0,m.closedIntervalsOverlap)(e,r,l,u.targetPos)){var d=u.targetPos-u.startPos,f=8388608*Math.ceil((d+1)/8388608),h=Math.pow(2,Math.ceil(Math.log2(d+1))),p=Math.min(h,f);r=Math.max(r,u.startPos+p)}}}catch(e){i=!0,s=e}finally{try{a||null==c.return||c.return()}finally{if(i)throw s}}return r=Math.max(r,e+524288),{start:e,end:r}}},j=function(){"use strict";function e(r){(0,c._)(this,e),this.options=r,this.fileSize=null,this.nextAge=0,this.workers=[],this.cache=[],this.currentCacheSize=0,this.disposed=!1}return(0,u._)(e,[{key:"read",value:function(e,r){(0,m.assert)(null!==this.fileSize);var n=this.options.prefetchProfile(e,r,this.workers),a=Math.max(n.start,0),i=Math.min(n.end,this.fileSize);(0,m.assert)(a<=e&&r<=i);var s=null,o=(0,m.binarySearchLessOrEqual)(this.cache,e,function(e){return e.start}),c=-1!==o?this.cache[o]:null;c&&c.start<=e&&r<=c.end&&(c.age=this.nextAge++,s={bytes:c.bytes,view:c.view,offset:c.start});var u=(0,m.binarySearchLessOrEqual)(this.cache,a,function(e){return e.start}),l=s?null:new Uint8Array(r-e),d=0,f=a,h=[];if(-1!==u){for(var p=u;p=i)break;if(!(g.end<=a)){var b=Math.max(a,g.start),k=Math.min(i,g.end);if((0,m.assert)(b<=k),f=l.length&&(s={bytes:l,view:(0,m.toDataView)(l),offset:e}),0===h.length)return(0,m.assert)(s),s;var S=(0,m.promiseWithResolvers)(),T=S.promise,x=S.resolve,I=S.reject,E=[],j=!0,P=!1,C=void 0;try{for(var A,B=h[Symbol.iterator]();!(j=(A=B.next()).done);j=!0){var M=A.value,D=Math.max(e,M.start),F=Math.min(r,M.end);D===M.start&&F===M.end?E.push(M):Dthis.options.maxWorkerCount;){for(var a=0,i=this.workers[0],s=1;s0)break;i.aborted=!0,this.workers.splice(a,1)}return n}},{key:"runWorker",value:function(e){(0,m.assert)(!e.running),(0,m.assert)(e.currentPos0)e.pendingSlices.forEach(function(e){return e.reject(r)}),e.pendingSlices.length=0;else throw r})}},{key:"supplyWorkerData",value:function(e,r){(0,m.assert)(!e.aborted);var n=e.currentPos,a=n+r.length;this.insertIntoCache({start:n,end:a,bytes:r,view:(0,m.toDataView)(r),age:this.nextAge++}),e.currentPos+=r.length,e.targetPos=Math.max(e.targetPos,e.currentPos);for(var i=0;il.start&&(l.start=a),l.end<=l.start&&(s.holes.splice(u,1),u--)}0===s.holes.length&&(s.resolve(s.bytes),e.pendingSlices.splice(i,1),i--)}for(var d=0;d0){var n=this.cache[r-1];if(n.end>=e.end)return;if(n.end>e.start){var a=new Uint8Array(e.end-n.start);a.set(n.bytes,0),a.set(e.bytes,e.start-n.start),this.currentCacheSize+=e.end-n.end,n.bytes=a,n.view=(0,m.toDataView)(a),n.end=e.end,r--,e=n}else this.cache.splice(r,0,e),this.currentCacheSize+=e.bytes.length}else this.cache.splice(r,0,e),this.currentCacheSize+=e.bytes.length;for(var i=r+1;i=s.end){this.cache.splice(i,1),this.currentCacheSize-=s.bytes.length,i--;continue}var o=new Uint8Array(s.end-e.start);o.set(e.bytes,0),o.set(s.bytes,s.start-e.start),this.currentCacheSize-=e.end-s.start,e.bytes=o,e.view=(0,m.toDataView)(o),e.end=s.end,this.cache.splice(i,1);break}for(;this.currentCacheSize>this.options.maxCacheSize;){for(var c=0,u=this.cache[0],l=1;l4&&void 0!==arguments[4]?arguments[4]:-1,u=arguments.length>5?arguments[5]:void 0,d=arguments.length>6?arguments[6]:void 0;if((0,s._)(this,e),this.data=r,this.type=n,this.timestamp=a,this.duration=i,this.sequenceNumber=o,r===l&&void 0===u)throw Error("Internal error: byteLength must be explicitly provided when constructing metadata-only packets.");if(void 0===u&&(u=r.byteLength),!(r instanceof Uint8Array))throw TypeError("data must be a Uint8Array.");if("key"!==n&&"delta"!==n)throw TypeError('type must be either "key" or "delta".');if(!Number.isFinite(a))throw TypeError("timestamp must be a number.");if(!Number.isFinite(i)||i<0)throw TypeError("duration must be a non-negative number.");if(!Number.isFinite(o))throw TypeError("sequenceNumber must be a number.");if(!Number.isInteger(u)||u<0)throw TypeError("byteLength must be a non-negative integer.");if(void 0!==d&&((void 0===d?"undefined":(0,c._)(d))!=="object"||!d))throw TypeError("sideData, when provided, must be an object.");if((null==d?void 0:d.alpha)!==void 0&&!(d.alpha instanceof Uint8Array))throw TypeError("sideData.alpha, when provided, must be a Uint8Array.");if((null==d?void 0:d.alphaByteLength)!==void 0&&(!Number.isInteger(d.alphaByteLength)||d.alphaByteLength<0))throw TypeError("sideData.alphaByteLength, when provided, must be a non-negative integer.");this.byteLength=u,this.sideData=null!=d?d:{},this.sideData.alpha&&void 0===this.sideData.alphaByteLength&&(this.sideData.alphaByteLength=this.sideData.alpha.byteLength)}return(0,o._)(e,[{key:"isMetadataOnly",get:function(){return this.data===l}},{key:"microsecondTimestamp",get:function(){return Math.trunc(u.SECOND_TO_MICROSECOND_FACTOR*this.timestamp)}},{key:"microsecondDuration",get:function(){return Math.trunc(u.SECOND_TO_MICROSECOND_FACTOR*this.duration)}},{key:"toEncodedVideoChunk",value:function(){if(this.isMetadataOnly)throw TypeError("Metadata-only packets cannot be converted to a video chunk.");if("undefined"==typeof EncodedVideoChunk)throw Error("Your browser does not support EncodedVideoChunk.");return new EncodedVideoChunk({data:this.data,type:this.type,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}},{key:"alphaToEncodedVideoChunk",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.type;if(!this.sideData.alpha)throw TypeError("This packet does not contain alpha side data.");if(this.isMetadataOnly)throw TypeError("Metadata-only packets cannot be converted to a video chunk.");if("undefined"==typeof EncodedVideoChunk)throw Error("Your browser does not support EncodedVideoChunk.");return new EncodedVideoChunk({data:this.sideData.alpha,type:e,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}},{key:"toEncodedAudioChunk",value:function(){if(this.isMetadataOnly)throw TypeError("Metadata-only packets cannot be converted to an audio chunk.");if("undefined"==typeof EncodedAudioChunk)throw Error("Your browser does not support EncodedAudioChunk.");return new EncodedAudioChunk({data:this.data,type:this.type,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}},{key:"clone",value:function(r){var n,a;if(void 0!==r&&((void 0===r?"undefined":(0,c._)(r))!=="object"||null===r))throw TypeError("options, when provided, must be an object.");if((null==r?void 0:r.timestamp)!==void 0&&!Number.isFinite(r.timestamp))throw TypeError("options.timestamp, when provided, must be a number.");if((null==r?void 0:r.duration)!==void 0&&!Number.isFinite(r.duration))throw TypeError("options.duration, when provided, must be a number.");return new e(this.data,this.type,null!=(n=null==r?void 0:r.timestamp)?n:this.timestamp,null!=(a=null==r?void 0:r.duration)?a:this.duration,this.sequenceNumber,this.byteLength)}}],[{key:"fromEncodedChunk",value:function(r,n){if(!(r instanceof EncodedVideoChunk||r instanceof EncodedAudioChunk))throw TypeError("chunk must be an EncodedVideoChunk or EncodedAudioChunk.");var a,i=new Uint8Array(r.byteLength);return r.copyTo(i),new e(i,r.type,r.timestamp/1e6,(null!=(a=r.duration)?a:0)/1e6,void 0,void 0,n)}}]),e}()},{"@swc/helpers/cjs/_class_call_check.cjs":"4Uf9M","@swc/helpers/cjs/_create_class.cjs":"igUuK","@swc/helpers/cjs/_type_of.cjs":"iXhRw","./misc.js":"j7iGm","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],"501Zr":[function(e,r,n,a){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(n),i.export(n,"toUlaw",function(){return s}),i.export(n,"fromUlaw",function(){return o}),i.export(n,"toAlaw",function(){return c}),i.export(n,"fromAlaw",function(){return u});var s=function(e){var r=e,n=4096,a=0,i=12,s=0;for(r<0&&(r=-r,a=128),(r+=33)>8191&&(r=8191);(r&n)!==n&&i>=5;)n>>=1,i--;return s=r>>i-4&15,255&~(a|i-5<<4|s)},o=function(e){var r=0,n=0,a=~e;128&a&&(a&=-129,r=-1);var i=(1<<(n=((240&a)>>4)+5)|(15&a)<4095&&(s=4095);(s&r)!==r&&a>=5;)r>>=1,a--;return i=s>>(4===a?1:a-4)&15,(n|a-4<<4|i)^85},u=function(e){var r=0,n=0,a=85^e;128&a&&(a&=-129,r=-1);var i=0;return i=4!=(n=((240&a)>>4)+4)?1<=1e3&&(console.error("A VideoSample was garbage collected without first being closed. For proper resource management, make sure to call close() on all your VideoSamples as soon as you're done using them."),h=r),"undefined"!=typeof VideoFrame&&e.data instanceof VideoFrame&&e.data.close()):(r-m>=1e3&&(console.error("An AudioSample was garbage collected without first being closed. For proper resource management, make sure to call close() on all your AudioSamples as soon as you're done using them."),m=r),"undefined"!=typeof AudioData&&e.data instanceof AudioData&&e.data.close())}));var g=function(){"use strict";function e(r,n){if((0,o._)(this,e),this._closed=!1,r instanceof ArrayBuffer||"undefined"!=typeof SharedArrayBuffer&&r instanceof SharedArrayBuffer||ArrayBuffer.isView(r)){if(!n||(void 0===n?"undefined":(0,l._)(n))!=="object")throw TypeError("init must be an object.");if(!("format"in n)||"string"!=typeof n.format)throw TypeError("init.format must be a string.");if(!Number.isInteger(n.codedWidth)||n.codedWidth<=0)throw TypeError("init.codedWidth must be a positive integer.");if(!Number.isInteger(n.codedHeight)||n.codedHeight<=0)throw TypeError("init.codedHeight must be a positive integer.");if(void 0!==n.rotation&&![0,90,180,270].includes(n.rotation))throw TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");if(!Number.isFinite(n.timestamp))throw TypeError("init.timestamp must be a number.");if(void 0!==n.duration&&(!Number.isFinite(n.duration)||n.duration<0))throw TypeError("init.duration, when provided, must be a non-negative number.");this._data=(0,f.toUint8Array)(r).slice(),this.format=n.format,this.codedWidth=n.codedWidth,this.codedHeight=n.codedHeight,this.rotation=null!=(a=n.rotation)?a:0,this.timestamp=n.timestamp,this.duration=null!=(i=n.duration)?i:0,this.colorSpace=new VideoColorSpace(n.colorSpace)}else if("undefined"!=typeof VideoFrame&&r instanceof VideoFrame){if((null==n?void 0:n.rotation)!==void 0&&![0,90,180,270].includes(n.rotation))throw TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");if((null==n?void 0:n.timestamp)!==void 0&&!Number.isFinite(null==n?void 0:n.timestamp))throw TypeError("init.timestamp, when provided, must be a number.");if((null==n?void 0:n.duration)!==void 0&&(!Number.isFinite(n.duration)||n.duration<0))throw TypeError("init.duration, when provided, must be a non-negative number.");this._data=r,this.format=r.format,this.codedWidth=r.displayWidth,this.codedHeight=r.displayHeight,this.rotation=null!=(s=null==n?void 0:n.rotation)?s:0,this.timestamp=null!=(c=null==n?void 0:n.timestamp)?c:r.timestamp/1e6,this.duration=null!=(d=null==n?void 0:n.duration)?d:(null!=(u=r.duration)?u:0)/1e6,this.colorSpace=r.colorSpace}else if("undefined"!=typeof HTMLImageElement&&r instanceof HTMLImageElement||"undefined"!=typeof SVGImageElement&&r instanceof SVGImageElement||"undefined"!=typeof ImageBitmap&&r instanceof ImageBitmap||"undefined"!=typeof HTMLVideoElement&&r instanceof HTMLVideoElement||"undefined"!=typeof HTMLCanvasElement&&r instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&r instanceof OffscreenCanvas){if(!n||(void 0===n?"undefined":(0,l._)(n))!=="object")throw TypeError("init must be an object.");if(void 0!==n.rotation&&![0,90,180,270].includes(n.rotation))throw TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");if(!Number.isFinite(n.timestamp))throw TypeError("init.timestamp must be a number.");if(void 0!==n.duration&&(!Number.isFinite(n.duration)||n.duration<0))throw TypeError("init.duration, when provided, must be a non-negative number.");if("undefined"!=typeof VideoFrame)return new e(new VideoFrame(r,{timestamp:Math.trunc(n.timestamp*f.SECOND_TO_MICROSECOND_FACTOR),duration:Math.trunc((null!=(h=n.duration)?h:0)*f.SECOND_TO_MICROSECOND_FACTOR)||void 0}),n);var a,i,s,c,u,d,h,m,g,b=0,k=0;if("naturalWidth"in r?(b=r.naturalWidth,k=r.naturalHeight):"videoWidth"in r?(b=r.videoWidth,k=r.videoHeight):"width"in r&&(b=Number(r.width),k=Number(r.height)),!b||!k)throw TypeError("Could not determine dimensions.");var _=new OffscreenCanvas(b,k),y=_.getContext("2d",{alpha:(0,f.isFirefox)(),willReadFrequently:!0});(0,f.assert)(y),y.drawImage(r,0,0),this._data=_,this.format="RGBX",this.codedWidth=b,this.codedHeight=k,this.rotation=null!=(m=n.rotation)?m:0,this.timestamp=n.timestamp,this.duration=null!=(g=n.duration)?g:0,this.colorSpace=new VideoColorSpace({matrix:"rgb",primaries:"bt709",transfer:"iec61966-2-1",fullRange:!0})}else throw TypeError("Invalid data type: Must be a BufferSource or CanvasImageSource.");null==p||p.register(this,{type:"video",data:this._data},this)}return(0,c._)(e,[{key:"displayWidth",get:function(){return this.rotation%180==0?this.codedWidth:this.codedHeight}},{key:"displayHeight",get:function(){return this.rotation%180==0?this.codedHeight:this.codedWidth}},{key:"microsecondTimestamp",get:function(){return Math.trunc(f.SECOND_TO_MICROSECOND_FACTOR*this.timestamp)}},{key:"microsecondDuration",get:function(){return Math.trunc(f.SECOND_TO_MICROSECOND_FACTOR*this.duration)}},{key:"hasAlpha",get:function(){return this.format&&this.format.includes("A")}},{key:"clone",value:function(){if(this._closed)throw Error("VideoSample is closed.");return((0,f.assert)(null!==this._data),b(this._data))?new e(this._data.clone(),{timestamp:this.timestamp,duration:this.duration,rotation:this.rotation}):this._data instanceof Uint8Array?new e(this._data.slice(),{format:this.format,codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.timestamp,duration:this.duration,colorSpace:this.colorSpace,rotation:this.rotation}):new e(this._data,{format:this.format,codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.timestamp,duration:this.duration,colorSpace:this.colorSpace,rotation:this.rotation})}},{key:"close",value:function(){this._closed||(null==p||p.unregister(this),b(this._data)?this._data.close():this._data=null,this._closed=!0)}},{key:"allocationSize",value:function(){if(this._closed)throw Error("VideoSample is closed.");return((0,f.assert)(null!==this._data),b(this._data))?this._data.allocationSize():this._data instanceof Uint8Array?this._data.byteLength:this.codedWidth*this.codedHeight*4}},{key:"copyTo",value:function(e){return(0,s._)(function(){var r,n;return(0,d._)(this,function(a){switch(a.label){case 0:if(!(0,f.isAllowSharedBufferSource)(e))throw TypeError("destination must be an ArrayBuffer or an ArrayBuffer view.");if(this._closed)throw Error("VideoSample is closed.");if((0,f.assert)(null!==this._data),!b(this._data))return[3,2];return[4,this._data.copyTo(e)];case 1:return a.sent(),[3,3];case 2:this._data instanceof Uint8Array?(0,f.toUint8Array)(e).set(this._data):(r=this._data.getContext("2d"),(0,f.assert)(r),n=r.getImageData(0,0,this.codedWidth,this.codedHeight),(0,f.toUint8Array)(e).set(n.data)),a.label=3;case 3:return[2]}})}).call(this)}},{key:"toVideoFrame",value:function(){if(this._closed)throw Error("VideoSample is closed.");return((0,f.assert)(null!==this._data),b(this._data))?new VideoFrame(this._data,{timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0}):this._data instanceof Uint8Array?new VideoFrame(this._data,{format:this.format,codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0,colorSpace:this.colorSpace}):new VideoFrame(this._data,{timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0})}},{key:"draw",value:function(e,r,n,a,i,s,o,c,u){var l,d=0,f=0,h=this.displayWidth,m=this.displayHeight,p=0,g=0,b=this.displayWidth,k=this.displayHeight;if(void 0!==s?(d=r,f=n,h=a,m=i,p=s,g=o,void 0!==c?(b=c,k=u):(b=h,k=m)):(p=r,g=n,void 0!==a&&(b=a,k=i)),!("undefined"!=typeof CanvasRenderingContext2D&&e instanceof CanvasRenderingContext2D||"undefined"!=typeof OffscreenCanvasRenderingContext2D&&e instanceof OffscreenCanvasRenderingContext2D))throw TypeError("context must be a CanvasRenderingContext2D or OffscreenCanvasRenderingContext2D.");if(!Number.isFinite(d))throw TypeError("sx must be a number.");if(!Number.isFinite(f))throw TypeError("sy must be a number.");if(!Number.isFinite(h)||h<0)throw TypeError("sWidth must be a non-negative number.");if(!Number.isFinite(m)||m<0)throw TypeError("sHeight must be a non-negative number.");if(!Number.isFinite(p))throw TypeError("dx must be a number.");if(!Number.isFinite(g))throw TypeError("dy must be a number.");if(!Number.isFinite(b)||b<0)throw TypeError("dWidth must be a non-negative number.");if(!Number.isFinite(k)||k<0)throw TypeError("dHeight must be a non-negative number.");if(this._closed)throw Error("VideoSample is closed.");d=(l=this._rotateSourceRegion(d,f,h,m,this.rotation)).sx,f=l.sy,h=l.sWidth,m=l.sHeight;var _=this.toCanvasImageSource();e.save();var y=p+b/2,w=g+k/2;e.translate(y,w),e.rotate(this.rotation*Math.PI/180);var S=this.rotation%180==0?1:b/k;e.scale(1/S,S),e.drawImage(_,d,f,h,m,-b/2,-k/2,b,k),e.restore()}},{key:"drawWithFit",value:function(e,r){if(!("undefined"!=typeof CanvasRenderingContext2D&&e instanceof CanvasRenderingContext2D||"undefined"!=typeof OffscreenCanvasRenderingContext2D&&e instanceof OffscreenCanvasRenderingContext2D))throw TypeError("context must be a CanvasRenderingContext2D or OffscreenCanvasRenderingContext2D.");if(!r||(void 0===r?"undefined":(0,l._)(r))!=="object")throw TypeError("options must be an object.");if(!["fill","contain","cover"].includes(r.fit))throw TypeError("options.fit must be 'fill', 'contain', or 'cover'.");if(void 0!==r.rotation&&![0,90,180,270].includes(r.rotation))throw TypeError("options.rotation, when provided, must be 0, 90, 180, or 270.");void 0!==r.crop&&_(r.crop,"options.");var n,a,i,s,o,c,d,f,h,m,p,g,b,y=e.canvas.width,w=e.canvas.height,S=null!=(o=r.rotation)?o:this.rotation,T=(0,u._)(S%180==0?[this.codedWidth,this.codedHeight]:[this.codedHeight,this.codedWidth],2),x=T[0],I=T[1];r.crop&&k(r.crop,x,I);var E=this._rotateSourceRegion(null!=(m=null==(n=r.crop)?void 0:n.left)?m:0,null!=(p=null==(a=r.crop)?void 0:a.top)?p:0,null!=(g=null==(i=r.crop)?void 0:i.width)?g:x,null!=(b=null==(s=r.crop)?void 0:s.height)?b:I,S),j=E.sx,P=E.sy,C=E.sWidth,A=E.sHeight;if("fill"===r.fit)c=0,d=0,f=y,h=w;else{var B=(0,u._)(r.crop?[r.crop.width,r.crop.height]:[x,I],2),M=B[0],D=B[1],F="contain"===r.fit?Math.min(y/M,w/D):Math.max(y/M,w/D);f=M*F,h=D*F,c=(y-f)/2,d=(w-h)/2}e.save();var R=S%180==0?1:f/h;e.translate(y/2,w/2),e.rotate(S*Math.PI/180),e.scale(1/R,R),e.translate(-y/2,-w/2),e.drawImage(this.toCanvasImageSource(),j,P,C,A,c,d,f,h),e.restore()}},{key:"_rotateSourceRegion",value:function(e,r,n,a,i){var s,o,c;return 90===i?(e=(s=[r,this.codedHeight-e-n,a,n])[0],r=s[1],n=s[2],a=s[3]):180===i?(e=(o=[this.codedWidth-e-n,this.codedHeight-r-a])[0],r=o[1]):270===i&&(e=(c=[this.codedWidth-r-a,e,a,n])[0],r=c[1],n=c[2],a=c[3]),{sx:e,sy:r,sWidth:n,sHeight:a}}},{key:"toCanvasImageSource",value:function(){if(this._closed)throw Error("VideoSample is closed.");if((0,f.assert)(null!==this._data),!(this._data instanceof Uint8Array))return this._data;var e=this.toVideoFrame();return queueMicrotask(function(){return e.close()}),e}},{key:"setRotation",value:function(e){if(![0,90,180,270].includes(e))throw TypeError("newRotation must be 0, 90, 180, or 270.");this.rotation=e}},{key:"setTimestamp",value:function(e){if(!Number.isFinite(e))throw TypeError("newTimestamp must be a number.");this.timestamp=e}},{key:"setDuration",value:function(e){if(!Number.isFinite(e)||e<0)throw TypeError("newDuration must be a non-negative number.");this.duration=e}},{key:Symbol.dispose,value:function(){this.close()}}]),e}(),b=function(e){return"undefined"!=typeof VideoFrame&&e instanceof VideoFrame},k=function(e,r,n){e.left=Math.min(e.left,r),e.top=Math.min(e.top,n),e.width=Math.min(e.width,r-e.left),e.height=Math.min(e.height,n-e.top),(0,f.assert)(e.width>=0),(0,f.assert)(e.height>=0)},_=function(e,r){if(!e||(void 0===e?"undefined":(0,l._)(e))!=="object")throw TypeError(r+"crop, when provided, must be an object.");if(!Number.isInteger(e.left)||e.left<0)throw TypeError(r+"crop.left must be a non-negative integer.");if(!Number.isInteger(e.top)||e.top<0)throw TypeError(r+"crop.top must be a non-negative integer.");if(!Number.isInteger(e.width)||e.width<0)throw TypeError(r+"crop.width must be a non-negative integer.");if(!Number.isInteger(e.height)||e.height<0)throw TypeError(r+"crop.height must be a non-negative integer.")},y=new Set(["f32","f32-planar","s16","s16-planar","s32","s32-planar","u8","u8-planar"]),w=function(){"use strict";function e(r){if((0,o._)(this,e),this._closed=!1,E(r)){if(null===r.format)throw TypeError("AudioData with null format is not supported.");this._data=r,this.format=r.format,this.sampleRate=r.sampleRate,this.numberOfFrames=r.numberOfFrames,this.numberOfChannels=r.numberOfChannels,this.timestamp=r.timestamp/1e6,this.duration=r.numberOfFrames/r.sampleRate}else{if(!r||(void 0===r?"undefined":(0,l._)(r))!=="object")throw TypeError("Invalid AudioDataInit: must be an object.");if(!y.has(r.format))throw TypeError("Invalid AudioDataInit: invalid format.");if(!Number.isFinite(r.sampleRate)||r.sampleRate<=0)throw TypeError("Invalid AudioDataInit: sampleRate must be >0.");if(!Number.isInteger(r.numberOfChannels)||0===r.numberOfChannels)throw TypeError("Invalid AudioDataInit: numberOfChannels must be an integer > 0.");if(!Number.isFinite(null==r?void 0:r.timestamp))throw TypeError("init.timestamp must be a number.");var n,a=r.data.byteLength/(S(r.format)*r.numberOfChannels);if(!Number.isInteger(a))throw TypeError("Invalid AudioDataInit: data size is not a multiple of frame size.");if(this.format=r.format,this.sampleRate=r.sampleRate,this.numberOfFrames=a,this.numberOfChannels=r.numberOfChannels,this.timestamp=r.timestamp,this.duration=a/r.sampleRate,r.data instanceof ArrayBuffer)n=new Uint8Array(r.data);else if(ArrayBuffer.isView(r.data))n=new Uint8Array(r.data.buffer,r.data.byteOffset,r.data.byteLength);else throw TypeError("Invalid AudioDataInit: data is not a BufferSource.");var i=this.numberOfFrames*this.numberOfChannels*S(this.format);if(n.byteLength=this.numberOfFrames)throw RangeError("frameOffset out of range");var s=void 0!==e.frameCount?e.frameCount:this.numberOfFrames-i;if(s>this.numberOfFrames-i)throw RangeError("frameCount out of range");var o=S(a),c=T(a);if(c&&e.planeIndex>=this.numberOfChannels||!c&&0!==e.planeIndex)throw RangeError("planeIndex out of range");return(c?s:s*this.numberOfChannels)*o}},{key:"copyTo",value:function(e,r){if(!(0,f.isAllowSharedBufferSource)(e))throw TypeError("destination must be an ArrayBuffer or an ArrayBuffer view.");if(!r||(void 0===r?"undefined":(0,l._)(r))!=="object")throw TypeError("options must be an object.");if(!Number.isInteger(r.planeIndex)||r.planeIndex<0)throw TypeError("planeIndex must be a non-negative integer.");if(void 0!==r.format&&!y.has(r.format))throw TypeError("Invalid format.");if(void 0!==r.frameOffset&&(!Number.isInteger(r.frameOffset)||r.frameOffset<0))throw TypeError("frameOffset must be a non-negative integer.");if(void 0!==r.frameCount&&(!Number.isInteger(r.frameCount)||r.frameCount<0))throw TypeError("frameCount must be a non-negative integer.");if(this._closed)throw Error("AudioSample is closed.");var n=r.planeIndex,a=r.format,i=r.frameCount,s=r.frameOffset,o=null!=a?a:this.format;if(!o)throw Error("Destination format not determined");var c=this.numberOfFrames,u=this.numberOfChannels,d=null!=s?s:0;if(d>=c)throw RangeError("frameOffset out of range");var h=void 0!==i?i:c-d;if(h>c-d)throw RangeError("frameCount out of range");var m=S(o),p=T(o);if(p&&n>=u||!p&&0!==n)throw RangeError("planeIndex out of range");var g=p?h:h*u;if(e.byteLength0))return[3,3];for(h=0,f=new Float32Array(a*(l=Math.min(o,u)));h0;){for(var d=Math.min(o,u),f=new Float32Array(a*d),h=0;h0){var n=(0,s._)(new Set(e.codecStrings));r+='; codecs="'.concat(n.join(", "),'"')}return r}},{"@swc/helpers/cjs/_to_consumable_array.cjs":"i81N6","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],fSW0K:[function(e,r,n,a){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(n),i.export(n,"MIN_BOX_HEADER_SIZE",function(){return u}),i.export(n,"MAX_BOX_HEADER_SIZE",function(){return l}),i.export(n,"readBoxHeader",function(){return d}),i.export(n,"readFixed_16_16",function(){return f}),i.export(n,"readFixed_2_30",function(){return h}),i.export(n,"readIsomVariableInteger",function(){return m}),i.export(n,"readMetadataStringShort",function(){return p}),i.export(n,"readDataBox",function(){return g});var s=e("../metadata.js"),o=e("../misc.js"),c=e("../reader.js"),u=8,l=16,d=function(e){var r=(0,c.readU32Be)(e),n=(0,c.readAscii)(e,4),a=8;1===r&&(r=(0,c.readU64Be)(e),a=16);var i=r-a;return i<0?null:{name:n,totalSize:r,headerSize:a,contentSize:i}},f=function(e){return(0,c.readI32Be)(e)/65536},h=function(e){return(0,c.readI32Be)(e)/0x40000000},m=function(e){for(var r=0,n=0;n<4;n++){r<<=7;var a=(0,c.readU8)(e);if(r|=127&a,(128&a)==0)break}return r},p=function(e){var r=(0,c.readU16Be)(e);return e.skip(2),r=Math.min(r,e.remainingLength),o.textDecoder.decode((0,c.readBytes)(e,r))},g=function(e){var r=d(e);if(!r||"data"!==r.name||e.remainingLength<8)return null;var n=(0,c.readU32Be)(e);e.skip(4);var a=(0,c.readBytes)(e,r.contentSize-8);switch(n){case 1:return o.textDecoder.decode(a);case 2:return new TextDecoder("utf-16be").decode(a);case 13:return new(0,s.RichImageData)(a,"image/jpeg");case 14:return new(0,s.RichImageData)(a,"image/png");case 27:return new(0,s.RichImageData)(a,"image/bmp");default:return a}}},{"../metadata.js":"eSjom","../misc.js":"j7iGm","../reader.js":"8KRfO","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],eSjom:[function(e,r,n,a){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(n),i.export(n,"RichImageData",function(){return c}),i.export(n,"AttachedFile",function(){return u}),i.export(n,"validateMetadataTags",function(){return l}),i.export(n,"metadataTagsAreEmpty",function(){return d}),i.export(n,"DEFAULT_TRACK_DISPOSITION",function(){return f}),i.export(n,"validateTrackDisposition",function(){return h});var s=e("@swc/helpers/cjs/_class_call_check.cjs"),o=e("@swc/helpers/cjs/_type_of.cjs"),c=function e(r,n){"use strict";if((0,s._)(this,e),this.data=r,this.mimeType=n,!(r instanceof Uint8Array))throw TypeError("data must be a Uint8Array.");if("string"!=typeof n)throw TypeError("mimeType must be a string.")},u=function e(r,n,a,i){"use strict";if((0,s._)(this,e),this.data=r,this.mimeType=n,this.name=a,this.description=i,!(r instanceof Uint8Array))throw TypeError("data must be a Uint8Array.");if(void 0!==n&&"string"!=typeof n)throw TypeError("mimeType, when provided, must be a string.");if(void 0!==a&&"string"!=typeof a)throw TypeError("name, when provided, must be a string.");if(void 0!==i&&"string"!=typeof i)throw TypeError("description, when provided, must be a string.")},l=function(e){if(!e||(void 0===e?"undefined":(0,o._)(e))!=="object")throw TypeError("tags must be an object.");if(void 0!==e.title&&"string"!=typeof e.title)throw TypeError("tags.title, when provided, must be a string.");if(void 0!==e.description&&"string"!=typeof e.description)throw TypeError("tags.description, when provided, must be a string.");if(void 0!==e.artist&&"string"!=typeof e.artist)throw TypeError("tags.artist, when provided, must be a string.");if(void 0!==e.album&&"string"!=typeof e.album)throw TypeError("tags.album, when provided, must be a string.");if(void 0!==e.albumArtist&&"string"!=typeof e.albumArtist)throw TypeError("tags.albumArtist, when provided, must be a string.");if(void 0!==e.trackNumber&&(!Number.isInteger(e.trackNumber)||e.trackNumber<=0))throw TypeError("tags.trackNumber, when provided, must be a positive integer.");if(void 0!==e.tracksTotal&&(!Number.isInteger(e.tracksTotal)||e.tracksTotal<=0))throw TypeError("tags.tracksTotal, when provided, must be a positive integer.");if(void 0!==e.discNumber&&(!Number.isInteger(e.discNumber)||e.discNumber<=0))throw TypeError("tags.discNumber, when provided, must be a positive integer.");if(void 0!==e.discsTotal&&(!Number.isInteger(e.discsTotal)||e.discsTotal<=0))throw TypeError("tags.discsTotal, when provided, must be a positive integer.");if(void 0!==e.genre&&"string"!=typeof e.genre)throw TypeError("tags.genre, when provided, must be a string.");if(void 0!==e.date&&(!(e.date instanceof Date)||Number.isNaN(e.date.getTime())))throw TypeError("tags.date, when provided, must be a valid Date.");if(void 0!==e.lyrics&&"string"!=typeof e.lyrics)throw TypeError("tags.lyrics, when provided, must be a string.");if(void 0!==e.images){if(!Array.isArray(e.images))throw TypeError("tags.images, when provided, must be an array.");var r=!0,n=!1,a=void 0;try{for(var i,s=e.images[Symbol.iterator]();!(r=(i=s.next()).done);r=!0){var l=i.value;if(!l||(void 0===l?"undefined":(0,o._)(l))!=="object")throw TypeError("Each image in tags.images must be an object.");if(!(l.data instanceof Uint8Array))throw TypeError("Each image.data must be a Uint8Array.");if("string"!=typeof l.mimeType)throw TypeError("Each image.mimeType must be a string.");if(!["coverFront","coverBack","unknown"].includes(l.kind))throw TypeError("Each image.kind must be 'coverFront', 'coverBack', or 'unknown'.")}}catch(e){n=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(n)throw a}}}if(void 0!==e.comment&&"string"!=typeof e.comment)throw TypeError("tags.comment, when provided, must be a string.");if(void 0!==e.raw){if(!e.raw||"object"!==(0,o._)(e.raw))throw TypeError("tags.raw, when provided, must be an object.");var d=!0,f=!1,h=void 0;try{for(var m,p=Object.values(e.raw)[Symbol.iterator]();!(d=(m=p.next()).done);d=!0){var g=m.value;if(null!==g&&"string"!=typeof g&&!(g instanceof Uint8Array)&&!(g instanceof c)&&!(g instanceof u))throw TypeError("Each value in tags.raw must be a string, Uint8Array, RichImageData, AttachedFile, or null.")}}catch(e){f=!0,h=e}finally{try{d||null==p.return||p.return()}finally{if(f)throw h}}}},d=function(e){return void 0===e.title&&void 0===e.description&&void 0===e.artist&&void 0===e.album&&void 0===e.albumArtist&&void 0===e.trackNumber&&void 0===e.tracksTotal&&void 0===e.discNumber&&void 0===e.discsTotal&&void 0===e.genre&&void 0===e.date&&void 0===e.lyrics&&(!e.images||0===e.images.length)&&void 0===e.comment&&(void 0===e.raw||0===Object.keys(e.raw).length)},f={default:!0,forced:!1,original:!1,commentary:!1,hearingImpaired:!1,visuallyImpaired:!1},h=function(e){if(!e||(void 0===e?"undefined":(0,o._)(e))!=="object")throw TypeError("disposition must be an object.");if(void 0!==e.default&&"boolean"!=typeof e.default)throw TypeError("disposition.default must be a boolean.");if(void 0!==e.forced&&"boolean"!=typeof e.forced)throw TypeError("disposition.forced must be a boolean.");if(void 0!==e.original&&"boolean"!=typeof e.original)throw TypeError("disposition.original must be a boolean.");if(void 0!==e.commentary&&"boolean"!=typeof e.commentary)throw TypeError("disposition.commentary must be a boolean.");if(void 0!==e.hearingImpaired&&"boolean"!=typeof e.hearingImpaired)throw TypeError("disposition.hearingImpaired must be a boolean.");if(void 0!==e.visuallyImpaired&&"boolean"!=typeof e.visuallyImpaired)throw TypeError("disposition.visuallyImpaired must be a boolean.")}},{"@swc/helpers/cjs/_class_call_check.cjs":"4Uf9M","@swc/helpers/cjs/_type_of.cjs":"iXhRw","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],fq2QE:[function(e,r,n,a){var i,s,o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(n),o.export(n,"EBMLFloat32",function(){return g}),o.export(n,"EBMLFloat64",function(){return b}),o.export(n,"EBMLSignedInt",function(){return k}),o.export(n,"EBMLUnicodeString",function(){return _}),o.export(n,"EBMLId",function(){return s}),o.export(n,"LEVEL_0_EBML_IDS",function(){return y}),o.export(n,"LEVEL_1_EBML_IDS",function(){return w}),o.export(n,"LEVEL_0_AND_1_EBML_IDS",function(){return S}),o.export(n,"measureUnsignedInt",function(){return T}),o.export(n,"measureUnsignedBigInt",function(){return x}),o.export(n,"measureSignedInt",function(){return I}),o.export(n,"measureVarInt",function(){return E}),o.export(n,"EBMLWriter",function(){return j}),o.export(n,"MAX_VAR_INT_SIZE",function(){return P}),o.export(n,"MIN_HEADER_SIZE",function(){return C}),o.export(n,"MAX_HEADER_SIZE",function(){return A}),o.export(n,"readVarIntSize",function(){return B}),o.export(n,"readVarInt",function(){return M}),o.export(n,"readUnsignedInt",function(){return D}),o.export(n,"readUnsignedBigInt",function(){return F}),o.export(n,"readSignedInt",function(){return R}),o.export(n,"readElementId",function(){return U}),o.export(n,"readElementSize",function(){return O}),o.export(n,"readElementHeader",function(){return L}),o.export(n,"readAsciiString",function(){return N}),o.export(n,"readUnicodeString",function(){return z}),o.export(n,"readFloat",function(){return V}),o.export(n,"searchForNextElementId",function(){return H}),o.export(n,"resync",function(){return G}),o.export(n,"CODEC_STRING_MAP",function(){return q}),o.export(n,"assertDefinedSize",function(){return W});var c=e("@swc/helpers/cjs/_async_to_generator.cjs"),u=e("@swc/helpers/cjs/_class_call_check.cjs"),l=e("@swc/helpers/cjs/_create_class.cjs"),d=e("@swc/helpers/cjs/_to_consumable_array.cjs"),f=e("@swc/helpers/cjs/_type_of.cjs"),h=e("@swc/helpers/cjs/_ts_generator.cjs"),m=e("../misc.js"),p=e("../reader.js"),g=function e(r){"use strict";(0,u._)(this,e),this.value=r},b=function e(r){"use strict";(0,u._)(this,e),this.value=r},k=function e(r){"use strict";(0,u._)(this,e),this.value=r},_=function e(r){"use strict";(0,u._)(this,e),this.value=r};(i=s||(s={}))[i.EBML=0x1a45dfa3]="EBML",i[i.EBMLVersion=17030]="EBMLVersion",i[i.EBMLReadVersion=17143]="EBMLReadVersion",i[i.EBMLMaxIDLength=17138]="EBMLMaxIDLength",i[i.EBMLMaxSizeLength=17139]="EBMLMaxSizeLength",i[i.DocType=17026]="DocType",i[i.DocTypeVersion=17031]="DocTypeVersion",i[i.DocTypeReadVersion=17029]="DocTypeReadVersion",i[i.Void=236]="Void",i[i.Segment=0x18538067]="Segment",i[i.SeekHead=0x114d9b74]="SeekHead",i[i.Seek=19899]="Seek",i[i.SeekID=21419]="SeekID",i[i.SeekPosition=21420]="SeekPosition",i[i.Duration=17545]="Duration",i[i.Info=0x1549a966]="Info",i[i.TimestampScale=2807729]="TimestampScale",i[i.MuxingApp=19840]="MuxingApp",i[i.WritingApp=22337]="WritingApp",i[i.Tracks=0x1654ae6b]="Tracks",i[i.TrackEntry=174]="TrackEntry",i[i.TrackNumber=215]="TrackNumber",i[i.TrackUID=29637]="TrackUID",i[i.TrackType=131]="TrackType",i[i.FlagEnabled=185]="FlagEnabled",i[i.FlagDefault=136]="FlagDefault",i[i.FlagForced=21930]="FlagForced",i[i.FlagOriginal=21934]="FlagOriginal",i[i.FlagHearingImpaired=21931]="FlagHearingImpaired",i[i.FlagVisualImpaired=21932]="FlagVisualImpaired",i[i.FlagCommentary=21935]="FlagCommentary",i[i.FlagLacing=156]="FlagLacing",i[i.Name=21358]="Name",i[i.Language=2274716]="Language",i[i.LanguageBCP47=2274717]="LanguageBCP47",i[i.CodecID=134]="CodecID",i[i.CodecPrivate=25506]="CodecPrivate",i[i.CodecDelay=22186]="CodecDelay",i[i.SeekPreRoll=22203]="SeekPreRoll",i[i.DefaultDuration=2352003]="DefaultDuration",i[i.Video=224]="Video",i[i.PixelWidth=176]="PixelWidth",i[i.PixelHeight=186]="PixelHeight",i[i.AlphaMode=21440]="AlphaMode",i[i.Audio=225]="Audio",i[i.SamplingFrequency=181]="SamplingFrequency",i[i.Channels=159]="Channels",i[i.BitDepth=25188]="BitDepth",i[i.SimpleBlock=163]="SimpleBlock",i[i.BlockGroup=160]="BlockGroup",i[i.Block=161]="Block",i[i.BlockAdditions=30113]="BlockAdditions",i[i.BlockMore=166]="BlockMore",i[i.BlockAdditional=165]="BlockAdditional",i[i.BlockAddID=238]="BlockAddID",i[i.BlockDuration=155]="BlockDuration",i[i.ReferenceBlock=251]="ReferenceBlock",i[i.Cluster=0x1f43b675]="Cluster",i[i.Timestamp=231]="Timestamp",i[i.Cues=0x1c53bb6b]="Cues",i[i.CuePoint=187]="CuePoint",i[i.CueTime=179]="CueTime",i[i.CueTrackPositions=183]="CueTrackPositions",i[i.CueTrack=247]="CueTrack",i[i.CueClusterPosition=241]="CueClusterPosition",i[i.Colour=21936]="Colour",i[i.MatrixCoefficients=21937]="MatrixCoefficients",i[i.TransferCharacteristics=21946]="TransferCharacteristics",i[i.Primaries=21947]="Primaries",i[i.Range=21945]="Range",i[i.Projection=30320]="Projection",i[i.ProjectionType=30321]="ProjectionType",i[i.ProjectionPoseRoll=30325]="ProjectionPoseRoll",i[i.Attachments=0x1941a469]="Attachments",i[i.AttachedFile=24999]="AttachedFile",i[i.FileDescription=18046]="FileDescription",i[i.FileName=18030]="FileName",i[i.FileMediaType=18016]="FileMediaType",i[i.FileData=18012]="FileData",i[i.FileUID=18094]="FileUID",i[i.Chapters=0x1043a770]="Chapters",i[i.Tags=0x1254c367]="Tags",i[i.Tag=29555]="Tag",i[i.Targets=25536]="Targets",i[i.TargetTypeValue=26826]="TargetTypeValue",i[i.TargetType=25546]="TargetType",i[i.TagTrackUID=25541]="TagTrackUID",i[i.TagEditionUID=25545]="TagEditionUID",i[i.TagChapterUID=25540]="TagChapterUID",i[i.TagAttachmentUID=25542]="TagAttachmentUID",i[i.SimpleTag=26568]="SimpleTag",i[i.TagName=17827]="TagName",i[i.TagLanguage=17530]="TagLanguage",i[i.TagString=17543]="TagString",i[i.TagBinary=17541]="TagBinary",i[i.ContentEncodings=28032]="ContentEncodings",i[i.ContentEncoding=25152]="ContentEncoding",i[i.ContentEncodingOrder=20529]="ContentEncodingOrder",i[i.ContentEncodingScope=20530]="ContentEncodingScope",i[i.ContentCompression=20532]="ContentCompression",i[i.ContentCompAlgo=16980]="ContentCompAlgo",i[i.ContentCompSettings=16981]="ContentCompSettings",i[i.ContentEncryption=20533]="ContentEncryption";var y=[s.EBML,s.Segment],w=[s.SeekHead,s.Info,s.Cluster,s.Tracks,s.Cues,s.Attachments,s.Chapters,s.Tags],S=(0,d._)(y).concat((0,d._)(w)),T=function(e){if(e<256)return 1;if(e<65536)return 2;if(e<0x1000000)return 3;if(e<0x100000000)return 4;if(e<0x10000000000)return 5;else return 6},x=function(e){if(e<1n<<8n)return 1;if(e<1n<<16n)return 2;if(e<1n<<24n)return 3;if(e<1n<<32n)return 4;if(e<1n<<40n)return 5;else if(e<1n<<48n)return 6;else if(e<1n<<56n)return 7;else return 8},I=function(e){if(e>=-64&&e<64)return 1;if(e>=-8192&&e<8192)return 2;if(e>=-1048576&&e<1048576)return 3;if(e>=-0x8000000&&e<0x8000000)return 4;if(e>=-0x400000000&&e<0x400000000)return 5;else return 6},E=function(e){if(e<127)return 1;if(e<16383)return 2;if(e<2097151)return 3;if(e<0xfffffff)return 4;if(e<0x7ffffffff)return 5;else if(e<0x3ffffffffff)return 6;else throw Error("EBML varint size not supported "+e)},j=function(){"use strict";function e(r){(0,u._)(this,e),this.writer=r,this.helper=new Uint8Array(8),this.helperView=new DataView(this.helper.buffer),this.offsets=new WeakMap,this.dataOffsets=new WeakMap}return(0,l._)(e,[{key:"writeByte",value:function(e){this.helperView.setUint8(0,e),this.writer.write(this.helper.subarray(0,1))}},{key:"writeFloat32",value:function(e){this.helperView.setFloat32(0,e,!1),this.writer.write(this.helper.subarray(0,4))}},{key:"writeFloat64",value:function(e){this.helperView.setFloat64(0,e,!1),this.writer.write(this.helper)}},{key:"writeUnsignedInt",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:T(e),n=0;switch(r){case 6:this.helperView.setUint8(n++,e/0x10000000000|0);case 5:this.helperView.setUint8(n++,e/0x100000000|0);case 4:this.helperView.setUint8(n++,e>>24);case 3:this.helperView.setUint8(n++,e>>16);case 2:this.helperView.setUint8(n++,e>>8);case 1:this.helperView.setUint8(n++,e);break;default:throw Error("Bad unsigned int size "+r)}this.writer.write(this.helper.subarray(0,n))}},{key:"writeUnsignedBigInt",value:function(e){for(var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:x(e),n=0,a=r-1;a>=0;a--)this.helperView.setUint8(n++,Number(e>>BigInt(8*a)&255n));this.writer.write(this.helper.subarray(0,n))}},{key:"writeSignedInt",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:I(e);e<0&&(e+=Math.pow(2,8*r)),this.writeUnsignedInt(e,r)}},{key:"writeVarInt",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:E(e),n=0;switch(r){case 1:this.helperView.setUint8(n++,128|e);break;case 2:this.helperView.setUint8(n++,64|e>>8),this.helperView.setUint8(n++,e);break;case 3:this.helperView.setUint8(n++,32|e>>16),this.helperView.setUint8(n++,e>>8),this.helperView.setUint8(n++,e);break;case 4:this.helperView.setUint8(n++,16|e>>24),this.helperView.setUint8(n++,e>>16),this.helperView.setUint8(n++,e>>8),this.helperView.setUint8(n++,e);break;case 5:this.helperView.setUint8(n++,8|e/0x100000000&7),this.helperView.setUint8(n++,e>>24),this.helperView.setUint8(n++,e>>16),this.helperView.setUint8(n++,e>>8),this.helperView.setUint8(n++,e);break;case 6:this.helperView.setUint8(n++,4|e/0x10000000000&3),this.helperView.setUint8(n++,e/0x100000000|0),this.helperView.setUint8(n++,e>>24),this.helperView.setUint8(n++,e>>16),this.helperView.setUint8(n++,e>>8),this.helperView.setUint8(n++,e);break;default:throw Error("Bad EBML varint size "+r)}this.writer.write(this.helper.subarray(0,n))}},{key:"writeAsciiString",value:function(e){this.writer.write(new Uint8Array(e.split("").map(function(e){return e.charCodeAt(0)})))}},{key:"writeEBML",value:function(e){if(null!==e){var r=!0,n=!1,a=void 0;if(e instanceof Uint8Array)this.writer.write(e);else if(Array.isArray(e))try{for(var i,s=e[Symbol.iterator]();!(r=(i=s.next()).done);r=!0){var o=i.value;this.writeEBML(o)}}catch(e){n=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(n)throw a}}else if(this.offsets.set(e,this.writer.getPos()),this.writeUnsignedInt(e.id),Array.isArray(e.data)){var c,u=this.writer.getPos(),l=-1===e.size?1:null!=(c=e.size)?c:4;-1===e.size?this.writeByte(255):this.writer.seek(this.writer.getPos()+l);var d=this.writer.getPos();if(this.dataOffsets.set(e,d),this.writeEBML(e.data),-1!==e.size){var h=this.writer.getPos()-d,p=this.writer.getPos();this.writer.seek(u),this.writeVarInt(h,l),this.writer.seek(p)}}else if("number"==typeof e.data){var y,w=null!=(y=e.size)?y:T(e.data);this.writeVarInt(w),this.writeUnsignedInt(e.data,w)}else if("bigint"===(0,f._)(e.data)){var S,E=null!=(S=e.size)?S:x(e.data);this.writeVarInt(E),this.writeUnsignedBigInt(e.data,E)}else if("string"==typeof e.data)this.writeVarInt(e.data.length),this.writeAsciiString(e.data);else if(e.data instanceof Uint8Array)this.writeVarInt(e.data.byteLength,e.size),this.writer.write(e.data);else if(e.data instanceof g)this.writeVarInt(4),this.writeFloat32(e.data.value);else if(e.data instanceof b)this.writeVarInt(8),this.writeFloat64(e.data.value);else if(e.data instanceof k){var j,P=null!=(j=e.size)?j:I(e.data.value);this.writeVarInt(P),this.writeSignedInt(e.data.value,P)}else if(e.data instanceof _){var C=m.textEncoder.encode(e.data.value);this.writeVarInt(C.length),this.writer.write(C)}else(0,m.assertNever)(e.data)}}}]),e}(),P=8,C=2,A=16,B=function(e){var r=(0,p.readU8)(e);if(e.skip(-1),0===r)return null;for(var n=1,a=128;(r&a)==0;)n++,a>>=1;return n},M=function(e){var r=(0,p.readU8)(e);if(0===r)return null;for(var n=1,a=128;(r&a)==0;)n++,a>>=1;for(var i=r&a-1,s=1;s8)throw Error("Bad unsigned int size "+r);for(var n=0,a=0;as?a:s,found:!1}]}})})()},G=function(e,r,n,a){return(0,c._)(function(){var i,s,o,c,u,l;return(0,h._)(this,function(d){switch(d.label){case 0:i=65536,s=new Set(n),o=r,d.label=1;case 1:if(!(oU&&(U=H.cuePoints.length,R=H)}catch(e){L=!0,N=e}finally{try{O||null==z.return||z.return()}finally{if(L)throw N}}G=!0,q=!1,W=void 0;try{for(K=this.currentSegment.tracks[Symbol.iterator]();!(G=(X=K.next()).done);G=!0)Z=X.value,0===Z.cuePoints.length&&(Z.cuePoints=R.cuePoints)}catch(e){q=!0,W=e}finally{try{G||null==K.return||K.return()}finally{if(q)throw W}}return this.currentSegment=null,[2]}})}).call(this)}},{key:"readCluster",value:function(e,r){return(0,f._)(function(){var n,a,i,s,o,u,l,d,f,h,m,p,g,b,_,w,S,T,x,I,E,P,A,B,M;return(0,y._)(this,function(y){switch(y.label){case 0:if((null==(n=r.lastReadCluster)?void 0:n.elementStartPos)===e)return[2,r.lastReadCluster];if(!((a=this.reader.requestSliceRange(e,C.MIN_HEADER_SIZE,C.MAX_HEADER_SIZE))instanceof Promise))return[3,2];return[4,a];case 1:a=y.sent(),y.label=2;case 2:if((0,j.assert)(a),i=e,s=(0,C.readElementHeader)(a),(0,j.assert)(s),o=s.id,(0,j.assert)(o===C.EBMLId.Cluster),u=s.size,l=a.filePos,null!==u)return[3,4];return[4,(0,C.searchForNextElementId)(this.reader,l,C.LEVEL_0_AND_1_EBML_IDS,r.elementEndPos)];case 3:u=y.sent().pos-l,y.label=4;case 4:if(!((d=this.reader.requestSlice(l,u))instanceof Promise))return[3,6];return[4,d];case 5:d=y.sent(),y.label=6;case 6:f={segment:r,elementStartPos:i,elementEndPos:l+u,dataStartPos:l,timestamp:-1,trackData:new Map},this.currentCluster=f,d&&(f.elementEndPos=this.readContiguousElements(d,C.LEVEL_0_AND_1_EBML_IDS)),h=!0,m=!1,p=void 0;try{for(g=f.trackData[Symbol.iterator]();!(h=(b=g.next()).done);h=!0){for(w=(_=(0,k._)(b.value,2)[1]).track,(0,j.assert)(_.blocks.length>0),S=!1,T=0;T<_.blocks.length;T++)x=_.blocks[T],x.timestamp+=f.timestamp,S||(S=x.lacing!==c.None);for(I=0,_.presentationTimestamps=_.blocks.map(function(e,r){return{timestamp:e.timestamp,blockIndex:r}}).sort(function(e,r){return e.timestamp-r.timestamp});I<_.presentationTimestamps.length;I++)E=_.presentationTimestamps[I],P=_.blocks[E.blockIndex],null===_.firstKeyFrameTimestamp&&P.isKeyFrame&&(_.firstKeyFrameTimestamp=P.timestamp),I<_.presentationTimestamps.length-1?P.duration=_.presentationTimestamps[I+1].timestamp-P.timestamp:0===P.duration&&null!=w.defaultDuration&&P.lacing===c.None&&(P.duration=w.defaultDuration);S&&(this.expandLacedBlocks(_.blocks,w),_.presentationTimestamps=_.blocks.map(function(e,r){return{timestamp:e.timestamp,blockIndex:r}}).sort(function(e,r){return e.timestamp-r.timestamp})),A=_.blocks[_.presentationTimestamps[0].blockIndex],B=_.blocks[(0,j.last)(_.presentationTimestamps).blockIndex],_.startTimestamp=A.timestamp,_.endTimestamp=B.timestamp+B.duration,M=(0,j.binarySearchLessOrEqual)(w.clusterPositionCache,_.startTimestamp,function(e){return e.startTimestamp}),(-1===M||w.clusterPositionCache[M].elementStartPos!==i)&&w.clusterPositionCache.splice(M+1,0,{elementStartPos:f.elementStartPos,startTimestamp:_.startTimestamp})}}catch(e){m=!0,p=e}finally{try{h||null==g.return||g.return()}finally{if(m)throw p}}return r.lastReadCluster=f,[2,f]}})}).call(this)}},{key:"getTrackDataInCluster",value:function(e,r){var n=e.trackData.get(r);if(!n){var a=e.segment.tracks.find(function(e){return e.id===r});if(!a)return null;n={track:a,startTimestamp:0,endTimestamp:0,firstKeyFrameTimestamp:null,blocks:[],presentationTimestamps:[]},e.trackData.set(r,n)}return n}},{key:"expandLacedBlocks",value:function(e,r){for(var n=0;n0;eP.blocks.push({timestamp:eC,duration:0,isKeyFrame:eB,data:eM,lacing:eA>>1&3,decoded:!eD,mainAdditional:null});break;case C.EBMLId.BlockGroup:if(!this.currentCluster)break;this.readContiguousElements(e.slice(f,d)),this.currentBlock=null;break;case C.EBMLId.Block:if(!this.currentCluster)break;var eF=(0,C.readVarInt)(e);if(null===eF)break;var eR=this.getTrackDataInCluster(this.currentCluster,eF);if(!eR)break;var eU=(0,B.readI16Be)(e),eO=(0,B.readU8)(e),eL=(0,B.readBytes)(e,d-(e.filePos-f)),eN=eR.track.decodingInstructions.length>0;this.currentBlock={timestamp:eU,duration:0,isKeyFrame:!0,data:eL,lacing:eO>>1&3,decoded:!eN,mainAdditional:null},eR.blocks.push(this.currentBlock);break;case C.EBMLId.BlockAdditions:this.readContiguousElements(e.slice(f,d));break;case C.EBMLId.BlockMore:if(!this.currentBlock)break;this.currentBlockAdditional={addId:1,data:null},this.readContiguousElements(e.slice(f,d)),this.currentBlockAdditional.data&&1===this.currentBlockAdditional.addId&&(this.currentBlock.mainAdditional=this.currentBlockAdditional.data),this.currentBlockAdditional=null;break;case C.EBMLId.BlockAdditional:if(!this.currentBlockAdditional)break;this.currentBlockAdditional.data=(0,B.readBytes)(e,d);break;case C.EBMLId.BlockAddID:if(!this.currentBlockAdditional)break;this.currentBlockAdditional.addId=(0,C.readUnsignedInt)(e,d);break;case C.EBMLId.BlockDuration:if(!this.currentBlock)break;this.currentBlock.duration=(0,C.readUnsignedInt)(e,d);break;case C.EBMLId.ReferenceBlock:if(!this.currentBlock)break;this.currentBlock.isKeyFrame=!1;break;case C.EBMLId.Tag:this.currentTagTargetIsMovie=!0,this.readContiguousElements(e.slice(f,d));break;case C.EBMLId.Targets:this.readContiguousElements(e.slice(f,d));break;case C.EBMLId.TargetTypeValue:50!==(0,C.readUnsignedInt)(e,d)&&(this.currentTagTargetIsMovie=!1);break;case C.EBMLId.TagTrackUID:case C.EBMLId.TagEditionUID:case C.EBMLId.TagChapterUID:case C.EBMLId.TagAttachmentUID:this.currentTagTargetIsMovie=!1;break;case C.EBMLId.SimpleTag:if(!this.currentTagTargetIsMovie)break;this.currentSimpleTagName=null,this.readContiguousElements(e.slice(f,d));break;case C.EBMLId.TagName:this.currentSimpleTagName=(0,C.readUnicodeString)(e,d);break;case C.EBMLId.TagString:if(!this.currentSimpleTagName)break;var ez=(0,C.readUnicodeString)(e,d);this.processTagValue(this.currentSimpleTagName,ez);break;case C.EBMLId.TagBinary:if(!this.currentSimpleTagName)break;var eV=(0,B.readBytes)(e,d);this.processTagValue(this.currentSimpleTagName,eV);break;case C.EBMLId.AttachedFile:if(!this.currentSegment)break;this.currentAttachedFile={fileUid:null,fileName:null,fileMediaType:null,fileData:null,fileDescription:null},this.readContiguousElements(e.slice(f,d));var eH=this.currentSegment.metadataTags;if(this.currentAttachedFile.fileUid&&this.currentAttachedFile.fileData&&(null!=eH.raw||(eH.raw={}),eH.raw[this.currentAttachedFile.fileUid.toString()]=new(0,E.AttachedFile)(this.currentAttachedFile.fileData,null!=(eq=this.currentAttachedFile.fileMediaType)?eq:void 0,null!=(eW=this.currentAttachedFile.fileName)?eW:void 0,null!=(eK=this.currentAttachedFile.fileDescription)?eK:void 0)),(null==(eG=this.currentAttachedFile.fileMediaType)?void 0:eG.startsWith("image/"))&&this.currentAttachedFile.fileData){var eG,eq,eW,eK,eX,eZ,eQ=this.currentAttachedFile.fileName,eY="unknown";if(eQ){var eJ=eQ.toLowerCase();eJ.startsWith("cover.")?eY="coverFront":eJ.startsWith("back.")&&(eY="coverBack")}null!=eH.images||(eH.images=[]),eH.images.push({data:this.currentAttachedFile.fileData,mimeType:this.currentAttachedFile.fileMediaType,kind:eY,name:null!=(eX=this.currentAttachedFile.fileName)?eX:void 0,description:null!=(eZ=this.currentAttachedFile.fileDescription)?eZ:void 0})}this.currentAttachedFile=null;break;case C.EBMLId.FileUID:if(!this.currentAttachedFile)break;this.currentAttachedFile.fileUid=(0,C.readUnsignedBigInt)(e,d);break;case C.EBMLId.FileName:if(!this.currentAttachedFile)break;this.currentAttachedFile.fileName=(0,C.readUnicodeString)(e,d);break;case C.EBMLId.FileMediaType:if(!this.currentAttachedFile)break;this.currentAttachedFile.fileMediaType=(0,C.readAsciiString)(e,d);break;case C.EBMLId.FileData:if(!this.currentAttachedFile)break;this.currentAttachedFile.fileData=(0,B.readBytes)(e,d);break;case C.EBMLId.FileDescription:if(!this.currentAttachedFile)break;this.currentAttachedFile.fileDescription=(0,C.readUnicodeString)(e,d);break;case C.EBMLId.ContentEncodings:if(!this.currentTrack)break;this.readContiguousElements(e.slice(f,d)),this.currentTrack.decodingInstructions.sort(function(e,r){return r.order-e.order});break;case C.EBMLId.ContentEncoding:this.currentDecodingInstruction={order:0,scope:u.Block,data:null},this.readContiguousElements(e.slice(f,d)),this.currentDecodingInstruction.data&&this.currentTrack.decodingInstructions.push(this.currentDecodingInstruction),this.currentDecodingInstruction=null;break;case C.EBMLId.ContentEncodingOrder:if(!this.currentDecodingInstruction)break;this.currentDecodingInstruction.order=(0,C.readUnsignedInt)(e,d);break;case C.EBMLId.ContentEncodingScope:if(!this.currentDecodingInstruction)break;this.currentDecodingInstruction.scope=(0,C.readUnsignedInt)(e,d);break;case C.EBMLId.ContentCompression:if(!this.currentDecodingInstruction)break;this.currentDecodingInstruction.data={type:"decompress",algorithm:l.Zlib,settings:null},this.readContiguousElements(e.slice(f,d));break;case C.EBMLId.ContentCompAlgo:if((null==(a=this.currentDecodingInstruction)||null==(n=a.data)?void 0:n.type)!=="decompress")break;this.currentDecodingInstruction.data.algorithm=(0,C.readUnsignedInt)(e,d);break;case C.EBMLId.ContentCompSettings:if((null==(s=this.currentDecodingInstruction)||null==(i=s.data)?void 0:i.type)!=="decompress")break;this.currentDecodingInstruction.data.settings=(0,B.readBytes)(e,d);break;case C.EBMLId.ContentEncryption:if(!this.currentDecodingInstruction)break;this.currentDecodingInstruction.data={type:"decrypt"}}return e.filePos=f+d,!0}},{key:"decodeBlockData",value:function(e,r){(0,j.assert)(e.decodingInstructions.length>0);var n=r,a=!0,i=!1,s=void 0;try{for(var o,c=e.decodingInstructions[Symbol.iterator]();!(a=(o=c.next()).done);a=!0){var u=o.value;if((0,j.assert)(u.data),"decompress"===u.data.type&&u.data.algorithm===l.HeaderStripping&&u.data.settings&&u.data.settings.length>0){var d=u.data.settings,f=new Uint8Array(d.length+n.length);f.set(d,0),f.set(n,d.length),n=f}}}catch(e){i=!0,s=e}finally{try{a||null==c.return||c.return()}finally{if(i)throw s}}return n}},{key:"processTagValue",value:function(e,r){if(null==(a=this.currentSegment)?void 0:a.metadataTags){var n=this.currentSegment.metadataTags;if(null!=n.raw||(n.raw={}),null!=(i=n.raw)[e]||(i[e]=r),"string"==typeof r)switch(e.toLowerCase()){case"title":null!=n.title||(n.title=r);break;case"description":null!=n.description||(n.description=r);break;case"artist":null!=n.artist||(n.artist=r);break;case"album":null!=n.album||(n.album=r);break;case"album_artist":null!=n.albumArtist||(n.albumArtist=r);break;case"genre":null!=n.genre||(n.genre=r);break;case"comment":null!=n.comment||(n.comment=r);break;case"lyrics":null!=n.lyrics||(n.lyrics=r);break;case"date":var a,i,s=new Date(r);Number.isNaN(s.getTime())||null!=n.date||(n.date=s);break;case"track_number":case"part_number":var o=r.split("/"),c=Number.parseInt(o[0],10),u=o[1]&&Number.parseInt(o[1],10);Number.isInteger(c)&&c>0&&(null!=n.trackNumber||(n.trackNumber=c)),u&&Number.isInteger(u)&&u>0&&(null!=n.tracksTotal||(n.tracksTotal=u));break;case"disc_number":case"disc":var l=r.split("/"),d=Number.parseInt(l[0],10),f=l[1]&&Number.parseInt(l[1],10);Number.isInteger(d)&&d>0&&(null!=n.discNumber||(n.discNumber=d)),f&&Number.isInteger(f)&&f>0&&(null!=n.discsTotal||(n.discsTotal=f))}}}}]),r}(x.Demuxer),F=function(){"use strict";function e(r){(0,m._)(this,e),this.internalTrack=r,this.packetToClusterLocation=new WeakMap}return(0,p._)(e,[{key:"getId",value:function(){return this.internalTrack.id}},{key:"getCodec",value:function(){throw Error("Not implemented on base class.")}},{key:"getInternalCodecId",value:function(){return this.internalTrack.codecId}},{key:"computeDuration",value:function(){return(0,f._)(function(){var e,r,n;return(0,y._)(this,function(a){switch(a.label){case 0:return[4,this.getPacket(1/0,{metadataOnly:!0})];case 1:return[2,(null!=(r=null==(e=a.sent())?void 0:e.timestamp)?r:0)+(null!=(n=null==e?void 0:e.duration)?n:0)]}})}).call(this)}},{key:"getName",value:function(){return this.internalTrack.name}},{key:"getLanguageCode",value:function(){return this.internalTrack.languageCode}},{key:"getFirstTimestamp",value:function(){return(0,f._)(function(){var e,r;return(0,y._)(this,function(n){switch(n.label){case 0:return[4,this.getFirstPacket({metadataOnly:!0})];case 1:return[2,null!=(r=null==(e=n.sent())?void 0:e.timestamp)?r:0]}})}).call(this)}},{key:"getTimeResolution",value:function(){return this.internalTrack.segment.timestampFactor}},{key:"getDisposition",value:function(){return this.internalTrack.disposition}},{key:"getFirstPacket",value:function(e){return(0,f._)(function(){var r;return(0,y._)(this,function(n){return r=this,[2,this.performClusterLookup(null,function(e){return e.trackData.get(r.internalTrack.id)?{blockIndex:0,correctBlockFound:!0}:{blockIndex:-1,correctBlockFound:!1}},-1/0,1/0,e)]})}).call(this)}},{key:"intoTimescale",value:function(e){return(0,j.roundIfAlmostInteger)(e*this.internalTrack.segment.timestampFactor)}},{key:"getPacket",value:function(e,r){return(0,f._)(function(){var n,a;return(0,y._)(this,function(i){return n=this,a=this.intoTimescale(e),[2,this.performClusterLookup(null,function(e){var r=e.trackData.get(n.internalTrack.id);if(!r)return{blockIndex:-1,correctBlockFound:!1};var i=(0,j.binarySearchLessOrEqual)(r.presentationTimestamps,a,function(e){return e.timestamp});return{blockIndex:-1!==i?r.presentationTimestamps[i].blockIndex:-1,correctBlockFound:-1!==i&&aa.blockIndex});if(-1!==r)return{blockIndex:r,correctBlockFound:!0}}else{var i=e.trackData.get(n.internalTrack.id);if(i&&null!==i.firstKeyFrameTimestamp){var s=i.blocks.findIndex(function(e){return e.isKeyFrame});return(0,j.assert)(-1!==s),{blockIndex:s,correctBlockFound:!0}}}return{blockIndex:-1,correctBlockFound:!1}},-1/0,1/0,r)]})}).call(this)}},{key:"fetchPacketInCluster",value:function(e,r,n){return(0,f._)(function(){var a,i,s,o,c,u,l;return(0,y._)(this,function(d){return -1===r?[2,null]:(i=e.trackData.get(this.internalTrack.id).blocks[r],(0,j.assert)(i),i.decoded||(i.data=this.internalTrack.demuxer.decodeBlockData(this.internalTrack,i.data),i.decoded=!0),s=n.metadataOnly?P.PLACEHOLDER_DATA:i.data,o=i.timestamp/this.internalTrack.segment.timestampFactor,c=i.duration/this.internalTrack.segment.timestampFactor,u={},i.mainAdditional&&(null==(a=this.internalTrack.info)?void 0:a.type)==="video"&&this.internalTrack.info.alphaMode&&(u.alpha=n.metadataOnly?P.PLACEHOLDER_DATA:i.mainAdditional,u.alphaByteLength=i.mainAdditional.byteLength),l=new(0,P.EncodedPacket)(s,i.isKeyFrame?"key":"delta",o,c,e.dataStartPos+r,i.data.byteLength,u),this.packetToClusterLocation.set(l,{cluster:e,blockIndex:r}),[2,l])})}).call(this)}},{key:"performClusterLookup",value:function(e,r,n,a,i){return(0,f._)(function(){var s,o,c,u,l,d,f,h,m,p,g,b,k,_,w,S,T,x,I,E,P,A,B,M,D,F,R,U,O,L,N,z;return(0,y._)(this,function(y){switch(y.label){case 0:if(o=(s=this.internalTrack).demuxer,c=s.segment,u=null,l=null,d=-1,e){if(h=(f=r(e)).blockIndex,f.correctBlockFound)return[2,this.fetchPacketInCluster(e,h,i)];-1!==h&&(l=e,d=h)}p=-1!==(m=(0,j.binarySearchLessOrEqual)(this.internalTrack.cuePoints,n,function(e){return e.time}))?this.internalTrack.cuePoints[m]:null,b=-1!==(g=(0,j.binarySearchLessOrEqual)(this.internalTrack.clusterPositionCache,n,function(e){return e.startTimestamp}))?this.internalTrack.clusterPositionCache[g]:null,w=Math.max(null!=(k=null==p?void 0:p.clusterPosition)?k:0,null!=(_=null==b?void 0:b.elementStartPos)?_:0)||null,e?null===w||e.elementStartPos>=w?(S=e.elementEndPos,u=e):S=w:S=null!=w?w:c.clusterSeekStartPos,y.label=1;case 1:if(!(null===c.elementEndPos||S<=c.elementEndPos-C.MIN_HEADER_SIZE)||u&&(T=u.trackData.get(this.internalTrack.id))&&T.startTimestamp>a)return[3,13];if(!((x=o.reader.requestSliceRange(S,C.MIN_HEADER_SIZE,C.MAX_HEADER_SIZE))instanceof Promise))return[3,3];return[4,x];case 2:x=y.sent(),y.label=3;case 3:if(!x)return[3,13];if(I=S,!(!(E=(0,C.readElementHeader)(x))||!C.LEVEL_1_EBML_IDS.includes(E.id)&&E.id!==C.EBMLId.Void))return[3,5];return[4,(0,C.resync)(o.reader,I,C.LEVEL_1_EBML_IDS,Math.min(null!=(P=c.elementEndPos)?P:1/0,I+0xa00000))];case 4:if(A=y.sent())return S=A,[3,1];return[3,13];case 5:if(B=E.id,M=E.size,D=x.filePos,B!==C.EBMLId.Cluster)return[3,7];return[4,o.readCluster(I,c)];case 6:if(M=(u=y.sent()).elementEndPos-D,R=(F=r(u)).blockIndex,F.correctBlockFound)return[2,this.fetchPacketInCluster(u,R,i)];-1!==R&&(l=u,d=R),y.label=7;case 7:if(null!==M)return[3,9];return(0,j.assert)(B!==C.EBMLId.Cluster),[4,(0,C.searchForNextElementId)(o.reader,D,C.LEVEL_0_AND_1_EBML_IDS,c.elementEndPos)];case 8:M=y.sent().pos-D,y.label=9;case 9:if(U=D+M,null!==c.elementEndPos)return[3,12];if(!((O=o.reader.requestSliceRange(U,C.MIN_HEADER_SIZE,C.MAX_HEADER_SIZE))instanceof Promise))return[3,11];return[4,O];case 10:O=y.sent(),y.label=11;case 11:if(!O)return[3,13];if((0,C.readElementId)(O)===C.EBMLId.Segment)return c.elementEndPos=U,[3,13];y.label=12;case 12:return S=U,[3,1];case 13:if(p&&(!l||l.elementStartPos0){var n=(0,s._)(new Set(e.codecStrings.filter(Boolean)));r+='; codecs="'.concat(n.join(", "),'"')}return r}},{"@swc/helpers/cjs/_to_consumable_array.cjs":"i81N6","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],ifShX:[function(e,r,n,a){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(n),i.export(n,"Mp3Demuxer",function(){return S});var s=e("@swc/helpers/cjs/_async_to_generator.cjs"),o=e("@swc/helpers/cjs/_call_super.cjs"),c=e("@swc/helpers/cjs/_class_call_check.cjs"),u=e("@swc/helpers/cjs/_create_class.cjs"),l=e("@swc/helpers/cjs/_inherits.cjs"),d=e("@swc/helpers/cjs/_object_spread.cjs"),f=e("@swc/helpers/cjs/_ts_generator.cjs"),h=e("../demuxer.js"),m=e("../input-track.js"),p=e("../metadata.js"),g=e("../misc.js"),b=e("../packet.js"),k=e("../../shared/mp3-misc.js"),_=e("../id3.js"),y=e("./mp3-reader.js"),w=e("../reader.js"),S=function(e){"use strict";function r(e){var n;return(0,c._)(this,r),(n=(0,o._)(this,r,[e])).metadataPromise=null,n.firstFrameHeader=null,n.loadedSamples=[],n.metadataTags=null,n.tracks=[],n.readingMutex=new(0,g.AsyncMutex),n.lastSampleLoaded=!1,n.lastLoadedPos=0,n.nextTimestampInSamples=0,n.reader=e._reader,n}return(0,l._)(r,e),(0,u._)(r,[{key:"readMetadata",value:function(){return(0,s._)(function(){var e,r;return(0,f._)(this,function(n){return e=this,[2,null!=(r=this.metadataPromise)?r:this.metadataPromise=(0,s._)(function(){return(0,f._)(this,function(e){switch(e.label){case 0:if(!(!this.firstFrameHeader&&!this.lastSampleLoaded))return[3,2];return[4,this.advanceReader()];case 1:return e.sent(),[3,0];case 2:if(!this.firstFrameHeader)throw Error("No valid MP3 frame found.");return this.tracks=[new(0,m.InputAudioTrack)(this.input,new T(this))],[2]}})}).call(e)]})}).call(this)}},{key:"advanceReader",value:function(){return(0,s._)(function(){var e,r,n,a,i,s,o,c,u;return(0,f._)(this,function(l){switch(l.label){case 0:if(0!==this.lastLoadedPos)return[3,4];l.label=1;case 1:if(!((e=this.reader.requestSlice(this.lastLoadedPos,_.ID3_V2_HEADER_SIZE))instanceof Promise))return[3,3];return[4,e];case 2:e=l.sent(),l.label=3;case 3:if(!e)return this.lastSampleLoaded=!0,[2];if(!(r=(0,_.readId3V2Header)(e)))return[3,4];return this.lastLoadedPos=e.filePos+r.size,[3,1];case 4:return[4,(0,y.readNextFrameHeader)(this.reader,this.lastLoadedPos,this.reader.fileSize)];case 5:if(!(n=l.sent()))return this.lastSampleLoaded=!0,[2];if(a=n.header,this.lastLoadedPos=n.startPos+a.totalSize-1,i=(0,k.getXingOffset)(a.mpegVersionId,a.channel),!((s=this.reader.requestSlice(n.startPos+i,4))instanceof Promise))return[3,7];return[4,s];case 6:s=l.sent(),l.label=7;case 7:if(s&&((o=(0,w.readU32Be)(s))===k.XING||o===k.INFO))return[2];return this.firstFrameHeader||(this.firstFrameHeader=a),a.sampleRate!==this.firstFrameHeader.sampleRate&&console.warn("MP3 changed sample rate mid-file: ".concat(this.firstFrameHeader.sampleRate," Hz to ").concat(a.sampleRate," Hz.")+" Might be a bug, so please report this file."),c=a.audioSamplesInFrame/this.firstFrameHeader.sampleRate,u={timestamp:this.nextTimestampInSamples/this.firstFrameHeader.sampleRate,duration:c,dataStart:n.startPos,dataSize:a.totalSize},this.loadedSamples.push(u),this.nextTimestampInSamples+=a.audioSamplesInFrame,[2]}})}).call(this)}},{key:"getMimeType",value:function(){return(0,s._)(function(){return(0,f._)(this,function(e){return[2,"audio/mpeg"]})})()}},{key:"getTracks",value:function(){return(0,s._)(function(){return(0,f._)(this,function(e){switch(e.label){case 0:return[4,this.readMetadata()];case 1:return e.sent(),[2,this.tracks]}})}).call(this)}},{key:"computeDuration",value:function(){return(0,s._)(function(){var e;return(0,f._)(this,function(r){switch(r.label){case 0:return[4,this.readMetadata()];case 1:return r.sent(),e=this.tracks[0],(0,g.assert)(e),[2,e.computeDuration()]}})}).call(this)}},{key:"getMetadataTags",value:function(){return(0,s._)(function(){var e,r,n,a,i,s,o;return(0,f._)(this,function(c){switch(c.label){case 0:return[4,this.readingMutex.acquire()];case 1:e=c.sent(),c.label=2;case 2:return c.trys.push([2,,13,14]),[4,this.readMetadata()];case 3:if(c.sent(),this.metadataTags)return[2,this.metadataTags];this.metadataTags={},r=0,n=!1,c.label=4;case 4:if(!((a=this.reader.requestSlice(r,_.ID3_V2_HEADER_SIZE))instanceof Promise))return[3,6];return[4,a];case 5:a=c.sent(),c.label=6;case 6:if(!a||!(i=(0,_.readId3V2Header)(a)))return[3,9];if(n=!0,!((s=this.reader.requestSlice(a.filePos,i.size))instanceof Promise))return[3,8];return[4,s];case 7:s=c.sent(),c.label=8;case 8:if(!s)return[3,9];return(0,_.parseId3V2Tag)(s,i,this.metadataTags),r=a.filePos+i.size,[3,4];case 9:if(!(!n&&null!==this.reader.fileSize&&this.reader.fileSize>=_.ID3_V1_TAG_SIZE))return[3,12];if(!((o=this.reader.requestSlice(this.reader.fileSize-_.ID3_V1_TAG_SIZE,_.ID3_V1_TAG_SIZE))instanceof Promise))return[3,11];return[4,o];case 10:o=c.sent(),c.label=11;case 11:(0,g.assert)(o),"TAG"===(0,w.readAscii)(o,3)&&(0,_.parseId3V1Tag)(o,this.metadataTags),c.label=12;case 12:return[2,this.metadataTags];case 13:return e(),[7];case 14:return[2]}})}).call(this)}}]),r}(h.Demuxer),T=function(){"use strict";function e(r){(0,c._)(this,e),this.demuxer=r}return(0,u._)(e,[{key:"getId",value:function(){return 1}},{key:"getFirstTimestamp",value:function(){return(0,s._)(function(){return(0,f._)(this,function(e){return[2,0]})})()}},{key:"getTimeResolution",value:function(){return(0,g.assert)(this.demuxer.firstFrameHeader),this.demuxer.firstFrameHeader.sampleRate/this.demuxer.firstFrameHeader.audioSamplesInFrame}},{key:"computeDuration",value:function(){return(0,s._)(function(){var e,r,n;return(0,f._)(this,function(a){switch(a.label){case 0:return[4,this.getPacket(1/0,{metadataOnly:!0})];case 1:return[2,(null!=(r=null==(e=a.sent())?void 0:e.timestamp)?r:0)+(null!=(n=null==e?void 0:e.duration)?n:0)]}})}).call(this)}},{key:"getName",value:function(){return null}},{key:"getLanguageCode",value:function(){return g.UNDETERMINED_LANGUAGE}},{key:"getCodec",value:function(){return"mp3"}},{key:"getInternalCodecId",value:function(){return null}},{key:"getNumberOfChannels",value:function(){return(0,g.assert)(this.demuxer.firstFrameHeader),3===this.demuxer.firstFrameHeader.channel?1:2}},{key:"getSampleRate",value:function(){return(0,g.assert)(this.demuxer.firstFrameHeader),this.demuxer.firstFrameHeader.sampleRate}},{key:"getDisposition",value:function(){return(0,d._)({},p.DEFAULT_TRACK_DISPOSITION)}},{key:"getDecoderConfig",value:function(){return(0,s._)(function(){return(0,f._)(this,function(e){return(0,g.assert)(this.demuxer.firstFrameHeader),[2,{codec:"mp3",numberOfChannels:3===this.demuxer.firstFrameHeader.channel?1:2,sampleRate:this.demuxer.firstFrameHeader.sampleRate}]})}).call(this)}},{key:"getPacketAtIndex",value:function(e,r){return(0,s._)(function(){var n,a,i;return(0,f._)(this,function(s){switch(s.label){case 0:if(-1===e||!(n=this.demuxer.loadedSamples[e]))return[2,null];if(!r.metadataOnly)return[3,1];return a=b.PLACEHOLDER_DATA,[3,4];case 1:if(!((i=this.demuxer.reader.requestSlice(n.dataStart,n.dataSize))instanceof Promise))return[3,3];return[4,i];case 2:i=s.sent(),s.label=3;case 3:if(!i)return[2,null];a=(0,w.readBytes)(i,n.dataSize),s.label=4;case 4:return[2,new(0,b.EncodedPacket)(a,"key",n.timestamp,n.duration,e,n.dataSize)]}})}).call(this)}},{key:"getFirstPacket",value:function(e){return this.getPacketAtIndex(0,e)}},{key:"getNextPacket",value:function(e,r){return(0,s._)(function(){var n,a,i;return(0,f._)(this,function(s){switch(s.label){case 0:return[4,this.demuxer.readingMutex.acquire()];case 1:n=s.sent(),s.label=2;case 2:if(s.trys.push([2,,6,7]),-1===(a=(0,g.binarySearchExact)(this.demuxer.loadedSamples,e.timestamp,function(e){return e.timestamp})))throw Error("Packet was not created from this track.");i=a+1,s.label=3;case 3:if(!(i>=this.demuxer.loadedSamples.length&&!this.demuxer.lastSampleLoaded))return[3,5];return[4,this.demuxer.advanceReader()];case 4:return s.sent(),[3,3];case 5:return[2,this.getPacketAtIndex(i,r)];case 6:return n(),[7];case 7:return[2]}})}).call(this)}},{key:"getPacket",value:function(e,r){return(0,s._)(function(){var n,a;return(0,f._)(this,function(i){switch(i.label){case 0:return[4,this.demuxer.readingMutex.acquire()];case 1:n=i.sent(),i.label=2;case 2:i.trys.push([2,,6,7]),i.label=3;case 3:if(-1===(a=(0,g.binarySearchLessOrEqual)(this.demuxer.loadedSamples,e,function(e){return e.timestamp}))&&this.demuxer.loadedSamples.length>0)return[2,null];if(this.demuxer.lastSampleLoaded||a>=0&&a+1>>24,i=e>>>16&255,s=e>>>8&255,u=255&e;if(255!==a&&255!==i&&255!==s&&255!==u)return{header:null,bytesAdvanced:4};if(255!==a||(224&i)!=224)return{header:null,bytesAdvanced:1};var l=0,f=0;16&i?l=8&i?0:1:(l=1,f=1);var h=i>>3&3,m=i>>1&3,p=(s>>2&3)%3,g=c[64*l+16*m+(s>>4&15)];if(-1===g)return{header:null,bytesAdvanced:1};var b=1e3*g,k=o[p]>>l+f,_=d(l,m,b,k,s>>1&1);return null!==r&&r<_?{header:null,bytesAdvanced:1}:(n=3===h?3===m?384:1152:3===m?384:2===m?1152:576,{header:{totalSize:_,mpegVersionId:h,layer:m,bitrate:b,frequencyIndex:p,sampleRate:k,channel:u>>6&3,modeExtension:u>>4&3,copyright:u>>3&1,original:u>>2&1,emphasis:3&u,audioSamplesInFrame:n},bytesAdvanced:1})},m=function(e){for(var r=127,n=0,a=e;(0x7fffffff^r)!=0;)n=(a&~r)<<1|a&r,r=(r+1<<8)-1,a=n;return n},p=function(e){for(var r=0x7f000000,n=0;0!==r;)n>>=1,n|=e&r,r>>=8;return n}},{"@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],"42Y2c":[function(e,r,n,a){var i,s,o,c,u=e("@parcel/transformer-js/src/esmodule-helpers.js");u.defineInteropFlag(n),u.export(n,"Id3V2HeaderFlags",function(){return o}),u.export(n,"Id3V2TextEncoding",function(){return c}),u.export(n,"ID3_V1_TAG_SIZE",function(){return p}),u.export(n,"ID3_V2_HEADER_SIZE",function(){return g}),u.export(n,"ID3_V1_GENRES",function(){return b}),u.export(n,"parseId3V1Tag",function(){return k}),u.export(n,"readId3V1String",function(){return _}),u.export(n,"readId3V2Header",function(){return y}),u.export(n,"parseId3V2Tag",function(){return w}),u.export(n,"Id3V2Reader",function(){return S}),u.export(n,"Id3V2Writer",function(){return T});var l=e("@swc/helpers/cjs/_class_call_check.cjs"),d=e("@swc/helpers/cjs/_create_class.cjs"),f=e("../shared/mp3-misc.js"),h=e("./misc.js"),m=e("./reader.js");(i=o||(o={}))[i.Unsynchronisation=128]="Unsynchronisation",i[i.ExtendedHeader=64]="ExtendedHeader",i[i.ExperimentalIndicator=32]="ExperimentalIndicator",i[i.Footer=16]="Footer",(s=c||(c={}))[s.ISO_8859_1=0]="ISO_8859_1",s[s.UTF_16_WITH_BOM=1]="UTF_16_WITH_BOM",s[s.UTF_16_BE_NO_BOM=2]="UTF_16_BE_NO_BOM",s[s.UTF_8=3]="UTF_8";var p=128,g=10,b=["Blues","Classic rock","Country","Dance","Disco","Funk","Grunge","Hip-hop","Jazz","Metal","New age","Oldies","Other","Pop","Rhythm and blues","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","Alternative rock","Bass","Soul","Punk","Space","Meditative","Instrumental pop","Instrumental rock","Ethnic","Gothic","Darkwave","Techno-industrial","Electronic","Pop-folk","Eurodance","Dream","Southern rock","Comedy","Cult","Gangsta","Top 40","Christian rap","Pop/funk","Jungle music","Native US","Cabaret","New wave","Psychedelic","Rave","Showtunes","Trailer","Lo-fi","Tribal","Acid punk","Acid jazz","Polka","Retro","Musical","Rock 'n' roll","Hard rock","Folk","Folk rock","National folk","Swing","Fast fusion","Bebop","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 music","Drum & bass","Club-house","Hardcore techno","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","Christmas","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"],k=function(e,r){var n=e.filePos;null!=r.raw||(r.raw={}),null!=(u=r.raw).TAG||(u.TAG=(0,m.readBytes)(e,p-3)),e.filePos=n;var a=_(e,30);a&&(null!=r.title||(r.title=a));var i=_(e,30);i&&(null!=r.artist||(r.artist=i));var s=_(e,30);s&&(null!=r.album||(r.album=s));var o=Number.parseInt(_(e,4),10);Number.isInteger(o)&&o>0&&(null!=r.date||(r.date=new Date(o,0,1)));var c=(0,m.readBytes)(e,30);if(0===c[28]&&0!==c[29]){var u,l,d=c[29];d>0&&(null!=r.trackNumber||(r.trackNumber=d)),e.skip(-30),l=_(e,28),e.skip(2)}else e.skip(-30),l=_(e,30);l&&(null!=r.comment||(r.comment=l));var f=(0,m.readU8)(e);f0&&(null!=n.trackNumber||(n.trackNumber=w)),T&&Number.isInteger(T)&&T>0&&(null!=n.tracksTotal||(n.tracksTotal=T));break;case"TPOS":case"TPA":var x=i.readId3V2EncodingAndText(l).split("/"),I=Number.parseInt(x[0],10),E=x[1]&&Number.parseInt(x[1],10);Number.isInteger(I)&&I>0&&(null!=n.discNumber||(n.discNumber=I)),E&&Number.isInteger(E)&&E>0&&(null!=n.discsTotal||(n.discsTotal=E));break;case"TCON":case"TCO":var j=i.readId3V2EncodingAndText(l),P=/^\((\d+)\)/.exec(j);if(P){var C=Number.parseInt(P[1]);if(void 0!==b[C]){null!=n.genre||(n.genre=b[C]);break}}if(P=/^\d+$/.exec(j)){var A=Number.parseInt(P[0]);if(void 0!==b[A]){null!=n.genre||(n.genre=b[A]);break}}null!=n.genre||(n.genre=j);break;case"TDRC":case"TDAT":var B=new Date(i.readId3V2EncodingAndText(l));Number.isNaN(B.getTime())||null!=n.date||(n.date=B);break;case"TYER":case"TYE":var M=Number.parseInt(i.readId3V2EncodingAndText(l),10);Number.isInteger(M)&&(null!=n.date||(n.date=new Date(M,0,1)));break;case"USLT":case"ULT":var D=i.readU8();i.pos+=3,i.readId3V2Text(D,l),null!=n.lyrics||(n.lyrics=i.readId3V2Text(D,l));break;case"COMM":case"COM":var F=i.readU8();i.pos+=3,i.readId3V2Text(F,l),null!=n.comment||(n.comment=i.readId3V2Text(F,l));break;case"APIC":case"PIC":var R=i.readId3V2TextEncoding(),U=void 0;if(2===r.majorVersion){var O=i.readAscii(3);U="PNG"===O?"image/png":"JPG"===O?"image/jpeg":"image/*"}else U=i.readId3V2Text(R,l);var L=i.readU8(),N=i.readId3V2Text(R,l).trimEnd(),z=l-i.pos;if(z>=0){var V=i.readBytes(z);n.images||(n.images=[]),n.images.push({data:V,mimeType:U,kind:3===L?"coverFront":4===L?"coverBack":"unknown",description:N})}break;default:i.pos+=c.size}i.pos=l}},S=function(){"use strict";function e(r,n){(0,l._)(this,e),this.header=r,this.bytes=n,this.pos=0,this.view=new DataView(n.buffer,n.byteOffset,n.byteLength)}return(0,d._)(e,[{key:"frameHeaderSize",value:function(){return 2===this.header.majorVersion?6:10}},{key:"ununsynchronizeAll",value:function(){for(var e=[],r=0;re.bytes.length)return!1;if(n<=e.bytes.length-e.frameHeaderSize()){e.pos+=r;var a=e.readAscii(4);if("\0\0\0\0"!==a&&!/[0-9A-Z]{4}/.test(a))return!1}return!0};if(!c(i)){var u=4===this.header.majorVersion?a:(0,f.decodeSynchsafe)(a);c(u)&&(i=u)}return this.pos=o,{id:n,size:i,flags:s}}},{key:"readId3V2TextEncoding",value:function(){var e=this.readU8();if(e>3)throw Error("Unsupported text encoding: ".concat(e));return e}},{key:"readId3V2Text",value:function(e,r){var n=this.pos,a=this.readBytes(r-this.pos);switch(e){case c.ISO_8859_1:for(var i="",s=0;s=e)return"";var r=this.readId3V2TextEncoding();return this.readId3V2Text(r,e)}}]),e}(),T=function(){"use strict";function e(r){(0,l._)(this,e),this.helper=new Uint8Array(8),this.helperView=(0,h.toDataView)(this.helper),this.writer=r}return(0,d._)(e,[{key:"writeId3V2Tag",value:function(e){var r=this.writer.getPos();this.writeAscii("ID3"),this.writeU8(4),this.writeU8(0),this.writeU8(0),this.writeSynchsafeU32(0);var n=this.writer.getPos(),a=new Set,i=!0,s=!1,o=void 0;try{for(var u,l=(0,h.keyValueIterator)(e)[Symbol.iterator]();!(i=(u=l.next()).done);i=!0){var d=u.value,f=d.key,m=d.value;switch(f){case"title":this.writeId3V2TextFrame("TIT2",m),a.add("TIT2");break;case"description":this.writeId3V2TextFrame("TIT3",m),a.add("TIT3");break;case"artist":this.writeId3V2TextFrame("TPE1",m),a.add("TPE1");break;case"album":this.writeId3V2TextFrame("TALB",m),a.add("TALB");break;case"albumArtist":this.writeId3V2TextFrame("TPE2",m),a.add("TPE2");break;case"trackNumber":var p=void 0!==e.tracksTotal?"".concat(m,"/").concat(e.tracksTotal):m.toString();this.writeId3V2TextFrame("TRCK",p),a.add("TRCK");break;case"discNumber":var g=void 0!==e.discsTotal?"".concat(m,"/").concat(e.discsTotal):m.toString();this.writeId3V2TextFrame("TPOS",g),a.add("TPOS");break;case"genre":this.writeId3V2TextFrame("TCON",m),a.add("TCON");break;case"date":this.writeId3V2TextFrame("TDRC",m.toISOString().slice(0,10)),a.add("TDRC");break;case"lyrics":this.writeId3V2LyricsFrame(m),a.add("USLT");break;case"comment":this.writeId3V2CommentFrame(m),a.add("COMM");break;case"images":var b={coverFront:3,coverBack:4,unknown:0},k=!0,_=!1,y=void 0;try{for(var w,S=m[Symbol.iterator]();!(k=(w=S.next()).done);k=!0){var T,x,I=w.value,E=null!=(T=b[I.kind])?T:0,j=null!=(x=I.description)?x:"";this.writeId3V2ApicFrame(I.mimeType,E,j,I.data)}}catch(e){_=!0,y=e}finally{try{k||null==S.return||S.return()}finally{if(_)throw y}}break;case"tracksTotal":case"discsTotal":case"raw":break;default:(0,h.assertNever)(f)}}}catch(e){s=!0,o=e}finally{try{i||null==l.return||l.return()}finally{if(s)throw o}}if(e.raw)for(var P in e.raw){var C=e.raw[P];if(!(null==C||4!==P.length||a.has(P))){var A=void 0;if("string"==typeof C){var B=h.textEncoder.encode(C);(A=new Uint8Array(B.byteLength+2))[0]=c.UTF_8,A.set(B,1)}else{if(!(C instanceof Uint8Array))continue;A=C}this.writeAscii(P),this.writeSynchsafeU32(A.byteLength),this.writeU16(0),this.writer.write(A)}}var M=this.writer.getPos(),D=M-n;return this.writer.seek(r+6),this.writeSynchsafeU32(D),this.writer.seek(M),D+10}},{key:"writeU8",value:function(e){this.helper[0]=e,this.writer.write(this.helper.subarray(0,1))}},{key:"writeU16",value:function(e){this.helperView.setUint16(0,e,!1),this.writer.write(this.helper.subarray(0,2))}},{key:"writeU32",value:function(e){this.helperView.setUint32(0,e,!1),this.writer.write(this.helper.subarray(0,4))}},{key:"writeAscii",value:function(e){for(var r=0;r=7&&1===l.data[0]&&118===l.data[1]&&111===l.data[2]&&114===l.data[3]&&98===l.data[4]&&105===l.data[5]&&115===l.data[6]))return[3,9];return[4,this.readVorbisMetadata(l,u)];case 8:return f.sent(),[3,11];case 9:if(!(l.data.byteLength>=8&&79===l.data[0]&&112===l.data[1]&&117===l.data[2]&&115===l.data[3]&&72===l.data[4]&&101===l.data[5]&&97===l.data[6]&&100===l.data[7]))return[3,11];return[4,this.readOpusMetadata(l,u)];case 10:f.sent(),f.label=11;case 11:null!==u.codecInfo.codec&&this.tracks.push(new(0,b.InputAudioTrack)(this.input,new I(u,this))),f.label=12;case 12:return a=!0,[3,6];case 13:return[3,16];case 14:return d=f.sent(),i=!0,s=d,[3,16];case 15:try{a||null==o.return||o.return()}finally{if(i)throw s}return[7];case 16:return[2]}})}).call(e)]})}).call(this)}},{key:"readVorbisMetadata",value:function(e,r){return(0,s._)(function(){var n,a,i,s,o,c,u,l;return(0,h._)(this,function(d){switch(d.label){case 0:return[4,this.findNextPacketStart(e)];case 1:case 3:if(!(n=d.sent()))return[2];return[4,this.readPacket(n.startPage,n.startSegmentIndex)];case 2:if(!(a=d.sent()))return[2];return[4,this.findNextPacketStart(a)];case 4:if(!(i=d.sent())||3!==a.data[0]||5!==i.data[0])return[2];return s=[],(o=function(e){for(;s.push(Math.min(255,e)),!(e<255);)e-=255})(e.data.length),o(a.data.length),(c=new Uint8Array(1+s.length+e.data.length+a.data.length+i.data.length))[0]=2,c.set(s,1),c.set(e.data,1+s.length),c.set(a.data,1+s.length+e.data.length),c.set(i.data,1+s.length+e.data.length+a.data.length),r.codecInfo.codec="vorbis",r.description=c,r.lastMetadataPacket=i,r.numberOfChannels=(u=(0,_.toDataView)(e.data)).getUint8(11),r.sampleRate=u.getUint32(12,!0),l=u.getUint8(28),r.codecInfo.vorbisInfo={blocksizes:[1<<(15&l),1<<(l>>4)],modeBlockflags:(0,p.parseModesFromVorbisSetupPacket)(i.data).modeBlockflags},(0,p.readVorbisComments)(a.data.subarray(7),this.metadataTags),[2]}})}).call(this)}},{key:"readOpusMetadata",value:function(e,r){return(0,s._)(function(){var n,a,i;return(0,h._)(this,function(s){switch(s.label){case 0:return[4,this.findNextPacketStart(e)];case 1:if(!(n=s.sent()))return[2];return[4,this.readPacket(n.startPage,n.startSegmentIndex)];case 2:if(!(a=s.sent()))return[2];return r.codecInfo.codec="opus",r.description=e.data,r.lastMetadataPacket=a,r.numberOfChannels=(i=(0,p.parseOpusIdentificationHeader)(e.data)).outputChannelCount,r.sampleRate=m.OPUS_SAMPLE_RATE,r.codecInfo.opusInfo={preSkip:i.preSkip},(0,p.readVorbisComments)(a.data.subarray(8),this.metadataTags),[2]}})}).call(this)}},{key:"readPacket",value:function(e,r){return(0,s._)(function(){var n,a,i,s,o,c,u,l,d,f,m,p,g,b,k,y;return(0,h._)(this,function(h){switch(h.label){case 0:for((0,_.assert)(rn?s=m.headerStartPos:(i=m,o.push(m)),[3,2];case 12:return[3,2];case 13:k=a.startPage,x=!0,I=!1,P=void 0;try{for(C=o[Symbol.iterator]();!(x=(A=C.next()).done)&&(B=A.value).granulePosition!==i.granulePosition;x=!0)(!k||B.headerStartPos>k.headerStartPos)&&(k=B)}catch(e){I=!0,P=e}finally{try{x||null==C.return||C.return()}finally{if(I)throw P}}D=[M=k],h.label=14;case 14:if(M.serialNumber===this.bitstream.serialNumber&&M.granulePosition===i.granulePosition)return[3,17];if(F=M.headerStartPos+M.totalSize,!((R=this.demuxer.reader.requestSliceRange(F,T.MIN_PAGE_HEADER_SIZE,T.MAX_PAGE_HEADER_SIZE))instanceof Promise))return[3,16];return[4,R];case 15:R=h.sent(),h.label=16;case 16:return(0,_.assert)(R),U=(0,T.readPageHeader)(R),(0,_.assert)(U),(M=U).serialNumber===this.bitstream.serialNumber&&D.push(M),[3,14];case 17:if((0,_.assert)(-1!==M.granulePosition),O=null,z=M,V=0,M.headerStartPos!==a.startPage.headerStartPos)return[3,18];return L=this.granulePositionToTimestampInSamples(0),N=!0,O=0,[3,20];case 18:for(L=0,N=!1,H=M.lacingValues.length-1;H>=0;H--)if(M.lacingValues[H]<255){O=H+1;break}if(null===O)throw Error("Invalid page with granule position: no packets end on this page.");return V=O-1,G={data:y.PLACEHOLDER_DATA,endPage:z,endSegmentIndex:V},[4,this.demuxer.findNextPacketStart(G)];case 19:if(h.sent())q=j(D,M,O),(0,_.assert)(q),(W=E(D,q.page,q.segmentIndex))&&(M=W.page,O=W.segmentIndex);else for(;(K=j(D,M,O))&&(X=E(D,K.page,K.segmentIndex));)if(M=X.page,O=X.segmentIndex,K.page.headerStartPos!==z.headerStartPos){z=K.page,V=K.segmentIndex;break}h.label=20;case 20:Z=null,Q=null,h.label=21;case 21:if(null===M)return[3,24];return(0,_.assert)(null!==O),[4,this.demuxer.readPacket(M,O)];case 22:if(!(Y=h.sent())||!(M.headerStartPos===a.startPage.headerStartPos&&On||Math.max(ee.timestampInSamples,0)===n)))return[3,24];return[4,this.demuxer.findNextPacketStart(Y)];case 23:if(!(er=h.sent()))return[3,24];return M=er.startPage,O=er.startSegmentIndex,[3,21];case 24:return[2,Z]}})}).call(this)}},{key:"getPacketSequential",value:function(e,r){return(0,s._)(function(){var n,a,i,s,o,c,u,l;return(0,h._)(this,function(d){switch(d.label){case 0:return[4,this.sequentialScanMutex.acquire()];case 1:n=d.sent(),d.label=2;case 2:if(d.trys.push([2,,9,10]),e=(a=(0,_.roundIfAlmostInteger)(e*this.internalSampleRate))/this.internalSampleRate,-1===(i=(0,_.binarySearchLessOrEqual)(this.sequentialScanCache,a,function(e){return e.timestampInSamples})))return[3,3];return o=this.sequentialScanCache[i],s=this.createEncodedPacketFromOggPacket(o.packet,{timestampInSamples:o.timestampInSamples,vorbisLastBlocksize:o.vorbisLastBlockSize},r),[3,5];case 3:return[4,this.getFirstPacket(r)];case 4:s=d.sent(),d.label=5;case 5:c=0,d.label=6;case 6:if(!(s&&s.timestampe)return[3,8];return s=u,100==++c&&(c=0,l=this.encodedPacketToMetadata.get(s),(0,_.assert)(l),this.sequentialScanCache.length>0&&(0,_.assert)((0,_.last)(this.sequentialScanCache).timestampInSamples<=l.timestampInSamples),this.sequentialScanCache.push(l)),[3,6];case 8:return[2,s];case 9:return n(),[7];case 10:return[2]}})}).call(this)}},{key:"getKeyPacket",value:function(e,r){return this.getPacket(e,r)}},{key:"getNextKeyPacket",value:function(e,r){return this.getNextPacket(e,r)}}]),e}(),E=function(e,r,n){var a=r,i=n;e:for(;;){for(i--;i>=0;i--)if(a.lacingValues[i]<255){i++;break e}if((0,_.assert)(-1===i),!(1&a.headerType)){i=0;break}var s=(0,_.findLast)(e,function(e){return e.headerStartPos0)return{page:r,segmentIndex:n-1};var a=(0,_.findLast)(e,function(e){return e.headerStartPos>>0}var m=function(e){var r=(0,c.toDataView)(e),n=r.getUint32(22,!0);r.setUint32(22,0,!0);for(var a=0,i=0;i>>24^e[i]])>>>0;return r.setUint32(22,n,!0),a},p=function(e,r,n){var a=0,i=null;if(e.length>0)if("vorbis"===r.codec){(0,c.assert)(r.vorbisInfo);var s=r.vorbisInfo.modeBlockflags.length,u=(1<<(0,c.ilog)(s-1))-1<<1,l=(e[0]&u)>>1;if(l>=r.vorbisInfo.modeBlockflags.length)throw Error("Invalid mode number.");var d=n,f=r.vorbisInfo.modeBlockflags[l];if(i=r.vorbisInfo.blocksizes[f],1===f){var h=e[0]&(1|u)+1?1:0;d=r.vorbisInfo.blocksizes[h]}a=null!==d?d+i>>2:0}else"opus"===r.codec&&(a=(0,o.parseOpusTocByte)(e).durationInSamples);return{durationInSamples:a,vorbisBlockSize:i}},g=function(e){var r="audio/ogg";if(e.codecStrings){var n=(0,s._)(new Set(e.codecStrings));r+='; codecs="'.concat(n.join(", "),'"')}return r}},{"@swc/helpers/cjs/_to_consumable_array.cjs":"i81N6","../codec-data.js":"kWTYV","../misc.js":"j7iGm","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],fY5up:[function(e,r,n,a){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(n),i.export(n,"MIN_PAGE_HEADER_SIZE",function(){return c}),i.export(n,"MAX_PAGE_HEADER_SIZE",function(){return u}),i.export(n,"MAX_PAGE_SIZE",function(){return l}),i.export(n,"readPageHeader",function(){return d}),i.export(n,"findNextPageHeader",function(){return f});var s=e("../reader.js"),o=e("./ogg-misc.js"),c=27,u=282,l=65307,d=function(e){var r=e.filePos;if((0,s.readU32Le)(e)!==o.OGGS)return null;e.skip(1);for(var n=(0,s.readU8)(e),a=(0,s.readI64Le)(e),i=(0,s.readU32Le)(e),c=(0,s.readU32Le)(e),u=(0,s.readU32Le)(e),l=(0,s.readU8)(e),d=new Uint8Array(l),f=0;f>>8&255,c=n>>>16&255,u=n>>>24&255;if(79===a||79===i||79===c||79===u){if(e.skip(-4),n===o.OGGS)return!0;e.skip(1)}}return!1}},{"../reader.js":"8KRfO","./ogg-misc.js":"g1LsD","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],cokSU:[function(e,r,n,a){var i,s,o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(n),o.export(n,"WaveFormat",function(){return s}),o.export(n,"WaveDemuxer",function(){return T});var c=e("@swc/helpers/cjs/_async_to_generator.cjs"),u=e("@swc/helpers/cjs/_call_super.cjs"),l=e("@swc/helpers/cjs/_class_call_check.cjs"),d=e("@swc/helpers/cjs/_create_class.cjs"),f=e("@swc/helpers/cjs/_inherits.cjs"),h=e("@swc/helpers/cjs/_object_spread.cjs"),m=e("@swc/helpers/cjs/_to_consumable_array.cjs"),p=e("@swc/helpers/cjs/_ts_generator.cjs"),g=e("../demuxer.js"),b=e("../input-track.js"),k=e("../metadata.js"),_=e("../misc.js"),y=e("../packet.js"),w=e("../reader.js"),S=e("../id3.js");(i=s||(s={}))[i.PCM=1]="PCM",i[i.IEEE_FLOAT=3]="IEEE_FLOAT",i[i.ALAW=6]="ALAW",i[i.MULAW=7]="MULAW",i[i.EXTENSIBLE=65534]="EXTENSIBLE";var T=function(e){"use strict";function r(e){var n;return(0,l._)(this,r),(n=(0,u._)(this,r,[e])).metadataPromise=null,n.dataStart=-1,n.dataSize=-1,n.audioInfo=null,n.tracks=[],n.lastKnownPacketIndex=0,n.metadataTags={},n.reader=e._reader,n}return(0,f._)(r,e),(0,d._)(r,[{key:"readMetadata",value:function(){return(0,c._)(function(){var e,r;return(0,p._)(this,function(n){return e=this,[2,null!=(r=this.metadataPromise)?r:this.metadataPromise=(0,c._)(function(){var e,r,n,a,i,s,o,c,u,l,d,f,h,m,g,k,y,S;return(0,p._)(this,function(p){switch(p.label){case 0:if(!((e=this.reader.requestSlice(0,12))instanceof Promise))return[3,2];return[4,e];case 1:e=p.sent(),p.label=2;case 2:if((0,_.assert)(e),n="RIFX"!==(r=(0,w.readAscii)(e,4)),a="RF64"===r,i=(0,w.readU32)(e,n),o=a?this.reader.fileSize:Math.min(i+8,null!=(s=this.reader.fileSize)?s:1/0),"WAVE"!==(0,w.readAscii)(e,4))throw Error("Invalid WAVE file - wrong format");c=0,u=null,l=e.filePos,p.label=3;case 3:if(!(null===o||l=18&&357!==i&&Math.min(r-18,(0,w.readU16)(a,n))>=22&&i===s.EXTENSIBLE&&(a.skip(6),i=(d=(0,w.readBytes)(a,16))[0]|d[1]<<8),(i===s.MULAW||i===s.ALAW)&&(l=8),this.audioInfo={format:i,numberOfChannels:o,sampleRate:c,sampleSizeInBytes:Math.ceil(l/8),blockSizeInBytes:u},[2]}})}).call(this)}},{key:"parseListChunk",value:function(e,r,n){return(0,c._)(function(){var a,i,s,o,c,u,l,d,f,h,g,b,k,_,y,S,T,x,I,E,j,P,C,A,B,M;return(0,p._)(this,function(p){switch(p.label){case 0:if(!((a=this.reader.requestSlice(e,r))instanceof Promise))return[3,2];return[4,a];case 1:a=p.sent(),p.label=2;case 2:if(!a||"INFO"!==(i=(0,w.readAscii)(a,4))&&"INF0"!==i)return[2];for(s=a.filePos;s<=e+r-8;){for(h=0,a.filePos=s,u=(0,w.readAscii)(a,4),l=(0,w.readU32)(a,n),d=(0,w.readBytes)(a,l),f=0;h0&&(null!=(S=this.metadataTags).trackNumber||(S.trackNumber=I)),E&&Number.isInteger(E)&&E>0&&(null!=(T=this.metadataTags).tracksTotal||(T.tracksTotal=E));break;case"ICRD":case"IDIT":Number.isNaN((P=new Date(g)).getTime())||null!=(j=this.metadataTags).date||(j.date=P);break;case"YEAR":Number.isInteger(A=Number.parseInt(g,10))&&A>0&&(null!=(C=this.metadataTags).date||(C.date=new Date(A,0,1)));break;case"IGNR":case"GENR":null!=(B=this.metadataTags).genre||(B.genre=g);break;case"ICMT":case"CMNT":case"COMM":null!=(M=this.metadataTags).comment||(M.comment=g)}s+=8+l+(1&l)}return[2]}})}).call(this)}},{key:"parseId3Chunk",value:function(e,r){return(0,c._)(function(){var n,a,i;return(0,p._)(this,function(s){switch(s.label){case 0:if(!((n=this.reader.requestSlice(e,r))instanceof Promise))return[3,2];return[4,n];case 1:n=s.sent(),s.label=2;case 2:if(!n)return[2];return(a=(0,S.readId3V2Header)(n))&&(i=n.slice(e+10,a.size),(0,S.parseId3V2Tag)(i,a,this.metadataTags)),[2]}})}).call(this)}},{key:"getCodec",value:function(){if((0,_.assert)(this.audioInfo),this.audioInfo.format===s.MULAW)return"ulaw";if(this.audioInfo.format===s.ALAW)return"alaw";if(this.audioInfo.format===s.PCM){if(1===this.audioInfo.sampleSizeInBytes)return"pcm-u8";else if(2===this.audioInfo.sampleSizeInBytes)return"pcm-s16";else if(3===this.audioInfo.sampleSizeInBytes)return"pcm-s24";else if(4===this.audioInfo.sampleSizeInBytes)return"pcm-s32"}return this.audioInfo.format===s.IEEE_FLOAT&&4===this.audioInfo.sampleSizeInBytes?"pcm-f32":null}},{key:"getMimeType",value:function(){return(0,c._)(function(){return(0,p._)(this,function(e){return[2,"audio/wav"]})})()}},{key:"computeDuration",value:function(){return(0,c._)(function(){var e;return(0,p._)(this,function(r){switch(r.label){case 0:return[4,this.readMetadata()];case 1:return r.sent(),e=this.tracks[0],(0,_.assert)(e),[2,e.computeDuration()]}})}).call(this)}},{key:"getTracks",value:function(){return(0,c._)(function(){return(0,p._)(this,function(e){switch(e.label){case 0:return[4,this.readMetadata()];case 1:return e.sent(),[2,this.tracks]}})}).call(this)}},{key:"getMetadataTags",value:function(){return(0,c._)(function(){return(0,p._)(this,function(e){switch(e.label){case 0:return[4,this.readMetadata()];case 1:return e.sent(),[2,this.metadataTags]}})}).call(this)}}]),r}(g.Demuxer),x=function(){"use strict";function e(r){(0,l._)(this,e),this.demuxer=r}return(0,d._)(e,[{key:"getId",value:function(){return 1}},{key:"getCodec",value:function(){return this.demuxer.getCodec()}},{key:"getInternalCodecId",value:function(){return(0,_.assert)(this.demuxer.audioInfo),this.demuxer.audioInfo.format}},{key:"getDecoderConfig",value:function(){return(0,c._)(function(){var e;return(0,p._)(this,function(r){return(e=this.demuxer.getCodec())?((0,_.assert)(this.demuxer.audioInfo),[2,{codec:e,numberOfChannels:this.demuxer.audioInfo.numberOfChannels,sampleRate:this.demuxer.audioInfo.sampleRate}]):[2,null]})}).call(this)}},{key:"computeDuration",value:function(){return(0,c._)(function(){var e,r,n;return(0,p._)(this,function(a){switch(a.label){case 0:return[4,this.getPacket(1/0,{metadataOnly:!0})];case 1:return[2,(null!=(r=null==(e=a.sent())?void 0:e.timestamp)?r:0)+(null!=(n=null==e?void 0:e.duration)?n:0)]}})}).call(this)}},{key:"getNumberOfChannels",value:function(){return(0,_.assert)(this.demuxer.audioInfo),this.demuxer.audioInfo.numberOfChannels}},{key:"getSampleRate",value:function(){return(0,_.assert)(this.demuxer.audioInfo),this.demuxer.audioInfo.sampleRate}},{key:"getTimeResolution",value:function(){return(0,_.assert)(this.demuxer.audioInfo),this.demuxer.audioInfo.sampleRate}},{key:"getName",value:function(){return null}},{key:"getLanguageCode",value:function(){return _.UNDETERMINED_LANGUAGE}},{key:"getDisposition",value:function(){return(0,h._)({},k.DEFAULT_TRACK_DISPOSITION)}},{key:"getFirstTimestamp",value:function(){return(0,c._)(function(){return(0,p._)(this,function(e){return[2,0]})})()}},{key:"getPacketAtIndex",value:function(e,r){return(0,c._)(function(){var n,a,i,s,o,c,u;return(0,p._)(this,function(l){switch(l.label){case 0:if((0,_.assert)(this.demuxer.audioInfo),(n=2048*e*this.demuxer.audioInfo.blockSizeInBytes)>=this.demuxer.dataSize)return[2,null];if(a=Math.min(2048*this.demuxer.audioInfo.blockSizeInBytes,this.demuxer.dataSize-n),null!==this.demuxer.reader.fileSize)return[3,3];if(!((i=this.demuxer.reader.requestSlice(this.demuxer.dataStart+n,a))instanceof Promise))return[3,2];return[4,i];case 1:i=l.sent(),l.label=2;case 2:if(!i)return[2,null];l.label=3;case 3:if(!r.metadataOnly)return[3,4];return s=y.PLACEHOLDER_DATA,[3,7];case 4:if(!((o=this.demuxer.reader.requestSlice(this.demuxer.dataStart+n,a))instanceof Promise))return[3,6];return[4,o];case 5:o=l.sent(),l.label=6;case 6:(0,_.assert)(o),s=(0,w.readBytes)(o,a),l.label=7;case 7:return c=2048*e/this.demuxer.audioInfo.sampleRate,u=a/this.demuxer.audioInfo.blockSizeInBytes/this.demuxer.audioInfo.sampleRate,this.demuxer.lastKnownPacketIndex=Math.max(e,c),[2,new(0,y.EncodedPacket)(s,"key",c,u,e,a)]}})}).call(this)}},{key:"getFirstPacket",value:function(e){return this.getPacketAtIndex(0,e)}},{key:"getPacket",value:function(e,r){return(0,c._)(function(){var n,a,i,s;return(0,p._)(this,function(o){switch(o.label){case 0:return(0,_.assert)(this.demuxer.audioInfo),n=Math.floor(Math.min(e*this.demuxer.audioInfo.sampleRate/2048,(this.demuxer.dataSize-1)/(2048*this.demuxer.audioInfo.blockSizeInBytes))),[4,this.getPacketAtIndex(n,r)];case 1:if(a=o.sent())return[2,a];if(0===n)return[2,null];return(0,_.assert)(null===this.demuxer.reader.fileSize),[4,this.getPacketAtIndex(this.demuxer.lastKnownPacketIndex,r)];case 2:i=o.sent(),o.label=3;case 3:if(!i)return[3,5];return[4,this.getNextPacket(i,r)];case 4:if(!(s=o.sent()))return[3,5];return i=s,[3,3];case 5:return[2,i]}})}).call(this)}},{key:"getNextPacket",value:function(e,r){(0,_.assert)(this.demuxer.audioInfo);var n=Math.round(e.timestamp*this.demuxer.audioInfo.sampleRate/2048);return this.getPacketAtIndex(n+1,r)}},{key:"getKeyPacket",value:function(e,r){return this.getPacket(e,r)}},{key:"getNextKeyPacket",value:function(e,r){return this.getNextPacket(e,r)}}]),e}()},{"@swc/helpers/cjs/_async_to_generator.cjs":"cZn0e","@swc/helpers/cjs/_call_super.cjs":"clpdF","@swc/helpers/cjs/_class_call_check.cjs":"4Uf9M","@swc/helpers/cjs/_create_class.cjs":"igUuK","@swc/helpers/cjs/_inherits.cjs":"jtSwf","@swc/helpers/cjs/_object_spread.cjs":"kyoEj","@swc/helpers/cjs/_to_consumable_array.cjs":"i81N6","@swc/helpers/cjs/_ts_generator.cjs":"eltGh","../demuxer.js":"d4thC","../input-track.js":"b22CJ","../metadata.js":"eSjom","../misc.js":"j7iGm","../packet.js":"QfqGG","../reader.js":"8KRfO","../id3.js":"42Y2c","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],"5AUBv":[function(e,r,n,a){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(n),i.export(n,"MIN_FRAME_HEADER_SIZE",function(){return c}),i.export(n,"MAX_FRAME_HEADER_SIZE",function(){return u}),i.export(n,"readFrameHeader",function(){return l});var s=e("../misc.js"),o=e("../reader.js"),c=7,u=9,l=function(e){var r=e.filePos,n=(0,o.readBytes)(e,9),a=new(0,s.Bitstream)(n);if(4095!==a.readBits(12)||(a.skipBits(1),0!==a.readBits(2)))return null;var i=a.readBits(1),c=a.readBits(2)+1,u=a.readBits(4);if(15===u)return null;a.skipBits(1);var l=a.readBits(3);if(0===l)throw Error("ADTS frames with channel configuration 0 are not supported.");a.skipBits(1),a.skipBits(1),a.skipBits(1),a.skipBits(1);var d=a.readBits(13);a.skipBits(11);var f=a.readBits(2)+1;if(1!==f)throw Error("ADTS frames with more than one AAC frame are not supported.");var h=null;return 1===i?e.filePos-=2:h=a.readBits(16),{objectType:c,samplingFrequencyIndex:u,channelConfiguration:l,frameLength:d,numberOfAacFrames:f,crcCheck:h,startPos:r}}},{"../misc.js":"j7iGm","../reader.js":"8KRfO","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],"3t0bF":[function(e,r,n,a){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(n),i.export(n,"AdtsDemuxer",function(){return w});var s=e("@swc/helpers/cjs/_async_to_generator.cjs"),o=e("@swc/helpers/cjs/_call_super.cjs"),c=e("@swc/helpers/cjs/_class_call_check.cjs"),u=e("@swc/helpers/cjs/_create_class.cjs"),l=e("@swc/helpers/cjs/_inherits.cjs"),d=e("@swc/helpers/cjs/_object_spread.cjs"),f=e("@swc/helpers/cjs/_ts_generator.cjs"),h=e("../codec.js"),m=e("../demuxer.js"),p=e("../input-track.js"),g=e("../misc.js"),b=e("../packet.js"),k=e("../reader.js"),_=e("../metadata.js"),y=e("./adts-reader.js"),w=function(e){"use strict";function r(e){var n;return(0,c._)(this,r),(n=(0,o._)(this,r,[e])).metadataPromise=null,n.firstFrameHeader=null,n.loadedSamples=[],n.tracks=[],n.readingMutex=new(0,g.AsyncMutex),n.lastSampleLoaded=!1,n.lastLoadedPos=0,n.nextTimestampInSamples=0,n.reader=e._reader,n}return(0,l._)(r,e),(0,u._)(r,[{key:"readMetadata",value:function(){return(0,s._)(function(){var e,r;return(0,f._)(this,function(n){return e=this,[2,null!=(r=this.metadataPromise)?r:this.metadataPromise=(0,s._)(function(){return(0,f._)(this,function(e){switch(e.label){case 0:if(!(!this.firstFrameHeader&&!this.lastSampleLoaded))return[3,2];return[4,this.advanceReader()];case 1:return e.sent(),[3,0];case 2:return(0,g.assert)(this.firstFrameHeader),this.tracks=[new(0,p.InputAudioTrack)(this.input,new S(this))],[2]}})}).call(e)]})}).call(this)}},{key:"advanceReader",value:function(){return(0,s._)(function(){var e,r,n,a,i,s;return(0,f._)(this,function(o){switch(o.label){case 0:if(!((e=this.reader.requestSliceRange(this.lastLoadedPos,y.MIN_FRAME_HEADER_SIZE,y.MAX_FRAME_HEADER_SIZE))instanceof Promise))return[3,2];return[4,e];case 1:e=o.sent(),o.label=2;case 2:if(!e||!(r=(0,y.readFrameHeader)(e))||null!==this.reader.fileSize&&r.startPos+r.frameLength>this.reader.fileSize)return this.lastSampleLoaded=!0,[2];return this.firstFrameHeader||(this.firstFrameHeader=r),n=h.aacFrequencyTable[r.samplingFrequencyIndex],(0,g.assert)(void 0!==n),a=1024/n,i=r.crcCheck?y.MAX_FRAME_HEADER_SIZE:y.MIN_FRAME_HEADER_SIZE,s={timestamp:this.nextTimestampInSamples/n,duration:a,dataStart:r.startPos+i,dataSize:r.frameLength-i},this.loadedSamples.push(s),this.nextTimestampInSamples+=1024,this.lastLoadedPos=r.startPos+r.frameLength,[2]}})}).call(this)}},{key:"getMimeType",value:function(){return(0,s._)(function(){return(0,f._)(this,function(e){return[2,"audio/aac"]})})()}},{key:"getTracks",value:function(){return(0,s._)(function(){return(0,f._)(this,function(e){switch(e.label){case 0:return[4,this.readMetadata()];case 1:return e.sent(),[2,this.tracks]}})}).call(this)}},{key:"computeDuration",value:function(){return(0,s._)(function(){var e;return(0,f._)(this,function(r){switch(r.label){case 0:return[4,this.readMetadata()];case 1:return r.sent(),e=this.tracks[0],(0,g.assert)(e),[2,e.computeDuration()]}})}).call(this)}},{key:"getMetadataTags",value:function(){return(0,s._)(function(){return(0,f._)(this,function(e){return[2,{}]})})()}}]),r}(m.Demuxer),S=function(){"use strict";function e(r){(0,c._)(this,e),this.demuxer=r}return(0,u._)(e,[{key:"getId",value:function(){return 1}},{key:"getFirstTimestamp",value:function(){return(0,s._)(function(){return(0,f._)(this,function(e){return[2,0]})})()}},{key:"getTimeResolution",value:function(){return this.getSampleRate()/1024}},{key:"computeDuration",value:function(){return(0,s._)(function(){var e,r,n;return(0,f._)(this,function(a){switch(a.label){case 0:return[4,this.getPacket(1/0,{metadataOnly:!0})];case 1:return[2,(null!=(r=null==(e=a.sent())?void 0:e.timestamp)?r:0)+(null!=(n=null==e?void 0:e.duration)?n:0)]}})}).call(this)}},{key:"getName",value:function(){return null}},{key:"getLanguageCode",value:function(){return g.UNDETERMINED_LANGUAGE}},{key:"getCodec",value:function(){return"aac"}},{key:"getInternalCodecId",value:function(){return(0,g.assert)(this.demuxer.firstFrameHeader),this.demuxer.firstFrameHeader.objectType}},{key:"getNumberOfChannels",value:function(){(0,g.assert)(this.demuxer.firstFrameHeader);var e=h.aacChannelMap[this.demuxer.firstFrameHeader.channelConfiguration];return(0,g.assert)(void 0!==e),e}},{key:"getSampleRate",value:function(){(0,g.assert)(this.demuxer.firstFrameHeader);var e=h.aacFrequencyTable[this.demuxer.firstFrameHeader.samplingFrequencyIndex];return(0,g.assert)(void 0!==e),e}},{key:"getDisposition",value:function(){return(0,d._)({},_.DEFAULT_TRACK_DISPOSITION)}},{key:"getDecoderConfig",value:function(){return(0,s._)(function(){var e,r,n,a,i,s;return(0,f._)(this,function(o){return(0,g.assert)(this.demuxer.firstFrameHeader),e=new Uint8Array(3),r=new(0,g.Bitstream)(e),a=(n=this.demuxer.firstFrameHeader).objectType,i=n.samplingFrequencyIndex,s=n.channelConfiguration,a>31?(r.writeBits(5,31),r.writeBits(6,a-32)):r.writeBits(5,a),r.writeBits(4,i),r.writeBits(4,s),[2,{codec:"mp4a.40.".concat(this.demuxer.firstFrameHeader.objectType),numberOfChannels:this.getNumberOfChannels(),sampleRate:this.getSampleRate(),description:e.subarray(0,Math.ceil((r.pos-1)/8))}]})}).call(this)}},{key:"getPacketAtIndex",value:function(e,r){return(0,s._)(function(){var n,a,i;return(0,f._)(this,function(s){switch(s.label){case 0:if(-1===e||!(n=this.demuxer.loadedSamples[e]))return[2,null];if(!r.metadataOnly)return[3,1];return a=b.PLACEHOLDER_DATA,[3,4];case 1:if(!((i=this.demuxer.reader.requestSlice(n.dataStart,n.dataSize))instanceof Promise))return[3,3];return[4,i];case 2:i=s.sent(),s.label=3;case 3:if(!i)return[2,null];a=(0,k.readBytes)(i,n.dataSize),s.label=4;case 4:return[2,new(0,b.EncodedPacket)(a,"key",n.timestamp,n.duration,e,n.dataSize)]}})}).call(this)}},{key:"getFirstPacket",value:function(e){return this.getPacketAtIndex(0,e)}},{key:"getNextPacket",value:function(e,r){return(0,s._)(function(){var n,a,i;return(0,f._)(this,function(s){switch(s.label){case 0:return[4,this.demuxer.readingMutex.acquire()];case 1:n=s.sent(),s.label=2;case 2:if(s.trys.push([2,,6,7]),-1===(a=(0,g.binarySearchExact)(this.demuxer.loadedSamples,e.timestamp,function(e){return e.timestamp})))throw Error("Packet was not created from this track.");i=a+1,s.label=3;case 3:if(!(i>=this.demuxer.loadedSamples.length&&!this.demuxer.lastSampleLoaded))return[3,5];return[4,this.demuxer.advanceReader()];case 4:return s.sent(),[3,3];case 5:return[2,this.getPacketAtIndex(i,r)];case 6:return n(),[7];case 7:return[2]}})}).call(this)}},{key:"getPacket",value:function(e,r){return(0,s._)(function(){var n,a;return(0,f._)(this,function(i){switch(i.label){case 0:return[4,this.demuxer.readingMutex.acquire()];case 1:n=i.sent(),i.label=2;case 2:i.trys.push([2,,6,7]),i.label=3;case 3:if(-1===(a=(0,g.binarySearchLessOrEqual)(this.demuxer.loadedSamples,e,function(e){return e.timestamp}))&&this.demuxer.loadedSamples.length>0)return[2,null];if(this.demuxer.lastSampleLoaded||a>=0&&a+1s.end-a)return[2,{num:o.num,blockSize:o.blockSize,sampleRate:o.sampleRate,size:s.end-r,isLastFrame:!0}];if(255===(0,k.readU8)(s)){if(c=s.filePos,(0,k.readU8)(s)!==(1===this.blockingBit?249:248)||(s.skip(-2),u=s.filePos-r,!(l=this.readFlacFrameHeader({slice:s,isFirstPacket:!1})))){s.filePos=c;continue}if(0===this.blockingBit){if(l.num-o.num!=1){s.filePos=c;continue}}else if(l.num-o.num!==o.blockSize){s.filePos=c;continue}return[2,{num:o.num,blockSize:o.blockSize,sampleRate:o.sampleRate,size:u,isLastFrame:!1}]}}return[2]}})}).apply(this,arguments)}},{key:"readFlacFrameHeader",value:function(e){var r=e.slice,n=e.isFirstPacket,a=r.filePos,i=(0,k.readBytes)(r,4),s=new(0,g.Bitstream)(i);if(32764!==s.readBits(15))return null;if(null===this.blockingBit){(0,g.assert)(n);var o=s.readBits(1);this.blockingBit=o}else if(1===this.blockingBit){if((0,g.assert)(!n),1!==s.readBits(1))return null}else if(0===this.blockingBit){if((0,g.assert)(!n),0!==s.readBits(1))return null}else throw Error("Invalid blocking bit");var c=(0,y.getBlockSizeOrUncommon)(s.readBits(4));if(!c)return null;(0,g.assert)(this.audioInfo);var u=(0,y.getSampleRateOrUncommon)(s.readBits(4),this.audioInfo.sampleRate);if(!u||(s.readBits(4),s.readBits(3),0!==s.readBits(1)))return null;var l=(0,y.readCodedNumber)(r),d=(0,y.readBlockSize)(r,c),f=(0,y.readSampleRate)(r,u);if(null===f||f!==this.audioInfo.sampleRate)return null;var h=r.filePos-a,m=(0,k.readU8)(r);return(r.skip(-h),r.skip(-1),m!==(0,y.calculateCrc8)((0,k.readBytes)(r,h)))?null:{num:l,blockSize:d,sampleRate:f}}},{key:"advanceReader",value:function(){return(0,s._)(function(){var e,r,n,a;return(0,f._)(this,function(i){switch(i.label){case 0:return[4,this.readMetadata()];case 1:return i.sent(),(0,g.assert)(null!==this.lastLoadedPos),(0,g.assert)(this.audioInfo),e=this.lastLoadedPos,[4,this.readNextFlacFrame({startPos:e,isFirstPacket:0===this.loadedSamples.length})];case 2:if(!(r=i.sent()))return this.lastSampleLoaded=!0,[2];return a={blockOffset:(n=this.loadedSamples[this.loadedSamples.length-1])?n.blockOffset+n.blockSize:0,blockSize:r.blockSize,byteOffset:e,byteSize:r.size},this.lastLoadedPos=this.lastLoadedPos+r.size,this.loadedSamples.push(a),r.isLastFrame&&(this.lastSampleLoaded=!0),[2]}})}).call(this)}}]),r}(m.Demuxer),S=function(){"use strict";function e(r){(0,c._)(this,e),this.demuxer=r}return(0,u._)(e,[{key:"getId",value:function(){return 1}},{key:"getCodec",value:function(){return"flac"}},{key:"getInternalCodecId",value:function(){return null}},{key:"getNumberOfChannels",value:function(){return(0,g.assert)(this.demuxer.audioInfo),this.demuxer.audioInfo.numberOfChannels}},{key:"computeDuration",value:function(){return(0,s._)(function(){var e,r,n;return(0,f._)(this,function(a){switch(a.label){case 0:return[4,this.getPacket(1/0,{metadataOnly:!0})];case 1:return[2,(null!=(r=null==(e=a.sent())?void 0:e.timestamp)?r:0)+(null!=(n=null==e?void 0:e.duration)?n:0)]}})}).call(this)}},{key:"getSampleRate",value:function(){return(0,g.assert)(this.demuxer.audioInfo),this.demuxer.audioInfo.sampleRate}},{key:"getName",value:function(){return null}},{key:"getLanguageCode",value:function(){return g.UNDETERMINED_LANGUAGE}},{key:"getTimeResolution",value:function(){return(0,g.assert)(this.demuxer.audioInfo),this.demuxer.audioInfo.sampleRate}},{key:"getDisposition",value:function(){return(0,d._)({},_.DEFAULT_TRACK_DISPOSITION)}},{key:"getFirstTimestamp",value:function(){return(0,s._)(function(){return(0,f._)(this,function(e){return[2,0]})})()}},{key:"getDecoderConfig",value:function(){return(0,s._)(function(){return(0,f._)(this,function(e){return(0,g.assert)(this.demuxer.audioInfo),[2,{codec:"flac",numberOfChannels:this.demuxer.audioInfo.numberOfChannels,sampleRate:this.demuxer.audioInfo.sampleRate,description:this.demuxer.audioInfo.description}]})}).call(this)}},{key:"getPacket",value:function(e,r){return(0,s._)(function(){var n,a,i,s;return(0,f._)(this,function(o){switch(o.label){case 0:if(n=this,(0,g.assert)(this.demuxer.audioInfo),e<0)throw Error("Timestamp cannot be negative");return[4,this.demuxer.readingMutex.acquire()];case 1:a=o.sent(),o.label=2;case 2:o.trys.push([2,,9,10]),o.label=3;case 3:if(-1!==(i=(0,g.binarySearchLessOrEqual)(this.demuxer.loadedSamples,e,function(e){return e.blockOffset/n.demuxer.audioInfo.sampleRate})))return[3,5];return[4,this.demuxer.advanceReader()];case 4:case 6:return o.sent(),[3,3];case 5:if(!((s=this.demuxer.loadedSamples[i]).blockOffset/this.demuxer.audioInfo.sampleRate+s.blockSize/this.demuxer.audioInfo.sampleRate<=e))return[3,7];if(this.demuxer.lastSampleLoaded)return[2,this.getPacketAtIndex(this.demuxer.loadedSamples.length-1,r)];return[4,this.demuxer.advanceReader()];case 7:return[2,this.getPacketAtIndex(i,r)];case 8:return[3,10];case 9:return a(),[7];case 10:return[2]}})}).call(this)}},{key:"getNextPacket",value:function(e,r){return(0,s._)(function(){var n,a;return(0,f._)(this,function(i){switch(i.label){case 0:return[4,this.demuxer.readingMutex.acquire()];case 1:n=i.sent(),i.label=2;case 2:if(i.trys.push([2,,6,7]),a=e.sequenceNumber+1,this.demuxer.lastSampleLoaded&&a>=this.demuxer.loadedSamples.length)return[2,null];i.label=3;case 3:if(!(a>=this.demuxer.loadedSamples.length&&!this.demuxer.lastSampleLoaded))return[3,5];return[4,this.demuxer.advanceReader()];case 4:return i.sent(),[3,3];case 5:return[2,this.getPacketAtIndex(a,r)];case 6:return n(),[7];case 7:return[2]}})}).call(this)}},{key:"getKeyPacket",value:function(e,r){return this.getPacket(e,r)}},{key:"getNextKeyPacket",value:function(e,r){return this.getNextPacket(e,r)}},{key:"getPacketAtIndex",value:function(e,r){return(0,s._)(function(){var n,a,i,s,o;return(0,f._)(this,function(c){switch(c.label){case 0:if(!(n=this.demuxer.loadedSamples[e]))return[2,null];if(!r.metadataOnly)return[3,1];return a=b.PLACEHOLDER_DATA,[3,4];case 1:if(!((i=this.demuxer.reader.requestSlice(n.byteOffset,n.byteSize))instanceof Promise))return[3,3];return[4,i];case 2:i=c.sent(),c.label=3;case 3:if(!i)return[2,null];a=(0,k.readBytes)(i,n.byteSize),c.label=4;case 4:return(0,g.assert)(this.demuxer.audioInfo),s=n.blockOffset/this.demuxer.audioInfo.sampleRate,o=n.blockSize/this.demuxer.audioInfo.sampleRate,[2,new(0,b.EncodedPacket)(a,"key",s,o,e,n.byteSize)]}})}).call(this)}},{key:"getFirstPacket",value:function(e){return(0,s._)(function(){return(0,f._)(this,function(r){switch(r.label){case 0:if(!(0===this.demuxer.loadedSamples.length&&!this.demuxer.lastSampleLoaded))return[3,2];return[4,this.demuxer.advanceReader()];case 1:return r.sent(),[3,0];case 2:return[2,this.getPacketAtIndex(0,e)]}})}).call(this)}}]),e}()},{"@swc/helpers/cjs/_async_to_generator.cjs":"cZn0e","@swc/helpers/cjs/_call_super.cjs":"clpdF","@swc/helpers/cjs/_class_call_check.cjs":"4Uf9M","@swc/helpers/cjs/_create_class.cjs":"igUuK","@swc/helpers/cjs/_inherits.cjs":"jtSwf","@swc/helpers/cjs/_object_spread.cjs":"kyoEj","@swc/helpers/cjs/_ts_generator.cjs":"eltGh","../codec-data.js":"kWTYV","../demuxer.js":"d4thC","../input-track.js":"b22CJ","../misc.js":"j7iGm","../packet.js":"QfqGG","../reader.js":"8KRfO","../metadata.js":"eSjom","./flac-misc.js":"4iR5P","@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}],"4iR5P":[function(e,r,n,a){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(n),i.export(n,"getBlockSizeOrUncommon",function(){return c}),i.export(n,"getSampleRateOrUncommon",function(){return u}),i.export(n,"readCodedNumber",function(){return l}),i.export(n,"readBlockSize",function(){return d}),i.export(n,"readSampleRate",function(){return f}),i.export(n,"calculateCrc8",function(){return h});var s=e("../misc.js"),o=e("../reader.js"),c=function(e){if(0===e)return null;if(1===e)return 192;if(e>=2&&e<=5)return 144*Math.pow(2,e);if(6===e)return"uncommon-u8";if(7===e)return"uncommon-u16";else if(e>=8&&e<=15)return Math.pow(2,e);else return null},u=function(e,r){switch(e){case 0:return r;case 1:return 88200;case 2:return 176400;case 3:return 192e3;case 4:return 8e3;case 5:return 16e3;case 6:return 22050;case 7:return 24e3;case 8:return 32e3;case 9:return 44100;case 10:return 48e3;case 11:return 96e3;case 12:return"uncommon-u8";case 13:return"uncommon-u16";case 14:return"uncommon-u16-10";default:return null}},l=function(e){for(var r=0,n=new(0,s.Bitstream)((0,o.readBytes)(e,1));1===n.readBits(1);)r++;if(0===r)return n.readBits(7);for(var a=[],i=r-1,c=new(0,s.Bitstream)((0,o.readBytes)(e,i)),u=8-r-1,l=0;l=u&&(a.emit("timeupdate"),P=i),Number.isFinite(E)&&e>=E){L(),a.emit("ended");return}w&&w.timestamp<=e?(n.clearRect(0,0,r.width,r.height),n.drawImage(w.canvas,0,0),w=null,U(T),C&&(a.emit("canplay"),a.emit("playing"),C=!1)):!w&&(U(T),!w&&Number.isFinite(E)&&e=0&&a.splice(i,1)}},emit:function(r,n){var a=new Event(r);a.detail=n;var i=e.get(r);i&&i.forEach(function(e){return e(a)})}}}i.defineInteropFlag(n),i.export(n,"createVideoEventTarget",function(){return s})},{"@parcel/transformer-js/src/esmodule-helpers.js":"qpMMf"}]},["OIaIB"],"OIaIB","parcelRequire4dc0",{});