polotno-node 2.14.11 → 2.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -0
- package/dist/assets/{index-CrNGOijE.js → index-D5GpnOg5.js} +1 -1
- package/dist/assets/{index-VaLliFQL.js → index-Xal09T7W.js} +3 -3
- package/dist/assets/{index.es-Drk8SfOv.js → index.es-6B4V2Olh.js} +1 -1
- package/dist/index.html +1 -1
- package/index.d.ts +6 -0
- package/instance.js +318 -86
- package/package.json +1 -1
|
@@ -277,7 +277,7 @@ For more info see: https://github.com/konvajs/react-konva/issues/194
|
|
|
277
277
|
float alpha = texture(u_alphaTexture, v_texCoord).r;
|
|
278
278
|
fragColor = vec4(color, alpha);
|
|
279
279
|
}
|
|
280
|
-
`),n=this.gl.createProgram();return this.gl.attachShader(n,e),this.gl.attachShader(n,r),this.gl.linkProgram(n),n}createShader(e,r){const n=this.gl.createShader(e);return this.gl.shaderSource(n,r),this.gl.compileShader(n),n}createVAO(){const e=this.gl.createVertexArray();this.gl.bindVertexArray(e);const 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);const i=this.gl.getAttribLocation(this.program,"a_position"),a=this.gl.getAttribLocation(this.program,"a_texCoord");return this.gl.enableVertexAttribArray(i),this.gl.vertexAttribPointer(i,2,this.gl.FLOAT,!1,16,0),this.gl.enableVertexAttribArray(a),this.gl.vertexAttribPointer(a,2,this.gl.FLOAT,!1,16,8),e}createTexture(){const 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}update(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)}close(){this.gl.getExtension("WEBGL_lose_context")?.loseContext(),this.gl=null}}class vD extends P7{constructor(e){if(!(e instanceof b1))throw new TypeError("videoTrack must be an InputVideoTrack.");super(),this._track=e}async _createDecoder(e,r){if(!await this._track.canDecode())throw new Error("This video track cannot be decoded by this browser. Make sure to check decodability before using a track.");const n=this._track.codec,i=this._track.rotation,a=await this._track.getDecoderConfig(),o=this._track.timeResolution;return $e(n&&a),new gD(e,r,n,a,i,o)}_createPacketSink(){return new Vb(this._track)}async getSample(e){tf(e);for await(const r of this.mediaSamplesAtTimestamps([e]))return r;throw new Error("Internal error: Iterator returned nothing.")}samples(e=0,r=1/0){return this.mediaSamplesInRange(e,r)}samplesAtTimestamps(e){return this.mediaSamplesAtTimestamps(e)}}class yD{constructor(e,r={}){if(this._nextCanvasIndex=0,!(e instanceof b1))throw new TypeError("videoTrack must be an InputVideoTrack.");if(r&&typeof r!="object")throw new TypeError("options must be an object.");if(r.alpha!==void 0&&typeof r.alpha!="boolean")throw new TypeError("options.alpha, when provided, must be a boolean.");if(r.width!==void 0&&(!Number.isInteger(r.width)||r.width<=0))throw new TypeError("options.width, when defined, must be a positive integer.");if(r.height!==void 0&&(!Number.isInteger(r.height)||r.height<=0))throw new TypeError("options.height, when defined, must be a positive integer.");if(r.fit!==void 0&&!["fill","contain","cover"].includes(r.fit))throw new TypeError('options.fit, when provided, must be one of "fill", "contain", or "cover".');if(r.width!==void 0&&r.height!==void 0&&r.fit===void 0)throw new TypeError("When both options.width and options.height are provided, options.fit must also be provided.");if(r.rotation!==void 0&&![0,90,180,270].includes(r.rotation))throw new TypeError("options.rotation, when provided, must be 0, 90, 180 or 270.");if(r.crop!==void 0&&E7(r.crop,"options."),r.poolSize!==void 0&&(typeof r.poolSize!="number"||!Number.isInteger(r.poolSize)||r.poolSize<0))throw new TypeError("poolSize must be a non-negative integer.");const n=r.rotation??e.rotation,[i,a]=n%180===0?[e.codedWidth,e.codedHeight]:[e.codedHeight,e.codedWidth],o=r.crop;o&&k7(o,i,a);let[s,l]=o?[o.width,o.height]:[i,a];const c=s/l;r.width!==void 0&&r.height===void 0?(s=r.width,l=Math.round(s/c)):r.width===void 0&&r.height!==void 0?(l=r.height,s=Math.round(l*c)):r.width!==void 0&&r.height!==void 0&&(s=r.width,l=r.height),this._videoTrack=e,this._alpha=r.alpha??!1,this._width=s,this._height=l,this._rotation=n,this._crop=o,this._fit=r.fit??"fill",this._videoSampleSink=new vD(e),this._canvasPool=Array.from({length:r.poolSize??0},()=>null)}_videoSampleToWrappedCanvas(e){let r=this._canvasPool[this._nextCanvasIndex],n=!1;r||(typeof document<"u"?(r=document.createElement("canvas"),r.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);const i=r.getContext("2d",{alpha:this._alpha||L5()});$e(i),i.resetTransform(),n||(!this._alpha&&L5()?(i.fillStyle="black",i.fillRect(0,0,this._width,this._height)):i.clearRect(0,0,this._width,this._height)),e.drawWithFit(i,{fit:this._fit,rotation:this._rotation,crop:this._crop});const a={canvas:r,timestamp:e.timestamp,duration:e.duration};return e.close(),a}async getCanvas(e){tf(e);const r=await this._videoSampleSink.getSample(e);return r&&this._videoSampleToWrappedCanvas(r)}canvases(e=0,r=1/0){return cm(this._videoSampleSink.samples(e,r),n=>this._videoSampleToWrappedCanvas(n))}canvasesAtTimestamps(e){return cm(this._videoSampleSink.samplesAtTimestamps(e),r=>r&&this._videoSampleToWrappedCanvas(r))}}class bD extends $b{constructor(e,r,n,i){super(e,r),this.decoder=null,this.customDecoder=null,this.customDecoderCallSerializer=new i7,this.customDecoderQueueSize=0,this.currentTimestamp=null;const a=s=>{(this.currentTimestamp===null||Math.abs(s.timestamp-this.currentTimestamp)>=s.duration)&&(this.currentTimestamp=s.timestamp);const l=this.currentTimestamp;if(this.currentTimestamp+=s.duration,s.numberOfFrames===0){s.close();return}const c=i.sampleRate;s.setTimestamp(Math.round(l*c)/c),e(s)},o=S7.find(s=>s.supports(n,i));if(o)this.customDecoder=new o,this.customDecoder.codec=n,this.customDecoder.config=i,this.customDecoder.onSample=s=>{if(!(s instanceof ih))throw new TypeError("The argument passed to onSample must be an AudioSample.");a(s)},this.customDecoderCallSerializer.call(()=>this.customDecoder.init());else{const s=new Error("Decoding error").stack;this.decoder=new AudioDecoder({output:l=>{try{a(new ih(l))}catch(c){this.onError(c)}},error:l=>{l.stack=s,this.onError(l)}}),this.decoder.configure(i)}}getDecodeQueueSize(){return this.customDecoder?this.customDecoderQueueSize:($e(this.decoder),this.decoder.decodeQueueSize)}decode(e){this.customDecoder?(this.customDecoderQueueSize++,this.customDecoderCallSerializer.call(()=>this.customDecoder.decode(e)).then(()=>this.customDecoderQueueSize--)):($e(this.decoder),this.decoder.decode(e.toEncodedAudioChunk()))}flush(){return this.customDecoder?this.customDecoderCallSerializer.call(()=>this.customDecoder.flush()):($e(this.decoder),this.decoder.flush())}close(){this.customDecoder?this.customDecoderCallSerializer.call(()=>this.customDecoder.close()):($e(this.decoder),this.decoder.close())}}class wD extends $b{constructor(e,r,n){super(e,r),this.decoderConfig=n,this.currentTimestamp=null,$e(of.includes(n.codec)),this.codec=n.codec;const{dataType:i,sampleSize:a,littleEndian:o}=d7(this.codec);switch(this.inputSampleSize=a,a){case 1:i==="unsigned"?this.readInputValue=(s,l)=>s.getUint8(l)-2**7:i==="signed"?this.readInputValue=(s,l)=>s.getInt8(l):i==="ulaw"?this.readInputValue=(s,l)=>lD(s.getUint8(l)):i==="alaw"?this.readInputValue=(s,l)=>uD(s.getUint8(l)):$e(!1);break;case 2:i==="unsigned"?this.readInputValue=(s,l)=>s.getUint16(l,o)-2**15:i==="signed"?this.readInputValue=(s,l)=>s.getInt16(l,o):$e(!1);break;case 3:i==="unsigned"?this.readInputValue=(s,l)=>Xm(s,l,o)-2**23:i==="signed"?this.readInputValue=(s,l)=>RM(s,l,o):$e(!1);break;case 4:i==="unsigned"?this.readInputValue=(s,l)=>s.getUint32(l,o)-2**31:i==="signed"?this.readInputValue=(s,l)=>s.getInt32(l,o):i==="float"?this.readInputValue=(s,l)=>s.getFloat32(l,o):$e(!1);break;case 8:i==="float"?this.readInputValue=(s,l)=>s.getFloat64(l,o):$e(!1);break;default:Lp(a),$e(!1)}switch(a){case 1:i==="ulaw"||i==="alaw"?(this.outputSampleSize=2,this.outputFormat="s16",this.writeOutputValue=(s,l,c)=>s.setInt16(l,c,!0)):(this.outputSampleSize=1,this.outputFormat="u8",this.writeOutputValue=(s,l,c)=>s.setUint8(l,c+2**7));break;case 2:this.outputSampleSize=2,this.outputFormat="s16",this.writeOutputValue=(s,l,c)=>s.setInt16(l,c,!0);break;case 3:this.outputSampleSize=4,this.outputFormat="s32",this.writeOutputValue=(s,l,c)=>s.setInt32(l,c<<8,!0);break;case 4:this.outputSampleSize=4,i==="float"?(this.outputFormat="f32",this.writeOutputValue=(s,l,c)=>s.setFloat32(l,c,!0)):(this.outputFormat="s32",this.writeOutputValue=(s,l,c)=>s.setInt32(l,c,!0));break;case 8:this.outputSampleSize=4,this.outputFormat="f32",this.writeOutputValue=(s,l,c)=>s.setFloat32(l,c,!0);break;default:Lp(a),$e(!1)}}getDecodeQueueSize(){return 0}decode(e){const r=Wa(e.data),n=e.byteLength/this.decoderConfig.numberOfChannels/this.inputSampleSize,i=n*this.decoderConfig.numberOfChannels*this.outputSampleSize,a=new ArrayBuffer(i),o=new DataView(a);for(let f=0;f<n*this.decoderConfig.numberOfChannels;f++){const h=f*this.inputSampleSize,d=f*this.outputSampleSize,p=this.readInputValue(r,h);this.writeOutputValue(o,d,p)}const s=n/this.decoderConfig.sampleRate;(this.currentTimestamp===null||Math.abs(e.timestamp-this.currentTimestamp)>=s)&&(this.currentTimestamp=e.timestamp);const l=this.currentTimestamp;this.currentTimestamp+=s;const c=new ih({format:this.outputFormat,data:a,numberOfChannels:this.decoderConfig.numberOfChannels,sampleRate:this.decoderConfig.sampleRate,numberOfFrames:n,timestamp:l});this.onSample(c)}async flush(){}close(){}}class xD extends P7{constructor(e){if(!(e instanceof xc))throw new TypeError("audioTrack must be an InputAudioTrack.");super(),this._track=e}async _createDecoder(e,r){if(!await this._track.canDecode())throw new Error("This audio track cannot be decoded by this browser. Make sure to check decodability before using a track.");const n=this._track.codec,i=await this._track.getDecoderConfig();return $e(n&&i),of.includes(i.codec)?new wD(e,r,i):new bD(e,r,n,i)}_createPacketSink(){return new Vb(this._track)}async getSample(e){tf(e);for await(const r of this.mediaSamplesAtTimestamps([e]))return r;throw new Error("Internal error: Iterator returned nothing.")}samples(e=0,r=1/0){return this.mediaSamplesInRange(e,r)}samplesAtTimestamps(e){return this.mediaSamplesAtTimestamps(e)}}class yH{constructor(e){if(!(e instanceof xc))throw new TypeError("audioTrack must be an InputAudioTrack.");this._audioSampleSink=new xD(e)}_audioSampleToWrappedArrayBuffer(e){const r={buffer:e.toAudioBuffer(),timestamp:e.timestamp,duration:e.duration};return e.close(),r}async getBuffer(e){tf(e);const r=await this._audioSampleSink.getSample(e);return r&&this._audioSampleToWrappedArrayBuffer(r)}buffers(e=0,r=1/0){return cm(this._audioSampleSink.samples(e,r),n=>this._audioSampleToWrappedArrayBuffer(n))}buffersAtTimestamps(e){return cm(this._audioSampleSink.samplesAtTimestamps(e),r=>r&&this._audioSampleToWrappedArrayBuffer(r))}}class Wb{constructor(e,r){this.input=e,this._backing=r}isVideoTrack(){return this instanceof b1}isAudioTrack(){return this instanceof xc}get id(){return this._backing.getId()}get internalCodecId(){return this._backing.getInternalCodecId()}get languageCode(){return this._backing.getLanguageCode()}get name(){return this._backing.getName()}get timeResolution(){return this._backing.getTimeResolution()}get disposition(){return this._backing.getDisposition()}getFirstTimestamp(){return this._backing.getFirstTimestamp()}computeDuration(){return this._backing.computeDuration()}async computePacketStats(e=1/0){const r=new Vb(this);let n=1/0,i=-1/0,a=0,o=0;for await(const s of r.packets(void 0,void 0,{metadataOnly:!0})){if(a>=e&&s.timestamp>=i)break;n=Math.min(n,s.timestamp),i=Math.max(i,s.timestamp+s.duration),a++,o+=s.byteLength}return{packetCount:a,averagePacketRate:a?Number((a/(i-n)).toPrecision(16)):0,averageBitrate:a?Number((8*o/(i-n)).toPrecision(16)):0}}}class b1 extends Wb{constructor(e,r){super(e,r),this._backing=r}get type(){return"video"}get codec(){return this._backing.getCodec()}get codedWidth(){return this._backing.getCodedWidth()}get codedHeight(){return this._backing.getCodedHeight()}get rotation(){return this._backing.getRotation()}get displayWidth(){return this._backing.getRotation()%180===0?this._backing.getCodedWidth():this._backing.getCodedHeight()}get displayHeight(){return this._backing.getRotation()%180===0?this._backing.getCodedHeight():this._backing.getCodedWidth()}getColorSpace(){return this._backing.getColorSpace()}async hasHighDynamicRange(){const e=await this._backing.getColorSpace();return e.primaries==="bt2020"||e.primaries==="smpte432"||e.transfer==="pg"||e.transfer==="hlg"||e.matrix==="bt2020-ncl"}canBeTransparent(){return this._backing.canBeTransparent()}getDecoderConfig(){return this._backing.getDecoderConfig()}async getCodecParameterString(){return(await this._backing.getDecoderConfig())?.codec??null}async canDecode(){try{const e=await this._backing.getDecoderConfig();if(!e)return!1;const r=this._backing.getCodec();return $e(r!==null),x7.some(i=>i.supports(r,e))?!0:typeof VideoDecoder>"u"?!1:(await VideoDecoder.isConfigSupported(e)).supported===!0}catch(e){return console.error("Error during decodability check:",e),!1}}async determinePacketType(e){if(!(e instanceof Bo))throw new TypeError("packet must be an EncodedPacket.");if(e.isMetadataOnly)throw new TypeError("packet must not be metadata-only to determine its type.");if(this.codec===null)return null;const r=await this.getDecoderConfig();return $e(r),w7(this.codec,r,e.data)}}class xc extends Wb{constructor(e,r){super(e,r),this._backing=r}get type(){return"audio"}get codec(){return this._backing.getCodec()}get numberOfChannels(){return this._backing.getNumberOfChannels()}get sampleRate(){return this._backing.getSampleRate()}getDecoderConfig(){return this._backing.getDecoderConfig()}async getCodecParameterString(){return(await this._backing.getDecoderConfig())?.codec??null}async canDecode(){try{const e=await this._backing.getDecoderConfig();if(!e)return!1;const r=this._backing.getCodec();return $e(r!==null),S7.some(n=>n.supports(r,e))||e.codec.startsWith("pcm-")?!0:typeof AudioDecoder>"u"?!1:(await AudioDecoder.isConfigSupported(e)).supported===!0}catch(e){return console.error("Error during decodability check:",e),!1}}async determinePacketType(e){if(!(e instanceof Bo))throw new TypeError("packet must be an EncodedPacket.");return this.codec===null?null:"key"}}const SD=t=>{let r=(t.hasVideo?"video/":t.hasAudio?"audio/":"application/")+(t.isQuickTime?"quicktime":"mp4");if(t.codecStrings.length>0){const n=[...new Set(t.codecStrings)];r+=`; codecs="${n.join(", ")}"`}return r};const tp=8,k0=16,Kf=t=>{let e=Dt(t);const r=Fo(t,4);let n=8;e===1&&(e=xu(t),n=16);const a=e-n;return a<0?null:{name:r,totalSize:e,headerSize:n,contentSize:a}},qh=t=>Kh(t)/65536,vy=t=>Kh(t)/1073741824,yy=t=>{let e=0;for(let r=0;r<4;r++){e<<=7;const n=dr(t);if(e|=n&127,(n&128)===0)break}return e},ic=t=>{let e=ts(t);return t.skip(2),e=Math.min(e,t.remainingLength),Kl.decode(Nr(t,e))},_D=t=>{const e=Kf(t);if(!e||e.name!=="data"||t.remainingLength<8)return null;const r=Dt(t);t.skip(4);const n=Nr(t,e.contentSize-8);switch(r){case 1:return Kl.decode(n);case 2:return new TextDecoder("utf-16be").decode(n);case 13:return new F0(n,"image/jpeg");case 14:return new F0(n,"image/png");case 27:return new F0(n,"image/bmp");default:return n}};class kD extends _d{constructor(e){super(e),this.moovSlice=null,this.currentTrack=null,this.tracks=[],this.metadataPromise=null,this.movieTimescale=-1,this.movieDurationInTimescale=-1,this.isQuickTime=!1,this.metadataTags={},this.currentMetadataKeys=null,this.isFragmented=!1,this.fragmentTrackDefaults=[],this.currentFragment=null,this.lastReadFragment=null,this.reader=e._reader}async computeDuration(){const e=await this.getTracks(),r=await Promise.all(e.map(n=>n.computeDuration()));return Math.max(0,...r)}async getTracks(){return await this.readMetadata(),this.tracks.map(e=>e.inputTrack)}async getMimeType(){await this.readMetadata();const e=await Promise.all(this.tracks.map(r=>r.inputTrack.getCodecParameterString()));return SD({isQuickTime:this.isQuickTime,hasVideo:this.tracks.some(r=>r.info?.type==="video"),hasAudio:this.tracks.some(r=>r.info?.type==="audio"),codecStrings:e.filter(Boolean)})}async getMetadataTags(){return await this.readMetadata(),this.metadataTags}readMetadata(){return this.metadataPromise??=(async()=>{let e=0;for(;;){let r=this.reader.requestSliceRange(e,tp,k0);if(r instanceof Promise&&(r=await r),!r)break;const n=e,i=Kf(r);if(!i)break;if(i.name==="ftyp"){const a=Fo(r,4);this.isQuickTime=a==="qt "}else if(i.name==="moov"){let a=this.reader.requestSlice(r.filePos,i.contentSize);if(a instanceof Promise&&(a=await a),!a)break;this.moovSlice=a,this.readContiguousBoxes(this.moovSlice),this.tracks.sort((o,s)=>Number(s.disposition.default)-Number(o.disposition.default));for(const o of this.tracks){const s=o.editListPreviousSegmentDurations/this.movieTimescale;o.editListOffset-=Math.round(s*o.timescale)}break}e=n+i.totalSize}if(this.isFragmented&&this.reader.fileSize!==null){let r=this.reader.requestSlice(this.reader.fileSize-4,4);r instanceof Promise&&(r=await r),$e(r);const n=Dt(r),i=this.reader.fileSize-n;if(i>=0&&i<=this.reader.fileSize-k0){let a=this.reader.requestSliceRange(i,tp,k0);if(a instanceof Promise&&(a=await a),a){const o=Kf(a);if(o&&o.name==="mfra"){let s=this.reader.requestSlice(a.filePos,o.contentSize);s instanceof Promise&&(s=await s),s&&this.readContiguousBoxes(s)}}}}})()}getSampleTableForTrack(e){if(e.sampleTable)return e.sampleTable;const r={sampleTimingEntries:[],sampleCompositionTimeOffsets:[],sampleSizes:[],keySampleIndices:null,chunkOffsets:[],sampleToChunk:[],presentationTimestamps:null,presentationTimestampIndexMap:null};e.sampleTable=r,$e(this.moovSlice);const n=this.moovSlice.slice(e.sampleTableByteOffset);if(this.currentTrack=e,this.traverseBox(n),this.currentTrack=null,e.info?.type==="audio"&&e.info.codec&&of.includes(e.info.codec)&&r.sampleCompositionTimeOffsets.length===0){$e(e.info?.type==="audio");const a=d7(e.info.codec),o=[],s=[];for(let l=0;l<r.sampleToChunk.length;l++){const c=r.sampleToChunk[l],f=r.sampleToChunk[l+1],h=(f?f.startChunkIndex:r.chunkOffsets.length)-c.startChunkIndex;for(let d=0;d<h;d++){const p=c.startSampleIndex+d*c.samplesPerChunk,y=p+c.samplesPerChunk,w=oi(r.sampleTimingEntries,p,N=>N.startIndex),x=r.sampleTimingEntries[w],b=oi(r.sampleTimingEntries,y,N=>N.startIndex),S=r.sampleTimingEntries[b],E=x.startDecodeTimestamp+(p-x.startIndex)*x.delta,P=S.startDecodeTimestamp+(y-S.startIndex)*S.delta-E,O=El(o);O&&O.delta===P?O.count++:o.push({startIndex:c.startChunkIndex+d,startDecodeTimestamp:E,count:1,delta:P});const T=c.samplesPerChunk*a.sampleSize*e.info.numberOfChannels;s.push(T)}c.startSampleIndex=c.startChunkIndex,c.samplesPerChunk=1}r.sampleTimingEntries=o,r.sampleSizes=s}if(r.sampleCompositionTimeOffsets.length>0){r.presentationTimestamps=[];for(const a of r.sampleTimingEntries)for(let o=0;o<a.count;o++)r.presentationTimestamps.push({presentationTimestamp:a.startDecodeTimestamp+o*a.delta,sampleIndex:a.startIndex+o});for(const a of r.sampleCompositionTimeOffsets)for(let o=0;o<a.count;o++){const s=a.startIndex+o,l=r.presentationTimestamps[s];l&&(l.presentationTimestamp+=a.offset)}r.presentationTimestamps.sort((a,o)=>a.presentationTimestamp-o.presentationTimestamp),r.presentationTimestampIndexMap=Array(r.presentationTimestamps.length).fill(-1);for(let a=0;a<r.presentationTimestamps.length;a++)r.presentationTimestampIndexMap[r.presentationTimestamps[a].sampleIndex]=a}return r}async readFragment(e){if(this.lastReadFragment?.moofOffset===e)return this.lastReadFragment;let r=this.reader.requestSliceRange(e,tp,k0);r instanceof Promise&&(r=await r),$e(r);const n=Kf(r);$e(n?.name==="moof");let i=this.reader.requestSlice(e,n.totalSize);i instanceof Promise&&(i=await i),$e(i),this.traverseBox(i);const a=this.lastReadFragment;$e(a&&a.moofOffset===e);for(const[,o]of a.trackData){const s=o.track,{fragmentPositionCache:l}=s;if(!o.startTimestampIsFinal){const f=s.fragmentLookupTable.find(h=>h.moofOffset===a.moofOffset);if(f)by(o,f.timestamp);else{const h=oi(l,a.moofOffset-1,d=>d.moofOffset);if(h!==-1){const d=l[h];by(o,d.endTimestamp)}}o.startTimestampIsFinal=!0}const c=oi(l,o.startTimestamp,f=>f.startTimestamp);(c===-1||l[c].moofOffset!==a.moofOffset)&&l.splice(c+1,0,{moofOffset:a.moofOffset,startTimestamp:o.startTimestamp,endTimestamp:o.endTimestamp})}return a}readContiguousBoxes(e){const r=e.filePos;for(;e.filePos-r<=e.length-tp&&this.traverseBox(e););}*iterateContiguousBoxes(e){const r=e.filePos;for(;e.filePos-r<=e.length-tp;){const n=e.filePos,i=Kf(e);if(!i)break;yield{boxInfo:i,slice:e},e.filePos=n+i.totalSize}}traverseBox(e){const r=e.filePos,n=Kf(e);if(!n)return!1;const i=e.filePos,a=r+n.totalSize;switch(n.name){case"mdia":case"minf":case"dinf":case"mfra":case"edts":this.readContiguousBoxes(e.slice(i,n.contentSize));break;case"mvhd":{const o=dr(e);e.skip(3),o===1?(e.skip(16),this.movieTimescale=Dt(e),this.movieDurationInTimescale=xu(e)):(e.skip(8),this.movieTimescale=Dt(e),this.movieDurationInTimescale=Dt(e))}break;case"trak":{const o={id:-1,demuxer:this,inputTrack:null,disposition:{...Sd},info:null,timescale:-1,durationInMovieTimescale:-1,durationInMediaTimescale:-1,rotation:0,internalCodecId:null,name:null,languageCode:ku,sampleTableByteOffset:-1,sampleTable:null,fragmentLookupTable:[],currentFragmentState:null,fragmentPositionCache:[],editListPreviousSegmentDurations:0,editListOffset:0};if(this.currentTrack=o,this.readContiguousBoxes(e.slice(i,n.contentSize)),o.id!==-1&&o.timescale!==-1&&o.info!==null){if(o.info.type==="video"&&o.info.width!==-1){const s=o;o.inputTrack=new b1(this.input,new ED(s)),this.tracks.push(o)}else if(o.info.type==="audio"&&o.info.numberOfChannels!==-1){const s=o;o.inputTrack=new xc(this.input,new PD(s)),this.tracks.push(o)}}this.currentTrack=null}break;case"tkhd":{const o=this.currentTrack;if(!o)break;const s=dr(e),c=!!(np(e)&1);if(o.disposition.default=c,s===0)e.skip(8),o.id=Dt(e),e.skip(4),o.durationInMovieTimescale=Dt(e);else if(s===1)e.skip(16),o.id=Dt(e),e.skip(4),o.durationInMovieTimescale=xu(e);else throw new Error(`Incorrect track header version ${s}.`);e.skip(16);const f=[qh(e),qh(e),vy(e),qh(e),qh(e),vy(e),qh(e),qh(e),vy(e)],h=Zk(DM(OD(f),90));$e(h===0||h===90||h===180||h===270),o.rotation=h}break;case"elst":{const o=this.currentTrack;if(!o)break;const s=dr(e);e.skip(3);let l=!1,c=0;const f=Dt(e);for(let h=0;h<f;h++){const d=s===1?xu(e):Dt(e),p=s===1?jF(e):Kh(e),y=qh(e);if(d!==0){if(l){console.warn("Unsupported edit list: multiple edits are not currently supported. Only using first edit.");break}if(p===-1){c+=d;continue}if(y!==1){console.warn("Unsupported edit list entry: media rate must be 1.");break}o.editListPreviousSegmentDurations=c,o.editListOffset=p,l=!0}}}break;case"mdhd":{const o=this.currentTrack;if(!o)break;const s=dr(e);e.skip(3),s===0?(e.skip(8),o.timescale=Dt(e),o.durationInMediaTimescale=Dt(e)):s===1&&(e.skip(16),o.timescale=Dt(e),o.durationInMediaTimescale=xu(e));let l=ts(e);if(l>0){o.languageCode="";for(let c=0;c<3;c++)o.languageCode=String.fromCharCode(96+(l&31))+o.languageCode,l>>=5;n7(o.languageCode)||(o.languageCode=ku)}}break;case"hdlr":{const o=this.currentTrack;if(!o)break;e.skip(8);const s=Fo(e,4);s==="vide"?o.info={type:"video",width:-1,height:-1,codec:null,codecDescription:null,colorSpace:null,avcType:null,avcCodecInfo:null,hevcCodecInfo:null,vp9CodecInfo:null,av1CodecInfo:null}:s==="soun"&&(o.info={type:"audio",numberOfChannels:-1,sampleRate:-1,codec:null,codecDescription:null,aacCodecInfo:null})}break;case"stbl":{const o=this.currentTrack;if(!o)break;o.sampleTableByteOffset=r,this.readContiguousBoxes(e.slice(i,n.contentSize))}break;case"stsd":{const o=this.currentTrack;if(!o||o.info===null||o.sampleTable)break;const s=dr(e);e.skip(3);const l=Dt(e);for(let c=0;c<l;c++){const f=e.filePos,h=Kf(e);if(!h)break;o.internalCodecId=h.name;const d=h.name.toLowerCase();if(o.info.type==="video")d==="avc1"||d==="avc3"?(o.info.codec="avc",o.info.avcType=d==="avc1"?1:3):d==="hvc1"||d==="hev1"?o.info.codec="hevc":d==="vp08"?o.info.codec="vp8":d==="vp09"?o.info.codec="vp9":d==="av01"?o.info.codec="av1":console.warn(`Unsupported video codec (sample entry type '${h.name}').`),e.skip(24),o.info.width=ts(e),o.info.height=ts(e),e.skip(50),this.readContiguousBoxes(e.slice(e.filePos,f+h.totalSize-e.filePos));else{d==="mp4a"||(d==="opus"?o.info.codec="opus":d==="flac"?o.info.codec="flac":d==="twos"||d==="sowt"||d==="raw "||d==="in24"||d==="in32"||d==="fl32"||d==="fl64"||d==="lpcm"||d==="ipcm"||d==="fpcm"||(d==="ulaw"?o.info.codec="ulaw":d==="alaw"?o.info.codec="alaw":console.warn(`Unsupported audio codec (sample entry type '${h.name}').`))),e.skip(8);const p=ts(e);e.skip(6);let y=ts(e),w=ts(e);e.skip(4);let x=Dt(e)/65536;if(s===0&&p>0){if(p===1)e.skip(4),w=8*Dt(e),e.skip(8);else if(p===2){e.skip(4),x=z7(e),y=Dt(e),e.skip(4),w=Dt(e);const b=Dt(e);if(e.skip(8),d==="lpcm"){const S=w+7>>3,E=!!(b&1),_=!!(b&2),P=b&4?-1:0;w>0&&w<=64&&(E?w===32&&(o.info.codec=_?"pcm-f32be":"pcm-f32"):P&1<<S-1?S===1?o.info.codec="pcm-s8":S===2?o.info.codec=_?"pcm-s16be":"pcm-s16":S===3?o.info.codec=_?"pcm-s24be":"pcm-s24":S===4&&(o.info.codec=_?"pcm-s32be":"pcm-s32"):S===1&&(o.info.codec="pcm-u8")),o.info.codec===null&&console.warn("Unsupported PCM format.")}}}o.info.codec==="opus"&&(x=Ym),o.info.numberOfChannels=y,o.info.sampleRate=x,d==="twos"?w===8?o.info.codec="pcm-s8":w===16?o.info.codec="pcm-s16be":(console.warn(`Unsupported sample size ${w} for codec 'twos'.`),o.info.codec=null):d==="sowt"?w===8?o.info.codec="pcm-s8":w===16?o.info.codec="pcm-s16":(console.warn(`Unsupported sample size ${w} for codec 'sowt'.`),o.info.codec=null):d==="raw "?o.info.codec="pcm-u8":d==="in24"?o.info.codec="pcm-s24be":d==="in32"?o.info.codec="pcm-s32be":d==="fl32"?o.info.codec="pcm-f32be":d==="fl64"?o.info.codec="pcm-f64be":d==="ipcm"?o.info.codec="pcm-s16be":d==="fpcm"&&(o.info.codec="pcm-f32be"),this.readContiguousBoxes(e.slice(e.filePos,f+h.totalSize-e.filePos))}}}break;case"avcC":{const o=this.currentTrack;if(!o)break;$e(o.info),o.info.codecDescription=Nr(e,n.contentSize)}break;case"hvcC":{const o=this.currentTrack;if(!o)break;$e(o.info),o.info.codecDescription=Nr(e,n.contentSize)}break;case"vpcC":{const o=this.currentTrack;if(!o)break;$e(o.info?.type==="video"),e.skip(4);const s=dr(e),l=dr(e),c=dr(e),f=c>>4,h=c>>1&7,d=c&1,p=dr(e),y=dr(e),w=dr(e);o.info.vp9CodecInfo={profile:s,level:l,bitDepth:f,chromaSubsampling:h,videoFullRangeFlag:d,colourPrimaries:p,transferCharacteristics:y,matrixCoefficients:w}}break;case"av1C":{const o=this.currentTrack;if(!o)break;$e(o.info?.type==="video"),e.skip(1);const s=dr(e),l=s>>5,c=s&31,f=dr(e),h=f>>7,d=f>>6&1,p=f>>5&1,y=f>>4&1,w=f>>3&1,x=f>>2&1,b=f&3,S=l===2&&d?p?12:10:d?10:8;o.info.av1CodecInfo={profile:l,level:c,tier:h,bitDepth:S,monochrome:y,chromaSubsamplingX:w,chromaSubsamplingY:x,chromaSamplePosition:b}}break;case"colr":{const o=this.currentTrack;if(!o||($e(o.info?.type==="video"),Fo(e,4)!=="nclx"))break;const l=ts(e),c=ts(e),f=ts(e),h=!!(dr(e)&128);o.info.colorSpace={primaries:Qk[l],transfer:Jk[c],matrix:e7[f],fullRange:h}}break;case"wave":this.readContiguousBoxes(e.slice(i,n.contentSize));break;case"esds":{const o=this.currentTrack;if(!o)break;$e(o.info?.type==="audio"),e.skip(4);const s=dr(e);$e(s===3),yy(e),e.skip(2);const l=dr(e),c=(l&128)!==0,f=(l&64)!==0,h=(l&32)!==0;if(c&&e.skip(2),f){const x=dr(e);e.skip(x)}h&&e.skip(2);const d=dr(e);$e(d===4);const p=yy(e),y=e.filePos,w=dr(e);if(w===64||w===103?(o.info.codec="aac",o.info.aacCodecInfo={isMpeg2:w===103}):w===105||w===107?o.info.codec="mp3":w===221?o.info.codec="vorbis":console.warn(`Unsupported audio codec (objectTypeIndication ${w}) - discarding track.`),e.skip(12),p>e.filePos-y){const x=dr(e);$e(x===5);const b=yy(e);if(o.info.codecDescription=Nr(e,b),o.info.codec==="aac"){const S=f7(o.info.codecDescription);S.numberOfChannels!==null&&(o.info.numberOfChannels=S.numberOfChannels),S.sampleRate!==null&&(o.info.sampleRate=S.sampleRate)}}}break;case"enda":{const o=this.currentTrack;if(!o)break;$e(o.info?.type==="audio"),ts(e)&255&&(o.info.codec==="pcm-s16be"?o.info.codec="pcm-s16":o.info.codec==="pcm-s24be"?o.info.codec="pcm-s24":o.info.codec==="pcm-s32be"?o.info.codec="pcm-s32":o.info.codec==="pcm-f32be"?o.info.codec="pcm-f32":o.info.codec==="pcm-f64be"&&(o.info.codec="pcm-f64"))}break;case"pcmC":{const o=this.currentTrack;if(!o)break;$e(o.info?.type==="audio"),e.skip(4);const l=!!(dr(e)&1),c=dr(e);o.info.codec==="pcm-s16be"?l?c===16?o.info.codec="pcm-s16":c===24?o.info.codec="pcm-s24":c===32?o.info.codec="pcm-s32":(console.warn(`Invalid ipcm sample size ${c}.`),o.info.codec=null):c===16?o.info.codec="pcm-s16be":c===24?o.info.codec="pcm-s24be":c===32?o.info.codec="pcm-s32be":(console.warn(`Invalid ipcm sample size ${c}.`),o.info.codec=null):o.info.codec==="pcm-f32be"&&(l?c===32?o.info.codec="pcm-f32":c===64?o.info.codec="pcm-f64":(console.warn(`Invalid fpcm sample size ${c}.`),o.info.codec=null):c===32?o.info.codec="pcm-f32be":c===64?o.info.codec="pcm-f64be":(console.warn(`Invalid fpcm sample size ${c}.`),o.info.codec=null));break}case"dOps":{const o=this.currentTrack;if(!o)break;$e(o.info?.type==="audio"),e.skip(1);const s=dr(e),l=ts(e),c=Dt(e),f=H5(e),h=dr(e);let d;h!==0?d=Nr(e,2+s):d=new Uint8Array(0);const p=new Uint8Array(19+d.byteLength),y=new DataView(p.buffer);y.setUint32(0,1332770163,!1),y.setUint32(4,1214603620,!1),y.setUint8(8,1),y.setUint8(9,s),y.setUint16(10,l,!0),y.setUint32(12,c,!0),y.setInt16(16,f,!0),y.setUint8(18,h),p.set(d,19),o.info.codecDescription=p,o.info.numberOfChannels=s}break;case"dfLa":{const o=this.currentTrack;if(!o)break;$e(o.info?.type==="audio"),e.skip(4);const s=127,l=128,c=e.filePos;for(;e.filePos<a;){const y=dr(e),w=np(e);if((y&s)===yp.STREAMINFO){e.skip(10);const b=Dt(e),S=b>>>12,E=(b>>9&7)+1;o.info.sampleRate=S,o.info.numberOfChannels=E,e.skip(20)}else e.skip(w);if(y&l)break}const f=e.filePos;e.filePos=c;const h=Nr(e,f-c),d=new Uint8Array(4+h.byteLength);new DataView(d.buffer).setUint32(0,1716281667,!1),d.set(h,4),o.info.codecDescription=d}break;case"stts":{const o=this.currentTrack;if(!o||!o.sampleTable)break;e.skip(4);const s=Dt(e);let l=0,c=0;for(let f=0;f<s;f++){const h=Dt(e),d=Dt(e);o.sampleTable.sampleTimingEntries.push({startIndex:l,startDecodeTimestamp:c,count:h,delta:d}),l+=h,c+=h*d}}break;case"ctts":{const o=this.currentTrack;if(!o||!o.sampleTable)break;e.skip(4);const s=Dt(e);let l=0;for(let c=0;c<s;c++){const f=Dt(e),h=Kh(e);o.sampleTable.sampleCompositionTimeOffsets.push({startIndex:l,count:f,offset:h}),l+=f}}break;case"stsz":{const o=this.currentTrack;if(!o||!o.sampleTable)break;e.skip(4);const s=Dt(e),l=Dt(e);if(s===0)for(let c=0;c<l;c++){const f=Dt(e);o.sampleTable.sampleSizes.push(f)}else o.sampleTable.sampleSizes.push(s)}break;case"stz2":{const o=this.currentTrack;if(!o||!o.sampleTable)break;e.skip(4),e.skip(3);const s=dr(e),l=Dt(e),c=Nr(e,Math.ceil(l*s/8)),f=new aa(c);for(let h=0;h<l;h++){const d=f.readBits(s);o.sampleTable.sampleSizes.push(d)}}break;case"stss":{const o=this.currentTrack;if(!o||!o.sampleTable)break;e.skip(4),o.sampleTable.keySampleIndices=[];const s=Dt(e);for(let l=0;l<s;l++){const c=Dt(e)-1;o.sampleTable.keySampleIndices.push(c)}o.sampleTable.keySampleIndices[0]!==0&&o.sampleTable.keySampleIndices.unshift(0)}break;case"stsc":{const o=this.currentTrack;if(!o||!o.sampleTable)break;e.skip(4);const s=Dt(e);for(let c=0;c<s;c++){const f=Dt(e)-1,h=Dt(e),d=Dt(e);o.sampleTable.sampleToChunk.push({startSampleIndex:-1,startChunkIndex:f,samplesPerChunk:h,sampleDescriptionIndex:d})}let l=0;for(let c=0;c<o.sampleTable.sampleToChunk.length;c++)if(o.sampleTable.sampleToChunk[c].startSampleIndex=l,c<o.sampleTable.sampleToChunk.length-1){const h=o.sampleTable.sampleToChunk[c+1].startChunkIndex-o.sampleTable.sampleToChunk[c].startChunkIndex;l+=h*o.sampleTable.sampleToChunk[c].samplesPerChunk}}break;case"stco":{const o=this.currentTrack;if(!o||!o.sampleTable)break;e.skip(4);const s=Dt(e);for(let l=0;l<s;l++){const c=Dt(e);o.sampleTable.chunkOffsets.push(c)}}break;case"co64":{const o=this.currentTrack;if(!o||!o.sampleTable)break;e.skip(4);const s=Dt(e);for(let l=0;l<s;l++){const c=xu(e);o.sampleTable.chunkOffsets.push(c)}}break;case"mvex":this.isFragmented=!0,this.readContiguousBoxes(e.slice(i,n.contentSize));break;case"mehd":{const o=dr(e);e.skip(3);const s=o===1?xu(e):Dt(e);this.movieDurationInTimescale=s}break;case"trex":{e.skip(4);const o=Dt(e),s=Dt(e),l=Dt(e),c=Dt(e),f=Dt(e);this.fragmentTrackDefaults.push({trackId:o,defaultSampleDescriptionIndex:s,defaultSampleDuration:l,defaultSampleSize:c,defaultSampleFlags:f})}break;case"tfra":{const o=dr(e);e.skip(3);const s=Dt(e),l=this.tracks.find(S=>S.id===s);if(!l)break;const c=Dt(e),f=(c&48)>>4,h=(c&12)>>2,d=c&3,p=[dr,ts,np,Dt],y=p[f],w=p[h],x=p[d],b=Dt(e);for(let S=0;S<b;S++){const E=o===1?xu(e):Dt(e),_=o===1?xu(e):Dt(e);y(e),w(e),x(e),l.fragmentLookupTable.push({timestamp:E,moofOffset:_})}l.fragmentLookupTable.sort((S,E)=>S.timestamp-E.timestamp);for(let S=0;S<l.fragmentLookupTable.length-1;S++){const E=l.fragmentLookupTable[S],_=l.fragmentLookupTable[S+1];E.timestamp===_.timestamp&&(l.fragmentLookupTable.splice(S+1,1),S--)}}break;case"moof":this.currentFragment={moofOffset:r,moofSize:n.totalSize,implicitBaseDataOffset:r,trackData:new Map},this.readContiguousBoxes(e.slice(i,n.contentSize)),this.lastReadFragment=this.currentFragment,this.currentFragment=null;break;case"traf":if($e(this.currentFragment),this.readContiguousBoxes(e.slice(i,n.contentSize)),this.currentTrack){const o=this.currentFragment.trackData.get(this.currentTrack.id);if(o){const{currentFragmentState:s}=this.currentTrack;$e(s),s.startTimestamp!==null&&(by(o,s.startTimestamp),o.startTimestampIsFinal=!0)}this.currentTrack.currentFragmentState=null,this.currentTrack=null}break;case"tfhd":{$e(this.currentFragment),e.skip(1);const o=np(e),s=!!(o&1),l=!!(o&2),c=!!(o&8),f=!!(o&16),h=!!(o&32),d=!!(o&65536),p=!!(o&131072),y=Dt(e),w=this.tracks.find(b=>b.id===y);if(!w)break;const x=this.fragmentTrackDefaults.find(b=>b.trackId===y);this.currentTrack=w,w.currentFragmentState={baseDataOffset:this.currentFragment.implicitBaseDataOffset,sampleDescriptionIndex:x?.defaultSampleDescriptionIndex??null,defaultSampleDuration:x?.defaultSampleDuration??null,defaultSampleSize:x?.defaultSampleSize??null,defaultSampleFlags:x?.defaultSampleFlags??null,startTimestamp:null},s?w.currentFragmentState.baseDataOffset=xu(e):p&&(w.currentFragmentState.baseDataOffset=this.currentFragment.moofOffset),l&&(w.currentFragmentState.sampleDescriptionIndex=Dt(e)),c&&(w.currentFragmentState.defaultSampleDuration=Dt(e)),f&&(w.currentFragmentState.defaultSampleSize=Dt(e)),h&&(w.currentFragmentState.defaultSampleFlags=Dt(e)),d&&(w.currentFragmentState.defaultSampleDuration=0)}break;case"tfdt":{const o=this.currentTrack;if(!o)break;$e(o.currentFragmentState);const s=dr(e);e.skip(3);const l=s===0?Dt(e):xu(e);o.currentFragmentState.startTimestamp=l}break;case"trun":{const o=this.currentTrack;if(!o)break;if($e(this.currentFragment),$e(o.currentFragmentState),this.currentFragment.trackData.has(o.id)){console.warn("Can't have two trun boxes for the same track in one fragment. Ignoring...");break}const s=dr(e),l=np(e),c=!!(l&1),f=!!(l&4),h=!!(l&256),d=!!(l&512),p=!!(l&1024),y=!!(l&2048),w=Dt(e);let x=o.currentFragmentState.baseDataOffset;c&&(x+=Kh(e));let b=null;f&&(b=Dt(e));let S=x;if(w===0){this.currentFragment.implicitBaseDataOffset=S;break}let E=0;const _={track:o,startTimestamp:0,endTimestamp:0,firstKeyFrameTimestamp:null,samples:[],presentationTimestamps:[],startTimestampIsFinal:!1};this.currentFragment.trackData.set(o.id,_);for(let T=0;T<w;T++){let N;h?N=Dt(e):($e(o.currentFragmentState.defaultSampleDuration!==null),N=o.currentFragmentState.defaultSampleDuration);let D;d?D=Dt(e):($e(o.currentFragmentState.defaultSampleSize!==null),D=o.currentFragmentState.defaultSampleSize);let F;p?F=Dt(e):($e(o.currentFragmentState.defaultSampleFlags!==null),F=o.currentFragmentState.defaultSampleFlags),T===0&&b!==null&&(F=b);let A=0;y&&(s===0?A=Dt(e):A=Kh(e));const L=!(F&65536);_.samples.push({presentationTimestamp:E+A,duration:N,byteOffset:S,byteSize:D,isKeyFrame:L}),S+=D,E+=N}_.presentationTimestamps=_.samples.map((T,N)=>({presentationTimestamp:T.presentationTimestamp,sampleIndex:N})).sort((T,N)=>T.presentationTimestamp-N.presentationTimestamp);for(let T=0;T<_.presentationTimestamps.length;T++){const N=_.presentationTimestamps[T],D=_.samples[N.sampleIndex];if(_.firstKeyFrameTimestamp===null&&D.isKeyFrame&&(_.firstKeyFrameTimestamp=D.presentationTimestamp),T<_.presentationTimestamps.length-1){const F=_.presentationTimestamps[T+1];D.duration=F.presentationTimestamp-N.presentationTimestamp}}const P=_.samples[_.presentationTimestamps[0].sampleIndex],O=_.samples[El(_.presentationTimestamps).sampleIndex];_.startTimestamp=P.presentationTimestamp,_.endTimestamp=O.presentationTimestamp+O.duration,this.currentFragment.implicitBaseDataOffset=S}break;case"udta":{const o=this.iterateContiguousBoxes(e.slice(i,n.contentSize));for(const{boxInfo:s,slice:l}of o){if(s.name!=="meta"&&!this.currentTrack){const c=l.filePos;this.metadataTags.raw??={},s.name[0]==="©"?this.metadataTags.raw[s.name]??=ic(l):this.metadataTags.raw[s.name]??=Nr(l,s.contentSize),l.filePos=c}switch(s.name){case"meta":l.skip(-s.headerSize),this.traverseBox(l);break;case"©nam":case"name":this.currentTrack?this.currentTrack.name=Kl.decode(Nr(l,s.contentSize)):this.metadataTags.title??=ic(l);break;case"©des":this.currentTrack||(this.metadataTags.description??=ic(l));break;case"©ART":this.currentTrack||(this.metadataTags.artist??=ic(l));break;case"©alb":this.currentTrack||(this.metadataTags.album??=ic(l));break;case"albr":this.currentTrack||(this.metadataTags.albumArtist??=ic(l));break;case"©gen":this.currentTrack||(this.metadataTags.genre??=ic(l));break;case"©day":if(!this.currentTrack){const c=new Date(ic(l));Number.isNaN(c.getTime())||(this.metadataTags.date??=c)}break;case"©cmt":this.currentTrack||(this.metadataTags.comment??=ic(l));break;case"©lyr":this.currentTrack||(this.metadataTags.lyrics??=ic(l));break}}}break;case"meta":{if(this.currentTrack)break;const s=Dt(e)!==0;this.currentMetadataKeys=new Map,s?this.readContiguousBoxes(e.slice(i,n.contentSize)):this.readContiguousBoxes(e.slice(i+4,n.contentSize-4)),this.currentMetadataKeys=null}break;case"keys":{if(!this.currentMetadataKeys)break;e.skip(4);const o=Dt(e);for(let s=0;s<o;s++){const l=Dt(e);e.skip(4);const c=Kl.decode(Nr(e,l-8));this.currentMetadataKeys.set(s+1,c)}}break;case"ilst":{if(!this.currentMetadataKeys)break;const o=this.iterateContiguousBoxes(e.slice(i,n.contentSize));for(const{boxInfo:s,slice:l}of o){let c=s.name;const f=(c.charCodeAt(0)<<24)+(c.charCodeAt(1)<<16)+(c.charCodeAt(2)<<8)+c.charCodeAt(3);this.currentMetadataKeys.has(f)&&(c=this.currentMetadataKeys.get(f));const h=_D(l);switch(this.metadataTags.raw??={},this.metadataTags.raw[c]??=h,c){case"©nam":case"titl":case"com.apple.quicktime.title":case"title":typeof h=="string"&&(this.metadataTags.title??=h);break;case"©des":case"desc":case"dscp":case"com.apple.quicktime.description":case"description":typeof h=="string"&&(this.metadataTags.description??=h);break;case"©ART":case"com.apple.quicktime.artist":case"artist":typeof h=="string"&&(this.metadataTags.artist??=h);break;case"©alb":case"albm":case"com.apple.quicktime.album":case"album":typeof h=="string"&&(this.metadataTags.album??=h);break;case"aART":case"album_artist":typeof h=="string"&&(this.metadataTags.albumArtist??=h);break;case"©cmt":case"com.apple.quicktime.comment":case"comment":typeof h=="string"&&(this.metadataTags.comment??=h);break;case"©gen":case"gnre":case"com.apple.quicktime.genre":case"genre":typeof h=="string"&&(this.metadataTags.genre??=h);break;case"©lyr":case"lyrics":typeof h=="string"&&(this.metadataTags.lyrics??=h);break;case"©day":case"rldt":case"com.apple.quicktime.creationdate":case"date":if(typeof h=="string"){const d=new Date(h);Number.isNaN(d.getTime())||(this.metadataTags.date??=d)}break;case"covr":case"com.apple.quicktime.artwork":h instanceof F0?(this.metadataTags.images??=[],this.metadataTags.images.push({data:h.data,kind:"coverFront",mimeType:h.mimeType})):h instanceof Uint8Array&&(this.metadataTags.images??=[],this.metadataTags.images.push({data:h,kind:"coverFront",mimeType:"image/*"}));break;case"track":if(typeof h=="string"){const d=h.split("/"),p=Number.parseInt(d[0],10),y=d[1]&&Number.parseInt(d[1],10);Number.isInteger(p)&&p>0&&(this.metadataTags.trackNumber??=p),y&&Number.isInteger(y)&&y>0&&(this.metadataTags.tracksTotal??=y)}break;case"trkn":if(h instanceof Uint8Array&&h.length>=6){const d=Wa(h),p=d.getUint16(2,!1),y=d.getUint16(4,!1);p>0&&(this.metadataTags.trackNumber??=p),y>0&&(this.metadataTags.tracksTotal??=y)}break;case"disc":case"disk":if(h instanceof Uint8Array&&h.length>=6){const d=Wa(h),p=d.getUint16(2,!1),y=d.getUint16(4,!1);p>0&&(this.metadataTags.discNumber??=p),y>0&&(this.metadataTags.discsTotal??=y)}break}}}break}return e.filePos=a,!0}}class C7{constructor(e){this.internalTrack=e,this.packetToSampleIndex=new WeakMap,this.packetToFragmentLocation=new WeakMap}getId(){return this.internalTrack.id}getCodec(){throw new Error("Not implemented on base class.")}getInternalCodecId(){return this.internalTrack.internalCodecId}getName(){return this.internalTrack.name}getLanguageCode(){return this.internalTrack.languageCode}getTimeResolution(){return this.internalTrack.timescale}getDisposition(){return this.internalTrack.disposition}async computeDuration(){const e=await this.getPacket(1/0,{metadataOnly:!0});return(e?.timestamp??0)+(e?.duration??0)}async getFirstTimestamp(){return(await this.getFirstPacket({metadataOnly:!0}))?.timestamp??0}async getFirstPacket(e){const r=await this.fetchPacketForSampleIndex(0,e);return r||!this.internalTrack.demuxer.isFragmented?r:this.performFragmentedLookup(null,n=>n.trackData.get(this.internalTrack.id)?{sampleIndex:0,correctSampleFound:!0}:{sampleIndex:-1,correctSampleFound:!1},-1/0,1/0,e)}mapTimestampIntoTimescale(e){return fm(e*this.internalTrack.timescale)+this.internalTrack.editListOffset}async getPacket(e,r){const n=this.mapTimestampIntoTimescale(e),i=this.internalTrack.demuxer.getSampleTableForTrack(this.internalTrack),a=D5(i,n),o=await this.fetchPacketForSampleIndex(a,r);return!ox(i)||!this.internalTrack.demuxer.isFragmented?o:this.performFragmentedLookup(null,s=>{const l=s.trackData.get(this.internalTrack.id);if(!l)return{sampleIndex:-1,correctSampleFound:!1};const c=oi(l.presentationTimestamps,n,d=>d.presentationTimestamp),f=c!==-1?l.presentationTimestamps[c].sampleIndex:-1,h=c!==-1&&n<l.endTimestamp;return{sampleIndex:f,correctSampleFound:h}},n,n,r)}async getNextPacket(e,r){const n=this.packetToSampleIndex.get(e);if(n!==void 0)return this.fetchPacketForSampleIndex(n+1,r);const i=this.packetToFragmentLocation.get(e);if(i===void 0)throw new Error("Packet was not created from this track.");return this.performFragmentedLookup(i.fragment,a=>{if(a===i.fragment){const o=a.trackData.get(this.internalTrack.id);if(i.sampleIndex+1<o.samples.length)return{sampleIndex:i.sampleIndex+1,correctSampleFound:!0}}else if(a.trackData.get(this.internalTrack.id))return{sampleIndex:0,correctSampleFound:!0};return{sampleIndex:-1,correctSampleFound:!1}},-1/0,1/0,r)}async getKeyPacket(e,r){const n=this.mapTimestampIntoTimescale(e),i=this.internalTrack.demuxer.getSampleTableForTrack(this.internalTrack),a=CD(i,n),o=await this.fetchPacketForSampleIndex(a,r);return!ox(i)||!this.internalTrack.demuxer.isFragmented?o:this.performFragmentedLookup(null,s=>{const l=s.trackData.get(this.internalTrack.id);if(!l)return{sampleIndex:-1,correctSampleFound:!1};const c=r7(l.presentationTimestamps,d=>l.samples[d.sampleIndex].isKeyFrame&&d.presentationTimestamp<=n),f=c!==-1?l.presentationTimestamps[c].sampleIndex:-1,h=c!==-1&&n<l.endTimestamp;return{sampleIndex:f,correctSampleFound:h}},n,n,r)}async getNextKeyPacket(e,r){const n=this.packetToSampleIndex.get(e);if(n!==void 0){const a=this.internalTrack.demuxer.getSampleTableForTrack(this.internalTrack),o=AD(a,n);return this.fetchPacketForSampleIndex(o,r)}const i=this.packetToFragmentLocation.get(e);if(i===void 0)throw new Error("Packet was not created from this track.");return this.performFragmentedLookup(i.fragment,a=>{if(a===i.fragment){const s=a.trackData.get(this.internalTrack.id).samples.findIndex((l,c)=>l.isKeyFrame&&c>i.sampleIndex);if(s!==-1)return{sampleIndex:s,correctSampleFound:!0}}else{const o=a.trackData.get(this.internalTrack.id);if(o&&o.firstKeyFrameTimestamp!==null){const s=o.samples.findIndex(l=>l.isKeyFrame);return $e(s!==-1),{sampleIndex:s,correctSampleFound:!0}}}return{sampleIndex:-1,correctSampleFound:!1}},-1/0,1/0,r)}async fetchPacketForSampleIndex(e,r){if(e===-1)return null;const n=this.internalTrack.demuxer.getSampleTableForTrack(this.internalTrack),i=TD(n,e);if(!i)return null;let a;if(r.metadataOnly)a=Zl;else{let c=this.internalTrack.demuxer.reader.requestSlice(i.sampleOffset,i.sampleSize);c instanceof Promise&&(c=await c),$e(c),a=Nr(c,i.sampleSize)}const o=(i.presentationTimestamp-this.internalTrack.editListOffset)/this.internalTrack.timescale,s=i.duration/this.internalTrack.timescale,l=new Bo(a,i.isKeyFrame?"key":"delta",o,s,e,i.sampleSize);return this.packetToSampleIndex.set(l,e),l}async fetchPacketInFragment(e,r,n){if(r===-1)return null;const a=e.trackData.get(this.internalTrack.id).samples[r];$e(a);let o;if(n.metadataOnly)o=Zl;else{let f=this.internalTrack.demuxer.reader.requestSlice(a.byteOffset,a.byteSize);f instanceof Promise&&(f=await f),$e(f),o=Nr(f,a.byteSize)}const s=(a.presentationTimestamp-this.internalTrack.editListOffset)/this.internalTrack.timescale,l=a.duration/this.internalTrack.timescale,c=new Bo(o,a.isKeyFrame?"key":"delta",s,l,e.moofOffset+r,a.byteSize);return this.packetToFragmentLocation.set(c,{fragment:e,sampleIndex:r}),c}async performFragmentedLookup(e,r,n,i,a){const o=this.internalTrack.demuxer;let s=null,l=null,c=-1;if(e){const{sampleIndex:x,correctSampleFound:b}=r(e);if(b)return this.fetchPacketInFragment(e,x,a);x!==-1&&(l=e,c=x)}const f=oi(this.internalTrack.fragmentLookupTable,n,x=>x.timestamp),h=f!==-1?this.internalTrack.fragmentLookupTable[f]:null,d=oi(this.internalTrack.fragmentPositionCache,n,x=>x.startTimestamp),p=d!==-1?this.internalTrack.fragmentPositionCache[d]:null,y=Math.max(h?.moofOffset??0,p?.moofOffset??0)||null;let w;for(e?y===null||e.moofOffset>=y?(w=e.moofOffset+e.moofSize,s=e):w=y:w=y??0;;){if(s){const E=s.trackData.get(this.internalTrack.id);if(E&&E.startTimestamp>i)break}let x=o.reader.requestSliceRange(w,tp,k0);if(x instanceof Promise&&(x=await x),!x)break;const b=w,S=Kf(x);if(!S)break;if(S.name==="moof"){s=await o.readFragment(b);const{sampleIndex:E,correctSampleFound:_}=r(s);if(_)return this.fetchPacketInFragment(s,E,a);E!==-1&&(l=s,c=E)}w=b+S.totalSize}if(h&&(!l||l.moofOffset<h.moofOffset)){const x=this.internalTrack.fragmentLookupTable[f-1];$e(!x||x.timestamp<h.timestamp);const b=x?.timestamp??-1/0;return this.performFragmentedLookup(null,r,b,i,a)}return l?this.fetchPacketInFragment(l,c,a):null}}class ED extends C7{constructor(e){super(e),this.decoderConfigPromise=null,this.internalTrack=e}getCodec(){return this.internalTrack.info.codec}getCodedWidth(){return this.internalTrack.info.width}getCodedHeight(){return this.internalTrack.info.height}getRotation(){return this.internalTrack.rotation}async getColorSpace(){return{primaries:this.internalTrack.info.colorSpace?.primaries,transfer:this.internalTrack.info.colorSpace?.transfer,matrix:this.internalTrack.info.colorSpace?.matrix,fullRange:this.internalTrack.info.colorSpace?.fullRange}}async canBeTransparent(){return!1}async getDecoderConfig(){return this.internalTrack.info.codec?this.decoderConfigPromise??=(async()=>{if(this.internalTrack.info.codec==="vp9"&&!this.internalTrack.info.vp9CodecInfo){const e=await this.getFirstPacket({});this.internalTrack.info.vp9CodecInfo=e&&v7(e.data)}else if(this.internalTrack.info.codec==="av1"&&!this.internalTrack.info.av1CodecInfo){const e=await this.getFirstPacket({});this.internalTrack.info.av1CodecInfo=e&&b7(e.data)}return{codec:u7(this.internalTrack.info),codedWidth:this.internalTrack.info.width,codedHeight:this.internalTrack.info.height,description:this.internalTrack.info.codecDescription??void 0,colorSpace:this.internalTrack.info.colorSpace??void 0}})():null}}class PD extends C7{constructor(e){super(e),this.decoderConfig=null,this.internalTrack=e}getCodec(){return this.internalTrack.info.codec}getNumberOfChannels(){return this.internalTrack.info.numberOfChannels}getSampleRate(){return this.internalTrack.info.sampleRate}async getDecoderConfig(){return this.internalTrack.info.codec?this.decoderConfig??={codec:c7(this.internalTrack.info),numberOfChannels:this.internalTrack.info.numberOfChannels,sampleRate:this.internalTrack.info.sampleRate,description:this.internalTrack.info.codecDescription??void 0}:null}}const D5=(t,e)=>{if(t.presentationTimestamps){const r=oi(t.presentationTimestamps,e,n=>n.presentationTimestamp);return r===-1?-1:t.presentationTimestamps[r].sampleIndex}else{const r=oi(t.sampleTimingEntries,e,i=>i.startDecodeTimestamp);if(r===-1)return-1;const n=t.sampleTimingEntries[r];return n.startIndex+Math.min(Math.floor((e-n.startDecodeTimestamp)/n.delta),n.count-1)}},CD=(t,e)=>{if(!t.keySampleIndices)return D5(t,e);if(t.presentationTimestamps){const r=oi(t.presentationTimestamps,e,n=>n.presentationTimestamp);if(r===-1)return-1;for(let n=r;n>=0;n--){const i=t.presentationTimestamps[n].sampleIndex;if(Gm(t.keySampleIndices,i,o=>o)!==-1)return i}return-1}else{const r=D5(t,e),n=oi(t.keySampleIndices,r,i=>i);return t.keySampleIndices[n]??-1}},TD=(t,e)=>{const r=oi(t.sampleTimingEntries,e,b=>b.startIndex),n=t.sampleTimingEntries[r];if(!n||n.startIndex+n.count<=e)return null;let a=n.startDecodeTimestamp+(e-n.startIndex)*n.delta;const o=oi(t.sampleCompositionTimeOffsets,e,b=>b.startIndex),s=t.sampleCompositionTimeOffsets[o];s&&e-s.startIndex<s.count&&(a+=s.offset);const l=t.sampleSizes[Math.min(e,t.sampleSizes.length-1)],c=oi(t.sampleToChunk,e,b=>b.startSampleIndex),f=t.sampleToChunk[c];$e(f);const h=f.startChunkIndex+Math.floor((e-f.startSampleIndex)/f.samplesPerChunk),d=t.chunkOffsets[h],p=f.startSampleIndex+(h-f.startChunkIndex)*f.samplesPerChunk;let y=0,w=d;if(t.sampleSizes.length===1)w+=l*(e-p),y+=l*f.samplesPerChunk;else for(let b=p;b<p+f.samplesPerChunk;b++){const S=t.sampleSizes[b];b<e&&(w+=S),y+=S}let x=n.delta;if(t.presentationTimestamps){const b=t.presentationTimestampIndexMap[e];$e(b!==void 0),b<t.presentationTimestamps.length-1&&(x=t.presentationTimestamps[b+1].presentationTimestamp-a)}return{presentationTimestamp:a,duration:x,sampleOffset:w,sampleSize:l,chunkOffset:d,chunkSize:y,isKeyFrame:t.keySampleIndices?Gm(t.keySampleIndices,e,b=>b)!==-1:!0}},AD=(t,e)=>{if(!t.keySampleIndices)return e+1;const r=oi(t.keySampleIndices,e,n=>n);return t.keySampleIndices[r+1]??-1},by=(t,e)=>{t.startTimestamp+=e,t.endTimestamp+=e;for(const r of t.samples)r.presentationTimestamp+=e;for(const r of t.presentationTimestamps)r.presentationTimestamp+=e},OD=t=>{const[e,,,r]=t,n=Math.hypot(e,r),i=e/n,a=r/n,o=-Math.atan2(a,i)*(180/Math.PI);return Number.isFinite(o)?o:0},ox=t=>t.sampleSizes.length===0;var bt;(function(t){t[t.EBML=440786851]="EBML",t[t.EBMLVersion=17030]="EBMLVersion",t[t.EBMLReadVersion=17143]="EBMLReadVersion",t[t.EBMLMaxIDLength=17138]="EBMLMaxIDLength",t[t.EBMLMaxSizeLength=17139]="EBMLMaxSizeLength",t[t.DocType=17026]="DocType",t[t.DocTypeVersion=17031]="DocTypeVersion",t[t.DocTypeReadVersion=17029]="DocTypeReadVersion",t[t.Void=236]="Void",t[t.Segment=408125543]="Segment",t[t.SeekHead=290298740]="SeekHead",t[t.Seek=19899]="Seek",t[t.SeekID=21419]="SeekID",t[t.SeekPosition=21420]="SeekPosition",t[t.Duration=17545]="Duration",t[t.Info=357149030]="Info",t[t.TimestampScale=2807729]="TimestampScale",t[t.MuxingApp=19840]="MuxingApp",t[t.WritingApp=22337]="WritingApp",t[t.Tracks=374648427]="Tracks",t[t.TrackEntry=174]="TrackEntry",t[t.TrackNumber=215]="TrackNumber",t[t.TrackUID=29637]="TrackUID",t[t.TrackType=131]="TrackType",t[t.FlagEnabled=185]="FlagEnabled",t[t.FlagDefault=136]="FlagDefault",t[t.FlagForced=21930]="FlagForced",t[t.FlagOriginal=21934]="FlagOriginal",t[t.FlagHearingImpaired=21931]="FlagHearingImpaired",t[t.FlagVisualImpaired=21932]="FlagVisualImpaired",t[t.FlagCommentary=21935]="FlagCommentary",t[t.FlagLacing=156]="FlagLacing",t[t.Name=21358]="Name",t[t.Language=2274716]="Language",t[t.LanguageBCP47=2274717]="LanguageBCP47",t[t.CodecID=134]="CodecID",t[t.CodecPrivate=25506]="CodecPrivate",t[t.CodecDelay=22186]="CodecDelay",t[t.SeekPreRoll=22203]="SeekPreRoll",t[t.DefaultDuration=2352003]="DefaultDuration",t[t.Video=224]="Video",t[t.PixelWidth=176]="PixelWidth",t[t.PixelHeight=186]="PixelHeight",t[t.AlphaMode=21440]="AlphaMode",t[t.Audio=225]="Audio",t[t.SamplingFrequency=181]="SamplingFrequency",t[t.Channels=159]="Channels",t[t.BitDepth=25188]="BitDepth",t[t.SimpleBlock=163]="SimpleBlock",t[t.BlockGroup=160]="BlockGroup",t[t.Block=161]="Block",t[t.BlockAdditions=30113]="BlockAdditions",t[t.BlockMore=166]="BlockMore",t[t.BlockAdditional=165]="BlockAdditional",t[t.BlockAddID=238]="BlockAddID",t[t.BlockDuration=155]="BlockDuration",t[t.ReferenceBlock=251]="ReferenceBlock",t[t.Cluster=524531317]="Cluster",t[t.Timestamp=231]="Timestamp",t[t.Cues=475249515]="Cues",t[t.CuePoint=187]="CuePoint",t[t.CueTime=179]="CueTime",t[t.CueTrackPositions=183]="CueTrackPositions",t[t.CueTrack=247]="CueTrack",t[t.CueClusterPosition=241]="CueClusterPosition",t[t.Colour=21936]="Colour",t[t.MatrixCoefficients=21937]="MatrixCoefficients",t[t.TransferCharacteristics=21946]="TransferCharacteristics",t[t.Primaries=21947]="Primaries",t[t.Range=21945]="Range",t[t.Projection=30320]="Projection",t[t.ProjectionType=30321]="ProjectionType",t[t.ProjectionPoseRoll=30325]="ProjectionPoseRoll",t[t.Attachments=423732329]="Attachments",t[t.AttachedFile=24999]="AttachedFile",t[t.FileDescription=18046]="FileDescription",t[t.FileName=18030]="FileName",t[t.FileMediaType=18016]="FileMediaType",t[t.FileData=18012]="FileData",t[t.FileUID=18094]="FileUID",t[t.Chapters=272869232]="Chapters",t[t.Tags=307544935]="Tags",t[t.Tag=29555]="Tag",t[t.Targets=25536]="Targets",t[t.TargetTypeValue=26826]="TargetTypeValue",t[t.TargetType=25546]="TargetType",t[t.TagTrackUID=25541]="TagTrackUID",t[t.TagEditionUID=25545]="TagEditionUID",t[t.TagChapterUID=25540]="TagChapterUID",t[t.TagAttachmentUID=25542]="TagAttachmentUID",t[t.SimpleTag=26568]="SimpleTag",t[t.TagName=17827]="TagName",t[t.TagLanguage=17530]="TagLanguage",t[t.TagString=17543]="TagString",t[t.TagBinary=17541]="TagBinary",t[t.ContentEncodings=28032]="ContentEncodings",t[t.ContentEncoding=25152]="ContentEncoding",t[t.ContentEncodingOrder=20529]="ContentEncodingOrder",t[t.ContentEncodingScope=20530]="ContentEncodingScope",t[t.ContentCompression=20532]="ContentCompression",t[t.ContentCompAlgo=16980]="ContentCompAlgo",t[t.ContentCompSettings=16981]="ContentCompSettings",t[t.ContentEncryption=20533]="ContentEncryption"})(bt||(bt={}));const ND=[bt.EBML,bt.Segment],i1=[bt.SeekHead,bt.Info,bt.Cluster,bt.Tracks,bt.Cues,bt.Attachments,bt.Chapters,bt.Tags],Dg=[...ND,...i1],F5=8,_u=2,Xc=2*F5,T7=t=>{const e=dr(t);if(t.skip(-1),e===0)return null;let r=1,n=128;for(;(e&n)===0;)r++,n>>=1;return r},E0=t=>{const e=dr(t);if(e===0)return null;let r=1,n=128;for(;(e&n)===0;)r++,n>>=1;let i=e&n-1;for(let a=1;a<r;a++)i*=256,i+=dr(t);return i},Jr=(t,e)=>{if(e<1||e>8)throw new Error("Bad unsigned int size "+e);let r=0;for(let n=0;n<e;n++)r*=256,r+=dr(t);return r},ID=(t,e)=>{if(e<1)throw new Error("Bad unsigned int size "+e);let r=0n;for(let n=0;n<e;n++)r<<=8n,r+=BigInt(dr(t));return r},Gb=t=>{const e=T7(t);return e===null?null:Jr(t,e)},A7=t=>{let e=dr(t);return e===255?e=null:(t.skip(-1),e=E0(t),e===72057594037927940&&(e=null)),e},Hc=t=>{const e=Gb(t);if(e===null)return null;const r=A7(t);return{id:e,size:r}},rp=(t,e)=>{const r=Nr(t,e);let n=0;for(;n<e&&r[n]!==0;)n+=1;return String.fromCharCode(...r.subarray(0,n))},c0=(t,e)=>{const r=Nr(t,e);let n=0;for(;n<e&&r[n]!==0;)n+=1;return Kl.decode(r.subarray(0,n))},wy=(t,e)=>{if(e===0)return 0;if(e!==4&&e!==8)throw new Error("Bad float size "+e);return e===4?UF(t):z7(t)},B5=async(t,e,r,n)=>{const i=new Set(r);let a=e;for(;n===null||a<n;){let o=t.requestSliceRange(a,_u,Xc);if(o instanceof Promise&&(o=await o),!o)break;const s=Hc(o);if(!s)break;if(i.has(s.id))return{pos:a,found:!0};Xf(s.size),a=o.filePos+s.size}return{pos:n!==null&&n>a?n:a,found:!1}},O7=async(t,e,r,n)=>{const a=new Set(r);let o=e;for(;o<n;){let s=t.requestSliceRange(o,0,Math.min(65536,n-o));if(s instanceof Promise&&(s=await s),!s||s.length<F5)break;for(let l=0;l<s.length-F5;l++){s.filePos=o;const c=Gb(s);if(c!==null&&a.has(c))return o;o++}}return null},ac={avc:"V_MPEG4/ISO/AVC",hevc:"V_MPEGH/ISO/HEVC",vp8:"V_VP8",vp9:"V_VP9",av1:"V_AV1",aac:"A_AAC",mp3:"A_MPEG/L3",opus:"A_OPUS",vorbis:"A_VORBIS",flac:"A_FLAC"};function Xf(t){if(t===null)throw new Error("Undefined element size is used in a place where it is not supported.")}const LD=t=>{let r=(t.hasVideo?"video/":t.hasAudio?"audio/":"application/")+(t.isWebM?"webm":"x-matroska");if(t.codecStrings.length>0){const n=[...new Set(t.codecStrings.filter(Boolean))];r+=`; codecs="${n.join(", ")}"`}return r};var zc;(function(t){t[t.None=0]="None",t[t.Xiph=1]="Xiph",t[t.FixedSize=2]="FixedSize",t[t.Ebml=3]="Ebml"})(zc||(zc={}));var dm;(function(t){t[t.Block=1]="Block",t[t.Private=2]="Private",t[t.Next=4]="Next"})(dm||(dm={}));var j0;(function(t){t[t.Zlib=0]="Zlib",t[t.Bzlib=1]="Bzlib",t[t.lzo1x=2]="lzo1x",t[t.HeaderStripping=3]="HeaderStripping"})(j0||(j0={}));const xy=[{id:bt.SeekHead,flag:"seekHeadSeen"},{id:bt.Info,flag:"infoSeen"},{id:bt.Tracks,flag:"tracksSeen"},{id:bt.Cues,flag:"cuesSeen"}],N7=10*2**20;class RD extends _d{constructor(e){super(e),this.readMetadataPromise=null,this.segments=[],this.currentSegment=null,this.currentTrack=null,this.currentCluster=null,this.currentBlock=null,this.currentBlockAdditional=null,this.currentCueTime=null,this.currentDecodingInstruction=null,this.currentTagTargetIsMovie=!0,this.currentSimpleTagName=null,this.currentAttachedFile=null,this.isWebM=!1,this.reader=e._reader}async computeDuration(){const e=await this.getTracks(),r=await Promise.all(e.map(n=>n.computeDuration()));return Math.max(0,...r)}async getTracks(){return await this.readMetadata(),this.segments.flatMap(e=>e.tracks.map(r=>r.inputTrack))}async getMimeType(){await this.readMetadata();const e=await this.getTracks(),r=await Promise.all(e.map(n=>n.getCodecParameterString()));return LD({isWebM:this.isWebM,hasVideo:this.segments.some(n=>n.tracks.some(i=>i.info?.type==="video")),hasAudio:this.segments.some(n=>n.tracks.some(i=>i.info?.type==="audio")),codecStrings:r.filter(Boolean)})}async getMetadataTags(){await this.readMetadata();for(const r of this.segments)r.metadataTagsCollected||(this.reader.fileSize!==null&&await this.loadSegmentMetadata(r),r.metadataTagsCollected=!0);let e={};for(const r of this.segments)e={...e,...r.metadataTags};return e}readMetadata(){return this.readMetadataPromise??=(async()=>{let e=0;for(;;){let r=this.reader.requestSliceRange(e,_u,Xc);if(r instanceof Promise&&(r=await r),!r)break;const n=Hc(r);if(!n)break;const i=n.id;let a=n.size;const o=r.filePos;if(i===bt.EBML){Xf(a);let s=this.reader.requestSlice(o,a);if(s instanceof Promise&&(s=await s),!s)break;this.readContiguousElements(s)}else if(i===bt.Segment){if(await this.readSegment(o,a),a===null||this.reader.fileSize===null)break}else if(i===bt.Cluster){if(this.reader.fileSize===null)break;a===null&&(a=(await B5(this.reader,o,Dg,this.reader.fileSize)).pos-o);const s=El(this.segments);s&&(s.elementEndPos=o+a)}Xf(a),e=o+a}})()}async readSegment(e,r){this.currentSegment={seekHeadSeen:!1,infoSeen:!1,tracksSeen:!1,cuesSeen:!1,tagsSeen:!1,attachmentsSeen:!1,timestampScale:-1,timestampFactor:-1,duration:-1,seekEntries:[],tracks:[],cuePoints:[],dataStartPos:e,elementEndPos:r===null?null:e+r,clusterSeekStartPos:e,lastReadCluster:null,metadataTags:{},metadataTagsCollected:!1},this.segments.push(this.currentSegment);let n=e;for(;this.currentSegment.elementEndPos===null||n<this.currentSegment.elementEndPos;){let s=this.reader.requestSliceRange(n,_u,Xc);if(s instanceof Promise&&(s=await s),!s)break;const l=n,c=Hc(s);if(!c||!i1.includes(c.id)&&c.id!==bt.Void){const y=await O7(this.reader,l,i1,Math.min(this.currentSegment.elementEndPos??1/0,l+N7));if(y){n=y;continue}else break}const{id:f,size:h}=c,d=s.filePos,p=xy.findIndex(y=>y.id===f);if(p!==-1){const y=xy[p].flag;this.currentSegment[y]=!0,Xf(h);let w=this.reader.requestSlice(d,h);w instanceof Promise&&(w=await w),w&&this.readContiguousElements(w)}else if(f===bt.Tags||f===bt.Attachments){f===bt.Tags?this.currentSegment.tagsSeen=!0:this.currentSegment.attachmentsSeen=!0,Xf(h);let y=this.reader.requestSlice(d,h);y instanceof Promise&&(y=await y),y&&this.readContiguousElements(y)}else if(f===bt.Cluster){this.currentSegment.clusterSeekStartPos=l;break}if(h===null)break;n=d+h}if(this.currentSegment.seekEntries.sort((s,l)=>s.segmentPosition-l.segmentPosition),this.reader.fileSize!==null)for(const s of this.currentSegment.seekEntries){const l=xy.find(y=>y.id===s.id);if(!l||this.currentSegment[l.flag])continue;let c=this.reader.requestSliceRange(e+s.segmentPosition,_u,Xc);if(c instanceof Promise&&(c=await c),!c)continue;const f=Hc(c);if(!f)continue;const{id:h,size:d}=f;if(h!==l.id)continue;Xf(d),this.currentSegment[l.flag]=!0;let p=this.reader.requestSlice(c.filePos,d);p instanceof Promise&&(p=await p),p&&this.readContiguousElements(p)}this.currentSegment.timestampScale===-1&&(this.currentSegment.timestampScale=1e6,this.currentSegment.timestampFactor=1e9/1e6),this.currentSegment.tracks.sort((s,l)=>Number(l.disposition.default)-Number(s.disposition.default));const i=new Map(this.currentSegment.tracks.map(s=>[s.id,s]));for(const s of this.currentSegment.cuePoints){const l=i.get(s.trackId);l&&l.cuePoints.push(s)}for(const s of this.currentSegment.tracks){s.cuePoints.sort((l,c)=>l.time-c.time);for(let l=0;l<s.cuePoints.length-1;l++){const c=s.cuePoints[l],f=s.cuePoints[l+1];c.time===f.time&&(s.cuePoints.splice(l+1,1),l--)}}let a=null,o=-1/0;for(const s of this.currentSegment.tracks)s.cuePoints.length>o&&(o=s.cuePoints.length,a=s);for(const s of this.currentSegment.tracks)s.cuePoints.length===0&&(s.cuePoints=a.cuePoints);this.currentSegment=null}async readCluster(e,r){if(r.lastReadCluster?.elementStartPos===e)return r.lastReadCluster;let n=this.reader.requestSliceRange(e,_u,Xc);n instanceof Promise&&(n=await n),$e(n);const i=e,a=Hc(n);$e(a);const o=a.id;$e(o===bt.Cluster);let s=a.size;const l=n.filePos;s===null&&(s=(await B5(this.reader,l,Dg,r.elementEndPos)).pos-l);let c=this.reader.requestSlice(l,s);c instanceof Promise&&(c=await c);const f={segment:r,elementStartPos:i,elementEndPos:l+s,dataStartPos:l,timestamp:-1,trackData:new Map};if(this.currentCluster=f,c){const h=this.readContiguousElements(c,Dg);f.elementEndPos=h}for(const[,h]of f.trackData){const d=h.track;$e(h.blocks.length>0);let p=!1;for(let b=0;b<h.blocks.length;b++){const S=h.blocks[b];S.timestamp+=f.timestamp,p||=S.lacing!==zc.None}h.presentationTimestamps=h.blocks.map((b,S)=>({timestamp:b.timestamp,blockIndex:S})).sort((b,S)=>b.timestamp-S.timestamp);for(let b=0;b<h.presentationTimestamps.length;b++){const S=h.presentationTimestamps[b],E=h.blocks[S.blockIndex];if(h.firstKeyFrameTimestamp===null&&E.isKeyFrame&&(h.firstKeyFrameTimestamp=E.timestamp),b<h.presentationTimestamps.length-1){const _=h.presentationTimestamps[b+1];E.duration=_.timestamp-E.timestamp}else E.duration===0&&d.defaultDuration!=null&&E.lacing===zc.None&&(E.duration=d.defaultDuration)}p&&(this.expandLacedBlocks(h.blocks,d),h.presentationTimestamps=h.blocks.map((b,S)=>({timestamp:b.timestamp,blockIndex:S})).sort((b,S)=>b.timestamp-S.timestamp));const y=h.blocks[h.presentationTimestamps[0].blockIndex],w=h.blocks[El(h.presentationTimestamps).blockIndex];h.startTimestamp=y.timestamp,h.endTimestamp=w.timestamp+w.duration;const x=oi(d.clusterPositionCache,h.startTimestamp,b=>b.startTimestamp);(x===-1||d.clusterPositionCache[x].elementStartPos!==i)&&d.clusterPositionCache.splice(x+1,0,{elementStartPos:f.elementStartPos,startTimestamp:h.startTimestamp})}return r.lastReadCluster=f,f}getTrackDataInCluster(e,r){let n=e.trackData.get(r);if(!n){const i=e.segment.tracks.find(a=>a.id===r);if(!i)return null;n={track:i,startTimestamp:0,endTimestamp:0,firstKeyFrameTimestamp:null,blocks:[],presentationTimestamps:[]},e.trackData.set(r,n)}return n}expandLacedBlocks(e,r){for(let n=0;n<e.length;n++){const i=e[n];if(i.lacing===zc.None)continue;i.decoded||(i.data=this.decodeBlockData(r,i.data),i.decoded=!0);const a=Rp.tempFromBytes(i.data),o=[],s=dr(a)+1;switch(i.lacing){case zc.Xiph:{let c=0;for(let f=0;f<s-1;f++){let h=0;for(;a.bufferPos<a.length;){const d=dr(a);if(h+=d,d<255){o.push(h),c+=h;break}}}o.push(a.length-(a.bufferPos+c))}break;case zc.FixedSize:{const c=a.length-1,f=Math.floor(c/s);for(let h=0;h<s;h++)o.push(f)}break;case zc.Ebml:{const c=E0(a);$e(c!==null);let f=c;o.push(f);let h=f;for(let d=1;d<s-1;d++){const p=a.bufferPos,y=E0(a);$e(y!==null);const w=y,b=(1<<(a.bufferPos-p)*7-1)-1,S=w-b;f+=S,o.push(f),h+=f}o.push(a.length-(a.bufferPos+h))}break;default:$e(!1)}$e(o.length===s),e.splice(n,1);const l=i.duration||s*(r.defaultDuration??0);for(let c=0;c<s;c++){const f=o[c],h=Nr(a,f),d=i.timestamp+l*c/s,p=l/s;e.splice(n+c,0,{timestamp:d,duration:p,isKeyFrame:i.isKeyFrame,data:h,lacing:zc.None,decoded:!0,mainAdditional:i.mainAdditional})}n+=s,n--}}async loadSegmentMetadata(e){for(const r of e.seekEntries){if(!(r.id===bt.Tags&&!e.tagsSeen)){if(!(r.id===bt.Attachments&&!e.attachmentsSeen))continue}let n=this.reader.requestSliceRange(e.dataStartPos+r.segmentPosition,_u,Xc);if(n instanceof Promise&&(n=await n),!n)continue;const i=Hc(n);if(!i||i.id!==r.id)continue;const{size:a}=i;Xf(a),$e(!this.currentSegment),this.currentSegment=e;let o=this.reader.requestSlice(n.filePos,a);o instanceof Promise&&(o=await o),o&&this.readContiguousElements(o),this.currentSegment=null,r.id===bt.Tags?e.tagsSeen=!0:r.id===bt.Attachments&&(e.attachmentsSeen=!0)}}readContiguousElements(e,r){const n=e.filePos;for(;e.filePos-n<=e.length-_u;){const i=e.filePos;if(!this.traverseElement(e,r))return i}return e.filePos}traverseElement(e,r){const n=Hc(e);if(!n||r&&r.includes(n.id))return!1;const{id:i,size:a}=n,o=e.filePos;switch(Xf(a),i){case bt.DocType:this.isWebM=rp(e,a)==="webm";break;case bt.Seek:{if(!this.currentSegment)break;const s={id:-1,segmentPosition:-1};this.currentSegment.seekEntries.push(s),this.readContiguousElements(e.slice(o,a)),(s.id===-1||s.segmentPosition===-1)&&this.currentSegment.seekEntries.pop()}break;case bt.SeekID:{const s=this.currentSegment?.seekEntries[this.currentSegment.seekEntries.length-1];if(!s)break;s.id=Jr(e,a)}break;case bt.SeekPosition:{const s=this.currentSegment?.seekEntries[this.currentSegment.seekEntries.length-1];if(!s)break;s.segmentPosition=Jr(e,a)}break;case bt.TimestampScale:{if(!this.currentSegment)break;this.currentSegment.timestampScale=Jr(e,a),this.currentSegment.timestampFactor=1e9/this.currentSegment.timestampScale}break;case bt.Duration:{if(!this.currentSegment)break;this.currentSegment.duration=wy(e,a)}break;case bt.TrackEntry:{if(!this.currentSegment)break;if(this.currentTrack={id:-1,segment:this.currentSegment,demuxer:this,clusterPositionCache:[],cuePoints:[],disposition:{...Sd},inputTrack:null,codecId:null,codecPrivate:null,defaultDuration:null,name:null,languageCode:ku,decodingInstructions:[],info:null},this.readContiguousElements(e.slice(o,a)),this.currentTrack.decodingInstructions.some(s=>s.data?.type!=="decompress"||s.scope!==dm.Block||s.data.algorithm!==j0.HeaderStripping)&&(console.warn(`Track #${this.currentTrack.id} has an unsupported content encoding; dropping.`),this.currentTrack=null),this.currentTrack&&this.currentTrack.id!==-1&&this.currentTrack.codecId&&this.currentTrack.info){const s=this.currentTrack.codecId.indexOf("/"),l=s===-1?this.currentTrack.codecId:this.currentTrack.codecId.slice(0,s);if(this.currentTrack.info.type==="video"&&this.currentTrack.info.width!==-1&&this.currentTrack.info.height!==-1){this.currentTrack.codecId===ac.avc?(this.currentTrack.info.codec="avc",this.currentTrack.info.codecDescription=this.currentTrack.codecPrivate):this.currentTrack.codecId===ac.hevc?(this.currentTrack.info.codec="hevc",this.currentTrack.info.codecDescription=this.currentTrack.codecPrivate):l===ac.vp8?this.currentTrack.info.codec="vp8":l===ac.vp9?this.currentTrack.info.codec="vp9":l===ac.av1&&(this.currentTrack.info.codec="av1");const c=this.currentTrack,f=new b1(this.input,new MD(c));this.currentTrack.inputTrack=f,this.currentSegment.tracks.push(this.currentTrack)}else if(this.currentTrack.info.type==="audio"&&this.currentTrack.info.numberOfChannels!==-1&&this.currentTrack.info.sampleRate!==-1){l===ac.aac?(this.currentTrack.info.codec="aac",this.currentTrack.info.aacCodecInfo={isMpeg2:this.currentTrack.codecId.includes("MPEG2")},this.currentTrack.info.codecDescription=this.currentTrack.codecPrivate):this.currentTrack.codecId===ac.mp3?this.currentTrack.info.codec="mp3":l===ac.opus?(this.currentTrack.info.codec="opus",this.currentTrack.info.codecDescription=this.currentTrack.codecPrivate,this.currentTrack.info.sampleRate=Ym):l===ac.vorbis?(this.currentTrack.info.codec="vorbis",this.currentTrack.info.codecDescription=this.currentTrack.codecPrivate):l===ac.flac?(this.currentTrack.info.codec="flac",this.currentTrack.info.codecDescription=this.currentTrack.codecPrivate):this.currentTrack.codecId==="A_PCM/INT/LIT"?this.currentTrack.info.bitDepth===8?this.currentTrack.info.codec="pcm-u8":this.currentTrack.info.bitDepth===16?this.currentTrack.info.codec="pcm-s16":this.currentTrack.info.bitDepth===24?this.currentTrack.info.codec="pcm-s24":this.currentTrack.info.bitDepth===32&&(this.currentTrack.info.codec="pcm-s32"):this.currentTrack.codecId==="A_PCM/INT/BIG"?this.currentTrack.info.bitDepth===8?this.currentTrack.info.codec="pcm-u8":this.currentTrack.info.bitDepth===16?this.currentTrack.info.codec="pcm-s16be":this.currentTrack.info.bitDepth===24?this.currentTrack.info.codec="pcm-s24be":this.currentTrack.info.bitDepth===32&&(this.currentTrack.info.codec="pcm-s32be"):this.currentTrack.codecId==="A_PCM/FLOAT/IEEE"&&(this.currentTrack.info.bitDepth===32?this.currentTrack.info.codec="pcm-f32":this.currentTrack.info.bitDepth===64&&(this.currentTrack.info.codec="pcm-f64"));const c=this.currentTrack,f=new xc(this.input,new DD(c));this.currentTrack.inputTrack=f,this.currentSegment.tracks.push(this.currentTrack)}}this.currentTrack=null}break;case bt.TrackNumber:{if(!this.currentTrack)break;this.currentTrack.id=Jr(e,a)}break;case bt.TrackType:{if(!this.currentTrack)break;const s=Jr(e,a);s===1?this.currentTrack.info={type:"video",width:-1,height:-1,rotation:0,codec:null,codecDescription:null,colorSpace:null,alphaMode:!1}:s===2&&(this.currentTrack.info={type:"audio",numberOfChannels:-1,sampleRate:-1,bitDepth:-1,codec:null,codecDescription:null,aacCodecInfo:null})}break;case bt.FlagEnabled:{if(!this.currentTrack)break;Jr(e,a)||(this.currentSegment.tracks.pop(),this.currentTrack=null)}break;case bt.FlagDefault:{if(!this.currentTrack)break;this.currentTrack.disposition.default=!!Jr(e,a)}break;case bt.FlagForced:{if(!this.currentTrack)break;this.currentTrack.disposition.forced=!!Jr(e,a)}break;case bt.FlagOriginal:{if(!this.currentTrack)break;this.currentTrack.disposition.original=!!Jr(e,a)}break;case bt.FlagHearingImpaired:{if(!this.currentTrack)break;this.currentTrack.disposition.hearingImpaired=!!Jr(e,a)}break;case bt.FlagVisualImpaired:{if(!this.currentTrack)break;this.currentTrack.disposition.visuallyImpaired=!!Jr(e,a)}break;case bt.FlagCommentary:{if(!this.currentTrack)break;this.currentTrack.disposition.commentary=!!Jr(e,a)}break;case bt.CodecID:{if(!this.currentTrack)break;this.currentTrack.codecId=rp(e,a)}break;case bt.CodecPrivate:{if(!this.currentTrack)break;this.currentTrack.codecPrivate=Nr(e,a)}break;case bt.DefaultDuration:{if(!this.currentTrack)break;this.currentTrack.defaultDuration=this.currentTrack.segment.timestampFactor*Jr(e,a)/1e9}break;case bt.Name:{if(!this.currentTrack)break;this.currentTrack.name=c0(e,a)}break;case bt.Language:{if(!this.currentTrack||this.currentTrack.languageCode!==ku)break;this.currentTrack.languageCode=rp(e,a),n7(this.currentTrack.languageCode)||(this.currentTrack.languageCode=ku)}break;case bt.LanguageBCP47:{if(!this.currentTrack)break;const l=rp(e,a).split("-")[0];l?this.currentTrack.languageCode=l:this.currentTrack.languageCode=ku}break;case bt.Video:{if(this.currentTrack?.info?.type!=="video")break;this.readContiguousElements(e.slice(o,a))}break;case bt.PixelWidth:{if(this.currentTrack?.info?.type!=="video")break;this.currentTrack.info.width=Jr(e,a)}break;case bt.PixelHeight:{if(this.currentTrack?.info?.type!=="video")break;this.currentTrack.info.height=Jr(e,a)}break;case bt.AlphaMode:{if(this.currentTrack?.info?.type!=="video")break;this.currentTrack.info.alphaMode=Jr(e,a)===1}break;case bt.Colour:{if(this.currentTrack?.info?.type!=="video")break;this.currentTrack.info.colorSpace={},this.readContiguousElements(e.slice(o,a))}break;case bt.MatrixCoefficients:{if(this.currentTrack?.info?.type!=="video"||!this.currentTrack.info.colorSpace)break;const s=Jr(e,a),l=e7[s]??null;this.currentTrack.info.colorSpace.matrix=l}break;case bt.Range:{if(this.currentTrack?.info?.type!=="video"||!this.currentTrack.info.colorSpace)break;this.currentTrack.info.colorSpace.fullRange=Jr(e,a)===2}break;case bt.TransferCharacteristics:{if(this.currentTrack?.info?.type!=="video"||!this.currentTrack.info.colorSpace)break;const s=Jr(e,a),l=Jk[s]??null;this.currentTrack.info.colorSpace.transfer=l}break;case bt.Primaries:{if(this.currentTrack?.info?.type!=="video"||!this.currentTrack.info.colorSpace)break;const s=Jr(e,a),l=Qk[s]??null;this.currentTrack.info.colorSpace.primaries=l}break;case bt.Projection:{if(this.currentTrack?.info?.type!=="video")break;this.readContiguousElements(e.slice(o,a))}break;case bt.ProjectionPoseRoll:{if(this.currentTrack?.info?.type!=="video")break;const l=-wy(e,a);try{this.currentTrack.info.rotation=Zk(l)}catch{}}break;case bt.Audio:{if(this.currentTrack?.info?.type!=="audio")break;this.readContiguousElements(e.slice(o,a))}break;case bt.SamplingFrequency:{if(this.currentTrack?.info?.type!=="audio")break;this.currentTrack.info.sampleRate=wy(e,a)}break;case bt.Channels:{if(this.currentTrack?.info?.type!=="audio")break;this.currentTrack.info.numberOfChannels=Jr(e,a)}break;case bt.BitDepth:{if(this.currentTrack?.info?.type!=="audio")break;this.currentTrack.info.bitDepth=Jr(e,a)}break;case bt.CuePoint:{if(!this.currentSegment)break;this.readContiguousElements(e.slice(o,a)),this.currentCueTime=null}break;case bt.CueTime:this.currentCueTime=Jr(e,a);break;case bt.CueTrackPositions:{if(this.currentCueTime===null)break;$e(this.currentSegment);const s={time:this.currentCueTime,trackId:-1,clusterPosition:-1};this.currentSegment.cuePoints.push(s),this.readContiguousElements(e.slice(o,a)),(s.trackId===-1||s.clusterPosition===-1)&&this.currentSegment.cuePoints.pop()}break;case bt.CueTrack:{const s=this.currentSegment?.cuePoints[this.currentSegment.cuePoints.length-1];if(!s)break;s.trackId=Jr(e,a)}break;case bt.CueClusterPosition:{const s=this.currentSegment?.cuePoints[this.currentSegment.cuePoints.length-1];if(!s)break;$e(this.currentSegment),s.clusterPosition=this.currentSegment.dataStartPos+Jr(e,a)}break;case bt.Timestamp:{if(!this.currentCluster)break;this.currentCluster.timestamp=Jr(e,a)}break;case bt.SimpleBlock:{if(!this.currentCluster)break;const s=E0(e);if(s===null)break;const l=this.getTrackDataInCluster(this.currentCluster,s);if(!l)break;const c=H5(e),f=dr(e),h=f>>1&3;let d=!!(f&128);l.track.info?.type==="audio"&&l.track.info.codec&&(d=!0);const p=Nr(e,a-(e.filePos-o)),y=l.track.decodingInstructions.length>0;l.blocks.push({timestamp:c,duration:0,isKeyFrame:d,data:p,lacing:h,decoded:!y,mainAdditional:null})}break;case bt.BlockGroup:{if(!this.currentCluster)break;this.readContiguousElements(e.slice(o,a)),this.currentBlock=null}break;case bt.Block:{if(!this.currentCluster)break;const s=E0(e);if(s===null)break;const l=this.getTrackDataInCluster(this.currentCluster,s);if(!l)break;const c=H5(e),h=dr(e)>>1&3,d=Nr(e,a-(e.filePos-o)),p=l.track.decodingInstructions.length>0;this.currentBlock={timestamp:c,duration:0,isKeyFrame:!0,data:d,lacing:h,decoded:!p,mainAdditional:null},l.blocks.push(this.currentBlock)}break;case bt.BlockAdditions:this.readContiguousElements(e.slice(o,a));break;case bt.BlockMore:{if(!this.currentBlock)break;this.currentBlockAdditional={addId:1,data:null},this.readContiguousElements(e.slice(o,a)),this.currentBlockAdditional.data&&this.currentBlockAdditional.addId===1&&(this.currentBlock.mainAdditional=this.currentBlockAdditional.data),this.currentBlockAdditional=null}break;case bt.BlockAdditional:{if(!this.currentBlockAdditional)break;this.currentBlockAdditional.data=Nr(e,a)}break;case bt.BlockAddID:{if(!this.currentBlockAdditional)break;this.currentBlockAdditional.addId=Jr(e,a)}break;case bt.BlockDuration:{if(!this.currentBlock)break;this.currentBlock.duration=Jr(e,a)}break;case bt.ReferenceBlock:{if(!this.currentBlock)break;this.currentBlock.isKeyFrame=!1}break;case bt.Tag:this.currentTagTargetIsMovie=!0,this.readContiguousElements(e.slice(o,a));break;case bt.Targets:this.readContiguousElements(e.slice(o,a));break;case bt.TargetTypeValue:Jr(e,a)!==50&&(this.currentTagTargetIsMovie=!1);break;case bt.TagTrackUID:case bt.TagEditionUID:case bt.TagChapterUID:case bt.TagAttachmentUID:this.currentTagTargetIsMovie=!1;break;case bt.SimpleTag:{if(!this.currentTagTargetIsMovie)break;this.currentSimpleTagName=null,this.readContiguousElements(e.slice(o,a))}break;case bt.TagName:this.currentSimpleTagName=c0(e,a);break;case bt.TagString:{if(!this.currentSimpleTagName)break;const s=c0(e,a);this.processTagValue(this.currentSimpleTagName,s)}break;case bt.TagBinary:{if(!this.currentSimpleTagName)break;const s=Nr(e,a);this.processTagValue(this.currentSimpleTagName,s)}break;case bt.AttachedFile:{if(!this.currentSegment)break;this.currentAttachedFile={fileUid:null,fileName:null,fileMediaType:null,fileData:null,fileDescription:null},this.readContiguousElements(e.slice(o,a));const s=this.currentSegment.metadataTags;if(this.currentAttachedFile.fileUid&&this.currentAttachedFile.fileData&&(s.raw??={},s.raw[this.currentAttachedFile.fileUid.toString()]=new l7(this.currentAttachedFile.fileData,this.currentAttachedFile.fileMediaType??void 0,this.currentAttachedFile.fileName??void 0,this.currentAttachedFile.fileDescription??void 0)),this.currentAttachedFile.fileMediaType?.startsWith("image/")&&this.currentAttachedFile.fileData){const l=this.currentAttachedFile.fileName;let c="unknown";if(l){const f=l.toLowerCase();f.startsWith("cover.")?c="coverFront":f.startsWith("back.")&&(c="coverBack")}s.images??=[],s.images.push({data:this.currentAttachedFile.fileData,mimeType:this.currentAttachedFile.fileMediaType,kind:c,name:this.currentAttachedFile.fileName??void 0,description:this.currentAttachedFile.fileDescription??void 0})}this.currentAttachedFile=null}break;case bt.FileUID:{if(!this.currentAttachedFile)break;this.currentAttachedFile.fileUid=ID(e,a)}break;case bt.FileName:{if(!this.currentAttachedFile)break;this.currentAttachedFile.fileName=c0(e,a)}break;case bt.FileMediaType:{if(!this.currentAttachedFile)break;this.currentAttachedFile.fileMediaType=rp(e,a)}break;case bt.FileData:{if(!this.currentAttachedFile)break;this.currentAttachedFile.fileData=Nr(e,a)}break;case bt.FileDescription:{if(!this.currentAttachedFile)break;this.currentAttachedFile.fileDescription=c0(e,a)}break;case bt.ContentEncodings:{if(!this.currentTrack)break;this.readContiguousElements(e.slice(o,a)),this.currentTrack.decodingInstructions.sort((s,l)=>l.order-s.order)}break;case bt.ContentEncoding:this.currentDecodingInstruction={order:0,scope:dm.Block,data:null},this.readContiguousElements(e.slice(o,a)),this.currentDecodingInstruction.data&&this.currentTrack.decodingInstructions.push(this.currentDecodingInstruction),this.currentDecodingInstruction=null;break;case bt.ContentEncodingOrder:{if(!this.currentDecodingInstruction)break;this.currentDecodingInstruction.order=Jr(e,a)}break;case bt.ContentEncodingScope:{if(!this.currentDecodingInstruction)break;this.currentDecodingInstruction.scope=Jr(e,a)}break;case bt.ContentCompression:{if(!this.currentDecodingInstruction)break;this.currentDecodingInstruction.data={type:"decompress",algorithm:j0.Zlib,settings:null},this.readContiguousElements(e.slice(o,a))}break;case bt.ContentCompAlgo:{if(this.currentDecodingInstruction?.data?.type!=="decompress")break;this.currentDecodingInstruction.data.algorithm=Jr(e,a)}break;case bt.ContentCompSettings:{if(this.currentDecodingInstruction?.data?.type!=="decompress")break;this.currentDecodingInstruction.data.settings=Nr(e,a)}break;case bt.ContentEncryption:{if(!this.currentDecodingInstruction)break;this.currentDecodingInstruction.data={type:"decrypt"}}break}return e.filePos=o+a,!0}decodeBlockData(e,r){$e(e.decodingInstructions.length>0);let n=r;for(const i of e.decodingInstructions)switch($e(i.data),i.data.type){case"decompress":switch(i.data.algorithm){case j0.HeaderStripping:if(i.data.settings&&i.data.settings.length>0){const a=i.data.settings,o=new Uint8Array(a.length+n.length);o.set(a,0),o.set(n,a.length),n=o}break}break}return n}processTagValue(e,r){if(!this.currentSegment?.metadataTags)return;const n=this.currentSegment.metadataTags;if(n.raw??={},n.raw[e]??=r,typeof r=="string")switch(e.toLowerCase()){case"title":n.title??=r;break;case"description":n.description??=r;break;case"artist":n.artist??=r;break;case"album":n.album??=r;break;case"album_artist":n.albumArtist??=r;break;case"genre":n.genre??=r;break;case"comment":n.comment??=r;break;case"lyrics":n.lyrics??=r;break;case"date":{const i=new Date(r);Number.isNaN(i.getTime())||(n.date??=i)}break;case"track_number":case"part_number":{const i=r.split("/"),a=Number.parseInt(i[0],10),o=i[1]&&Number.parseInt(i[1],10);Number.isInteger(a)&&a>0&&(n.trackNumber??=a),o&&Number.isInteger(o)&&o>0&&(n.tracksTotal??=o)}break;case"disc_number":case"disc":{const i=r.split("/"),a=Number.parseInt(i[0],10),o=i[1]&&Number.parseInt(i[1],10);Number.isInteger(a)&&a>0&&(n.discNumber??=a),o&&Number.isInteger(o)&&o>0&&(n.discsTotal??=o)}break}}}class I7{constructor(e){this.internalTrack=e,this.packetToClusterLocation=new WeakMap}getId(){return this.internalTrack.id}getCodec(){throw new Error("Not implemented on base class.")}getInternalCodecId(){return this.internalTrack.codecId}async computeDuration(){const e=await this.getPacket(1/0,{metadataOnly:!0});return(e?.timestamp??0)+(e?.duration??0)}getName(){return this.internalTrack.name}getLanguageCode(){return this.internalTrack.languageCode}async getFirstTimestamp(){return(await this.getFirstPacket({metadataOnly:!0}))?.timestamp??0}getTimeResolution(){return this.internalTrack.segment.timestampFactor}getDisposition(){return this.internalTrack.disposition}async getFirstPacket(e){return this.performClusterLookup(null,r=>r.trackData.get(this.internalTrack.id)?{blockIndex:0,correctBlockFound:!0}:{blockIndex:-1,correctBlockFound:!1},-1/0,1/0,e)}intoTimescale(e){return fm(e*this.internalTrack.segment.timestampFactor)}async getPacket(e,r){const n=this.intoTimescale(e);return this.performClusterLookup(null,i=>{const a=i.trackData.get(this.internalTrack.id);if(!a)return{blockIndex:-1,correctBlockFound:!1};const o=oi(a.presentationTimestamps,n,c=>c.timestamp),s=o!==-1?a.presentationTimestamps[o].blockIndex:-1,l=o!==-1&&n<a.endTimestamp;return{blockIndex:s,correctBlockFound:l}},n,n,r)}async getNextPacket(e,r){const n=this.packetToClusterLocation.get(e);if(n===void 0)throw new Error("Packet was not created from this track.");return this.performClusterLookup(n.cluster,i=>{if(i===n.cluster){const a=i.trackData.get(this.internalTrack.id);if(n.blockIndex+1<a.blocks.length)return{blockIndex:n.blockIndex+1,correctBlockFound:!0}}else if(i.trackData.get(this.internalTrack.id))return{blockIndex:0,correctBlockFound:!0};return{blockIndex:-1,correctBlockFound:!1}},-1/0,1/0,r)}async getKeyPacket(e,r){const n=this.intoTimescale(e);return this.performClusterLookup(null,i=>{const a=i.trackData.get(this.internalTrack.id);if(!a)return{blockIndex:-1,correctBlockFound:!1};const o=r7(a.presentationTimestamps,c=>a.blocks[c.blockIndex].isKeyFrame&&c.timestamp<=n),s=o!==-1?a.presentationTimestamps[o].blockIndex:-1,l=o!==-1&&n<a.endTimestamp;return{blockIndex:s,correctBlockFound:l}},n,n,r)}async getNextKeyPacket(e,r){const n=this.packetToClusterLocation.get(e);if(n===void 0)throw new Error("Packet was not created from this track.");return this.performClusterLookup(n.cluster,i=>{if(i===n.cluster){const o=i.trackData.get(this.internalTrack.id).blocks.findIndex((s,l)=>s.isKeyFrame&&l>n.blockIndex);if(o!==-1)return{blockIndex:o,correctBlockFound:!0}}else{const a=i.trackData.get(this.internalTrack.id);if(a&&a.firstKeyFrameTimestamp!==null){const o=a.blocks.findIndex(s=>s.isKeyFrame);return $e(o!==-1),{blockIndex:o,correctBlockFound:!0}}}return{blockIndex:-1,correctBlockFound:!1}},-1/0,1/0,r)}async fetchPacketInCluster(e,r,n){if(r===-1)return null;const a=e.trackData.get(this.internalTrack.id).blocks[r];$e(a),a.decoded||(a.data=this.internalTrack.demuxer.decodeBlockData(this.internalTrack,a.data),a.decoded=!0);const o=n.metadataOnly?Zl:a.data,s=a.timestamp/this.internalTrack.segment.timestampFactor,l=a.duration/this.internalTrack.segment.timestampFactor,c={};a.mainAdditional&&this.internalTrack.info?.type==="video"&&this.internalTrack.info.alphaMode&&(c.alpha=n.metadataOnly?Zl:a.mainAdditional,c.alphaByteLength=a.mainAdditional.byteLength);const f=new Bo(o,a.isKeyFrame?"key":"delta",s,l,e.dataStartPos+r,a.data.byteLength,c);return this.packetToClusterLocation.set(f,{cluster:e,blockIndex:r}),f}async performClusterLookup(e,r,n,i,a){const{demuxer:o,segment:s}=this.internalTrack;let l=null,c=null,f=-1;if(e){const{blockIndex:b,correctBlockFound:S}=r(e);if(S)return this.fetchPacketInCluster(e,b,a);b!==-1&&(c=e,f=b)}const h=oi(this.internalTrack.cuePoints,n,b=>b.time),d=h!==-1?this.internalTrack.cuePoints[h]:null,p=oi(this.internalTrack.clusterPositionCache,n,b=>b.startTimestamp),y=p!==-1?this.internalTrack.clusterPositionCache[p]:null,w=Math.max(d?.clusterPosition??0,y?.elementStartPos??0)||null;let x;for(e?w===null||e.elementStartPos>=w?(x=e.elementEndPos,l=e):x=w:x=w??s.clusterSeekStartPos;s.elementEndPos===null||x<=s.elementEndPos-_u;){if(l){const N=l.trackData.get(this.internalTrack.id);if(N&&N.startTimestamp>i)break}let b=o.reader.requestSliceRange(x,_u,Xc);if(b instanceof Promise&&(b=await b),!b)break;const S=x,E=Hc(b);if(!E||!i1.includes(E.id)&&E.id!==bt.Void){const N=await O7(o.reader,S,i1,Math.min(s.elementEndPos??1/0,S+N7));if(N){x=N;continue}else break}const _=E.id;let P=E.size;const O=b.filePos;if(_===bt.Cluster){l=await o.readCluster(S,s),P=l.elementEndPos-O;const{blockIndex:N,correctBlockFound:D}=r(l);if(D)return this.fetchPacketInCluster(l,N,a);N!==-1&&(c=l,f=N)}P===null&&($e(_!==bt.Cluster),P=(await B5(o.reader,O,Dg,s.elementEndPos)).pos-O);const T=O+P;if(s.elementEndPos===null){let N=o.reader.requestSliceRange(T,_u,Xc);if(N instanceof Promise&&(N=await N),!N)break;if(Gb(N)===bt.Segment){s.elementEndPos=T;break}}x=T}if(d&&(!c||c.elementStartPos<d.clusterPosition)){const b=this.internalTrack.cuePoints[h-1];$e(!b||b.time<d.time);const S=b?.time??-1/0;return this.performClusterLookup(null,r,S,i,a)}return c?this.fetchPacketInCluster(c,f,a):null}}class MD extends I7{constructor(e){super(e),this.decoderConfigPromise=null,this.internalTrack=e}getCodec(){return this.internalTrack.info.codec}getCodedWidth(){return this.internalTrack.info.width}getCodedHeight(){return this.internalTrack.info.height}getRotation(){return this.internalTrack.info.rotation}async getColorSpace(){return{primaries:this.internalTrack.info.colorSpace?.primaries,transfer:this.internalTrack.info.colorSpace?.transfer,matrix:this.internalTrack.info.colorSpace?.matrix,fullRange:this.internalTrack.info.colorSpace?.fullRange}}async canBeTransparent(){return this.internalTrack.info.alphaMode}async getDecoderConfig(){return this.internalTrack.info.codec?this.decoderConfigPromise??=(async()=>{let e=null;return(this.internalTrack.info.codec==="vp9"||this.internalTrack.info.codec==="av1"||this.internalTrack.info.codec==="avc"&&!this.internalTrack.info.codecDescription||this.internalTrack.info.codec==="hevc"&&!this.internalTrack.info.codecDescription)&&(e=await this.getFirstPacket({})),{codec:u7({width:this.internalTrack.info.width,height:this.internalTrack.info.height,codec:this.internalTrack.info.codec,codecDescription:this.internalTrack.info.codecDescription,colorSpace:this.internalTrack.info.colorSpace,avcType:1,avcCodecInfo:this.internalTrack.info.codec==="avc"&&e?YM(e.data):null,hevcCodecInfo:this.internalTrack.info.codec==="hevc"&&e?ZM(e.data):null,vp9CodecInfo:this.internalTrack.info.codec==="vp9"&&e?v7(e.data):null,av1CodecInfo:this.internalTrack.info.codec==="av1"&&e?b7(e.data):null}),codedWidth:this.internalTrack.info.width,codedHeight:this.internalTrack.info.height,description:this.internalTrack.info.codecDescription??void 0,colorSpace:this.internalTrack.info.colorSpace??void 0}})():null}}class DD extends I7{constructor(e){super(e),this.decoderConfig=null,this.internalTrack=e}getCodec(){return this.internalTrack.info.codec}getNumberOfChannels(){return this.internalTrack.info.numberOfChannels}getSampleRate(){return this.internalTrack.info.sampleRate}async getDecoderConfig(){return this.internalTrack.info.codec?this.decoderConfig??={codec:c7({codec:this.internalTrack.info.codec,codecDescription:this.internalTrack.info.codecDescription,aacCodecInfo:this.internalTrack.info.aacCodecInfo}),numberOfChannels:this.internalTrack.info.numberOfChannels,sampleRate:this.internalTrack.info.sampleRate,description:this.internalTrack.info.codecDescription??void 0}:null}}const L7=4,FD=[44100,48e3,32e3],BD=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1,-1,32,48,56,64,80,96,112,128,160,192,224,256,320,384,-1,-1,32,64,96,128,160,192,224,256,288,320,352,384,416,448,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,16,24,32,40,48,56,64,80,96,112,128,144,160,-1,-1,8,16,24,32,40,48,56,64,80,96,112,128,144,160,-1,-1,32,48,56,64,80,96,112,128,144,160,176,192,224,256,-1],jD=1483304551,zD=1231971951,UD=(t,e,r,n,i)=>e===0?0:e===1?Math.floor(144*r/(n<<t))+i:e===2?Math.floor(144*r/n)+i:(Math.floor(12*r/n)+i)*4,qD=(t,e)=>t===3?e===3?21:36:e===3?13:21,HD=(t,e)=>{const r=t>>>24,n=t>>>16&255,i=t>>>8&255,a=t&255;if(r!==255&&n!==255&&i!==255&&a!==255)return{header:null,bytesAdvanced:4};if(r!==255)return{header:null,bytesAdvanced:1};if((n&224)!==224)return{header:null,bytesAdvanced:1};let o=0,s=0;n&16?o=n&8?0:1:(o=1,s=1);const l=n>>3&3,c=n>>1&3,f=i>>4&15,h=(i>>2&3)%3,d=i>>1&1,p=a>>6&3,y=a>>4&3,w=a>>3&1,x=a>>2&1,b=a&3,S=BD[o*16*4+c*16+f];if(S===-1)return{header:null,bytesAdvanced:1};const E=S*1e3,_=FD[h]>>o+s,P=UD(o,c,E,_,d);if(e!==null&&e<P)return{header:null,bytesAdvanced:1};let O;return l===3?O=c===3?384:1152:c===3?O=384:c===2?O=1152:O=576,{header:{totalSize:P,mpegVersionId:l,layer:c,bitrate:E,frequencyIndex:h,sampleRate:_,channel:p,modeExtension:y,copyright:w,original:x,emphasis:b,audioSamplesInFrame:O},bytesAdvanced:1}},j5=t=>{let e=2130706432,r=0;for(;e!==0;)r>>=1,r|=t&e,e>>=8;return r};var fp;(function(t){t[t.Unsynchronisation=128]="Unsynchronisation",t[t.ExtendedHeader=64]="ExtendedHeader",t[t.ExperimentalIndicator=32]="ExperimentalIndicator",t[t.Footer=16]="Footer"})(fp||(fp={}));var hp;(function(t){t[t.ISO_8859_1=0]="ISO_8859_1",t[t.UTF_16_WITH_BOM=1]="UTF_16_WITH_BOM",t[t.UTF_16_BE_NO_BOM=2]="UTF_16_BE_NO_BOM",t[t.UTF_8=3]="UTF_8"})(hp||(hp={}));const Fg=128,pm=10,dp=["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"],VD=(t,e)=>{const r=t.filePos;e.raw??={},e.raw.TAG??=Nr(t,Fg-3),t.filePos=r;const n=Gd(t,30);n&&(e.title??=n);const i=Gd(t,30);i&&(e.artist??=i);const a=Gd(t,30);a&&(e.album??=a);const o=Gd(t,4),s=Number.parseInt(o,10);Number.isInteger(s)&&s>0&&(e.date??=new Date(s,0,1));const l=Nr(t,30);let c;if(l[28]===0&&l[29]!==0){const h=l[29];h>0&&(e.trackNumber??=h),t.skip(-30),c=Gd(t,28),t.skip(2)}else t.skip(-30),c=Gd(t,30);c&&(e.comment??=c);const f=dr(t);f<dp.length&&(e.genre??=dp[f])},Gd=(t,e)=>{const r=Nr(t,e),n=ep(r.indexOf(0),r.length),i=r.subarray(0,n);let a="";for(let o=0;o<i.length;o++)a+=String.fromCharCode(i[o]);return a.trimEnd()},gm=t=>{const e=t.filePos,r=Fo(t,3),n=dr(t),i=dr(t),a=dr(t),o=Dt(t);if(r!=="ID3"||n===255||i===255||(o&2155905152)!==0)return t.filePos=e,null;const s=j5(o);return{majorVersion:n,revision:i,flags:a,size:s}},R7=(t,e,r)=>{if(![2,3,4].includes(e.majorVersion)){console.warn(`Unsupported ID3v2 major version: ${e.majorVersion}`);return}const n=Nr(t,e.size),i=new $D(e,n);if(e.flags&fp.Footer&&i.removeFooter(),e.flags&fp.Unsynchronisation&&e.majorVersion===3&&i.ununsynchronizeAll(),e.flags&fp.ExtendedHeader){const a=i.readU32();e.majorVersion===3?i.pos+=a:i.pos+=a-4}for(;i.pos<=i.bytes.length-i.frameHeaderSize();){const a=i.readId3V2Frame();if(!a)break;const o=i.pos,s=i.pos+a.size;let l=!1,c=!1,f=!1;if(e.majorVersion===3?(l=!!(a.flags&64),c=!!(a.flags&128)):e.majorVersion===4&&(l=!!(a.flags&4),c=!!(a.flags&8),f=!!(a.flags&2)||!!(e.flags&fp.Unsynchronisation)),l){console.warn(`Skipping encrypted ID3v2 frame ${a.id}`),i.pos=s;continue}if(c){console.warn(`Skipping compressed ID3v2 frame ${a.id}`),i.pos=s;continue}switch(f&&i.ununsynchronizeRegion(i.pos,s),r.raw??={},a.id[0]==="T"?r.raw[a.id]??=i.readId3V2EncodingAndText(s):r.raw[a.id]??=i.readBytes(a.size),i.pos=o,a.id){case"TIT2":case"TT2":r.title??=i.readId3V2EncodingAndText(s);break;case"TIT3":case"TT3":r.description??=i.readId3V2EncodingAndText(s);break;case"TPE1":case"TP1":r.artist??=i.readId3V2EncodingAndText(s);break;case"TALB":case"TAL":r.album??=i.readId3V2EncodingAndText(s);break;case"TPE2":case"TP2":r.albumArtist??=i.readId3V2EncodingAndText(s);break;case"TRCK":case"TRK":{const d=i.readId3V2EncodingAndText(s).split("/"),p=Number.parseInt(d[0],10),y=d[1]&&Number.parseInt(d[1],10);Number.isInteger(p)&&p>0&&(r.trackNumber??=p),y&&Number.isInteger(y)&&y>0&&(r.tracksTotal??=y)}break;case"TPOS":case"TPA":{const d=i.readId3V2EncodingAndText(s).split("/"),p=Number.parseInt(d[0],10),y=d[1]&&Number.parseInt(d[1],10);Number.isInteger(p)&&p>0&&(r.discNumber??=p),y&&Number.isInteger(y)&&y>0&&(r.discsTotal??=y)}break;case"TCON":case"TCO":{const h=i.readId3V2EncodingAndText(s);let d=/^\((\d+)\)/.exec(h);if(d){const p=Number.parseInt(d[1]);if(dp[p]!==void 0){r.genre??=dp[p];break}}if(d=/^\d+$/.exec(h),d){const p=Number.parseInt(d[0]);if(dp[p]!==void 0){r.genre??=dp[p];break}}r.genre??=h}break;case"TDRC":case"TDAT":{const h=i.readId3V2EncodingAndText(s),d=new Date(h);Number.isNaN(d.getTime())||(r.date??=d)}break;case"TYER":case"TYE":{const h=i.readId3V2EncodingAndText(s),d=Number.parseInt(h,10);Number.isInteger(d)&&(r.date??=new Date(d,0,1))}break;case"USLT":case"ULT":{const h=i.readU8();i.pos+=3,i.readId3V2Text(h,s),r.lyrics??=i.readId3V2Text(h,s)}break;case"COMM":case"COM":{const h=i.readU8();i.pos+=3,i.readId3V2Text(h,s),r.comment??=i.readId3V2Text(h,s)}break;case"APIC":case"PIC":{const h=i.readId3V2TextEncoding();let d;if(e.majorVersion===2){const x=i.readAscii(3);d=x==="PNG"?"image/png":x==="JPG"?"image/jpeg":"image/*"}else d=i.readId3V2Text(h,s);const p=i.readU8(),y=i.readId3V2Text(h,s).trimEnd(),w=s-i.pos;if(w>=0){const x=i.readBytes(w);r.images||(r.images=[]),r.images.push({data:x,mimeType:d,kind:p===3?"coverFront":p===4?"coverBack":"unknown",description:y})}}break;default:i.pos+=a.size;break}i.pos=s}};class $D{constructor(e,r){this.header=e,this.bytes=r,this.pos=0,this.view=new DataView(r.buffer,r.byteOffset,r.byteLength)}frameHeaderSize(){return this.header.majorVersion===2?6:10}ununsynchronizeAll(){const e=[];for(let r=0;r<this.bytes.length;r++){const n=this.bytes[r];e.push(n),n===255&&r!==this.bytes.length-1&&this.bytes[r]===0&&r++}this.bytes=new Uint8Array(e),this.view=new DataView(this.bytes.buffer)}ununsynchronizeRegion(e,r){const n=[];for(let o=e;o<r;o++){const s=this.bytes[o];n.push(s),s===255&&o!==r-1&&this.bytes[o+1]===0&&o++}const i=this.bytes.subarray(0,e),a=this.bytes.subarray(r);this.bytes=new Uint8Array(i.length+n.length+a.length),this.bytes.set(i,0),this.bytes.set(n,i.length),this.bytes.set(a,i.length+n.length),this.view=new DataView(this.bytes.buffer)}removeFooter(){this.bytes=this.bytes.subarray(0,this.bytes.length-pm),this.view=new DataView(this.bytes.buffer)}readBytes(e){const r=this.bytes.subarray(this.pos,this.pos+e);return this.pos+=e,r}readU8(){const e=this.view.getUint8(this.pos);return this.pos+=1,e}readU16(){const e=this.view.getUint16(this.pos,!1);return this.pos+=2,e}readU24(){const e=this.view.getUint16(this.pos,!1),r=this.view.getUint8(this.pos+1);return this.pos+=3,e*256+r}readU32(){const e=this.view.getUint32(this.pos,!1);return this.pos+=4,e}readAscii(e){let r="";for(let n=0;n<e;n++)r+=String.fromCharCode(this.view.getUint8(this.pos+n));return this.pos+=e,r}readId3V2Frame(){if(this.header.majorVersion===2){const e=this.readAscii(3);if(e==="\0\0\0")return null;const r=this.readU24();return{id:e,size:r,flags:0}}else{const e=this.readAscii(4);if(e==="\0\0\0\0")return null;const r=this.readU32();let n=this.header.majorVersion===4?j5(r):r;const i=this.readU16(),a=this.pos,o=s=>{const l=this.pos+s;if(l>this.bytes.length)return!1;if(l<=this.bytes.length-this.frameHeaderSize()){this.pos+=s;const c=this.readAscii(4);if(c!=="\0\0\0\0"&&!/[0-9A-Z]{4}/.test(c))return!1}return!0};if(!o(n)){const s=this.header.majorVersion===4?r:j5(r);o(s)&&(n=s)}return this.pos=a,{id:e,size:n,flags:i}}}readId3V2TextEncoding(){const e=this.readU8();if(e>3)throw new Error(`Unsupported text encoding: ${e}`);return e}readId3V2Text(e,r){const n=this.pos,i=this.readBytes(r-this.pos);switch(e){case hp.ISO_8859_1:{let a="";for(let o=0;o<i.length;o++){const s=i[o];if(s===0){this.pos=n+o+1;break}a+=String.fromCharCode(s)}return a}case hp.UTF_16_WITH_BOM:if(i[0]===255&&i[1]===254){const a=new TextDecoder("utf-16le"),o=ep(i.findIndex((s,l)=>s===0&&i[l+1]===0&&l%2===0),i.length);return this.pos=n+Math.min(o+2,i.length),a.decode(i.subarray(2,o))}else if(i[0]===254&&i[1]===255){const a=new TextDecoder("utf-16be"),o=ep(i.findIndex((s,l)=>s===0&&i[l+1]===0&&l%2===0),i.length);return this.pos=n+Math.min(o+2,i.length),a.decode(i.subarray(2,o))}else{const a=ep(i.findIndex(o=>o===0),i.length);return this.pos=n+Math.min(a+1,i.length),Kl.decode(i.subarray(0,a))}case hp.UTF_16_BE_NO_BOM:{const a=new TextDecoder("utf-16be"),o=ep(i.findIndex((s,l)=>s===0&&i[l+1]===0&&l%2===0),i.length);return this.pos=n+Math.min(o+2,i.length),a.decode(i.subarray(0,o))}case hp.UTF_8:{const a=ep(i.findIndex(o=>o===0),i.length);return this.pos=n+Math.min(a+1,i.length),Kl.decode(i.subarray(0,a))}}}readId3V2EncodingAndText(e){if(this.pos>=e)return"";const r=this.readId3V2TextEncoding();return this.readId3V2Text(r,e)}}const z5=async(t,e,r)=>{let n=e;for(;r===null||n<r;){let i=t.requestSlice(n,L7);if(i instanceof Promise&&(i=await i),!i)break;const a=Dt(i),o=HD(a,t.fileSize!==null?t.fileSize-n:null);if(o.header)return{header:o.header,startPos:n};n+=o.bytesAdvanced}return null};class WD extends _d{constructor(e){super(e),this.metadataPromise=null,this.firstFrameHeader=null,this.loadedSamples=[],this.metadataTags=null,this.tracks=[],this.readingMutex=new Wm,this.lastSampleLoaded=!1,this.lastLoadedPos=0,this.nextTimestampInSamples=0,this.reader=e._reader}async readMetadata(){return this.metadataPromise??=(async()=>{for(;!this.firstFrameHeader&&!this.lastSampleLoaded;)await this.advanceReader();if(!this.firstFrameHeader)throw new Error("No valid MP3 frame found.");this.tracks=[new xc(this.input,new GD(this))]})()}async advanceReader(){if(this.lastLoadedPos===0)for(;;){let s=this.reader.requestSlice(this.lastLoadedPos,pm);if(s instanceof Promise&&(s=await s),!s){this.lastSampleLoaded=!0;return}const l=gm(s);if(!l)break;this.lastLoadedPos=s.filePos+l.size}const e=await z5(this.reader,this.lastLoadedPos,this.reader.fileSize);if(!e){this.lastSampleLoaded=!0;return}const r=e.header;this.lastLoadedPos=e.startPos+r.totalSize-1;const n=qD(r.mpegVersionId,r.channel);let i=this.reader.requestSlice(e.startPos+n,4);if(i instanceof Promise&&(i=await i),i){const s=Dt(i);if(s===jD||s===zD)return}this.firstFrameHeader||(this.firstFrameHeader=r),r.sampleRate!==this.firstFrameHeader.sampleRate&&console.warn(`MP3 changed sample rate mid-file: ${this.firstFrameHeader.sampleRate} Hz to ${r.sampleRate} Hz. Might be a bug, so please report this file.`);const a=r.audioSamplesInFrame/this.firstFrameHeader.sampleRate,o={timestamp:this.nextTimestampInSamples/this.firstFrameHeader.sampleRate,duration:a,dataStart:e.startPos,dataSize:r.totalSize};this.loadedSamples.push(o),this.nextTimestampInSamples+=r.audioSamplesInFrame}async getMimeType(){return"audio/mpeg"}async getTracks(){return await this.readMetadata(),this.tracks}async computeDuration(){await this.readMetadata();const e=this.tracks[0];return $e(e),e.computeDuration()}async getMetadataTags(){const e=await this.readingMutex.acquire();try{if(await this.readMetadata(),this.metadataTags)return this.metadataTags;this.metadataTags={};let r=0,n=!1;for(;;){let i=this.reader.requestSlice(r,pm);if(i instanceof Promise&&(i=await i),!i)break;const a=gm(i);if(!a)break;n=!0;let o=this.reader.requestSlice(i.filePos,a.size);if(o instanceof Promise&&(o=await o),!o)break;R7(o,a,this.metadataTags),r=i.filePos+a.size}if(!n&&this.reader.fileSize!==null&&this.reader.fileSize>=Fg){let i=this.reader.requestSlice(this.reader.fileSize-Fg,Fg);i instanceof Promise&&(i=await i),$e(i),Fo(i,3)==="TAG"&&VD(i,this.metadataTags)}return this.metadataTags}finally{e()}}}class GD{constructor(e){this.demuxer=e}getId(){return 1}async getFirstTimestamp(){return 0}getTimeResolution(){return $e(this.demuxer.firstFrameHeader),this.demuxer.firstFrameHeader.sampleRate/this.demuxer.firstFrameHeader.audioSamplesInFrame}async computeDuration(){const e=await this.getPacket(1/0,{metadataOnly:!0});return(e?.timestamp??0)+(e?.duration??0)}getName(){return null}getLanguageCode(){return ku}getCodec(){return"mp3"}getInternalCodecId(){return null}getNumberOfChannels(){return $e(this.demuxer.firstFrameHeader),this.demuxer.firstFrameHeader.channel===3?1:2}getSampleRate(){return $e(this.demuxer.firstFrameHeader),this.demuxer.firstFrameHeader.sampleRate}getDisposition(){return{...Sd}}async getDecoderConfig(){return $e(this.demuxer.firstFrameHeader),{codec:"mp3",numberOfChannels:this.demuxer.firstFrameHeader.channel===3?1:2,sampleRate:this.demuxer.firstFrameHeader.sampleRate}}async getPacketAtIndex(e,r){if(e===-1)return null;const n=this.demuxer.loadedSamples[e];if(!n)return null;let i;if(r.metadataOnly)i=Zl;else{let a=this.demuxer.reader.requestSlice(n.dataStart,n.dataSize);if(a instanceof Promise&&(a=await a),!a)return null;i=Nr(a,n.dataSize)}return new Bo(i,"key",n.timestamp,n.duration,e,n.dataSize)}getFirstPacket(e){return this.getPacketAtIndex(0,e)}async getNextPacket(e,r){const n=await this.demuxer.readingMutex.acquire();try{const i=Gm(this.demuxer.loadedSamples,e.timestamp,o=>o.timestamp);if(i===-1)throw new Error("Packet was not created from this track.");const a=i+1;for(;a>=this.demuxer.loadedSamples.length&&!this.demuxer.lastSampleLoaded;)await this.demuxer.advanceReader();return this.getPacketAtIndex(a,r)}finally{n()}}async getPacket(e,r){const n=await this.demuxer.readingMutex.acquire();try{for(;;){const i=oi(this.demuxer.loadedSamples,e,a=>a.timestamp);if(i===-1&&this.demuxer.loadedSamples.length>0)return null;if(this.demuxer.lastSampleLoaded)return this.getPacketAtIndex(i,r);if(i>=0&&i+1<this.demuxer.loadedSamples.length)return this.getPacketAtIndex(i,r);await this.demuxer.advanceReader()}}finally{n()}}getKeyPacket(e,r){return this.getPacket(e,r)}getNextKeyPacket(e,r){return this.getNextPacket(e,r)}}const M7=1399285583,XD=79764919,D7=new Uint32Array(256);for(let t=0;t<256;t++){let e=t<<24;for(let r=0;r<8;r++)e=e&2147483648?e<<1^XD:e<<1;D7[t]=e>>>0&4294967295}const YD=t=>{const e=Wa(t),r=e.getUint32(22,!0);e.setUint32(22,0,!0);let n=0;for(let i=0;i<t.length;i++){const a=t[i];n=(n<<8^D7[n>>>24^a])>>>0}return e.setUint32(22,r,!0),n},KD=(t,e,r)=>{let n=0,i=null;if(t.length>0)if(e.codec==="vorbis"){$e(e.vorbisInfo);const a=e.vorbisInfo.modeBlockflags.length,s=(1<<FM(a-1))-1<<1,l=(t[0]&s)>>1;if(l>=e.vorbisInfo.modeBlockflags.length)throw new Error("Invalid mode number.");let c=r;const f=e.vorbisInfo.modeBlockflags[l];if(i=e.vorbisInfo.blocksizes[f],f===1){const h=(s|1)+1,d=t[0]&h?1:0;c=e.vorbisInfo.blocksizes[d]}n=c!==null?c+i>>2:0}else e.codec==="opus"&&(n=oD(t).durationInSamples);return{durationInSamples:n,vorbisBlockSize:i}},ZD=t=>{let e="audio/ogg";if(t.codecStrings){const r=[...new Set(t.codecStrings)];e+=`; codecs="${r.join(", ")}"`}return e};const Yh=27,bp=282,QD=bp+65025,z0=t=>{const e=t.filePos;if(pp(t)!==M7)return null;t.skip(1);const n=dr(t),i=zF(t),a=pp(t),o=pp(t),s=pp(t),l=dr(t),c=new Uint8Array(l);for(let p=0;p<l;p++)c[p]=dr(t);const f=27+l,h=c.reduce((p,y)=>p+y,0),d=f+h;return{headerStartPos:e,totalSize:d,dataStartPos:e+f,dataSize:h,headerType:n,granulePosition:i,serialNumber:a,sequenceNumber:o,checksum:s,lacingValues:c}},JD=(t,e)=>{for(;t.filePos<e-3;){const r=pp(t),n=r&255,i=r>>>8&255,a=r>>>16&255,o=r>>>24&255,s=79;if(!(n!==s&&i!==s&&a!==s&&o!==s)){if(t.skip(-4),r===M7)return!0;t.skip(1)}}return!1};class eF extends _d{constructor(e){super(e),this.metadataPromise=null,this.bitstreams=[],this.tracks=[],this.metadataTags={},this.reader=e._reader}async readMetadata(){return this.metadataPromise??=(async()=>{let e=0;for(;;){let r=this.reader.requestSliceRange(e,Yh,bp);if(r instanceof Promise&&(r=await r),!r)break;const n=z0(r);if(!n||!!!(n.headerType&2))break;this.bitstreams.push({serialNumber:n.serialNumber,bosPage:n,description:null,numberOfChannels:-1,sampleRate:-1,codecInfo:{codec:null,vorbisInfo:null,opusInfo:null},lastMetadataPacket:null}),e=n.headerStartPos+n.totalSize}for(const r of this.bitstreams){const n=await this.readPacket(r.bosPage,0);n&&(n.data.byteLength>=7&&n.data[0]===1&&n.data[1]===118&&n.data[2]===111&&n.data[3]===114&&n.data[4]===98&&n.data[5]===105&&n.data[6]===115?await this.readVorbisMetadata(n,r):n.data.byteLength>=8&&n.data[0]===79&&n.data[1]===112&&n.data[2]===117&&n.data[3]===115&&n.data[4]===72&&n.data[5]===101&&n.data[6]===97&&n.data[7]===100&&await this.readOpusMetadata(n,r),r.codecInfo.codec!==null&&this.tracks.push(new xc(this.input,new tF(r,this))))}})()}async readVorbisMetadata(e,r){let n=await this.findNextPacketStart(e);if(!n)return;const i=await this.readPacket(n.startPage,n.startSegmentIndex);if(!i||(n=await this.findNextPacketStart(i),!n))return;const a=await this.readPacket(n.startPage,n.startSegmentIndex);if(!a||i.data[0]!==3||a.data[0]!==5)return;const o=[],s=h=>{for(;o.push(Math.min(255,h)),!(h<255);)h-=255};s(e.data.length),s(i.data.length);const l=new Uint8Array(1+o.length+e.data.length+i.data.length+a.data.length);l[0]=2,l.set(o,1),l.set(e.data,1+o.length),l.set(i.data,1+o.length+e.data.length),l.set(a.data,1+o.length+e.data.length+i.data.length),r.codecInfo.codec="vorbis",r.description=l,r.lastMetadataPacket=a;const c=Wa(e.data);r.numberOfChannels=c.getUint8(11),r.sampleRate=c.getUint32(12,!0);const f=c.getUint8(28);r.codecInfo.vorbisInfo={blocksizes:[1<<(f&15),1<<(f>>4)],modeBlockflags:sD(a.data).modeBlockflags},M5(i.data.subarray(7),this.metadataTags)}async readOpusMetadata(e,r){const n=await this.findNextPacketStart(e);if(!n)return;const i=await this.readPacket(n.startPage,n.startSegmentIndex);if(!i)return;r.codecInfo.codec="opus",r.description=e.data,r.lastMetadataPacket=i;const a=iD(e.data);r.numberOfChannels=a.outputChannelCount,r.sampleRate=Ym,r.codecInfo.opusInfo={preSkip:a.preSkip},M5(i.data.subarray(8),this.metadataTags)}async readPacket(e,r){$e(r<e.lacingValues.length);let n=0;for(let h=0;h<r;h++)n+=e.lacingValues[h];let i=e,a=n,o=r;const s=[];e:for(;;){let h=this.reader.requestSlice(i.dataStartPos,i.dataSize);h instanceof Promise&&(h=await h),$e(h);const d=Nr(h,i.dataSize);for(;;){if(o===i.lacingValues.length){s.push(d.subarray(n,a));break}const y=i.lacingValues[o];if(a+=y,y<255){s.push(d.subarray(n,a));break e}o++}let p=i.headerStartPos+i.totalSize;for(;;){let y=this.reader.requestSliceRange(p,Yh,bp);if(y instanceof Promise&&(y=await y),!y)return null;const w=z0(y);if(!w)return null;if(i=w,i.serialNumber===e.serialNumber)break;p=i.headerStartPos+i.totalSize}n=0,a=0,o=0}const l=s.reduce((h,d)=>h+d.length,0),c=new Uint8Array(l);let f=0;for(let h=0;h<s.length;h++){const d=s[h];c.set(d,f),f+=d.length}return{data:c,endPage:i,endSegmentIndex:o}}async findNextPacketStart(e){if(e.endSegmentIndex<e.endPage.lacingValues.length-1)return{startPage:e.endPage,startSegmentIndex:e.endSegmentIndex+1};if(!!(e.endPage.headerType&4))return null;let n=e.endPage.headerStartPos+e.endPage.totalSize;for(;;){let i=this.reader.requestSliceRange(n,Yh,bp);if(i instanceof Promise&&(i=await i),!i)return null;const a=z0(i);if(!a)return null;if(a.serialNumber===e.endPage.serialNumber)return{startPage:a,startSegmentIndex:0};n=a.headerStartPos+a.totalSize}}async getMimeType(){await this.readMetadata();const e=await Promise.all(this.tracks.map(r=>r.getCodecParameterString()));return ZD({codecStrings:e.filter(Boolean)})}async getTracks(){return await this.readMetadata(),this.tracks}async computeDuration(){const e=await this.getTracks(),r=await Promise.all(e.map(n=>n.computeDuration()));return Math.max(0,...r)}async getMetadataTags(){return await this.readMetadata(),this.metadataTags}}class tF{constructor(e,r){this.bitstream=e,this.demuxer=r,this.encodedPacketToMetadata=new WeakMap,this.sequentialScanCache=[],this.sequentialScanMutex=new Wm,this.internalSampleRate=e.codecInfo.codec==="opus"?Ym:e.sampleRate}getId(){return this.bitstream.serialNumber}getNumberOfChannels(){return this.bitstream.numberOfChannels}getSampleRate(){return this.bitstream.sampleRate}getTimeResolution(){return this.bitstream.sampleRate}getCodec(){return this.bitstream.codecInfo.codec}getInternalCodecId(){return null}async getDecoderConfig(){return $e(this.bitstream.codecInfo.codec),{codec:this.bitstream.codecInfo.codec,numberOfChannels:this.bitstream.numberOfChannels,sampleRate:this.bitstream.sampleRate,description:this.bitstream.description??void 0}}getName(){return null}getLanguageCode(){return ku}getDisposition(){return{...Sd}}async getFirstTimestamp(){return 0}async computeDuration(){const e=await this.getPacket(1/0,{metadataOnly:!0});return(e?.timestamp??0)+(e?.duration??0)}granulePositionToTimestampInSamples(e){return this.bitstream.codecInfo.codec==="opus"?($e(this.bitstream.codecInfo.opusInfo),e-this.bitstream.codecInfo.opusInfo.preSkip):e}createEncodedPacketFromOggPacket(e,r,n){if(!e)return null;const{durationInSamples:i,vorbisBlockSize:a}=KD(e.data,this.bitstream.codecInfo,r.vorbisLastBlocksize),o=new Bo(n.metadataOnly?Zl:e.data,"key",Math.max(0,r.timestampInSamples)/this.internalSampleRate,i/this.internalSampleRate,e.endPage.headerStartPos+e.endSegmentIndex,e.data.byteLength);return this.encodedPacketToMetadata.set(o,{packet:e,timestampInSamples:r.timestampInSamples,durationInSamples:i,vorbisLastBlockSize:r.vorbisLastBlocksize,vorbisBlockSize:a}),o}async getFirstPacket(e){$e(this.bitstream.lastMetadataPacket);const r=await this.demuxer.findNextPacketStart(this.bitstream.lastMetadataPacket);if(!r)return null;let n=0;this.bitstream.codecInfo.codec==="opus"&&($e(this.bitstream.codecInfo.opusInfo),n-=this.bitstream.codecInfo.opusInfo.preSkip);const i=await this.demuxer.readPacket(r.startPage,r.startSegmentIndex);return this.createEncodedPacketFromOggPacket(i,{timestampInSamples:n,vorbisLastBlocksize:null},e)}async getNextPacket(e,r){const n=this.encodedPacketToMetadata.get(e);if(!n)throw new Error("Packet was not created from this track.");const i=await this.demuxer.findNextPacketStart(n.packet);if(!i)return null;const a=n.timestampInSamples+n.durationInSamples,o=await this.demuxer.readPacket(i.startPage,i.startSegmentIndex);return this.createEncodedPacketFromOggPacket(o,{timestampInSamples:a,vorbisLastBlocksize:n.vorbisBlockSize},r)}async getPacket(e,r){if(this.demuxer.reader.fileSize===null)return this.getPacketSequential(e,r);const n=fm(e*this.internalSampleRate);if(n===0)return this.getFirstPacket(r);if(n<0)return null;$e(this.bitstream.lastMetadataPacket);const i=await this.demuxer.findNextPacketStart(this.bitstream.lastMetadataPacket);if(!i)return null;let a=i.startPage,o=this.demuxer.reader.fileSize;const s=[a];e:for(;a.headerStartPos+a.totalSize<o;){const S=a.headerStartPos,E=Math.floor((S+o)/2);let _=E;for(;;){const P=Math.min(_+QD,o-Yh);let O=this.demuxer.reader.requestSlice(_,P-_);if(O instanceof Promise&&(O=await O),$e(O),!JD(O,P)){o=E+Yh;continue e}let N=this.demuxer.reader.requestSliceRange(O.filePos,Yh,bp);N instanceof Promise&&(N=await N),$e(N);const D=z0(N);$e(D);let F=!1;if(D.serialNumber===this.bitstream.serialNumber)F=!0;else{let L=this.demuxer.reader.requestSlice(D.headerStartPos,D.totalSize);L instanceof Promise&&(L=await L),$e(L);const H=Nr(L,D.totalSize);F=YD(H)===D.checksum}if(!F){_=D.headerStartPos+4;continue}if(F&&D.serialNumber!==this.bitstream.serialNumber){_=D.headerStartPos+D.totalSize;continue}if(D.granulePosition===-1){_=D.headerStartPos+D.totalSize;continue}this.granulePositionToTimestampInSamples(D.granulePosition)>n?o=D.headerStartPos:(a=D,s.push(D));continue e}}let l=i.startPage;for(const S of s){if(S.granulePosition===a.granulePosition)break;(!l||S.headerStartPos>l.headerStartPos)&&(l=S)}let c=l;const f=[c];for(;!(c.serialNumber===this.bitstream.serialNumber&&c.granulePosition===a.granulePosition);){const S=c.headerStartPos+c.totalSize;let E=this.demuxer.reader.requestSliceRange(S,Yh,bp);E instanceof Promise&&(E=await E),$e(E);const _=z0(E);$e(_),c=_,c.serialNumber===this.bitstream.serialNumber&&f.push(c)}$e(c.granulePosition!==-1);let h=null,d,p,y=c,w=0;if(c.headerStartPos===i.startPage.headerStartPos)d=this.granulePositionToTimestampInSamples(0),p=!0,h=0;else{d=0,p=!1;for(let _=c.lacingValues.length-1;_>=0;_--)if(c.lacingValues[_]<255){h=_+1;break}if(h===null)throw new Error("Invalid page with granule position: no packets end on this page.");w=h-1;const S={data:Zl,endPage:y,endSegmentIndex:w};if(await this.demuxer.findNextPacketStart(S)){const _=lx(f,c,h);$e(_);const P=sx(f,_.page,_.segmentIndex);P&&(c=P.page,h=P.segmentIndex)}else for(;;){const _=lx(f,c,h);if(!_)break;const P=sx(f,_.page,_.segmentIndex);if(!P)break;if(c=P.page,h=P.segmentIndex,_.page.headerStartPos!==y.headerStartPos){y=_.page,w=_.segmentIndex;break}}}let x=null,b=null;for(;c!==null;){$e(h!==null);const S=await this.demuxer.readPacket(c,h);if(!S)break;if(!(c.headerStartPos===i.startPage.headerStartPos&&h<i.startSegmentIndex)){let P=this.createEncodedPacketFromOggPacket(S,{timestampInSamples:d,vorbisLastBlocksize:b?.vorbisBlockSize??null},r);$e(P);let O=this.encodedPacketToMetadata.get(P);if($e(O),!p&&S.endPage.headerStartPos===y.headerStartPos&&S.endSegmentIndex===w?(d=this.granulePositionToTimestampInSamples(c.granulePosition),p=!0,P=this.createEncodedPacketFromOggPacket(S,{timestampInSamples:d-O.durationInSamples,vorbisLastBlocksize:b?.vorbisBlockSize??null},r),$e(P),O=this.encodedPacketToMetadata.get(P),$e(O)):d+=O.durationInSamples,x=P,b=O,p&&(Math.max(d,0)>n||Math.max(O.timestampInSamples,0)===n))break}const _=await this.demuxer.findNextPacketStart(S);if(!_)break;c=_.startPage,h=_.startSegmentIndex}return x}async getPacketSequential(e,r){const n=await this.sequentialScanMutex.acquire();try{const i=fm(e*this.internalSampleRate);e=i/this.internalSampleRate;const a=oi(this.sequentialScanCache,i,l=>l.timestampInSamples);let o;if(a!==-1){const l=this.sequentialScanCache[a];o=this.createEncodedPacketFromOggPacket(l.packet,{timestampInSamples:l.timestampInSamples,vorbisLastBlocksize:l.vorbisLastBlockSize},r)}else o=await this.getFirstPacket(r);let s=0;for(;o&&o.timestamp<e;){const l=await this.getNextPacket(o,r);if(!l||l.timestamp>e)break;if(o=l,s++,s===100){s=0;const c=this.encodedPacketToMetadata.get(o);$e(c),this.sequentialScanCache.length>0&&$e(El(this.sequentialScanCache).timestampInSamples<=c.timestampInSamples),this.sequentialScanCache.push(c)}}return o}finally{n()}}getKeyPacket(e,r){return this.getPacket(e,r)}getNextKeyPacket(e,r){return this.getNextPacket(e,r)}}const sx=(t,e,r)=>{let n=e,i=r;e:for(;;){for(i--,i;i>=0;i--)if(n.lacingValues[i]<255){i++;break e}if($e(i===-1),!(n.headerType&1)){i=0;break}const o=t7(t,s=>s.headerStartPos<n.headerStartPos);if(!o)return null;n=o,i=n.lacingValues.length}if($e(i!==-1),i===n.lacingValues.length){const a=t[t.indexOf(n)+1];$e(a),n=a,i=0}return{page:n,segmentIndex:i}},lx=(t,e,r)=>{if(r>0)return{page:e,segmentIndex:r-1};const n=t7(t,i=>i.headerStartPos<e.headerStartPos);return n?{page:n,segmentIndex:n.lacingValues.length-1}:null};var Uc;(function(t){t[t.PCM=1]="PCM",t[t.IEEE_FLOAT=3]="IEEE_FLOAT",t[t.ALAW=6]="ALAW",t[t.MULAW=7]="MULAW",t[t.EXTENSIBLE=65534]="EXTENSIBLE"})(Uc||(Uc={}));class rF extends _d{constructor(e){super(e),this.metadataPromise=null,this.dataStart=-1,this.dataSize=-1,this.audioInfo=null,this.tracks=[],this.lastKnownPacketIndex=0,this.metadataTags={},this.reader=e._reader}async readMetadata(){return this.metadataPromise??=(async()=>{let e=this.reader.requestSlice(0,12);e instanceof Promise&&(e=await e),$e(e);const r=Fo(e,4),n=r!=="RIFX",i=r==="RF64",a=ah(e,n);let o=i?this.reader.fileSize:Math.min(a+8,this.reader.fileSize??1/0);if(Fo(e,4)!=="WAVE")throw new Error("Invalid WAVE file - wrong format");let l=0,c=null,f=e.filePos;for(;o===null||f<o;){let d=this.reader.requestSlice(f,8);if(d instanceof Promise&&(d=await d),!d)break;const p=Fo(d,4),y=ah(d,n),w=d.filePos;if(i&&l===0&&p!=="ds64")throw new Error('Invalid RF64 file: First chunk must be "ds64".');if(p==="fmt ")await this.parseFmtChunk(w,y,n);else if(p==="data"){if(c??=y,this.dataStart=d.filePos,this.dataSize=Math.min(c,(o??1/0)-this.dataStart),this.reader.fileSize===null)break}else if(p==="ds64"){let x=this.reader.requestSlice(w,y);if(x instanceof Promise&&(x=await x),!x)break;const b=cx(x,n);c=cx(x,n),o=Math.min(b+8,this.reader.fileSize??1/0)}else p==="LIST"?await this.parseListChunk(w,y,n):(p==="ID3 "||p==="id3 ")&&await this.parseId3Chunk(w,y);f=w+y+(y&1),l++}if(!this.audioInfo)throw new Error('Invalid WAVE file - missing "fmt " chunk');if(this.dataStart===-1)throw new Error('Invalid WAVE file - missing "data" chunk');const h=this.audioInfo.blockSizeInBytes;this.dataSize=Math.floor(this.dataSize/h)*h,this.tracks.push(new xc(this.input,new nF(this)))})()}async parseFmtChunk(e,r,n){let i=this.reader.requestSlice(e,r);if(i instanceof Promise&&(i=await i),!i)return;let a=f0(i,n);const o=f0(i,n),s=ah(i,n);i.skip(4);const l=f0(i,n);let c;if(r===14?c=8:c=f0(i,n),r>=18&&a!==357){const f=f0(i,n),h=r-18;if(Math.min(h,f)>=22&&a===Uc.EXTENSIBLE){i.skip(6);const p=Nr(i,16);a=p[0]|p[1]<<8}}(a===Uc.MULAW||a===Uc.ALAW)&&(c=8),this.audioInfo={format:a,numberOfChannels:o,sampleRate:s,sampleSizeInBytes:Math.ceil(c/8),blockSizeInBytes:l}}async parseListChunk(e,r,n){let i=this.reader.requestSlice(e,r);if(i instanceof Promise&&(i=await i),!i)return;const a=Fo(i,4);if(a!=="INFO"&&a!=="INF0")return;let o=i.filePos;for(;o<=e+r-8;){i.filePos=o;const s=Fo(i,4),l=ah(i,n),c=Nr(i,l);let f=0;for(let d=0;d<c.length&&c[d]!==0;d++)f++;const h=String.fromCharCode(...c.subarray(0,f));switch(this.metadataTags.raw??={},this.metadataTags.raw[s]=h,s){case"INAM":case"TITL":this.metadataTags.title??=h;break;case"TIT3":this.metadataTags.description??=h;break;case"IART":this.metadataTags.artist??=h;break;case"IPRD":this.metadataTags.album??=h;break;case"IPRT":case"ITRK":case"TRCK":{const d=h.split("/"),p=Number.parseInt(d[0],10),y=d[1]&&Number.parseInt(d[1],10);Number.isInteger(p)&&p>0&&(this.metadataTags.trackNumber??=p),y&&Number.isInteger(y)&&y>0&&(this.metadataTags.tracksTotal??=y)}break;case"ICRD":case"IDIT":{const d=new Date(h);Number.isNaN(d.getTime())||(this.metadataTags.date??=d)}break;case"YEAR":{const d=Number.parseInt(h,10);Number.isInteger(d)&&d>0&&(this.metadataTags.date??=new Date(d,0,1))}break;case"IGNR":case"GENR":this.metadataTags.genre??=h;break;case"ICMT":case"CMNT":case"COMM":this.metadataTags.comment??=h;break}o+=8+l+(l&1)}}async parseId3Chunk(e,r){let n=this.reader.requestSlice(e,r);if(n instanceof Promise&&(n=await n),!n)return;const i=gm(n);if(i){const a=n.slice(e+10,i.size);R7(a,i,this.metadataTags)}}getCodec(){if($e(this.audioInfo),this.audioInfo.format===Uc.MULAW)return"ulaw";if(this.audioInfo.format===Uc.ALAW)return"alaw";if(this.audioInfo.format===Uc.PCM){if(this.audioInfo.sampleSizeInBytes===1)return"pcm-u8";if(this.audioInfo.sampleSizeInBytes===2)return"pcm-s16";if(this.audioInfo.sampleSizeInBytes===3)return"pcm-s24";if(this.audioInfo.sampleSizeInBytes===4)return"pcm-s32"}return this.audioInfo.format===Uc.IEEE_FLOAT&&this.audioInfo.sampleSizeInBytes===4?"pcm-f32":null}async getMimeType(){return"audio/wav"}async computeDuration(){await this.readMetadata();const e=this.tracks[0];return $e(e),e.computeDuration()}async getTracks(){return await this.readMetadata(),this.tracks}async getMetadataTags(){return await this.readMetadata(),this.metadataTags}}const Xd=2048;class nF{constructor(e){this.demuxer=e}getId(){return 1}getCodec(){return this.demuxer.getCodec()}getInternalCodecId(){return $e(this.demuxer.audioInfo),this.demuxer.audioInfo.format}async getDecoderConfig(){const e=this.demuxer.getCodec();return e?($e(this.demuxer.audioInfo),{codec:e,numberOfChannels:this.demuxer.audioInfo.numberOfChannels,sampleRate:this.demuxer.audioInfo.sampleRate}):null}async computeDuration(){const e=await this.getPacket(1/0,{metadataOnly:!0});return(e?.timestamp??0)+(e?.duration??0)}getNumberOfChannels(){return $e(this.demuxer.audioInfo),this.demuxer.audioInfo.numberOfChannels}getSampleRate(){return $e(this.demuxer.audioInfo),this.demuxer.audioInfo.sampleRate}getTimeResolution(){return $e(this.demuxer.audioInfo),this.demuxer.audioInfo.sampleRate}getName(){return null}getLanguageCode(){return ku}getDisposition(){return{...Sd}}async getFirstTimestamp(){return 0}async getPacketAtIndex(e,r){$e(this.demuxer.audioInfo);const n=e*Xd*this.demuxer.audioInfo.blockSizeInBytes;if(n>=this.demuxer.dataSize)return null;const i=Math.min(Xd*this.demuxer.audioInfo.blockSizeInBytes,this.demuxer.dataSize-n);if(this.demuxer.reader.fileSize===null){let l=this.demuxer.reader.requestSlice(this.demuxer.dataStart+n,i);if(l instanceof Promise&&(l=await l),!l)return null}let a;if(r.metadataOnly)a=Zl;else{let l=this.demuxer.reader.requestSlice(this.demuxer.dataStart+n,i);l instanceof Promise&&(l=await l),$e(l),a=Nr(l,i)}const o=e*Xd/this.demuxer.audioInfo.sampleRate,s=i/this.demuxer.audioInfo.blockSizeInBytes/this.demuxer.audioInfo.sampleRate;return this.demuxer.lastKnownPacketIndex=Math.max(e,o),new Bo(a,"key",o,s,e,i)}getFirstPacket(e){return this.getPacketAtIndex(0,e)}async getPacket(e,r){$e(this.demuxer.audioInfo);const n=Math.floor(Math.min(e*this.demuxer.audioInfo.sampleRate/Xd,(this.demuxer.dataSize-1)/(Xd*this.demuxer.audioInfo.blockSizeInBytes))),i=await this.getPacketAtIndex(n,r);if(i)return i;if(n===0)return null;$e(this.demuxer.reader.fileSize===null);let a=await this.getPacketAtIndex(this.demuxer.lastKnownPacketIndex,r);for(;a;){const o=await this.getNextPacket(a,r);if(!o)break;a=o}return a}getNextPacket(e,r){$e(this.demuxer.audioInfo);const n=Math.round(e.timestamp*this.demuxer.audioInfo.sampleRate/Xd);return this.getPacketAtIndex(n+1,r)}getKeyPacket(e,r){return this.getPacket(e,r)}getNextKeyPacket(e,r){return this.getNextPacket(e,r)}}const mm=7,vm=9,U5=t=>{const e=t.filePos,r=Nr(t,9),n=new aa(r);if(n.readBits(12)!==4095||(n.skipBits(1),n.readBits(2)!==0))return null;const o=n.readBits(1),s=n.readBits(2)+1,l=n.readBits(4);if(l===15)return null;n.skipBits(1);const c=n.readBits(3);if(c===0)throw new Error("ADTS frames with channel configuration 0 are not supported.");n.skipBits(1),n.skipBits(1),n.skipBits(1),n.skipBits(1);const f=n.readBits(13);n.skipBits(11);const h=n.readBits(2)+1;if(h!==1)throw new Error("ADTS frames with more than one AAC frame are not supported.");let d=null;return o===1?t.filePos-=2:d=n.readBits(16),{objectType:s,samplingFrequencyIndex:l,channelConfiguration:c,frameLength:f,numberOfAacFrames:h,crcCheck:d,startPos:e}};const q5=1024;class iF extends _d{constructor(e){super(e),this.metadataPromise=null,this.firstFrameHeader=null,this.loadedSamples=[],this.tracks=[],this.readingMutex=new Wm,this.lastSampleLoaded=!1,this.lastLoadedPos=0,this.nextTimestampInSamples=0,this.reader=e._reader}async readMetadata(){return this.metadataPromise??=(async()=>{for(;!this.firstFrameHeader&&!this.lastSampleLoaded;)await this.advanceReader();$e(this.firstFrameHeader),this.tracks=[new xc(this.input,new aF(this))]})()}async advanceReader(){let e=this.reader.requestSliceRange(this.lastLoadedPos,mm,vm);if(e instanceof Promise&&(e=await e),!e){this.lastSampleLoaded=!0;return}const r=U5(e);if(!r){this.lastSampleLoaded=!0;return}if(this.reader.fileSize!==null&&r.startPos+r.frameLength>this.reader.fileSize){this.lastSampleLoaded=!0;return}this.firstFrameHeader||(this.firstFrameHeader=r);const n=r1[r.samplingFrequencyIndex];$e(n!==void 0);const i=q5/n,a=r.crcCheck?vm:mm,o={timestamp:this.nextTimestampInSamples/n,duration:i,dataStart:r.startPos+a,dataSize:r.frameLength-a};this.loadedSamples.push(o),this.nextTimestampInSamples+=q5,this.lastLoadedPos=r.startPos+r.frameLength}async getMimeType(){return"audio/aac"}async getTracks(){return await this.readMetadata(),this.tracks}async computeDuration(){await this.readMetadata();const e=this.tracks[0];return $e(e),e.computeDuration()}async getMetadataTags(){return{}}}class aF{constructor(e){this.demuxer=e}getId(){return 1}async getFirstTimestamp(){return 0}getTimeResolution(){return this.getSampleRate()/q5}async computeDuration(){const e=await this.getPacket(1/0,{metadataOnly:!0});return(e?.timestamp??0)+(e?.duration??0)}getName(){return null}getLanguageCode(){return ku}getCodec(){return"aac"}getInternalCodecId(){return $e(this.demuxer.firstFrameHeader),this.demuxer.firstFrameHeader.objectType}getNumberOfChannels(){$e(this.demuxer.firstFrameHeader);const e=Hb[this.demuxer.firstFrameHeader.channelConfiguration];return $e(e!==void 0),e}getSampleRate(){$e(this.demuxer.firstFrameHeader);const e=r1[this.demuxer.firstFrameHeader.samplingFrequencyIndex];return $e(e!==void 0),e}getDisposition(){return{...Sd}}async getDecoderConfig(){$e(this.demuxer.firstFrameHeader);const e=new Uint8Array(3),r=new aa(e),{objectType:n,samplingFrequencyIndex:i,channelConfiguration:a}=this.demuxer.firstFrameHeader;return n>31?(r.writeBits(5,31),r.writeBits(6,n-32)):r.writeBits(5,n),r.writeBits(4,i),r.writeBits(4,a),{codec:`mp4a.40.${this.demuxer.firstFrameHeader.objectType}`,numberOfChannels:this.getNumberOfChannels(),sampleRate:this.getSampleRate(),description:e.subarray(0,Math.ceil((r.pos-1)/8))}}async getPacketAtIndex(e,r){if(e===-1)return null;const n=this.demuxer.loadedSamples[e];if(!n)return null;let i;if(r.metadataOnly)i=Zl;else{let a=this.demuxer.reader.requestSlice(n.dataStart,n.dataSize);if(a instanceof Promise&&(a=await a),!a)return null;i=Nr(a,n.dataSize)}return new Bo(i,"key",n.timestamp,n.duration,e,n.dataSize)}getFirstPacket(e){return this.getPacketAtIndex(0,e)}async getNextPacket(e,r){const n=await this.demuxer.readingMutex.acquire();try{const i=Gm(this.demuxer.loadedSamples,e.timestamp,o=>o.timestamp);if(i===-1)throw new Error("Packet was not created from this track.");const a=i+1;for(;a>=this.demuxer.loadedSamples.length&&!this.demuxer.lastSampleLoaded;)await this.demuxer.advanceReader();return this.getPacketAtIndex(a,r)}finally{n()}}async getPacket(e,r){const n=await this.demuxer.readingMutex.acquire();try{for(;;){const i=oi(this.demuxer.loadedSamples,e,a=>a.timestamp);if(i===-1&&this.demuxer.loadedSamples.length>0)return null;if(this.demuxer.lastSampleLoaded)return this.getPacketAtIndex(i,r);if(i>=0&&i+1<this.demuxer.loadedSamples.length)return this.getPacketAtIndex(i,r);await this.demuxer.advanceReader()}}finally{n()}}getKeyPacket(e,r){return this.getPacket(e,r)}getNextKeyPacket(e,r){return this.getNextPacket(e,r)}}const oF=t=>t===0?null:t===1?192:t>=2&&t<=5?144*2**t:t===6?"uncommon-u8":t===7?"uncommon-u16":t>=8&&t<=15?2**t:null,sF=(t,e)=>{switch(t){case 0:return e;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}},lF=t=>{let e=0;const r=new aa(Nr(t,1));for(;r.readBits(1)===1;)e++;if(e===0)return r.readBits(7);const n=[],i=e-1,a=new aa(Nr(t,i)),o=8-e-1;for(let l=0;l<o;l++)n.unshift(r.readBits(1));for(let l=0;l<i;l++)for(let c=0;c<8;c++){const f=a.readBits(1);c<2||n.unshift(f)}return n.reduce((l,c,f)=>l|c<<f,0)},uF=(t,e)=>{if(e==="uncommon-u16")return ts(t)+1;if(e==="uncommon-u8")return dr(t)+1;if(typeof e=="number")return e;Lp(e),$e(!1)},cF=(t,e)=>e==="uncommon-u16"?ts(t):e==="uncommon-u16-10"?ts(t)*10:e==="uncommon-u8"?dr(t):typeof e=="number"?e:null,fF=t=>{let r=0;for(const n of t){r^=n;for(let i=0;i<8;i++)(r&128)!==0?r=r<<1^7:r<<=1,r&=255}return r};class hF extends _d{constructor(e){super(e),this.loadedSamples=[],this.metadataPromise=null,this.track=null,this.metadataTags={},this.audioInfo=null,this.lastLoadedPos=null,this.blockingBit=null,this.readingMutex=new Wm,this.lastSampleLoaded=!1,this.reader=e._reader}async computeDuration(){return await this.readMetadata(),$e(this.track),this.track.computeDuration()}async getMetadataTags(){return await this.readMetadata(),this.metadataTags}async getTracks(){return await this.readMetadata(),$e(this.track),[this.track]}async getMimeType(){return"audio/flac"}async readMetadata(){let e=4;return this.metadataPromise??=(async()=>{for(;this.reader.fileSize===null||e<this.reader.fileSize;){let r=this.reader.requestSlice(e,4);if(r instanceof Promise&&(r=await r),e+=4,r===null)throw new Error(`Metadata block at position ${e} is too small! Corrupted file.`);$e(r);const n=dr(r),i=np(r),a=(n&128)!==0;switch(n&127){case yp.STREAMINFO:{let s=this.reader.requestSlice(e,i);if(s instanceof Promise&&(s=await s),$e(s),s===null)throw new Error(`StreamInfo block at position ${e} is too small! Corrupted file.`);const l=Nr(s,34),c=new aa(l),f=c.readBits(16),h=c.readBits(16),d=c.readBits(24),p=c.readBits(24),y=c.readBits(20),w=c.readBits(3)+1;c.readBits(5);const x=c.readBits(36);c.skipBits(128);const b=new Uint8Array(42);b.set(new Uint8Array([102,76,97,67]),0),b.set(new Uint8Array([128,0,0,34]),4),b.set(l,8),this.audioInfo={numberOfChannels:w,sampleRate:y,totalSamples:x,minimumBlockSize:f,maximumBlockSize:h,minimumFrameSize:d,maximumFrameSize:p,description:b},this.track=new xc(this.input,new dF(this));break}case yp.VORBIS_COMMENT:{let s=this.reader.requestSlice(e,i);s instanceof Promise&&(s=await s),$e(s),M5(Nr(s,i),this.metadataTags);break}case yp.PICTURE:{let s=this.reader.requestSlice(e,i);s instanceof Promise&&(s=await s),$e(s);const l=Dt(s),c=Dt(s),f=Kl.decode(Nr(s,c)),h=Dt(s),d=Kl.decode(Nr(s,h));s.skip(16);const p=Dt(s),y=Nr(s,p);this.metadataTags.images??=[],this.metadataTags.images.push({data:y,mimeType:f,kind:l===3?"coverFront":l===4?"coverBack":"unknown",description:d});break}}if(e+=i,a){this.lastLoadedPos=e;break}}})()}async readNextFlacFrame({startPos:e,isFirstPacket:r}){$e(this.audioInfo);const n=6,a=this.audioInfo.maximumFrameSize+16,o=await this.reader.requestSliceRange(e,this.audioInfo.minimumFrameSize,a);if(!o)return null;const s=this.readFlacFrameHeader({slice:o,isFirstPacket:r});if(!s)return null;for(o.filePos=e+this.audioInfo.minimumFrameSize;;){if(o.filePos>o.end-n)return{num:s.num,blockSize:s.blockSize,sampleRate:s.sampleRate,size:o.end-e,isLastFrame:!0};if(dr(o)===255){const c=o.filePos,f=dr(o),h=this.blockingBit===1?249:248;if(f!==h){o.filePos=c;continue}o.skip(-2);const d=o.filePos-e,p=this.readFlacFrameHeader({slice:o,isFirstPacket:!1});if(!p){o.filePos=c;continue}if(this.blockingBit===0){if(p.num-s.num!==1){o.filePos=c;continue}}else if(p.num-s.num!==s.blockSize){o.filePos=c;continue}return{num:s.num,blockSize:s.blockSize,sampleRate:s.sampleRate,size:d,isLastFrame:!1}}}}readFlacFrameHeader({slice:e,isFirstPacket:r}){const n=e.filePos,i=Nr(e,4),a=new aa(i);if(a.readBits(15)!==32764)return null;if(this.blockingBit===null){$e(r);const x=a.readBits(1);this.blockingBit=x}else if(this.blockingBit===1){if($e(!r),a.readBits(1)!==1)return null}else if(this.blockingBit===0){if($e(!r),a.readBits(1)!==0)return null}else throw new Error("Invalid blocking bit");const s=oF(a.readBits(4));if(!s)return null;$e(this.audioInfo);const l=sF(a.readBits(4),this.audioInfo.sampleRate);if(!l||(a.readBits(4),a.readBits(3),a.readBits(1)!==0))return null;const f=lF(e),h=uF(e,s),d=cF(e,l);if(d===null||d!==this.audioInfo.sampleRate)return null;const p=e.filePos-n,y=dr(e);e.skip(-p),e.skip(-1);const w=fF(Nr(e,p));return y!==w?null:{num:f,blockSize:h,sampleRate:d}}async advanceReader(){await this.readMetadata(),$e(this.lastLoadedPos!==null),$e(this.audioInfo);const e=this.lastLoadedPos,r=await this.readNextFlacFrame({startPos:e,isFirstPacket:this.loadedSamples.length===0});if(!r){this.lastSampleLoaded=!0;return}const n=this.loadedSamples[this.loadedSamples.length-1],a={blockOffset:n?n.blockOffset+n.blockSize:0,blockSize:r.blockSize,byteOffset:e,byteSize:r.size};if(this.lastLoadedPos=this.lastLoadedPos+r.size,this.loadedSamples.push(a),r.isLastFrame){this.lastSampleLoaded=!0;return}}}class dF{constructor(e){this.demuxer=e}getId(){return 1}getCodec(){return"flac"}getInternalCodecId(){return null}getNumberOfChannels(){return $e(this.demuxer.audioInfo),this.demuxer.audioInfo.numberOfChannels}async computeDuration(){const e=await this.getPacket(1/0,{metadataOnly:!0});return(e?.timestamp??0)+(e?.duration??0)}getSampleRate(){return $e(this.demuxer.audioInfo),this.demuxer.audioInfo.sampleRate}getName(){return null}getLanguageCode(){return ku}getTimeResolution(){return $e(this.demuxer.audioInfo),this.demuxer.audioInfo.sampleRate}getDisposition(){return{...Sd}}async getFirstTimestamp(){return 0}async getDecoderConfig(){return $e(this.demuxer.audioInfo),{codec:"flac",numberOfChannels:this.demuxer.audioInfo.numberOfChannels,sampleRate:this.demuxer.audioInfo.sampleRate,description:this.demuxer.audioInfo.description}}async getPacket(e,r){if($e(this.demuxer.audioInfo),e<0)throw new Error("Timestamp cannot be negative");const n=await this.demuxer.readingMutex.acquire();try{for(;;){const i=oi(this.demuxer.loadedSamples,e,l=>l.blockOffset/this.demuxer.audioInfo.sampleRate);if(i===-1){await this.demuxer.advanceReader();continue}const a=this.demuxer.loadedSamples[i],o=a.blockOffset/this.demuxer.audioInfo.sampleRate,s=a.blockSize/this.demuxer.audioInfo.sampleRate;if(o+s<=e){if(this.demuxer.lastSampleLoaded)return this.getPacketAtIndex(this.demuxer.loadedSamples.length-1,r);await this.demuxer.advanceReader();continue}return this.getPacketAtIndex(i,r)}}finally{n()}}async getNextPacket(e,r){const n=await this.demuxer.readingMutex.acquire();try{const i=e.sequenceNumber+1;if(this.demuxer.lastSampleLoaded&&i>=this.demuxer.loadedSamples.length)return null;for(;i>=this.demuxer.loadedSamples.length&&!this.demuxer.lastSampleLoaded;)await this.demuxer.advanceReader();return this.getPacketAtIndex(i,r)}finally{n()}}getKeyPacket(e,r){return this.getPacket(e,r)}getNextKeyPacket(e,r){return this.getNextPacket(e,r)}async getPacketAtIndex(e,r){const n=this.demuxer.loadedSamples[e];if(!n)return null;let i;if(r.metadataOnly)i=Zl;else{let s=this.demuxer.reader.requestSlice(n.byteOffset,n.byteSize);if(s instanceof Promise&&(s=await s),!s)return null;i=Nr(s,n.byteSize)}$e(this.demuxer.audioInfo);const a=n.blockOffset/this.demuxer.audioInfo.sampleRate,o=n.blockSize/this.demuxer.audioInfo.sampleRate;return new Bo(i,"key",a,o,e,n.byteSize)}async getFirstPacket(e){for(;this.demuxer.loadedSamples.length===0&&!this.demuxer.lastSampleLoaded;)await this.demuxer.advanceReader();return this.getPacketAtIndex(0,e)}}class _h{}class F7 extends _h{async _getMajorBrand(e){let r=e._reader.requestSlice(0,12);return r instanceof Promise&&(r=await r),!r||(r.skip(4),Fo(r,4)!=="ftyp")?null:Fo(r,4)}_createDemuxer(e){return new kD(e)}}class pF extends F7{async _canReadInput(e){const r=await this._getMajorBrand(e);return!!r&&r!=="qt "}get name(){return"MP4"}get mimeType(){return"video/mp4"}}class gF extends F7{async _canReadInput(e){return await this._getMajorBrand(e)==="qt "}get name(){return"QuickTime File Format"}get mimeType(){return"video/quicktime"}}class B7 extends _h{async isSupportedEBMLOfDocType(e,r){let n=e._reader.requestSlice(0,Xc);if(n instanceof Promise&&(n=await n),!n)return!1;const i=T7(n);if(i===null||i<1||i>8||Jr(n,i)!==bt.EBML)return!1;const o=A7(n);if(o===null)return!1;let s=e._reader.requestSlice(n.filePos,o);if(s instanceof Promise&&(s=await s),!s)return!1;const l=n.filePos;for(;s.filePos<=l+o-_u;){const c=Hc(s);if(!c)break;const{id:f,size:h}=c,d=s.filePos;if(h===null)return!1;switch(f){case bt.EBMLVersion:if(Jr(s,h)!==1)return!1;break;case bt.EBMLReadVersion:if(Jr(s,h)!==1)return!1;break;case bt.DocType:if(rp(s,h)!==r)return!1;break;case bt.DocTypeVersion:if(Jr(s,h)>4)return!1;break}s.filePos=d+h}return!0}_canReadInput(e){return this.isSupportedEBMLOfDocType(e,"matroska")}_createDemuxer(e){return new RD(e)}get name(){return"Matroska"}get mimeType(){return"video/x-matroska"}}class mF extends B7{_canReadInput(e){return this.isSupportedEBMLOfDocType(e,"webm")}get name(){return"WebM"}get mimeType(){return"video/webm"}}class vF extends _h{async _canReadInput(e){let r=e._reader.requestSlice(0,10);if(r instanceof Promise&&(r=await r),!r)return!1;let n=0,i=!1;for(;;){let c=e._reader.requestSlice(n,pm);if(c instanceof Promise&&(c=await c),!c)break;const f=gm(c);if(!f)break;i=!0,n=c.filePos+f.size}const a=await z5(e._reader,n,n+4096);if(!a)return!1;if(i)return!0;n=a.startPos+a.header.totalSize;const o=await z5(e._reader,n,n+L7);if(!o)return!1;const s=a.header,l=o.header;return!(s.channel!==l.channel||s.sampleRate!==l.sampleRate)}_createDemuxer(e){return new WD(e)}get name(){return"MP3"}get mimeType(){return"audio/mpeg"}}class yF extends _h{async _canReadInput(e){let r=e._reader.requestSlice(0,12);if(r instanceof Promise&&(r=await r),!r)return!1;const n=Fo(r,4);return n!=="RIFF"&&n!=="RIFX"&&n!=="RF64"?!1:(r.skip(4),Fo(r,4)==="WAVE")}_createDemuxer(e){return new rF(e)}get name(){return"WAVE"}get mimeType(){return"audio/wav"}}class bF extends _h{async _canReadInput(e){let r=e._reader.requestSlice(0,4);return r instanceof Promise&&(r=await r),r?Fo(r,4)==="OggS":!1}_createDemuxer(e){return new eF(e)}get name(){return"Ogg"}get mimeType(){return"application/ogg"}}class wF extends _h{async _canReadInput(e){let r=e._reader.requestSlice(0,4);return r instanceof Promise&&(r=await r),r?Fo(r,4)==="fLaC":!1}get name(){return"FLAC"}get mimeType(){return"audio/flac"}_createDemuxer(e){return new hF(e)}}class xF extends _h{async _canReadInput(e){let r=e._reader.requestSliceRange(0,mm,vm);if(r instanceof Promise&&(r=await r),!r)return!1;const n=U5(r);if(!n||(r=e._reader.requestSliceRange(n.frameLength,mm,vm),r instanceof Promise&&(r=await r),!r))return!1;const i=U5(r);return i?n.objectType===i.objectType&&n.samplingFrequencyIndex===i.samplingFrequencyIndex&&n.channelConfiguration===i.channelConfiguration:!1}_createDemuxer(e){return new iF(e)}get name(){return"ADTS"}get mimeType(){return"audio/aac"}}const SF=new pF,_F=new gF,kF=new B7,EF=new mF,PF=new vF,CF=new yF,TF=new bF,AF=new xF,OF=new wF,NF=[SF,_F,kF,EF,CF,TF,OF,PF,AF];class Xb{constructor(){this._disposed=!1,this._sizePromise=null,this.onread=null}async getSizeOrNull(){if(this._disposed)throw new xl;return this._sizePromise??=Promise.resolve(this._retrieveSize())}async getSize(){if(this._disposed)throw new xl;const e=await this.getSizeOrNull();if(e===null)throw new Error("Cannot determine the size of an unsized source.");return e}}class ux extends Xb{constructor(e){if(!(e instanceof ArrayBuffer)&&!(typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer)&&!ArrayBuffer.isView(e))throw new TypeError("buffer must be an ArrayBuffer, SharedArrayBuffer, or ArrayBufferView.");super(),this._onreadCalled=!1,this._bytes=td(e),this._view=Wa(e)}_retrieveSize(){return this._bytes.byteLength}_read(){return this._onreadCalled||(this.onread?.(0,this._bytes.byteLength),this._onreadCalled=!0),{bytes:this._bytes,view:this._view,offset:0}}_dispose(){}}const j7=.5*2**20,IF=((t,e,r)=>{if(e instanceof Error&&(e.message.includes("Failed to fetch")||e.message.includes("Load failed")||e.message.includes("NetworkError when attempting to fetch resource"))){let i=null;try{typeof window<"u"&&typeof window.location<"u"&&(i=new URL(r instanceof Request?r.url:r,window.location.href).origin)}catch{}if((typeof navigator<"u"&&typeof navigator.onLine=="boolean"?navigator.onLine:!0)&&i!==null&&i!==window.location.origin)return console.warn("Request will not be retried because a CORS error was suspected due to different origins. You can modify this behavior by providing your own function for the 'getRetryDelay' option."),null}return Math.min(2**(t-2),16)});class LF extends Xb{constructor(e,r={}){if(typeof e!="string"&&!(e instanceof URL)&&!(typeof Request<"u"&&e instanceof Request))throw new TypeError("url must be a string, URL or Request.");if(!r||typeof r!="object")throw new TypeError("options must be an object.");if(r.requestInit!==void 0&&(!r.requestInit||typeof r.requestInit!="object"))throw new TypeError("options.requestInit, when provided, must be an object.");if(r.getRetryDelay!==void 0&&typeof r.getRetryDelay!="function")throw new TypeError("options.getRetryDelay, when provided, must be a function.");if(r.maxCacheSize!==void 0&&(!s7(r.maxCacheSize)||r.maxCacheSize<0))throw new TypeError("options.maxCacheSize, when provided, must be a non-negative number.");if(r.fetchFn!==void 0&&typeof r.fetchFn!="function")throw new TypeError("options.fetchFn, when provided, must be a function.");super(),this._existingResponses=new WeakMap,this._url=e,this._options=r,this._getRetryDelay=r.getRetryDelay??IF,this._orchestrator=new MF({maxCacheSize:r.maxCacheSize??64*2**20,maxWorkerCount:2,runWorker:this._runWorker.bind(this),prefetchProfile:RF.network})}async _retrieveSize(){const e=new AbortController,r=await Y6(this._options.fetchFn??fetch,this._url,G6(this._options.requestInit??{},{headers:{Range:"bytes=0-"},signal:e.signal}),this._getRetryDelay,()=>this._disposed);if(!r.ok)throw new Error(`Error fetching ${String(this._url)}: ${r.status} ${r.statusText}`);let n,i;if(r.status===206)i=this._getTotalLengthFromRangeResponse(r),n=this._orchestrator.createWorker(0,Math.min(i,j7));else{const a=r.headers.get("Content-Length");if(a)i=Number(a),n=this._orchestrator.createWorker(0,i),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 new Error(`HTTP response (status ${r.status}) must surface Content-Length header.`)}return this._orchestrator.fileSize=i,this._existingResponses.set(n,{response:r,abortController:e}),this._orchestrator.runWorker(n),i}_read(e,r){return this._orchestrator.read(e,r)}async _runWorker(e){for(;;){const r=this._existingResponses.get(e);this._existingResponses.delete(e);let n=r?.abortController,i=r?.response;if(n||(n=new AbortController,i=await Y6(this._options.fetchFn??fetch,this._url,G6(this._options.requestInit??{},{headers:{Range:`bytes=${e.currentPos}-`},signal:n.signal}),this._getRetryDelay,()=>this._disposed)),$e(i),!i.ok)throw new Error(`Error fetching ${String(this._url)}: ${i.status} ${i.statusText}`);if(e.currentPos>0&&i.status!==206)throw new 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(!i.body)throw new Error("Missing HTTP response body stream. The used fetch function must provide the response body as a ReadableStream.");const a=i.body.getReader();for(;;){if(e.currentPos>=e.targetPos||e.aborted){n.abort(),e.running=!1;return}let o;try{o=await a.read()}catch(c){if(this._disposed)throw c;const f=this._getRetryDelay(1,c,this._url);if(f!==null){console.error("Error while reading response stream. Attempting to resume.",c),await new Promise(h=>setTimeout(h,1e3*f));break}else throw c}if(e.aborted)break;const{done:s,value:l}=o;if(s){if(e.currentPos>=e.targetPos){this._orchestrator.forgetWorker(e),e.running=!1;return}break}this.onread?.(e.currentPos,e.currentPos+l.length),this._orchestrator.supplyWorkerData(e,l)}if(e.aborted)break}e.running=!1}_getTotalLengthFromRangeResponse(e){const r=e.headers.get("Content-Range");if(r){const i=/\/(\d+)/.exec(r);if(i)return Number(i[1])}const n=e.headers.get("Content-Length");if(n)return Number(n);throw new Error("Partial HTTP response (status 206) must surface either Content-Range or Content-Length header.")}_dispose(){this._orchestrator.dispose()}}const RF={network:(t,e,r)=>{t=Math.max(0,Math.floor((t-65536)/65536)*65536);for(const i of r){const o=Math.max((i.startPos+i.targetPos)/2,i.targetPos-8388608);if(R5(t,e,o,i.targetPos)){const s=i.targetPos-i.startPos,l=Math.ceil((s+1)/8388608)*8388608,c=2**Math.ceil(Math.log2(s+1)),f=Math.min(c,l);e=Math.max(e,i.startPos+f)}}return e=Math.max(e,t+j7),{start:t,end:e}}};class MF{constructor(e){this.options=e,this.fileSize=null,this.nextAge=0,this.workers=[],this.cache=[],this.currentCacheSize=0,this.disposed=!1}read(e,r){$e(this.fileSize!==null);const n=this.options.prefetchProfile(e,r,this.workers),i=Math.max(n.start,0),a=Math.min(n.end,this.fileSize);$e(i<=e&&r<=a);let o=null;const s=oi(this.cache,e,S=>S.start),l=s!==-1?this.cache[s]:null;l&&l.start<=e&&r<=l.end&&(l.age=this.nextAge++,o={bytes:l.bytes,view:l.view,offset:l.start});const c=oi(this.cache,i,S=>S.start),f=o?null:new Uint8Array(r-e);let h=0,d=i;const p=[];if(c!==-1){for(let S=c;S<this.cache.length;S++){const E=this.cache[S];if(E.start>=a)break;if(E.end<=i)continue;const _=Math.max(i,E.start),P=Math.min(a,E.end);if($e(_<=P),d<_&&p.push({start:d,end:_}),d=P,f){const O=Math.max(e,E.start),T=Math.min(r,E.end);if(O<T){const N=O-e;f.set(E.bytes.subarray(O-E.start,T-E.start),N),N===h&&(h=T-e)}}E.age=this.nextAge++}d<a&&p.push({start:d,end:a})}else p.push({start:i,end:a});if(f&&h>=f.length&&(o={bytes:f,view:Wa(f),offset:e}),p.length===0)return $e(o),o;const{promise:y,resolve:w,reject:x}=wl(),b=[];for(const S of p){const E=Math.max(e,S.start),_=Math.min(r,S.end);E===S.start&&_===S.end?b.push(S):E<_&&b.push({start:E,end:_})}for(const S of p){const E=f&&{start:e,bytes:f,holes:b,resolve:w,reject:x};let _=!1;for(const P of this.workers)if(R5(S.start-131072,S.start,P.currentPos,P.targetPos)){P.targetPos=Math.max(P.targetPos,S.end),_=!0,E&&!P.pendingSlices.includes(E)&&P.pendingSlices.push(E),P.running||this.runWorker(P);break}if(!_){const P=this.createWorker(S.start,S.end);E&&(P.pendingSlices=[E]),this.runWorker(P)}}return o||($e(f),o=y.then(S=>({bytes:S,view:Wa(S),offset:e}))),o}createWorker(e,r){const n={startPos:e,currentPos:e,targetPos:r,running:!1,aborted:this.disposed,pendingSlices:[],age:this.nextAge++};for(this.workers.push(n);this.workers.length>this.options.maxWorkerCount;){let i=0,a=this.workers[0];for(let o=1;o<this.workers.length;o++){const s=this.workers[o];s.age<a.age&&(i=o,a=s)}if(a.running&&a.pendingSlices.length>0)break;a.aborted=!0,this.workers.splice(i,1)}return n}runWorker(e){$e(!e.running),$e(e.currentPos<e.targetPos),e.running=!0,e.age=this.nextAge++,this.options.runWorker(e).catch(r=>{if(e.running=!1,e.pendingSlices.length>0)e.pendingSlices.forEach(n=>n.reject(r)),e.pendingSlices.length=0;else throw r})}supplyWorkerData(e,r){$e(!e.aborted);const n=e.currentPos,i=n+r.length;this.insertIntoCache({start:n,end:i,bytes:r,view:Wa(r),age:this.nextAge++}),e.currentPos+=r.length,e.targetPos=Math.max(e.targetPos,e.currentPos);for(let a=0;a<e.pendingSlices.length;a++){const o=e.pendingSlices[a],s=Math.max(n,o.start),l=Math.min(i,o.start+o.bytes.length);s<l&&o.bytes.set(r.subarray(s-n,l-n),s-o.start);for(let c=0;c<o.holes.length;c++){const f=o.holes[c];n<=f.start&&i>f.start&&(f.start=i),f.end<=f.start&&(o.holes.splice(c,1),c--)}o.holes.length===0&&(o.resolve(o.bytes),e.pendingSlices.splice(a,1),a--)}for(let a=0;a<this.workers.length;a++){const o=this.workers[a];e===o||o.running||R5(n,i,o.currentPos,o.targetPos)&&(this.workers.splice(a,1),a--)}}forgetWorker(e){const r=this.workers.indexOf(e);$e(r!==-1),this.workers.splice(r,1)}insertIntoCache(e){if(this.options.maxCacheSize===0)return;let r=oi(this.cache,e.start,n=>n.start)+1;if(r>0){const n=this.cache[r-1];if(n.end>=e.end)return;if(n.end>e.start){const i=new Uint8Array(e.end-n.start);i.set(n.bytes,0),i.set(e.bytes,e.start-n.start),this.currentCacheSize+=e.end-n.end,n.bytes=i,n.view=Wa(i),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(let n=r+1;n<this.cache.length;n++){const i=this.cache[n];if(e.end<=i.start)break;if(e.end>=i.end){this.cache.splice(n,1),this.currentCacheSize-=i.bytes.length,n--;continue}const a=new Uint8Array(i.end-e.start);a.set(e.bytes,0),a.set(i.bytes,i.start-e.start),this.currentCacheSize-=e.end-i.start,e.bytes=a,e.view=Wa(a),e.end=i.end,this.cache.splice(n,1);break}for(;this.currentCacheSize>this.options.maxCacheSize;){let n=0,i=this.cache[0];for(let a=1;a<this.cache.length;a++){const o=this.cache[a];o.age<i.age&&(n=a,i=o)}if(this.currentCacheSize-i.bytes.length<=this.options.maxCacheSize)break;this.cache.splice(n,1),this.currentCacheSize-=i.bytes.length}}dispose(){for(const e of this.workers)e.aborted=!0;this.workers.length=0,this.cache.length=0,this.disposed=!0}}o7();class DF{get disposed(){return this._disposed}constructor(e){if(this._demuxerPromise=null,this._format=null,this._disposed=!1,!e||typeof e!="object")throw new TypeError("options must be an object.");if(!Array.isArray(e.formats)||e.formats.some(r=>!(r instanceof _h)))throw new TypeError("options.formats must be an array of InputFormat.");if(!(e.source instanceof Xb))throw new TypeError("options.source must be a Source.");if(e.source._disposed)throw new Error("options.source must not be disposed.");this._formats=e.formats,this._source=e.source,this._reader=new FF(e.source)}_getDemuxer(){return this._demuxerPromise??=(async()=>{this._reader.fileSize=await this._source.getSizeOrNull();for(const e of this._formats)if(await e._canReadInput(this))return this._format=e,e._createDemuxer(this);throw new Error("Input has an unsupported or unrecognizable format.")})()}get source(){return this._source}async getFormat(){return await this._getDemuxer(),$e(this._format),this._format}async computeDuration(){return(await this._getDemuxer()).computeDuration()}async getTracks(){return(await this._getDemuxer()).getTracks()}async getVideoTracks(){return(await this.getTracks()).filter(r=>r.isVideoTrack())}async getAudioTracks(){return(await this.getTracks()).filter(r=>r.isAudioTrack())}async getPrimaryVideoTrack(){return(await this.getTracks()).find(r=>r.isVideoTrack())??null}async getPrimaryAudioTrack(){return(await this.getTracks()).find(r=>r.isAudioTrack())??null}async getMimeType(){return(await this._getDemuxer()).getMimeType()}async getMetadataTags(){return(await this._getDemuxer()).getMetadataTags()}dispose(){this._disposed||(this._disposed=!0,this._source._disposed=!0,this._source._dispose())}[Symbol.dispose](){this.dispose()}}class xl extends Error{constructor(e="Input has been disposed."){super(e),this.name="InputDisposedError"}}class FF{constructor(e){this.source=e}requestSlice(e,r){if(this.source._disposed)throw new xl;if(this.fileSize!==null&&e+r>this.fileSize)return null;const n=e+r,i=this.source._read(e,n);return i instanceof Promise?i.then(a=>a?new Rp(a.bytes,a.view,a.offset,e,n):null):i?new Rp(i.bytes,i.view,i.offset,e,n):null}requestSliceRange(e,r,n){if(this.source._disposed)throw new xl;if(this.fileSize!==null)return this.requestSlice(e,vp(this.fileSize-e,r,n));{const i=this.requestSlice(e,n),a=o=>{if(o)return o;const s=c=>($e(c!==null),this.requestSlice(e,vp(c-e,r,n))),l=this.source._retrieveSize();return l instanceof Promise?l.then(s):s(l)};return i instanceof Promise?i.then(a):a(i)}}}class Rp{constructor(e,r,n,i,a){this.bytes=e,this.view=r,this.offset=n,this.start=i,this.end=a,this.bufferPos=i-n}static tempFromBytes(e){return new Rp(e,Wa(e),0,0,e.length)}get length(){return this.end-this.start}get filePos(){return this.offset+this.bufferPos}set filePos(e){this.bufferPos=e-this.offset}get remainingLength(){return Math.max(this.end-this.filePos,0)}skip(e){this.bufferPos+=e}slice(e,r=this.end-e){if(e<this.start||e+r>this.end)throw new RangeError("Slicing outside of original slice.");return new Rp(this.bytes,this.view,this.offset,e,e+r)}}const Zs=(t,e)=>{if(t.filePos<t.start||t.filePos+e>t.end)throw new RangeError(`Tried reading [${t.filePos}, ${t.filePos+e}), but slice is [${t.start}, ${t.end}). This is likely an internal error, please report it alongside the file that caused it.`)},Nr=(t,e)=>{Zs(t,e);const r=t.bytes.subarray(t.bufferPos,t.bufferPos+e);return t.bufferPos+=e,r},dr=t=>(Zs(t,1),t.view.getUint8(t.bufferPos++)),f0=(t,e)=>{Zs(t,2);const r=t.view.getUint16(t.bufferPos,e);return t.bufferPos+=2,r},ts=t=>{Zs(t,2);const e=t.view.getUint16(t.bufferPos,!1);return t.bufferPos+=2,e},np=t=>{Zs(t,3);const e=Xm(t.view,t.bufferPos,!1);return t.bufferPos+=3,e},H5=t=>{Zs(t,2);const e=t.view.getInt16(t.bufferPos,!1);return t.bufferPos+=2,e},ah=(t,e)=>{Zs(t,4);const r=t.view.getUint32(t.bufferPos,e);return t.bufferPos+=4,r},Dt=t=>{Zs(t,4);const e=t.view.getUint32(t.bufferPos,!1);return t.bufferPos+=4,e},pp=t=>{Zs(t,4);const e=t.view.getUint32(t.bufferPos,!0);return t.bufferPos+=4,e},Kh=t=>{Zs(t,4);const e=t.view.getInt32(t.bufferPos,!1);return t.bufferPos+=4,e},BF=t=>{Zs(t,4);const e=t.view.getInt32(t.bufferPos,!0);return t.bufferPos+=4,e},cx=(t,e)=>{let r,n;return e?(r=ah(t,!0),n=ah(t,!0)):(n=ah(t,!1),r=ah(t,!1)),n*4294967296+r},xu=t=>{const e=Dt(t),r=Dt(t);return e*4294967296+r},jF=t=>{const e=Kh(t),r=Dt(t);return e*4294967296+r},zF=t=>{const e=pp(t);return BF(t)*4294967296+e},UF=t=>{Zs(t,4);const e=t.view.getFloat32(t.bufferPos,!1);return t.bufferPos+=4,e},z7=t=>{Zs(t,8);const e=t.view.getFloat64(t.bufferPos,!1);return t.bufferPos+=8,e},Fo=(t,e)=>{Zs(t,e);let r="";for(let n=0;n<e;n++)r+=String.fromCharCode(t.bytes[t.bufferPos++]);return r},Yd=.05,qF=(t,e,r)=>{const[n,i]=oe.useState({input:null,videoSink:null,duration:0,isReady:!1,error:null});oe.useRef(n).current=n;const a=oe.useRef(0),o=oe.useRef(null),s=oe.useRef(null),l=oe.useRef(null),c=oe.useRef(null),f=oe.useRef(null),h=oe.useRef(null),d=oe.useRef(!1),p=oe.useRef(null),y=oe.useRef([]),w=oe.useRef(null),x=oe.useRef(!1),[,b]=oe.useReducer(S=>S+1,0);return oe.useEffect(()=>{if(!r)return;let S=!0;const E=++a.current;let _=null;return(async()=>{try{if(!S||E!==a.current)return;_=rf(`mediabunny init ${t.id}`);const P=await(async function(A){if((function(L){return L.startsWith("data:")})(A)){const L=(function(H){const U=H.indexOf(",");if(U===-1)throw new Error("Invalid data URL format");const ee=H.slice(U+1),se=atob(ee),te=new Uint8Array(se.length);for(let Z=0;Z<se.length;Z++)te[Z]=se.charCodeAt(Z);return te.buffer})(A);return new ux(L)}if((function(L){return L.startsWith("file://")})(A))try{const L=await fetch(A),H=await L.arrayBuffer();return new ux(H)}catch(L){throw new Error(`Failed to load file URL: ${A}. File URLs may not be supported in this environment. Error: ${L}`)}return new LF(A)})(t.src);if(!S||E!==a.current)return void(_&&(_(),_=null));const O=new DF({source:P,formats:NF}),T=await O.computeDuration(),N=await O.getPrimaryVideoTrack();if(!N)throw new Error("No video track found");if(N.codec===null)throw new Error("Unsupported video codec");if(!await N.canDecode())throw new Error("Unable to decode the video track");const D=await N.canBeTransparent(),F=new yD(N,{poolSize:5,fit:"contain",alpha:D});if(!S||E!==a.current)return O.dispose(),void(_&&(_(),_=null));_&&(_(),_=null),i(A=>Object.assign(Object.assign({},A),{input:O,videoSink:F,duration:T,isReady:!0,error:null}))}catch(P){if(console.error("Failed to initialize mediabunny:",P),_&&(_(),_=null),S&&E===a.current){const O=`Failed to initialize mediabunny for video ${t.id}: ${P}`;zp(O),i(T=>Object.assign(Object.assign({},T),{error:String(P),isReady:!1}))}}})(),()=>{S=!1,_&&(_(),_=null)}},[t.src,r]),oe.useEffect(()=>()=>{s.current&&(s.current.return(),s.current=null),o.current&&(o.current(),o.current=null),l.current=null,c.current=null,f.current=null,d.current=!1,p.current=null,y.current=[],w.current=null,x.current=!1,i({input:null,videoSink:null,duration:0,isReady:!1,error:null})},[r]),oe.useEffect(()=>{if(!r||!n.isReady||!n.videoSink)return;const S=++a.current,E=typeof t.src=="string"?t.src.slice(0,120):String(t.src),_=(L,H={},U="debug")=>{const ee=Object.assign({event:L,elementId:t.id,targetTime:f.current,duration:n.duration,lastFrameTimestamp:c.current,hasIterator:!!s.current,prefetchSize:y.current.length,srcHint:E,timeCalc:h.current},H);U==="error"?console.error("mediabunny:",ee):U==="warn"?console.warn("mediabunny:",ee):console.debug("mediabunny:",ee)},P=L=>{const H=n.duration||0;if(!H||!Number.isFinite(H))return L;const U=H>Yd?H-Yd:H;return Math.max(0,Math.min(L,U))},O=L=>{let H=l.current;H&&H.width===L.canvas.width&&H.height===L.canvas.height||(H||(H=document.createElement("canvas"),l.current=H),H.width=L.canvas.width,H.height=L.canvas.height);const U=H.getContext("2d");U&&(U.clearRect(0,0,H.width,H.height),U.drawImage(L.canvas,0,0)),c.current=L.timestamp},T=L=>{const H=s.current;H&&(x.current||(x.current=!0,w.current=(async()=>{try{for(;y.current.length<4&&L===a.current;){const U=await H.next();if(L!==a.current)return;if(U.done||!U.value)break;y.current.push({timestamp:U.value.timestamp,frame:U.value})}}catch{}finally{x.current=!1,w.current=null}})()))},N=L=>{const H=y.current;for(let U=0;U<H.length;U++)if(Math.abs(H[U].timestamp-L)<Yd){const ee=H[U];return y.current=H.slice(U+1),ee}return null},D=()=>{y.current=[]},F=async(L,H,U=0)=>{const ee=P(L),se=(te=>{const Z=c.current;return Z===null||te<Z-Yd||te>Z+.5})(ee)?"seek":"iterate";try{const te=n.videoSink,Z=c.current;if(Z!==null&&Math.abs(Z-ee)<Yd)return void(f.current=L);const ne=N(ee);if(ne)return O(ne.frame),f.current=L,T(H),void b();if(w.current){await w.current;const G=N(ee);if(G)return O(G.frame),f.current=L,T(H),void b()}if(D(),se==="seek"){s.current&&(await s.current.return(),s.current=null);const G=te.canvases(ee);s.current=G;const j=await G.next();if(H!==a.current)return void(s.current&&(await s.current.return(),s.current=null));if(j.done||!j.value){if(_("iterator_exhausted",{mode:se,requestedTargetTime:L,clampedTargetTime:ee},"warn"),H===a.current)try{s.current&&(await s.current.return(),s.current=null),D();const B=te.canvases(ee);s.current=B;const z=await B.next();!z.done&&z.value&&(O(z.value),T(H),f.current=L,b())}catch{}return}O(j.value),T(H)}else{const G=s.current;if(!G)return;let j=!1;for(;H===a.current;){const B=await G.next();if(H!==a.current)break;if(B.done||!B.value){if(_("iterator_exhausted",{mode:se,requestedTargetTime:L,clampedTargetTime:ee},"warn"),!j){j=!0;try{s.current&&(await s.current.return(),s.current=null),D();const Y=te.canvases(ee);s.current=Y;const Q=await Y.next();if(H!==a.current||Q.done||!Q.value)break;O(Q.value),T(H);break}catch{break}}break}const z=B.value;if(O(z),Math.abs(z.timestamp-ee)<Yd){T(H);break}if(z.timestamp>ee){T(H);break}}}f.current=L,b()}catch(te){const Z=te instanceof Error?{name:te.name,message:te.message,stack:te.stack}:{message:String(te)},ne=te instanceof Error?`${te.name}: ${te.message}`:String(te),G=ne.includes("Unsupported configuration")||ne.includes("isConfigSupported")||ne.includes("OperationError");if(_("frame_process_failed",{mode:se,requestedTargetTime:L,clampedTargetTime:ee,unsupportedConfigAttempt:U,isUnsupportedConfig:G,error:Z},"error"),G&&U<1)try{s.current&&(await s.current.return(),s.current=null),D(),w.current=null,x.current=!1,c.current=null,await F(L,H,U+1)}catch{}}},A=Tu(()=>{const L=n.videoSink,H=n.duration;if(!L||!H)return;const U=t.startTime*H*1e3,ee=H*(t.endTime-t.startTime)*1e3,se=((e.currentTime||t.page.startTime)-t.page.startTime)%ee+U,te=se/1e3,Z=P(te);h.current={pageStartTime:t.page.startTime,storeCurrentTime:e.currentTime,offsetMs:U,durationMs:ee,restMs:se,targetTime:te,clampedTargetTime:Z,startTime:t.startTime,endTime:t.endTime,videoDuration:H},((ne,G)=>{d.current?p.current=ne:(d.current=!0,o.current||(o.current=rf(`mediabunny video frame ${t.id}`)),(async()=>{let j=ne;for(;j!==null&&G===a.current;)await F(j,G),j=p.current,p.current=null;o.current&&(o.current(),o.current=null),d.current=!1})())})(Z,S)});return()=>{A(),a.current++,o.current&&(o.current(),o.current=null)}},[r,n.isReady,n.videoSink,n.duration,e,t]),r&&n.isReady?l.current:null};function wp(){return document.createElement("canvas")}const U7=new window.Image;U7.src=ff(`
|
|
280
|
+
`),n=this.gl.createProgram();return this.gl.attachShader(n,e),this.gl.attachShader(n,r),this.gl.linkProgram(n),n}createShader(e,r){const n=this.gl.createShader(e);return this.gl.shaderSource(n,r),this.gl.compileShader(n),n}createVAO(){const e=this.gl.createVertexArray();this.gl.bindVertexArray(e);const 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);const i=this.gl.getAttribLocation(this.program,"a_position"),a=this.gl.getAttribLocation(this.program,"a_texCoord");return this.gl.enableVertexAttribArray(i),this.gl.vertexAttribPointer(i,2,this.gl.FLOAT,!1,16,0),this.gl.enableVertexAttribArray(a),this.gl.vertexAttribPointer(a,2,this.gl.FLOAT,!1,16,8),e}createTexture(){const 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}update(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)}close(){this.gl.getExtension("WEBGL_lose_context")?.loseContext(),this.gl=null}}class vD extends P7{constructor(e){if(!(e instanceof b1))throw new TypeError("videoTrack must be an InputVideoTrack.");super(),this._track=e}async _createDecoder(e,r){if(!await this._track.canDecode())throw new Error("This video track cannot be decoded by this browser. Make sure to check decodability before using a track.");const n=this._track.codec,i=this._track.rotation,a=await this._track.getDecoderConfig(),o=this._track.timeResolution;return $e(n&&a),new gD(e,r,n,a,i,o)}_createPacketSink(){return new Vb(this._track)}async getSample(e){tf(e);for await(const r of this.mediaSamplesAtTimestamps([e]))return r;throw new Error("Internal error: Iterator returned nothing.")}samples(e=0,r=1/0){return this.mediaSamplesInRange(e,r)}samplesAtTimestamps(e){return this.mediaSamplesAtTimestamps(e)}}class yD{constructor(e,r={}){if(this._nextCanvasIndex=0,!(e instanceof b1))throw new TypeError("videoTrack must be an InputVideoTrack.");if(r&&typeof r!="object")throw new TypeError("options must be an object.");if(r.alpha!==void 0&&typeof r.alpha!="boolean")throw new TypeError("options.alpha, when provided, must be a boolean.");if(r.width!==void 0&&(!Number.isInteger(r.width)||r.width<=0))throw new TypeError("options.width, when defined, must be a positive integer.");if(r.height!==void 0&&(!Number.isInteger(r.height)||r.height<=0))throw new TypeError("options.height, when defined, must be a positive integer.");if(r.fit!==void 0&&!["fill","contain","cover"].includes(r.fit))throw new TypeError('options.fit, when provided, must be one of "fill", "contain", or "cover".');if(r.width!==void 0&&r.height!==void 0&&r.fit===void 0)throw new TypeError("When both options.width and options.height are provided, options.fit must also be provided.");if(r.rotation!==void 0&&![0,90,180,270].includes(r.rotation))throw new TypeError("options.rotation, when provided, must be 0, 90, 180 or 270.");if(r.crop!==void 0&&E7(r.crop,"options."),r.poolSize!==void 0&&(typeof r.poolSize!="number"||!Number.isInteger(r.poolSize)||r.poolSize<0))throw new TypeError("poolSize must be a non-negative integer.");const n=r.rotation??e.rotation,[i,a]=n%180===0?[e.codedWidth,e.codedHeight]:[e.codedHeight,e.codedWidth],o=r.crop;o&&k7(o,i,a);let[s,l]=o?[o.width,o.height]:[i,a];const c=s/l;r.width!==void 0&&r.height===void 0?(s=r.width,l=Math.round(s/c)):r.width===void 0&&r.height!==void 0?(l=r.height,s=Math.round(l*c)):r.width!==void 0&&r.height!==void 0&&(s=r.width,l=r.height),this._videoTrack=e,this._alpha=r.alpha??!1,this._width=s,this._height=l,this._rotation=n,this._crop=o,this._fit=r.fit??"fill",this._videoSampleSink=new vD(e),this._canvasPool=Array.from({length:r.poolSize??0},()=>null)}_videoSampleToWrappedCanvas(e){let r=this._canvasPool[this._nextCanvasIndex],n=!1;r||(typeof document<"u"?(r=document.createElement("canvas"),r.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);const i=r.getContext("2d",{alpha:this._alpha||L5()});$e(i),i.resetTransform(),n||(!this._alpha&&L5()?(i.fillStyle="black",i.fillRect(0,0,this._width,this._height)):i.clearRect(0,0,this._width,this._height)),e.drawWithFit(i,{fit:this._fit,rotation:this._rotation,crop:this._crop});const a={canvas:r,timestamp:e.timestamp,duration:e.duration};return e.close(),a}async getCanvas(e){tf(e);const r=await this._videoSampleSink.getSample(e);return r&&this._videoSampleToWrappedCanvas(r)}canvases(e=0,r=1/0){return cm(this._videoSampleSink.samples(e,r),n=>this._videoSampleToWrappedCanvas(n))}canvasesAtTimestamps(e){return cm(this._videoSampleSink.samplesAtTimestamps(e),r=>r&&this._videoSampleToWrappedCanvas(r))}}class bD extends $b{constructor(e,r,n,i){super(e,r),this.decoder=null,this.customDecoder=null,this.customDecoderCallSerializer=new i7,this.customDecoderQueueSize=0,this.currentTimestamp=null;const a=s=>{(this.currentTimestamp===null||Math.abs(s.timestamp-this.currentTimestamp)>=s.duration)&&(this.currentTimestamp=s.timestamp);const l=this.currentTimestamp;if(this.currentTimestamp+=s.duration,s.numberOfFrames===0){s.close();return}const c=i.sampleRate;s.setTimestamp(Math.round(l*c)/c),e(s)},o=S7.find(s=>s.supports(n,i));if(o)this.customDecoder=new o,this.customDecoder.codec=n,this.customDecoder.config=i,this.customDecoder.onSample=s=>{if(!(s instanceof ih))throw new TypeError("The argument passed to onSample must be an AudioSample.");a(s)},this.customDecoderCallSerializer.call(()=>this.customDecoder.init());else{const s=new Error("Decoding error").stack;this.decoder=new AudioDecoder({output:l=>{try{a(new ih(l))}catch(c){this.onError(c)}},error:l=>{l.stack=s,this.onError(l)}}),this.decoder.configure(i)}}getDecodeQueueSize(){return this.customDecoder?this.customDecoderQueueSize:($e(this.decoder),this.decoder.decodeQueueSize)}decode(e){this.customDecoder?(this.customDecoderQueueSize++,this.customDecoderCallSerializer.call(()=>this.customDecoder.decode(e)).then(()=>this.customDecoderQueueSize--)):($e(this.decoder),this.decoder.decode(e.toEncodedAudioChunk()))}flush(){return this.customDecoder?this.customDecoderCallSerializer.call(()=>this.customDecoder.flush()):($e(this.decoder),this.decoder.flush())}close(){this.customDecoder?this.customDecoderCallSerializer.call(()=>this.customDecoder.close()):($e(this.decoder),this.decoder.close())}}class wD extends $b{constructor(e,r,n){super(e,r),this.decoderConfig=n,this.currentTimestamp=null,$e(of.includes(n.codec)),this.codec=n.codec;const{dataType:i,sampleSize:a,littleEndian:o}=d7(this.codec);switch(this.inputSampleSize=a,a){case 1:i==="unsigned"?this.readInputValue=(s,l)=>s.getUint8(l)-2**7:i==="signed"?this.readInputValue=(s,l)=>s.getInt8(l):i==="ulaw"?this.readInputValue=(s,l)=>lD(s.getUint8(l)):i==="alaw"?this.readInputValue=(s,l)=>uD(s.getUint8(l)):$e(!1);break;case 2:i==="unsigned"?this.readInputValue=(s,l)=>s.getUint16(l,o)-2**15:i==="signed"?this.readInputValue=(s,l)=>s.getInt16(l,o):$e(!1);break;case 3:i==="unsigned"?this.readInputValue=(s,l)=>Xm(s,l,o)-2**23:i==="signed"?this.readInputValue=(s,l)=>RM(s,l,o):$e(!1);break;case 4:i==="unsigned"?this.readInputValue=(s,l)=>s.getUint32(l,o)-2**31:i==="signed"?this.readInputValue=(s,l)=>s.getInt32(l,o):i==="float"?this.readInputValue=(s,l)=>s.getFloat32(l,o):$e(!1);break;case 8:i==="float"?this.readInputValue=(s,l)=>s.getFloat64(l,o):$e(!1);break;default:Lp(a),$e(!1)}switch(a){case 1:i==="ulaw"||i==="alaw"?(this.outputSampleSize=2,this.outputFormat="s16",this.writeOutputValue=(s,l,c)=>s.setInt16(l,c,!0)):(this.outputSampleSize=1,this.outputFormat="u8",this.writeOutputValue=(s,l,c)=>s.setUint8(l,c+2**7));break;case 2:this.outputSampleSize=2,this.outputFormat="s16",this.writeOutputValue=(s,l,c)=>s.setInt16(l,c,!0);break;case 3:this.outputSampleSize=4,this.outputFormat="s32",this.writeOutputValue=(s,l,c)=>s.setInt32(l,c<<8,!0);break;case 4:this.outputSampleSize=4,i==="float"?(this.outputFormat="f32",this.writeOutputValue=(s,l,c)=>s.setFloat32(l,c,!0)):(this.outputFormat="s32",this.writeOutputValue=(s,l,c)=>s.setInt32(l,c,!0));break;case 8:this.outputSampleSize=4,this.outputFormat="f32",this.writeOutputValue=(s,l,c)=>s.setFloat32(l,c,!0);break;default:Lp(a),$e(!1)}}getDecodeQueueSize(){return 0}decode(e){const r=Wa(e.data),n=e.byteLength/this.decoderConfig.numberOfChannels/this.inputSampleSize,i=n*this.decoderConfig.numberOfChannels*this.outputSampleSize,a=new ArrayBuffer(i),o=new DataView(a);for(let f=0;f<n*this.decoderConfig.numberOfChannels;f++){const h=f*this.inputSampleSize,d=f*this.outputSampleSize,p=this.readInputValue(r,h);this.writeOutputValue(o,d,p)}const s=n/this.decoderConfig.sampleRate;(this.currentTimestamp===null||Math.abs(e.timestamp-this.currentTimestamp)>=s)&&(this.currentTimestamp=e.timestamp);const l=this.currentTimestamp;this.currentTimestamp+=s;const c=new ih({format:this.outputFormat,data:a,numberOfChannels:this.decoderConfig.numberOfChannels,sampleRate:this.decoderConfig.sampleRate,numberOfFrames:n,timestamp:l});this.onSample(c)}async flush(){}close(){}}class xD extends P7{constructor(e){if(!(e instanceof xc))throw new TypeError("audioTrack must be an InputAudioTrack.");super(),this._track=e}async _createDecoder(e,r){if(!await this._track.canDecode())throw new Error("This audio track cannot be decoded by this browser. Make sure to check decodability before using a track.");const n=this._track.codec,i=await this._track.getDecoderConfig();return $e(n&&i),of.includes(i.codec)?new wD(e,r,i):new bD(e,r,n,i)}_createPacketSink(){return new Vb(this._track)}async getSample(e){tf(e);for await(const r of this.mediaSamplesAtTimestamps([e]))return r;throw new Error("Internal error: Iterator returned nothing.")}samples(e=0,r=1/0){return this.mediaSamplesInRange(e,r)}samplesAtTimestamps(e){return this.mediaSamplesAtTimestamps(e)}}class yH{constructor(e){if(!(e instanceof xc))throw new TypeError("audioTrack must be an InputAudioTrack.");this._audioSampleSink=new xD(e)}_audioSampleToWrappedArrayBuffer(e){const r={buffer:e.toAudioBuffer(),timestamp:e.timestamp,duration:e.duration};return e.close(),r}async getBuffer(e){tf(e);const r=await this._audioSampleSink.getSample(e);return r&&this._audioSampleToWrappedArrayBuffer(r)}buffers(e=0,r=1/0){return cm(this._audioSampleSink.samples(e,r),n=>this._audioSampleToWrappedArrayBuffer(n))}buffersAtTimestamps(e){return cm(this._audioSampleSink.samplesAtTimestamps(e),r=>r&&this._audioSampleToWrappedArrayBuffer(r))}}class Wb{constructor(e,r){this.input=e,this._backing=r}isVideoTrack(){return this instanceof b1}isAudioTrack(){return this instanceof xc}get id(){return this._backing.getId()}get internalCodecId(){return this._backing.getInternalCodecId()}get languageCode(){return this._backing.getLanguageCode()}get name(){return this._backing.getName()}get timeResolution(){return this._backing.getTimeResolution()}get disposition(){return this._backing.getDisposition()}getFirstTimestamp(){return this._backing.getFirstTimestamp()}computeDuration(){return this._backing.computeDuration()}async computePacketStats(e=1/0){const r=new Vb(this);let n=1/0,i=-1/0,a=0,o=0;for await(const s of r.packets(void 0,void 0,{metadataOnly:!0})){if(a>=e&&s.timestamp>=i)break;n=Math.min(n,s.timestamp),i=Math.max(i,s.timestamp+s.duration),a++,o+=s.byteLength}return{packetCount:a,averagePacketRate:a?Number((a/(i-n)).toPrecision(16)):0,averageBitrate:a?Number((8*o/(i-n)).toPrecision(16)):0}}}class b1 extends Wb{constructor(e,r){super(e,r),this._backing=r}get type(){return"video"}get codec(){return this._backing.getCodec()}get codedWidth(){return this._backing.getCodedWidth()}get codedHeight(){return this._backing.getCodedHeight()}get rotation(){return this._backing.getRotation()}get displayWidth(){return this._backing.getRotation()%180===0?this._backing.getCodedWidth():this._backing.getCodedHeight()}get displayHeight(){return this._backing.getRotation()%180===0?this._backing.getCodedHeight():this._backing.getCodedWidth()}getColorSpace(){return this._backing.getColorSpace()}async hasHighDynamicRange(){const e=await this._backing.getColorSpace();return e.primaries==="bt2020"||e.primaries==="smpte432"||e.transfer==="pg"||e.transfer==="hlg"||e.matrix==="bt2020-ncl"}canBeTransparent(){return this._backing.canBeTransparent()}getDecoderConfig(){return this._backing.getDecoderConfig()}async getCodecParameterString(){return(await this._backing.getDecoderConfig())?.codec??null}async canDecode(){try{const e=await this._backing.getDecoderConfig();if(!e)return!1;const r=this._backing.getCodec();return $e(r!==null),x7.some(i=>i.supports(r,e))?!0:typeof VideoDecoder>"u"?!1:(await VideoDecoder.isConfigSupported(e)).supported===!0}catch(e){return console.error("Error during decodability check:",e),!1}}async determinePacketType(e){if(!(e instanceof Bo))throw new TypeError("packet must be an EncodedPacket.");if(e.isMetadataOnly)throw new TypeError("packet must not be metadata-only to determine its type.");if(this.codec===null)return null;const r=await this.getDecoderConfig();return $e(r),w7(this.codec,r,e.data)}}class xc extends Wb{constructor(e,r){super(e,r),this._backing=r}get type(){return"audio"}get codec(){return this._backing.getCodec()}get numberOfChannels(){return this._backing.getNumberOfChannels()}get sampleRate(){return this._backing.getSampleRate()}getDecoderConfig(){return this._backing.getDecoderConfig()}async getCodecParameterString(){return(await this._backing.getDecoderConfig())?.codec??null}async canDecode(){try{const e=await this._backing.getDecoderConfig();if(!e)return!1;const r=this._backing.getCodec();return $e(r!==null),S7.some(n=>n.supports(r,e))||e.codec.startsWith("pcm-")?!0:typeof AudioDecoder>"u"?!1:(await AudioDecoder.isConfigSupported(e)).supported===!0}catch(e){return console.error("Error during decodability check:",e),!1}}async determinePacketType(e){if(!(e instanceof Bo))throw new TypeError("packet must be an EncodedPacket.");return this.codec===null?null:"key"}}const SD=t=>{let r=(t.hasVideo?"video/":t.hasAudio?"audio/":"application/")+(t.isQuickTime?"quicktime":"mp4");if(t.codecStrings.length>0){const n=[...new Set(t.codecStrings)];r+=`; codecs="${n.join(", ")}"`}return r};const tp=8,k0=16,Kf=t=>{let e=Dt(t);const r=Fo(t,4);let n=8;e===1&&(e=xu(t),n=16);const a=e-n;return a<0?null:{name:r,totalSize:e,headerSize:n,contentSize:a}},qh=t=>Kh(t)/65536,vy=t=>Kh(t)/1073741824,yy=t=>{let e=0;for(let r=0;r<4;r++){e<<=7;const n=dr(t);if(e|=n&127,(n&128)===0)break}return e},ic=t=>{let e=ts(t);return t.skip(2),e=Math.min(e,t.remainingLength),Kl.decode(Nr(t,e))},_D=t=>{const e=Kf(t);if(!e||e.name!=="data"||t.remainingLength<8)return null;const r=Dt(t);t.skip(4);const n=Nr(t,e.contentSize-8);switch(r){case 1:return Kl.decode(n);case 2:return new TextDecoder("utf-16be").decode(n);case 13:return new F0(n,"image/jpeg");case 14:return new F0(n,"image/png");case 27:return new F0(n,"image/bmp");default:return n}};class kD extends _d{constructor(e){super(e),this.moovSlice=null,this.currentTrack=null,this.tracks=[],this.metadataPromise=null,this.movieTimescale=-1,this.movieDurationInTimescale=-1,this.isQuickTime=!1,this.metadataTags={},this.currentMetadataKeys=null,this.isFragmented=!1,this.fragmentTrackDefaults=[],this.currentFragment=null,this.lastReadFragment=null,this.reader=e._reader}async computeDuration(){const e=await this.getTracks(),r=await Promise.all(e.map(n=>n.computeDuration()));return Math.max(0,...r)}async getTracks(){return await this.readMetadata(),this.tracks.map(e=>e.inputTrack)}async getMimeType(){await this.readMetadata();const e=await Promise.all(this.tracks.map(r=>r.inputTrack.getCodecParameterString()));return SD({isQuickTime:this.isQuickTime,hasVideo:this.tracks.some(r=>r.info?.type==="video"),hasAudio:this.tracks.some(r=>r.info?.type==="audio"),codecStrings:e.filter(Boolean)})}async getMetadataTags(){return await this.readMetadata(),this.metadataTags}readMetadata(){return this.metadataPromise??=(async()=>{let e=0;for(;;){let r=this.reader.requestSliceRange(e,tp,k0);if(r instanceof Promise&&(r=await r),!r)break;const n=e,i=Kf(r);if(!i)break;if(i.name==="ftyp"){const a=Fo(r,4);this.isQuickTime=a==="qt "}else if(i.name==="moov"){let a=this.reader.requestSlice(r.filePos,i.contentSize);if(a instanceof Promise&&(a=await a),!a)break;this.moovSlice=a,this.readContiguousBoxes(this.moovSlice),this.tracks.sort((o,s)=>Number(s.disposition.default)-Number(o.disposition.default));for(const o of this.tracks){const s=o.editListPreviousSegmentDurations/this.movieTimescale;o.editListOffset-=Math.round(s*o.timescale)}break}e=n+i.totalSize}if(this.isFragmented&&this.reader.fileSize!==null){let r=this.reader.requestSlice(this.reader.fileSize-4,4);r instanceof Promise&&(r=await r),$e(r);const n=Dt(r),i=this.reader.fileSize-n;if(i>=0&&i<=this.reader.fileSize-k0){let a=this.reader.requestSliceRange(i,tp,k0);if(a instanceof Promise&&(a=await a),a){const o=Kf(a);if(o&&o.name==="mfra"){let s=this.reader.requestSlice(a.filePos,o.contentSize);s instanceof Promise&&(s=await s),s&&this.readContiguousBoxes(s)}}}}})()}getSampleTableForTrack(e){if(e.sampleTable)return e.sampleTable;const r={sampleTimingEntries:[],sampleCompositionTimeOffsets:[],sampleSizes:[],keySampleIndices:null,chunkOffsets:[],sampleToChunk:[],presentationTimestamps:null,presentationTimestampIndexMap:null};e.sampleTable=r,$e(this.moovSlice);const n=this.moovSlice.slice(e.sampleTableByteOffset);if(this.currentTrack=e,this.traverseBox(n),this.currentTrack=null,e.info?.type==="audio"&&e.info.codec&&of.includes(e.info.codec)&&r.sampleCompositionTimeOffsets.length===0){$e(e.info?.type==="audio");const a=d7(e.info.codec),o=[],s=[];for(let l=0;l<r.sampleToChunk.length;l++){const c=r.sampleToChunk[l],f=r.sampleToChunk[l+1],h=(f?f.startChunkIndex:r.chunkOffsets.length)-c.startChunkIndex;for(let d=0;d<h;d++){const p=c.startSampleIndex+d*c.samplesPerChunk,y=p+c.samplesPerChunk,w=oi(r.sampleTimingEntries,p,N=>N.startIndex),x=r.sampleTimingEntries[w],b=oi(r.sampleTimingEntries,y,N=>N.startIndex),S=r.sampleTimingEntries[b],E=x.startDecodeTimestamp+(p-x.startIndex)*x.delta,P=S.startDecodeTimestamp+(y-S.startIndex)*S.delta-E,O=El(o);O&&O.delta===P?O.count++:o.push({startIndex:c.startChunkIndex+d,startDecodeTimestamp:E,count:1,delta:P});const T=c.samplesPerChunk*a.sampleSize*e.info.numberOfChannels;s.push(T)}c.startSampleIndex=c.startChunkIndex,c.samplesPerChunk=1}r.sampleTimingEntries=o,r.sampleSizes=s}if(r.sampleCompositionTimeOffsets.length>0){r.presentationTimestamps=[];for(const a of r.sampleTimingEntries)for(let o=0;o<a.count;o++)r.presentationTimestamps.push({presentationTimestamp:a.startDecodeTimestamp+o*a.delta,sampleIndex:a.startIndex+o});for(const a of r.sampleCompositionTimeOffsets)for(let o=0;o<a.count;o++){const s=a.startIndex+o,l=r.presentationTimestamps[s];l&&(l.presentationTimestamp+=a.offset)}r.presentationTimestamps.sort((a,o)=>a.presentationTimestamp-o.presentationTimestamp),r.presentationTimestampIndexMap=Array(r.presentationTimestamps.length).fill(-1);for(let a=0;a<r.presentationTimestamps.length;a++)r.presentationTimestampIndexMap[r.presentationTimestamps[a].sampleIndex]=a}return r}async readFragment(e){if(this.lastReadFragment?.moofOffset===e)return this.lastReadFragment;let r=this.reader.requestSliceRange(e,tp,k0);r instanceof Promise&&(r=await r),$e(r);const n=Kf(r);$e(n?.name==="moof");let i=this.reader.requestSlice(e,n.totalSize);i instanceof Promise&&(i=await i),$e(i),this.traverseBox(i);const a=this.lastReadFragment;$e(a&&a.moofOffset===e);for(const[,o]of a.trackData){const s=o.track,{fragmentPositionCache:l}=s;if(!o.startTimestampIsFinal){const f=s.fragmentLookupTable.find(h=>h.moofOffset===a.moofOffset);if(f)by(o,f.timestamp);else{const h=oi(l,a.moofOffset-1,d=>d.moofOffset);if(h!==-1){const d=l[h];by(o,d.endTimestamp)}}o.startTimestampIsFinal=!0}const c=oi(l,o.startTimestamp,f=>f.startTimestamp);(c===-1||l[c].moofOffset!==a.moofOffset)&&l.splice(c+1,0,{moofOffset:a.moofOffset,startTimestamp:o.startTimestamp,endTimestamp:o.endTimestamp})}return a}readContiguousBoxes(e){const r=e.filePos;for(;e.filePos-r<=e.length-tp&&this.traverseBox(e););}*iterateContiguousBoxes(e){const r=e.filePos;for(;e.filePos-r<=e.length-tp;){const n=e.filePos,i=Kf(e);if(!i)break;yield{boxInfo:i,slice:e},e.filePos=n+i.totalSize}}traverseBox(e){const r=e.filePos,n=Kf(e);if(!n)return!1;const i=e.filePos,a=r+n.totalSize;switch(n.name){case"mdia":case"minf":case"dinf":case"mfra":case"edts":this.readContiguousBoxes(e.slice(i,n.contentSize));break;case"mvhd":{const o=dr(e);e.skip(3),o===1?(e.skip(16),this.movieTimescale=Dt(e),this.movieDurationInTimescale=xu(e)):(e.skip(8),this.movieTimescale=Dt(e),this.movieDurationInTimescale=Dt(e))}break;case"trak":{const o={id:-1,demuxer:this,inputTrack:null,disposition:{...Sd},info:null,timescale:-1,durationInMovieTimescale:-1,durationInMediaTimescale:-1,rotation:0,internalCodecId:null,name:null,languageCode:ku,sampleTableByteOffset:-1,sampleTable:null,fragmentLookupTable:[],currentFragmentState:null,fragmentPositionCache:[],editListPreviousSegmentDurations:0,editListOffset:0};if(this.currentTrack=o,this.readContiguousBoxes(e.slice(i,n.contentSize)),o.id!==-1&&o.timescale!==-1&&o.info!==null){if(o.info.type==="video"&&o.info.width!==-1){const s=o;o.inputTrack=new b1(this.input,new ED(s)),this.tracks.push(o)}else if(o.info.type==="audio"&&o.info.numberOfChannels!==-1){const s=o;o.inputTrack=new xc(this.input,new PD(s)),this.tracks.push(o)}}this.currentTrack=null}break;case"tkhd":{const o=this.currentTrack;if(!o)break;const s=dr(e),c=!!(np(e)&1);if(o.disposition.default=c,s===0)e.skip(8),o.id=Dt(e),e.skip(4),o.durationInMovieTimescale=Dt(e);else if(s===1)e.skip(16),o.id=Dt(e),e.skip(4),o.durationInMovieTimescale=xu(e);else throw new Error(`Incorrect track header version ${s}.`);e.skip(16);const f=[qh(e),qh(e),vy(e),qh(e),qh(e),vy(e),qh(e),qh(e),vy(e)],h=Zk(DM(OD(f),90));$e(h===0||h===90||h===180||h===270),o.rotation=h}break;case"elst":{const o=this.currentTrack;if(!o)break;const s=dr(e);e.skip(3);let l=!1,c=0;const f=Dt(e);for(let h=0;h<f;h++){const d=s===1?xu(e):Dt(e),p=s===1?jF(e):Kh(e),y=qh(e);if(d!==0){if(l){console.warn("Unsupported edit list: multiple edits are not currently supported. Only using first edit.");break}if(p===-1){c+=d;continue}if(y!==1){console.warn("Unsupported edit list entry: media rate must be 1.");break}o.editListPreviousSegmentDurations=c,o.editListOffset=p,l=!0}}}break;case"mdhd":{const o=this.currentTrack;if(!o)break;const s=dr(e);e.skip(3),s===0?(e.skip(8),o.timescale=Dt(e),o.durationInMediaTimescale=Dt(e)):s===1&&(e.skip(16),o.timescale=Dt(e),o.durationInMediaTimescale=xu(e));let l=ts(e);if(l>0){o.languageCode="";for(let c=0;c<3;c++)o.languageCode=String.fromCharCode(96+(l&31))+o.languageCode,l>>=5;n7(o.languageCode)||(o.languageCode=ku)}}break;case"hdlr":{const o=this.currentTrack;if(!o)break;e.skip(8);const s=Fo(e,4);s==="vide"?o.info={type:"video",width:-1,height:-1,codec:null,codecDescription:null,colorSpace:null,avcType:null,avcCodecInfo:null,hevcCodecInfo:null,vp9CodecInfo:null,av1CodecInfo:null}:s==="soun"&&(o.info={type:"audio",numberOfChannels:-1,sampleRate:-1,codec:null,codecDescription:null,aacCodecInfo:null})}break;case"stbl":{const o=this.currentTrack;if(!o)break;o.sampleTableByteOffset=r,this.readContiguousBoxes(e.slice(i,n.contentSize))}break;case"stsd":{const o=this.currentTrack;if(!o||o.info===null||o.sampleTable)break;const s=dr(e);e.skip(3);const l=Dt(e);for(let c=0;c<l;c++){const f=e.filePos,h=Kf(e);if(!h)break;o.internalCodecId=h.name;const d=h.name.toLowerCase();if(o.info.type==="video")d==="avc1"||d==="avc3"?(o.info.codec="avc",o.info.avcType=d==="avc1"?1:3):d==="hvc1"||d==="hev1"?o.info.codec="hevc":d==="vp08"?o.info.codec="vp8":d==="vp09"?o.info.codec="vp9":d==="av01"?o.info.codec="av1":console.warn(`Unsupported video codec (sample entry type '${h.name}').`),e.skip(24),o.info.width=ts(e),o.info.height=ts(e),e.skip(50),this.readContiguousBoxes(e.slice(e.filePos,f+h.totalSize-e.filePos));else{d==="mp4a"||(d==="opus"?o.info.codec="opus":d==="flac"?o.info.codec="flac":d==="twos"||d==="sowt"||d==="raw "||d==="in24"||d==="in32"||d==="fl32"||d==="fl64"||d==="lpcm"||d==="ipcm"||d==="fpcm"||(d==="ulaw"?o.info.codec="ulaw":d==="alaw"?o.info.codec="alaw":console.warn(`Unsupported audio codec (sample entry type '${h.name}').`))),e.skip(8);const p=ts(e);e.skip(6);let y=ts(e),w=ts(e);e.skip(4);let x=Dt(e)/65536;if(s===0&&p>0){if(p===1)e.skip(4),w=8*Dt(e),e.skip(8);else if(p===2){e.skip(4),x=z7(e),y=Dt(e),e.skip(4),w=Dt(e);const b=Dt(e);if(e.skip(8),d==="lpcm"){const S=w+7>>3,E=!!(b&1),_=!!(b&2),P=b&4?-1:0;w>0&&w<=64&&(E?w===32&&(o.info.codec=_?"pcm-f32be":"pcm-f32"):P&1<<S-1?S===1?o.info.codec="pcm-s8":S===2?o.info.codec=_?"pcm-s16be":"pcm-s16":S===3?o.info.codec=_?"pcm-s24be":"pcm-s24":S===4&&(o.info.codec=_?"pcm-s32be":"pcm-s32"):S===1&&(o.info.codec="pcm-u8")),o.info.codec===null&&console.warn("Unsupported PCM format.")}}}o.info.codec==="opus"&&(x=Ym),o.info.numberOfChannels=y,o.info.sampleRate=x,d==="twos"?w===8?o.info.codec="pcm-s8":w===16?o.info.codec="pcm-s16be":(console.warn(`Unsupported sample size ${w} for codec 'twos'.`),o.info.codec=null):d==="sowt"?w===8?o.info.codec="pcm-s8":w===16?o.info.codec="pcm-s16":(console.warn(`Unsupported sample size ${w} for codec 'sowt'.`),o.info.codec=null):d==="raw "?o.info.codec="pcm-u8":d==="in24"?o.info.codec="pcm-s24be":d==="in32"?o.info.codec="pcm-s32be":d==="fl32"?o.info.codec="pcm-f32be":d==="fl64"?o.info.codec="pcm-f64be":d==="ipcm"?o.info.codec="pcm-s16be":d==="fpcm"&&(o.info.codec="pcm-f32be"),this.readContiguousBoxes(e.slice(e.filePos,f+h.totalSize-e.filePos))}}}break;case"avcC":{const o=this.currentTrack;if(!o)break;$e(o.info),o.info.codecDescription=Nr(e,n.contentSize)}break;case"hvcC":{const o=this.currentTrack;if(!o)break;$e(o.info),o.info.codecDescription=Nr(e,n.contentSize)}break;case"vpcC":{const o=this.currentTrack;if(!o)break;$e(o.info?.type==="video"),e.skip(4);const s=dr(e),l=dr(e),c=dr(e),f=c>>4,h=c>>1&7,d=c&1,p=dr(e),y=dr(e),w=dr(e);o.info.vp9CodecInfo={profile:s,level:l,bitDepth:f,chromaSubsampling:h,videoFullRangeFlag:d,colourPrimaries:p,transferCharacteristics:y,matrixCoefficients:w}}break;case"av1C":{const o=this.currentTrack;if(!o)break;$e(o.info?.type==="video"),e.skip(1);const s=dr(e),l=s>>5,c=s&31,f=dr(e),h=f>>7,d=f>>6&1,p=f>>5&1,y=f>>4&1,w=f>>3&1,x=f>>2&1,b=f&3,S=l===2&&d?p?12:10:d?10:8;o.info.av1CodecInfo={profile:l,level:c,tier:h,bitDepth:S,monochrome:y,chromaSubsamplingX:w,chromaSubsamplingY:x,chromaSamplePosition:b}}break;case"colr":{const o=this.currentTrack;if(!o||($e(o.info?.type==="video"),Fo(e,4)!=="nclx"))break;const l=ts(e),c=ts(e),f=ts(e),h=!!(dr(e)&128);o.info.colorSpace={primaries:Qk[l],transfer:Jk[c],matrix:e7[f],fullRange:h}}break;case"wave":this.readContiguousBoxes(e.slice(i,n.contentSize));break;case"esds":{const o=this.currentTrack;if(!o)break;$e(o.info?.type==="audio"),e.skip(4);const s=dr(e);$e(s===3),yy(e),e.skip(2);const l=dr(e),c=(l&128)!==0,f=(l&64)!==0,h=(l&32)!==0;if(c&&e.skip(2),f){const x=dr(e);e.skip(x)}h&&e.skip(2);const d=dr(e);$e(d===4);const p=yy(e),y=e.filePos,w=dr(e);if(w===64||w===103?(o.info.codec="aac",o.info.aacCodecInfo={isMpeg2:w===103}):w===105||w===107?o.info.codec="mp3":w===221?o.info.codec="vorbis":console.warn(`Unsupported audio codec (objectTypeIndication ${w}) - discarding track.`),e.skip(12),p>e.filePos-y){const x=dr(e);$e(x===5);const b=yy(e);if(o.info.codecDescription=Nr(e,b),o.info.codec==="aac"){const S=f7(o.info.codecDescription);S.numberOfChannels!==null&&(o.info.numberOfChannels=S.numberOfChannels),S.sampleRate!==null&&(o.info.sampleRate=S.sampleRate)}}}break;case"enda":{const o=this.currentTrack;if(!o)break;$e(o.info?.type==="audio"),ts(e)&255&&(o.info.codec==="pcm-s16be"?o.info.codec="pcm-s16":o.info.codec==="pcm-s24be"?o.info.codec="pcm-s24":o.info.codec==="pcm-s32be"?o.info.codec="pcm-s32":o.info.codec==="pcm-f32be"?o.info.codec="pcm-f32":o.info.codec==="pcm-f64be"&&(o.info.codec="pcm-f64"))}break;case"pcmC":{const o=this.currentTrack;if(!o)break;$e(o.info?.type==="audio"),e.skip(4);const l=!!(dr(e)&1),c=dr(e);o.info.codec==="pcm-s16be"?l?c===16?o.info.codec="pcm-s16":c===24?o.info.codec="pcm-s24":c===32?o.info.codec="pcm-s32":(console.warn(`Invalid ipcm sample size ${c}.`),o.info.codec=null):c===16?o.info.codec="pcm-s16be":c===24?o.info.codec="pcm-s24be":c===32?o.info.codec="pcm-s32be":(console.warn(`Invalid ipcm sample size ${c}.`),o.info.codec=null):o.info.codec==="pcm-f32be"&&(l?c===32?o.info.codec="pcm-f32":c===64?o.info.codec="pcm-f64":(console.warn(`Invalid fpcm sample size ${c}.`),o.info.codec=null):c===32?o.info.codec="pcm-f32be":c===64?o.info.codec="pcm-f64be":(console.warn(`Invalid fpcm sample size ${c}.`),o.info.codec=null));break}case"dOps":{const o=this.currentTrack;if(!o)break;$e(o.info?.type==="audio"),e.skip(1);const s=dr(e),l=ts(e),c=Dt(e),f=H5(e),h=dr(e);let d;h!==0?d=Nr(e,2+s):d=new Uint8Array(0);const p=new Uint8Array(19+d.byteLength),y=new DataView(p.buffer);y.setUint32(0,1332770163,!1),y.setUint32(4,1214603620,!1),y.setUint8(8,1),y.setUint8(9,s),y.setUint16(10,l,!0),y.setUint32(12,c,!0),y.setInt16(16,f,!0),y.setUint8(18,h),p.set(d,19),o.info.codecDescription=p,o.info.numberOfChannels=s}break;case"dfLa":{const o=this.currentTrack;if(!o)break;$e(o.info?.type==="audio"),e.skip(4);const s=127,l=128,c=e.filePos;for(;e.filePos<a;){const y=dr(e),w=np(e);if((y&s)===yp.STREAMINFO){e.skip(10);const b=Dt(e),S=b>>>12,E=(b>>9&7)+1;o.info.sampleRate=S,o.info.numberOfChannels=E,e.skip(20)}else e.skip(w);if(y&l)break}const f=e.filePos;e.filePos=c;const h=Nr(e,f-c),d=new Uint8Array(4+h.byteLength);new DataView(d.buffer).setUint32(0,1716281667,!1),d.set(h,4),o.info.codecDescription=d}break;case"stts":{const o=this.currentTrack;if(!o||!o.sampleTable)break;e.skip(4);const s=Dt(e);let l=0,c=0;for(let f=0;f<s;f++){const h=Dt(e),d=Dt(e);o.sampleTable.sampleTimingEntries.push({startIndex:l,startDecodeTimestamp:c,count:h,delta:d}),l+=h,c+=h*d}}break;case"ctts":{const o=this.currentTrack;if(!o||!o.sampleTable)break;e.skip(4);const s=Dt(e);let l=0;for(let c=0;c<s;c++){const f=Dt(e),h=Kh(e);o.sampleTable.sampleCompositionTimeOffsets.push({startIndex:l,count:f,offset:h}),l+=f}}break;case"stsz":{const o=this.currentTrack;if(!o||!o.sampleTable)break;e.skip(4);const s=Dt(e),l=Dt(e);if(s===0)for(let c=0;c<l;c++){const f=Dt(e);o.sampleTable.sampleSizes.push(f)}else o.sampleTable.sampleSizes.push(s)}break;case"stz2":{const o=this.currentTrack;if(!o||!o.sampleTable)break;e.skip(4),e.skip(3);const s=dr(e),l=Dt(e),c=Nr(e,Math.ceil(l*s/8)),f=new aa(c);for(let h=0;h<l;h++){const d=f.readBits(s);o.sampleTable.sampleSizes.push(d)}}break;case"stss":{const o=this.currentTrack;if(!o||!o.sampleTable)break;e.skip(4),o.sampleTable.keySampleIndices=[];const s=Dt(e);for(let l=0;l<s;l++){const c=Dt(e)-1;o.sampleTable.keySampleIndices.push(c)}o.sampleTable.keySampleIndices[0]!==0&&o.sampleTable.keySampleIndices.unshift(0)}break;case"stsc":{const o=this.currentTrack;if(!o||!o.sampleTable)break;e.skip(4);const s=Dt(e);for(let c=0;c<s;c++){const f=Dt(e)-1,h=Dt(e),d=Dt(e);o.sampleTable.sampleToChunk.push({startSampleIndex:-1,startChunkIndex:f,samplesPerChunk:h,sampleDescriptionIndex:d})}let l=0;for(let c=0;c<o.sampleTable.sampleToChunk.length;c++)if(o.sampleTable.sampleToChunk[c].startSampleIndex=l,c<o.sampleTable.sampleToChunk.length-1){const h=o.sampleTable.sampleToChunk[c+1].startChunkIndex-o.sampleTable.sampleToChunk[c].startChunkIndex;l+=h*o.sampleTable.sampleToChunk[c].samplesPerChunk}}break;case"stco":{const o=this.currentTrack;if(!o||!o.sampleTable)break;e.skip(4);const s=Dt(e);for(let l=0;l<s;l++){const c=Dt(e);o.sampleTable.chunkOffsets.push(c)}}break;case"co64":{const o=this.currentTrack;if(!o||!o.sampleTable)break;e.skip(4);const s=Dt(e);for(let l=0;l<s;l++){const c=xu(e);o.sampleTable.chunkOffsets.push(c)}}break;case"mvex":this.isFragmented=!0,this.readContiguousBoxes(e.slice(i,n.contentSize));break;case"mehd":{const o=dr(e);e.skip(3);const s=o===1?xu(e):Dt(e);this.movieDurationInTimescale=s}break;case"trex":{e.skip(4);const o=Dt(e),s=Dt(e),l=Dt(e),c=Dt(e),f=Dt(e);this.fragmentTrackDefaults.push({trackId:o,defaultSampleDescriptionIndex:s,defaultSampleDuration:l,defaultSampleSize:c,defaultSampleFlags:f})}break;case"tfra":{const o=dr(e);e.skip(3);const s=Dt(e),l=this.tracks.find(S=>S.id===s);if(!l)break;const c=Dt(e),f=(c&48)>>4,h=(c&12)>>2,d=c&3,p=[dr,ts,np,Dt],y=p[f],w=p[h],x=p[d],b=Dt(e);for(let S=0;S<b;S++){const E=o===1?xu(e):Dt(e),_=o===1?xu(e):Dt(e);y(e),w(e),x(e),l.fragmentLookupTable.push({timestamp:E,moofOffset:_})}l.fragmentLookupTable.sort((S,E)=>S.timestamp-E.timestamp);for(let S=0;S<l.fragmentLookupTable.length-1;S++){const E=l.fragmentLookupTable[S],_=l.fragmentLookupTable[S+1];E.timestamp===_.timestamp&&(l.fragmentLookupTable.splice(S+1,1),S--)}}break;case"moof":this.currentFragment={moofOffset:r,moofSize:n.totalSize,implicitBaseDataOffset:r,trackData:new Map},this.readContiguousBoxes(e.slice(i,n.contentSize)),this.lastReadFragment=this.currentFragment,this.currentFragment=null;break;case"traf":if($e(this.currentFragment),this.readContiguousBoxes(e.slice(i,n.contentSize)),this.currentTrack){const o=this.currentFragment.trackData.get(this.currentTrack.id);if(o){const{currentFragmentState:s}=this.currentTrack;$e(s),s.startTimestamp!==null&&(by(o,s.startTimestamp),o.startTimestampIsFinal=!0)}this.currentTrack.currentFragmentState=null,this.currentTrack=null}break;case"tfhd":{$e(this.currentFragment),e.skip(1);const o=np(e),s=!!(o&1),l=!!(o&2),c=!!(o&8),f=!!(o&16),h=!!(o&32),d=!!(o&65536),p=!!(o&131072),y=Dt(e),w=this.tracks.find(b=>b.id===y);if(!w)break;const x=this.fragmentTrackDefaults.find(b=>b.trackId===y);this.currentTrack=w,w.currentFragmentState={baseDataOffset:this.currentFragment.implicitBaseDataOffset,sampleDescriptionIndex:x?.defaultSampleDescriptionIndex??null,defaultSampleDuration:x?.defaultSampleDuration??null,defaultSampleSize:x?.defaultSampleSize??null,defaultSampleFlags:x?.defaultSampleFlags??null,startTimestamp:null},s?w.currentFragmentState.baseDataOffset=xu(e):p&&(w.currentFragmentState.baseDataOffset=this.currentFragment.moofOffset),l&&(w.currentFragmentState.sampleDescriptionIndex=Dt(e)),c&&(w.currentFragmentState.defaultSampleDuration=Dt(e)),f&&(w.currentFragmentState.defaultSampleSize=Dt(e)),h&&(w.currentFragmentState.defaultSampleFlags=Dt(e)),d&&(w.currentFragmentState.defaultSampleDuration=0)}break;case"tfdt":{const o=this.currentTrack;if(!o)break;$e(o.currentFragmentState);const s=dr(e);e.skip(3);const l=s===0?Dt(e):xu(e);o.currentFragmentState.startTimestamp=l}break;case"trun":{const o=this.currentTrack;if(!o)break;if($e(this.currentFragment),$e(o.currentFragmentState),this.currentFragment.trackData.has(o.id)){console.warn("Can't have two trun boxes for the same track in one fragment. Ignoring...");break}const s=dr(e),l=np(e),c=!!(l&1),f=!!(l&4),h=!!(l&256),d=!!(l&512),p=!!(l&1024),y=!!(l&2048),w=Dt(e);let x=o.currentFragmentState.baseDataOffset;c&&(x+=Kh(e));let b=null;f&&(b=Dt(e));let S=x;if(w===0){this.currentFragment.implicitBaseDataOffset=S;break}let E=0;const _={track:o,startTimestamp:0,endTimestamp:0,firstKeyFrameTimestamp:null,samples:[],presentationTimestamps:[],startTimestampIsFinal:!1};this.currentFragment.trackData.set(o.id,_);for(let T=0;T<w;T++){let N;h?N=Dt(e):($e(o.currentFragmentState.defaultSampleDuration!==null),N=o.currentFragmentState.defaultSampleDuration);let D;d?D=Dt(e):($e(o.currentFragmentState.defaultSampleSize!==null),D=o.currentFragmentState.defaultSampleSize);let F;p?F=Dt(e):($e(o.currentFragmentState.defaultSampleFlags!==null),F=o.currentFragmentState.defaultSampleFlags),T===0&&b!==null&&(F=b);let A=0;y&&(s===0?A=Dt(e):A=Kh(e));const L=!(F&65536);_.samples.push({presentationTimestamp:E+A,duration:N,byteOffset:S,byteSize:D,isKeyFrame:L}),S+=D,E+=N}_.presentationTimestamps=_.samples.map((T,N)=>({presentationTimestamp:T.presentationTimestamp,sampleIndex:N})).sort((T,N)=>T.presentationTimestamp-N.presentationTimestamp);for(let T=0;T<_.presentationTimestamps.length;T++){const N=_.presentationTimestamps[T],D=_.samples[N.sampleIndex];if(_.firstKeyFrameTimestamp===null&&D.isKeyFrame&&(_.firstKeyFrameTimestamp=D.presentationTimestamp),T<_.presentationTimestamps.length-1){const F=_.presentationTimestamps[T+1];D.duration=F.presentationTimestamp-N.presentationTimestamp}}const P=_.samples[_.presentationTimestamps[0].sampleIndex],O=_.samples[El(_.presentationTimestamps).sampleIndex];_.startTimestamp=P.presentationTimestamp,_.endTimestamp=O.presentationTimestamp+O.duration,this.currentFragment.implicitBaseDataOffset=S}break;case"udta":{const o=this.iterateContiguousBoxes(e.slice(i,n.contentSize));for(const{boxInfo:s,slice:l}of o){if(s.name!=="meta"&&!this.currentTrack){const c=l.filePos;this.metadataTags.raw??={},s.name[0]==="©"?this.metadataTags.raw[s.name]??=ic(l):this.metadataTags.raw[s.name]??=Nr(l,s.contentSize),l.filePos=c}switch(s.name){case"meta":l.skip(-s.headerSize),this.traverseBox(l);break;case"©nam":case"name":this.currentTrack?this.currentTrack.name=Kl.decode(Nr(l,s.contentSize)):this.metadataTags.title??=ic(l);break;case"©des":this.currentTrack||(this.metadataTags.description??=ic(l));break;case"©ART":this.currentTrack||(this.metadataTags.artist??=ic(l));break;case"©alb":this.currentTrack||(this.metadataTags.album??=ic(l));break;case"albr":this.currentTrack||(this.metadataTags.albumArtist??=ic(l));break;case"©gen":this.currentTrack||(this.metadataTags.genre??=ic(l));break;case"©day":if(!this.currentTrack){const c=new Date(ic(l));Number.isNaN(c.getTime())||(this.metadataTags.date??=c)}break;case"©cmt":this.currentTrack||(this.metadataTags.comment??=ic(l));break;case"©lyr":this.currentTrack||(this.metadataTags.lyrics??=ic(l));break}}}break;case"meta":{if(this.currentTrack)break;const s=Dt(e)!==0;this.currentMetadataKeys=new Map,s?this.readContiguousBoxes(e.slice(i,n.contentSize)):this.readContiguousBoxes(e.slice(i+4,n.contentSize-4)),this.currentMetadataKeys=null}break;case"keys":{if(!this.currentMetadataKeys)break;e.skip(4);const o=Dt(e);for(let s=0;s<o;s++){const l=Dt(e);e.skip(4);const c=Kl.decode(Nr(e,l-8));this.currentMetadataKeys.set(s+1,c)}}break;case"ilst":{if(!this.currentMetadataKeys)break;const o=this.iterateContiguousBoxes(e.slice(i,n.contentSize));for(const{boxInfo:s,slice:l}of o){let c=s.name;const f=(c.charCodeAt(0)<<24)+(c.charCodeAt(1)<<16)+(c.charCodeAt(2)<<8)+c.charCodeAt(3);this.currentMetadataKeys.has(f)&&(c=this.currentMetadataKeys.get(f));const h=_D(l);switch(this.metadataTags.raw??={},this.metadataTags.raw[c]??=h,c){case"©nam":case"titl":case"com.apple.quicktime.title":case"title":typeof h=="string"&&(this.metadataTags.title??=h);break;case"©des":case"desc":case"dscp":case"com.apple.quicktime.description":case"description":typeof h=="string"&&(this.metadataTags.description??=h);break;case"©ART":case"com.apple.quicktime.artist":case"artist":typeof h=="string"&&(this.metadataTags.artist??=h);break;case"©alb":case"albm":case"com.apple.quicktime.album":case"album":typeof h=="string"&&(this.metadataTags.album??=h);break;case"aART":case"album_artist":typeof h=="string"&&(this.metadataTags.albumArtist??=h);break;case"©cmt":case"com.apple.quicktime.comment":case"comment":typeof h=="string"&&(this.metadataTags.comment??=h);break;case"©gen":case"gnre":case"com.apple.quicktime.genre":case"genre":typeof h=="string"&&(this.metadataTags.genre??=h);break;case"©lyr":case"lyrics":typeof h=="string"&&(this.metadataTags.lyrics??=h);break;case"©day":case"rldt":case"com.apple.quicktime.creationdate":case"date":if(typeof h=="string"){const d=new Date(h);Number.isNaN(d.getTime())||(this.metadataTags.date??=d)}break;case"covr":case"com.apple.quicktime.artwork":h instanceof F0?(this.metadataTags.images??=[],this.metadataTags.images.push({data:h.data,kind:"coverFront",mimeType:h.mimeType})):h instanceof Uint8Array&&(this.metadataTags.images??=[],this.metadataTags.images.push({data:h,kind:"coverFront",mimeType:"image/*"}));break;case"track":if(typeof h=="string"){const d=h.split("/"),p=Number.parseInt(d[0],10),y=d[1]&&Number.parseInt(d[1],10);Number.isInteger(p)&&p>0&&(this.metadataTags.trackNumber??=p),y&&Number.isInteger(y)&&y>0&&(this.metadataTags.tracksTotal??=y)}break;case"trkn":if(h instanceof Uint8Array&&h.length>=6){const d=Wa(h),p=d.getUint16(2,!1),y=d.getUint16(4,!1);p>0&&(this.metadataTags.trackNumber??=p),y>0&&(this.metadataTags.tracksTotal??=y)}break;case"disc":case"disk":if(h instanceof Uint8Array&&h.length>=6){const d=Wa(h),p=d.getUint16(2,!1),y=d.getUint16(4,!1);p>0&&(this.metadataTags.discNumber??=p),y>0&&(this.metadataTags.discsTotal??=y)}break}}}break}return e.filePos=a,!0}}class C7{constructor(e){this.internalTrack=e,this.packetToSampleIndex=new WeakMap,this.packetToFragmentLocation=new WeakMap}getId(){return this.internalTrack.id}getCodec(){throw new Error("Not implemented on base class.")}getInternalCodecId(){return this.internalTrack.internalCodecId}getName(){return this.internalTrack.name}getLanguageCode(){return this.internalTrack.languageCode}getTimeResolution(){return this.internalTrack.timescale}getDisposition(){return this.internalTrack.disposition}async computeDuration(){const e=await this.getPacket(1/0,{metadataOnly:!0});return(e?.timestamp??0)+(e?.duration??0)}async getFirstTimestamp(){return(await this.getFirstPacket({metadataOnly:!0}))?.timestamp??0}async getFirstPacket(e){const r=await this.fetchPacketForSampleIndex(0,e);return r||!this.internalTrack.demuxer.isFragmented?r:this.performFragmentedLookup(null,n=>n.trackData.get(this.internalTrack.id)?{sampleIndex:0,correctSampleFound:!0}:{sampleIndex:-1,correctSampleFound:!1},-1/0,1/0,e)}mapTimestampIntoTimescale(e){return fm(e*this.internalTrack.timescale)+this.internalTrack.editListOffset}async getPacket(e,r){const n=this.mapTimestampIntoTimescale(e),i=this.internalTrack.demuxer.getSampleTableForTrack(this.internalTrack),a=D5(i,n),o=await this.fetchPacketForSampleIndex(a,r);return!ox(i)||!this.internalTrack.demuxer.isFragmented?o:this.performFragmentedLookup(null,s=>{const l=s.trackData.get(this.internalTrack.id);if(!l)return{sampleIndex:-1,correctSampleFound:!1};const c=oi(l.presentationTimestamps,n,d=>d.presentationTimestamp),f=c!==-1?l.presentationTimestamps[c].sampleIndex:-1,h=c!==-1&&n<l.endTimestamp;return{sampleIndex:f,correctSampleFound:h}},n,n,r)}async getNextPacket(e,r){const n=this.packetToSampleIndex.get(e);if(n!==void 0)return this.fetchPacketForSampleIndex(n+1,r);const i=this.packetToFragmentLocation.get(e);if(i===void 0)throw new Error("Packet was not created from this track.");return this.performFragmentedLookup(i.fragment,a=>{if(a===i.fragment){const o=a.trackData.get(this.internalTrack.id);if(i.sampleIndex+1<o.samples.length)return{sampleIndex:i.sampleIndex+1,correctSampleFound:!0}}else if(a.trackData.get(this.internalTrack.id))return{sampleIndex:0,correctSampleFound:!0};return{sampleIndex:-1,correctSampleFound:!1}},-1/0,1/0,r)}async getKeyPacket(e,r){const n=this.mapTimestampIntoTimescale(e),i=this.internalTrack.demuxer.getSampleTableForTrack(this.internalTrack),a=CD(i,n),o=await this.fetchPacketForSampleIndex(a,r);return!ox(i)||!this.internalTrack.demuxer.isFragmented?o:this.performFragmentedLookup(null,s=>{const l=s.trackData.get(this.internalTrack.id);if(!l)return{sampleIndex:-1,correctSampleFound:!1};const c=r7(l.presentationTimestamps,d=>l.samples[d.sampleIndex].isKeyFrame&&d.presentationTimestamp<=n),f=c!==-1?l.presentationTimestamps[c].sampleIndex:-1,h=c!==-1&&n<l.endTimestamp;return{sampleIndex:f,correctSampleFound:h}},n,n,r)}async getNextKeyPacket(e,r){const n=this.packetToSampleIndex.get(e);if(n!==void 0){const a=this.internalTrack.demuxer.getSampleTableForTrack(this.internalTrack),o=AD(a,n);return this.fetchPacketForSampleIndex(o,r)}const i=this.packetToFragmentLocation.get(e);if(i===void 0)throw new Error("Packet was not created from this track.");return this.performFragmentedLookup(i.fragment,a=>{if(a===i.fragment){const s=a.trackData.get(this.internalTrack.id).samples.findIndex((l,c)=>l.isKeyFrame&&c>i.sampleIndex);if(s!==-1)return{sampleIndex:s,correctSampleFound:!0}}else{const o=a.trackData.get(this.internalTrack.id);if(o&&o.firstKeyFrameTimestamp!==null){const s=o.samples.findIndex(l=>l.isKeyFrame);return $e(s!==-1),{sampleIndex:s,correctSampleFound:!0}}}return{sampleIndex:-1,correctSampleFound:!1}},-1/0,1/0,r)}async fetchPacketForSampleIndex(e,r){if(e===-1)return null;const n=this.internalTrack.demuxer.getSampleTableForTrack(this.internalTrack),i=TD(n,e);if(!i)return null;let a;if(r.metadataOnly)a=Zl;else{let c=this.internalTrack.demuxer.reader.requestSlice(i.sampleOffset,i.sampleSize);c instanceof Promise&&(c=await c),$e(c),a=Nr(c,i.sampleSize)}const o=(i.presentationTimestamp-this.internalTrack.editListOffset)/this.internalTrack.timescale,s=i.duration/this.internalTrack.timescale,l=new Bo(a,i.isKeyFrame?"key":"delta",o,s,e,i.sampleSize);return this.packetToSampleIndex.set(l,e),l}async fetchPacketInFragment(e,r,n){if(r===-1)return null;const a=e.trackData.get(this.internalTrack.id).samples[r];$e(a);let o;if(n.metadataOnly)o=Zl;else{let f=this.internalTrack.demuxer.reader.requestSlice(a.byteOffset,a.byteSize);f instanceof Promise&&(f=await f),$e(f),o=Nr(f,a.byteSize)}const s=(a.presentationTimestamp-this.internalTrack.editListOffset)/this.internalTrack.timescale,l=a.duration/this.internalTrack.timescale,c=new Bo(o,a.isKeyFrame?"key":"delta",s,l,e.moofOffset+r,a.byteSize);return this.packetToFragmentLocation.set(c,{fragment:e,sampleIndex:r}),c}async performFragmentedLookup(e,r,n,i,a){const o=this.internalTrack.demuxer;let s=null,l=null,c=-1;if(e){const{sampleIndex:x,correctSampleFound:b}=r(e);if(b)return this.fetchPacketInFragment(e,x,a);x!==-1&&(l=e,c=x)}const f=oi(this.internalTrack.fragmentLookupTable,n,x=>x.timestamp),h=f!==-1?this.internalTrack.fragmentLookupTable[f]:null,d=oi(this.internalTrack.fragmentPositionCache,n,x=>x.startTimestamp),p=d!==-1?this.internalTrack.fragmentPositionCache[d]:null,y=Math.max(h?.moofOffset??0,p?.moofOffset??0)||null;let w;for(e?y===null||e.moofOffset>=y?(w=e.moofOffset+e.moofSize,s=e):w=y:w=y??0;;){if(s){const E=s.trackData.get(this.internalTrack.id);if(E&&E.startTimestamp>i)break}let x=o.reader.requestSliceRange(w,tp,k0);if(x instanceof Promise&&(x=await x),!x)break;const b=w,S=Kf(x);if(!S)break;if(S.name==="moof"){s=await o.readFragment(b);const{sampleIndex:E,correctSampleFound:_}=r(s);if(_)return this.fetchPacketInFragment(s,E,a);E!==-1&&(l=s,c=E)}w=b+S.totalSize}if(h&&(!l||l.moofOffset<h.moofOffset)){const x=this.internalTrack.fragmentLookupTable[f-1];$e(!x||x.timestamp<h.timestamp);const b=x?.timestamp??-1/0;return this.performFragmentedLookup(null,r,b,i,a)}return l?this.fetchPacketInFragment(l,c,a):null}}class ED extends C7{constructor(e){super(e),this.decoderConfigPromise=null,this.internalTrack=e}getCodec(){return this.internalTrack.info.codec}getCodedWidth(){return this.internalTrack.info.width}getCodedHeight(){return this.internalTrack.info.height}getRotation(){return this.internalTrack.rotation}async getColorSpace(){return{primaries:this.internalTrack.info.colorSpace?.primaries,transfer:this.internalTrack.info.colorSpace?.transfer,matrix:this.internalTrack.info.colorSpace?.matrix,fullRange:this.internalTrack.info.colorSpace?.fullRange}}async canBeTransparent(){return!1}async getDecoderConfig(){return this.internalTrack.info.codec?this.decoderConfigPromise??=(async()=>{if(this.internalTrack.info.codec==="vp9"&&!this.internalTrack.info.vp9CodecInfo){const e=await this.getFirstPacket({});this.internalTrack.info.vp9CodecInfo=e&&v7(e.data)}else if(this.internalTrack.info.codec==="av1"&&!this.internalTrack.info.av1CodecInfo){const e=await this.getFirstPacket({});this.internalTrack.info.av1CodecInfo=e&&b7(e.data)}return{codec:u7(this.internalTrack.info),codedWidth:this.internalTrack.info.width,codedHeight:this.internalTrack.info.height,description:this.internalTrack.info.codecDescription??void 0,colorSpace:this.internalTrack.info.colorSpace??void 0}})():null}}class PD extends C7{constructor(e){super(e),this.decoderConfig=null,this.internalTrack=e}getCodec(){return this.internalTrack.info.codec}getNumberOfChannels(){return this.internalTrack.info.numberOfChannels}getSampleRate(){return this.internalTrack.info.sampleRate}async getDecoderConfig(){return this.internalTrack.info.codec?this.decoderConfig??={codec:c7(this.internalTrack.info),numberOfChannels:this.internalTrack.info.numberOfChannels,sampleRate:this.internalTrack.info.sampleRate,description:this.internalTrack.info.codecDescription??void 0}:null}}const D5=(t,e)=>{if(t.presentationTimestamps){const r=oi(t.presentationTimestamps,e,n=>n.presentationTimestamp);return r===-1?-1:t.presentationTimestamps[r].sampleIndex}else{const r=oi(t.sampleTimingEntries,e,i=>i.startDecodeTimestamp);if(r===-1)return-1;const n=t.sampleTimingEntries[r];return n.startIndex+Math.min(Math.floor((e-n.startDecodeTimestamp)/n.delta),n.count-1)}},CD=(t,e)=>{if(!t.keySampleIndices)return D5(t,e);if(t.presentationTimestamps){const r=oi(t.presentationTimestamps,e,n=>n.presentationTimestamp);if(r===-1)return-1;for(let n=r;n>=0;n--){const i=t.presentationTimestamps[n].sampleIndex;if(Gm(t.keySampleIndices,i,o=>o)!==-1)return i}return-1}else{const r=D5(t,e),n=oi(t.keySampleIndices,r,i=>i);return t.keySampleIndices[n]??-1}},TD=(t,e)=>{const r=oi(t.sampleTimingEntries,e,b=>b.startIndex),n=t.sampleTimingEntries[r];if(!n||n.startIndex+n.count<=e)return null;let a=n.startDecodeTimestamp+(e-n.startIndex)*n.delta;const o=oi(t.sampleCompositionTimeOffsets,e,b=>b.startIndex),s=t.sampleCompositionTimeOffsets[o];s&&e-s.startIndex<s.count&&(a+=s.offset);const l=t.sampleSizes[Math.min(e,t.sampleSizes.length-1)],c=oi(t.sampleToChunk,e,b=>b.startSampleIndex),f=t.sampleToChunk[c];$e(f);const h=f.startChunkIndex+Math.floor((e-f.startSampleIndex)/f.samplesPerChunk),d=t.chunkOffsets[h],p=f.startSampleIndex+(h-f.startChunkIndex)*f.samplesPerChunk;let y=0,w=d;if(t.sampleSizes.length===1)w+=l*(e-p),y+=l*f.samplesPerChunk;else for(let b=p;b<p+f.samplesPerChunk;b++){const S=t.sampleSizes[b];b<e&&(w+=S),y+=S}let x=n.delta;if(t.presentationTimestamps){const b=t.presentationTimestampIndexMap[e];$e(b!==void 0),b<t.presentationTimestamps.length-1&&(x=t.presentationTimestamps[b+1].presentationTimestamp-a)}return{presentationTimestamp:a,duration:x,sampleOffset:w,sampleSize:l,chunkOffset:d,chunkSize:y,isKeyFrame:t.keySampleIndices?Gm(t.keySampleIndices,e,b=>b)!==-1:!0}},AD=(t,e)=>{if(!t.keySampleIndices)return e+1;const r=oi(t.keySampleIndices,e,n=>n);return t.keySampleIndices[r+1]??-1},by=(t,e)=>{t.startTimestamp+=e,t.endTimestamp+=e;for(const r of t.samples)r.presentationTimestamp+=e;for(const r of t.presentationTimestamps)r.presentationTimestamp+=e},OD=t=>{const[e,,,r]=t,n=Math.hypot(e,r),i=e/n,a=r/n,o=-Math.atan2(a,i)*(180/Math.PI);return Number.isFinite(o)?o:0},ox=t=>t.sampleSizes.length===0;var bt;(function(t){t[t.EBML=440786851]="EBML",t[t.EBMLVersion=17030]="EBMLVersion",t[t.EBMLReadVersion=17143]="EBMLReadVersion",t[t.EBMLMaxIDLength=17138]="EBMLMaxIDLength",t[t.EBMLMaxSizeLength=17139]="EBMLMaxSizeLength",t[t.DocType=17026]="DocType",t[t.DocTypeVersion=17031]="DocTypeVersion",t[t.DocTypeReadVersion=17029]="DocTypeReadVersion",t[t.Void=236]="Void",t[t.Segment=408125543]="Segment",t[t.SeekHead=290298740]="SeekHead",t[t.Seek=19899]="Seek",t[t.SeekID=21419]="SeekID",t[t.SeekPosition=21420]="SeekPosition",t[t.Duration=17545]="Duration",t[t.Info=357149030]="Info",t[t.TimestampScale=2807729]="TimestampScale",t[t.MuxingApp=19840]="MuxingApp",t[t.WritingApp=22337]="WritingApp",t[t.Tracks=374648427]="Tracks",t[t.TrackEntry=174]="TrackEntry",t[t.TrackNumber=215]="TrackNumber",t[t.TrackUID=29637]="TrackUID",t[t.TrackType=131]="TrackType",t[t.FlagEnabled=185]="FlagEnabled",t[t.FlagDefault=136]="FlagDefault",t[t.FlagForced=21930]="FlagForced",t[t.FlagOriginal=21934]="FlagOriginal",t[t.FlagHearingImpaired=21931]="FlagHearingImpaired",t[t.FlagVisualImpaired=21932]="FlagVisualImpaired",t[t.FlagCommentary=21935]="FlagCommentary",t[t.FlagLacing=156]="FlagLacing",t[t.Name=21358]="Name",t[t.Language=2274716]="Language",t[t.LanguageBCP47=2274717]="LanguageBCP47",t[t.CodecID=134]="CodecID",t[t.CodecPrivate=25506]="CodecPrivate",t[t.CodecDelay=22186]="CodecDelay",t[t.SeekPreRoll=22203]="SeekPreRoll",t[t.DefaultDuration=2352003]="DefaultDuration",t[t.Video=224]="Video",t[t.PixelWidth=176]="PixelWidth",t[t.PixelHeight=186]="PixelHeight",t[t.AlphaMode=21440]="AlphaMode",t[t.Audio=225]="Audio",t[t.SamplingFrequency=181]="SamplingFrequency",t[t.Channels=159]="Channels",t[t.BitDepth=25188]="BitDepth",t[t.SimpleBlock=163]="SimpleBlock",t[t.BlockGroup=160]="BlockGroup",t[t.Block=161]="Block",t[t.BlockAdditions=30113]="BlockAdditions",t[t.BlockMore=166]="BlockMore",t[t.BlockAdditional=165]="BlockAdditional",t[t.BlockAddID=238]="BlockAddID",t[t.BlockDuration=155]="BlockDuration",t[t.ReferenceBlock=251]="ReferenceBlock",t[t.Cluster=524531317]="Cluster",t[t.Timestamp=231]="Timestamp",t[t.Cues=475249515]="Cues",t[t.CuePoint=187]="CuePoint",t[t.CueTime=179]="CueTime",t[t.CueTrackPositions=183]="CueTrackPositions",t[t.CueTrack=247]="CueTrack",t[t.CueClusterPosition=241]="CueClusterPosition",t[t.Colour=21936]="Colour",t[t.MatrixCoefficients=21937]="MatrixCoefficients",t[t.TransferCharacteristics=21946]="TransferCharacteristics",t[t.Primaries=21947]="Primaries",t[t.Range=21945]="Range",t[t.Projection=30320]="Projection",t[t.ProjectionType=30321]="ProjectionType",t[t.ProjectionPoseRoll=30325]="ProjectionPoseRoll",t[t.Attachments=423732329]="Attachments",t[t.AttachedFile=24999]="AttachedFile",t[t.FileDescription=18046]="FileDescription",t[t.FileName=18030]="FileName",t[t.FileMediaType=18016]="FileMediaType",t[t.FileData=18012]="FileData",t[t.FileUID=18094]="FileUID",t[t.Chapters=272869232]="Chapters",t[t.Tags=307544935]="Tags",t[t.Tag=29555]="Tag",t[t.Targets=25536]="Targets",t[t.TargetTypeValue=26826]="TargetTypeValue",t[t.TargetType=25546]="TargetType",t[t.TagTrackUID=25541]="TagTrackUID",t[t.TagEditionUID=25545]="TagEditionUID",t[t.TagChapterUID=25540]="TagChapterUID",t[t.TagAttachmentUID=25542]="TagAttachmentUID",t[t.SimpleTag=26568]="SimpleTag",t[t.TagName=17827]="TagName",t[t.TagLanguage=17530]="TagLanguage",t[t.TagString=17543]="TagString",t[t.TagBinary=17541]="TagBinary",t[t.ContentEncodings=28032]="ContentEncodings",t[t.ContentEncoding=25152]="ContentEncoding",t[t.ContentEncodingOrder=20529]="ContentEncodingOrder",t[t.ContentEncodingScope=20530]="ContentEncodingScope",t[t.ContentCompression=20532]="ContentCompression",t[t.ContentCompAlgo=16980]="ContentCompAlgo",t[t.ContentCompSettings=16981]="ContentCompSettings",t[t.ContentEncryption=20533]="ContentEncryption"})(bt||(bt={}));const ND=[bt.EBML,bt.Segment],i1=[bt.SeekHead,bt.Info,bt.Cluster,bt.Tracks,bt.Cues,bt.Attachments,bt.Chapters,bt.Tags],Dg=[...ND,...i1],F5=8,_u=2,Xc=2*F5,T7=t=>{const e=dr(t);if(t.skip(-1),e===0)return null;let r=1,n=128;for(;(e&n)===0;)r++,n>>=1;return r},E0=t=>{const e=dr(t);if(e===0)return null;let r=1,n=128;for(;(e&n)===0;)r++,n>>=1;let i=e&n-1;for(let a=1;a<r;a++)i*=256,i+=dr(t);return i},Jr=(t,e)=>{if(e<1||e>8)throw new Error("Bad unsigned int size "+e);let r=0;for(let n=0;n<e;n++)r*=256,r+=dr(t);return r},ID=(t,e)=>{if(e<1)throw new Error("Bad unsigned int size "+e);let r=0n;for(let n=0;n<e;n++)r<<=8n,r+=BigInt(dr(t));return r},Gb=t=>{const e=T7(t);return e===null?null:Jr(t,e)},A7=t=>{let e=dr(t);return e===255?e=null:(t.skip(-1),e=E0(t),e===72057594037927940&&(e=null)),e},Hc=t=>{const e=Gb(t);if(e===null)return null;const r=A7(t);return{id:e,size:r}},rp=(t,e)=>{const r=Nr(t,e);let n=0;for(;n<e&&r[n]!==0;)n+=1;return String.fromCharCode(...r.subarray(0,n))},c0=(t,e)=>{const r=Nr(t,e);let n=0;for(;n<e&&r[n]!==0;)n+=1;return Kl.decode(r.subarray(0,n))},wy=(t,e)=>{if(e===0)return 0;if(e!==4&&e!==8)throw new Error("Bad float size "+e);return e===4?UF(t):z7(t)},B5=async(t,e,r,n)=>{const i=new Set(r);let a=e;for(;n===null||a<n;){let o=t.requestSliceRange(a,_u,Xc);if(o instanceof Promise&&(o=await o),!o)break;const s=Hc(o);if(!s)break;if(i.has(s.id))return{pos:a,found:!0};Xf(s.size),a=o.filePos+s.size}return{pos:n!==null&&n>a?n:a,found:!1}},O7=async(t,e,r,n)=>{const a=new Set(r);let o=e;for(;o<n;){let s=t.requestSliceRange(o,0,Math.min(65536,n-o));if(s instanceof Promise&&(s=await s),!s||s.length<F5)break;for(let l=0;l<s.length-F5;l++){s.filePos=o;const c=Gb(s);if(c!==null&&a.has(c))return o;o++}}return null},ac={avc:"V_MPEG4/ISO/AVC",hevc:"V_MPEGH/ISO/HEVC",vp8:"V_VP8",vp9:"V_VP9",av1:"V_AV1",aac:"A_AAC",mp3:"A_MPEG/L3",opus:"A_OPUS",vorbis:"A_VORBIS",flac:"A_FLAC"};function Xf(t){if(t===null)throw new Error("Undefined element size is used in a place where it is not supported.")}const LD=t=>{let r=(t.hasVideo?"video/":t.hasAudio?"audio/":"application/")+(t.isWebM?"webm":"x-matroska");if(t.codecStrings.length>0){const n=[...new Set(t.codecStrings.filter(Boolean))];r+=`; codecs="${n.join(", ")}"`}return r};var zc;(function(t){t[t.None=0]="None",t[t.Xiph=1]="Xiph",t[t.FixedSize=2]="FixedSize",t[t.Ebml=3]="Ebml"})(zc||(zc={}));var dm;(function(t){t[t.Block=1]="Block",t[t.Private=2]="Private",t[t.Next=4]="Next"})(dm||(dm={}));var j0;(function(t){t[t.Zlib=0]="Zlib",t[t.Bzlib=1]="Bzlib",t[t.lzo1x=2]="lzo1x",t[t.HeaderStripping=3]="HeaderStripping"})(j0||(j0={}));const xy=[{id:bt.SeekHead,flag:"seekHeadSeen"},{id:bt.Info,flag:"infoSeen"},{id:bt.Tracks,flag:"tracksSeen"},{id:bt.Cues,flag:"cuesSeen"}],N7=10*2**20;class RD extends _d{constructor(e){super(e),this.readMetadataPromise=null,this.segments=[],this.currentSegment=null,this.currentTrack=null,this.currentCluster=null,this.currentBlock=null,this.currentBlockAdditional=null,this.currentCueTime=null,this.currentDecodingInstruction=null,this.currentTagTargetIsMovie=!0,this.currentSimpleTagName=null,this.currentAttachedFile=null,this.isWebM=!1,this.reader=e._reader}async computeDuration(){const e=await this.getTracks(),r=await Promise.all(e.map(n=>n.computeDuration()));return Math.max(0,...r)}async getTracks(){return await this.readMetadata(),this.segments.flatMap(e=>e.tracks.map(r=>r.inputTrack))}async getMimeType(){await this.readMetadata();const e=await this.getTracks(),r=await Promise.all(e.map(n=>n.getCodecParameterString()));return LD({isWebM:this.isWebM,hasVideo:this.segments.some(n=>n.tracks.some(i=>i.info?.type==="video")),hasAudio:this.segments.some(n=>n.tracks.some(i=>i.info?.type==="audio")),codecStrings:r.filter(Boolean)})}async getMetadataTags(){await this.readMetadata();for(const r of this.segments)r.metadataTagsCollected||(this.reader.fileSize!==null&&await this.loadSegmentMetadata(r),r.metadataTagsCollected=!0);let e={};for(const r of this.segments)e={...e,...r.metadataTags};return e}readMetadata(){return this.readMetadataPromise??=(async()=>{let e=0;for(;;){let r=this.reader.requestSliceRange(e,_u,Xc);if(r instanceof Promise&&(r=await r),!r)break;const n=Hc(r);if(!n)break;const i=n.id;let a=n.size;const o=r.filePos;if(i===bt.EBML){Xf(a);let s=this.reader.requestSlice(o,a);if(s instanceof Promise&&(s=await s),!s)break;this.readContiguousElements(s)}else if(i===bt.Segment){if(await this.readSegment(o,a),a===null||this.reader.fileSize===null)break}else if(i===bt.Cluster){if(this.reader.fileSize===null)break;a===null&&(a=(await B5(this.reader,o,Dg,this.reader.fileSize)).pos-o);const s=El(this.segments);s&&(s.elementEndPos=o+a)}Xf(a),e=o+a}})()}async readSegment(e,r){this.currentSegment={seekHeadSeen:!1,infoSeen:!1,tracksSeen:!1,cuesSeen:!1,tagsSeen:!1,attachmentsSeen:!1,timestampScale:-1,timestampFactor:-1,duration:-1,seekEntries:[],tracks:[],cuePoints:[],dataStartPos:e,elementEndPos:r===null?null:e+r,clusterSeekStartPos:e,lastReadCluster:null,metadataTags:{},metadataTagsCollected:!1},this.segments.push(this.currentSegment);let n=e;for(;this.currentSegment.elementEndPos===null||n<this.currentSegment.elementEndPos;){let s=this.reader.requestSliceRange(n,_u,Xc);if(s instanceof Promise&&(s=await s),!s)break;const l=n,c=Hc(s);if(!c||!i1.includes(c.id)&&c.id!==bt.Void){const y=await O7(this.reader,l,i1,Math.min(this.currentSegment.elementEndPos??1/0,l+N7));if(y){n=y;continue}else break}const{id:f,size:h}=c,d=s.filePos,p=xy.findIndex(y=>y.id===f);if(p!==-1){const y=xy[p].flag;this.currentSegment[y]=!0,Xf(h);let w=this.reader.requestSlice(d,h);w instanceof Promise&&(w=await w),w&&this.readContiguousElements(w)}else if(f===bt.Tags||f===bt.Attachments){f===bt.Tags?this.currentSegment.tagsSeen=!0:this.currentSegment.attachmentsSeen=!0,Xf(h);let y=this.reader.requestSlice(d,h);y instanceof Promise&&(y=await y),y&&this.readContiguousElements(y)}else if(f===bt.Cluster){this.currentSegment.clusterSeekStartPos=l;break}if(h===null)break;n=d+h}if(this.currentSegment.seekEntries.sort((s,l)=>s.segmentPosition-l.segmentPosition),this.reader.fileSize!==null)for(const s of this.currentSegment.seekEntries){const l=xy.find(y=>y.id===s.id);if(!l||this.currentSegment[l.flag])continue;let c=this.reader.requestSliceRange(e+s.segmentPosition,_u,Xc);if(c instanceof Promise&&(c=await c),!c)continue;const f=Hc(c);if(!f)continue;const{id:h,size:d}=f;if(h!==l.id)continue;Xf(d),this.currentSegment[l.flag]=!0;let p=this.reader.requestSlice(c.filePos,d);p instanceof Promise&&(p=await p),p&&this.readContiguousElements(p)}this.currentSegment.timestampScale===-1&&(this.currentSegment.timestampScale=1e6,this.currentSegment.timestampFactor=1e9/1e6),this.currentSegment.tracks.sort((s,l)=>Number(l.disposition.default)-Number(s.disposition.default));const i=new Map(this.currentSegment.tracks.map(s=>[s.id,s]));for(const s of this.currentSegment.cuePoints){const l=i.get(s.trackId);l&&l.cuePoints.push(s)}for(const s of this.currentSegment.tracks){s.cuePoints.sort((l,c)=>l.time-c.time);for(let l=0;l<s.cuePoints.length-1;l++){const c=s.cuePoints[l],f=s.cuePoints[l+1];c.time===f.time&&(s.cuePoints.splice(l+1,1),l--)}}let a=null,o=-1/0;for(const s of this.currentSegment.tracks)s.cuePoints.length>o&&(o=s.cuePoints.length,a=s);for(const s of this.currentSegment.tracks)s.cuePoints.length===0&&(s.cuePoints=a.cuePoints);this.currentSegment=null}async readCluster(e,r){if(r.lastReadCluster?.elementStartPos===e)return r.lastReadCluster;let n=this.reader.requestSliceRange(e,_u,Xc);n instanceof Promise&&(n=await n),$e(n);const i=e,a=Hc(n);$e(a);const o=a.id;$e(o===bt.Cluster);let s=a.size;const l=n.filePos;s===null&&(s=(await B5(this.reader,l,Dg,r.elementEndPos)).pos-l);let c=this.reader.requestSlice(l,s);c instanceof Promise&&(c=await c);const f={segment:r,elementStartPos:i,elementEndPos:l+s,dataStartPos:l,timestamp:-1,trackData:new Map};if(this.currentCluster=f,c){const h=this.readContiguousElements(c,Dg);f.elementEndPos=h}for(const[,h]of f.trackData){const d=h.track;$e(h.blocks.length>0);let p=!1;for(let b=0;b<h.blocks.length;b++){const S=h.blocks[b];S.timestamp+=f.timestamp,p||=S.lacing!==zc.None}h.presentationTimestamps=h.blocks.map((b,S)=>({timestamp:b.timestamp,blockIndex:S})).sort((b,S)=>b.timestamp-S.timestamp);for(let b=0;b<h.presentationTimestamps.length;b++){const S=h.presentationTimestamps[b],E=h.blocks[S.blockIndex];if(h.firstKeyFrameTimestamp===null&&E.isKeyFrame&&(h.firstKeyFrameTimestamp=E.timestamp),b<h.presentationTimestamps.length-1){const _=h.presentationTimestamps[b+1];E.duration=_.timestamp-E.timestamp}else E.duration===0&&d.defaultDuration!=null&&E.lacing===zc.None&&(E.duration=d.defaultDuration)}p&&(this.expandLacedBlocks(h.blocks,d),h.presentationTimestamps=h.blocks.map((b,S)=>({timestamp:b.timestamp,blockIndex:S})).sort((b,S)=>b.timestamp-S.timestamp));const y=h.blocks[h.presentationTimestamps[0].blockIndex],w=h.blocks[El(h.presentationTimestamps).blockIndex];h.startTimestamp=y.timestamp,h.endTimestamp=w.timestamp+w.duration;const x=oi(d.clusterPositionCache,h.startTimestamp,b=>b.startTimestamp);(x===-1||d.clusterPositionCache[x].elementStartPos!==i)&&d.clusterPositionCache.splice(x+1,0,{elementStartPos:f.elementStartPos,startTimestamp:h.startTimestamp})}return r.lastReadCluster=f,f}getTrackDataInCluster(e,r){let n=e.trackData.get(r);if(!n){const i=e.segment.tracks.find(a=>a.id===r);if(!i)return null;n={track:i,startTimestamp:0,endTimestamp:0,firstKeyFrameTimestamp:null,blocks:[],presentationTimestamps:[]},e.trackData.set(r,n)}return n}expandLacedBlocks(e,r){for(let n=0;n<e.length;n++){const i=e[n];if(i.lacing===zc.None)continue;i.decoded||(i.data=this.decodeBlockData(r,i.data),i.decoded=!0);const a=Rp.tempFromBytes(i.data),o=[],s=dr(a)+1;switch(i.lacing){case zc.Xiph:{let c=0;for(let f=0;f<s-1;f++){let h=0;for(;a.bufferPos<a.length;){const d=dr(a);if(h+=d,d<255){o.push(h),c+=h;break}}}o.push(a.length-(a.bufferPos+c))}break;case zc.FixedSize:{const c=a.length-1,f=Math.floor(c/s);for(let h=0;h<s;h++)o.push(f)}break;case zc.Ebml:{const c=E0(a);$e(c!==null);let f=c;o.push(f);let h=f;for(let d=1;d<s-1;d++){const p=a.bufferPos,y=E0(a);$e(y!==null);const w=y,b=(1<<(a.bufferPos-p)*7-1)-1,S=w-b;f+=S,o.push(f),h+=f}o.push(a.length-(a.bufferPos+h))}break;default:$e(!1)}$e(o.length===s),e.splice(n,1);const l=i.duration||s*(r.defaultDuration??0);for(let c=0;c<s;c++){const f=o[c],h=Nr(a,f),d=i.timestamp+l*c/s,p=l/s;e.splice(n+c,0,{timestamp:d,duration:p,isKeyFrame:i.isKeyFrame,data:h,lacing:zc.None,decoded:!0,mainAdditional:i.mainAdditional})}n+=s,n--}}async loadSegmentMetadata(e){for(const r of e.seekEntries){if(!(r.id===bt.Tags&&!e.tagsSeen)){if(!(r.id===bt.Attachments&&!e.attachmentsSeen))continue}let n=this.reader.requestSliceRange(e.dataStartPos+r.segmentPosition,_u,Xc);if(n instanceof Promise&&(n=await n),!n)continue;const i=Hc(n);if(!i||i.id!==r.id)continue;const{size:a}=i;Xf(a),$e(!this.currentSegment),this.currentSegment=e;let o=this.reader.requestSlice(n.filePos,a);o instanceof Promise&&(o=await o),o&&this.readContiguousElements(o),this.currentSegment=null,r.id===bt.Tags?e.tagsSeen=!0:r.id===bt.Attachments&&(e.attachmentsSeen=!0)}}readContiguousElements(e,r){const n=e.filePos;for(;e.filePos-n<=e.length-_u;){const i=e.filePos;if(!this.traverseElement(e,r))return i}return e.filePos}traverseElement(e,r){const n=Hc(e);if(!n||r&&r.includes(n.id))return!1;const{id:i,size:a}=n,o=e.filePos;switch(Xf(a),i){case bt.DocType:this.isWebM=rp(e,a)==="webm";break;case bt.Seek:{if(!this.currentSegment)break;const s={id:-1,segmentPosition:-1};this.currentSegment.seekEntries.push(s),this.readContiguousElements(e.slice(o,a)),(s.id===-1||s.segmentPosition===-1)&&this.currentSegment.seekEntries.pop()}break;case bt.SeekID:{const s=this.currentSegment?.seekEntries[this.currentSegment.seekEntries.length-1];if(!s)break;s.id=Jr(e,a)}break;case bt.SeekPosition:{const s=this.currentSegment?.seekEntries[this.currentSegment.seekEntries.length-1];if(!s)break;s.segmentPosition=Jr(e,a)}break;case bt.TimestampScale:{if(!this.currentSegment)break;this.currentSegment.timestampScale=Jr(e,a),this.currentSegment.timestampFactor=1e9/this.currentSegment.timestampScale}break;case bt.Duration:{if(!this.currentSegment)break;this.currentSegment.duration=wy(e,a)}break;case bt.TrackEntry:{if(!this.currentSegment)break;if(this.currentTrack={id:-1,segment:this.currentSegment,demuxer:this,clusterPositionCache:[],cuePoints:[],disposition:{...Sd},inputTrack:null,codecId:null,codecPrivate:null,defaultDuration:null,name:null,languageCode:ku,decodingInstructions:[],info:null},this.readContiguousElements(e.slice(o,a)),this.currentTrack.decodingInstructions.some(s=>s.data?.type!=="decompress"||s.scope!==dm.Block||s.data.algorithm!==j0.HeaderStripping)&&(console.warn(`Track #${this.currentTrack.id} has an unsupported content encoding; dropping.`),this.currentTrack=null),this.currentTrack&&this.currentTrack.id!==-1&&this.currentTrack.codecId&&this.currentTrack.info){const s=this.currentTrack.codecId.indexOf("/"),l=s===-1?this.currentTrack.codecId:this.currentTrack.codecId.slice(0,s);if(this.currentTrack.info.type==="video"&&this.currentTrack.info.width!==-1&&this.currentTrack.info.height!==-1){this.currentTrack.codecId===ac.avc?(this.currentTrack.info.codec="avc",this.currentTrack.info.codecDescription=this.currentTrack.codecPrivate):this.currentTrack.codecId===ac.hevc?(this.currentTrack.info.codec="hevc",this.currentTrack.info.codecDescription=this.currentTrack.codecPrivate):l===ac.vp8?this.currentTrack.info.codec="vp8":l===ac.vp9?this.currentTrack.info.codec="vp9":l===ac.av1&&(this.currentTrack.info.codec="av1");const c=this.currentTrack,f=new b1(this.input,new MD(c));this.currentTrack.inputTrack=f,this.currentSegment.tracks.push(this.currentTrack)}else if(this.currentTrack.info.type==="audio"&&this.currentTrack.info.numberOfChannels!==-1&&this.currentTrack.info.sampleRate!==-1){l===ac.aac?(this.currentTrack.info.codec="aac",this.currentTrack.info.aacCodecInfo={isMpeg2:this.currentTrack.codecId.includes("MPEG2")},this.currentTrack.info.codecDescription=this.currentTrack.codecPrivate):this.currentTrack.codecId===ac.mp3?this.currentTrack.info.codec="mp3":l===ac.opus?(this.currentTrack.info.codec="opus",this.currentTrack.info.codecDescription=this.currentTrack.codecPrivate,this.currentTrack.info.sampleRate=Ym):l===ac.vorbis?(this.currentTrack.info.codec="vorbis",this.currentTrack.info.codecDescription=this.currentTrack.codecPrivate):l===ac.flac?(this.currentTrack.info.codec="flac",this.currentTrack.info.codecDescription=this.currentTrack.codecPrivate):this.currentTrack.codecId==="A_PCM/INT/LIT"?this.currentTrack.info.bitDepth===8?this.currentTrack.info.codec="pcm-u8":this.currentTrack.info.bitDepth===16?this.currentTrack.info.codec="pcm-s16":this.currentTrack.info.bitDepth===24?this.currentTrack.info.codec="pcm-s24":this.currentTrack.info.bitDepth===32&&(this.currentTrack.info.codec="pcm-s32"):this.currentTrack.codecId==="A_PCM/INT/BIG"?this.currentTrack.info.bitDepth===8?this.currentTrack.info.codec="pcm-u8":this.currentTrack.info.bitDepth===16?this.currentTrack.info.codec="pcm-s16be":this.currentTrack.info.bitDepth===24?this.currentTrack.info.codec="pcm-s24be":this.currentTrack.info.bitDepth===32&&(this.currentTrack.info.codec="pcm-s32be"):this.currentTrack.codecId==="A_PCM/FLOAT/IEEE"&&(this.currentTrack.info.bitDepth===32?this.currentTrack.info.codec="pcm-f32":this.currentTrack.info.bitDepth===64&&(this.currentTrack.info.codec="pcm-f64"));const c=this.currentTrack,f=new xc(this.input,new DD(c));this.currentTrack.inputTrack=f,this.currentSegment.tracks.push(this.currentTrack)}}this.currentTrack=null}break;case bt.TrackNumber:{if(!this.currentTrack)break;this.currentTrack.id=Jr(e,a)}break;case bt.TrackType:{if(!this.currentTrack)break;const s=Jr(e,a);s===1?this.currentTrack.info={type:"video",width:-1,height:-1,rotation:0,codec:null,codecDescription:null,colorSpace:null,alphaMode:!1}:s===2&&(this.currentTrack.info={type:"audio",numberOfChannels:-1,sampleRate:-1,bitDepth:-1,codec:null,codecDescription:null,aacCodecInfo:null})}break;case bt.FlagEnabled:{if(!this.currentTrack)break;Jr(e,a)||(this.currentSegment.tracks.pop(),this.currentTrack=null)}break;case bt.FlagDefault:{if(!this.currentTrack)break;this.currentTrack.disposition.default=!!Jr(e,a)}break;case bt.FlagForced:{if(!this.currentTrack)break;this.currentTrack.disposition.forced=!!Jr(e,a)}break;case bt.FlagOriginal:{if(!this.currentTrack)break;this.currentTrack.disposition.original=!!Jr(e,a)}break;case bt.FlagHearingImpaired:{if(!this.currentTrack)break;this.currentTrack.disposition.hearingImpaired=!!Jr(e,a)}break;case bt.FlagVisualImpaired:{if(!this.currentTrack)break;this.currentTrack.disposition.visuallyImpaired=!!Jr(e,a)}break;case bt.FlagCommentary:{if(!this.currentTrack)break;this.currentTrack.disposition.commentary=!!Jr(e,a)}break;case bt.CodecID:{if(!this.currentTrack)break;this.currentTrack.codecId=rp(e,a)}break;case bt.CodecPrivate:{if(!this.currentTrack)break;this.currentTrack.codecPrivate=Nr(e,a)}break;case bt.DefaultDuration:{if(!this.currentTrack)break;this.currentTrack.defaultDuration=this.currentTrack.segment.timestampFactor*Jr(e,a)/1e9}break;case bt.Name:{if(!this.currentTrack)break;this.currentTrack.name=c0(e,a)}break;case bt.Language:{if(!this.currentTrack||this.currentTrack.languageCode!==ku)break;this.currentTrack.languageCode=rp(e,a),n7(this.currentTrack.languageCode)||(this.currentTrack.languageCode=ku)}break;case bt.LanguageBCP47:{if(!this.currentTrack)break;const l=rp(e,a).split("-")[0];l?this.currentTrack.languageCode=l:this.currentTrack.languageCode=ku}break;case bt.Video:{if(this.currentTrack?.info?.type!=="video")break;this.readContiguousElements(e.slice(o,a))}break;case bt.PixelWidth:{if(this.currentTrack?.info?.type!=="video")break;this.currentTrack.info.width=Jr(e,a)}break;case bt.PixelHeight:{if(this.currentTrack?.info?.type!=="video")break;this.currentTrack.info.height=Jr(e,a)}break;case bt.AlphaMode:{if(this.currentTrack?.info?.type!=="video")break;this.currentTrack.info.alphaMode=Jr(e,a)===1}break;case bt.Colour:{if(this.currentTrack?.info?.type!=="video")break;this.currentTrack.info.colorSpace={},this.readContiguousElements(e.slice(o,a))}break;case bt.MatrixCoefficients:{if(this.currentTrack?.info?.type!=="video"||!this.currentTrack.info.colorSpace)break;const s=Jr(e,a),l=e7[s]??null;this.currentTrack.info.colorSpace.matrix=l}break;case bt.Range:{if(this.currentTrack?.info?.type!=="video"||!this.currentTrack.info.colorSpace)break;this.currentTrack.info.colorSpace.fullRange=Jr(e,a)===2}break;case bt.TransferCharacteristics:{if(this.currentTrack?.info?.type!=="video"||!this.currentTrack.info.colorSpace)break;const s=Jr(e,a),l=Jk[s]??null;this.currentTrack.info.colorSpace.transfer=l}break;case bt.Primaries:{if(this.currentTrack?.info?.type!=="video"||!this.currentTrack.info.colorSpace)break;const s=Jr(e,a),l=Qk[s]??null;this.currentTrack.info.colorSpace.primaries=l}break;case bt.Projection:{if(this.currentTrack?.info?.type!=="video")break;this.readContiguousElements(e.slice(o,a))}break;case bt.ProjectionPoseRoll:{if(this.currentTrack?.info?.type!=="video")break;const l=-wy(e,a);try{this.currentTrack.info.rotation=Zk(l)}catch{}}break;case bt.Audio:{if(this.currentTrack?.info?.type!=="audio")break;this.readContiguousElements(e.slice(o,a))}break;case bt.SamplingFrequency:{if(this.currentTrack?.info?.type!=="audio")break;this.currentTrack.info.sampleRate=wy(e,a)}break;case bt.Channels:{if(this.currentTrack?.info?.type!=="audio")break;this.currentTrack.info.numberOfChannels=Jr(e,a)}break;case bt.BitDepth:{if(this.currentTrack?.info?.type!=="audio")break;this.currentTrack.info.bitDepth=Jr(e,a)}break;case bt.CuePoint:{if(!this.currentSegment)break;this.readContiguousElements(e.slice(o,a)),this.currentCueTime=null}break;case bt.CueTime:this.currentCueTime=Jr(e,a);break;case bt.CueTrackPositions:{if(this.currentCueTime===null)break;$e(this.currentSegment);const s={time:this.currentCueTime,trackId:-1,clusterPosition:-1};this.currentSegment.cuePoints.push(s),this.readContiguousElements(e.slice(o,a)),(s.trackId===-1||s.clusterPosition===-1)&&this.currentSegment.cuePoints.pop()}break;case bt.CueTrack:{const s=this.currentSegment?.cuePoints[this.currentSegment.cuePoints.length-1];if(!s)break;s.trackId=Jr(e,a)}break;case bt.CueClusterPosition:{const s=this.currentSegment?.cuePoints[this.currentSegment.cuePoints.length-1];if(!s)break;$e(this.currentSegment),s.clusterPosition=this.currentSegment.dataStartPos+Jr(e,a)}break;case bt.Timestamp:{if(!this.currentCluster)break;this.currentCluster.timestamp=Jr(e,a)}break;case bt.SimpleBlock:{if(!this.currentCluster)break;const s=E0(e);if(s===null)break;const l=this.getTrackDataInCluster(this.currentCluster,s);if(!l)break;const c=H5(e),f=dr(e),h=f>>1&3;let d=!!(f&128);l.track.info?.type==="audio"&&l.track.info.codec&&(d=!0);const p=Nr(e,a-(e.filePos-o)),y=l.track.decodingInstructions.length>0;l.blocks.push({timestamp:c,duration:0,isKeyFrame:d,data:p,lacing:h,decoded:!y,mainAdditional:null})}break;case bt.BlockGroup:{if(!this.currentCluster)break;this.readContiguousElements(e.slice(o,a)),this.currentBlock=null}break;case bt.Block:{if(!this.currentCluster)break;const s=E0(e);if(s===null)break;const l=this.getTrackDataInCluster(this.currentCluster,s);if(!l)break;const c=H5(e),h=dr(e)>>1&3,d=Nr(e,a-(e.filePos-o)),p=l.track.decodingInstructions.length>0;this.currentBlock={timestamp:c,duration:0,isKeyFrame:!0,data:d,lacing:h,decoded:!p,mainAdditional:null},l.blocks.push(this.currentBlock)}break;case bt.BlockAdditions:this.readContiguousElements(e.slice(o,a));break;case bt.BlockMore:{if(!this.currentBlock)break;this.currentBlockAdditional={addId:1,data:null},this.readContiguousElements(e.slice(o,a)),this.currentBlockAdditional.data&&this.currentBlockAdditional.addId===1&&(this.currentBlock.mainAdditional=this.currentBlockAdditional.data),this.currentBlockAdditional=null}break;case bt.BlockAdditional:{if(!this.currentBlockAdditional)break;this.currentBlockAdditional.data=Nr(e,a)}break;case bt.BlockAddID:{if(!this.currentBlockAdditional)break;this.currentBlockAdditional.addId=Jr(e,a)}break;case bt.BlockDuration:{if(!this.currentBlock)break;this.currentBlock.duration=Jr(e,a)}break;case bt.ReferenceBlock:{if(!this.currentBlock)break;this.currentBlock.isKeyFrame=!1}break;case bt.Tag:this.currentTagTargetIsMovie=!0,this.readContiguousElements(e.slice(o,a));break;case bt.Targets:this.readContiguousElements(e.slice(o,a));break;case bt.TargetTypeValue:Jr(e,a)!==50&&(this.currentTagTargetIsMovie=!1);break;case bt.TagTrackUID:case bt.TagEditionUID:case bt.TagChapterUID:case bt.TagAttachmentUID:this.currentTagTargetIsMovie=!1;break;case bt.SimpleTag:{if(!this.currentTagTargetIsMovie)break;this.currentSimpleTagName=null,this.readContiguousElements(e.slice(o,a))}break;case bt.TagName:this.currentSimpleTagName=c0(e,a);break;case bt.TagString:{if(!this.currentSimpleTagName)break;const s=c0(e,a);this.processTagValue(this.currentSimpleTagName,s)}break;case bt.TagBinary:{if(!this.currentSimpleTagName)break;const s=Nr(e,a);this.processTagValue(this.currentSimpleTagName,s)}break;case bt.AttachedFile:{if(!this.currentSegment)break;this.currentAttachedFile={fileUid:null,fileName:null,fileMediaType:null,fileData:null,fileDescription:null},this.readContiguousElements(e.slice(o,a));const s=this.currentSegment.metadataTags;if(this.currentAttachedFile.fileUid&&this.currentAttachedFile.fileData&&(s.raw??={},s.raw[this.currentAttachedFile.fileUid.toString()]=new l7(this.currentAttachedFile.fileData,this.currentAttachedFile.fileMediaType??void 0,this.currentAttachedFile.fileName??void 0,this.currentAttachedFile.fileDescription??void 0)),this.currentAttachedFile.fileMediaType?.startsWith("image/")&&this.currentAttachedFile.fileData){const l=this.currentAttachedFile.fileName;let c="unknown";if(l){const f=l.toLowerCase();f.startsWith("cover.")?c="coverFront":f.startsWith("back.")&&(c="coverBack")}s.images??=[],s.images.push({data:this.currentAttachedFile.fileData,mimeType:this.currentAttachedFile.fileMediaType,kind:c,name:this.currentAttachedFile.fileName??void 0,description:this.currentAttachedFile.fileDescription??void 0})}this.currentAttachedFile=null}break;case bt.FileUID:{if(!this.currentAttachedFile)break;this.currentAttachedFile.fileUid=ID(e,a)}break;case bt.FileName:{if(!this.currentAttachedFile)break;this.currentAttachedFile.fileName=c0(e,a)}break;case bt.FileMediaType:{if(!this.currentAttachedFile)break;this.currentAttachedFile.fileMediaType=rp(e,a)}break;case bt.FileData:{if(!this.currentAttachedFile)break;this.currentAttachedFile.fileData=Nr(e,a)}break;case bt.FileDescription:{if(!this.currentAttachedFile)break;this.currentAttachedFile.fileDescription=c0(e,a)}break;case bt.ContentEncodings:{if(!this.currentTrack)break;this.readContiguousElements(e.slice(o,a)),this.currentTrack.decodingInstructions.sort((s,l)=>l.order-s.order)}break;case bt.ContentEncoding:this.currentDecodingInstruction={order:0,scope:dm.Block,data:null},this.readContiguousElements(e.slice(o,a)),this.currentDecodingInstruction.data&&this.currentTrack.decodingInstructions.push(this.currentDecodingInstruction),this.currentDecodingInstruction=null;break;case bt.ContentEncodingOrder:{if(!this.currentDecodingInstruction)break;this.currentDecodingInstruction.order=Jr(e,a)}break;case bt.ContentEncodingScope:{if(!this.currentDecodingInstruction)break;this.currentDecodingInstruction.scope=Jr(e,a)}break;case bt.ContentCompression:{if(!this.currentDecodingInstruction)break;this.currentDecodingInstruction.data={type:"decompress",algorithm:j0.Zlib,settings:null},this.readContiguousElements(e.slice(o,a))}break;case bt.ContentCompAlgo:{if(this.currentDecodingInstruction?.data?.type!=="decompress")break;this.currentDecodingInstruction.data.algorithm=Jr(e,a)}break;case bt.ContentCompSettings:{if(this.currentDecodingInstruction?.data?.type!=="decompress")break;this.currentDecodingInstruction.data.settings=Nr(e,a)}break;case bt.ContentEncryption:{if(!this.currentDecodingInstruction)break;this.currentDecodingInstruction.data={type:"decrypt"}}break}return e.filePos=o+a,!0}decodeBlockData(e,r){$e(e.decodingInstructions.length>0);let n=r;for(const i of e.decodingInstructions)switch($e(i.data),i.data.type){case"decompress":switch(i.data.algorithm){case j0.HeaderStripping:if(i.data.settings&&i.data.settings.length>0){const a=i.data.settings,o=new Uint8Array(a.length+n.length);o.set(a,0),o.set(n,a.length),n=o}break}break}return n}processTagValue(e,r){if(!this.currentSegment?.metadataTags)return;const n=this.currentSegment.metadataTags;if(n.raw??={},n.raw[e]??=r,typeof r=="string")switch(e.toLowerCase()){case"title":n.title??=r;break;case"description":n.description??=r;break;case"artist":n.artist??=r;break;case"album":n.album??=r;break;case"album_artist":n.albumArtist??=r;break;case"genre":n.genre??=r;break;case"comment":n.comment??=r;break;case"lyrics":n.lyrics??=r;break;case"date":{const i=new Date(r);Number.isNaN(i.getTime())||(n.date??=i)}break;case"track_number":case"part_number":{const i=r.split("/"),a=Number.parseInt(i[0],10),o=i[1]&&Number.parseInt(i[1],10);Number.isInteger(a)&&a>0&&(n.trackNumber??=a),o&&Number.isInteger(o)&&o>0&&(n.tracksTotal??=o)}break;case"disc_number":case"disc":{const i=r.split("/"),a=Number.parseInt(i[0],10),o=i[1]&&Number.parseInt(i[1],10);Number.isInteger(a)&&a>0&&(n.discNumber??=a),o&&Number.isInteger(o)&&o>0&&(n.discsTotal??=o)}break}}}class I7{constructor(e){this.internalTrack=e,this.packetToClusterLocation=new WeakMap}getId(){return this.internalTrack.id}getCodec(){throw new Error("Not implemented on base class.")}getInternalCodecId(){return this.internalTrack.codecId}async computeDuration(){const e=await this.getPacket(1/0,{metadataOnly:!0});return(e?.timestamp??0)+(e?.duration??0)}getName(){return this.internalTrack.name}getLanguageCode(){return this.internalTrack.languageCode}async getFirstTimestamp(){return(await this.getFirstPacket({metadataOnly:!0}))?.timestamp??0}getTimeResolution(){return this.internalTrack.segment.timestampFactor}getDisposition(){return this.internalTrack.disposition}async getFirstPacket(e){return this.performClusterLookup(null,r=>r.trackData.get(this.internalTrack.id)?{blockIndex:0,correctBlockFound:!0}:{blockIndex:-1,correctBlockFound:!1},-1/0,1/0,e)}intoTimescale(e){return fm(e*this.internalTrack.segment.timestampFactor)}async getPacket(e,r){const n=this.intoTimescale(e);return this.performClusterLookup(null,i=>{const a=i.trackData.get(this.internalTrack.id);if(!a)return{blockIndex:-1,correctBlockFound:!1};const o=oi(a.presentationTimestamps,n,c=>c.timestamp),s=o!==-1?a.presentationTimestamps[o].blockIndex:-1,l=o!==-1&&n<a.endTimestamp;return{blockIndex:s,correctBlockFound:l}},n,n,r)}async getNextPacket(e,r){const n=this.packetToClusterLocation.get(e);if(n===void 0)throw new Error("Packet was not created from this track.");return this.performClusterLookup(n.cluster,i=>{if(i===n.cluster){const a=i.trackData.get(this.internalTrack.id);if(n.blockIndex+1<a.blocks.length)return{blockIndex:n.blockIndex+1,correctBlockFound:!0}}else if(i.trackData.get(this.internalTrack.id))return{blockIndex:0,correctBlockFound:!0};return{blockIndex:-1,correctBlockFound:!1}},-1/0,1/0,r)}async getKeyPacket(e,r){const n=this.intoTimescale(e);return this.performClusterLookup(null,i=>{const a=i.trackData.get(this.internalTrack.id);if(!a)return{blockIndex:-1,correctBlockFound:!1};const o=r7(a.presentationTimestamps,c=>a.blocks[c.blockIndex].isKeyFrame&&c.timestamp<=n),s=o!==-1?a.presentationTimestamps[o].blockIndex:-1,l=o!==-1&&n<a.endTimestamp;return{blockIndex:s,correctBlockFound:l}},n,n,r)}async getNextKeyPacket(e,r){const n=this.packetToClusterLocation.get(e);if(n===void 0)throw new Error("Packet was not created from this track.");return this.performClusterLookup(n.cluster,i=>{if(i===n.cluster){const o=i.trackData.get(this.internalTrack.id).blocks.findIndex((s,l)=>s.isKeyFrame&&l>n.blockIndex);if(o!==-1)return{blockIndex:o,correctBlockFound:!0}}else{const a=i.trackData.get(this.internalTrack.id);if(a&&a.firstKeyFrameTimestamp!==null){const o=a.blocks.findIndex(s=>s.isKeyFrame);return $e(o!==-1),{blockIndex:o,correctBlockFound:!0}}}return{blockIndex:-1,correctBlockFound:!1}},-1/0,1/0,r)}async fetchPacketInCluster(e,r,n){if(r===-1)return null;const a=e.trackData.get(this.internalTrack.id).blocks[r];$e(a),a.decoded||(a.data=this.internalTrack.demuxer.decodeBlockData(this.internalTrack,a.data),a.decoded=!0);const o=n.metadataOnly?Zl:a.data,s=a.timestamp/this.internalTrack.segment.timestampFactor,l=a.duration/this.internalTrack.segment.timestampFactor,c={};a.mainAdditional&&this.internalTrack.info?.type==="video"&&this.internalTrack.info.alphaMode&&(c.alpha=n.metadataOnly?Zl:a.mainAdditional,c.alphaByteLength=a.mainAdditional.byteLength);const f=new Bo(o,a.isKeyFrame?"key":"delta",s,l,e.dataStartPos+r,a.data.byteLength,c);return this.packetToClusterLocation.set(f,{cluster:e,blockIndex:r}),f}async performClusterLookup(e,r,n,i,a){const{demuxer:o,segment:s}=this.internalTrack;let l=null,c=null,f=-1;if(e){const{blockIndex:b,correctBlockFound:S}=r(e);if(S)return this.fetchPacketInCluster(e,b,a);b!==-1&&(c=e,f=b)}const h=oi(this.internalTrack.cuePoints,n,b=>b.time),d=h!==-1?this.internalTrack.cuePoints[h]:null,p=oi(this.internalTrack.clusterPositionCache,n,b=>b.startTimestamp),y=p!==-1?this.internalTrack.clusterPositionCache[p]:null,w=Math.max(d?.clusterPosition??0,y?.elementStartPos??0)||null;let x;for(e?w===null||e.elementStartPos>=w?(x=e.elementEndPos,l=e):x=w:x=w??s.clusterSeekStartPos;s.elementEndPos===null||x<=s.elementEndPos-_u;){if(l){const N=l.trackData.get(this.internalTrack.id);if(N&&N.startTimestamp>i)break}let b=o.reader.requestSliceRange(x,_u,Xc);if(b instanceof Promise&&(b=await b),!b)break;const S=x,E=Hc(b);if(!E||!i1.includes(E.id)&&E.id!==bt.Void){const N=await O7(o.reader,S,i1,Math.min(s.elementEndPos??1/0,S+N7));if(N){x=N;continue}else break}const _=E.id;let P=E.size;const O=b.filePos;if(_===bt.Cluster){l=await o.readCluster(S,s),P=l.elementEndPos-O;const{blockIndex:N,correctBlockFound:D}=r(l);if(D)return this.fetchPacketInCluster(l,N,a);N!==-1&&(c=l,f=N)}P===null&&($e(_!==bt.Cluster),P=(await B5(o.reader,O,Dg,s.elementEndPos)).pos-O);const T=O+P;if(s.elementEndPos===null){let N=o.reader.requestSliceRange(T,_u,Xc);if(N instanceof Promise&&(N=await N),!N)break;if(Gb(N)===bt.Segment){s.elementEndPos=T;break}}x=T}if(d&&(!c||c.elementStartPos<d.clusterPosition)){const b=this.internalTrack.cuePoints[h-1];$e(!b||b.time<d.time);const S=b?.time??-1/0;return this.performClusterLookup(null,r,S,i,a)}return c?this.fetchPacketInCluster(c,f,a):null}}class MD extends I7{constructor(e){super(e),this.decoderConfigPromise=null,this.internalTrack=e}getCodec(){return this.internalTrack.info.codec}getCodedWidth(){return this.internalTrack.info.width}getCodedHeight(){return this.internalTrack.info.height}getRotation(){return this.internalTrack.info.rotation}async getColorSpace(){return{primaries:this.internalTrack.info.colorSpace?.primaries,transfer:this.internalTrack.info.colorSpace?.transfer,matrix:this.internalTrack.info.colorSpace?.matrix,fullRange:this.internalTrack.info.colorSpace?.fullRange}}async canBeTransparent(){return this.internalTrack.info.alphaMode}async getDecoderConfig(){return this.internalTrack.info.codec?this.decoderConfigPromise??=(async()=>{let e=null;return(this.internalTrack.info.codec==="vp9"||this.internalTrack.info.codec==="av1"||this.internalTrack.info.codec==="avc"&&!this.internalTrack.info.codecDescription||this.internalTrack.info.codec==="hevc"&&!this.internalTrack.info.codecDescription)&&(e=await this.getFirstPacket({})),{codec:u7({width:this.internalTrack.info.width,height:this.internalTrack.info.height,codec:this.internalTrack.info.codec,codecDescription:this.internalTrack.info.codecDescription,colorSpace:this.internalTrack.info.colorSpace,avcType:1,avcCodecInfo:this.internalTrack.info.codec==="avc"&&e?YM(e.data):null,hevcCodecInfo:this.internalTrack.info.codec==="hevc"&&e?ZM(e.data):null,vp9CodecInfo:this.internalTrack.info.codec==="vp9"&&e?v7(e.data):null,av1CodecInfo:this.internalTrack.info.codec==="av1"&&e?b7(e.data):null}),codedWidth:this.internalTrack.info.width,codedHeight:this.internalTrack.info.height,description:this.internalTrack.info.codecDescription??void 0,colorSpace:this.internalTrack.info.colorSpace??void 0}})():null}}class DD extends I7{constructor(e){super(e),this.decoderConfig=null,this.internalTrack=e}getCodec(){return this.internalTrack.info.codec}getNumberOfChannels(){return this.internalTrack.info.numberOfChannels}getSampleRate(){return this.internalTrack.info.sampleRate}async getDecoderConfig(){return this.internalTrack.info.codec?this.decoderConfig??={codec:c7({codec:this.internalTrack.info.codec,codecDescription:this.internalTrack.info.codecDescription,aacCodecInfo:this.internalTrack.info.aacCodecInfo}),numberOfChannels:this.internalTrack.info.numberOfChannels,sampleRate:this.internalTrack.info.sampleRate,description:this.internalTrack.info.codecDescription??void 0}:null}}const L7=4,FD=[44100,48e3,32e3],BD=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1,-1,32,48,56,64,80,96,112,128,160,192,224,256,320,384,-1,-1,32,64,96,128,160,192,224,256,288,320,352,384,416,448,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,16,24,32,40,48,56,64,80,96,112,128,144,160,-1,-1,8,16,24,32,40,48,56,64,80,96,112,128,144,160,-1,-1,32,48,56,64,80,96,112,128,144,160,176,192,224,256,-1],jD=1483304551,zD=1231971951,UD=(t,e,r,n,i)=>e===0?0:e===1?Math.floor(144*r/(n<<t))+i:e===2?Math.floor(144*r/n)+i:(Math.floor(12*r/n)+i)*4,qD=(t,e)=>t===3?e===3?21:36:e===3?13:21,HD=(t,e)=>{const r=t>>>24,n=t>>>16&255,i=t>>>8&255,a=t&255;if(r!==255&&n!==255&&i!==255&&a!==255)return{header:null,bytesAdvanced:4};if(r!==255)return{header:null,bytesAdvanced:1};if((n&224)!==224)return{header:null,bytesAdvanced:1};let o=0,s=0;n&16?o=n&8?0:1:(o=1,s=1);const l=n>>3&3,c=n>>1&3,f=i>>4&15,h=(i>>2&3)%3,d=i>>1&1,p=a>>6&3,y=a>>4&3,w=a>>3&1,x=a>>2&1,b=a&3,S=BD[o*16*4+c*16+f];if(S===-1)return{header:null,bytesAdvanced:1};const E=S*1e3,_=FD[h]>>o+s,P=UD(o,c,E,_,d);if(e!==null&&e<P)return{header:null,bytesAdvanced:1};let O;return l===3?O=c===3?384:1152:c===3?O=384:c===2?O=1152:O=576,{header:{totalSize:P,mpegVersionId:l,layer:c,bitrate:E,frequencyIndex:h,sampleRate:_,channel:p,modeExtension:y,copyright:w,original:x,emphasis:b,audioSamplesInFrame:O},bytesAdvanced:1}},j5=t=>{let e=2130706432,r=0;for(;e!==0;)r>>=1,r|=t&e,e>>=8;return r};var fp;(function(t){t[t.Unsynchronisation=128]="Unsynchronisation",t[t.ExtendedHeader=64]="ExtendedHeader",t[t.ExperimentalIndicator=32]="ExperimentalIndicator",t[t.Footer=16]="Footer"})(fp||(fp={}));var hp;(function(t){t[t.ISO_8859_1=0]="ISO_8859_1",t[t.UTF_16_WITH_BOM=1]="UTF_16_WITH_BOM",t[t.UTF_16_BE_NO_BOM=2]="UTF_16_BE_NO_BOM",t[t.UTF_8=3]="UTF_8"})(hp||(hp={}));const Fg=128,pm=10,dp=["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"],VD=(t,e)=>{const r=t.filePos;e.raw??={},e.raw.TAG??=Nr(t,Fg-3),t.filePos=r;const n=Gd(t,30);n&&(e.title??=n);const i=Gd(t,30);i&&(e.artist??=i);const a=Gd(t,30);a&&(e.album??=a);const o=Gd(t,4),s=Number.parseInt(o,10);Number.isInteger(s)&&s>0&&(e.date??=new Date(s,0,1));const l=Nr(t,30);let c;if(l[28]===0&&l[29]!==0){const h=l[29];h>0&&(e.trackNumber??=h),t.skip(-30),c=Gd(t,28),t.skip(2)}else t.skip(-30),c=Gd(t,30);c&&(e.comment??=c);const f=dr(t);f<dp.length&&(e.genre??=dp[f])},Gd=(t,e)=>{const r=Nr(t,e),n=ep(r.indexOf(0),r.length),i=r.subarray(0,n);let a="";for(let o=0;o<i.length;o++)a+=String.fromCharCode(i[o]);return a.trimEnd()},gm=t=>{const e=t.filePos,r=Fo(t,3),n=dr(t),i=dr(t),a=dr(t),o=Dt(t);if(r!=="ID3"||n===255||i===255||(o&2155905152)!==0)return t.filePos=e,null;const s=j5(o);return{majorVersion:n,revision:i,flags:a,size:s}},R7=(t,e,r)=>{if(![2,3,4].includes(e.majorVersion)){console.warn(`Unsupported ID3v2 major version: ${e.majorVersion}`);return}const n=Nr(t,e.size),i=new $D(e,n);if(e.flags&fp.Footer&&i.removeFooter(),e.flags&fp.Unsynchronisation&&e.majorVersion===3&&i.ununsynchronizeAll(),e.flags&fp.ExtendedHeader){const a=i.readU32();e.majorVersion===3?i.pos+=a:i.pos+=a-4}for(;i.pos<=i.bytes.length-i.frameHeaderSize();){const a=i.readId3V2Frame();if(!a)break;const o=i.pos,s=i.pos+a.size;let l=!1,c=!1,f=!1;if(e.majorVersion===3?(l=!!(a.flags&64),c=!!(a.flags&128)):e.majorVersion===4&&(l=!!(a.flags&4),c=!!(a.flags&8),f=!!(a.flags&2)||!!(e.flags&fp.Unsynchronisation)),l){console.warn(`Skipping encrypted ID3v2 frame ${a.id}`),i.pos=s;continue}if(c){console.warn(`Skipping compressed ID3v2 frame ${a.id}`),i.pos=s;continue}switch(f&&i.ununsynchronizeRegion(i.pos,s),r.raw??={},a.id[0]==="T"?r.raw[a.id]??=i.readId3V2EncodingAndText(s):r.raw[a.id]??=i.readBytes(a.size),i.pos=o,a.id){case"TIT2":case"TT2":r.title??=i.readId3V2EncodingAndText(s);break;case"TIT3":case"TT3":r.description??=i.readId3V2EncodingAndText(s);break;case"TPE1":case"TP1":r.artist??=i.readId3V2EncodingAndText(s);break;case"TALB":case"TAL":r.album??=i.readId3V2EncodingAndText(s);break;case"TPE2":case"TP2":r.albumArtist??=i.readId3V2EncodingAndText(s);break;case"TRCK":case"TRK":{const d=i.readId3V2EncodingAndText(s).split("/"),p=Number.parseInt(d[0],10),y=d[1]&&Number.parseInt(d[1],10);Number.isInteger(p)&&p>0&&(r.trackNumber??=p),y&&Number.isInteger(y)&&y>0&&(r.tracksTotal??=y)}break;case"TPOS":case"TPA":{const d=i.readId3V2EncodingAndText(s).split("/"),p=Number.parseInt(d[0],10),y=d[1]&&Number.parseInt(d[1],10);Number.isInteger(p)&&p>0&&(r.discNumber??=p),y&&Number.isInteger(y)&&y>0&&(r.discsTotal??=y)}break;case"TCON":case"TCO":{const h=i.readId3V2EncodingAndText(s);let d=/^\((\d+)\)/.exec(h);if(d){const p=Number.parseInt(d[1]);if(dp[p]!==void 0){r.genre??=dp[p];break}}if(d=/^\d+$/.exec(h),d){const p=Number.parseInt(d[0]);if(dp[p]!==void 0){r.genre??=dp[p];break}}r.genre??=h}break;case"TDRC":case"TDAT":{const h=i.readId3V2EncodingAndText(s),d=new Date(h);Number.isNaN(d.getTime())||(r.date??=d)}break;case"TYER":case"TYE":{const h=i.readId3V2EncodingAndText(s),d=Number.parseInt(h,10);Number.isInteger(d)&&(r.date??=new Date(d,0,1))}break;case"USLT":case"ULT":{const h=i.readU8();i.pos+=3,i.readId3V2Text(h,s),r.lyrics??=i.readId3V2Text(h,s)}break;case"COMM":case"COM":{const h=i.readU8();i.pos+=3,i.readId3V2Text(h,s),r.comment??=i.readId3V2Text(h,s)}break;case"APIC":case"PIC":{const h=i.readId3V2TextEncoding();let d;if(e.majorVersion===2){const x=i.readAscii(3);d=x==="PNG"?"image/png":x==="JPG"?"image/jpeg":"image/*"}else d=i.readId3V2Text(h,s);const p=i.readU8(),y=i.readId3V2Text(h,s).trimEnd(),w=s-i.pos;if(w>=0){const x=i.readBytes(w);r.images||(r.images=[]),r.images.push({data:x,mimeType:d,kind:p===3?"coverFront":p===4?"coverBack":"unknown",description:y})}}break;default:i.pos+=a.size;break}i.pos=s}};class $D{constructor(e,r){this.header=e,this.bytes=r,this.pos=0,this.view=new DataView(r.buffer,r.byteOffset,r.byteLength)}frameHeaderSize(){return this.header.majorVersion===2?6:10}ununsynchronizeAll(){const e=[];for(let r=0;r<this.bytes.length;r++){const n=this.bytes[r];e.push(n),n===255&&r!==this.bytes.length-1&&this.bytes[r]===0&&r++}this.bytes=new Uint8Array(e),this.view=new DataView(this.bytes.buffer)}ununsynchronizeRegion(e,r){const n=[];for(let o=e;o<r;o++){const s=this.bytes[o];n.push(s),s===255&&o!==r-1&&this.bytes[o+1]===0&&o++}const i=this.bytes.subarray(0,e),a=this.bytes.subarray(r);this.bytes=new Uint8Array(i.length+n.length+a.length),this.bytes.set(i,0),this.bytes.set(n,i.length),this.bytes.set(a,i.length+n.length),this.view=new DataView(this.bytes.buffer)}removeFooter(){this.bytes=this.bytes.subarray(0,this.bytes.length-pm),this.view=new DataView(this.bytes.buffer)}readBytes(e){const r=this.bytes.subarray(this.pos,this.pos+e);return this.pos+=e,r}readU8(){const e=this.view.getUint8(this.pos);return this.pos+=1,e}readU16(){const e=this.view.getUint16(this.pos,!1);return this.pos+=2,e}readU24(){const e=this.view.getUint16(this.pos,!1),r=this.view.getUint8(this.pos+1);return this.pos+=3,e*256+r}readU32(){const e=this.view.getUint32(this.pos,!1);return this.pos+=4,e}readAscii(e){let r="";for(let n=0;n<e;n++)r+=String.fromCharCode(this.view.getUint8(this.pos+n));return this.pos+=e,r}readId3V2Frame(){if(this.header.majorVersion===2){const e=this.readAscii(3);if(e==="\0\0\0")return null;const r=this.readU24();return{id:e,size:r,flags:0}}else{const e=this.readAscii(4);if(e==="\0\0\0\0")return null;const r=this.readU32();let n=this.header.majorVersion===4?j5(r):r;const i=this.readU16(),a=this.pos,o=s=>{const l=this.pos+s;if(l>this.bytes.length)return!1;if(l<=this.bytes.length-this.frameHeaderSize()){this.pos+=s;const c=this.readAscii(4);if(c!=="\0\0\0\0"&&!/[0-9A-Z]{4}/.test(c))return!1}return!0};if(!o(n)){const s=this.header.majorVersion===4?r:j5(r);o(s)&&(n=s)}return this.pos=a,{id:e,size:n,flags:i}}}readId3V2TextEncoding(){const e=this.readU8();if(e>3)throw new Error(`Unsupported text encoding: ${e}`);return e}readId3V2Text(e,r){const n=this.pos,i=this.readBytes(r-this.pos);switch(e){case hp.ISO_8859_1:{let a="";for(let o=0;o<i.length;o++){const s=i[o];if(s===0){this.pos=n+o+1;break}a+=String.fromCharCode(s)}return a}case hp.UTF_16_WITH_BOM:if(i[0]===255&&i[1]===254){const a=new TextDecoder("utf-16le"),o=ep(i.findIndex((s,l)=>s===0&&i[l+1]===0&&l%2===0),i.length);return this.pos=n+Math.min(o+2,i.length),a.decode(i.subarray(2,o))}else if(i[0]===254&&i[1]===255){const a=new TextDecoder("utf-16be"),o=ep(i.findIndex((s,l)=>s===0&&i[l+1]===0&&l%2===0),i.length);return this.pos=n+Math.min(o+2,i.length),a.decode(i.subarray(2,o))}else{const a=ep(i.findIndex(o=>o===0),i.length);return this.pos=n+Math.min(a+1,i.length),Kl.decode(i.subarray(0,a))}case hp.UTF_16_BE_NO_BOM:{const a=new TextDecoder("utf-16be"),o=ep(i.findIndex((s,l)=>s===0&&i[l+1]===0&&l%2===0),i.length);return this.pos=n+Math.min(o+2,i.length),a.decode(i.subarray(0,o))}case hp.UTF_8:{const a=ep(i.findIndex(o=>o===0),i.length);return this.pos=n+Math.min(a+1,i.length),Kl.decode(i.subarray(0,a))}}}readId3V2EncodingAndText(e){if(this.pos>=e)return"";const r=this.readId3V2TextEncoding();return this.readId3V2Text(r,e)}}const z5=async(t,e,r)=>{let n=e;for(;r===null||n<r;){let i=t.requestSlice(n,L7);if(i instanceof Promise&&(i=await i),!i)break;const a=Dt(i),o=HD(a,t.fileSize!==null?t.fileSize-n:null);if(o.header)return{header:o.header,startPos:n};n+=o.bytesAdvanced}return null};class WD extends _d{constructor(e){super(e),this.metadataPromise=null,this.firstFrameHeader=null,this.loadedSamples=[],this.metadataTags=null,this.tracks=[],this.readingMutex=new Wm,this.lastSampleLoaded=!1,this.lastLoadedPos=0,this.nextTimestampInSamples=0,this.reader=e._reader}async readMetadata(){return this.metadataPromise??=(async()=>{for(;!this.firstFrameHeader&&!this.lastSampleLoaded;)await this.advanceReader();if(!this.firstFrameHeader)throw new Error("No valid MP3 frame found.");this.tracks=[new xc(this.input,new GD(this))]})()}async advanceReader(){if(this.lastLoadedPos===0)for(;;){let s=this.reader.requestSlice(this.lastLoadedPos,pm);if(s instanceof Promise&&(s=await s),!s){this.lastSampleLoaded=!0;return}const l=gm(s);if(!l)break;this.lastLoadedPos=s.filePos+l.size}const e=await z5(this.reader,this.lastLoadedPos,this.reader.fileSize);if(!e){this.lastSampleLoaded=!0;return}const r=e.header;this.lastLoadedPos=e.startPos+r.totalSize-1;const n=qD(r.mpegVersionId,r.channel);let i=this.reader.requestSlice(e.startPos+n,4);if(i instanceof Promise&&(i=await i),i){const s=Dt(i);if(s===jD||s===zD)return}this.firstFrameHeader||(this.firstFrameHeader=r),r.sampleRate!==this.firstFrameHeader.sampleRate&&console.warn(`MP3 changed sample rate mid-file: ${this.firstFrameHeader.sampleRate} Hz to ${r.sampleRate} Hz. Might be a bug, so please report this file.`);const a=r.audioSamplesInFrame/this.firstFrameHeader.sampleRate,o={timestamp:this.nextTimestampInSamples/this.firstFrameHeader.sampleRate,duration:a,dataStart:e.startPos,dataSize:r.totalSize};this.loadedSamples.push(o),this.nextTimestampInSamples+=r.audioSamplesInFrame}async getMimeType(){return"audio/mpeg"}async getTracks(){return await this.readMetadata(),this.tracks}async computeDuration(){await this.readMetadata();const e=this.tracks[0];return $e(e),e.computeDuration()}async getMetadataTags(){const e=await this.readingMutex.acquire();try{if(await this.readMetadata(),this.metadataTags)return this.metadataTags;this.metadataTags={};let r=0,n=!1;for(;;){let i=this.reader.requestSlice(r,pm);if(i instanceof Promise&&(i=await i),!i)break;const a=gm(i);if(!a)break;n=!0;let o=this.reader.requestSlice(i.filePos,a.size);if(o instanceof Promise&&(o=await o),!o)break;R7(o,a,this.metadataTags),r=i.filePos+a.size}if(!n&&this.reader.fileSize!==null&&this.reader.fileSize>=Fg){let i=this.reader.requestSlice(this.reader.fileSize-Fg,Fg);i instanceof Promise&&(i=await i),$e(i),Fo(i,3)==="TAG"&&VD(i,this.metadataTags)}return this.metadataTags}finally{e()}}}class GD{constructor(e){this.demuxer=e}getId(){return 1}async getFirstTimestamp(){return 0}getTimeResolution(){return $e(this.demuxer.firstFrameHeader),this.demuxer.firstFrameHeader.sampleRate/this.demuxer.firstFrameHeader.audioSamplesInFrame}async computeDuration(){const e=await this.getPacket(1/0,{metadataOnly:!0});return(e?.timestamp??0)+(e?.duration??0)}getName(){return null}getLanguageCode(){return ku}getCodec(){return"mp3"}getInternalCodecId(){return null}getNumberOfChannels(){return $e(this.demuxer.firstFrameHeader),this.demuxer.firstFrameHeader.channel===3?1:2}getSampleRate(){return $e(this.demuxer.firstFrameHeader),this.demuxer.firstFrameHeader.sampleRate}getDisposition(){return{...Sd}}async getDecoderConfig(){return $e(this.demuxer.firstFrameHeader),{codec:"mp3",numberOfChannels:this.demuxer.firstFrameHeader.channel===3?1:2,sampleRate:this.demuxer.firstFrameHeader.sampleRate}}async getPacketAtIndex(e,r){if(e===-1)return null;const n=this.demuxer.loadedSamples[e];if(!n)return null;let i;if(r.metadataOnly)i=Zl;else{let a=this.demuxer.reader.requestSlice(n.dataStart,n.dataSize);if(a instanceof Promise&&(a=await a),!a)return null;i=Nr(a,n.dataSize)}return new Bo(i,"key",n.timestamp,n.duration,e,n.dataSize)}getFirstPacket(e){return this.getPacketAtIndex(0,e)}async getNextPacket(e,r){const n=await this.demuxer.readingMutex.acquire();try{const i=Gm(this.demuxer.loadedSamples,e.timestamp,o=>o.timestamp);if(i===-1)throw new Error("Packet was not created from this track.");const a=i+1;for(;a>=this.demuxer.loadedSamples.length&&!this.demuxer.lastSampleLoaded;)await this.demuxer.advanceReader();return this.getPacketAtIndex(a,r)}finally{n()}}async getPacket(e,r){const n=await this.demuxer.readingMutex.acquire();try{for(;;){const i=oi(this.demuxer.loadedSamples,e,a=>a.timestamp);if(i===-1&&this.demuxer.loadedSamples.length>0)return null;if(this.demuxer.lastSampleLoaded)return this.getPacketAtIndex(i,r);if(i>=0&&i+1<this.demuxer.loadedSamples.length)return this.getPacketAtIndex(i,r);await this.demuxer.advanceReader()}}finally{n()}}getKeyPacket(e,r){return this.getPacket(e,r)}getNextKeyPacket(e,r){return this.getNextPacket(e,r)}}const M7=1399285583,XD=79764919,D7=new Uint32Array(256);for(let t=0;t<256;t++){let e=t<<24;for(let r=0;r<8;r++)e=e&2147483648?e<<1^XD:e<<1;D7[t]=e>>>0&4294967295}const YD=t=>{const e=Wa(t),r=e.getUint32(22,!0);e.setUint32(22,0,!0);let n=0;for(let i=0;i<t.length;i++){const a=t[i];n=(n<<8^D7[n>>>24^a])>>>0}return e.setUint32(22,r,!0),n},KD=(t,e,r)=>{let n=0,i=null;if(t.length>0)if(e.codec==="vorbis"){$e(e.vorbisInfo);const a=e.vorbisInfo.modeBlockflags.length,s=(1<<FM(a-1))-1<<1,l=(t[0]&s)>>1;if(l>=e.vorbisInfo.modeBlockflags.length)throw new Error("Invalid mode number.");let c=r;const f=e.vorbisInfo.modeBlockflags[l];if(i=e.vorbisInfo.blocksizes[f],f===1){const h=(s|1)+1,d=t[0]&h?1:0;c=e.vorbisInfo.blocksizes[d]}n=c!==null?c+i>>2:0}else e.codec==="opus"&&(n=oD(t).durationInSamples);return{durationInSamples:n,vorbisBlockSize:i}},ZD=t=>{let e="audio/ogg";if(t.codecStrings){const r=[...new Set(t.codecStrings)];e+=`; codecs="${r.join(", ")}"`}return e};const Yh=27,bp=282,QD=bp+65025,z0=t=>{const e=t.filePos;if(pp(t)!==M7)return null;t.skip(1);const n=dr(t),i=zF(t),a=pp(t),o=pp(t),s=pp(t),l=dr(t),c=new Uint8Array(l);for(let p=0;p<l;p++)c[p]=dr(t);const f=27+l,h=c.reduce((p,y)=>p+y,0),d=f+h;return{headerStartPos:e,totalSize:d,dataStartPos:e+f,dataSize:h,headerType:n,granulePosition:i,serialNumber:a,sequenceNumber:o,checksum:s,lacingValues:c}},JD=(t,e)=>{for(;t.filePos<e-3;){const r=pp(t),n=r&255,i=r>>>8&255,a=r>>>16&255,o=r>>>24&255,s=79;if(!(n!==s&&i!==s&&a!==s&&o!==s)){if(t.skip(-4),r===M7)return!0;t.skip(1)}}return!1};class eF extends _d{constructor(e){super(e),this.metadataPromise=null,this.bitstreams=[],this.tracks=[],this.metadataTags={},this.reader=e._reader}async readMetadata(){return this.metadataPromise??=(async()=>{let e=0;for(;;){let r=this.reader.requestSliceRange(e,Yh,bp);if(r instanceof Promise&&(r=await r),!r)break;const n=z0(r);if(!n||!!!(n.headerType&2))break;this.bitstreams.push({serialNumber:n.serialNumber,bosPage:n,description:null,numberOfChannels:-1,sampleRate:-1,codecInfo:{codec:null,vorbisInfo:null,opusInfo:null},lastMetadataPacket:null}),e=n.headerStartPos+n.totalSize}for(const r of this.bitstreams){const n=await this.readPacket(r.bosPage,0);n&&(n.data.byteLength>=7&&n.data[0]===1&&n.data[1]===118&&n.data[2]===111&&n.data[3]===114&&n.data[4]===98&&n.data[5]===105&&n.data[6]===115?await this.readVorbisMetadata(n,r):n.data.byteLength>=8&&n.data[0]===79&&n.data[1]===112&&n.data[2]===117&&n.data[3]===115&&n.data[4]===72&&n.data[5]===101&&n.data[6]===97&&n.data[7]===100&&await this.readOpusMetadata(n,r),r.codecInfo.codec!==null&&this.tracks.push(new xc(this.input,new tF(r,this))))}})()}async readVorbisMetadata(e,r){let n=await this.findNextPacketStart(e);if(!n)return;const i=await this.readPacket(n.startPage,n.startSegmentIndex);if(!i||(n=await this.findNextPacketStart(i),!n))return;const a=await this.readPacket(n.startPage,n.startSegmentIndex);if(!a||i.data[0]!==3||a.data[0]!==5)return;const o=[],s=h=>{for(;o.push(Math.min(255,h)),!(h<255);)h-=255};s(e.data.length),s(i.data.length);const l=new Uint8Array(1+o.length+e.data.length+i.data.length+a.data.length);l[0]=2,l.set(o,1),l.set(e.data,1+o.length),l.set(i.data,1+o.length+e.data.length),l.set(a.data,1+o.length+e.data.length+i.data.length),r.codecInfo.codec="vorbis",r.description=l,r.lastMetadataPacket=a;const c=Wa(e.data);r.numberOfChannels=c.getUint8(11),r.sampleRate=c.getUint32(12,!0);const f=c.getUint8(28);r.codecInfo.vorbisInfo={blocksizes:[1<<(f&15),1<<(f>>4)],modeBlockflags:sD(a.data).modeBlockflags},M5(i.data.subarray(7),this.metadataTags)}async readOpusMetadata(e,r){const n=await this.findNextPacketStart(e);if(!n)return;const i=await this.readPacket(n.startPage,n.startSegmentIndex);if(!i)return;r.codecInfo.codec="opus",r.description=e.data,r.lastMetadataPacket=i;const a=iD(e.data);r.numberOfChannels=a.outputChannelCount,r.sampleRate=Ym,r.codecInfo.opusInfo={preSkip:a.preSkip},M5(i.data.subarray(8),this.metadataTags)}async readPacket(e,r){$e(r<e.lacingValues.length);let n=0;for(let h=0;h<r;h++)n+=e.lacingValues[h];let i=e,a=n,o=r;const s=[];e:for(;;){let h=this.reader.requestSlice(i.dataStartPos,i.dataSize);h instanceof Promise&&(h=await h),$e(h);const d=Nr(h,i.dataSize);for(;;){if(o===i.lacingValues.length){s.push(d.subarray(n,a));break}const y=i.lacingValues[o];if(a+=y,y<255){s.push(d.subarray(n,a));break e}o++}let p=i.headerStartPos+i.totalSize;for(;;){let y=this.reader.requestSliceRange(p,Yh,bp);if(y instanceof Promise&&(y=await y),!y)return null;const w=z0(y);if(!w)return null;if(i=w,i.serialNumber===e.serialNumber)break;p=i.headerStartPos+i.totalSize}n=0,a=0,o=0}const l=s.reduce((h,d)=>h+d.length,0),c=new Uint8Array(l);let f=0;for(let h=0;h<s.length;h++){const d=s[h];c.set(d,f),f+=d.length}return{data:c,endPage:i,endSegmentIndex:o}}async findNextPacketStart(e){if(e.endSegmentIndex<e.endPage.lacingValues.length-1)return{startPage:e.endPage,startSegmentIndex:e.endSegmentIndex+1};if(!!(e.endPage.headerType&4))return null;let n=e.endPage.headerStartPos+e.endPage.totalSize;for(;;){let i=this.reader.requestSliceRange(n,Yh,bp);if(i instanceof Promise&&(i=await i),!i)return null;const a=z0(i);if(!a)return null;if(a.serialNumber===e.endPage.serialNumber)return{startPage:a,startSegmentIndex:0};n=a.headerStartPos+a.totalSize}}async getMimeType(){await this.readMetadata();const e=await Promise.all(this.tracks.map(r=>r.getCodecParameterString()));return ZD({codecStrings:e.filter(Boolean)})}async getTracks(){return await this.readMetadata(),this.tracks}async computeDuration(){const e=await this.getTracks(),r=await Promise.all(e.map(n=>n.computeDuration()));return Math.max(0,...r)}async getMetadataTags(){return await this.readMetadata(),this.metadataTags}}class tF{constructor(e,r){this.bitstream=e,this.demuxer=r,this.encodedPacketToMetadata=new WeakMap,this.sequentialScanCache=[],this.sequentialScanMutex=new Wm,this.internalSampleRate=e.codecInfo.codec==="opus"?Ym:e.sampleRate}getId(){return this.bitstream.serialNumber}getNumberOfChannels(){return this.bitstream.numberOfChannels}getSampleRate(){return this.bitstream.sampleRate}getTimeResolution(){return this.bitstream.sampleRate}getCodec(){return this.bitstream.codecInfo.codec}getInternalCodecId(){return null}async getDecoderConfig(){return $e(this.bitstream.codecInfo.codec),{codec:this.bitstream.codecInfo.codec,numberOfChannels:this.bitstream.numberOfChannels,sampleRate:this.bitstream.sampleRate,description:this.bitstream.description??void 0}}getName(){return null}getLanguageCode(){return ku}getDisposition(){return{...Sd}}async getFirstTimestamp(){return 0}async computeDuration(){const e=await this.getPacket(1/0,{metadataOnly:!0});return(e?.timestamp??0)+(e?.duration??0)}granulePositionToTimestampInSamples(e){return this.bitstream.codecInfo.codec==="opus"?($e(this.bitstream.codecInfo.opusInfo),e-this.bitstream.codecInfo.opusInfo.preSkip):e}createEncodedPacketFromOggPacket(e,r,n){if(!e)return null;const{durationInSamples:i,vorbisBlockSize:a}=KD(e.data,this.bitstream.codecInfo,r.vorbisLastBlocksize),o=new Bo(n.metadataOnly?Zl:e.data,"key",Math.max(0,r.timestampInSamples)/this.internalSampleRate,i/this.internalSampleRate,e.endPage.headerStartPos+e.endSegmentIndex,e.data.byteLength);return this.encodedPacketToMetadata.set(o,{packet:e,timestampInSamples:r.timestampInSamples,durationInSamples:i,vorbisLastBlockSize:r.vorbisLastBlocksize,vorbisBlockSize:a}),o}async getFirstPacket(e){$e(this.bitstream.lastMetadataPacket);const r=await this.demuxer.findNextPacketStart(this.bitstream.lastMetadataPacket);if(!r)return null;let n=0;this.bitstream.codecInfo.codec==="opus"&&($e(this.bitstream.codecInfo.opusInfo),n-=this.bitstream.codecInfo.opusInfo.preSkip);const i=await this.demuxer.readPacket(r.startPage,r.startSegmentIndex);return this.createEncodedPacketFromOggPacket(i,{timestampInSamples:n,vorbisLastBlocksize:null},e)}async getNextPacket(e,r){const n=this.encodedPacketToMetadata.get(e);if(!n)throw new Error("Packet was not created from this track.");const i=await this.demuxer.findNextPacketStart(n.packet);if(!i)return null;const a=n.timestampInSamples+n.durationInSamples,o=await this.demuxer.readPacket(i.startPage,i.startSegmentIndex);return this.createEncodedPacketFromOggPacket(o,{timestampInSamples:a,vorbisLastBlocksize:n.vorbisBlockSize},r)}async getPacket(e,r){if(this.demuxer.reader.fileSize===null)return this.getPacketSequential(e,r);const n=fm(e*this.internalSampleRate);if(n===0)return this.getFirstPacket(r);if(n<0)return null;$e(this.bitstream.lastMetadataPacket);const i=await this.demuxer.findNextPacketStart(this.bitstream.lastMetadataPacket);if(!i)return null;let a=i.startPage,o=this.demuxer.reader.fileSize;const s=[a];e:for(;a.headerStartPos+a.totalSize<o;){const S=a.headerStartPos,E=Math.floor((S+o)/2);let _=E;for(;;){const P=Math.min(_+QD,o-Yh);let O=this.demuxer.reader.requestSlice(_,P-_);if(O instanceof Promise&&(O=await O),$e(O),!JD(O,P)){o=E+Yh;continue e}let N=this.demuxer.reader.requestSliceRange(O.filePos,Yh,bp);N instanceof Promise&&(N=await N),$e(N);const D=z0(N);$e(D);let F=!1;if(D.serialNumber===this.bitstream.serialNumber)F=!0;else{let L=this.demuxer.reader.requestSlice(D.headerStartPos,D.totalSize);L instanceof Promise&&(L=await L),$e(L);const H=Nr(L,D.totalSize);F=YD(H)===D.checksum}if(!F){_=D.headerStartPos+4;continue}if(F&&D.serialNumber!==this.bitstream.serialNumber){_=D.headerStartPos+D.totalSize;continue}if(D.granulePosition===-1){_=D.headerStartPos+D.totalSize;continue}this.granulePositionToTimestampInSamples(D.granulePosition)>n?o=D.headerStartPos:(a=D,s.push(D));continue e}}let l=i.startPage;for(const S of s){if(S.granulePosition===a.granulePosition)break;(!l||S.headerStartPos>l.headerStartPos)&&(l=S)}let c=l;const f=[c];for(;!(c.serialNumber===this.bitstream.serialNumber&&c.granulePosition===a.granulePosition);){const S=c.headerStartPos+c.totalSize;let E=this.demuxer.reader.requestSliceRange(S,Yh,bp);E instanceof Promise&&(E=await E),$e(E);const _=z0(E);$e(_),c=_,c.serialNumber===this.bitstream.serialNumber&&f.push(c)}$e(c.granulePosition!==-1);let h=null,d,p,y=c,w=0;if(c.headerStartPos===i.startPage.headerStartPos)d=this.granulePositionToTimestampInSamples(0),p=!0,h=0;else{d=0,p=!1;for(let _=c.lacingValues.length-1;_>=0;_--)if(c.lacingValues[_]<255){h=_+1;break}if(h===null)throw new Error("Invalid page with granule position: no packets end on this page.");w=h-1;const S={data:Zl,endPage:y,endSegmentIndex:w};if(await this.demuxer.findNextPacketStart(S)){const _=lx(f,c,h);$e(_);const P=sx(f,_.page,_.segmentIndex);P&&(c=P.page,h=P.segmentIndex)}else for(;;){const _=lx(f,c,h);if(!_)break;const P=sx(f,_.page,_.segmentIndex);if(!P)break;if(c=P.page,h=P.segmentIndex,_.page.headerStartPos!==y.headerStartPos){y=_.page,w=_.segmentIndex;break}}}let x=null,b=null;for(;c!==null;){$e(h!==null);const S=await this.demuxer.readPacket(c,h);if(!S)break;if(!(c.headerStartPos===i.startPage.headerStartPos&&h<i.startSegmentIndex)){let P=this.createEncodedPacketFromOggPacket(S,{timestampInSamples:d,vorbisLastBlocksize:b?.vorbisBlockSize??null},r);$e(P);let O=this.encodedPacketToMetadata.get(P);if($e(O),!p&&S.endPage.headerStartPos===y.headerStartPos&&S.endSegmentIndex===w?(d=this.granulePositionToTimestampInSamples(c.granulePosition),p=!0,P=this.createEncodedPacketFromOggPacket(S,{timestampInSamples:d-O.durationInSamples,vorbisLastBlocksize:b?.vorbisBlockSize??null},r),$e(P),O=this.encodedPacketToMetadata.get(P),$e(O)):d+=O.durationInSamples,x=P,b=O,p&&(Math.max(d,0)>n||Math.max(O.timestampInSamples,0)===n))break}const _=await this.demuxer.findNextPacketStart(S);if(!_)break;c=_.startPage,h=_.startSegmentIndex}return x}async getPacketSequential(e,r){const n=await this.sequentialScanMutex.acquire();try{const i=fm(e*this.internalSampleRate);e=i/this.internalSampleRate;const a=oi(this.sequentialScanCache,i,l=>l.timestampInSamples);let o;if(a!==-1){const l=this.sequentialScanCache[a];o=this.createEncodedPacketFromOggPacket(l.packet,{timestampInSamples:l.timestampInSamples,vorbisLastBlocksize:l.vorbisLastBlockSize},r)}else o=await this.getFirstPacket(r);let s=0;for(;o&&o.timestamp<e;){const l=await this.getNextPacket(o,r);if(!l||l.timestamp>e)break;if(o=l,s++,s===100){s=0;const c=this.encodedPacketToMetadata.get(o);$e(c),this.sequentialScanCache.length>0&&$e(El(this.sequentialScanCache).timestampInSamples<=c.timestampInSamples),this.sequentialScanCache.push(c)}}return o}finally{n()}}getKeyPacket(e,r){return this.getPacket(e,r)}getNextKeyPacket(e,r){return this.getNextPacket(e,r)}}const sx=(t,e,r)=>{let n=e,i=r;e:for(;;){for(i--,i;i>=0;i--)if(n.lacingValues[i]<255){i++;break e}if($e(i===-1),!(n.headerType&1)){i=0;break}const o=t7(t,s=>s.headerStartPos<n.headerStartPos);if(!o)return null;n=o,i=n.lacingValues.length}if($e(i!==-1),i===n.lacingValues.length){const a=t[t.indexOf(n)+1];$e(a),n=a,i=0}return{page:n,segmentIndex:i}},lx=(t,e,r)=>{if(r>0)return{page:e,segmentIndex:r-1};const n=t7(t,i=>i.headerStartPos<e.headerStartPos);return n?{page:n,segmentIndex:n.lacingValues.length-1}:null};var Uc;(function(t){t[t.PCM=1]="PCM",t[t.IEEE_FLOAT=3]="IEEE_FLOAT",t[t.ALAW=6]="ALAW",t[t.MULAW=7]="MULAW",t[t.EXTENSIBLE=65534]="EXTENSIBLE"})(Uc||(Uc={}));class rF extends _d{constructor(e){super(e),this.metadataPromise=null,this.dataStart=-1,this.dataSize=-1,this.audioInfo=null,this.tracks=[],this.lastKnownPacketIndex=0,this.metadataTags={},this.reader=e._reader}async readMetadata(){return this.metadataPromise??=(async()=>{let e=this.reader.requestSlice(0,12);e instanceof Promise&&(e=await e),$e(e);const r=Fo(e,4),n=r!=="RIFX",i=r==="RF64",a=ah(e,n);let o=i?this.reader.fileSize:Math.min(a+8,this.reader.fileSize??1/0);if(Fo(e,4)!=="WAVE")throw new Error("Invalid WAVE file - wrong format");let l=0,c=null,f=e.filePos;for(;o===null||f<o;){let d=this.reader.requestSlice(f,8);if(d instanceof Promise&&(d=await d),!d)break;const p=Fo(d,4),y=ah(d,n),w=d.filePos;if(i&&l===0&&p!=="ds64")throw new Error('Invalid RF64 file: First chunk must be "ds64".');if(p==="fmt ")await this.parseFmtChunk(w,y,n);else if(p==="data"){if(c??=y,this.dataStart=d.filePos,this.dataSize=Math.min(c,(o??1/0)-this.dataStart),this.reader.fileSize===null)break}else if(p==="ds64"){let x=this.reader.requestSlice(w,y);if(x instanceof Promise&&(x=await x),!x)break;const b=cx(x,n);c=cx(x,n),o=Math.min(b+8,this.reader.fileSize??1/0)}else p==="LIST"?await this.parseListChunk(w,y,n):(p==="ID3 "||p==="id3 ")&&await this.parseId3Chunk(w,y);f=w+y+(y&1),l++}if(!this.audioInfo)throw new Error('Invalid WAVE file - missing "fmt " chunk');if(this.dataStart===-1)throw new Error('Invalid WAVE file - missing "data" chunk');const h=this.audioInfo.blockSizeInBytes;this.dataSize=Math.floor(this.dataSize/h)*h,this.tracks.push(new xc(this.input,new nF(this)))})()}async parseFmtChunk(e,r,n){let i=this.reader.requestSlice(e,r);if(i instanceof Promise&&(i=await i),!i)return;let a=f0(i,n);const o=f0(i,n),s=ah(i,n);i.skip(4);const l=f0(i,n);let c;if(r===14?c=8:c=f0(i,n),r>=18&&a!==357){const f=f0(i,n),h=r-18;if(Math.min(h,f)>=22&&a===Uc.EXTENSIBLE){i.skip(6);const p=Nr(i,16);a=p[0]|p[1]<<8}}(a===Uc.MULAW||a===Uc.ALAW)&&(c=8),this.audioInfo={format:a,numberOfChannels:o,sampleRate:s,sampleSizeInBytes:Math.ceil(c/8),blockSizeInBytes:l}}async parseListChunk(e,r,n){let i=this.reader.requestSlice(e,r);if(i instanceof Promise&&(i=await i),!i)return;const a=Fo(i,4);if(a!=="INFO"&&a!=="INF0")return;let o=i.filePos;for(;o<=e+r-8;){i.filePos=o;const s=Fo(i,4),l=ah(i,n),c=Nr(i,l);let f=0;for(let d=0;d<c.length&&c[d]!==0;d++)f++;const h=String.fromCharCode(...c.subarray(0,f));switch(this.metadataTags.raw??={},this.metadataTags.raw[s]=h,s){case"INAM":case"TITL":this.metadataTags.title??=h;break;case"TIT3":this.metadataTags.description??=h;break;case"IART":this.metadataTags.artist??=h;break;case"IPRD":this.metadataTags.album??=h;break;case"IPRT":case"ITRK":case"TRCK":{const d=h.split("/"),p=Number.parseInt(d[0],10),y=d[1]&&Number.parseInt(d[1],10);Number.isInteger(p)&&p>0&&(this.metadataTags.trackNumber??=p),y&&Number.isInteger(y)&&y>0&&(this.metadataTags.tracksTotal??=y)}break;case"ICRD":case"IDIT":{const d=new Date(h);Number.isNaN(d.getTime())||(this.metadataTags.date??=d)}break;case"YEAR":{const d=Number.parseInt(h,10);Number.isInteger(d)&&d>0&&(this.metadataTags.date??=new Date(d,0,1))}break;case"IGNR":case"GENR":this.metadataTags.genre??=h;break;case"ICMT":case"CMNT":case"COMM":this.metadataTags.comment??=h;break}o+=8+l+(l&1)}}async parseId3Chunk(e,r){let n=this.reader.requestSlice(e,r);if(n instanceof Promise&&(n=await n),!n)return;const i=gm(n);if(i){const a=n.slice(e+10,i.size);R7(a,i,this.metadataTags)}}getCodec(){if($e(this.audioInfo),this.audioInfo.format===Uc.MULAW)return"ulaw";if(this.audioInfo.format===Uc.ALAW)return"alaw";if(this.audioInfo.format===Uc.PCM){if(this.audioInfo.sampleSizeInBytes===1)return"pcm-u8";if(this.audioInfo.sampleSizeInBytes===2)return"pcm-s16";if(this.audioInfo.sampleSizeInBytes===3)return"pcm-s24";if(this.audioInfo.sampleSizeInBytes===4)return"pcm-s32"}return this.audioInfo.format===Uc.IEEE_FLOAT&&this.audioInfo.sampleSizeInBytes===4?"pcm-f32":null}async getMimeType(){return"audio/wav"}async computeDuration(){await this.readMetadata();const e=this.tracks[0];return $e(e),e.computeDuration()}async getTracks(){return await this.readMetadata(),this.tracks}async getMetadataTags(){return await this.readMetadata(),this.metadataTags}}const Xd=2048;class nF{constructor(e){this.demuxer=e}getId(){return 1}getCodec(){return this.demuxer.getCodec()}getInternalCodecId(){return $e(this.demuxer.audioInfo),this.demuxer.audioInfo.format}async getDecoderConfig(){const e=this.demuxer.getCodec();return e?($e(this.demuxer.audioInfo),{codec:e,numberOfChannels:this.demuxer.audioInfo.numberOfChannels,sampleRate:this.demuxer.audioInfo.sampleRate}):null}async computeDuration(){const e=await this.getPacket(1/0,{metadataOnly:!0});return(e?.timestamp??0)+(e?.duration??0)}getNumberOfChannels(){return $e(this.demuxer.audioInfo),this.demuxer.audioInfo.numberOfChannels}getSampleRate(){return $e(this.demuxer.audioInfo),this.demuxer.audioInfo.sampleRate}getTimeResolution(){return $e(this.demuxer.audioInfo),this.demuxer.audioInfo.sampleRate}getName(){return null}getLanguageCode(){return ku}getDisposition(){return{...Sd}}async getFirstTimestamp(){return 0}async getPacketAtIndex(e,r){$e(this.demuxer.audioInfo);const n=e*Xd*this.demuxer.audioInfo.blockSizeInBytes;if(n>=this.demuxer.dataSize)return null;const i=Math.min(Xd*this.demuxer.audioInfo.blockSizeInBytes,this.demuxer.dataSize-n);if(this.demuxer.reader.fileSize===null){let l=this.demuxer.reader.requestSlice(this.demuxer.dataStart+n,i);if(l instanceof Promise&&(l=await l),!l)return null}let a;if(r.metadataOnly)a=Zl;else{let l=this.demuxer.reader.requestSlice(this.demuxer.dataStart+n,i);l instanceof Promise&&(l=await l),$e(l),a=Nr(l,i)}const o=e*Xd/this.demuxer.audioInfo.sampleRate,s=i/this.demuxer.audioInfo.blockSizeInBytes/this.demuxer.audioInfo.sampleRate;return this.demuxer.lastKnownPacketIndex=Math.max(e,o),new Bo(a,"key",o,s,e,i)}getFirstPacket(e){return this.getPacketAtIndex(0,e)}async getPacket(e,r){$e(this.demuxer.audioInfo);const n=Math.floor(Math.min(e*this.demuxer.audioInfo.sampleRate/Xd,(this.demuxer.dataSize-1)/(Xd*this.demuxer.audioInfo.blockSizeInBytes))),i=await this.getPacketAtIndex(n,r);if(i)return i;if(n===0)return null;$e(this.demuxer.reader.fileSize===null);let a=await this.getPacketAtIndex(this.demuxer.lastKnownPacketIndex,r);for(;a;){const o=await this.getNextPacket(a,r);if(!o)break;a=o}return a}getNextPacket(e,r){$e(this.demuxer.audioInfo);const n=Math.round(e.timestamp*this.demuxer.audioInfo.sampleRate/Xd);return this.getPacketAtIndex(n+1,r)}getKeyPacket(e,r){return this.getPacket(e,r)}getNextKeyPacket(e,r){return this.getNextPacket(e,r)}}const mm=7,vm=9,U5=t=>{const e=t.filePos,r=Nr(t,9),n=new aa(r);if(n.readBits(12)!==4095||(n.skipBits(1),n.readBits(2)!==0))return null;const o=n.readBits(1),s=n.readBits(2)+1,l=n.readBits(4);if(l===15)return null;n.skipBits(1);const c=n.readBits(3);if(c===0)throw new Error("ADTS frames with channel configuration 0 are not supported.");n.skipBits(1),n.skipBits(1),n.skipBits(1),n.skipBits(1);const f=n.readBits(13);n.skipBits(11);const h=n.readBits(2)+1;if(h!==1)throw new Error("ADTS frames with more than one AAC frame are not supported.");let d=null;return o===1?t.filePos-=2:d=n.readBits(16),{objectType:s,samplingFrequencyIndex:l,channelConfiguration:c,frameLength:f,numberOfAacFrames:h,crcCheck:d,startPos:e}};const q5=1024;class iF extends _d{constructor(e){super(e),this.metadataPromise=null,this.firstFrameHeader=null,this.loadedSamples=[],this.tracks=[],this.readingMutex=new Wm,this.lastSampleLoaded=!1,this.lastLoadedPos=0,this.nextTimestampInSamples=0,this.reader=e._reader}async readMetadata(){return this.metadataPromise??=(async()=>{for(;!this.firstFrameHeader&&!this.lastSampleLoaded;)await this.advanceReader();$e(this.firstFrameHeader),this.tracks=[new xc(this.input,new aF(this))]})()}async advanceReader(){let e=this.reader.requestSliceRange(this.lastLoadedPos,mm,vm);if(e instanceof Promise&&(e=await e),!e){this.lastSampleLoaded=!0;return}const r=U5(e);if(!r){this.lastSampleLoaded=!0;return}if(this.reader.fileSize!==null&&r.startPos+r.frameLength>this.reader.fileSize){this.lastSampleLoaded=!0;return}this.firstFrameHeader||(this.firstFrameHeader=r);const n=r1[r.samplingFrequencyIndex];$e(n!==void 0);const i=q5/n,a=r.crcCheck?vm:mm,o={timestamp:this.nextTimestampInSamples/n,duration:i,dataStart:r.startPos+a,dataSize:r.frameLength-a};this.loadedSamples.push(o),this.nextTimestampInSamples+=q5,this.lastLoadedPos=r.startPos+r.frameLength}async getMimeType(){return"audio/aac"}async getTracks(){return await this.readMetadata(),this.tracks}async computeDuration(){await this.readMetadata();const e=this.tracks[0];return $e(e),e.computeDuration()}async getMetadataTags(){return{}}}class aF{constructor(e){this.demuxer=e}getId(){return 1}async getFirstTimestamp(){return 0}getTimeResolution(){return this.getSampleRate()/q5}async computeDuration(){const e=await this.getPacket(1/0,{metadataOnly:!0});return(e?.timestamp??0)+(e?.duration??0)}getName(){return null}getLanguageCode(){return ku}getCodec(){return"aac"}getInternalCodecId(){return $e(this.demuxer.firstFrameHeader),this.demuxer.firstFrameHeader.objectType}getNumberOfChannels(){$e(this.demuxer.firstFrameHeader);const e=Hb[this.demuxer.firstFrameHeader.channelConfiguration];return $e(e!==void 0),e}getSampleRate(){$e(this.demuxer.firstFrameHeader);const e=r1[this.demuxer.firstFrameHeader.samplingFrequencyIndex];return $e(e!==void 0),e}getDisposition(){return{...Sd}}async getDecoderConfig(){$e(this.demuxer.firstFrameHeader);const e=new Uint8Array(3),r=new aa(e),{objectType:n,samplingFrequencyIndex:i,channelConfiguration:a}=this.demuxer.firstFrameHeader;return n>31?(r.writeBits(5,31),r.writeBits(6,n-32)):r.writeBits(5,n),r.writeBits(4,i),r.writeBits(4,a),{codec:`mp4a.40.${this.demuxer.firstFrameHeader.objectType}`,numberOfChannels:this.getNumberOfChannels(),sampleRate:this.getSampleRate(),description:e.subarray(0,Math.ceil((r.pos-1)/8))}}async getPacketAtIndex(e,r){if(e===-1)return null;const n=this.demuxer.loadedSamples[e];if(!n)return null;let i;if(r.metadataOnly)i=Zl;else{let a=this.demuxer.reader.requestSlice(n.dataStart,n.dataSize);if(a instanceof Promise&&(a=await a),!a)return null;i=Nr(a,n.dataSize)}return new Bo(i,"key",n.timestamp,n.duration,e,n.dataSize)}getFirstPacket(e){return this.getPacketAtIndex(0,e)}async getNextPacket(e,r){const n=await this.demuxer.readingMutex.acquire();try{const i=Gm(this.demuxer.loadedSamples,e.timestamp,o=>o.timestamp);if(i===-1)throw new Error("Packet was not created from this track.");const a=i+1;for(;a>=this.demuxer.loadedSamples.length&&!this.demuxer.lastSampleLoaded;)await this.demuxer.advanceReader();return this.getPacketAtIndex(a,r)}finally{n()}}async getPacket(e,r){const n=await this.demuxer.readingMutex.acquire();try{for(;;){const i=oi(this.demuxer.loadedSamples,e,a=>a.timestamp);if(i===-1&&this.demuxer.loadedSamples.length>0)return null;if(this.demuxer.lastSampleLoaded)return this.getPacketAtIndex(i,r);if(i>=0&&i+1<this.demuxer.loadedSamples.length)return this.getPacketAtIndex(i,r);await this.demuxer.advanceReader()}}finally{n()}}getKeyPacket(e,r){return this.getPacket(e,r)}getNextKeyPacket(e,r){return this.getNextPacket(e,r)}}const oF=t=>t===0?null:t===1?192:t>=2&&t<=5?144*2**t:t===6?"uncommon-u8":t===7?"uncommon-u16":t>=8&&t<=15?2**t:null,sF=(t,e)=>{switch(t){case 0:return e;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}},lF=t=>{let e=0;const r=new aa(Nr(t,1));for(;r.readBits(1)===1;)e++;if(e===0)return r.readBits(7);const n=[],i=e-1,a=new aa(Nr(t,i)),o=8-e-1;for(let l=0;l<o;l++)n.unshift(r.readBits(1));for(let l=0;l<i;l++)for(let c=0;c<8;c++){const f=a.readBits(1);c<2||n.unshift(f)}return n.reduce((l,c,f)=>l|c<<f,0)},uF=(t,e)=>{if(e==="uncommon-u16")return ts(t)+1;if(e==="uncommon-u8")return dr(t)+1;if(typeof e=="number")return e;Lp(e),$e(!1)},cF=(t,e)=>e==="uncommon-u16"?ts(t):e==="uncommon-u16-10"?ts(t)*10:e==="uncommon-u8"?dr(t):typeof e=="number"?e:null,fF=t=>{let r=0;for(const n of t){r^=n;for(let i=0;i<8;i++)(r&128)!==0?r=r<<1^7:r<<=1,r&=255}return r};class hF extends _d{constructor(e){super(e),this.loadedSamples=[],this.metadataPromise=null,this.track=null,this.metadataTags={},this.audioInfo=null,this.lastLoadedPos=null,this.blockingBit=null,this.readingMutex=new Wm,this.lastSampleLoaded=!1,this.reader=e._reader}async computeDuration(){return await this.readMetadata(),$e(this.track),this.track.computeDuration()}async getMetadataTags(){return await this.readMetadata(),this.metadataTags}async getTracks(){return await this.readMetadata(),$e(this.track),[this.track]}async getMimeType(){return"audio/flac"}async readMetadata(){let e=4;return this.metadataPromise??=(async()=>{for(;this.reader.fileSize===null||e<this.reader.fileSize;){let r=this.reader.requestSlice(e,4);if(r instanceof Promise&&(r=await r),e+=4,r===null)throw new Error(`Metadata block at position ${e} is too small! Corrupted file.`);$e(r);const n=dr(r),i=np(r),a=(n&128)!==0;switch(n&127){case yp.STREAMINFO:{let s=this.reader.requestSlice(e,i);if(s instanceof Promise&&(s=await s),$e(s),s===null)throw new Error(`StreamInfo block at position ${e} is too small! Corrupted file.`);const l=Nr(s,34),c=new aa(l),f=c.readBits(16),h=c.readBits(16),d=c.readBits(24),p=c.readBits(24),y=c.readBits(20),w=c.readBits(3)+1;c.readBits(5);const x=c.readBits(36);c.skipBits(128);const b=new Uint8Array(42);b.set(new Uint8Array([102,76,97,67]),0),b.set(new Uint8Array([128,0,0,34]),4),b.set(l,8),this.audioInfo={numberOfChannels:w,sampleRate:y,totalSamples:x,minimumBlockSize:f,maximumBlockSize:h,minimumFrameSize:d,maximumFrameSize:p,description:b},this.track=new xc(this.input,new dF(this));break}case yp.VORBIS_COMMENT:{let s=this.reader.requestSlice(e,i);s instanceof Promise&&(s=await s),$e(s),M5(Nr(s,i),this.metadataTags);break}case yp.PICTURE:{let s=this.reader.requestSlice(e,i);s instanceof Promise&&(s=await s),$e(s);const l=Dt(s),c=Dt(s),f=Kl.decode(Nr(s,c)),h=Dt(s),d=Kl.decode(Nr(s,h));s.skip(16);const p=Dt(s),y=Nr(s,p);this.metadataTags.images??=[],this.metadataTags.images.push({data:y,mimeType:f,kind:l===3?"coverFront":l===4?"coverBack":"unknown",description:d});break}}if(e+=i,a){this.lastLoadedPos=e;break}}})()}async readNextFlacFrame({startPos:e,isFirstPacket:r}){$e(this.audioInfo);const n=6,a=this.audioInfo.maximumFrameSize+16,o=await this.reader.requestSliceRange(e,this.audioInfo.minimumFrameSize,a);if(!o)return null;const s=this.readFlacFrameHeader({slice:o,isFirstPacket:r});if(!s)return null;for(o.filePos=e+this.audioInfo.minimumFrameSize;;){if(o.filePos>o.end-n)return{num:s.num,blockSize:s.blockSize,sampleRate:s.sampleRate,size:o.end-e,isLastFrame:!0};if(dr(o)===255){const c=o.filePos,f=dr(o),h=this.blockingBit===1?249:248;if(f!==h){o.filePos=c;continue}o.skip(-2);const d=o.filePos-e,p=this.readFlacFrameHeader({slice:o,isFirstPacket:!1});if(!p){o.filePos=c;continue}if(this.blockingBit===0){if(p.num-s.num!==1){o.filePos=c;continue}}else if(p.num-s.num!==s.blockSize){o.filePos=c;continue}return{num:s.num,blockSize:s.blockSize,sampleRate:s.sampleRate,size:d,isLastFrame:!1}}}}readFlacFrameHeader({slice:e,isFirstPacket:r}){const n=e.filePos,i=Nr(e,4),a=new aa(i);if(a.readBits(15)!==32764)return null;if(this.blockingBit===null){$e(r);const x=a.readBits(1);this.blockingBit=x}else if(this.blockingBit===1){if($e(!r),a.readBits(1)!==1)return null}else if(this.blockingBit===0){if($e(!r),a.readBits(1)!==0)return null}else throw new Error("Invalid blocking bit");const s=oF(a.readBits(4));if(!s)return null;$e(this.audioInfo);const l=sF(a.readBits(4),this.audioInfo.sampleRate);if(!l||(a.readBits(4),a.readBits(3),a.readBits(1)!==0))return null;const f=lF(e),h=uF(e,s),d=cF(e,l);if(d===null||d!==this.audioInfo.sampleRate)return null;const p=e.filePos-n,y=dr(e);e.skip(-p),e.skip(-1);const w=fF(Nr(e,p));return y!==w?null:{num:f,blockSize:h,sampleRate:d}}async advanceReader(){await this.readMetadata(),$e(this.lastLoadedPos!==null),$e(this.audioInfo);const e=this.lastLoadedPos,r=await this.readNextFlacFrame({startPos:e,isFirstPacket:this.loadedSamples.length===0});if(!r){this.lastSampleLoaded=!0;return}const n=this.loadedSamples[this.loadedSamples.length-1],a={blockOffset:n?n.blockOffset+n.blockSize:0,blockSize:r.blockSize,byteOffset:e,byteSize:r.size};if(this.lastLoadedPos=this.lastLoadedPos+r.size,this.loadedSamples.push(a),r.isLastFrame){this.lastSampleLoaded=!0;return}}}class dF{constructor(e){this.demuxer=e}getId(){return 1}getCodec(){return"flac"}getInternalCodecId(){return null}getNumberOfChannels(){return $e(this.demuxer.audioInfo),this.demuxer.audioInfo.numberOfChannels}async computeDuration(){const e=await this.getPacket(1/0,{metadataOnly:!0});return(e?.timestamp??0)+(e?.duration??0)}getSampleRate(){return $e(this.demuxer.audioInfo),this.demuxer.audioInfo.sampleRate}getName(){return null}getLanguageCode(){return ku}getTimeResolution(){return $e(this.demuxer.audioInfo),this.demuxer.audioInfo.sampleRate}getDisposition(){return{...Sd}}async getFirstTimestamp(){return 0}async getDecoderConfig(){return $e(this.demuxer.audioInfo),{codec:"flac",numberOfChannels:this.demuxer.audioInfo.numberOfChannels,sampleRate:this.demuxer.audioInfo.sampleRate,description:this.demuxer.audioInfo.description}}async getPacket(e,r){if($e(this.demuxer.audioInfo),e<0)throw new Error("Timestamp cannot be negative");const n=await this.demuxer.readingMutex.acquire();try{for(;;){const i=oi(this.demuxer.loadedSamples,e,l=>l.blockOffset/this.demuxer.audioInfo.sampleRate);if(i===-1){await this.demuxer.advanceReader();continue}const a=this.demuxer.loadedSamples[i],o=a.blockOffset/this.demuxer.audioInfo.sampleRate,s=a.blockSize/this.demuxer.audioInfo.sampleRate;if(o+s<=e){if(this.demuxer.lastSampleLoaded)return this.getPacketAtIndex(this.demuxer.loadedSamples.length-1,r);await this.demuxer.advanceReader();continue}return this.getPacketAtIndex(i,r)}}finally{n()}}async getNextPacket(e,r){const n=await this.demuxer.readingMutex.acquire();try{const i=e.sequenceNumber+1;if(this.demuxer.lastSampleLoaded&&i>=this.demuxer.loadedSamples.length)return null;for(;i>=this.demuxer.loadedSamples.length&&!this.demuxer.lastSampleLoaded;)await this.demuxer.advanceReader();return this.getPacketAtIndex(i,r)}finally{n()}}getKeyPacket(e,r){return this.getPacket(e,r)}getNextKeyPacket(e,r){return this.getNextPacket(e,r)}async getPacketAtIndex(e,r){const n=this.demuxer.loadedSamples[e];if(!n)return null;let i;if(r.metadataOnly)i=Zl;else{let s=this.demuxer.reader.requestSlice(n.byteOffset,n.byteSize);if(s instanceof Promise&&(s=await s),!s)return null;i=Nr(s,n.byteSize)}$e(this.demuxer.audioInfo);const a=n.blockOffset/this.demuxer.audioInfo.sampleRate,o=n.blockSize/this.demuxer.audioInfo.sampleRate;return new Bo(i,"key",a,o,e,n.byteSize)}async getFirstPacket(e){for(;this.demuxer.loadedSamples.length===0&&!this.demuxer.lastSampleLoaded;)await this.demuxer.advanceReader();return this.getPacketAtIndex(0,e)}}class _h{}class F7 extends _h{async _getMajorBrand(e){let r=e._reader.requestSlice(0,12);return r instanceof Promise&&(r=await r),!r||(r.skip(4),Fo(r,4)!=="ftyp")?null:Fo(r,4)}_createDemuxer(e){return new kD(e)}}class pF extends F7{async _canReadInput(e){const r=await this._getMajorBrand(e);return!!r&&r!=="qt "}get name(){return"MP4"}get mimeType(){return"video/mp4"}}class gF extends F7{async _canReadInput(e){return await this._getMajorBrand(e)==="qt "}get name(){return"QuickTime File Format"}get mimeType(){return"video/quicktime"}}class B7 extends _h{async isSupportedEBMLOfDocType(e,r){let n=e._reader.requestSlice(0,Xc);if(n instanceof Promise&&(n=await n),!n)return!1;const i=T7(n);if(i===null||i<1||i>8||Jr(n,i)!==bt.EBML)return!1;const o=A7(n);if(o===null)return!1;let s=e._reader.requestSlice(n.filePos,o);if(s instanceof Promise&&(s=await s),!s)return!1;const l=n.filePos;for(;s.filePos<=l+o-_u;){const c=Hc(s);if(!c)break;const{id:f,size:h}=c,d=s.filePos;if(h===null)return!1;switch(f){case bt.EBMLVersion:if(Jr(s,h)!==1)return!1;break;case bt.EBMLReadVersion:if(Jr(s,h)!==1)return!1;break;case bt.DocType:if(rp(s,h)!==r)return!1;break;case bt.DocTypeVersion:if(Jr(s,h)>4)return!1;break}s.filePos=d+h}return!0}_canReadInput(e){return this.isSupportedEBMLOfDocType(e,"matroska")}_createDemuxer(e){return new RD(e)}get name(){return"Matroska"}get mimeType(){return"video/x-matroska"}}class mF extends B7{_canReadInput(e){return this.isSupportedEBMLOfDocType(e,"webm")}get name(){return"WebM"}get mimeType(){return"video/webm"}}class vF extends _h{async _canReadInput(e){let r=e._reader.requestSlice(0,10);if(r instanceof Promise&&(r=await r),!r)return!1;let n=0,i=!1;for(;;){let c=e._reader.requestSlice(n,pm);if(c instanceof Promise&&(c=await c),!c)break;const f=gm(c);if(!f)break;i=!0,n=c.filePos+f.size}const a=await z5(e._reader,n,n+4096);if(!a)return!1;if(i)return!0;n=a.startPos+a.header.totalSize;const o=await z5(e._reader,n,n+L7);if(!o)return!1;const s=a.header,l=o.header;return!(s.channel!==l.channel||s.sampleRate!==l.sampleRate)}_createDemuxer(e){return new WD(e)}get name(){return"MP3"}get mimeType(){return"audio/mpeg"}}class yF extends _h{async _canReadInput(e){let r=e._reader.requestSlice(0,12);if(r instanceof Promise&&(r=await r),!r)return!1;const n=Fo(r,4);return n!=="RIFF"&&n!=="RIFX"&&n!=="RF64"?!1:(r.skip(4),Fo(r,4)==="WAVE")}_createDemuxer(e){return new rF(e)}get name(){return"WAVE"}get mimeType(){return"audio/wav"}}class bF extends _h{async _canReadInput(e){let r=e._reader.requestSlice(0,4);return r instanceof Promise&&(r=await r),r?Fo(r,4)==="OggS":!1}_createDemuxer(e){return new eF(e)}get name(){return"Ogg"}get mimeType(){return"application/ogg"}}class wF extends _h{async _canReadInput(e){let r=e._reader.requestSlice(0,4);return r instanceof Promise&&(r=await r),r?Fo(r,4)==="fLaC":!1}get name(){return"FLAC"}get mimeType(){return"audio/flac"}_createDemuxer(e){return new hF(e)}}class xF extends _h{async _canReadInput(e){let r=e._reader.requestSliceRange(0,mm,vm);if(r instanceof Promise&&(r=await r),!r)return!1;const n=U5(r);if(!n||(r=e._reader.requestSliceRange(n.frameLength,mm,vm),r instanceof Promise&&(r=await r),!r))return!1;const i=U5(r);return i?n.objectType===i.objectType&&n.samplingFrequencyIndex===i.samplingFrequencyIndex&&n.channelConfiguration===i.channelConfiguration:!1}_createDemuxer(e){return new iF(e)}get name(){return"ADTS"}get mimeType(){return"audio/aac"}}const SF=new pF,_F=new gF,kF=new B7,EF=new mF,PF=new vF,CF=new yF,TF=new bF,AF=new xF,OF=new wF,NF=[SF,_F,kF,EF,CF,TF,OF,PF,AF];class Xb{constructor(){this._disposed=!1,this._sizePromise=null,this.onread=null}async getSizeOrNull(){if(this._disposed)throw new xl;return this._sizePromise??=Promise.resolve(this._retrieveSize())}async getSize(){if(this._disposed)throw new xl;const e=await this.getSizeOrNull();if(e===null)throw new Error("Cannot determine the size of an unsized source.");return e}}class ux extends Xb{constructor(e){if(!(e instanceof ArrayBuffer)&&!(typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer)&&!ArrayBuffer.isView(e))throw new TypeError("buffer must be an ArrayBuffer, SharedArrayBuffer, or ArrayBufferView.");super(),this._onreadCalled=!1,this._bytes=td(e),this._view=Wa(e)}_retrieveSize(){return this._bytes.byteLength}_read(){return this._onreadCalled||(this.onread?.(0,this._bytes.byteLength),this._onreadCalled=!0),{bytes:this._bytes,view:this._view,offset:0}}_dispose(){}}const j7=.5*2**20,IF=((t,e,r)=>{if(e instanceof Error&&(e.message.includes("Failed to fetch")||e.message.includes("Load failed")||e.message.includes("NetworkError when attempting to fetch resource"))){let i=null;try{typeof window<"u"&&typeof window.location<"u"&&(i=new URL(r instanceof Request?r.url:r,window.location.href).origin)}catch{}if((typeof navigator<"u"&&typeof navigator.onLine=="boolean"?navigator.onLine:!0)&&i!==null&&i!==window.location.origin)return console.warn("Request will not be retried because a CORS error was suspected due to different origins. You can modify this behavior by providing your own function for the 'getRetryDelay' option."),null}return Math.min(2**(t-2),16)});class LF extends Xb{constructor(e,r={}){if(typeof e!="string"&&!(e instanceof URL)&&!(typeof Request<"u"&&e instanceof Request))throw new TypeError("url must be a string, URL or Request.");if(!r||typeof r!="object")throw new TypeError("options must be an object.");if(r.requestInit!==void 0&&(!r.requestInit||typeof r.requestInit!="object"))throw new TypeError("options.requestInit, when provided, must be an object.");if(r.getRetryDelay!==void 0&&typeof r.getRetryDelay!="function")throw new TypeError("options.getRetryDelay, when provided, must be a function.");if(r.maxCacheSize!==void 0&&(!s7(r.maxCacheSize)||r.maxCacheSize<0))throw new TypeError("options.maxCacheSize, when provided, must be a non-negative number.");if(r.fetchFn!==void 0&&typeof r.fetchFn!="function")throw new TypeError("options.fetchFn, when provided, must be a function.");super(),this._existingResponses=new WeakMap,this._url=e,this._options=r,this._getRetryDelay=r.getRetryDelay??IF,this._orchestrator=new MF({maxCacheSize:r.maxCacheSize??64*2**20,maxWorkerCount:2,runWorker:this._runWorker.bind(this),prefetchProfile:RF.network})}async _retrieveSize(){const e=new AbortController,r=await Y6(this._options.fetchFn??fetch,this._url,G6(this._options.requestInit??{},{headers:{Range:"bytes=0-"},signal:e.signal}),this._getRetryDelay,()=>this._disposed);if(!r.ok)throw new Error(`Error fetching ${String(this._url)}: ${r.status} ${r.statusText}`);let n,i;if(r.status===206)i=this._getTotalLengthFromRangeResponse(r),n=this._orchestrator.createWorker(0,Math.min(i,j7));else{const a=r.headers.get("Content-Length");if(a)i=Number(a),n=this._orchestrator.createWorker(0,i),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 new Error(`HTTP response (status ${r.status}) must surface Content-Length header.`)}return this._orchestrator.fileSize=i,this._existingResponses.set(n,{response:r,abortController:e}),this._orchestrator.runWorker(n),i}_read(e,r){return this._orchestrator.read(e,r)}async _runWorker(e){for(;;){const r=this._existingResponses.get(e);this._existingResponses.delete(e);let n=r?.abortController,i=r?.response;if(n||(n=new AbortController,i=await Y6(this._options.fetchFn??fetch,this._url,G6(this._options.requestInit??{},{headers:{Range:`bytes=${e.currentPos}-`},signal:n.signal}),this._getRetryDelay,()=>this._disposed)),$e(i),!i.ok)throw new Error(`Error fetching ${String(this._url)}: ${i.status} ${i.statusText}`);if(e.currentPos>0&&i.status!==206)throw new 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(!i.body)throw new Error("Missing HTTP response body stream. The used fetch function must provide the response body as a ReadableStream.");const a=i.body.getReader();for(;;){if(e.currentPos>=e.targetPos||e.aborted){n.abort(),e.running=!1;return}let o;try{o=await a.read()}catch(c){if(this._disposed)throw c;const f=this._getRetryDelay(1,c,this._url);if(f!==null){console.error("Error while reading response stream. Attempting to resume.",c),await new Promise(h=>setTimeout(h,1e3*f));break}else throw c}if(e.aborted)break;const{done:s,value:l}=o;if(s){if(e.currentPos>=e.targetPos){this._orchestrator.forgetWorker(e),e.running=!1;return}break}this.onread?.(e.currentPos,e.currentPos+l.length),this._orchestrator.supplyWorkerData(e,l)}if(e.aborted)break}e.running=!1}_getTotalLengthFromRangeResponse(e){const r=e.headers.get("Content-Range");if(r){const i=/\/(\d+)/.exec(r);if(i)return Number(i[1])}const n=e.headers.get("Content-Length");if(n)return Number(n);throw new Error("Partial HTTP response (status 206) must surface either Content-Range or Content-Length header.")}_dispose(){this._orchestrator.dispose()}}const RF={network:(t,e,r)=>{t=Math.max(0,Math.floor((t-65536)/65536)*65536);for(const i of r){const o=Math.max((i.startPos+i.targetPos)/2,i.targetPos-8388608);if(R5(t,e,o,i.targetPos)){const s=i.targetPos-i.startPos,l=Math.ceil((s+1)/8388608)*8388608,c=2**Math.ceil(Math.log2(s+1)),f=Math.min(c,l);e=Math.max(e,i.startPos+f)}}return e=Math.max(e,t+j7),{start:t,end:e}}};class MF{constructor(e){this.options=e,this.fileSize=null,this.nextAge=0,this.workers=[],this.cache=[],this.currentCacheSize=0,this.disposed=!1}read(e,r){$e(this.fileSize!==null);const n=this.options.prefetchProfile(e,r,this.workers),i=Math.max(n.start,0),a=Math.min(n.end,this.fileSize);$e(i<=e&&r<=a);let o=null;const s=oi(this.cache,e,S=>S.start),l=s!==-1?this.cache[s]:null;l&&l.start<=e&&r<=l.end&&(l.age=this.nextAge++,o={bytes:l.bytes,view:l.view,offset:l.start});const c=oi(this.cache,i,S=>S.start),f=o?null:new Uint8Array(r-e);let h=0,d=i;const p=[];if(c!==-1){for(let S=c;S<this.cache.length;S++){const E=this.cache[S];if(E.start>=a)break;if(E.end<=i)continue;const _=Math.max(i,E.start),P=Math.min(a,E.end);if($e(_<=P),d<_&&p.push({start:d,end:_}),d=P,f){const O=Math.max(e,E.start),T=Math.min(r,E.end);if(O<T){const N=O-e;f.set(E.bytes.subarray(O-E.start,T-E.start),N),N===h&&(h=T-e)}}E.age=this.nextAge++}d<a&&p.push({start:d,end:a})}else p.push({start:i,end:a});if(f&&h>=f.length&&(o={bytes:f,view:Wa(f),offset:e}),p.length===0)return $e(o),o;const{promise:y,resolve:w,reject:x}=wl(),b=[];for(const S of p){const E=Math.max(e,S.start),_=Math.min(r,S.end);E===S.start&&_===S.end?b.push(S):E<_&&b.push({start:E,end:_})}for(const S of p){const E=f&&{start:e,bytes:f,holes:b,resolve:w,reject:x};let _=!1;for(const P of this.workers)if(R5(S.start-131072,S.start,P.currentPos,P.targetPos)){P.targetPos=Math.max(P.targetPos,S.end),_=!0,E&&!P.pendingSlices.includes(E)&&P.pendingSlices.push(E),P.running||this.runWorker(P);break}if(!_){const P=this.createWorker(S.start,S.end);E&&(P.pendingSlices=[E]),this.runWorker(P)}}return o||($e(f),o=y.then(S=>({bytes:S,view:Wa(S),offset:e}))),o}createWorker(e,r){const n={startPos:e,currentPos:e,targetPos:r,running:!1,aborted:this.disposed,pendingSlices:[],age:this.nextAge++};for(this.workers.push(n);this.workers.length>this.options.maxWorkerCount;){let i=0,a=this.workers[0];for(let o=1;o<this.workers.length;o++){const s=this.workers[o];s.age<a.age&&(i=o,a=s)}if(a.running&&a.pendingSlices.length>0)break;a.aborted=!0,this.workers.splice(i,1)}return n}runWorker(e){$e(!e.running),$e(e.currentPos<e.targetPos),e.running=!0,e.age=this.nextAge++,this.options.runWorker(e).catch(r=>{if(e.running=!1,e.pendingSlices.length>0)e.pendingSlices.forEach(n=>n.reject(r)),e.pendingSlices.length=0;else throw r})}supplyWorkerData(e,r){$e(!e.aborted);const n=e.currentPos,i=n+r.length;this.insertIntoCache({start:n,end:i,bytes:r,view:Wa(r),age:this.nextAge++}),e.currentPos+=r.length,e.targetPos=Math.max(e.targetPos,e.currentPos);for(let a=0;a<e.pendingSlices.length;a++){const o=e.pendingSlices[a],s=Math.max(n,o.start),l=Math.min(i,o.start+o.bytes.length);s<l&&o.bytes.set(r.subarray(s-n,l-n),s-o.start);for(let c=0;c<o.holes.length;c++){const f=o.holes[c];n<=f.start&&i>f.start&&(f.start=i),f.end<=f.start&&(o.holes.splice(c,1),c--)}o.holes.length===0&&(o.resolve(o.bytes),e.pendingSlices.splice(a,1),a--)}for(let a=0;a<this.workers.length;a++){const o=this.workers[a];e===o||o.running||R5(n,i,o.currentPos,o.targetPos)&&(this.workers.splice(a,1),a--)}}forgetWorker(e){const r=this.workers.indexOf(e);$e(r!==-1),this.workers.splice(r,1)}insertIntoCache(e){if(this.options.maxCacheSize===0)return;let r=oi(this.cache,e.start,n=>n.start)+1;if(r>0){const n=this.cache[r-1];if(n.end>=e.end)return;if(n.end>e.start){const i=new Uint8Array(e.end-n.start);i.set(n.bytes,0),i.set(e.bytes,e.start-n.start),this.currentCacheSize+=e.end-n.end,n.bytes=i,n.view=Wa(i),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(let n=r+1;n<this.cache.length;n++){const i=this.cache[n];if(e.end<=i.start)break;if(e.end>=i.end){this.cache.splice(n,1),this.currentCacheSize-=i.bytes.length,n--;continue}const a=new Uint8Array(i.end-e.start);a.set(e.bytes,0),a.set(i.bytes,i.start-e.start),this.currentCacheSize-=e.end-i.start,e.bytes=a,e.view=Wa(a),e.end=i.end,this.cache.splice(n,1);break}for(;this.currentCacheSize>this.options.maxCacheSize;){let n=0,i=this.cache[0];for(let a=1;a<this.cache.length;a++){const o=this.cache[a];o.age<i.age&&(n=a,i=o)}if(this.currentCacheSize-i.bytes.length<=this.options.maxCacheSize)break;this.cache.splice(n,1),this.currentCacheSize-=i.bytes.length}}dispose(){for(const e of this.workers)e.aborted=!0;this.workers.length=0,this.cache.length=0,this.disposed=!0}}o7();class DF{get disposed(){return this._disposed}constructor(e){if(this._demuxerPromise=null,this._format=null,this._disposed=!1,!e||typeof e!="object")throw new TypeError("options must be an object.");if(!Array.isArray(e.formats)||e.formats.some(r=>!(r instanceof _h)))throw new TypeError("options.formats must be an array of InputFormat.");if(!(e.source instanceof Xb))throw new TypeError("options.source must be a Source.");if(e.source._disposed)throw new Error("options.source must not be disposed.");this._formats=e.formats,this._source=e.source,this._reader=new FF(e.source)}_getDemuxer(){return this._demuxerPromise??=(async()=>{this._reader.fileSize=await this._source.getSizeOrNull();for(const e of this._formats)if(await e._canReadInput(this))return this._format=e,e._createDemuxer(this);throw new Error("Input has an unsupported or unrecognizable format.")})()}get source(){return this._source}async getFormat(){return await this._getDemuxer(),$e(this._format),this._format}async computeDuration(){return(await this._getDemuxer()).computeDuration()}async getTracks(){return(await this._getDemuxer()).getTracks()}async getVideoTracks(){return(await this.getTracks()).filter(r=>r.isVideoTrack())}async getAudioTracks(){return(await this.getTracks()).filter(r=>r.isAudioTrack())}async getPrimaryVideoTrack(){return(await this.getTracks()).find(r=>r.isVideoTrack())??null}async getPrimaryAudioTrack(){return(await this.getTracks()).find(r=>r.isAudioTrack())??null}async getMimeType(){return(await this._getDemuxer()).getMimeType()}async getMetadataTags(){return(await this._getDemuxer()).getMetadataTags()}dispose(){this._disposed||(this._disposed=!0,this._source._disposed=!0,this._source._dispose())}[Symbol.dispose](){this.dispose()}}class xl extends Error{constructor(e="Input has been disposed."){super(e),this.name="InputDisposedError"}}class FF{constructor(e){this.source=e}requestSlice(e,r){if(this.source._disposed)throw new xl;if(this.fileSize!==null&&e+r>this.fileSize)return null;const n=e+r,i=this.source._read(e,n);return i instanceof Promise?i.then(a=>a?new Rp(a.bytes,a.view,a.offset,e,n):null):i?new Rp(i.bytes,i.view,i.offset,e,n):null}requestSliceRange(e,r,n){if(this.source._disposed)throw new xl;if(this.fileSize!==null)return this.requestSlice(e,vp(this.fileSize-e,r,n));{const i=this.requestSlice(e,n),a=o=>{if(o)return o;const s=c=>($e(c!==null),this.requestSlice(e,vp(c-e,r,n))),l=this.source._retrieveSize();return l instanceof Promise?l.then(s):s(l)};return i instanceof Promise?i.then(a):a(i)}}}class Rp{constructor(e,r,n,i,a){this.bytes=e,this.view=r,this.offset=n,this.start=i,this.end=a,this.bufferPos=i-n}static tempFromBytes(e){return new Rp(e,Wa(e),0,0,e.length)}get length(){return this.end-this.start}get filePos(){return this.offset+this.bufferPos}set filePos(e){this.bufferPos=e-this.offset}get remainingLength(){return Math.max(this.end-this.filePos,0)}skip(e){this.bufferPos+=e}slice(e,r=this.end-e){if(e<this.start||e+r>this.end)throw new RangeError("Slicing outside of original slice.");return new Rp(this.bytes,this.view,this.offset,e,e+r)}}const Zs=(t,e)=>{if(t.filePos<t.start||t.filePos+e>t.end)throw new RangeError(`Tried reading [${t.filePos}, ${t.filePos+e}), but slice is [${t.start}, ${t.end}). This is likely an internal error, please report it alongside the file that caused it.`)},Nr=(t,e)=>{Zs(t,e);const r=t.bytes.subarray(t.bufferPos,t.bufferPos+e);return t.bufferPos+=e,r},dr=t=>(Zs(t,1),t.view.getUint8(t.bufferPos++)),f0=(t,e)=>{Zs(t,2);const r=t.view.getUint16(t.bufferPos,e);return t.bufferPos+=2,r},ts=t=>{Zs(t,2);const e=t.view.getUint16(t.bufferPos,!1);return t.bufferPos+=2,e},np=t=>{Zs(t,3);const e=Xm(t.view,t.bufferPos,!1);return t.bufferPos+=3,e},H5=t=>{Zs(t,2);const e=t.view.getInt16(t.bufferPos,!1);return t.bufferPos+=2,e},ah=(t,e)=>{Zs(t,4);const r=t.view.getUint32(t.bufferPos,e);return t.bufferPos+=4,r},Dt=t=>{Zs(t,4);const e=t.view.getUint32(t.bufferPos,!1);return t.bufferPos+=4,e},pp=t=>{Zs(t,4);const e=t.view.getUint32(t.bufferPos,!0);return t.bufferPos+=4,e},Kh=t=>{Zs(t,4);const e=t.view.getInt32(t.bufferPos,!1);return t.bufferPos+=4,e},BF=t=>{Zs(t,4);const e=t.view.getInt32(t.bufferPos,!0);return t.bufferPos+=4,e},cx=(t,e)=>{let r,n;return e?(r=ah(t,!0),n=ah(t,!0)):(n=ah(t,!1),r=ah(t,!1)),n*4294967296+r},xu=t=>{const e=Dt(t),r=Dt(t);return e*4294967296+r},jF=t=>{const e=Kh(t),r=Dt(t);return e*4294967296+r},zF=t=>{const e=pp(t);return BF(t)*4294967296+e},UF=t=>{Zs(t,4);const e=t.view.getFloat32(t.bufferPos,!1);return t.bufferPos+=4,e},z7=t=>{Zs(t,8);const e=t.view.getFloat64(t.bufferPos,!1);return t.bufferPos+=8,e},Fo=(t,e)=>{Zs(t,e);let r="";for(let n=0;n<e;n++)r+=String.fromCharCode(t.bytes[t.bufferPos++]);return r},Yd=.05,qF=(t,e,r)=>{const[n,i]=oe.useState({input:null,videoSink:null,duration:0,isReady:!1,error:null});oe.useRef(n).current=n;const a=oe.useRef(0),o=oe.useRef(null),s=oe.useRef(null),l=oe.useRef(null),c=oe.useRef(null),f=oe.useRef(null),h=oe.useRef(null),d=oe.useRef(!1),p=oe.useRef(null),y=oe.useRef([]),w=oe.useRef(null),x=oe.useRef(!1),[,b]=oe.useReducer(S=>S+1,0);return oe.useEffect(()=>{if(!r)return;let S=!0;const E=++a.current;let _=null;return(async()=>{try{if(!S||E!==a.current)return;_=rf(`mediabunny init ${t.id}`);const P=await(async function(A){if((function(L){return L.startsWith("data:")})(A)){const L=(function(H){const U=H.indexOf(",");if(U===-1)throw new Error("Invalid data URL format");const ee=H.slice(U+1),se=atob(ee),te=new Uint8Array(se.length);for(let Z=0;Z<se.length;Z++)te[Z]=se.charCodeAt(Z);return te.buffer})(A);return new ux(L)}if((function(L){return L.startsWith("file://")})(A))try{const L=await fetch(A),H=await L.arrayBuffer();return new ux(H)}catch(L){throw new Error(`Failed to load file URL: ${A}. File URLs may not be supported in this environment. Error: ${L}`)}return new LF(A)})(t.src);if(!S||E!==a.current)return void(_&&(_(),_=null));const O=new DF({source:P,formats:NF}),T=await O.computeDuration(),N=await O.getPrimaryVideoTrack();if(!N)throw new Error("No video track found");if(N.codec===null)throw new Error("Unsupported video codec");if(!await N.canDecode())throw new Error("Unable to decode the video track");const D=await N.canBeTransparent(),F=new yD(N,{poolSize:5,fit:"contain",alpha:D});if(!S||E!==a.current)return O.dispose(),void(_&&(_(),_=null));_&&(_(),_=null),i(A=>Object.assign(Object.assign({},A),{input:O,videoSink:F,duration:T,isReady:!0,error:null}))}catch(P){if(console.error("Failed to initialize mediabunny:",P),_&&(_(),_=null),S&&E===a.current){const O=`Failed to initialize mediabunny for video ${t.id}: ${P}`;zp(O),i(T=>Object.assign(Object.assign({},T),{error:String(P),isReady:!1}))}}})(),()=>{S=!1,_&&(_(),_=null)}},[t.src,r]),oe.useEffect(()=>()=>{s.current&&(s.current.return(),s.current=null),o.current&&(o.current(),o.current=null),l.current=null,c.current=null,f.current=null,d.current=!1,p.current=null,y.current=[],w.current=null,x.current=!1,i({input:null,videoSink:null,duration:0,isReady:!1,error:null})},[r]),oe.useEffect(()=>{if(!r||!n.isReady||!n.videoSink)return;const S=++a.current,E=typeof t.src=="string"?t.src.slice(0,120):String(t.src),_=(L,H={},U="debug")=>{let ee="";try{ee=JSON.stringify(Object.assign(Object.assign({},H),{timeCalc:h.current}))}catch(te){ee=`[unserializable extras: ${String(te)}]`}const se=`mediabunny event=${L} elementId=${t.id} targetTime=${f.current} duration=${n.duration} lastFrameTimestamp=${c.current} hasIterator=${!!s.current} prefetchSize=${y.current.length} srcHint=${E} extras=${ee}`;U==="error"?console.error(se):U==="warn"?console.warn(se):console.debug(se)},P=L=>{const H=n.duration||0;if(!H||!Number.isFinite(H))return L;const U=H>Yd?H-Yd:H;return Math.max(0,Math.min(L,U))},O=L=>{let H=l.current;H&&H.width===L.canvas.width&&H.height===L.canvas.height||(H||(H=document.createElement("canvas"),l.current=H),H.width=L.canvas.width,H.height=L.canvas.height);const U=H.getContext("2d");U&&(U.clearRect(0,0,H.width,H.height),U.drawImage(L.canvas,0,0)),c.current=L.timestamp},T=L=>{const H=s.current;H&&(x.current||(x.current=!0,w.current=(async()=>{try{for(;y.current.length<4&&L===a.current;){const U=await H.next();if(L!==a.current)return;if(U.done||!U.value)break;y.current.push({timestamp:U.value.timestamp,frame:U.value})}}catch{}finally{x.current=!1,w.current=null}})()))},N=L=>{const H=y.current;for(let U=0;U<H.length;U++)if(Math.abs(H[U].timestamp-L)<Yd){const ee=H[U];return y.current=H.slice(U+1),ee}return null},D=()=>{y.current=[]},F=async(L,H,U=0)=>{const ee=P(L),se=(te=>{const Z=c.current;return Z===null||te<Z-Yd||te>Z+.5})(ee)?"seek":"iterate";try{const te=n.videoSink,Z=c.current;if(Z!==null&&Math.abs(Z-ee)<Yd)return void(f.current=L);const ne=N(ee);if(ne)return O(ne.frame),f.current=L,T(H),void b();if(w.current){await w.current;const G=N(ee);if(G)return O(G.frame),f.current=L,T(H),void b()}if(D(),se==="seek"){s.current&&(await s.current.return(),s.current=null);const G=te.canvases(ee);s.current=G;const j=await G.next();if(H!==a.current)return void(s.current&&(await s.current.return(),s.current=null));if(j.done||!j.value){if(_("iterator_exhausted",{mode:se,requestedTargetTime:L,clampedTargetTime:ee},"warn"),H===a.current)try{s.current&&(await s.current.return(),s.current=null),D();const B=te.canvases(ee);s.current=B;const z=await B.next();!z.done&&z.value&&(O(z.value),T(H),f.current=L,b())}catch{}return}O(j.value),T(H)}else{const G=s.current;if(!G)return;let j=!1;for(;H===a.current;){const B=await G.next();if(H!==a.current)break;if(B.done||!B.value){if(_("iterator_exhausted",{mode:se,requestedTargetTime:L,clampedTargetTime:ee},"warn"),!j){j=!0;try{s.current&&(await s.current.return(),s.current=null),D();const Y=te.canvases(ee);s.current=Y;const Q=await Y.next();if(H!==a.current||Q.done||!Q.value)break;O(Q.value),T(H);break}catch{break}}break}const z=B.value;if(O(z),Math.abs(z.timestamp-ee)<Yd){T(H);break}if(z.timestamp>ee){T(H);break}}}f.current=L,b()}catch(te){const Z=te instanceof Error?{name:te.name,message:te.message,stack:te.stack}:{message:String(te)},ne=te instanceof Error?`${te.name}: ${te.message}`:String(te),G=ne.includes("Unsupported configuration")||ne.includes("isConfigSupported")||ne.includes("OperationError");if(_("frame_process_failed",{mode:se,requestedTargetTime:L,clampedTargetTime:ee,unsupportedConfigAttempt:U,isUnsupportedConfig:G,error:Z},"error"),G&&U<1)try{s.current&&(await s.current.return(),s.current=null),D(),w.current=null,x.current=!1,c.current=null,await F(L,H,U+1)}catch{}}},A=Tu(()=>{const L=n.videoSink,H=n.duration;if(!L||!H)return;const U=t.startTime*H*1e3,ee=H*(t.endTime-t.startTime)*1e3,se=((e.currentTime||t.page.startTime)-t.page.startTime)%ee+U,te=se/1e3,Z=P(te);h.current={pageStartTime:t.page.startTime,storeCurrentTime:e.currentTime,offsetMs:U,durationMs:ee,restMs:se,targetTime:te,clampedTargetTime:Z,startTime:t.startTime,endTime:t.endTime,videoDuration:H},((ne,G)=>{d.current?p.current=ne:(d.current=!0,o.current||(o.current=rf(`mediabunny video frame ${t.id}`)),(async()=>{let j=ne;for(;j!==null&&G===a.current;)await F(j,G),j=p.current,p.current=null;o.current&&(o.current(),o.current=null),d.current=!1})())})(Z,S)});return()=>{A(),a.current++,o.current&&(o.current(),o.current=null)}},[r,n.isReady,n.videoSink,n.duration,e,t]),r&&n.isReady?l.current:null};function wp(){return document.createElement("canvas")}const U7=new window.Image;U7.src=ff(`
|
|
281
281
|
<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
282
282
|
<path opacity="0.6" d="M4 5.49683V18.5032C4 20.05 5.68077 21.0113 7.01404 20.227L18.0694 13.7239C19.384 12.9506 19.384 11.0494 18.0694 10.2761L7.01404 3.77296C5.68077 2.98869 4 3.95 4 5.49683Z" fill="white"/>
|
|
283
283
|
<path d="M4 5.49683V18.5032C4 20.05 5.68077 21.0113 7.01404 20.227L18.0694 13.7239C19.384 12.9506 19.384 11.0494 18.0694 10.2761L7.01404 3.77296C5.68077 2.98869 4 3.95 4 5.49683Z" stroke="#323232" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
@@ -511,7 +511,7 @@ T* `):V.join(` Tj
|
|
|
511
511
|
endobj\r
|
|
512
512
|
`},r.outline.count_r=function(n,i){for(var a=0;a<i.children.length;a++)n.count++,this.count_r(n,i.children[a]);return n.count}}])})(cr.API),(function(t){var e=[192,193,194,195,196,197,198,199];t.processJPEG=function(r,n,i,a,o,s){var l,c=this.decode.DCT_DECODE,f=null;if(typeof r=="string"||this.__addimage__.isArrayBuffer(r)||this.__addimage__.isArrayBufferView(r)){switch(r=o||r,r=this.__addimage__.isArrayBuffer(r)?new Uint8Array(r):r,l=(function(h){for(var d,p=256*h.charCodeAt(4)+h.charCodeAt(5),y=h.length,w={width:0,height:0,numcomponents:1},x=4;x<y;x+=2){if(x+=p,e.indexOf(h.charCodeAt(x+1))!==-1){d=256*h.charCodeAt(x+5)+h.charCodeAt(x+6),w={width:256*h.charCodeAt(x+7)+h.charCodeAt(x+8),height:d,numcomponents:h.charCodeAt(x+9)};break}p=256*h.charCodeAt(x+2)+h.charCodeAt(x+3)}return w})(r=this.__addimage__.isArrayBufferView(r)?this.__addimage__.arrayBufferToBinaryString(r):r),l.numcomponents){case 1:s=this.color_spaces.DEVICE_GRAY;break;case 4:s=this.color_spaces.DEVICE_CMYK;break;case 3:s=this.color_spaces.DEVICE_RGB}f={data:r,width:l.width,height:l.height,colorSpace:s,bitsPerComponent:8,filter:c,index:n,alias:i}}return f}})(cr.API),cr.API.processPNG=function(t,e,r,n){if(this.__addimage__.isArrayBuffer(t)&&(t=new Uint8Array(t)),this.__addimage__.isArrayBufferView(t)){var i,a=$U(t,{checkCrc:!0}),o=a.width,s=a.height,l=a.channels,c=a.palette,f=a.depth;i=c&&l===1?(function(N){for(var D=N.width,F=N.height,A=N.data,L=N.palette,H=N.depth,U=!1,ee=[],se=[],te=void 0,Z=!1,ne=0,G=0;G<L.length;G++){var j=Vx(L[G],4),B=j[0],z=j[1],Y=j[2],Q=j[3];ee.push(B,z,Y),Q!=null&&(Q===0?(ne++,se.length<1&&se.push(G)):Q<255&&(Z=!0))}if(Z||ne>1){U=!0,se=void 0;var K=D*F;te=new Uint8Array(K);for(var ie=new DataView(A.buffer),he=0;he<K;he++){var ue=Zy(ie,he,H),we=Vx(L[ue],4)[3];te[he]=we}}else ne===0&&(se=void 0);return{colorSpace:"Indexed",colorsPerPixel:1,sMaskBitsPerComponent:U?8:void 0,colorBytes:A,alphaBytes:te,needSMask:U,palette:ee,mask:se}})(a):l===2||l===4?(function(N){for(var D=N.data,F=N.width,A=N.height,L=N.channels,H=N.depth,U=L===2?"DeviceGray":"DeviceRGB",ee=L-1,se=F*A,te=ee,Z=se*te,ne=1*se,G=Math.ceil(Z*H/8),j=Math.ceil(ne*H/8),B=new Uint8Array(G),z=new Uint8Array(j),Y=new DataView(D.buffer),Q=new DataView(B.buffer),K=new DataView(z.buffer),ie=!1,he=0;he<se;he++){for(var ue=he*L,we=0;we<te;we++)Y8(Q,Zy(Y,ue+we,H),he*te+we,H);var Ae=Zy(Y,ue+te,H);Ae<(1<<H)-1&&(ie=!0),Y8(K,Ae,1*he,H)}return{colorSpace:U,colorsPerPixel:ee,sMaskBitsPerComponent:ie?H:void 0,colorBytes:B,alphaBytes:z,needSMask:ie}})(a):(function(N){var D=N.data,F=N.channels===1?"DeviceGray":"DeviceRGB";return{colorSpace:F,colorsPerPixel:F==="DeviceGray"?1:3,colorBytes:D instanceof Uint16Array?(function(A){for(var L=A.length,H=new Uint8Array(2*L),U=new DataView(H.buffer,H.byteOffset,H.byteLength),ee=0;ee<L;ee++)U.setUint16(2*ee,A[ee],!1);return H})(D):D,needSMask:!1}})(a);var h,d,p,y=i,w=y.colorSpace,x=y.colorsPerPixel,b=y.sMaskBitsPerComponent,S=y.colorBytes,E=y.alphaBytes,_=y.needSMask,P=y.palette,O=y.mask,T=null;return n!==cr.API.image_compression.NONE&&typeof Y5=="function"?(T=(function(N){var D;switch(N){case cr.API.image_compression.FAST:D=11;break;case cr.API.image_compression.MEDIUM:D=13;break;case cr.API.image_compression.SLOW:D=14;break;default:D=12}return D})(n),h=this.decode.FLATE_DECODE,d="/Predictor ".concat(T," /Colors ").concat(x," /BitsPerComponent ").concat(f," /Columns ").concat(o),t=V8(S,Math.ceil(o*x*f/8),x,f,n),_&&(p=V8(E,Math.ceil(o*b/8),1,b,n))):(h=void 0,d=void 0,t=S,_&&(p=E)),(this.__addimage__.isArrayBuffer(t)||this.__addimage__.isArrayBufferView(t))&&(t=this.__addimage__.arrayBufferToBinaryString(t)),(p&&this.__addimage__.isArrayBuffer(p)||this.__addimage__.isArrayBufferView(p))&&(p=this.__addimage__.arrayBufferToBinaryString(p)),{alias:r,data:t,index:e,filter:h,decodeParameters:d,transparency:O,palette:P,sMask:p,predictor:T,width:o,height:s,bitsPerComponent:f,sMaskBitsPerComponent:b,colorSpace:w}}},(function(t){t.processGIF89A=function(e,r,n,i){var a=new hq(e),o=a.width,s=a.height,l=[];a.decodeAndBlitFrameRGBA(0,l);var c={data:l,width:o,height:s},f=new Qy(100).encode(c,100);return t.processJPEG.call(this,f,r,n,i)},t.processGIF87A=t.processGIF89A})(cr.API),wu.prototype.parseHeader=function(){if(this.fileSize=this.datav.getUint32(this.pos,!0),this.pos+=4,this.reserved=this.datav.getUint32(this.pos,!0),this.pos+=4,this.offset=this.datav.getUint32(this.pos,!0),this.pos+=4,this.headerSize=this.datav.getUint32(this.pos,!0),this.pos+=4,this.width=this.datav.getUint32(this.pos,!0),this.pos+=4,this.height=this.datav.getInt32(this.pos,!0),this.pos+=4,this.planes=this.datav.getUint16(this.pos,!0),this.pos+=2,this.bitPP=this.datav.getUint16(this.pos,!0),this.pos+=2,this.compress=this.datav.getUint32(this.pos,!0),this.pos+=4,this.rawSize=this.datav.getUint32(this.pos,!0),this.pos+=4,this.hr=this.datav.getUint32(this.pos,!0),this.pos+=4,this.vr=this.datav.getUint32(this.pos,!0),this.pos+=4,this.colors=this.datav.getUint32(this.pos,!0),this.pos+=4,this.importantColors=this.datav.getUint32(this.pos,!0),this.pos+=4,this.bitPP===16&&this.is_with_alpha&&(this.bitPP=15),this.bitPP<15){var t=this.colors===0?1<<this.bitPP:this.colors;this.palette=new Array(t);for(var e=0;e<t;e++){var r=this.datav.getUint8(this.pos++,!0),n=this.datav.getUint8(this.pos++,!0),i=this.datav.getUint8(this.pos++,!0),a=this.datav.getUint8(this.pos++,!0);this.palette[e]={red:i,green:n,blue:r,quad:a}}}this.height<0&&(this.height*=-1,this.bottom_up=!1)},wu.prototype.parseBGR=function(){this.pos=this.offset;try{var t="bit"+this.bitPP,e=this.width*this.height*4;this.data=new Uint8Array(e),this[t]()}catch(r){ai.log("bit decode error:"+r)}},wu.prototype.bit1=function(){var t,e=Math.ceil(this.width/8),r=e%4;for(t=this.height-1;t>=0;t--){for(var n=this.bottom_up?t:this.height-1-t,i=0;i<e;i++)for(var a=this.datav.getUint8(this.pos++,!0),o=n*this.width*4+8*i*4,s=0;s<8&&8*i+s<this.width;s++){var l=this.palette[a>>7-s&1];this.data[o+4*s]=l.blue,this.data[o+4*s+1]=l.green,this.data[o+4*s+2]=l.red,this.data[o+4*s+3]=255}r!==0&&(this.pos+=4-r)}},wu.prototype.bit4=function(){for(var t=Math.ceil(this.width/2),e=t%4,r=this.height-1;r>=0;r--){for(var n=this.bottom_up?r:this.height-1-r,i=0;i<t;i++){var a=this.datav.getUint8(this.pos++,!0),o=n*this.width*4+2*i*4,s=a>>4,l=15&a,c=this.palette[s];if(this.data[o]=c.blue,this.data[o+1]=c.green,this.data[o+2]=c.red,this.data[o+3]=255,2*i+1>=this.width)break;c=this.palette[l],this.data[o+4]=c.blue,this.data[o+4+1]=c.green,this.data[o+4+2]=c.red,this.data[o+4+3]=255}e!==0&&(this.pos+=4-e)}},wu.prototype.bit8=function(){for(var t=this.width%4,e=this.height-1;e>=0;e--){for(var r=this.bottom_up?e:this.height-1-e,n=0;n<this.width;n++){var i=this.datav.getUint8(this.pos++,!0),a=r*this.width*4+4*n;if(i<this.palette.length){var o=this.palette[i];this.data[a]=o.red,this.data[a+1]=o.green,this.data[a+2]=o.blue,this.data[a+3]=255}else this.data[a]=255,this.data[a+1]=255,this.data[a+2]=255,this.data[a+3]=255}t!==0&&(this.pos+=4-t)}},wu.prototype.bit15=function(){for(var t=this.width%3,e=parseInt("11111",2),r=this.height-1;r>=0;r--){for(var n=this.bottom_up?r:this.height-1-r,i=0;i<this.width;i++){var a=this.datav.getUint16(this.pos,!0);this.pos+=2;var o=(a&e)/e*255|0,s=(a>>5&e)/e*255|0,l=(a>>10&e)/e*255|0,c=a>>15?255:0,f=n*this.width*4+4*i;this.data[f]=l,this.data[f+1]=s,this.data[f+2]=o,this.data[f+3]=c}this.pos+=t}},wu.prototype.bit16=function(){for(var t=this.width%3,e=parseInt("11111",2),r=parseInt("111111",2),n=this.height-1;n>=0;n--){for(var i=this.bottom_up?n:this.height-1-n,a=0;a<this.width;a++){var o=this.datav.getUint16(this.pos,!0);this.pos+=2;var s=(o&e)/e*255|0,l=(o>>5&r)/r*255|0,c=(o>>11)/e*255|0,f=i*this.width*4+4*a;this.data[f]=c,this.data[f+1]=l,this.data[f+2]=s,this.data[f+3]=255}this.pos+=t}},wu.prototype.bit24=function(){for(var t=this.height-1;t>=0;t--){for(var e=this.bottom_up?t:this.height-1-t,r=0;r<this.width;r++){var n=this.datav.getUint8(this.pos++,!0),i=this.datav.getUint8(this.pos++,!0),a=this.datav.getUint8(this.pos++,!0),o=e*this.width*4+4*r;this.data[o]=a,this.data[o+1]=i,this.data[o+2]=n,this.data[o+3]=255}this.pos+=this.width%4}},wu.prototype.bit32=function(){for(var t=this.height-1;t>=0;t--)for(var e=this.bottom_up?t:this.height-1-t,r=0;r<this.width;r++){var n=this.datav.getUint8(this.pos++,!0),i=this.datav.getUint8(this.pos++,!0),a=this.datav.getUint8(this.pos++,!0),o=this.datav.getUint8(this.pos++,!0),s=e*this.width*4+4*r;this.data[s]=a,this.data[s+1]=i,this.data[s+2]=n,this.data[s+3]=o}},wu.prototype.getData=function(){return this.data},(function(t){t.processBMP=function(e,r,n,i){var a=new wu(e,!1),o=a.width,s=a.height,l={data:a.getData(),width:o,height:s},c=new Qy(100).encode(l,100);return t.processJPEG.call(this,c,r,n,i)}})(cr.API),Z8.prototype.getData=function(){return this.data},(function(t){t.processWEBP=function(e,r,n,i){var a=new Z8(e),o=a.width,s=a.height,l={data:a.getData(),width:o,height:s},c=new Qy(100).encode(l,100);return t.processJPEG.call(this,c,r,n,i)}})(cr.API),cr.API.processRGBA=function(t,e,r){for(var n=t.data,i=n.length,a=new Uint8Array(i/4*3),o=new Uint8Array(i/4),s=0,l=0,c=0;c<i;c+=4){var f=n[c],h=n[c+1],d=n[c+2],p=n[c+3];a[s++]=f,a[s++]=h,a[s++]=d,o[l++]=p}var y=this.__addimage__.arrayBufferToBinaryString(a);return{alpha:this.__addimage__.arrayBufferToBinaryString(o),data:y,index:e,alias:r,colorSpace:"DeviceRGB",bitsPerComponent:8,width:t.width,height:t.height}},cr.API.setLanguage=function(t){return this.internal.languageSettings===void 0&&(this.internal.languageSettings={},this.internal.languageSettings.isSubscribed=!1),{af:"Afrikaans",sq:"Albanian",ar:"Arabic (Standard)","ar-DZ":"Arabic (Algeria)","ar-BH":"Arabic (Bahrain)","ar-EG":"Arabic (Egypt)","ar-IQ":"Arabic (Iraq)","ar-JO":"Arabic (Jordan)","ar-KW":"Arabic (Kuwait)","ar-LB":"Arabic (Lebanon)","ar-LY":"Arabic (Libya)","ar-MA":"Arabic (Morocco)","ar-OM":"Arabic (Oman)","ar-QA":"Arabic (Qatar)","ar-SA":"Arabic (Saudi Arabia)","ar-SY":"Arabic (Syria)","ar-TN":"Arabic (Tunisia)","ar-AE":"Arabic (U.A.E.)","ar-YE":"Arabic (Yemen)",an:"Aragonese",hy:"Armenian",as:"Assamese",ast:"Asturian",az:"Azerbaijani",eu:"Basque",be:"Belarusian",bn:"Bengali",bs:"Bosnian",br:"Breton",bg:"Bulgarian",my:"Burmese",ca:"Catalan",ch:"Chamorro",ce:"Chechen",zh:"Chinese","zh-HK":"Chinese (Hong Kong)","zh-CN":"Chinese (PRC)","zh-SG":"Chinese (Singapore)","zh-TW":"Chinese (Taiwan)",cv:"Chuvash",co:"Corsican",cr:"Cree",hr:"Croatian",cs:"Czech",da:"Danish",nl:"Dutch (Standard)","nl-BE":"Dutch (Belgian)",en:"English","en-AU":"English (Australia)","en-BZ":"English (Belize)","en-CA":"English (Canada)","en-IE":"English (Ireland)","en-JM":"English (Jamaica)","en-NZ":"English (New Zealand)","en-PH":"English (Philippines)","en-ZA":"English (South Africa)","en-TT":"English (Trinidad & Tobago)","en-GB":"English (United Kingdom)","en-US":"English (United States)","en-ZW":"English (Zimbabwe)",eo:"Esperanto",et:"Estonian",fo:"Faeroese",fj:"Fijian",fi:"Finnish",fr:"French (Standard)","fr-BE":"French (Belgium)","fr-CA":"French (Canada)","fr-FR":"French (France)","fr-LU":"French (Luxembourg)","fr-MC":"French (Monaco)","fr-CH":"French (Switzerland)",fy:"Frisian",fur:"Friulian",gd:"Gaelic (Scots)","gd-IE":"Gaelic (Irish)",gl:"Galacian",ka:"Georgian",de:"German (Standard)","de-AT":"German (Austria)","de-DE":"German (Germany)","de-LI":"German (Liechtenstein)","de-LU":"German (Luxembourg)","de-CH":"German (Switzerland)",el:"Greek",gu:"Gujurati",ht:"Haitian",he:"Hebrew",hi:"Hindi",hu:"Hungarian",is:"Icelandic",id:"Indonesian",iu:"Inuktitut",ga:"Irish",it:"Italian (Standard)","it-CH":"Italian (Switzerland)",ja:"Japanese",kn:"Kannada",ks:"Kashmiri",kk:"Kazakh",km:"Khmer",ky:"Kirghiz",tlh:"Klingon",ko:"Korean","ko-KP":"Korean (North Korea)","ko-KR":"Korean (South Korea)",la:"Latin",lv:"Latvian",lt:"Lithuanian",lb:"Luxembourgish",mk:"North Macedonia",ms:"Malay",ml:"Malayalam",mt:"Maltese",mi:"Maori",mr:"Marathi",mo:"Moldavian",nv:"Navajo",ng:"Ndonga",ne:"Nepali",no:"Norwegian",nb:"Norwegian (Bokmal)",nn:"Norwegian (Nynorsk)",oc:"Occitan",or:"Oriya",om:"Oromo",fa:"Persian","fa-IR":"Persian/Iran",pl:"Polish",pt:"Portuguese","pt-BR":"Portuguese (Brazil)",pa:"Punjabi","pa-IN":"Punjabi (India)","pa-PK":"Punjabi (Pakistan)",qu:"Quechua",rm:"Rhaeto-Romanic",ro:"Romanian","ro-MO":"Romanian (Moldavia)",ru:"Russian","ru-MO":"Russian (Moldavia)",sz:"Sami (Lappish)",sg:"Sango",sa:"Sanskrit",sc:"Sardinian",sd:"Sindhi",si:"Singhalese",sr:"Serbian",sk:"Slovak",sl:"Slovenian",so:"Somani",sb:"Sorbian",es:"Spanish","es-AR":"Spanish (Argentina)","es-BO":"Spanish (Bolivia)","es-CL":"Spanish (Chile)","es-CO":"Spanish (Colombia)","es-CR":"Spanish (Costa Rica)","es-DO":"Spanish (Dominican Republic)","es-EC":"Spanish (Ecuador)","es-SV":"Spanish (El Salvador)","es-GT":"Spanish (Guatemala)","es-HN":"Spanish (Honduras)","es-MX":"Spanish (Mexico)","es-NI":"Spanish (Nicaragua)","es-PA":"Spanish (Panama)","es-PY":"Spanish (Paraguay)","es-PE":"Spanish (Peru)","es-PR":"Spanish (Puerto Rico)","es-ES":"Spanish (Spain)","es-UY":"Spanish (Uruguay)","es-VE":"Spanish (Venezuela)",sx:"Sutu",sw:"Swahili",sv:"Swedish","sv-FI":"Swedish (Finland)","sv-SV":"Swedish (Sweden)",ta:"Tamil",tt:"Tatar",te:"Teluga",th:"Thai",tig:"Tigre",ts:"Tsonga",tn:"Tswana",tr:"Turkish",tk:"Turkmen",uk:"Ukrainian",hsb:"Upper Sorbian",ur:"Urdu",ve:"Venda",vi:"Vietnamese",vo:"Volapuk",wa:"Walloon",cy:"Welsh",xh:"Xhosa",ji:"Yiddish",zu:"Zulu"}[t]!==void 0&&(this.internal.languageSettings.languageCode=t,this.internal.languageSettings.isSubscribed===!1&&(this.internal.events.subscribe("putCatalog",function(){this.internal.write("/Lang ("+this.internal.languageSettings.languageCode+")")}),this.internal.languageSettings.isSubscribed=!0)),this},Qd=cr.API,Pg=Qd.getCharWidthsArray=function(t,e){var r,n,i=(e=e||{}).font||this.internal.getFont(),a=e.fontSize||this.internal.getFontSize(),o=e.charSpace||this.internal.getCharSpace(),s=e.widths?e.widths:i.metadata.Unicode.widths,l=s.fof?s.fof:1,c=e.kerning?e.kerning:i.metadata.Unicode.kerning,f=c.fof?c.fof:1,h=e.doKerning!==!1,d=0,p=t.length,y=0,w=s[0]||l,x=[];for(r=0;r<p;r++)n=t.charCodeAt(r),typeof i.metadata.widthOfString=="function"?x.push((i.metadata.widthOfGlyph(i.metadata.characterToGlyph(n))+o*(1e3/a)||0)/1e3):(d=h&&Hn(c[n])==="object"&&!isNaN(parseInt(c[n][y],10))?c[n][y]/f:0,x.push((s[n]||w)/l+d)),y=n;return x},U8=Qd.getStringUnitWidth=function(t,e){var r=(e=e||{}).fontSize||this.internal.getFontSize(),n=e.font||this.internal.getFont(),i=e.charSpace||this.internal.getCharSpace();return Qd.processArabic&&(t=Qd.processArabic(t)),typeof n.metadata.widthOfString=="function"?n.metadata.widthOfString(t,r,i)/r:Pg.apply(this,arguments).reduce(function(a,o){return a+o},0)},q8=function(t,e,r,n){for(var i=[],a=0,o=t.length,s=0;a!==o&&s+e[a]<r;)s+=e[a],a++;i.push(t.slice(0,a));var l=a;for(s=0;a!==o;)s+e[a]>n&&(i.push(t.slice(l,a)),s=0,l=a),s+=e[a],a++;return l!==a&&i.push(t.slice(l,a)),i},H8=function(t,e,r){r||(r={});var n,i,a,o,s,l,c,f=[],h=[f],d=r.textIndent||0,p=0,y=0,w=t.split(" "),x=Pg.apply(this,[" ",r])[0];if(l=r.lineIndent===-1?w[0].length+2:r.lineIndent||0){var b=Array(l).join(" "),S=[];w.map(function(_){(_=_.split(/\s*\n/)).length>1?S=S.concat(_.map(function(P,O){return(O&&P.length?`
|
|
513
513
|
`:"")+P})):S.push(_[0])}),w=S,l=U8.apply(this,[b,r])}for(a=0,o=w.length;a<o;a++){var E=0;if(n=w[a],l&&n[0]==`
|
|
514
|
-
`&&(n=n.substr(1),E=1),d+p+(y=(i=Pg.apply(this,[n,r])).reduce(function(_,P){return _+P},0))>e||E){if(y>e){for(s=q8.apply(this,[n,i,e-(d+p),e]),f.push(s.shift()),f=[s.pop()];s.length;)h.push([s.shift()]);y=i.slice(n.length-(f[0]?f[0].length:0)).reduce(function(_,P){return _+P},0)}else f=[n];h.push(f),d=y+l,p=x}else f.push(n),d+=p+y,p=x}return c=l?function(_,P){return(P?b:"")+_.join(" ")}:function(_){return _.join(" ")},h.map(c)},Qd.splitTextToSize=function(t,e,r){var n,i=(r=r||{}).fontSize||this.internal.getFontSize(),a=(function(f){if(f.widths&&f.kerning)return{widths:f.widths,kerning:f.kerning};var h=this.internal.getFont(f.fontName,f.fontStyle),d="Unicode";return h.metadata[d]?{widths:h.metadata[d].widths||{0:1},kerning:h.metadata[d].kerning||{}}:{font:h.metadata,fontSize:this.internal.getFontSize(),charSpace:this.internal.getCharSpace()}}).call(this,r);n=Array.isArray(t)?t:String(t).split(/\r?\n/);var o=1*this.internal.scaleFactor*e/i;a.textIndent=r.textIndent?1*r.textIndent*this.internal.scaleFactor/i:0,a.lineIndent=r.lineIndent;var s,l,c=[];for(s=0,l=n.length;s<l;s++)c=c.concat(H8.apply(this,[n[s],o,a]));return c},(function(t){t.__fontmetrics__=t.__fontmetrics__||{};for(var e="0123456789abcdef",r="klmnopqrstuvwxyz",n={},i={},a=0;a<16;a++)n[r[a]]=e[a],i[e[a]]=r[a];var o=function(d){return"0x"+parseInt(d,10).toString(16)},s=t.__fontmetrics__.compress=function(d){var p,y,w,x,b=["{"];for(var S in d){if(p=d[S],isNaN(parseInt(S,10))?y="'"+S+"'":(S=parseInt(S,10),y=(y=o(S).slice(2)).slice(0,-1)+i[y.slice(-1)]),typeof p=="number")p<0?(w=o(p).slice(3),x="-"):(w=o(p).slice(2),x=""),w=x+w.slice(0,-1)+i[w.slice(-1)];else{if(Hn(p)!=="object")throw new Error("Don't know what to do with value type "+Hn(p)+".");w=s(p)}b.push(y+w)}return b.push("}"),b.join("")},l=t.__fontmetrics__.uncompress=function(d){if(typeof d!="string")throw new Error("Invalid argument passed to uncompress.");for(var p,y,w,x,b={},S=1,E=b,_=[],P="",O="",T=d.length-1,N=1;N<T;N+=1)(x=d[N])=="'"?p?(w=p.join(""),p=void 0):p=[]:p?p.push(x):x=="{"?(_.push([E,w]),E={},w=void 0):x=="}"?((y=_.pop())[0][y[1]]=E,w=void 0,E=y[0]):x=="-"?S=-1:w===void 0?n.hasOwnProperty(x)?(P+=n[x],w=parseInt(P,16)*S,S=1,P=""):P+=x:n.hasOwnProperty(x)?(O+=n[x],E[w]=parseInt(O,16)*S,S=1,w=void 0,O=""):O+=x;return b},c={codePages:["WinAnsiEncoding"],WinAnsiEncoding:l("{19m8n201n9q201o9r201s9l201t9m201u8m201w9n201x9o201y8o202k8q202l8r202m9p202q8p20aw8k203k8t203t8v203u9v2cq8s212m9t15m8w15n9w2dw9s16k8u16l9u17s9z17x8y17y9y}")},f={Unicode:{Courier:c,"Courier-Bold":c,"Courier-BoldOblique":c,"Courier-Oblique":c,Helvetica:c,"Helvetica-Bold":c,"Helvetica-BoldOblique":c,"Helvetica-Oblique":c,"Times-Roman":c,"Times-Bold":c,"Times-BoldItalic":c,"Times-Italic":c}},h={Unicode:{"Courier-Oblique":l("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),"Times-BoldItalic":l("{'widths'{k3o2q4ycx2r201n3m201o6o201s2l201t2l201u2l201w3m201x3m201y3m2k1t2l2r202m2n2n3m2o3m2p5n202q6o2r1w2s2l2t2l2u3m2v3t2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w3t3x3t3y3t3z3m4k5n4l4m4m4m4n4m4o4s4p4m4q4m4r4s4s4y4t2r4u3m4v4m4w3x4x5t4y4s4z4s5k3x5l4s5m4m5n3r5o3x5p4s5q4m5r5t5s4m5t3x5u3x5v2l5w1w5x2l5y3t5z3m6k2l6l3m6m3m6n2w6o3m6p2w6q2l6r3m6s3r6t1w6u1w6v3m6w1w6x4y6y3r6z3m7k3m7l3m7m2r7n2r7o1w7p3r7q2w7r4m7s3m7t2w7u2r7v2n7w1q7x2n7y3t202l3mcl4mal2ram3man3mao3map3mar3mas2lat4uau1uav3maw3way4uaz2lbk2sbl3t'fof'6obo2lbp3tbq3mbr1tbs2lbu1ybv3mbz3mck4m202k3mcm4mcn4mco4mcp4mcq5ycr4mcs4mct4mcu4mcv4mcw2r2m3rcy2rcz2rdl4sdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek3mel3mem3men3meo3mep3meq4ser2wes2wet2weu2wev2wew1wex1wey1wez1wfl3rfm3mfn3mfo3mfp3mfq3mfr3tfs3mft3rfu3rfv3rfw3rfz2w203k6o212m6o2dw2l2cq2l3t3m3u2l17s3x19m3m}'kerning'{cl{4qu5kt5qt5rs17ss5ts}201s{201ss}201t{cks4lscmscnscoscpscls2wu2yu201ts}201x{2wu2yu}2k{201ts}2w{4qx5kx5ou5qx5rs17su5tu}2x{17su5tu5ou}2y{4qx5kx5ou5qx5rs17ss5ts}'fof'-6ofn{17sw5tw5ou5qw5rs}7t{cksclscmscnscoscps4ls}3u{17su5tu5os5qs}3v{17su5tu5os5qs}7p{17su5tu}ck{4qu5kt5qt5rs17ss5ts}4l{4qu5kt5qt5rs17ss5ts}cm{4qu5kt5qt5rs17ss5ts}cn{4qu5kt5qt5rs17ss5ts}co{4qu5kt5qt5rs17ss5ts}cp{4qu5kt5qt5rs17ss5ts}6l{4qu5ou5qw5rt17su5tu}5q{ckuclucmucnucoucpu4lu}5r{ckuclucmucnucoucpu4lu}7q{cksclscmscnscoscps4ls}6p{4qu5ou5qw5rt17sw5tw}ek{4qu5ou5qw5rt17su5tu}el{4qu5ou5qw5rt17su5tu}em{4qu5ou5qw5rt17su5tu}en{4qu5ou5qw5rt17su5tu}eo{4qu5ou5qw5rt17su5tu}ep{4qu5ou5qw5rt17su5tu}es{17ss5ts5qs4qu}et{4qu5ou5qw5rt17sw5tw}eu{4qu5ou5qw5rt17ss5ts}ev{17ss5ts5qs4qu}6z{17sw5tw5ou5qw5rs}fm{17sw5tw5ou5qw5rs}7n{201ts}fo{17sw5tw5ou5qw5rs}fp{17sw5tw5ou5qw5rs}fq{17sw5tw5ou5qw5rs}7r{cksclscmscnscoscps4ls}fs{17sw5tw5ou5qw5rs}ft{17su5tu}fu{17su5tu}fv{17su5tu}fw{17su5tu}fz{cksclscmscnscoscps4ls}}}"),"Helvetica-Bold":l("{'widths'{k3s2q4scx1w201n3r201o6o201s1w201t1w201u1w201w3m201x3m201y3m2k1w2l2l202m2n2n3r2o3r2p5t202q6o2r1s2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v2l3w3u3x3u3y3u3z3x4k6l4l4s4m4s4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3r4v4s4w3x4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v2l5w1w5x2l5y3u5z3r6k2l6l3r6m3x6n3r6o3x6p3r6q2l6r3x6s3x6t1w6u1w6v3r6w1w6x5t6y3x6z3x7k3x7l3x7m2r7n3r7o2l7p3x7q3r7r4y7s3r7t3r7u3m7v2r7w1w7x2r7y3u202l3rcl4sal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3xbq3rbr1wbs2lbu2obv3rbz3xck4s202k3rcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw1w2m2zcy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3res3ret3reu3rev3rew1wex1wey1wez1wfl3xfm3xfn3xfo3xfp3xfq3xfr3ufs3xft3xfu3xfv3xfw3xfz3r203k6o212m6o2dw2l2cq2l3t3r3u2l17s4m19m3r}'kerning'{cl{4qs5ku5ot5qs17sv5tv}201t{2ww4wy2yw}201w{2ks}201x{2ww4wy2yw}2k{201ts201xs}2w{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}2x{5ow5qs}2y{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}'fof'-6o7p{17su5tu5ot}ck{4qs5ku5ot5qs17sv5tv}4l{4qs5ku5ot5qs17sv5tv}cm{4qs5ku5ot5qs17sv5tv}cn{4qs5ku5ot5qs17sv5tv}co{4qs5ku5ot5qs17sv5tv}cp{4qs5ku5ot5qs17sv5tv}6l{17st5tt5os}17s{2kwclvcmvcnvcovcpv4lv4wwckv}5o{2kucltcmtcntcotcpt4lt4wtckt}5q{2ksclscmscnscoscps4ls4wvcks}5r{2ks4ws}5t{2kwclvcmvcnvcovcpv4lv4wwckv}eo{17st5tt5os}fu{17su5tu5ot}6p{17ss5ts}ek{17st5tt5os}el{17st5tt5os}em{17st5tt5os}en{17st5tt5os}6o{201ts}ep{17st5tt5os}es{17ss5ts}et{17ss5ts}eu{17ss5ts}ev{17ss5ts}6z{17su5tu5os5qt}fm{17su5tu5os5qt}fn{17su5tu5os5qt}fo{17su5tu5os5qt}fp{17su5tu5os5qt}fq{17su5tu5os5qt}fs{17su5tu5os5qt}ft{17su5tu5ot}7m{5os}fv{17su5tu5ot}fw{17su5tu5ot}}}"),Courier:l("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),"Courier-BoldOblique":l("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),"Times-Bold":l("{'widths'{k3q2q5ncx2r201n3m201o6o201s2l201t2l201u2l201w3m201x3m201y3m2k1t2l2l202m2n2n3m2o3m2p6o202q6o2r1w2s2l2t2l2u3m2v3t2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w3t3x3t3y3t3z3m4k5x4l4s4m4m4n4s4o4s4p4m4q3x4r4y4s4y4t2r4u3m4v4y4w4m4x5y4y4s4z4y5k3x5l4y5m4s5n3r5o4m5p4s5q4s5r6o5s4s5t4s5u4m5v2l5w1w5x2l5y3u5z3m6k2l6l3m6m3r6n2w6o3r6p2w6q2l6r3m6s3r6t1w6u2l6v3r6w1w6x5n6y3r6z3m7k3r7l3r7m2w7n2r7o2l7p3r7q3m7r4s7s3m7t3m7u2w7v2r7w1q7x2r7y3o202l3mcl4sal2lam3man3mao3map3mar3mas2lat4uau1yav3maw3tay4uaz2lbk2sbl3t'fof'6obo2lbp3rbr1tbs2lbu2lbv3mbz3mck4s202k3mcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw2r2m3rcy2rcz2rdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3rek3mel3mem3men3meo3mep3meq4ser2wes2wet2weu2wev2wew1wex1wey1wez1wfl3rfm3mfn3mfo3mfp3mfq3mfr3tfs3mft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3m3u2l17s4s19m3m}'kerning'{cl{4qt5ks5ot5qy5rw17sv5tv}201t{cks4lscmscnscoscpscls4wv}2k{201ts}2w{4qu5ku7mu5os5qx5ru17su5tu}2x{17su5tu5ou5qs}2y{4qv5kv7mu5ot5qz5ru17su5tu}'fof'-6o7t{cksclscmscnscoscps4ls}3u{17su5tu5os5qu}3v{17su5tu5os5qu}fu{17su5tu5ou5qu}7p{17su5tu5ou5qu}ck{4qt5ks5ot5qy5rw17sv5tv}4l{4qt5ks5ot5qy5rw17sv5tv}cm{4qt5ks5ot5qy5rw17sv5tv}cn{4qt5ks5ot5qy5rw17sv5tv}co{4qt5ks5ot5qy5rw17sv5tv}cp{4qt5ks5ot5qy5rw17sv5tv}6l{17st5tt5ou5qu}17s{ckuclucmucnucoucpu4lu4wu}5o{ckuclucmucnucoucpu4lu4wu}5q{ckzclzcmzcnzcozcpz4lz4wu}5r{ckxclxcmxcnxcoxcpx4lx4wu}5t{ckuclucmucnucoucpu4lu4wu}7q{ckuclucmucnucoucpu4lu}6p{17sw5tw5ou5qu}ek{17st5tt5qu}el{17st5tt5ou5qu}em{17st5tt5qu}en{17st5tt5qu}eo{17st5tt5qu}ep{17st5tt5ou5qu}es{17ss5ts5qu}et{17sw5tw5ou5qu}eu{17sw5tw5ou5qu}ev{17ss5ts5qu}6z{17sw5tw5ou5qu5rs}fm{17sw5tw5ou5qu5rs}fn{17sw5tw5ou5qu5rs}fo{17sw5tw5ou5qu5rs}fp{17sw5tw5ou5qu5rs}fq{17sw5tw5ou5qu5rs}7r{cktcltcmtcntcotcpt4lt5os}fs{17sw5tw5ou5qu5rs}ft{17su5tu5ou5qu}7m{5os}fv{17su5tu5ou5qu}fw{17su5tu5ou5qu}fz{cksclscmscnscoscps4ls}}}"),Symbol:l("{'widths'{k3uaw4r19m3m2k1t2l2l202m2y2n3m2p5n202q6o3k3m2s2l2t2l2v3r2w1t3m3m2y1t2z1wbk2sbl3r'fof'6o3n3m3o3m3p3m3q3m3r3m3s3m3t3m3u1w3v1w3w3r3x3r3y3r3z2wbp3t3l3m5v2l5x2l5z3m2q4yfr3r7v3k7w1o7x3k}'kerning'{'fof'-6o}}"),Helvetica:l("{'widths'{k3p2q4mcx1w201n3r201o6o201s1q201t1q201u1q201w2l201x2l201y2l2k1w2l1w202m2n2n3r2o3r2p5t202q6o2r1n2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v1w3w3u3x3u3y3u3z3r4k6p4l4m4m4m4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3m4v4m4w3r4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v1w5w1w5x1w5y2z5z3r6k2l6l3r6m3r6n3m6o3r6p3r6q1w6r3r6s3r6t1q6u1q6v3m6w1q6x5n6y3r6z3r7k3r7l3r7m2l7n3m7o1w7p3r7q3m7r4s7s3m7t3m7u3m7v2l7w1u7x2l7y3u202l3rcl4mal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3rbr1wbs2lbu2obv3rbz3xck4m202k3rcm4mcn4mco4mcp4mcq6ocr4scs4mct4mcu4mcv4mcw1w2m2ncy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3mes3ret3reu3rev3rew1wex1wey1wez1wfl3rfm3rfn3rfo3rfp3rfq3rfr3ufs3xft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3r3u1w17s4m19m3r}'kerning'{5q{4wv}cl{4qs5kw5ow5qs17sv5tv}201t{2wu4w1k2yu}201x{2wu4wy2yu}17s{2ktclucmucnu4otcpu4lu4wycoucku}2w{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}2x{17sy5ty5oy5qs}2y{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}'fof'-6o7p{17sv5tv5ow}ck{4qs5kw5ow5qs17sv5tv}4l{4qs5kw5ow5qs17sv5tv}cm{4qs5kw5ow5qs17sv5tv}cn{4qs5kw5ow5qs17sv5tv}co{4qs5kw5ow5qs17sv5tv}cp{4qs5kw5ow5qs17sv5tv}6l{17sy5ty5ow}do{17st5tt}4z{17st5tt}7s{fst}dm{17st5tt}dn{17st5tt}5o{ckwclwcmwcnwcowcpw4lw4wv}dp{17st5tt}dq{17st5tt}7t{5ow}ds{17st5tt}5t{2ktclucmucnu4otcpu4lu4wycoucku}fu{17sv5tv5ow}6p{17sy5ty5ow5qs}ek{17sy5ty5ow}el{17sy5ty5ow}em{17sy5ty5ow}en{5ty}eo{17sy5ty5ow}ep{17sy5ty5ow}es{17sy5ty5qs}et{17sy5ty5ow5qs}eu{17sy5ty5ow5qs}ev{17sy5ty5ow5qs}6z{17sy5ty5ow5qs}fm{17sy5ty5ow5qs}fn{17sy5ty5ow5qs}fo{17sy5ty5ow5qs}fp{17sy5ty5qs}fq{17sy5ty5ow5qs}7r{5ow}fs{17sy5ty5ow5qs}ft{17sv5tv5ow}7m{5ow}fv{17sv5tv5ow}fw{17sv5tv5ow}}}"),"Helvetica-BoldOblique":l("{'widths'{k3s2q4scx1w201n3r201o6o201s1w201t1w201u1w201w3m201x3m201y3m2k1w2l2l202m2n2n3r2o3r2p5t202q6o2r1s2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v2l3w3u3x3u3y3u3z3x4k6l4l4s4m4s4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3r4v4s4w3x4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v2l5w1w5x2l5y3u5z3r6k2l6l3r6m3x6n3r6o3x6p3r6q2l6r3x6s3x6t1w6u1w6v3r6w1w6x5t6y3x6z3x7k3x7l3x7m2r7n3r7o2l7p3x7q3r7r4y7s3r7t3r7u3m7v2r7w1w7x2r7y3u202l3rcl4sal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3xbq3rbr1wbs2lbu2obv3rbz3xck4s202k3rcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw1w2m2zcy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3res3ret3reu3rev3rew1wex1wey1wez1wfl3xfm3xfn3xfo3xfp3xfq3xfr3ufs3xft3xfu3xfv3xfw3xfz3r203k6o212m6o2dw2l2cq2l3t3r3u2l17s4m19m3r}'kerning'{cl{4qs5ku5ot5qs17sv5tv}201t{2ww4wy2yw}201w{2ks}201x{2ww4wy2yw}2k{201ts201xs}2w{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}2x{5ow5qs}2y{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}'fof'-6o7p{17su5tu5ot}ck{4qs5ku5ot5qs17sv5tv}4l{4qs5ku5ot5qs17sv5tv}cm{4qs5ku5ot5qs17sv5tv}cn{4qs5ku5ot5qs17sv5tv}co{4qs5ku5ot5qs17sv5tv}cp{4qs5ku5ot5qs17sv5tv}6l{17st5tt5os}17s{2kwclvcmvcnvcovcpv4lv4wwckv}5o{2kucltcmtcntcotcpt4lt4wtckt}5q{2ksclscmscnscoscps4ls4wvcks}5r{2ks4ws}5t{2kwclvcmvcnvcovcpv4lv4wwckv}eo{17st5tt5os}fu{17su5tu5ot}6p{17ss5ts}ek{17st5tt5os}el{17st5tt5os}em{17st5tt5os}en{17st5tt5os}6o{201ts}ep{17st5tt5os}es{17ss5ts}et{17ss5ts}eu{17ss5ts}ev{17ss5ts}6z{17su5tu5os5qt}fm{17su5tu5os5qt}fn{17su5tu5os5qt}fo{17su5tu5os5qt}fp{17su5tu5os5qt}fq{17su5tu5os5qt}fs{17su5tu5os5qt}ft{17su5tu5ot}7m{5os}fv{17su5tu5ot}fw{17su5tu5ot}}}"),ZapfDingbats:l("{'widths'{k4u2k1w'fof'6o}'kerning'{'fof'-6o}}"),"Courier-Bold":l("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),"Times-Italic":l("{'widths'{k3n2q4ycx2l201n3m201o5t201s2l201t2l201u2l201w3r201x3r201y3r2k1t2l2l202m2n2n3m2o3m2p5n202q5t2r1p2s2l2t2l2u3m2v4n2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w4n3x4n3y4n3z3m4k5w4l3x4m3x4n4m4o4s4p3x4q3x4r4s4s4s4t2l4u2w4v4m4w3r4x5n4y4m4z4s5k3x5l4s5m3x5n3m5o3r5p4s5q3x5r5n5s3x5t3r5u3r5v2r5w1w5x2r5y2u5z3m6k2l6l3m6m3m6n2w6o3m6p2w6q1w6r3m6s3m6t1w6u1w6v2w6w1w6x4s6y3m6z3m7k3m7l3m7m2r7n2r7o1w7p3m7q2w7r4m7s2w7t2w7u2r7v2s7w1v7x2s7y3q202l3mcl3xal2ram3man3mao3map3mar3mas2lat4wau1vav3maw4nay4waz2lbk2sbl4n'fof'6obo2lbp3mbq3obr1tbs2lbu1zbv3mbz3mck3x202k3mcm3xcn3xco3xcp3xcq5tcr4mcs3xct3xcu3xcv3xcw2l2m2ucy2lcz2ldl4mdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek3mel3mem3men3meo3mep3meq4mer2wes2wet2weu2wev2wew1wex1wey1wez1wfl3mfm3mfn3mfo3mfp3mfq3mfr4nfs3mft3mfu3mfv3mfw3mfz2w203k6o212m6m2dw2l2cq2l3t3m3u2l17s3r19m3m}'kerning'{cl{5kt4qw}201s{201sw}201t{201tw2wy2yy6q-t}201x{2wy2yy}2k{201tw}2w{7qs4qy7rs5ky7mw5os5qx5ru17su5tu}2x{17ss5ts5os}2y{7qs4qy7rs5ky7mw5os5qx5ru17su5tu}'fof'-6o6t{17ss5ts5qs}7t{5os}3v{5qs}7p{17su5tu5qs}ck{5kt4qw}4l{5kt4qw}cm{5kt4qw}cn{5kt4qw}co{5kt4qw}cp{5kt4qw}6l{4qs5ks5ou5qw5ru17su5tu}17s{2ks}5q{ckvclvcmvcnvcovcpv4lv}5r{ckuclucmucnucoucpu4lu}5t{2ks}6p{4qs5ks5ou5qw5ru17su5tu}ek{4qs5ks5ou5qw5ru17su5tu}el{4qs5ks5ou5qw5ru17su5tu}em{4qs5ks5ou5qw5ru17su5tu}en{4qs5ks5ou5qw5ru17su5tu}eo{4qs5ks5ou5qw5ru17su5tu}ep{4qs5ks5ou5qw5ru17su5tu}es{5ks5qs4qs}et{4qs5ks5ou5qw5ru17su5tu}eu{4qs5ks5qw5ru17su5tu}ev{5ks5qs4qs}ex{17ss5ts5qs}6z{4qv5ks5ou5qw5ru17su5tu}fm{4qv5ks5ou5qw5ru17su5tu}fn{4qv5ks5ou5qw5ru17su5tu}fo{4qv5ks5ou5qw5ru17su5tu}fp{4qv5ks5ou5qw5ru17su5tu}fq{4qv5ks5ou5qw5ru17su5tu}7r{5os}fs{4qv5ks5ou5qw5ru17su5tu}ft{17su5tu5qs}fu{17su5tu5qs}fv{17su5tu5qs}fw{17su5tu5qs}}}"),"Times-Roman":l("{'widths'{k3n2q4ycx2l201n3m201o6o201s2l201t2l201u2l201w2w201x2w201y2w2k1t2l2l202m2n2n3m2o3m2p5n202q6o2r1m2s2l2t2l2u3m2v3s2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v1w3w3s3x3s3y3s3z2w4k5w4l4s4m4m4n4m4o4s4p3x4q3r4r4s4s4s4t2l4u2r4v4s4w3x4x5t4y4s4z4s5k3r5l4s5m4m5n3r5o3x5p4s5q4s5r5y5s4s5t4s5u3x5v2l5w1w5x2l5y2z5z3m6k2l6l2w6m3m6n2w6o3m6p2w6q2l6r3m6s3m6t1w6u1w6v3m6w1w6x4y6y3m6z3m7k3m7l3m7m2l7n2r7o1w7p3m7q3m7r4s7s3m7t3m7u2w7v3k7w1o7x3k7y3q202l3mcl4sal2lam3man3mao3map3mar3mas2lat4wau1vav3maw3say4waz2lbk2sbl3s'fof'6obo2lbp3mbq2xbr1tbs2lbu1zbv3mbz2wck4s202k3mcm4scn4sco4scp4scq5tcr4mcs3xct3xcu3xcv3xcw2l2m2tcy2lcz2ldl4sdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek2wel2wem2wen2weo2wep2weq4mer2wes2wet2weu2wev2wew1wex1wey1wez1wfl3mfm3mfn3mfo3mfp3mfq3mfr3sfs3mft3mfu3mfv3mfw3mfz3m203k6o212m6m2dw2l2cq2l3t3m3u1w17s4s19m3m}'kerning'{cl{4qs5ku17sw5ou5qy5rw201ss5tw201ws}201s{201ss}201t{ckw4lwcmwcnwcowcpwclw4wu201ts}2k{201ts}2w{4qs5kw5os5qx5ru17sx5tx}2x{17sw5tw5ou5qu}2y{4qs5kw5os5qx5ru17sx5tx}'fof'-6o7t{ckuclucmucnucoucpu4lu5os5rs}3u{17su5tu5qs}3v{17su5tu5qs}7p{17sw5tw5qs}ck{4qs5ku17sw5ou5qy5rw201ss5tw201ws}4l{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cm{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cn{4qs5ku17sw5ou5qy5rw201ss5tw201ws}co{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cp{4qs5ku17sw5ou5qy5rw201ss5tw201ws}6l{17su5tu5os5qw5rs}17s{2ktclvcmvcnvcovcpv4lv4wuckv}5o{ckwclwcmwcnwcowcpw4lw4wu}5q{ckyclycmycnycoycpy4ly4wu5ms}5r{cktcltcmtcntcotcpt4lt4ws}5t{2ktclvcmvcnvcovcpv4lv4wuckv}7q{cksclscmscnscoscps4ls}6p{17su5tu5qw5rs}ek{5qs5rs}el{17su5tu5os5qw5rs}em{17su5tu5os5qs5rs}en{17su5qs5rs}eo{5qs5rs}ep{17su5tu5os5qw5rs}es{5qs}et{17su5tu5qw5rs}eu{17su5tu5qs5rs}ev{5qs}6z{17sv5tv5os5qx5rs}fm{5os5qt5rs}fn{17sv5tv5os5qx5rs}fo{17sv5tv5os5qx5rs}fp{5os5qt5rs}fq{5os5qt5rs}7r{ckuclucmucnucoucpu4lu5os}fs{17sv5tv5os5qx5rs}ft{17ss5ts5qs}fu{17sw5tw5qs}fv{17sw5tw5qs}fw{17ss5ts5qs}fz{ckuclucmucnucoucpu4lu5os5rs}}}"),"Helvetica-Oblique":l("{'widths'{k3p2q4mcx1w201n3r201o6o201s1q201t1q201u1q201w2l201x2l201y2l2k1w2l1w202m2n2n3r2o3r2p5t202q6o2r1n2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v1w3w3u3x3u3y3u3z3r4k6p4l4m4m4m4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3m4v4m4w3r4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v1w5w1w5x1w5y2z5z3r6k2l6l3r6m3r6n3m6o3r6p3r6q1w6r3r6s3r6t1q6u1q6v3m6w1q6x5n6y3r6z3r7k3r7l3r7m2l7n3m7o1w7p3r7q3m7r4s7s3m7t3m7u3m7v2l7w1u7x2l7y3u202l3rcl4mal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3rbr1wbs2lbu2obv3rbz3xck4m202k3rcm4mcn4mco4mcp4mcq6ocr4scs4mct4mcu4mcv4mcw1w2m2ncy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3mes3ret3reu3rev3rew1wex1wey1wez1wfl3rfm3rfn3rfo3rfp3rfq3rfr3ufs3xft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3r3u1w17s4m19m3r}'kerning'{5q{4wv}cl{4qs5kw5ow5qs17sv5tv}201t{2wu4w1k2yu}201x{2wu4wy2yu}17s{2ktclucmucnu4otcpu4lu4wycoucku}2w{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}2x{17sy5ty5oy5qs}2y{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}'fof'-6o7p{17sv5tv5ow}ck{4qs5kw5ow5qs17sv5tv}4l{4qs5kw5ow5qs17sv5tv}cm{4qs5kw5ow5qs17sv5tv}cn{4qs5kw5ow5qs17sv5tv}co{4qs5kw5ow5qs17sv5tv}cp{4qs5kw5ow5qs17sv5tv}6l{17sy5ty5ow}do{17st5tt}4z{17st5tt}7s{fst}dm{17st5tt}dn{17st5tt}5o{ckwclwcmwcnwcowcpw4lw4wv}dp{17st5tt}dq{17st5tt}7t{5ow}ds{17st5tt}5t{2ktclucmucnu4otcpu4lu4wycoucku}fu{17sv5tv5ow}6p{17sy5ty5ow5qs}ek{17sy5ty5ow}el{17sy5ty5ow}em{17sy5ty5ow}en{5ty}eo{17sy5ty5ow}ep{17sy5ty5ow}es{17sy5ty5qs}et{17sy5ty5ow5qs}eu{17sy5ty5ow5qs}ev{17sy5ty5ow5qs}6z{17sy5ty5ow5qs}fm{17sy5ty5ow5qs}fn{17sy5ty5ow5qs}fo{17sy5ty5ow5qs}fp{17sy5ty5qs}fq{17sy5ty5ow5qs}7r{5ow}fs{17sy5ty5ow5qs}ft{17sv5tv5ow}7m{5ow}fv{17sv5tv5ow}fw{17sv5tv5ow}}}")}};t.events.push(["addFont",function(d){var p=d.font,y=h.Unicode[p.postScriptName];y&&(p.metadata.Unicode={},p.metadata.Unicode.widths=y.widths,p.metadata.Unicode.kerning=y.kerning);var w=f.Unicode[p.postScriptName];w&&(p.metadata.Unicode.encoding=w,p.encoding=w.codePages[0])}])})(cr.API),(function(t){var e=function(r){for(var n=r.length,i=new Uint8Array(n),a=0;a<n;a++)i[a]=r.charCodeAt(a);return i};t.API.events.push(["addFont",function(r){var n=void 0,i=r.font,a=r.instance;if(!i.isStandardFont){if(a===void 0)throw new Error("Font does not exist in vFS, import fonts or remove declaration doc.addFont('"+i.postScriptName+"').");if(typeof(n=a.existsFileInVFS(i.postScriptName)===!1?a.loadFile(i.postScriptName):a.getFileFromVFS(i.postScriptName))!="string")throw new Error("Font is not stored as string-data in vFS, import fonts or remove declaration doc.addFont('"+i.postScriptName+"').");(function(o,s){s=/^\x00\x01\x00\x00/.test(s)?e(s):e(zg(s)),o.metadata=t.API.TTFFont.open(s),o.metadata.Unicode=o.metadata.Unicode||{encoding:{},kerning:{},widths:[]},o.metadata.glyIdsUsed=[0]})(i,n)}}])})(cr),cr.API.addSvgAsImage=function(t,e,r,n,i,a,o,s){if(isNaN(e)||isNaN(r))throw ai.error("jsPDF.addSvgAsImage: Invalid coordinates",arguments),new Error("Invalid coordinates passed to jsPDF.addSvgAsImage");if(isNaN(n)||isNaN(i))throw ai.error("jsPDF.addSvgAsImage: Invalid measurements",arguments),new Error("Invalid measurements (width and/or height) passed to jsPDF.addSvgAsImage");var l=document.createElement("canvas");l.width=n,l.height=i;var c=l.getContext("2d");c.fillStyle="#fff",c.fillRect(0,0,l.width,l.height);var f={ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0},h=this;return(Tr.canvg?Promise.resolve(Tr.canvg):Cg(()=>import("./index.es-Drk8SfOv.js"),[],import.meta.url)).catch(function(d){return Promise.reject(new Error("Could not load canvg: "+d))}).then(function(d){return d.default?d.default:d}).then(function(d){return d.fromString(c,t,f)},function(){return Promise.reject(new Error("Could not load canvg."))}).then(function(d){return d.render(f)}).then(function(){h.addImage(l.toDataURL("image/jpeg",1),e,r,n,i,o,s)})},cr.API.putTotalPages=function(t){var e,r=0;parseInt(this.internal.getFont().id.substr(1),10)<15?(e=new RegExp(t,"g"),r=this.internal.getNumberOfPages()):(e=new RegExp(this.pdfEscape16(t,this.internal.getFont()),"g"),r=this.pdfEscape16(this.internal.getNumberOfPages()+"",this.internal.getFont()));for(var n=1;n<=this.internal.getNumberOfPages();n++)for(var i=0;i<this.internal.pages[n].length;i++)this.internal.pages[n][i]=this.internal.pages[n][i].replace(e,r);return this},cr.API.viewerPreferences=function(t,e){var r;t=t||{},e=e||!1;var n,i,a,o={HideToolbar:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},HideMenubar:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},HideWindowUI:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},FitWindow:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},CenterWindow:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},DisplayDocTitle:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.4},NonFullScreenPageMode:{defaultValue:"UseNone",value:"UseNone",type:"name",explicitSet:!1,valueSet:["UseNone","UseOutlines","UseThumbs","UseOC"],pdfVersion:1.3},Direction:{defaultValue:"L2R",value:"L2R",type:"name",explicitSet:!1,valueSet:["L2R","R2L"],pdfVersion:1.3},ViewArea:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},ViewClip:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintArea:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintClip:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintScaling:{defaultValue:"AppDefault",value:"AppDefault",type:"name",explicitSet:!1,valueSet:["AppDefault","None"],pdfVersion:1.6},Duplex:{defaultValue:"",value:"none",type:"name",explicitSet:!1,valueSet:["Simplex","DuplexFlipShortEdge","DuplexFlipLongEdge","none"],pdfVersion:1.7},PickTrayByPDFSize:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.7},PrintPageRange:{defaultValue:"",value:"",type:"array",explicitSet:!1,valueSet:null,pdfVersion:1.7},NumCopies:{defaultValue:1,value:1,type:"integer",explicitSet:!1,valueSet:null,pdfVersion:1.7}},s=Object.keys(o),l=[],c=0,f=0,h=0;function d(y,w){var x,b=!1;for(x=0;x<y.length;x+=1)y[x]===w&&(b=!0);return b}if(this.internal.viewerpreferences===void 0&&(this.internal.viewerpreferences={},this.internal.viewerpreferences.configuration=JSON.parse(JSON.stringify(o)),this.internal.viewerpreferences.isSubscribed=!1),r=this.internal.viewerpreferences.configuration,t==="reset"||e===!0){var p=s.length;for(h=0;h<p;h+=1)r[s[h]].value=r[s[h]].defaultValue,r[s[h]].explicitSet=!1}if(Hn(t)==="object"){for(i in t)if(a=t[i],d(s,i)&&a!==void 0){if(r[i].type==="boolean"&&typeof a=="boolean")r[i].value=a;else if(r[i].type==="name"&&d(r[i].valueSet,a))r[i].value=a;else if(r[i].type==="integer"&&Number.isInteger(a))r[i].value=a;else if(r[i].type==="array"){for(c=0;c<a.length;c+=1)if(n=!0,a[c].length===1&&typeof a[c][0]=="number")l.push(String(a[c]-1));else if(a[c].length>1){for(f=0;f<a[c].length;f+=1)typeof a[c][f]!="number"&&(n=!1);n===!0&&l.push([a[c][0]-1,a[c][1]-1].join(" "))}r[i].value="["+l.join(" ")+"]"}else r[i].value=r[i].defaultValue;r[i].explicitSet=!0}}return this.internal.viewerpreferences.isSubscribed===!1&&(this.internal.events.subscribe("putCatalog",function(){var y,w=[];for(y in r)r[y].explicitSet===!0&&(r[y].type==="name"?w.push("/"+y+" /"+r[y].value):w.push("/"+y+" "+r[y].value));w.length!==0&&this.internal.write(`/ViewerPreferences
|
|
514
|
+
`&&(n=n.substr(1),E=1),d+p+(y=(i=Pg.apply(this,[n,r])).reduce(function(_,P){return _+P},0))>e||E){if(y>e){for(s=q8.apply(this,[n,i,e-(d+p),e]),f.push(s.shift()),f=[s.pop()];s.length;)h.push([s.shift()]);y=i.slice(n.length-(f[0]?f[0].length:0)).reduce(function(_,P){return _+P},0)}else f=[n];h.push(f),d=y+l,p=x}else f.push(n),d+=p+y,p=x}return c=l?function(_,P){return(P?b:"")+_.join(" ")}:function(_){return _.join(" ")},h.map(c)},Qd.splitTextToSize=function(t,e,r){var n,i=(r=r||{}).fontSize||this.internal.getFontSize(),a=(function(f){if(f.widths&&f.kerning)return{widths:f.widths,kerning:f.kerning};var h=this.internal.getFont(f.fontName,f.fontStyle),d="Unicode";return h.metadata[d]?{widths:h.metadata[d].widths||{0:1},kerning:h.metadata[d].kerning||{}}:{font:h.metadata,fontSize:this.internal.getFontSize(),charSpace:this.internal.getCharSpace()}}).call(this,r);n=Array.isArray(t)?t:String(t).split(/\r?\n/);var o=1*this.internal.scaleFactor*e/i;a.textIndent=r.textIndent?1*r.textIndent*this.internal.scaleFactor/i:0,a.lineIndent=r.lineIndent;var s,l,c=[];for(s=0,l=n.length;s<l;s++)c=c.concat(H8.apply(this,[n[s],o,a]));return c},(function(t){t.__fontmetrics__=t.__fontmetrics__||{};for(var e="0123456789abcdef",r="klmnopqrstuvwxyz",n={},i={},a=0;a<16;a++)n[r[a]]=e[a],i[e[a]]=r[a];var o=function(d){return"0x"+parseInt(d,10).toString(16)},s=t.__fontmetrics__.compress=function(d){var p,y,w,x,b=["{"];for(var S in d){if(p=d[S],isNaN(parseInt(S,10))?y="'"+S+"'":(S=parseInt(S,10),y=(y=o(S).slice(2)).slice(0,-1)+i[y.slice(-1)]),typeof p=="number")p<0?(w=o(p).slice(3),x="-"):(w=o(p).slice(2),x=""),w=x+w.slice(0,-1)+i[w.slice(-1)];else{if(Hn(p)!=="object")throw new Error("Don't know what to do with value type "+Hn(p)+".");w=s(p)}b.push(y+w)}return b.push("}"),b.join("")},l=t.__fontmetrics__.uncompress=function(d){if(typeof d!="string")throw new Error("Invalid argument passed to uncompress.");for(var p,y,w,x,b={},S=1,E=b,_=[],P="",O="",T=d.length-1,N=1;N<T;N+=1)(x=d[N])=="'"?p?(w=p.join(""),p=void 0):p=[]:p?p.push(x):x=="{"?(_.push([E,w]),E={},w=void 0):x=="}"?((y=_.pop())[0][y[1]]=E,w=void 0,E=y[0]):x=="-"?S=-1:w===void 0?n.hasOwnProperty(x)?(P+=n[x],w=parseInt(P,16)*S,S=1,P=""):P+=x:n.hasOwnProperty(x)?(O+=n[x],E[w]=parseInt(O,16)*S,S=1,w=void 0,O=""):O+=x;return b},c={codePages:["WinAnsiEncoding"],WinAnsiEncoding:l("{19m8n201n9q201o9r201s9l201t9m201u8m201w9n201x9o201y8o202k8q202l8r202m9p202q8p20aw8k203k8t203t8v203u9v2cq8s212m9t15m8w15n9w2dw9s16k8u16l9u17s9z17x8y17y9y}")},f={Unicode:{Courier:c,"Courier-Bold":c,"Courier-BoldOblique":c,"Courier-Oblique":c,Helvetica:c,"Helvetica-Bold":c,"Helvetica-BoldOblique":c,"Helvetica-Oblique":c,"Times-Roman":c,"Times-Bold":c,"Times-BoldItalic":c,"Times-Italic":c}},h={Unicode:{"Courier-Oblique":l("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),"Times-BoldItalic":l("{'widths'{k3o2q4ycx2r201n3m201o6o201s2l201t2l201u2l201w3m201x3m201y3m2k1t2l2r202m2n2n3m2o3m2p5n202q6o2r1w2s2l2t2l2u3m2v3t2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w3t3x3t3y3t3z3m4k5n4l4m4m4m4n4m4o4s4p4m4q4m4r4s4s4y4t2r4u3m4v4m4w3x4x5t4y4s4z4s5k3x5l4s5m4m5n3r5o3x5p4s5q4m5r5t5s4m5t3x5u3x5v2l5w1w5x2l5y3t5z3m6k2l6l3m6m3m6n2w6o3m6p2w6q2l6r3m6s3r6t1w6u1w6v3m6w1w6x4y6y3r6z3m7k3m7l3m7m2r7n2r7o1w7p3r7q2w7r4m7s3m7t2w7u2r7v2n7w1q7x2n7y3t202l3mcl4mal2ram3man3mao3map3mar3mas2lat4uau1uav3maw3way4uaz2lbk2sbl3t'fof'6obo2lbp3tbq3mbr1tbs2lbu1ybv3mbz3mck4m202k3mcm4mcn4mco4mcp4mcq5ycr4mcs4mct4mcu4mcv4mcw2r2m3rcy2rcz2rdl4sdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek3mel3mem3men3meo3mep3meq4ser2wes2wet2weu2wev2wew1wex1wey1wez1wfl3rfm3mfn3mfo3mfp3mfq3mfr3tfs3mft3rfu3rfv3rfw3rfz2w203k6o212m6o2dw2l2cq2l3t3m3u2l17s3x19m3m}'kerning'{cl{4qu5kt5qt5rs17ss5ts}201s{201ss}201t{cks4lscmscnscoscpscls2wu2yu201ts}201x{2wu2yu}2k{201ts}2w{4qx5kx5ou5qx5rs17su5tu}2x{17su5tu5ou}2y{4qx5kx5ou5qx5rs17ss5ts}'fof'-6ofn{17sw5tw5ou5qw5rs}7t{cksclscmscnscoscps4ls}3u{17su5tu5os5qs}3v{17su5tu5os5qs}7p{17su5tu}ck{4qu5kt5qt5rs17ss5ts}4l{4qu5kt5qt5rs17ss5ts}cm{4qu5kt5qt5rs17ss5ts}cn{4qu5kt5qt5rs17ss5ts}co{4qu5kt5qt5rs17ss5ts}cp{4qu5kt5qt5rs17ss5ts}6l{4qu5ou5qw5rt17su5tu}5q{ckuclucmucnucoucpu4lu}5r{ckuclucmucnucoucpu4lu}7q{cksclscmscnscoscps4ls}6p{4qu5ou5qw5rt17sw5tw}ek{4qu5ou5qw5rt17su5tu}el{4qu5ou5qw5rt17su5tu}em{4qu5ou5qw5rt17su5tu}en{4qu5ou5qw5rt17su5tu}eo{4qu5ou5qw5rt17su5tu}ep{4qu5ou5qw5rt17su5tu}es{17ss5ts5qs4qu}et{4qu5ou5qw5rt17sw5tw}eu{4qu5ou5qw5rt17ss5ts}ev{17ss5ts5qs4qu}6z{17sw5tw5ou5qw5rs}fm{17sw5tw5ou5qw5rs}7n{201ts}fo{17sw5tw5ou5qw5rs}fp{17sw5tw5ou5qw5rs}fq{17sw5tw5ou5qw5rs}7r{cksclscmscnscoscps4ls}fs{17sw5tw5ou5qw5rs}ft{17su5tu}fu{17su5tu}fv{17su5tu}fw{17su5tu}fz{cksclscmscnscoscps4ls}}}"),"Helvetica-Bold":l("{'widths'{k3s2q4scx1w201n3r201o6o201s1w201t1w201u1w201w3m201x3m201y3m2k1w2l2l202m2n2n3r2o3r2p5t202q6o2r1s2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v2l3w3u3x3u3y3u3z3x4k6l4l4s4m4s4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3r4v4s4w3x4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v2l5w1w5x2l5y3u5z3r6k2l6l3r6m3x6n3r6o3x6p3r6q2l6r3x6s3x6t1w6u1w6v3r6w1w6x5t6y3x6z3x7k3x7l3x7m2r7n3r7o2l7p3x7q3r7r4y7s3r7t3r7u3m7v2r7w1w7x2r7y3u202l3rcl4sal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3xbq3rbr1wbs2lbu2obv3rbz3xck4s202k3rcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw1w2m2zcy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3res3ret3reu3rev3rew1wex1wey1wez1wfl3xfm3xfn3xfo3xfp3xfq3xfr3ufs3xft3xfu3xfv3xfw3xfz3r203k6o212m6o2dw2l2cq2l3t3r3u2l17s4m19m3r}'kerning'{cl{4qs5ku5ot5qs17sv5tv}201t{2ww4wy2yw}201w{2ks}201x{2ww4wy2yw}2k{201ts201xs}2w{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}2x{5ow5qs}2y{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}'fof'-6o7p{17su5tu5ot}ck{4qs5ku5ot5qs17sv5tv}4l{4qs5ku5ot5qs17sv5tv}cm{4qs5ku5ot5qs17sv5tv}cn{4qs5ku5ot5qs17sv5tv}co{4qs5ku5ot5qs17sv5tv}cp{4qs5ku5ot5qs17sv5tv}6l{17st5tt5os}17s{2kwclvcmvcnvcovcpv4lv4wwckv}5o{2kucltcmtcntcotcpt4lt4wtckt}5q{2ksclscmscnscoscps4ls4wvcks}5r{2ks4ws}5t{2kwclvcmvcnvcovcpv4lv4wwckv}eo{17st5tt5os}fu{17su5tu5ot}6p{17ss5ts}ek{17st5tt5os}el{17st5tt5os}em{17st5tt5os}en{17st5tt5os}6o{201ts}ep{17st5tt5os}es{17ss5ts}et{17ss5ts}eu{17ss5ts}ev{17ss5ts}6z{17su5tu5os5qt}fm{17su5tu5os5qt}fn{17su5tu5os5qt}fo{17su5tu5os5qt}fp{17su5tu5os5qt}fq{17su5tu5os5qt}fs{17su5tu5os5qt}ft{17su5tu5ot}7m{5os}fv{17su5tu5ot}fw{17su5tu5ot}}}"),Courier:l("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),"Courier-BoldOblique":l("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),"Times-Bold":l("{'widths'{k3q2q5ncx2r201n3m201o6o201s2l201t2l201u2l201w3m201x3m201y3m2k1t2l2l202m2n2n3m2o3m2p6o202q6o2r1w2s2l2t2l2u3m2v3t2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w3t3x3t3y3t3z3m4k5x4l4s4m4m4n4s4o4s4p4m4q3x4r4y4s4y4t2r4u3m4v4y4w4m4x5y4y4s4z4y5k3x5l4y5m4s5n3r5o4m5p4s5q4s5r6o5s4s5t4s5u4m5v2l5w1w5x2l5y3u5z3m6k2l6l3m6m3r6n2w6o3r6p2w6q2l6r3m6s3r6t1w6u2l6v3r6w1w6x5n6y3r6z3m7k3r7l3r7m2w7n2r7o2l7p3r7q3m7r4s7s3m7t3m7u2w7v2r7w1q7x2r7y3o202l3mcl4sal2lam3man3mao3map3mar3mas2lat4uau1yav3maw3tay4uaz2lbk2sbl3t'fof'6obo2lbp3rbr1tbs2lbu2lbv3mbz3mck4s202k3mcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw2r2m3rcy2rcz2rdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3rek3mel3mem3men3meo3mep3meq4ser2wes2wet2weu2wev2wew1wex1wey1wez1wfl3rfm3mfn3mfo3mfp3mfq3mfr3tfs3mft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3m3u2l17s4s19m3m}'kerning'{cl{4qt5ks5ot5qy5rw17sv5tv}201t{cks4lscmscnscoscpscls4wv}2k{201ts}2w{4qu5ku7mu5os5qx5ru17su5tu}2x{17su5tu5ou5qs}2y{4qv5kv7mu5ot5qz5ru17su5tu}'fof'-6o7t{cksclscmscnscoscps4ls}3u{17su5tu5os5qu}3v{17su5tu5os5qu}fu{17su5tu5ou5qu}7p{17su5tu5ou5qu}ck{4qt5ks5ot5qy5rw17sv5tv}4l{4qt5ks5ot5qy5rw17sv5tv}cm{4qt5ks5ot5qy5rw17sv5tv}cn{4qt5ks5ot5qy5rw17sv5tv}co{4qt5ks5ot5qy5rw17sv5tv}cp{4qt5ks5ot5qy5rw17sv5tv}6l{17st5tt5ou5qu}17s{ckuclucmucnucoucpu4lu4wu}5o{ckuclucmucnucoucpu4lu4wu}5q{ckzclzcmzcnzcozcpz4lz4wu}5r{ckxclxcmxcnxcoxcpx4lx4wu}5t{ckuclucmucnucoucpu4lu4wu}7q{ckuclucmucnucoucpu4lu}6p{17sw5tw5ou5qu}ek{17st5tt5qu}el{17st5tt5ou5qu}em{17st5tt5qu}en{17st5tt5qu}eo{17st5tt5qu}ep{17st5tt5ou5qu}es{17ss5ts5qu}et{17sw5tw5ou5qu}eu{17sw5tw5ou5qu}ev{17ss5ts5qu}6z{17sw5tw5ou5qu5rs}fm{17sw5tw5ou5qu5rs}fn{17sw5tw5ou5qu5rs}fo{17sw5tw5ou5qu5rs}fp{17sw5tw5ou5qu5rs}fq{17sw5tw5ou5qu5rs}7r{cktcltcmtcntcotcpt4lt5os}fs{17sw5tw5ou5qu5rs}ft{17su5tu5ou5qu}7m{5os}fv{17su5tu5ou5qu}fw{17su5tu5ou5qu}fz{cksclscmscnscoscps4ls}}}"),Symbol:l("{'widths'{k3uaw4r19m3m2k1t2l2l202m2y2n3m2p5n202q6o3k3m2s2l2t2l2v3r2w1t3m3m2y1t2z1wbk2sbl3r'fof'6o3n3m3o3m3p3m3q3m3r3m3s3m3t3m3u1w3v1w3w3r3x3r3y3r3z2wbp3t3l3m5v2l5x2l5z3m2q4yfr3r7v3k7w1o7x3k}'kerning'{'fof'-6o}}"),Helvetica:l("{'widths'{k3p2q4mcx1w201n3r201o6o201s1q201t1q201u1q201w2l201x2l201y2l2k1w2l1w202m2n2n3r2o3r2p5t202q6o2r1n2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v1w3w3u3x3u3y3u3z3r4k6p4l4m4m4m4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3m4v4m4w3r4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v1w5w1w5x1w5y2z5z3r6k2l6l3r6m3r6n3m6o3r6p3r6q1w6r3r6s3r6t1q6u1q6v3m6w1q6x5n6y3r6z3r7k3r7l3r7m2l7n3m7o1w7p3r7q3m7r4s7s3m7t3m7u3m7v2l7w1u7x2l7y3u202l3rcl4mal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3rbr1wbs2lbu2obv3rbz3xck4m202k3rcm4mcn4mco4mcp4mcq6ocr4scs4mct4mcu4mcv4mcw1w2m2ncy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3mes3ret3reu3rev3rew1wex1wey1wez1wfl3rfm3rfn3rfo3rfp3rfq3rfr3ufs3xft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3r3u1w17s4m19m3r}'kerning'{5q{4wv}cl{4qs5kw5ow5qs17sv5tv}201t{2wu4w1k2yu}201x{2wu4wy2yu}17s{2ktclucmucnu4otcpu4lu4wycoucku}2w{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}2x{17sy5ty5oy5qs}2y{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}'fof'-6o7p{17sv5tv5ow}ck{4qs5kw5ow5qs17sv5tv}4l{4qs5kw5ow5qs17sv5tv}cm{4qs5kw5ow5qs17sv5tv}cn{4qs5kw5ow5qs17sv5tv}co{4qs5kw5ow5qs17sv5tv}cp{4qs5kw5ow5qs17sv5tv}6l{17sy5ty5ow}do{17st5tt}4z{17st5tt}7s{fst}dm{17st5tt}dn{17st5tt}5o{ckwclwcmwcnwcowcpw4lw4wv}dp{17st5tt}dq{17st5tt}7t{5ow}ds{17st5tt}5t{2ktclucmucnu4otcpu4lu4wycoucku}fu{17sv5tv5ow}6p{17sy5ty5ow5qs}ek{17sy5ty5ow}el{17sy5ty5ow}em{17sy5ty5ow}en{5ty}eo{17sy5ty5ow}ep{17sy5ty5ow}es{17sy5ty5qs}et{17sy5ty5ow5qs}eu{17sy5ty5ow5qs}ev{17sy5ty5ow5qs}6z{17sy5ty5ow5qs}fm{17sy5ty5ow5qs}fn{17sy5ty5ow5qs}fo{17sy5ty5ow5qs}fp{17sy5ty5qs}fq{17sy5ty5ow5qs}7r{5ow}fs{17sy5ty5ow5qs}ft{17sv5tv5ow}7m{5ow}fv{17sv5tv5ow}fw{17sv5tv5ow}}}"),"Helvetica-BoldOblique":l("{'widths'{k3s2q4scx1w201n3r201o6o201s1w201t1w201u1w201w3m201x3m201y3m2k1w2l2l202m2n2n3r2o3r2p5t202q6o2r1s2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v2l3w3u3x3u3y3u3z3x4k6l4l4s4m4s4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3r4v4s4w3x4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v2l5w1w5x2l5y3u5z3r6k2l6l3r6m3x6n3r6o3x6p3r6q2l6r3x6s3x6t1w6u1w6v3r6w1w6x5t6y3x6z3x7k3x7l3x7m2r7n3r7o2l7p3x7q3r7r4y7s3r7t3r7u3m7v2r7w1w7x2r7y3u202l3rcl4sal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3xbq3rbr1wbs2lbu2obv3rbz3xck4s202k3rcm4scn4sco4scp4scq6ocr4scs4mct4mcu4mcv4mcw1w2m2zcy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3res3ret3reu3rev3rew1wex1wey1wez1wfl3xfm3xfn3xfo3xfp3xfq3xfr3ufs3xft3xfu3xfv3xfw3xfz3r203k6o212m6o2dw2l2cq2l3t3r3u2l17s4m19m3r}'kerning'{cl{4qs5ku5ot5qs17sv5tv}201t{2ww4wy2yw}201w{2ks}201x{2ww4wy2yw}2k{201ts201xs}2w{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}2x{5ow5qs}2y{7qs4qu5kw5os5qw5rs17su5tu7tsfzs}'fof'-6o7p{17su5tu5ot}ck{4qs5ku5ot5qs17sv5tv}4l{4qs5ku5ot5qs17sv5tv}cm{4qs5ku5ot5qs17sv5tv}cn{4qs5ku5ot5qs17sv5tv}co{4qs5ku5ot5qs17sv5tv}cp{4qs5ku5ot5qs17sv5tv}6l{17st5tt5os}17s{2kwclvcmvcnvcovcpv4lv4wwckv}5o{2kucltcmtcntcotcpt4lt4wtckt}5q{2ksclscmscnscoscps4ls4wvcks}5r{2ks4ws}5t{2kwclvcmvcnvcovcpv4lv4wwckv}eo{17st5tt5os}fu{17su5tu5ot}6p{17ss5ts}ek{17st5tt5os}el{17st5tt5os}em{17st5tt5os}en{17st5tt5os}6o{201ts}ep{17st5tt5os}es{17ss5ts}et{17ss5ts}eu{17ss5ts}ev{17ss5ts}6z{17su5tu5os5qt}fm{17su5tu5os5qt}fn{17su5tu5os5qt}fo{17su5tu5os5qt}fp{17su5tu5os5qt}fq{17su5tu5os5qt}fs{17su5tu5os5qt}ft{17su5tu5ot}7m{5os}fv{17su5tu5ot}fw{17su5tu5ot}}}"),ZapfDingbats:l("{'widths'{k4u2k1w'fof'6o}'kerning'{'fof'-6o}}"),"Courier-Bold":l("{'widths'{k3w'fof'6o}'kerning'{'fof'-6o}}"),"Times-Italic":l("{'widths'{k3n2q4ycx2l201n3m201o5t201s2l201t2l201u2l201w3r201x3r201y3r2k1t2l2l202m2n2n3m2o3m2p5n202q5t2r1p2s2l2t2l2u3m2v4n2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v2l3w4n3x4n3y4n3z3m4k5w4l3x4m3x4n4m4o4s4p3x4q3x4r4s4s4s4t2l4u2w4v4m4w3r4x5n4y4m4z4s5k3x5l4s5m3x5n3m5o3r5p4s5q3x5r5n5s3x5t3r5u3r5v2r5w1w5x2r5y2u5z3m6k2l6l3m6m3m6n2w6o3m6p2w6q1w6r3m6s3m6t1w6u1w6v2w6w1w6x4s6y3m6z3m7k3m7l3m7m2r7n2r7o1w7p3m7q2w7r4m7s2w7t2w7u2r7v2s7w1v7x2s7y3q202l3mcl3xal2ram3man3mao3map3mar3mas2lat4wau1vav3maw4nay4waz2lbk2sbl4n'fof'6obo2lbp3mbq3obr1tbs2lbu1zbv3mbz3mck3x202k3mcm3xcn3xco3xcp3xcq5tcr4mcs3xct3xcu3xcv3xcw2l2m2ucy2lcz2ldl4mdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek3mel3mem3men3meo3mep3meq4mer2wes2wet2weu2wev2wew1wex1wey1wez1wfl3mfm3mfn3mfo3mfp3mfq3mfr4nfs3mft3mfu3mfv3mfw3mfz2w203k6o212m6m2dw2l2cq2l3t3m3u2l17s3r19m3m}'kerning'{cl{5kt4qw}201s{201sw}201t{201tw2wy2yy6q-t}201x{2wy2yy}2k{201tw}2w{7qs4qy7rs5ky7mw5os5qx5ru17su5tu}2x{17ss5ts5os}2y{7qs4qy7rs5ky7mw5os5qx5ru17su5tu}'fof'-6o6t{17ss5ts5qs}7t{5os}3v{5qs}7p{17su5tu5qs}ck{5kt4qw}4l{5kt4qw}cm{5kt4qw}cn{5kt4qw}co{5kt4qw}cp{5kt4qw}6l{4qs5ks5ou5qw5ru17su5tu}17s{2ks}5q{ckvclvcmvcnvcovcpv4lv}5r{ckuclucmucnucoucpu4lu}5t{2ks}6p{4qs5ks5ou5qw5ru17su5tu}ek{4qs5ks5ou5qw5ru17su5tu}el{4qs5ks5ou5qw5ru17su5tu}em{4qs5ks5ou5qw5ru17su5tu}en{4qs5ks5ou5qw5ru17su5tu}eo{4qs5ks5ou5qw5ru17su5tu}ep{4qs5ks5ou5qw5ru17su5tu}es{5ks5qs4qs}et{4qs5ks5ou5qw5ru17su5tu}eu{4qs5ks5qw5ru17su5tu}ev{5ks5qs4qs}ex{17ss5ts5qs}6z{4qv5ks5ou5qw5ru17su5tu}fm{4qv5ks5ou5qw5ru17su5tu}fn{4qv5ks5ou5qw5ru17su5tu}fo{4qv5ks5ou5qw5ru17su5tu}fp{4qv5ks5ou5qw5ru17su5tu}fq{4qv5ks5ou5qw5ru17su5tu}7r{5os}fs{4qv5ks5ou5qw5ru17su5tu}ft{17su5tu5qs}fu{17su5tu5qs}fv{17su5tu5qs}fw{17su5tu5qs}}}"),"Times-Roman":l("{'widths'{k3n2q4ycx2l201n3m201o6o201s2l201t2l201u2l201w2w201x2w201y2w2k1t2l2l202m2n2n3m2o3m2p5n202q6o2r1m2s2l2t2l2u3m2v3s2w1t2x2l2y1t2z1w3k3m3l3m3m3m3n3m3o3m3p3m3q3m3r3m3s3m203t2l203u2l3v1w3w3s3x3s3y3s3z2w4k5w4l4s4m4m4n4m4o4s4p3x4q3r4r4s4s4s4t2l4u2r4v4s4w3x4x5t4y4s4z4s5k3r5l4s5m4m5n3r5o3x5p4s5q4s5r5y5s4s5t4s5u3x5v2l5w1w5x2l5y2z5z3m6k2l6l2w6m3m6n2w6o3m6p2w6q2l6r3m6s3m6t1w6u1w6v3m6w1w6x4y6y3m6z3m7k3m7l3m7m2l7n2r7o1w7p3m7q3m7r4s7s3m7t3m7u2w7v3k7w1o7x3k7y3q202l3mcl4sal2lam3man3mao3map3mar3mas2lat4wau1vav3maw3say4waz2lbk2sbl3s'fof'6obo2lbp3mbq2xbr1tbs2lbu1zbv3mbz2wck4s202k3mcm4scn4sco4scp4scq5tcr4mcs3xct3xcu3xcv3xcw2l2m2tcy2lcz2ldl4sdm4sdn4sdo4sdp4sdq4sds4sdt4sdu4sdv4sdw4sdz3mek2wel2wem2wen2weo2wep2weq4mer2wes2wet2weu2wev2wew1wex1wey1wez1wfl3mfm3mfn3mfo3mfp3mfq3mfr3sfs3mft3mfu3mfv3mfw3mfz3m203k6o212m6m2dw2l2cq2l3t3m3u1w17s4s19m3m}'kerning'{cl{4qs5ku17sw5ou5qy5rw201ss5tw201ws}201s{201ss}201t{ckw4lwcmwcnwcowcpwclw4wu201ts}2k{201ts}2w{4qs5kw5os5qx5ru17sx5tx}2x{17sw5tw5ou5qu}2y{4qs5kw5os5qx5ru17sx5tx}'fof'-6o7t{ckuclucmucnucoucpu4lu5os5rs}3u{17su5tu5qs}3v{17su5tu5qs}7p{17sw5tw5qs}ck{4qs5ku17sw5ou5qy5rw201ss5tw201ws}4l{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cm{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cn{4qs5ku17sw5ou5qy5rw201ss5tw201ws}co{4qs5ku17sw5ou5qy5rw201ss5tw201ws}cp{4qs5ku17sw5ou5qy5rw201ss5tw201ws}6l{17su5tu5os5qw5rs}17s{2ktclvcmvcnvcovcpv4lv4wuckv}5o{ckwclwcmwcnwcowcpw4lw4wu}5q{ckyclycmycnycoycpy4ly4wu5ms}5r{cktcltcmtcntcotcpt4lt4ws}5t{2ktclvcmvcnvcovcpv4lv4wuckv}7q{cksclscmscnscoscps4ls}6p{17su5tu5qw5rs}ek{5qs5rs}el{17su5tu5os5qw5rs}em{17su5tu5os5qs5rs}en{17su5qs5rs}eo{5qs5rs}ep{17su5tu5os5qw5rs}es{5qs}et{17su5tu5qw5rs}eu{17su5tu5qs5rs}ev{5qs}6z{17sv5tv5os5qx5rs}fm{5os5qt5rs}fn{17sv5tv5os5qx5rs}fo{17sv5tv5os5qx5rs}fp{5os5qt5rs}fq{5os5qt5rs}7r{ckuclucmucnucoucpu4lu5os}fs{17sv5tv5os5qx5rs}ft{17ss5ts5qs}fu{17sw5tw5qs}fv{17sw5tw5qs}fw{17ss5ts5qs}fz{ckuclucmucnucoucpu4lu5os5rs}}}"),"Helvetica-Oblique":l("{'widths'{k3p2q4mcx1w201n3r201o6o201s1q201t1q201u1q201w2l201x2l201y2l2k1w2l1w202m2n2n3r2o3r2p5t202q6o2r1n2s2l2t2l2u2r2v3u2w1w2x2l2y1w2z1w3k3r3l3r3m3r3n3r3o3r3p3r3q3r3r3r3s3r203t2l203u2l3v1w3w3u3x3u3y3u3z3r4k6p4l4m4m4m4n4s4o4s4p4m4q3x4r4y4s4s4t1w4u3m4v4m4w3r4x5n4y4s4z4y5k4m5l4y5m4s5n4m5o3x5p4s5q4m5r5y5s4m5t4m5u3x5v1w5w1w5x1w5y2z5z3r6k2l6l3r6m3r6n3m6o3r6p3r6q1w6r3r6s3r6t1q6u1q6v3m6w1q6x5n6y3r6z3r7k3r7l3r7m2l7n3m7o1w7p3r7q3m7r4s7s3m7t3m7u3m7v2l7w1u7x2l7y3u202l3rcl4mal2lam3ran3rao3rap3rar3ras2lat4tau2pav3raw3uay4taz2lbk2sbl3u'fof'6obo2lbp3rbr1wbs2lbu2obv3rbz3xck4m202k3rcm4mcn4mco4mcp4mcq6ocr4scs4mct4mcu4mcv4mcw1w2m2ncy1wcz1wdl4sdm4ydn4ydo4ydp4ydq4yds4ydt4sdu4sdv4sdw4sdz3xek3rel3rem3ren3reo3rep3req5ter3mes3ret3reu3rev3rew1wex1wey1wez1wfl3rfm3rfn3rfo3rfp3rfq3rfr3ufs3xft3rfu3rfv3rfw3rfz3m203k6o212m6o2dw2l2cq2l3t3r3u1w17s4m19m3r}'kerning'{5q{4wv}cl{4qs5kw5ow5qs17sv5tv}201t{2wu4w1k2yu}201x{2wu4wy2yu}17s{2ktclucmucnu4otcpu4lu4wycoucku}2w{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}2x{17sy5ty5oy5qs}2y{7qs4qz5k1m17sy5ow5qx5rsfsu5ty7tufzu}'fof'-6o7p{17sv5tv5ow}ck{4qs5kw5ow5qs17sv5tv}4l{4qs5kw5ow5qs17sv5tv}cm{4qs5kw5ow5qs17sv5tv}cn{4qs5kw5ow5qs17sv5tv}co{4qs5kw5ow5qs17sv5tv}cp{4qs5kw5ow5qs17sv5tv}6l{17sy5ty5ow}do{17st5tt}4z{17st5tt}7s{fst}dm{17st5tt}dn{17st5tt}5o{ckwclwcmwcnwcowcpw4lw4wv}dp{17st5tt}dq{17st5tt}7t{5ow}ds{17st5tt}5t{2ktclucmucnu4otcpu4lu4wycoucku}fu{17sv5tv5ow}6p{17sy5ty5ow5qs}ek{17sy5ty5ow}el{17sy5ty5ow}em{17sy5ty5ow}en{5ty}eo{17sy5ty5ow}ep{17sy5ty5ow}es{17sy5ty5qs}et{17sy5ty5ow5qs}eu{17sy5ty5ow5qs}ev{17sy5ty5ow5qs}6z{17sy5ty5ow5qs}fm{17sy5ty5ow5qs}fn{17sy5ty5ow5qs}fo{17sy5ty5ow5qs}fp{17sy5ty5qs}fq{17sy5ty5ow5qs}7r{5ow}fs{17sy5ty5ow5qs}ft{17sv5tv5ow}7m{5ow}fv{17sv5tv5ow}fw{17sv5tv5ow}}}")}};t.events.push(["addFont",function(d){var p=d.font,y=h.Unicode[p.postScriptName];y&&(p.metadata.Unicode={},p.metadata.Unicode.widths=y.widths,p.metadata.Unicode.kerning=y.kerning);var w=f.Unicode[p.postScriptName];w&&(p.metadata.Unicode.encoding=w,p.encoding=w.codePages[0])}])})(cr.API),(function(t){var e=function(r){for(var n=r.length,i=new Uint8Array(n),a=0;a<n;a++)i[a]=r.charCodeAt(a);return i};t.API.events.push(["addFont",function(r){var n=void 0,i=r.font,a=r.instance;if(!i.isStandardFont){if(a===void 0)throw new Error("Font does not exist in vFS, import fonts or remove declaration doc.addFont('"+i.postScriptName+"').");if(typeof(n=a.existsFileInVFS(i.postScriptName)===!1?a.loadFile(i.postScriptName):a.getFileFromVFS(i.postScriptName))!="string")throw new Error("Font is not stored as string-data in vFS, import fonts or remove declaration doc.addFont('"+i.postScriptName+"').");(function(o,s){s=/^\x00\x01\x00\x00/.test(s)?e(s):e(zg(s)),o.metadata=t.API.TTFFont.open(s),o.metadata.Unicode=o.metadata.Unicode||{encoding:{},kerning:{},widths:[]},o.metadata.glyIdsUsed=[0]})(i,n)}}])})(cr),cr.API.addSvgAsImage=function(t,e,r,n,i,a,o,s){if(isNaN(e)||isNaN(r))throw ai.error("jsPDF.addSvgAsImage: Invalid coordinates",arguments),new Error("Invalid coordinates passed to jsPDF.addSvgAsImage");if(isNaN(n)||isNaN(i))throw ai.error("jsPDF.addSvgAsImage: Invalid measurements",arguments),new Error("Invalid measurements (width and/or height) passed to jsPDF.addSvgAsImage");var l=document.createElement("canvas");l.width=n,l.height=i;var c=l.getContext("2d");c.fillStyle="#fff",c.fillRect(0,0,l.width,l.height);var f={ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0},h=this;return(Tr.canvg?Promise.resolve(Tr.canvg):Cg(()=>import("./index.es-6B4V2Olh.js"),[],import.meta.url)).catch(function(d){return Promise.reject(new Error("Could not load canvg: "+d))}).then(function(d){return d.default?d.default:d}).then(function(d){return d.fromString(c,t,f)},function(){return Promise.reject(new Error("Could not load canvg."))}).then(function(d){return d.render(f)}).then(function(){h.addImage(l.toDataURL("image/jpeg",1),e,r,n,i,o,s)})},cr.API.putTotalPages=function(t){var e,r=0;parseInt(this.internal.getFont().id.substr(1),10)<15?(e=new RegExp(t,"g"),r=this.internal.getNumberOfPages()):(e=new RegExp(this.pdfEscape16(t,this.internal.getFont()),"g"),r=this.pdfEscape16(this.internal.getNumberOfPages()+"",this.internal.getFont()));for(var n=1;n<=this.internal.getNumberOfPages();n++)for(var i=0;i<this.internal.pages[n].length;i++)this.internal.pages[n][i]=this.internal.pages[n][i].replace(e,r);return this},cr.API.viewerPreferences=function(t,e){var r;t=t||{},e=e||!1;var n,i,a,o={HideToolbar:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},HideMenubar:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},HideWindowUI:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},FitWindow:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},CenterWindow:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.3},DisplayDocTitle:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.4},NonFullScreenPageMode:{defaultValue:"UseNone",value:"UseNone",type:"name",explicitSet:!1,valueSet:["UseNone","UseOutlines","UseThumbs","UseOC"],pdfVersion:1.3},Direction:{defaultValue:"L2R",value:"L2R",type:"name",explicitSet:!1,valueSet:["L2R","R2L"],pdfVersion:1.3},ViewArea:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},ViewClip:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintArea:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintClip:{defaultValue:"CropBox",value:"CropBox",type:"name",explicitSet:!1,valueSet:["MediaBox","CropBox","TrimBox","BleedBox","ArtBox"],pdfVersion:1.4},PrintScaling:{defaultValue:"AppDefault",value:"AppDefault",type:"name",explicitSet:!1,valueSet:["AppDefault","None"],pdfVersion:1.6},Duplex:{defaultValue:"",value:"none",type:"name",explicitSet:!1,valueSet:["Simplex","DuplexFlipShortEdge","DuplexFlipLongEdge","none"],pdfVersion:1.7},PickTrayByPDFSize:{defaultValue:!1,value:!1,type:"boolean",explicitSet:!1,valueSet:[!0,!1],pdfVersion:1.7},PrintPageRange:{defaultValue:"",value:"",type:"array",explicitSet:!1,valueSet:null,pdfVersion:1.7},NumCopies:{defaultValue:1,value:1,type:"integer",explicitSet:!1,valueSet:null,pdfVersion:1.7}},s=Object.keys(o),l=[],c=0,f=0,h=0;function d(y,w){var x,b=!1;for(x=0;x<y.length;x+=1)y[x]===w&&(b=!0);return b}if(this.internal.viewerpreferences===void 0&&(this.internal.viewerpreferences={},this.internal.viewerpreferences.configuration=JSON.parse(JSON.stringify(o)),this.internal.viewerpreferences.isSubscribed=!1),r=this.internal.viewerpreferences.configuration,t==="reset"||e===!0){var p=s.length;for(h=0;h<p;h+=1)r[s[h]].value=r[s[h]].defaultValue,r[s[h]].explicitSet=!1}if(Hn(t)==="object"){for(i in t)if(a=t[i],d(s,i)&&a!==void 0){if(r[i].type==="boolean"&&typeof a=="boolean")r[i].value=a;else if(r[i].type==="name"&&d(r[i].valueSet,a))r[i].value=a;else if(r[i].type==="integer"&&Number.isInteger(a))r[i].value=a;else if(r[i].type==="array"){for(c=0;c<a.length;c+=1)if(n=!0,a[c].length===1&&typeof a[c][0]=="number")l.push(String(a[c]-1));else if(a[c].length>1){for(f=0;f<a[c].length;f+=1)typeof a[c][f]!="number"&&(n=!1);n===!0&&l.push([a[c][0]-1,a[c][1]-1].join(" "))}r[i].value="["+l.join(" ")+"]"}else r[i].value=r[i].defaultValue;r[i].explicitSet=!0}}return this.internal.viewerpreferences.isSubscribed===!1&&(this.internal.events.subscribe("putCatalog",function(){var y,w=[];for(y in r)r[y].explicitSet===!0&&(r[y].type==="name"?w.push("/"+y+" /"+r[y].value):w.push("/"+y+" "+r[y].value));w.length!==0&&this.internal.write(`/ViewerPreferences
|
|
515
515
|
<<
|
|
516
516
|
`+w.join(`
|
|
517
517
|
`)+`
|
|
@@ -540,4 +540,4 @@ endbfchar
|
|
|
540
540
|
CMapName currentdict /CMap defineresource pop
|
|
541
541
|
end
|
|
542
542
|
end`};e.events.push(["putFont",function(a){(function(o){var s=o.font,l=o.out,c=o.newObject,f=o.putStream;if(s.metadata instanceof t.API.TTFFont&&s.encoding==="Identity-H"){for(var h=s.metadata.Unicode.widths,d=s.metadata.subset.encode(s.metadata.glyIdsUsed,1),p="",y=0;y<d.length;y++)p+=String.fromCharCode(d[y]);var w=c();f({data:p,addLength1:!0,objectId:w}),l("endobj");var x=c();f({data:n(s.metadata.toUnicode),addLength1:!0,objectId:x}),l("endobj");var b=c();l("<<"),l("/Type /FontDescriptor"),l("/FontName /"+ap(s.fontName)),l("/FontFile2 "+w+" 0 R"),l("/FontBBox "+t.API.PDFObject.convert(s.metadata.bbox)),l("/Flags "+s.metadata.flags),l("/StemV "+s.metadata.stemV),l("/ItalicAngle "+s.metadata.italicAngle),l("/Ascent "+s.metadata.ascender),l("/Descent "+s.metadata.decender),l("/CapHeight "+s.metadata.capHeight),l(">>"),l("endobj");var S=c();l("<<"),l("/Type /Font"),l("/BaseFont /"+ap(s.fontName)),l("/FontDescriptor "+b+" 0 R"),l("/W "+t.API.PDFObject.convert(h)),l("/CIDToGIDMap /Identity"),l("/DW 1000"),l("/Subtype /CIDFontType2"),l("/CIDSystemInfo"),l("<<"),l("/Supplement 0"),l("/Registry (Adobe)"),l("/Ordering ("+s.encoding+")"),l(">>"),l(">>"),l("endobj"),s.objectNumber=c(),l("<<"),l("/Type /Font"),l("/Subtype /Type0"),l("/ToUnicode "+x+" 0 R"),l("/BaseFont /"+ap(s.fontName)),l("/Encoding /"+s.encoding),l("/DescendantFonts ["+S+" 0 R]"),l(">>"),l("endobj"),s.isAlreadyPutted=!0}})(a)}]),e.events.push(["putFont",function(a){(function(o){var s=o.font,l=o.out,c=o.newObject,f=o.putStream;if(s.metadata instanceof t.API.TTFFont&&s.encoding==="WinAnsiEncoding"){for(var h=s.metadata.rawData,d="",p=0;p<h.length;p++)d+=String.fromCharCode(h[p]);var y=c();f({data:d,addLength1:!0,objectId:y}),l("endobj");var w=c();f({data:n(s.metadata.toUnicode),addLength1:!0,objectId:w}),l("endobj");var x=c();l("<<"),l("/Descent "+s.metadata.decender),l("/CapHeight "+s.metadata.capHeight),l("/StemV "+s.metadata.stemV),l("/Type /FontDescriptor"),l("/FontFile2 "+y+" 0 R"),l("/Flags 96"),l("/FontBBox "+t.API.PDFObject.convert(s.metadata.bbox)),l("/FontName /"+ap(s.fontName)),l("/ItalicAngle "+s.metadata.italicAngle),l("/Ascent "+s.metadata.ascender),l(">>"),l("endobj"),s.objectNumber=c();for(var b=0;b<s.metadata.hmtx.widths.length;b++)s.metadata.hmtx.widths[b]=parseInt(s.metadata.hmtx.widths[b]*(1e3/s.metadata.head.unitsPerEm));l("<</Subtype/TrueType/Type/Font/ToUnicode "+w+" 0 R/BaseFont/"+ap(s.fontName)+"/FontDescriptor "+x+" 0 R/Encoding/"+s.encoding+" /FirstChar 29 /LastChar 255 /Widths "+t.API.PDFObject.convert(s.metadata.hmtx.widths)+">>"),l("endobj"),s.isAlreadyPutted=!0}})(a)}]);var i=function(a){var o,s=a.text||"",l=a.x,c=a.y,f=a.options||{},h=a.mutex||{},d=h.pdfEscape,p=h.activeFontKey,y=h.fonts,w=p,x="",b=0,S="",E=y[w].encoding;if(y[w].encoding!=="Identity-H")return{text:s,x:l,y:c,options:f,mutex:h};for(S=s,w=p,Array.isArray(s)&&(S=s[0]),b=0;b<S.length;b+=1)y[w].metadata.hasOwnProperty("cmap")&&(o=y[w].metadata.cmap.unicode.codeMap[S[b].charCodeAt(0)]),o||S[b].charCodeAt(0)<256&&y[w].metadata.hasOwnProperty("Unicode")?x+=S[b]:x+="";var _="";return parseInt(w.slice(1))<14||E==="WinAnsiEncoding"?_=d(x,w).split("").map(function(P){return P.charCodeAt(0).toString(16)}).join(""):E==="Identity-H"&&(_=r(x,y[w])),h.isHex=!0,{text:_,x:l,y:c,options:f,mutex:h}};e.events.push(["postProcessText",function(a){var o=a.text||"",s=[],l={text:o,x:a.x,y:a.y,options:a.options,mutex:a.mutex};if(Array.isArray(o)){var c=0;for(c=0;c<o.length;c+=1)Array.isArray(o[c])&&o[c].length===3?s.push([i(Object.assign({},l,{text:o[c][0]})).text,o[c][1],o[c][2]]):s.push(i(Object.assign({},l,{text:o[c]})).text);a.text=s}else a.text=i(Object.assign({},l,{text:o})).text}])})(cr),(function(t){var e=function(){return this.internal.vFS===void 0&&(this.internal.vFS={}),!0};t.existsFileInVFS=function(r){return e.call(this),this.internal.vFS[r]!==void 0},t.addFileToVFS=function(r,n){return e.call(this),this.internal.vFS[r]=n,this},t.getFileFromVFS=function(r){return e.call(this),this.internal.vFS[r]!==void 0?this.internal.vFS[r]:null}})(cr.API),(function(t){t.__bidiEngine__=t.prototype.__bidiEngine__=function(n){var i,a,o,s,l,c,f,h=e,d=[[0,3,0,1,0,0,0],[0,3,0,1,2,2,0],[0,3,0,17,2,0,1],[0,3,5,5,4,1,0],[0,3,21,21,4,0,1],[0,3,5,5,4,2,0]],p=[[2,0,1,1,0,1,0],[2,0,1,1,0,2,0],[2,0,2,1,3,2,0],[2,0,2,33,3,1,1]],y={L:0,R:1,EN:2,AN:3,N:4,B:5,S:6},w={0:0,5:1,6:2,7:3,32:4,251:5,254:6,255:7},x=["(",")","(","<",">","<","[","]","[","{","}","{","«","»","«","‹","›","‹","⁅","⁆","⁅","⁽","⁾","⁽","₍","₎","₍","≤","≥","≤","〈","〉","〈","﹙","﹚","﹙","﹛","﹜","﹛","﹝","﹞","﹝","﹤","﹥","﹤"],b=new RegExp(/^([1-4|9]|1[0-9]|2[0-9]|3[0168]|4[04589]|5[012]|7[78]|159|16[0-9]|17[0-2]|21[569]|22[03489]|250)$/),S=!1,E=0;this.__bidiEngine__={};var _=function(A){var L=A.charCodeAt(),H=L>>8,U=w[H];return U!==void 0?h[256*U+(255&L)]:H===252||H===253?"AL":b.test(H)?"L":H===8?"R":"N"},P=function(A){for(var L,H=0;H<A.length;H++){if((L=_(A.charAt(H)))==="L")return!1;if(L==="R")return!0}return!1},O=function(A,L,H,U){var ee,se,te,Z,ne=L[U];switch(ne){case"L":case"R":case"LRE":case"RLE":case"LRO":case"RLO":case"PDF":S=!1;break;case"N":case"AN":break;case"EN":S&&(ne="AN");break;case"AL":S=!0,ne="R";break;case"WS":case"BN":ne="N";break;case"CS":U<1||U+1>=L.length||(ee=H[U-1])!=="EN"&&ee!=="AN"||(se=L[U+1])!=="EN"&&se!=="AN"?ne="N":S&&(se="AN"),ne=se===ee?se:"N";break;case"ES":ne=(ee=U>0?H[U-1]:"B")==="EN"&&U+1<L.length&&L[U+1]==="EN"?"EN":"N";break;case"ET":if(U>0&&H[U-1]==="EN"){ne="EN";break}if(S){ne="N";break}for(te=U+1,Z=L.length;te<Z&&L[te]==="ET";)te++;ne=te<Z&&L[te]==="EN"?"EN":"N";break;case"NSM":if(o&&!s){for(Z=L.length,te=U+1;te<Z&&L[te]==="NSM";)te++;if(te<Z){var G=A[U],j=G>=1425&&G<=2303||G===64286;if(ee=L[te],j&&(ee==="R"||ee==="AL")){ne="R";break}}}ne=U<1||(ee=L[U-1])==="B"?"N":H[U-1];break;case"B":S=!1,i=!0,ne=E;break;case"S":a=!0,ne="N"}return ne},T=function(A,L,H){var U=A.split("");return H&&N(U,H,{hiLevel:E}),U.reverse(),L&&L.reverse(),U.join("")},N=function(A,L,H){var U,ee,se,te,Z,ne=-1,G=A.length,j=0,B=[],z=E?p:d,Y=[];for(S=!1,i=!1,a=!1,ee=0;ee<G;ee++)Y[ee]=_(A[ee]);for(se=0;se<G;se++){if(Z=j,B[se]=O(A,Y,B,se),U=240&(j=z[Z][y[B[se]]]),j&=15,L[se]=te=z[j][5],U>0)if(U===16){for(ee=ne;ee<se;ee++)L[ee]=1;ne=-1}else ne=-1;if(z[j][6])ne===-1&&(ne=se);else if(ne>-1){for(ee=ne;ee<se;ee++)L[ee]=te;ne=-1}Y[se]==="B"&&(L[se]=0),H.hiLevel|=te}a&&(function(Q,K,ie){for(var he=0;he<ie;he++)if(Q[he]==="S"){K[he]=E;for(var ue=he-1;ue>=0&&Q[ue]==="WS";ue--)K[ue]=E}})(Y,L,G)},D=function(A,L,H,U,ee){if(!(ee.hiLevel<A)){if(A===1&&E===1&&!i)return L.reverse(),void(H&&H.reverse());for(var se,te,Z,ne,G=L.length,j=0;j<G;){if(U[j]>=A){for(Z=j+1;Z<G&&U[Z]>=A;)Z++;for(ne=j,te=Z-1;ne<te;ne++,te--)se=L[ne],L[ne]=L[te],L[te]=se,H&&(se=H[ne],H[ne]=H[te],H[te]=se);j=Z}j++}}},F=function(A,L,H){var U=A.split(""),ee={hiLevel:E};return H||(H=[]),N(U,H,ee),(function(se,te,Z){if(Z.hiLevel!==0&&f)for(var ne,G=0;G<se.length;G++)te[G]===1&&(ne=x.indexOf(se[G]))>=0&&(se[G]=x[ne+1])})(U,H,ee),D(2,U,L,H,ee),D(1,U,L,H,ee),U.join("")};return this.__bidiEngine__.doBidiReorder=function(A,L,H){if((function(ee,se){if(se)for(var te=0;te<ee.length;te++)se[te]=te;s===void 0&&(s=P(ee)),c===void 0&&(c=P(ee))})(A,L),o||!l||c)if(o&&l&&s^c)E=s?1:0,A=T(A,L,H);else if(!o&&l&&c)E=s?1:0,A=F(A,L,H),A=T(A,L);else if(!o||s||l||c){if(o&&!l&&s^c)A=T(A,L),s?(E=0,A=F(A,L,H)):(E=1,A=F(A,L,H),A=T(A,L));else if(o&&s&&!l&&c)E=1,A=F(A,L,H),A=T(A,L);else if(!o&&!l&&s^c){var U=f;s?(E=1,A=F(A,L,H),E=0,f=!1,A=F(A,L,H),f=U):(E=0,A=F(A,L,H),A=T(A,L),E=1,f=!1,A=F(A,L,H),f=U,A=T(A,L))}}else E=0,A=F(A,L,H);else E=s?1:0,A=F(A,L,H);return A},this.__bidiEngine__.setOptions=function(A){A&&(o=A.isInputVisual,l=A.isOutputVisual,s=A.isInputRtl,c=A.isOutputRtl,f=A.isSymmetricSwapping)},this.__bidiEngine__.setOptions(n),this.__bidiEngine__};var e=["BN","BN","BN","BN","BN","BN","BN","BN","BN","S","B","S","WS","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","B","B","B","S","WS","N","N","ET","ET","ET","N","N","N","N","N","ES","CS","ES","CS","CS","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","CS","N","N","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","N","N","BN","BN","BN","BN","BN","BN","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","CS","N","ET","ET","ET","ET","N","N","N","N","L","N","N","BN","N","N","ET","ET","EN","EN","N","L","N","N","N","EN","L","N","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","L","L","L","L","L","L","L","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","L","N","N","N","N","N","ET","N","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","R","NSM","R","NSM","NSM","R","NSM","NSM","R","NSM","N","N","N","N","N","N","N","N","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","N","N","N","N","N","R","R","R","R","R","N","N","N","N","N","N","N","N","N","N","N","AN","AN","AN","AN","AN","AN","N","N","AL","ET","ET","AL","CS","AL","N","N","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AL","AL","N","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AN","AN","AN","AN","AN","AN","AN","AN","AN","AN","ET","AN","AN","AL","AL","AL","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AN","N","NSM","NSM","NSM","NSM","NSM","NSM","AL","AL","NSM","NSM","N","NSM","NSM","NSM","NSM","AL","AL","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","N","AL","AL","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","N","N","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AL","N","N","N","N","N","N","N","N","N","N","N","N","N","N","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","R","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","R","R","N","N","N","N","R","N","N","N","N","N","WS","WS","WS","WS","WS","WS","WS","WS","WS","WS","WS","BN","BN","BN","L","R","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","WS","B","LRE","RLE","PDF","LRO","RLO","CS","ET","ET","ET","ET","ET","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","CS","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","WS","BN","BN","BN","BN","BN","N","LRI","RLI","FSI","PDI","BN","BN","BN","BN","BN","BN","EN","L","N","N","EN","EN","EN","EN","EN","EN","ES","ES","N","N","N","L","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","ES","ES","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","N","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","ET","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","L","L","L","L","L","L","L","N","N","N","N","N","N","N","N","N","N","N","N","L","L","L","L","L","N","N","N","N","N","R","NSM","R","R","R","R","R","R","R","R","R","R","ES","R","R","R","R","R","R","R","R","R","R","R","R","R","N","R","R","R","R","R","N","R","N","R","R","N","R","R","N","R","R","R","R","R","R","R","R","R","R","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","CS","N","CS","N","N","CS","N","N","N","N","N","N","N","N","N","ET","N","N","ES","ES","N","N","N","N","N","ET","ET","N","N","N","N","N","AL","AL","AL","AL","AL","N","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","N","N","BN","N","N","N","ET","ET","ET","N","N","N","N","N","ES","CS","ES","CS","CS","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","CS","N","N","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","N","N","N","N","N","N","N","N","N","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","N","N","N","L","L","L","L","L","L","N","N","L","L","L","L","L","L","N","N","L","L","L","L","L","L","N","N","L","L","L","N","N","N","ET","ET","N","N","N","ET","ET","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N","N"],r=new t.__bidiEngine__({isInputVisual:!0});t.API.events.push(["postProcessText",function(n){var i=n.text;n.x,n.y;var a=n.options||{};n.mutex,a.lang;var o=[];if(a.isInputVisual=typeof a.isInputVisual!="boolean"||a.isInputVisual,r.setOptions(a),Object.prototype.toString.call(i)==="[object Array]"){var s=0;for(o=[],s=0;s<i.length;s+=1)Object.prototype.toString.call(i[s])==="[object Array]"?o.push([r.doBidiReorder(i[s][0]),i[s][1],i[s][2]]):o.push([r.doBidiReorder(i[s])]);n.text=o}else n.text=r.doBidiReorder(i);r.setOptions({isInputVisual:!0})}])})(cr),cr.API.TTFFont=(function(){function t(e){var r;if(this.rawData=e,r=this.contents=new dh(e),this.contents.pos=4,r.readString(4)==="ttcf")throw new Error("TTCF not supported.");r.pos=0,this.parse(),this.subset=new Cq(this),this.registerTTF()}return t.open=function(e){return new t(e)},t.prototype.parse=function(){return this.directory=new dq(this.contents),this.head=new gq(this),this.name=new wq(this),this.cmap=new oE(this),this.toUnicode={},this.hhea=new mq(this),this.maxp=new xq(this),this.hmtx=new Sq(this),this.post=new yq(this),this.os2=new vq(this),this.loca=new Pq(this),this.glyf=new _q(this),this.ascender=this.os2.exists&&this.os2.ascender||this.hhea.ascender,this.decender=this.os2.exists&&this.os2.decender||this.hhea.decender,this.lineGap=this.os2.exists&&this.os2.lineGap||this.hhea.lineGap,this.bbox=[this.head.xMin,this.head.yMin,this.head.xMax,this.head.yMax]},t.prototype.registerTTF=function(){var e,r,n,i,a;if(this.scaleFactor=1e3/this.head.unitsPerEm,this.bbox=(function(){var o,s,l,c;for(c=[],o=0,s=(l=this.bbox).length;o<s;o++)e=l[o],c.push(Math.round(e*this.scaleFactor));return c}).call(this),this.stemV=0,this.post.exists?(n=255&(i=this.post.italic_angle),32768&(r=i>>16)&&(r=-(1+(65535^r))),this.italicAngle=+(r+"."+n)):this.italicAngle=0,this.ascender=Math.round(this.ascender*this.scaleFactor),this.decender=Math.round(this.decender*this.scaleFactor),this.lineGap=Math.round(this.lineGap*this.scaleFactor),this.capHeight=this.os2.exists&&this.os2.capHeight||this.ascender,this.xHeight=this.os2.exists&&this.os2.xHeight||0,this.familyClass=(this.os2.exists&&this.os2.familyClass||0)>>8,this.isSerif=(a=this.familyClass)===1||a===2||a===3||a===4||a===5||a===7,this.isScript=this.familyClass===10,this.flags=0,this.post.isFixedPitch&&(this.flags|=1),this.isSerif&&(this.flags|=2),this.isScript&&(this.flags|=8),this.italicAngle!==0&&(this.flags|=64),this.flags|=32,!this.cmap.unicode)throw new Error("No unicode cmap for font")},t.prototype.characterToGlyph=function(e){var r;return((r=this.cmap.unicode)!=null?r.codeMap[e]:void 0)||0},t.prototype.widthOfGlyph=function(e){var r;return r=1e3/this.head.unitsPerEm,this.hmtx.forGlyph(e).advance*r},t.prototype.widthOfString=function(e,r,n){var i,a,o,s;for(o=0,a=0,s=(e=""+e).length;0<=s?a<s:a>s;a=0<=s?++a:--a)i=e.charCodeAt(a),o+=this.widthOfGlyph(this.characterToGlyph(i))+n*(1e3/r)||0;return o*(r/1e3)},t.prototype.lineHeight=function(e,r){var n;return r==null&&(r=!1),n=r?this.lineGap:0,(this.ascender+n-this.decender)/1e3*e},t})();var Mu,dh=(function(){function t(e){this.data=e??[],this.pos=0,this.length=this.data.length}return t.prototype.readByte=function(){return this.data[this.pos++]},t.prototype.writeByte=function(e){return this.data[this.pos++]=e},t.prototype.readUInt32=function(){return 16777216*this.readByte()+(this.readByte()<<16)+(this.readByte()<<8)+this.readByte()},t.prototype.writeUInt32=function(e){return this.writeByte(e>>>24&255),this.writeByte(e>>16&255),this.writeByte(e>>8&255),this.writeByte(255&e)},t.prototype.readInt32=function(){var e;return(e=this.readUInt32())>=2147483648?e-4294967296:e},t.prototype.writeInt32=function(e){return e<0&&(e+=4294967296),this.writeUInt32(e)},t.prototype.readUInt16=function(){return this.readByte()<<8|this.readByte()},t.prototype.writeUInt16=function(e){return this.writeByte(e>>8&255),this.writeByte(255&e)},t.prototype.readInt16=function(){var e;return(e=this.readUInt16())>=32768?e-65536:e},t.prototype.writeInt16=function(e){return e<0&&(e+=65536),this.writeUInt16(e)},t.prototype.readString=function(e){var r,n;for(n=[],r=0;0<=e?r<e:r>e;r=0<=e?++r:--r)n[r]=String.fromCharCode(this.readByte());return n.join("")},t.prototype.writeString=function(e){var r,n,i;for(i=[],r=0,n=e.length;0<=n?r<n:r>n;r=0<=n?++r:--r)i.push(this.writeByte(e.charCodeAt(r)));return i},t.prototype.readShort=function(){return this.readInt16()},t.prototype.writeShort=function(e){return this.writeInt16(e)},t.prototype.readLongLong=function(){var e,r,n,i,a,o,s,l;return e=this.readByte(),r=this.readByte(),n=this.readByte(),i=this.readByte(),a=this.readByte(),o=this.readByte(),s=this.readByte(),l=this.readByte(),128&e?-1*(72057594037927940*(255^e)+281474976710656*(255^r)+1099511627776*(255^n)+4294967296*(255^i)+16777216*(255^a)+65536*(255^o)+256*(255^s)+(255^l)+1):72057594037927940*e+281474976710656*r+1099511627776*n+4294967296*i+16777216*a+65536*o+256*s+l},t.prototype.writeLongLong=function(e){var r,n;return r=Math.floor(e/4294967296),n=4294967295&e,this.writeByte(r>>24&255),this.writeByte(r>>16&255),this.writeByte(r>>8&255),this.writeByte(255&r),this.writeByte(n>>24&255),this.writeByte(n>>16&255),this.writeByte(n>>8&255),this.writeByte(255&n)},t.prototype.readInt=function(){return this.readInt32()},t.prototype.writeInt=function(e){return this.writeInt32(e)},t.prototype.read=function(e){var r,n;for(r=[],n=0;0<=e?n<e:n>e;n=0<=e?++n:--n)r.push(this.readByte());return r},t.prototype.write=function(e){var r,n,i,a;for(a=[],n=0,i=e.length;n<i;n++)r=e[n],a.push(this.writeByte(r));return a},t})(),dq=(function(){var t;function e(r){var n,i,a;for(this.scalarType=r.readInt(),this.tableCount=r.readShort(),this.searchRange=r.readShort(),this.entrySelector=r.readShort(),this.rangeShift=r.readShort(),this.tables={},i=0,a=this.tableCount;0<=a?i<a:i>a;i=0<=a?++i:--i)n={tag:r.readString(4),checksum:r.readInt(),offset:r.readInt(),length:r.readInt()},this.tables[n.tag]=n}return e.prototype.encode=function(r){var n,i,a,o,s,l,c,f,h,d,p,y,w;for(w in p=Object.keys(r).length,l=Math.log(2),h=16*Math.floor(Math.log(p)/l),o=Math.floor(h/l),f=16*p-h,(i=new dh).writeInt(this.scalarType),i.writeShort(p),i.writeShort(h),i.writeShort(o),i.writeShort(f),a=16*p,c=i.pos+a,s=null,y=[],r)for(d=r[w],i.writeString(w),i.writeInt(t(d)),i.writeInt(c),i.writeInt(d.length),y=y.concat(d),w==="head"&&(s=c),c+=d.length;c%4;)y.push(0),c++;return i.write(y),n=2981146554-t(i.data),i.pos=s+8,i.writeUInt32(n),i.data},t=function(r){var n,i,a,o;for(r=sE.call(r);r.length%4;)r.push(0);for(a=new dh(r),i=0,n=0,o=r.length;n<o;n=n+=4)i+=a.readUInt32();return 4294967295&i},e})(),pq={}.hasOwnProperty,Sc=function(t,e){for(var r in e)pq.call(e,r)&&(t[r]=e[r]);function n(){this.constructor=t}return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};Mu=(function(){function t(e){var r;this.file=e,r=this.file.directory.tables[this.tag],this.exists=!!r,r&&(this.offset=r.offset,this.length=r.length,this.parse(this.file.contents))}return t.prototype.parse=function(){},t.prototype.encode=function(){},t.prototype.raw=function(){return this.exists?(this.file.contents.pos=this.offset,this.file.contents.read(this.length)):null},t})();var gq=(function(){function t(){return t.__super__.constructor.apply(this,arguments)}return Sc(t,Mu),t.prototype.tag="head",t.prototype.parse=function(e){return e.pos=this.offset,this.version=e.readInt(),this.revision=e.readInt(),this.checkSumAdjustment=e.readInt(),this.magicNumber=e.readInt(),this.flags=e.readShort(),this.unitsPerEm=e.readShort(),this.created=e.readLongLong(),this.modified=e.readLongLong(),this.xMin=e.readShort(),this.yMin=e.readShort(),this.xMax=e.readShort(),this.yMax=e.readShort(),this.macStyle=e.readShort(),this.lowestRecPPEM=e.readShort(),this.fontDirectionHint=e.readShort(),this.indexToLocFormat=e.readShort(),this.glyphDataFormat=e.readShort()},t.prototype.encode=function(e){var r;return(r=new dh).writeInt(this.version),r.writeInt(this.revision),r.writeInt(this.checkSumAdjustment),r.writeInt(this.magicNumber),r.writeShort(this.flags),r.writeShort(this.unitsPerEm),r.writeLongLong(this.created),r.writeLongLong(this.modified),r.writeShort(this.xMin),r.writeShort(this.yMin),r.writeShort(this.xMax),r.writeShort(this.yMax),r.writeShort(this.macStyle),r.writeShort(this.lowestRecPPEM),r.writeShort(this.fontDirectionHint),r.writeShort(e),r.writeShort(this.glyphDataFormat),r.data},t})(),Q8=(function(){function t(e,r){var n,i,a,o,s,l,c,f,h,d,p,y,w,x,b,S,E;switch(this.platformID=e.readUInt16(),this.encodingID=e.readShort(),this.offset=r+e.readInt(),h=e.pos,e.pos=this.offset,this.format=e.readUInt16(),this.length=e.readUInt16(),this.language=e.readUInt16(),this.isUnicode=this.platformID===3&&this.encodingID===1&&this.format===4||this.platformID===0&&this.format===4,this.codeMap={},this.format){case 0:for(l=0;l<256;++l)this.codeMap[l]=e.readByte();break;case 4:for(p=e.readUInt16(),d=p/2,e.pos+=6,a=(function(){var _,P;for(P=[],l=_=0;0<=d?_<d:_>d;l=0<=d?++_:--_)P.push(e.readUInt16());return P})(),e.pos+=2,w=(function(){var _,P;for(P=[],l=_=0;0<=d?_<d:_>d;l=0<=d?++_:--_)P.push(e.readUInt16());return P})(),c=(function(){var _,P;for(P=[],l=_=0;0<=d?_<d:_>d;l=0<=d?++_:--_)P.push(e.readUInt16());return P})(),f=(function(){var _,P;for(P=[],l=_=0;0<=d?_<d:_>d;l=0<=d?++_:--_)P.push(e.readUInt16());return P})(),i=(this.length-e.pos+this.offset)/2,s=(function(){var _,P;for(P=[],l=_=0;0<=i?_<i:_>i;l=0<=i?++_:--_)P.push(e.readUInt16());return P})(),l=b=0,E=a.length;b<E;l=++b)for(x=a[l],n=S=y=w[l];y<=x?S<=x:S>=x;n=y<=x?++S:--S)f[l]===0?o=n+c[l]:(o=s[f[l]/2+(n-y)-(d-l)]||0)!==0&&(o+=c[l]),this.codeMap[n]=65535&o}e.pos=h}return t.encode=function(e,r){var n,i,a,o,s,l,c,f,h,d,p,y,w,x,b,S,E,_,P,O,T,N,D,F,A,L,H,U,ee,se,te,Z,ne,G,j,B,z,Y,Q,K,ie,he,ue,we,Ae,qe;switch(U=new dh,o=Object.keys(e).sort(function(ze,rt){return ze-rt}),r){case"macroman":for(w=0,x=(function(){var ze=[];for(y=0;y<256;++y)ze.push(0);return ze})(),S={0:0},a={},ee=0,ne=o.length;ee<ne;ee++)S[ue=e[i=o[ee]]]==null&&(S[ue]=++w),a[i]={old:e[i],new:S[e[i]]},x[i]=S[e[i]];return U.writeUInt16(1),U.writeUInt16(0),U.writeUInt32(12),U.writeUInt16(0),U.writeUInt16(262),U.writeUInt16(0),U.write(x),{charMap:a,subtable:U.data,maxGlyphID:w+1};case"unicode":for(L=[],h=[],E=0,S={},n={},b=c=null,se=0,G=o.length;se<G;se++)S[P=e[i=o[se]]]==null&&(S[P]=++E),n[i]={old:P,new:S[P]},s=S[P]-i,b!=null&&s===c||(b&&h.push(b),L.push(i),c=s),b=i;for(b&&h.push(b),h.push(65535),L.push(65535),F=2*(D=L.length),N=2*Math.pow(Math.log(D)/Math.LN2,2),d=Math.log(N/2)/Math.LN2,T=2*D-N,l=[],O=[],p=[],y=te=0,j=L.length;te<j;y=++te){if(A=L[y],f=h[y],A===65535){l.push(0),O.push(0);break}if(A-(H=n[A].new)>=32768)for(l.push(0),O.push(2*(p.length+D-y)),i=Z=A;A<=f?Z<=f:Z>=f;i=A<=f?++Z:--Z)p.push(n[i].new);else l.push(H-A),O.push(0)}for(U.writeUInt16(3),U.writeUInt16(1),U.writeUInt32(12),U.writeUInt16(4),U.writeUInt16(16+8*D+2*p.length),U.writeUInt16(0),U.writeUInt16(F),U.writeUInt16(N),U.writeUInt16(d),U.writeUInt16(T),ie=0,B=h.length;ie<B;ie++)i=h[ie],U.writeUInt16(i);for(U.writeUInt16(0),he=0,z=L.length;he<z;he++)i=L[he],U.writeUInt16(i);for(we=0,Y=l.length;we<Y;we++)s=l[we],U.writeUInt16(s);for(Ae=0,Q=O.length;Ae<Q;Ae++)_=O[Ae],U.writeUInt16(_);for(qe=0,K=p.length;qe<K;qe++)w=p[qe],U.writeUInt16(w);return{charMap:n,subtable:U.data,maxGlyphID:E+1}}},t})(),oE=(function(){function t(){return t.__super__.constructor.apply(this,arguments)}return Sc(t,Mu),t.prototype.tag="cmap",t.prototype.parse=function(e){var r,n,i;for(e.pos=this.offset,this.version=e.readUInt16(),i=e.readUInt16(),this.tables=[],this.unicode=null,n=0;0<=i?n<i:n>i;n=0<=i?++n:--n)r=new Q8(e,this.offset),this.tables.push(r),r.isUnicode&&this.unicode==null&&(this.unicode=r);return!0},t.encode=function(e,r){var n,i;return r==null&&(r="macroman"),n=Q8.encode(e,r),(i=new dh).writeUInt16(0),i.writeUInt16(1),n.table=i.data.concat(n.subtable),n},t})(),mq=(function(){function t(){return t.__super__.constructor.apply(this,arguments)}return Sc(t,Mu),t.prototype.tag="hhea",t.prototype.parse=function(e){return e.pos=this.offset,this.version=e.readInt(),this.ascender=e.readShort(),this.decender=e.readShort(),this.lineGap=e.readShort(),this.advanceWidthMax=e.readShort(),this.minLeftSideBearing=e.readShort(),this.minRightSideBearing=e.readShort(),this.xMaxExtent=e.readShort(),this.caretSlopeRise=e.readShort(),this.caretSlopeRun=e.readShort(),this.caretOffset=e.readShort(),e.pos+=8,this.metricDataFormat=e.readShort(),this.numberOfMetrics=e.readUInt16()},t})(),vq=(function(){function t(){return t.__super__.constructor.apply(this,arguments)}return Sc(t,Mu),t.prototype.tag="OS/2",t.prototype.parse=function(e){if(e.pos=this.offset,this.version=e.readUInt16(),this.averageCharWidth=e.readShort(),this.weightClass=e.readUInt16(),this.widthClass=e.readUInt16(),this.type=e.readShort(),this.ySubscriptXSize=e.readShort(),this.ySubscriptYSize=e.readShort(),this.ySubscriptXOffset=e.readShort(),this.ySubscriptYOffset=e.readShort(),this.ySuperscriptXSize=e.readShort(),this.ySuperscriptYSize=e.readShort(),this.ySuperscriptXOffset=e.readShort(),this.ySuperscriptYOffset=e.readShort(),this.yStrikeoutSize=e.readShort(),this.yStrikeoutPosition=e.readShort(),this.familyClass=e.readShort(),this.panose=(function(){var r,n;for(n=[],r=0;r<10;++r)n.push(e.readByte());return n})(),this.charRange=(function(){var r,n;for(n=[],r=0;r<4;++r)n.push(e.readInt());return n})(),this.vendorID=e.readString(4),this.selection=e.readShort(),this.firstCharIndex=e.readShort(),this.lastCharIndex=e.readShort(),this.version>0&&(this.ascent=e.readShort(),this.descent=e.readShort(),this.lineGap=e.readShort(),this.winAscent=e.readShort(),this.winDescent=e.readShort(),this.codePageRange=(function(){var r,n;for(n=[],r=0;r<2;r=++r)n.push(e.readInt());return n})(),this.version>1))return this.xHeight=e.readShort(),this.capHeight=e.readShort(),this.defaultChar=e.readShort(),this.breakChar=e.readShort(),this.maxContext=e.readShort()},t})(),yq=(function(){function t(){return t.__super__.constructor.apply(this,arguments)}return Sc(t,Mu),t.prototype.tag="post",t.prototype.parse=function(e){var r,n,i;switch(e.pos=this.offset,this.format=e.readInt(),this.italicAngle=e.readInt(),this.underlinePosition=e.readShort(),this.underlineThickness=e.readShort(),this.isFixedPitch=e.readInt(),this.minMemType42=e.readInt(),this.maxMemType42=e.readInt(),this.minMemType1=e.readInt(),this.maxMemType1=e.readInt(),this.format){case 65536:case 196608:break;case 131072:var a;for(n=e.readUInt16(),this.glyphNameIndex=[],a=0;0<=n?a<n:a>n;a=0<=n?++a:--a)this.glyphNameIndex.push(e.readUInt16());for(this.names=[],i=[];e.pos<this.offset+this.length;)r=e.readByte(),i.push(this.names.push(e.readString(r)));return i;case 151552:return n=e.readUInt16(),this.offsets=e.read(n);case 262144:return this.map=(function(){var o,s,l;for(l=[],a=o=0,s=this.file.maxp.numGlyphs;0<=s?o<s:o>s;a=0<=s?++o:--o)l.push(e.readUInt32());return l}).call(this)}},t})(),bq=function(t,e){this.raw=t,this.length=t.length,this.platformID=e.platformID,this.encodingID=e.encodingID,this.languageID=e.languageID},wq=(function(){function t(){return t.__super__.constructor.apply(this,arguments)}return Sc(t,Mu),t.prototype.tag="name",t.prototype.parse=function(e){var r,n,i,a,o,s,l,c,f,h,d;for(e.pos=this.offset,e.readShort(),r=e.readShort(),s=e.readShort(),n=[],a=0;0<=r?a<r:a>r;a=0<=r?++a:--a)n.push({platformID:e.readShort(),encodingID:e.readShort(),languageID:e.readShort(),nameID:e.readShort(),length:e.readShort(),offset:this.offset+s+e.readShort()});for(l={},a=f=0,h=n.length;f<h;a=++f)i=n[a],e.pos=i.offset,c=e.readString(i.length),o=new bq(c,i),l[d=i.nameID]==null&&(l[d]=[]),l[i.nameID].push(o);this.strings=l,this.copyright=l[0],this.fontFamily=l[1],this.fontSubfamily=l[2],this.uniqueSubfamily=l[3],this.fontName=l[4],this.version=l[5];try{this.postscriptName=l[6][0].raw.replace(/[\x00-\x19\x80-\xff]/g,"")}catch{this.postscriptName=l[4][0].raw.replace(/[\x00-\x19\x80-\xff]/g,"")}return this.trademark=l[7],this.manufacturer=l[8],this.designer=l[9],this.description=l[10],this.vendorUrl=l[11],this.designerUrl=l[12],this.license=l[13],this.licenseUrl=l[14],this.preferredFamily=l[15],this.preferredSubfamily=l[17],this.compatibleFull=l[18],this.sampleText=l[19]},t})(),xq=(function(){function t(){return t.__super__.constructor.apply(this,arguments)}return Sc(t,Mu),t.prototype.tag="maxp",t.prototype.parse=function(e){return e.pos=this.offset,this.version=e.readInt(),this.numGlyphs=e.readUInt16(),this.maxPoints=e.readUInt16(),this.maxContours=e.readUInt16(),this.maxCompositePoints=e.readUInt16(),this.maxComponentContours=e.readUInt16(),this.maxZones=e.readUInt16(),this.maxTwilightPoints=e.readUInt16(),this.maxStorage=e.readUInt16(),this.maxFunctionDefs=e.readUInt16(),this.maxInstructionDefs=e.readUInt16(),this.maxStackElements=e.readUInt16(),this.maxSizeOfInstructions=e.readUInt16(),this.maxComponentElements=e.readUInt16(),this.maxComponentDepth=e.readUInt16()},t})(),Sq=(function(){function t(){return t.__super__.constructor.apply(this,arguments)}return Sc(t,Mu),t.prototype.tag="hmtx",t.prototype.parse=function(e){var r,n,i,a,o,s,l;for(e.pos=this.offset,this.metrics=[],r=0,s=this.file.hhea.numberOfMetrics;0<=s?r<s:r>s;r=0<=s?++r:--r)this.metrics.push({advance:e.readUInt16(),lsb:e.readInt16()});for(i=this.file.maxp.numGlyphs-this.file.hhea.numberOfMetrics,this.leftSideBearings=(function(){var c,f;for(f=[],r=c=0;0<=i?c<i:c>i;r=0<=i?++c:--c)f.push(e.readInt16());return f})(),this.widths=(function(){var c,f,h,d;for(d=[],c=0,f=(h=this.metrics).length;c<f;c++)a=h[c],d.push(a.advance);return d}).call(this),n=this.widths[this.widths.length-1],l=[],r=o=0;0<=i?o<i:o>i;r=0<=i?++o:--o)l.push(this.widths.push(n));return l},t.prototype.forGlyph=function(e){return e in this.metrics?this.metrics[e]:{advance:this.metrics[this.metrics.length-1].advance,lsb:this.leftSideBearings[e-this.metrics.length]}},t})(),sE=[].slice,_q=(function(){function t(){return t.__super__.constructor.apply(this,arguments)}return Sc(t,Mu),t.prototype.tag="glyf",t.prototype.parse=function(){return this.cache={}},t.prototype.glyphFor=function(e){var r,n,i,a,o,s,l,c,f,h;return e in this.cache?this.cache[e]:(a=this.file.loca,r=this.file.contents,n=a.indexOf(e),(i=a.lengthOf(e))===0?this.cache[e]=null:(r.pos=this.offset+n,o=(s=new dh(r.read(i))).readShort(),c=s.readShort(),h=s.readShort(),l=s.readShort(),f=s.readShort(),this.cache[e]=o===-1?new Eq(s,c,h,l,f):new kq(s,o,c,h,l,f),this.cache[e]))},t.prototype.encode=function(e,r,n){var i,a,o,s,l;for(o=[],a=[],s=0,l=r.length;s<l;s++)i=e[r[s]],a.push(o.length),i&&(o=o.concat(i.encode(n)));return a.push(o.length),{table:o,offsets:a}},t})(),kq=(function(){function t(e,r,n,i,a,o){this.raw=e,this.numberOfContours=r,this.xMin=n,this.yMin=i,this.xMax=a,this.yMax=o,this.compound=!1}return t.prototype.encode=function(){return this.raw.data},t})(),Eq=(function(){function t(e,r,n,i,a){var o,s;for(this.raw=e,this.xMin=r,this.yMin=n,this.xMax=i,this.yMax=a,this.compound=!0,this.glyphIDs=[],this.glyphOffsets=[],o=this.raw;s=o.readShort(),this.glyphOffsets.push(o.pos),this.glyphIDs.push(o.readUInt16()),32&s;)o.pos+=1&s?4:2,128&s?o.pos+=8:64&s?o.pos+=4:8&s&&(o.pos+=2)}return t.prototype.encode=function(){var e,r,n;for(r=new dh(sE.call(this.raw.data)),e=0,n=this.glyphIDs.length;e<n;++e)r.pos=this.glyphOffsets[e];return r.data},t})(),Pq=(function(){function t(){return t.__super__.constructor.apply(this,arguments)}return Sc(t,Mu),t.prototype.tag="loca",t.prototype.parse=function(e){var r,n;return e.pos=this.offset,r=this.file.head.indexToLocFormat,this.offsets=r===0?(function(){var i,a;for(a=[],n=0,i=this.length;n<i;n+=2)a.push(2*e.readUInt16());return a}).call(this):(function(){var i,a;for(a=[],n=0,i=this.length;n<i;n+=4)a.push(e.readUInt32());return a}).call(this)},t.prototype.indexOf=function(e){return this.offsets[e]},t.prototype.lengthOf=function(e){return this.offsets[e+1]-this.offsets[e]},t.prototype.encode=function(e,r){for(var n=new Uint32Array(this.offsets.length),i=0,a=0,o=0;o<n.length;++o)if(n[o]=i,a<r.length&&r[a]==o){++a,n[o]=i;var s=this.offsets[o],l=this.offsets[o+1]-s;l>0&&(i+=l)}for(var c=new Array(4*n.length),f=0;f<n.length;++f)c[4*f+3]=255&n[f],c[4*f+2]=(65280&n[f])>>8,c[4*f+1]=(16711680&n[f])>>16,c[4*f]=(4278190080&n[f])>>24;return c},t})(),Cq=(function(){function t(e){this.font=e,this.subset={},this.unicodes={},this.next=33}return t.prototype.generateCmap=function(){var e,r,n,i,a;for(r in i=this.font.cmap.tables[0].codeMap,e={},a=this.subset)n=a[r],e[r]=i[n];return e},t.prototype.glyphsFor=function(e){var r,n,i,a,o,s,l;for(i={},o=0,s=e.length;o<s;o++)i[a=e[o]]=this.font.glyf.glyphFor(a);for(a in r=[],i)(n=i[a])!=null&&n.compound&&r.push.apply(r,n.glyphIDs);if(r.length>0)for(a in l=this.glyphsFor(r))n=l[a],i[a]=n;return i},t.prototype.encode=function(e,r){var n,i,a,o,s,l,c,f,h,d,p,y,w,x,b;for(i in n=oE.encode(this.generateCmap(),"unicode"),o=this.glyphsFor(e),p={0:0},b=n.charMap)p[(l=b[i]).old]=l.new;for(y in d=n.maxGlyphID,o)y in p||(p[y]=d++);return f=(function(S){var E,_;for(E in _={},S)_[S[E]]=E;return _})(p),h=Object.keys(f).sort(function(S,E){return S-E}),w=(function(){var S,E,_;for(_=[],S=0,E=h.length;S<E;S++)s=h[S],_.push(f[s]);return _})(),a=this.font.glyf.encode(o,w,p),c=this.font.loca.encode(a.offsets,w),x={cmap:this.font.cmap.raw(),glyf:a.table,loca:c,hmtx:this.font.hmtx.raw(),hhea:this.font.hhea.raw(),maxp:this.font.maxp.raw(),post:this.font.post.raw(),name:this.font.name.raw(),head:this.font.head.encode(r)},this.font.os2.exists&&(x["OS/2"]=this.font.os2.raw()),this.font.directory.encode(x)},t})();cr.API.PDFObject=(function(){var t;function e(){}return t=function(r,n){return(Array(n+1).join("0")+r).slice(-n)},e.convert=function(r){var n,i,a,o;if(Array.isArray(r))return"["+(function(){var s,l,c;for(c=[],s=0,l=r.length;s<l;s++)n=r[s],c.push(e.convert(n));return c})().join(" ")+"]";if(typeof r=="string")return"/"+r;if(r?.isString)return"("+r+")";if(r instanceof Date)return"(D:"+t(r.getUTCFullYear(),4)+t(r.getUTCMonth(),2)+t(r.getUTCDate(),2)+t(r.getUTCHours(),2)+t(r.getUTCMinutes(),2)+t(r.getUTCSeconds(),2)+"Z)";if({}.toString.call(r)==="[object Object]"){for(i in a=["<<"],r)o=r[i],a.push("/"+i+" "+e.convert(o));return a.push(">>"),a.join(`
|
|
543
|
-
`)}return""+r},e})();window.jspdf={jsPDF:cr};At.prototype._requestDraw=()=>{};qN(!1);Y_("change-font-size");const Tq=new URLSearchParams(location.search).get("key"),lE=$B({key:Tq});window.store=lE;let Jy=null;window.loadVideoExportModule=async()=>(Jy||(Jy=Cg(()=>import("./index-
|
|
543
|
+
`)}return""+r},e})();window.jspdf={jsPDF:cr};At.prototype._requestDraw=()=>{};qN(!1);Y_("change-font-size");const Tq=new URLSearchParams(location.search).get("key"),lE=$B({key:Tq});window.store=lE;let Jy=null;window.loadVideoExportModule=async()=>(Jy||(Jy=Cg(()=>import("./index-D5GpnOg5.js"),[],import.meta.url)),await Jy);window.config={addGlobalFont:YN,setRichTextEnabled:nI,setTextVerticalResizeEnabled:rI,setTextOverflow:Y_,onLoadError:XN,setAssetLoadTimeout:VN,setFontLoadTimeout:$N,unstable_setTextSplitAllowed:aI};const Aq=eS.createRoot(document.getElementById("root"));Aq.render(oe.createElement(jj,{visiblePagesOffset:0,renderOnlyActivePage:!0,store:lE,components:{PageControls:()=>null,Tooltip:()=>null}}));export{vH as $,Wm as A,L5 as B,zb as C,gH as D,aH as E,oH as F,tH as G,sH as H,nH as I,nh as J,ih as K,i7 as L,qb as M,UM as N,Bo as O,of as P,f7 as Q,F0 as R,eH as S,Ub as T,ku as U,Qq as V,iH as W,vp as X,MM as Y,Gq as Z,mH as _,$e as a,Kq as a0,n7 as a1,Zq as a2,Hq as a3,yH as a4,DF as a5,NF as a6,LF as a7,ux as a8,$g as a9,Hn as aa,hd as ab,Lp as b,Wq as c,td as d,iD as e,wl as f,rH as g,SD as h,Vq as i,YM as j,Yq as k,El as l,ZM as m,dH as n,Xq as o,d7 as p,uH as q,cH as r,hH as s,$q as t,fH as u,lH as v,k0 as w,tp as x,Jq as y,pH as z};
|