filens-preview 0.3.0 → 0.3.2

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.
Files changed (40) hide show
  1. package/README.md +13 -7
  2. package/dist/all-in-one/THIRD-PARTY-NOTICES.txt +870 -0
  3. package/dist/all-in-one/filens.js +5069 -114897
  4. package/dist/index.d.ts +2 -0
  5. package/dist/split/THIRD-PARTY-NOTICES.txt +870 -0
  6. package/dist/split/chunks/archive-haip2eOP.js +1 -0
  7. package/dist/split/chunks/browser-video-session-C_14e_mG.js +1 -0
  8. package/dist/split/chunks/cad-5oTkbaDV.js +7 -0
  9. package/dist/split/chunks/core-EjELrtsP.js +17 -0
  10. package/dist/split/chunks/diagram-BRcdlitF.js +1 -0
  11. package/dist/split/chunks/docx-I39iDYpR.js +1 -0
  12. package/dist/split/chunks/ebook-BRfadCGl.js +5 -0
  13. package/dist/split/chunks/index-C4jdVbDq.js +1 -0
  14. package/dist/split/chunks/index-DkF8PBGR.js +1 -0
  15. package/dist/split/chunks/iwork-DXq9Adf7.js +4 -0
  16. package/dist/split/chunks/media-runtime-B6322raw.js +1 -0
  17. package/dist/split/chunks/mindmap-CyR3TRfx.js +1 -0
  18. package/dist/split/chunks/model3d-BEt6INTt.js +55 -0
  19. package/dist/split/chunks/mp4box.all-Bw_Tlr0T-D0URDfA1.js +1 -0
  20. package/dist/split/chunks/panorama-ChsqnvWC.js +973 -0
  21. package/dist/split/chunks/pdf-Dzzffz3p.js +12 -0
  22. package/dist/split/chunks/vendor-C1aIdQ-w.js +4115 -0
  23. package/dist/split/chunks/xlsx-CITQo0Od.js +3 -0
  24. package/dist/split/converter-image.wasm +0 -0
  25. package/dist/split/filens.js +2 -5012
  26. package/package.json +1 -1
  27. package/dist/split/chunks/archive-B4jVwD9o.js +0 -921
  28. package/dist/split/chunks/cad-DMg-lGJX.js +0 -2405
  29. package/dist/split/chunks/core--zVW212C.js +0 -14627
  30. package/dist/split/chunks/diagram-CDwCA6LZ.js +0 -654
  31. package/dist/split/chunks/docx-CuQfFJqr.js +0 -299
  32. package/dist/split/chunks/ebook-CLlJ8KX3.js +0 -623
  33. package/dist/split/chunks/iwork-dNVC0X8j.js +0 -772
  34. package/dist/split/chunks/media-runtime-gcsBQMuo.js +0 -48
  35. package/dist/split/chunks/mindmap-g0-VoK-K.js +0 -560
  36. package/dist/split/chunks/model3d-1G1CC52V.js +0 -5093
  37. package/dist/split/chunks/panorama-D7GVivtM.js +0 -5972
  38. package/dist/split/chunks/pdf-CecYOWld.js +0 -17898
  39. package/dist/split/chunks/vendor-DPFNKNkh.js +0 -59575
  40. package/dist/split/chunks/xlsx-Co26yo-R.js +0 -818
@@ -0,0 +1 @@
1
+ var La=Object.defineProperty,Vn=(t,e)=>{let s={};for(var i in t)La(s,i,{get:t[i],enumerable:true});return La(s,Symbol.toStringTag,{value:"Module"}),s},Ha=Object.defineProperty,$a=(t,e)=>{let s={};for(var i in t)Ha(s,i,{get:t[i],enumerable:true});return Ha(s,Symbol.toStringTag,{value:"Module"}),s};function qa(t,e){if(e.has(t))throw TypeError("Cannot initialize the same private elements twice on an object")}function Gn(t,e){qa(t,e),e.add(t)}function lt(t,e,s){if(typeof t=="function"?t===e:t.has(e))return arguments.length<3?e:s;throw TypeError("Private element is not present on this object")}function jn(t,e,s){qa(t,e),e.set(t,s)}function $n(t,e){return t.get(lt(t,e))}function qn(t,e,s){return t.set(lt(t,e),s),s}var X,mt,Z,_t,gt,xt,bt,yt,Ut,wt,St,vt,Bt,zt,kt,It,Et,Ct,Pt,At,Ft,Tt,Dt,Lt,Ht,Mt,Ot,Rt,Nt,Vt,Gt,jt,$t,qt,Yt,Wt,Kt,Jt,Qt,Xt,Zt,te,ee,se,ie,re,ae,ne,oe,he,le,de,ce,pe,ue,tt,fe,me,_e,ge,xe,be,ye,Ue,we,Se,ve,Be,ze,ke,Ie,Ee,Ce,Pe,Ae,Fe,Te,De,Le,He,Me,Oe,Re,Ne,Ve,Ge,je,$e,qe,Ye,We,Ke,Je,Qe,Xe,Ze,ts,es,ss,is,rs,as,ns,os,hs,ls,ds,cs,ps,us,fs,ms,_s,gs,xs,bs,ys,Us,ws,Ss,vs,Bs,zs,ks,Is,Es,Cs,Ps,As,Fs,Ts,Ds,Ls,Hs,Ms,Os,Rs,Ns,Vs,Gs,js,$s,qs=2**32,B=2**32-1,Yn=131072,R=class Ya extends ArrayBuffer{constructor(e){super(e),this.fileStart=0,this.usedBytes=0}static fromArrayBuffer(e,s){let i=new Ya(e.byteLength);return new Uint8Array(i).set(new Uint8Array(e)),i.fileStart=s,i}},C=(X=new WeakSet,mt=class b{constructor(e,s,i){Gn(this,X),this._byteLength=0,this.failurePosition=0,this._dynamicSize=1,this._byteOffset=s||0,e instanceof ArrayBuffer?this.buffer=R.fromArrayBuffer(e,0):e instanceof DataView?(this.dataView=e,s&&(this._byteOffset+=s)):this.buffer=new R(e||0),this.position=0,this.endianness=i||1}getPosition(){return this.position}_realloc(e){if(!this._dynamicSize)return;let s=this._byteOffset+this.position+e,i=this._buffer.byteLength;if(s<=i){s>this._byteLength&&(this._byteLength=s);return}for(i<1&&(i=1);s>i;)i*=2;let r=new R(i),a=new Uint8Array(this._buffer);new Uint8Array(r,0,a.length).set(a),this.buffer=r,this._byteLength=s}_trimAlloc(){if(this._byteLength===this._buffer.byteLength)return;let e=new R(this._byteLength),s=new Uint8Array(e),i=new Uint8Array(this._buffer,0,s.length);s.set(i),this.buffer=e}get byteLength(){return this._byteLength-this._byteOffset}get buffer(){return this._trimAlloc(),this._buffer}set buffer(e){this._buffer=e,this._dataView=new DataView(e,this._byteOffset),this._byteLength=e.byteLength}get byteOffset(){return this._byteOffset}set byteOffset(e){this._byteOffset=e,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._buffer.byteLength}get dataView(){return this._dataView}set dataView(e){this._byteOffset=e.byteOffset,this._buffer=R.fromArrayBuffer(e.buffer,0),this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._byteOffset+e.byteLength}seek(e){let s=Math.max(0,Math.min(this.byteLength,e));this.position=isNaN(s)||!isFinite(s)?0:s}isEof(){return this.position>=this._byteLength}mapUint8Array(e){this._realloc(e*1);let s=new Uint8Array(this._buffer,this.byteOffset+this.position,e);return this.position+=e*1,s}readInt32Array(e,s){e=e===void 0?this.byteLength-this.position/4:e;let i=new Int32Array(e);return b.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),b.arrayToNative(i,s??this.endianness),this.position+=i.byteLength,i}readInt16Array(e,s){e=e===void 0?this.byteLength-this.position/2:e;let i=new Int16Array(e);return b.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),b.arrayToNative(i,s??this.endianness),this.position+=i.byteLength,i}readInt8Array(e){e=e===void 0?this.byteLength-this.position:e;let s=new Int8Array(e);return b.memcpy(s.buffer,0,this.buffer,this.byteOffset+this.position,e*s.BYTES_PER_ELEMENT),this.position+=s.byteLength,s}readUint32Array(e,s){e=e===void 0?this.byteLength-this.position/4:e;let i=new Uint32Array(e);return b.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),b.arrayToNative(i,s??this.endianness),this.position+=i.byteLength,i}readUint16Array(e,s){e=e===void 0?this.byteLength-this.position/2:e;let i=new Uint16Array(e);return b.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),b.arrayToNative(i,s??this.endianness),this.position+=i.byteLength,i}readUint8Array(e){e=e===void 0?this.byteLength-this.position:e;let s=new Uint8Array(e);return b.memcpy(s.buffer,0,this.buffer,this.byteOffset+this.position,e*s.BYTES_PER_ELEMENT),this.position+=s.byteLength,s}readFloat64Array(e,s){e=e===void 0?this.byteLength-this.position/8:e;let i=new Float64Array(e);return b.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),b.arrayToNative(i,s??this.endianness),this.position+=i.byteLength,i}readFloat32Array(e,s){e=e===void 0?this.byteLength-this.position/4:e;let i=new Float32Array(e);return b.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,e*i.BYTES_PER_ELEMENT),b.arrayToNative(i,s??this.endianness),this.position+=i.byteLength,i}readInt32(e){let s=this._dataView.getInt32(this.position,(e??this.endianness)===2);return this.position+=4,s}readInt16(e){let s=this._dataView.getInt16(this.position,(e??this.endianness)===2);return this.position+=2,s}readInt8(){let e=this._dataView.getInt8(this.position);return this.position+=1,e}readUint32(e){let s=this._dataView.getUint32(this.position,(e??this.endianness)===2);return this.position+=4,s}readUint16(e){let s=this._dataView.getUint16(this.position,(e??this.endianness)===2);return this.position+=2,s}readUint8(){let e=this._dataView.getUint8(this.position);return this.position+=1,e}readFloat32(e){let s=this._dataView.getFloat32(this.position,(e??this.endianness)===2);return this.position+=4,s}readFloat64(e){let s=this._dataView.getFloat64(this.position,(e??this.endianness)===2);return this.position+=8,s}static memcpy(e,s,i,r,a){let n=new Uint8Array(e,s,a),o=new Uint8Array(i,r,a);n.set(o)}static arrayToNative(e,s){return s===b.ENDIANNESS?e:this.flipArrayEndianness(e)}static nativeToEndian(e,s){return s&&b.ENDIANNESS===2?e:this.flipArrayEndianness(e)}static flipArrayEndianness(e){let s=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);for(let i=0;i<e.byteLength;i+=e.BYTES_PER_ELEMENT)for(let r=i+e.BYTES_PER_ELEMENT-1,a=i;r>a;r--,a++){let n=s[a];s[a]=s[r],s[r]=n}return e}readString(e,s){return s===void 0||s==="ASCII"?Oa(this.mapUint8Array(e===void 0?this.byteLength-this.position:e)):new TextDecoder(s).decode(this.mapUint8Array(e))}readCString(e){let s=0,i=this.byteLength-this.position,r=new Uint8Array(this._buffer,this._byteOffset+this.position),a=e===void 0?i:Math.min(e,i);for(;s<a&&r[s]!==0;s++);let n=Oa(this.mapUint8Array(s));return e===void 0?s!==i&&(this.position+=1):this.position+=a-s,n}readInt64(){return this.readInt32()*qs+this.readUint32()}readUint64(){return this.readUint32()*qs+this.readUint32()}readUint24(){return(this.readUint8()<<16)+(this.readUint8()<<8)+this.readUint8()}save(e){let s=new Blob([this.buffer]);if(typeof window<"u"&&typeof document<"u")if(window.URL&&URL.createObjectURL){let i=window.URL.createObjectURL(s),r=document.createElement("a");document.body.appendChild(r),r.setAttribute("href",i),r.setAttribute("download",e),r.setAttribute("target","_self"),r.click(),window.URL.revokeObjectURL(i),document.body.removeChild(r)}else throw Error("DataStream.save: Can't create object URL.");return s}get dynamicSize(){return this._dynamicSize}set dynamicSize(e){e||this._trimAlloc(),this._dynamicSize=e}shift(e){let s=new R(this._byteLength-e),i=new Uint8Array(s),r=new Uint8Array(this._buffer,e,i.length);i.set(r),this.buffer=s,this.position-=e}writeInt32Array(e,s){if(this._realloc(e.length*4),e instanceof Int32Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)b.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapInt32Array(e.length,s);else for(let i=0;i<e.length;i++)this.writeInt32(e[i],s)}writeInt16Array(e,s){if(this._realloc(e.length*2),e instanceof Int16Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)b.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapInt16Array(e.length,s);else for(let i=0;i<e.length;i++)this.writeInt16(e[i],s)}writeInt8Array(e){if(this._realloc(e.length*1),e instanceof Int8Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)b.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapInt8Array(e.length);else for(let s=0;s<e.length;s++)this.writeInt8(e[s])}writeUint32Array(e,s){if(this._realloc(e.length*4),e instanceof Uint32Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)b.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapUint32Array(e.length,s);else for(let i=0;i<e.length;i++)this.writeUint32(e[i],s)}writeUint16Array(e,s){if(this._realloc(e.length*2),e instanceof Uint16Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)b.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapUint16Array(e.length,s);else for(let i=0;i<e.length;i++)this.writeUint16(e[i],s)}writeUint8Array(e){if(this._realloc(e.length*1),e instanceof Uint8Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)b.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapUint8Array(e.length);else for(let s=0;s<e.length;s++)this.writeUint8(e[s])}writeFloat64Array(e,s){if(this._realloc(e.length*8),e instanceof Float64Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)b.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapFloat64Array(e.length,s);else for(let i=0;i<e.length;i++)this.writeFloat64(e[i],s)}writeFloat32Array(e,s){if(this._realloc(e.length*4),e instanceof Float32Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0)b.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength),this.mapFloat32Array(e.length,s);else for(let i=0;i<e.length;i++)this.writeFloat32(e[i],s)}writeInt64(e,s){this._realloc(8),this._dataView.setBigInt64(this.position,BigInt(e),(s??this.endianness)===2),this.position+=8}writeInt32(e,s){this._realloc(4),this._dataView.setInt32(this.position,e,(s??this.endianness)===2),this.position+=4}writeInt16(e,s){this._realloc(2),this._dataView.setInt16(this.position,e,(s??this.endianness)===2),this.position+=2}writeInt8(e){this._realloc(1),this._dataView.setInt8(this.position,e),this.position+=1}writeUint32(e,s){this._realloc(4),this._dataView.setUint32(this.position,e,(s??this.endianness)===2),this.position+=4}writeUint16(e,s){this._realloc(2),this._dataView.setUint16(this.position,e,(s??this.endianness)===2),this.position+=2}writeUint8(e){this._realloc(1),this._dataView.setUint8(this.position,e),this.position+=1}writeFloat32(e,s){this._realloc(4),this._dataView.setFloat32(this.position,e,(s??this.endianness)===2),this.position+=4}writeFloat64(e,s){this._realloc(8),this._dataView.setFloat64(this.position,e,(s??this.endianness)===2),this.position+=8}writeUCS2String(e,s,i){i===void 0&&(i=e.length);let r=0;for(;r<e.length&&r<i;r++)this.writeUint16(e.charCodeAt(r),s);for(;r<i;r++)this.writeUint16(0)}writeString(e,s,i){let r=0;if(s===void 0||s==="ASCII")if(i!==void 0){let a=Math.min(e.length,i);for(r=0;r<a;r++)this.writeUint8(e.charCodeAt(r));for(;r<i;r++)this.writeUint8(0)}else for(r=0;r<e.length;r++)this.writeUint8(e.charCodeAt(r));else this.writeUint8Array(new TextEncoder(s).encode(e.substring(0,i)))}writeCString(e,s){let i=0;if(s!==void 0){let r=Math.min(e.length,s);for(i=0;i<r;i++)this.writeUint8(e.charCodeAt(i));for(;i<s;i++)this.writeUint8(0)}else{for(i=0;i<e.length;i++)this.writeUint8(e.charCodeAt(i));this.writeUint8(0)}}writeStruct(e,s){for(let i=0;i<e.length;i++){let[r,a]=e[i],n=s[r];this.writeType(a,n,s)}}writeType(e,s,i){if(typeof e=="function")return e(this,s);if(typeof e=="object"&&!(e instanceof Array))return e.set(this,s,i);let r,a="ASCII",n=this.position,o=e;if(typeof e=="string"&&/:/.test(e)){let l=e.split(":");o=l[0],r=parseInt(l[1])}if(typeof o=="string"&&/,/.test(o)){let l=o.split(",");o=l[0],a=l[1]}switch(o){case"uint8":this.writeUint8(s);break;case"int8":this.writeInt8(s);break;case"uint16":this.writeUint16(s,this.endianness);break;case"int16":this.writeInt16(s,this.endianness);break;case"uint32":this.writeUint32(s,this.endianness);break;case"int32":this.writeInt32(s,this.endianness);break;case"float32":this.writeFloat32(s,this.endianness);break;case"float64":this.writeFloat64(s,this.endianness);break;case"uint16be":this.writeUint16(s,1);break;case"int16be":this.writeInt16(s,1);break;case"uint32be":this.writeUint32(s,1);break;case"int32be":this.writeInt32(s,1);break;case"float32be":this.writeFloat32(s,1);break;case"float64be":this.writeFloat64(s,1);break;case"uint16le":this.writeUint16(s,2);break;case"int16le":this.writeInt16(s,2);break;case"uint32le":this.writeUint32(s,2);break;case"int32le":this.writeInt32(s,2);break;case"float32le":this.writeFloat32(s,2);break;case"float64le":this.writeFloat64(s,2);break;case"cstring":this.writeCString(s,r);break;case"string":this.writeString(s,a,r);break;case"u16string":this.writeUCS2String(s,this.endianness,r);break;case"u16stringle":this.writeUCS2String(s,2,r);break;case"u16stringbe":this.writeUCS2String(s,1,r);break;default:if(lt(X,this,Ma).call(this,o)){let[,l]=o;for(let h=0;h<s.length;h++)this.writeType(l,s[h]);break}this.writeStruct(o,s)}r&&(this.position=n,this._realloc(r),this.position=n+r)}writeUint64(e){let s=Math.floor(e/qs);this.writeUint32(s),this.writeUint32(e|0)}writeUint24(e){this.writeUint8((e&16711680)>>16),this.writeUint8((e&65280)>>8),this.writeUint8(e&255)}adjustUint32(e,s){let i=this.position;this.seek(e),this.writeUint32(s),this.seek(i)}readStruct(e){let s={},i=this.position;for(let r=0;r<e.length;r+=1){let a=e[r][1],n=this.readType(a,s);if(!n){this.failurePosition===0&&(this.failurePosition=this.position),this.position=i;return}s[e[r][0]]=n}return s}readUCS2String(e,s){return String.fromCharCode.apply(void 0,this.readUint16Array(e,s))}readType(e,s){if(typeof e=="function")return e(this,s);if(typeof e=="object"&&!(e instanceof Array))return e.get(this,s);if(e instanceof Array&&e.length!==3)return this.readStruct(e);let i,r,a="ASCII",n=this.position,o=e;if(typeof o=="string"&&/:/.test(o)){let l=o.split(":");o=l[0],r=parseInt(l[1])}if(typeof o=="string"&&/,/.test(o)){let l=o.split(",");o=l[0],a=l[1]}switch(o){case"uint8":i=this.readUint8();break;case"int8":i=this.readInt8();break;case"uint16":i=this.readUint16(this.endianness);break;case"int16":i=this.readInt16(this.endianness);break;case"uint32":i=this.readUint32(this.endianness);break;case"int32":i=this.readInt32(this.endianness);break;case"float32":i=this.readFloat32(this.endianness);break;case"float64":i=this.readFloat64(this.endianness);break;case"uint16be":i=this.readUint16(1);break;case"int16be":i=this.readInt16(1);break;case"uint32be":i=this.readUint32(1);break;case"int32be":i=this.readInt32(1);break;case"float32be":i=this.readFloat32(1);break;case"float64be":i=this.readFloat64(1);break;case"uint16le":i=this.readUint16(2);break;case"int16le":i=this.readInt16(2);break;case"uint32le":i=this.readUint32(2);break;case"int32le":i=this.readInt32(2);break;case"float32le":i=this.readFloat32(2);break;case"float64le":i=this.readFloat64(2);break;case"cstring":i=this.readCString(r);break;case"string":i=this.readString(r,a);break;case"u16string":i=this.readUCS2String(r,this.endianness);break;case"u16stringle":i=this.readUCS2String(r,2);break;case"u16stringbe":i=this.readUCS2String(r,1);break;default:if(lt(X,this,Ma).call(this,o)){let[,l,h]=o,c=typeof h=="function"?h(s,this,o):typeof h=="string"&&s[h]!==void 0?parseInt(s[h]):typeof h=="number"?h:h==="*"?void 0:parseInt(h);if(typeof l=="string"){let u=l.replace(/(le|be)$/,""),m;switch(/le$/.test(l)?m=2:/be$/.test(l)&&(m=1),u){case"uint8":i=this.readUint8Array(c);break;case"uint16":i=this.readUint16Array(c,m);break;case"uint32":i=this.readUint32Array(c,m);break;case"int8":i=this.readInt8Array(c);break;case"int16":i=this.readInt16Array(c,m);break;case"int32":i=this.readInt32Array(c,m);break;case"float32":i=this.readFloat32Array(c,m);break;case"float64":i=this.readFloat64Array(c,m);break;case"cstring":case"utf16string":case"string":if(c){i=Array(c);for(let _=0;_<c;_++)i[_]=this.readType(l,s)}else for(i=[];!this.isEof();){let _=this.readType(l,s);if(!_)break;i.push(_)}}}else if(c){i=Array(c);for(let u=0;u<c;u++){let m=this.readType(l,s);if(!m)return;i[u]=m}}else for(i=[];;){let u=this.position;try{let m=this.readType(l,s);if(!m){this.position=u;break}i.push(m)}catch{this.position=u;break}}break}}return r&&(this.position=n+r),i}mapInt32Array(e,s){this._realloc(e*4);let i=new Int32Array(this._buffer,this.byteOffset+this.position,e);return b.arrayToNative(i,s??this.endianness),this.position+=e*4,i}mapInt16Array(e,s){this._realloc(e*2);let i=new Int16Array(this._buffer,this.byteOffset+this.position,e);return b.arrayToNative(i,s??this.endianness),this.position+=e*2,i}mapInt8Array(e,s){this._realloc(e*1);let i=new Int8Array(this._buffer,this.byteOffset+this.position,e);return this.position+=e*1,i}mapUint32Array(e,s){this._realloc(e*4);let i=new Uint32Array(this._buffer,this.byteOffset+this.position,e);return b.arrayToNative(i,s??this.endianness),this.position+=e*4,i}mapUint16Array(e,s){this._realloc(e*2);let i=new Uint16Array(this._buffer,this.byteOffset+this.position,e);return b.arrayToNative(i,s??this.endianness),this.position+=e*2,i}mapFloat64Array(e,s){this._realloc(e*8);let i=new Float64Array(this._buffer,this.byteOffset+this.position,e);return b.arrayToNative(i,s??this.endianness),this.position+=e*8,i}mapFloat32Array(e,s){this._realloc(e*4);let i=new Float32Array(this._buffer,this.byteOffset+this.position,e);return b.arrayToNative(i,s??this.endianness),this.position+=e*4,i}},mt.ENDIANNESS=new Int8Array(new Int16Array([1]).buffer)[0]>0?2:1,mt);function Ma(t){return Array.isArray(t)&&t.length===3&&t[0]==="[]"}function Oa(t){let e=[];for(let s=0;s<t.length;s++)e[s]=t[s];return String.fromCharCode.apply(void 0,e)}var et=new Date,Ea=4,Ra=3,Na=2,Va=1,Y=Ea,d={setLogLevel(t){Y=t===this.debug?Va:t===this.info?Na:t===this.warn?Ra:(this.error,Ea)},debug(t,e){console.debug===void 0&&(console.debug=console.log),Va>=Y&&console.debug("["+d.getDurationString(new Date().getTime()-et.getTime(),1e3)+"]","["+t+"]",e)},log(t,e){this.debug(t.msg)},info(t,e){Na>=Y&&console.info("["+d.getDurationString(new Date().getTime()-et.getTime(),1e3)+"]","["+t+"]",e)},warn(t,e){Ra>=Y&&console.warn("["+d.getDurationString(new Date().getTime()-et.getTime(),1e3)+"]","["+t+"]",e)},error(t,e,s){s!=null&&s.onError?s.onError(t,e):Ea>=Y&&console.error("["+d.getDurationString(new Date().getTime()-et.getTime(),1e3)+"]","["+t+"]",e)},getDurationString(t,e){let s;function i(l,h){let c=(""+l).split(".");for(;c[0].length<h;)c[0]="0"+c[0];return c.join(".")}t<0?(s=true,t=-t):s=false;let r=t/(e||1),a=Math.floor(r/3600);r-=a*3600;let n=Math.floor(r/60);r-=n*60;let o=r*1e3;return r=Math.floor(r),o-=r*1e3,o=Math.floor(o),(s?"-":"")+a+":"+i(n,2)+":"+i(r,2)+"."+i(o,3)},printRanges(t){let e=t.length;if(e>0){let s="";for(let i=0;i<e;i++)i>0&&(s+=","),s+="["+d.getDurationString(t.start(i))+","+d.getDurationString(t.end(i))+"]";return s}return"(empty)"}};function Wn(t,e){d.debug("ArrayBuffer","Trying to create a new buffer of size: "+(t.byteLength+e.byteLength));let s=new Uint8Array(t.byteLength+e.byteLength);return s.set(new Uint8Array(t),0),s.set(new Uint8Array(e),t.byteLength),s.buffer}var at=class extends C{constructor(t){super(new ArrayBuffer,0),this.buffers=[],this.bufferIndex=-1,t&&(this.insertBuffer(t),this.bufferIndex=0)}initialized(){if(this.bufferIndex>-1)return true;if(this.buffers.length>0){let t=this.buffers[0];return t.fileStart===0?(this.buffer=t,this.bufferIndex=0,d.debug("MultiBufferStream","Stream ready for parsing"),true):(d.warn("MultiBufferStream","The first buffer should have a fileStart of 0"),this.logBufferLevel(),false)}return d.warn("MultiBufferStream","No buffer to start parsing from"),this.logBufferLevel(),false}reduceBuffer(t,e,s){let i=new Uint8Array(s);return i.set(new Uint8Array(t,e,s)),i.buffer.fileStart=t.fileStart+e,i.buffer.usedBytes=0,i.buffer}insertBuffer(t){let e=true,s=0;for(;s<this.buffers.length;s++){let i=this.buffers[s];if(t.fileStart<=i.fileStart){if(t.fileStart===i.fileStart){if(t.byteLength>i.byteLength){this.buffers.splice(s,1),s--;continue}d.warn("MultiBufferStream","Buffer (fileStart: "+t.fileStart+" - Length: "+t.byteLength+") already appended, ignoring")}else t.fileStart+t.byteLength<=i.fileStart||(t=this.reduceBuffer(t,0,i.fileStart-t.fileStart)),d.debug("MultiBufferStream","Appending new buffer (fileStart: "+t.fileStart+" - Length: "+t.byteLength+")"),this.buffers.splice(s,0,t),s===0&&(this.buffer=t);e=false;break}if(t.fileStart<i.fileStart+i.byteLength){let r=i.fileStart+i.byteLength-t.fileStart,a=t.byteLength-r;if(a>0)t=this.reduceBuffer(t,r,a);else{e=false;break}}}e&&(d.debug("MultiBufferStream","Appending new buffer (fileStart: "+t.fileStart+" - Length: "+t.byteLength+")"),this.buffers.push(t),s===0&&(this.buffer=t))}logBufferLevel(t){let e=[],s="",i,r=0,a=0;for(let o=0;o<this.buffers.length;o++){let l=this.buffers[o];o===0?(i={start:l.fileStart,end:l.fileStart+l.byteLength},e.push(i),s+="["+i.start+"-"):i.end===l.fileStart?i.end=l.fileStart+l.byteLength:(i={start:l.fileStart,end:l.fileStart+l.byteLength},s+=e[e.length-1].end-1+"], ["+i.start+"-",e.push(i)),r+=l.usedBytes,a+=l.byteLength}e.length>0&&(s+=i.end-1+"]");let n=t?d.info:d.debug;this.buffers.length===0?n("MultiBufferStream","No more buffer in memory"):n("MultiBufferStream",""+this.buffers.length+" stored buffer(s) ("+r+"/"+a+" bytes), continuous ranges: "+s)}cleanBuffers(){for(let t=0;t<this.buffers.length;t++){let e=this.buffers[t];e.usedBytes===e.byteLength&&(d.debug("MultiBufferStream","Removing buffer #"+t),this.buffers.splice(t,1),t--)}}mergeNextBuffer(){if(this.bufferIndex+1<this.buffers.length){let t=this.buffers[this.bufferIndex+1];if(t.fileStart===this.buffer.fileStart+this.buffer.byteLength){let e=this.buffer.byteLength,s=this.buffer.usedBytes,i=this.buffer.fileStart;return this.buffers[this.bufferIndex]=Wn(this.buffer,t),this.buffer=this.buffers[this.bufferIndex],this.buffers.splice(this.bufferIndex+1,1),this.buffer.usedBytes=s,this.buffer.fileStart=i,d.debug("ISOFile","Concatenating buffer for box parsing (length: "+e+"->"+this.buffer.byteLength+")"),true}return false}return false}findPosition(t,e,s){let i=-1,r=t===true?0:this.bufferIndex;for(;r<this.buffers.length;){let n=this.buffers[r];if(n&&n.fileStart<=e)i=r,s&&(n.usedBytes=n.fileStart+n.byteLength<=e?n.byteLength:e-n.fileStart,this.logBufferLevel());else break;r++}if(i===-1)return-1;let a=this.buffers[i];return a.fileStart+a.byteLength>=e?(d.debug("MultiBufferStream","Found position in existing buffer #"+i),i):-1}findEndContiguousBuf(t){let e=t===void 0?this.bufferIndex:t,s=this.buffers[e];if(this.buffers.length>e+1)for(let i=e+1;i<this.buffers.length;i++){let r=this.buffers[i];if(r.fileStart===s.fileStart+s.byteLength)s=r;else break}return s.fileStart+s.byteLength}getEndFilePositionAfter(t){let e=this.findPosition(true,t,false);return e===-1?t:this.findEndContiguousBuf(e)}addUsedBytes(t){this.buffer.usedBytes+=t,this.logBufferLevel()}setAllUsedBytes(){this.buffer.usedBytes=this.buffer.byteLength,this.logBufferLevel()}seek(t,e,s){let i=this.findPosition(e,t,s);return i===-1?(d.debug("MultiBufferStream","Position "+t+" not found in buffered data"),false):(this.buffer=this.buffers[i],this.bufferIndex=i,this.position=t-this.buffer.fileStart,d.debug("MultiBufferStream","Repositioning parser at buffer position: "+this.position),true)}getPosition(){return this.bufferIndex===-1||this.buffers[this.bufferIndex]===void 0?0:this.buffers[this.bufferIndex].fileStart+this.position}getLength(){return this.byteLength}getEndPosition(){return this.bufferIndex===-1||this.buffers[this.bufferIndex]===void 0?0:this.buffers[this.bufferIndex].fileStart+this.byteLength}getAbsoluteEndPosition(){if(this.buffers.length===0)return 0;let t=this.buffers[this.buffers.length-1];return t.fileStart+t.byteLength}},f=(Z=new WeakMap,_t=class{get type(){return this.constructor.fourcc??$n(Z,this)}set type(t){qn(Z,this,t)}constructor(t=0){jn(this,Z,void 0),this.size=t}addBox(t){return this.boxes||(this.boxes=[]),this.boxes.push(t),this[t.type+"s"]?this[t.type+"s"].push(t):this[t.type]=t,t}set(t,e){return this[t]=e,this}addEntry(t,e){let s=e||"entries";return this[s]||(this[s]=[]),this[s].push(t),this}writeHeader(t,e){if(this.size+=8,(this.size>B||this.original_size===1)&&(this.size+=8),this.type==="uuid"&&(this.size+=16),d.debug("BoxWriter","Writing box "+this.type+" of size: "+this.size+" at position "+t.getPosition()+(e||"")),this.original_size===0?t.writeUint32(0):this.size>B||this.original_size===1?t.writeUint32(1):(this.sizePosition=t.getPosition(),t.writeUint32(this.size)),t.writeString(this.type,void 0,4),this.type==="uuid"){let s=new Uint8Array(16);for(let i=0;i<16;i++)s[i]=parseInt(this.uuid.substring(i*2,i*2+2),16);t.writeUint8Array(s)}(this.size>B||this.original_size===1)&&(this.sizePosition=t.getPosition(),t.writeUint64(this.size))}write(t){if(this.type==="mdat"){let e=this;if(e.stream){this.size=e.stream.getAbsoluteEndPosition(),this.writeHeader(t);for(let s of e.stream.buffers){let i=new Uint8Array(s);t.writeUint8Array(i)}}else e.data&&(this.size=e.data.length,this.writeHeader(t),t.writeUint8Array(e.data))}else this.size=this.data?this.data.length:0,this.writeHeader(t),this.data&&t.writeUint8Array(this.data)}printHeader(t){this.size+=8,this.size>B&&(this.size+=8),this.type==="uuid"&&(this.size+=16),t.log(t.indent+"size:"+this.size),t.log(t.indent+"type:"+this.type)}print(t){this.printHeader(t)}parse(t){this.type==="mdat"?this.size===0?t.seek(t.getEndPosition()):t.seek(this.start+this.size):this.data=t.readUint8Array(this.size-this.hdr_size)}parseDataAndRewind(t){this.data=t.readUint8Array(this.size-this.hdr_size),t.seek(this.start+this.hdr_size)}parseLanguage(t){this.language=t.readUint16();let e=[];e[0]=this.language>>10&31,e[1]=this.language>>5&31,e[2]=this.language&31,this.languageString=String.fromCharCode(e[0]+96,e[1]+96,e[2]+96)}computeSize(t){let e=t||new at;this.write(e)}isEndOfBox(t){return t.getPosition()===this.start+this.size}},_t.registryId=Symbol.for("BoxIdentifier"),_t),p=class extends f{constructor(...t){super(...t),this.flags=0,this.version=0}writeHeader(t){this.size+=4,super.writeHeader(t," v="+this.version+" f="+this.flags),t.writeUint8(this.version),t.writeUint24(this.flags)}printHeader(t){this.size+=4,super.printHeader(t),t.log(t.indent+"version:"+this.version),t.log(t.indent+"flags:"+this.flags)}parseDataAndRewind(t){this.parseFullHeader(t),this.data=t.readUint8Array(this.size-this.hdr_size),this.hdr_size-=4,t.seek(this.start+this.hdr_size)}parseFullHeader(t){this.version=t.readUint8(),this.flags=t.readUint24(),this.hdr_size+=4}parse(t){this.parseFullHeader(t),this.data=t.readUint8Array(this.size-this.hdr_size)}},v=(gt=class{constructor(t){this.grouping_type=t}write(t){t.writeUint8Array(this.data)}parse(t){d.warn("BoxParser",`Unknown sample group type: '${this.grouping_type}'`),this.data=t.readUint8Array(this.description_length)}},gt.registryId=Symbol.for("SampleGroupEntryIdentifier"),gt),Wa=class extends p{parse(t){this.parseFullHeader(t),this.track_group_id=t.readUint32()}},Kn=class extends f{constructor(t,e,s,i,r){super(e),this.box_name=s,this.hdr_size=i,this.start=r,this.type=t}parse(t){this.from_item_ID=t.readUint16();let e=t.readUint16();this.references=[];for(let s=0;s<e;s++)this.references[s]={to_item_ID:t.readUint16()}}},Jn=class extends f{constructor(t,e,s,i,r){super(e),this.box_name=s,this.hdr_size=i,this.start=r,this.type=t}parse(t){this.from_item_ID=t.readUint32();let e=t.readUint16();this.references=[];for(let s=0;s<e;s++)this.references[s]={to_item_ID:t.readUint32()}}},Ka=class extends f{constructor(t,e,s,i){super(e),this.hdr_size=s,this.start=i,this.type=t}parse(t){this.track_ids=t.readUint32Array((this.size-this.hdr_size)/4)}write(t){this.size=this.track_ids.length*4,this.writeHeader(t),t.writeUint32Array(this.track_ids)}},Ca=["boxes","entries","references","subsamples","items","item_infos","extents","associations","subsegments","ranges","seekLists","seekPoints","esd","levels"],Qn=["compatible_brands","matrix","opcolor","sample_counts","sample_deltas","first_chunk","samples_per_chunk","sample_sizes","chunk_offsets","sample_offsets","sample_description_index","sample_duration"];function Xn(t,e){if(t&&!e)return false;let s;for(s in t)if(!Ca.find(i=>i===s)){if(t[s]instanceof f||e[s]instanceof f)continue;if(t[s]===void 0||e[s]===void 0)continue;if(typeof t[s]=="function"||typeof e[s]=="function")continue;if("subBoxNames"in t&&t.subBoxNames.indexOf(s.slice(0,4))>-1||"subBoxNames"in e&&e.subBoxNames.indexOf(s.slice(0,4))>-1)continue;if(s==="data"||s==="start"||s==="size"||s==="creation_time"||s==="modification_time")continue;if(Qn.find(i=>i===s))continue;if(t[s]!==e[s])return false}return true}function Ja(t,e){if(!Xn(t,e))return false;for(let s=0;s<Ca.length;s++){let i=Ca[s];if(t[i]&&e[i]&&!Ja(t[i],e[i]))return false}return true}function Fa(t){let e=t;for(;e;){if("registryId"in e)return e.registryId;e=Object.getPrototypeOf(e)}}var Zn=t=>{let e=Symbol.for("SampleGroupEntryIdentifier");return Fa(t)===e},to=t=>{let e=Symbol.for("SampleEntryIdentifier");return Fa(t)===e},eo=t=>{let e=Symbol.for("BoxIdentifier");return Fa(t)===e},P={uuid:{},sampleEntry:{},sampleGroupEntry:{},box:{}};function so(t){let e={uuid:{},sampleEntry:{},sampleGroupEntry:{},box:{}};for(let[s,i]of Object.entries(t))if(Zn(i)){let r="grouping_type"in i?i.grouping_type:void 0;if(!r)throw Error(`SampleGroupEntry class ${s} does not have a valid static grouping_type. Please ensure it is defined correctly.`);if(r in e.sampleGroupEntry)throw Error(`SampleGroupEntry class ${s} has a grouping_type that is already registered. Please ensure it is unique.`);e.sampleGroupEntry[r]=i}else if(to(i)){let r="fourcc"in i?i.fourcc:void 0;if(!r)throw Error(`SampleEntry class ${s} does not have a valid static fourcc. Please ensure it is defined correctly.`);if(r in e.sampleEntry)throw Error(`SampleEntry class ${s} has a fourcc that is already registered. Please ensure it is unique.`);e.sampleEntry[r]=i}else if(eo(i)){let r="fourcc"in i?i.fourcc:void 0,a="uuid"in i?i.uuid:void 0;if(r==="uuid"){if(!a)throw Error(`Box class ${s} has a fourcc of 'uuid' but does not have a valid uuid. Please ensure it is defined correctly.`);if(a in e.uuid)throw Error(`Box class ${s} has a uuid that is already registered. Please ensure it is unique.`);e.uuid[a]=i;continue}e.box[r]=i}else throw Error(`Box class ${s} does not have a valid static fourcc, uuid, or grouping_type. Please ensure it is defined correctly.`);return P.uuid={...e.uuid},P.sampleEntry={...e.sampleEntry},P.sampleGroupEntry={...e.sampleGroupEntry},P.box={...e.box},P}var dt={};function io(t){return Object.entries(t).forEach(([e,s])=>dt[e]=s),dt}function ro(t){return V(t)}function V(t){let e="";for(let s=0;s<16;s++){let i=t.readUint8().toString(16);e+=i.length===1?"0"+i:i}return e}function H(t,e,s){let i,r,a=t.getPosition(),n=0,o;if(t.getEndPosition()-a<8)return d.debug("BoxParser","Not enough data in stream to parse the type and size of the box"),{code:0};if(s&&s<8)return d.debug("BoxParser","Not enough bytes left in the parent box to parse a new box"),{code:0};let l=t.readUint32(),h=t.readString(4);if(h.length!==4||!/^[\x20-\x7E]{4}$/.test(h))return d.error("BoxParser",`Invalid box type: '${h}'`),{code:-1,start:a,type:h};let c=h;if(d.debug("BoxParser","Found box of type '"+h+"' and size "+l+" at position "+a),n=8,h==="uuid"){if(t.getEndPosition()-t.getPosition()<16||s-n<16)return t.seek(a),d.debug("BoxParser","Not enough bytes left in the parent box to parse a UUID box"),{code:0};o=ro(t),n+=16,c=o}if(l===1){if(t.getEndPosition()-t.getPosition()<8||s&&s-n<8)return t.seek(a),d.warn("BoxParser",'Not enough data in stream to parse the extended size of the "'+h+'" box'),{code:0};r=l,l=t.readUint64(),n+=8}else if(l===0)if(s)l=s;else{if(h!=="mdat")return d.error("BoxParser","Unlimited box size not supported for type: '"+h+"'"),i=new f(l),i.type=h,{code:1,box:i,size:i.size};l=t.getEndPosition()-a}if(l!==0&&l<n)return d.error("BoxParser","Box of type "+h+" has an invalid size "+l+" (too small to be a box)"),{code:0,type:h,size:l,hdr_size:n,start:a};if(l!==0&&s&&l>s)return d.error("BoxParser","Box of type '"+h+"' has a size "+l+" greater than its container size "+s),{code:0,type:h,size:l,hdr_size:n,start:a};if(l!==0&&a+l>t.getEndPosition())return t.seek(a),d.info("BoxParser","Not enough data in stream to parse the entire '"+h+"' box"),{code:0,type:h,size:l,hdr_size:n,start:a,original_size:r};if(e)return{code:1,type:h,size:l,hdr_size:n,start:a};h in P.box?i=new P.box[h](l):h==="uuid"?o in P.uuid?i=new P.uuid[o](l):(d.warn("BoxParser",`Unknown UUID box type: '${o}'`),i=new f(l),i.type=h,i.uuid=o,i.has_unparsed_data=true):(d.warn("BoxParser",`Unknown box type: '${h}'`),i=new f(l),i.type=h,i.has_unparsed_data=true),i.original_size=r,i.hdr_size=n,i.start=a,i.write===f.prototype.write&&i.type!=="mdat"&&(d.info("BoxParser","'"+c+"' box writing not yet implemented, keeping unparsed data in memory for later write"),i.parseDataAndRewind(t)),i.parse(t);let u=t.getPosition()-(i.start+i.size);return u<0?(d.warn("BoxParser","Parsing of box '"+c+"' did not read the entire indicated box data size (missing "+-u+" bytes), seeking forward"),t.seek(i.start+i.size)):u>0&&i.size!==0&&(d.error("BoxParser","Parsing of box '"+c+"' read "+u+" more bytes than the indicated box data size, seeking backwards"),t.seek(i.start+i.size)),{code:1,box:i,size:i.size}}var x=class extends f{write(t){if(this.size=0,this.writeHeader(t),this.boxes)for(let e=0;e<this.boxes.length;e++)this.boxes[e]&&(this.boxes[e].write(t),this.size+=this.boxes[e].size);d.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),t.adjustUint32(this.sizePosition,this.size)}print(t){this.printHeader(t);for(let e=0;e<this.boxes.length;e++)if(this.boxes[e]){let s=t.indent;t.indent+=" ",this.boxes[e].print(t),t.indent=s}}parse(t){let e;for(;t.getPosition()<this.start+this.size;)if(e=H(t,false,this.size-(t.getPosition()-this.start)),e.code===1){let s=e.box;if(this.boxes||(this.boxes=[]),this.boxes.push(s),this.subBoxNames&&this.subBoxNames.indexOf(s.type)!==-1){let i=this.subBoxNames[this.subBoxNames.indexOf(s.type)]+"s";this[i]||(this[i]=[]),this[i].push(s)}else{let i=s.type==="uuid"?s.uuid:s.type;this[i]?d.warn("ContainerBox",`Box of type ${i} already exists in container box ${this.type}.`):this[i]=s}}else return}},M=(xt=class extends x{constructor(t,e,s){super(t),this.hdr_size=e,this.start=s}isVideo(){return false}isAudio(){return false}isSubtitle(){return false}isMetadata(){return false}isHint(){return false}getCodec(){return this.type.replace(".","")}getWidth(){return""}getHeight(){return""}getChannelCount(){return""}getSampleRate(){return""}getSampleSize(){return""}parseHeader(t){t.readUint8Array(6),this.data_reference_index=t.readUint16(),this.hdr_size+=8}parse(t){this.parseHeader(t),this.data=t.readUint8Array(this.size-this.hdr_size)}parseDataAndRewind(t){this.parseHeader(t),this.data=t.readUint8Array(this.size-this.hdr_size),this.hdr_size-=8,t.seek(this.start+this.hdr_size)}parseFooter(t){super.parse(t)}writeHeader(t){this.size=8,super.writeHeader(t),t.writeUint8(0),t.writeUint8(0),t.writeUint8(0),t.writeUint8(0),t.writeUint8(0),t.writeUint8(0),t.writeUint16(this.data_reference_index)}writeFooter(t){if(this.boxes)for(let e=0;e<this.boxes.length;e++)this.boxes[e].write(t),this.size+=this.boxes[e].size;d.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),t.adjustUint32(this.sizePosition,this.size)}write(t){this.writeHeader(t),t.writeUint8Array(this.data),this.size+=this.data.length,d.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),t.adjustUint32(this.sizePosition,this.size)}},xt.registryId=Symbol.for("SampleEntryIdentifier"),xt),Ga=class extends M{},J=class extends M{isMetadata(){return true}},G=class extends M{isSubtitle(){return true}},ao=class extends M{},w=class extends M{parse(t){this.parseHeader(t),t.readUint16(),t.readUint16(),t.readUint32Array(3),this.width=t.readUint16(),this.height=t.readUint16(),this.horizresolution=t.readUint32(),this.vertresolution=t.readUint32(),t.readUint32(),this.frame_count=t.readUint16();let e=Math.min(31,t.readUint8());this.compressorname=t.readString(e),e<31&&t.readString(31-e),this.depth=t.readUint16(),t.readUint16(),this.parseFooter(t)}isVideo(){return true}getWidth(){return this.width}getHeight(){return this.height}write(t){this.writeHeader(t),this.size+=70,t.writeUint16(0),t.writeUint16(0),t.writeUint32(0),t.writeUint32(0),t.writeUint32(0),t.writeUint16(this.width),t.writeUint16(this.height),t.writeUint32(this.horizresolution),t.writeUint32(this.vertresolution),t.writeUint32(0),t.writeUint16(this.frame_count),t.writeUint8(Math.min(31,this.compressorname.length)),t.writeString(this.compressorname,void 0,31),t.writeUint16(this.depth),t.writeInt16(-1),this.writeFooter(t)}},A=class extends M{parse(t){var e,s;this.parseHeader(t),this.version=t.readUint16(),t.readUint16(),t.readUint32(),this.channel_count=t.readUint16(),this.samplesize=t.readUint16(),t.readUint16(),t.readUint16(),this.samplerate=t.readUint32()/65536,(s=(e=t.isofile)==null?void 0:e.ftyp)!=null&&s.major_brand.includes("qt")&&(this.version===1?this.extensions=t.readUint8Array(16):this.version===2&&(this.extensions=t.readUint8Array(36))),this.parseFooter(t)}isAudio(){return true}getChannelCount(){return this.channel_count}getSampleRate(){return this.samplerate}getSampleSize(){return this.samplesize}write(t){this.writeHeader(t),this.size+=20,t.writeUint32(0),t.writeUint32(0),t.writeUint16(this.channel_count),t.writeUint16(this.samplesize),t.writeUint16(0),t.writeUint16(0),t.writeUint32(this.samplerate<<16),this.writeFooter(t)}},Qa=class extends M{parse(t){this.parseHeader(t),this.parseFooter(t)}write(t){this.writeHeader(t),this.writeFooter(t)}},ja=class extends Array{toString(){let t="<table class='inner-table'>";t+="<thead><tr><th>length</th><th>nalu_data</th></tr></thead>",t+="<tbody>";for(let e=0;e<this.length;e++){let s=this[e];t+="<tr>",t+="<td>"+s.length+"</td>",t+="<td>",t+=s.data.reduce(function(i,r){return i+r.toString(16).padStart(2,"0")},"0x"),t+="</td></tr>"}return t+="</tbody></table>",t}},Xa=(bt=class extends f{constructor(...t){super(...t),this.box_name="AVCConfigurationBox"}parse(t){this.configurationVersion=t.readUint8(),this.AVCProfileIndication=t.readUint8(),this.profile_compatibility=t.readUint8(),this.AVCLevelIndication=t.readUint8(),this.lengthSizeMinusOne=t.readUint8()&3,this.nb_SPS_nalus=t.readUint8()&31;let e=this.size-this.hdr_size-6;this.SPS=new ja;for(let s=0;s<this.nb_SPS_nalus;s++){let i=t.readUint16();this.SPS.push({length:i,data:t.readUint8Array(i)}),e-=2+i}this.nb_PPS_nalus=t.readUint8(),e--,this.PPS=new ja;for(let s=0;s<this.nb_PPS_nalus;s++){let i=t.readUint16();this.PPS.push({length:i,data:t.readUint8Array(i)}),e-=2+i}e>0&&(this.ext=t.readUint8Array(e))}write(t){this.size=7;for(let e=0;e<this.SPS.length;e++)this.size+=2+this.SPS[e].length;for(let e=0;e<this.PPS.length;e++)this.size+=2+this.PPS[e].length;this.ext&&(this.size+=this.ext.length),this.writeHeader(t),t.writeUint8(this.configurationVersion),t.writeUint8(this.AVCProfileIndication),t.writeUint8(this.profile_compatibility),t.writeUint8(this.AVCLevelIndication),t.writeUint8(this.lengthSizeMinusOne+252),t.writeUint8(this.SPS.length+224);for(let e=0;e<this.SPS.length;e++)t.writeUint16(this.SPS[e].length),t.writeUint8Array(this.SPS[e].data);t.writeUint8(this.PPS.length);for(let e=0;e<this.PPS.length;e++)t.writeUint16(this.PPS[e].length),t.writeUint8Array(this.PPS[e].data);this.ext&&t.writeUint8Array(this.ext)}},bt.fourcc="avcC",bt),nt=(yt=class extends f{constructor(...t){super(...t),this.box_name="MediaDataBox"}},yt.fourcc="mdat",yt),no=(Ut=class extends f{constructor(...t){super(...t),this.box_name="ItemDataBox"}},Ut.fourcc="idat",Ut),oo=(wt=class extends f{constructor(...t){super(...t),this.box_name="FreeSpaceBox"}},wt.fourcc="free",wt),ho=(St=class extends f{constructor(...t){super(...t),this.box_name="FreeSpaceBox"}},St.fourcc="skip",St),Za=(vt=class extends p{constructor(...t){super(...t),this.box_name="HintMediaHeaderBox"}},vt.fourcc="hmhd",vt),tn=(Bt=class extends p{constructor(...t){super(...t),this.box_name="NullMediaHeaderBox"}},Bt.fourcc="nmhd",Bt),lo=(zt=class extends p{constructor(...t){super(...t),this.box_name="ObjectDescriptorBox"}},zt.fourcc="iods",zt),co=(kt=class extends p{constructor(...t){super(...t),this.box_name="XMLBox"}},kt.fourcc="xml ",kt),po=(It=class extends p{constructor(...t){super(...t),this.box_name="BinaryXMLBox"}},It.fourcc="bxml",It),uo=(Et=class extends p{constructor(...t){super(...t),this.box_name="ItemProtectionBox",this.sinfs=[]}get protections(){return this.sinfs}},Et.fourcc="ipro",Et),ot=(Ct=class extends x{constructor(...t){super(...t),this.box_name="MovieBox",this.traks=[],this.psshs=[],this.subBoxNames=["trak","pssh"]}},Ct.fourcc="moov",Ct),en=(Pt=class extends x{constructor(...t){super(...t),this.box_name="TrackBox",this.samples=[]}},Pt.fourcc="trak",Pt),fo=(At=class extends x{constructor(...t){super(...t),this.box_name="EditBox"}},At.fourcc="edts",At),sn=(Ft=class extends x{constructor(...t){super(...t),this.box_name="MediaBox"}},Ft.fourcc="mdia",Ft),rn=(Tt=class extends x{constructor(...t){super(...t),this.box_name="MediaInformationBox"}},Tt.fourcc="minf",Tt),an=(Dt=class extends x{constructor(...t){super(...t),this.box_name="DataInformationBox"}},Dt.fourcc="dinf",Dt),nn=(Lt=class extends x{constructor(...t){super(...t),this.box_name="SampleTableBox",this.sgpds=[],this.sbgps=[],this.subBoxNames=["sgpd","sbgp"]}},Lt.fourcc="stbl",Lt),Pa=(Ht=class extends x{constructor(...t){super(...t),this.box_name="MovieExtendsBox",this.trexs=[],this.subBoxNames=["trex"]}},Ht.fourcc="mvex",Ht),on=(Mt=class extends x{constructor(...t){super(...t),this.box_name="MovieFragmentBox",this.trafs=[],this.subBoxNames=["traf"]}},Mt.fourcc="moof",Mt),hn=(Ot=class extends x{constructor(...t){super(...t),this.box_name="TrackFragmentBox",this.truns=[],this.sgpds=[],this.sbgps=[],this.subBoxNames=["trun","sgpd","sbgp"]}},Ot.fourcc="traf",Ot),mo=(Rt=class extends x{constructor(...t){super(...t),this.box_name="VTTCueBox"}},Rt.fourcc="vttc",Rt),_o=(Nt=class extends x{constructor(...t){super(...t),this.box_name="MovieFragmentRandomAccessBox",this.tfras=[],this.subBoxNames=["tfra"]}},Nt.fourcc="mfra",Nt),go=(Vt=class extends x{constructor(...t){super(...t),this.box_name="AdditionalMetadataContainerBox"}},Vt.fourcc="meco",Vt),xo=(Gt=class extends x{constructor(...t){super(...t),this.box_name="trackhintinformation",this.subBoxNames=["sdp ","rtp "]}},Gt.fourcc="hnti",Gt),bo=(jt=class extends x{constructor(...t){super(...t),this.box_name="hintstatisticsbox",this.maxrs=[],this.subBoxNames=["maxr"]}},jt.fourcc="hinf",jt),yo=($t=class extends x{constructor(...t){super(...t),this.box_name="SubTrackBox"}},$t.fourcc="strk",$t),Uo=(qt=class extends x{constructor(...t){super(...t),this.box_name="SubTrackDefinitionBox"}},qt.fourcc="strd",qt),wo=(Yt=class extends x{constructor(...t){super(...t),this.box_name="ProtectionSchemeInfoBox"}},Yt.fourcc="sinf",Yt),So=(Wt=class extends x{constructor(...t){super(...t),this.box_name="RestrictedSchemeInfoBox"}},Wt.fourcc="rinf",Wt),vo=(Kt=class extends x{constructor(...t){super(...t),this.box_name="SchemeInformationBox"}},Kt.fourcc="schi",Kt),Bo=(Jt=class extends x{constructor(...t){super(...t),this.box_name="TrackGroupBox"}},Jt.fourcc="trgr",Jt),zo=(Qt=class extends x{constructor(...t){super(...t),this.box_name="UserDataBox",this.kinds=[],this.strks=[],this.subBoxNames=["kind","strk"]}},Qt.fourcc="udta",Qt),ko=(Xt=class extends x{constructor(...t){super(...t),this.box_name="ItemPropertiesBox",this.ipmas=[],this.subBoxNames=["ipma"]}},Xt.fourcc="iprp",Xt),Io=(Zt=class extends x{constructor(...t){super(...t),this.box_name="ItemPropertyContainerBox",this.hvcCs=[],this.ispes=[],this.claps=[],this.irots=[],this.subBoxNames=["hvcC","ispe","clap","irot"]}},Zt.fourcc="ipco",Zt),Eo=(te=class extends x{constructor(...t){super(...t),this.box_name="GroupsListBox"}},te.fourcc="grpl",te),Co=(ee=class extends x{constructor(...t){super(...t),this.box_name="J2KHeaderInfoBox"}},ee.fourcc="j2kH",ee),Po=(se=class extends x{constructor(...t){super(...t),this.box_name="ExtendedTypeBox",this.tycos=[],this.subBoxNames=["tyco"]}},se.fourcc="etyp",se),Ao=(ie=class extends x{constructor(...t){super(...t),this.box_name="ProjectedOmniVideoBox",this.subBoxNames=["prfr"]}},ie.fourcc="povd",ie),ln=(re=class extends p{constructor(...t){super(...t),this.box_name="DataReferenceBox"}parse(t){this.parseFullHeader(t),this.entries=[];let e=t.readUint32();for(let s=0;s<e;s++){let i=H(t,false,this.size-(t.getPosition()-this.start));if(i.code===1){let r=i.box;this.entries.push(r)}else return}}write(t){this.version=0,this.flags=0,this.size=4,this.writeHeader(t),t.writeUint32(this.entries.length);for(let e=0;e<this.entries.length;e++)this.entries[e].write(t),this.size+=this.entries[e].size;d.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),t.adjustUint32(this.sizePosition,this.size)}},re.fourcc="dref",re),dn=(ae=class extends p{constructor(...t){super(...t),this.box_name="ExtendedLanguageBox"}parse(t){this.parseFullHeader(t),this.extended_language=t.readString(this.size-this.hdr_size)}write(t){this.version=0,this.flags=0,this.size=this.extended_language.length,this.writeHeader(t),t.writeString(this.extended_language)}},ae.fourcc="elng",ae),cn=(ne=class extends f{constructor(...t){super(...t),this.box_name="FileTypeBox"}parse(t){let e=this.size-this.hdr_size;this.major_brand=t.readString(4),this.minor_version=t.readUint32();let s=String.fromCharCode(this.minor_version>>24,this.minor_version>>16&255,this.minor_version>>8&255,this.minor_version&255);s.match("[a-zA-Z0-9]{4}")&&(this.minor_version=s),e-=8,this.compatible_brands=[];let i=0;for(;e>=4;)this.compatible_brands[i]=t.readString(4),e-=4,i++}write(t){this.size=8+4*this.compatible_brands.length,this.writeHeader(t),t.writeString(this.major_brand,void 0,4),typeof this.minor_version=="number"?t.writeUint32(this.minor_version):t.writeString(this.minor_version,void 0,4);for(let e=0;e<this.compatible_brands.length;e++)t.writeString(this.compatible_brands[e],void 0,4)}},ne.fourcc="ftyp",ne),pn=(oe=class extends p{constructor(...t){super(...t),this.box_name="HandlerBox"}parse(t){if(this.parseFullHeader(t),this.version===0&&(t.readUint32(),this.handler=t.readString(4),t.readUint32Array(3),!this.isEndOfBox(t))){let e=this.start+this.size-t.getPosition();this.name=t.readCString();let s=this.start+this.size-1;t.seek(s),t.readUint8()!==0&&e>1&&(d.info("BoxParser","Warning: hdlr name is not null-terminated, possibly length-prefixed string. Trimming first byte."),this.name=this.name.slice(1))}}write(t){this.size=20+this.name.length+1,this.version=0,this.flags=0,this.writeHeader(t),t.writeUint32(0),t.writeString(this.handler,void 0,4),t.writeUint32Array([0,0,0]),t.writeCString(this.name)}},oe.fourcc="hdlr",oe),un=(he=class extends f{constructor(...t){super(...t),this.box_name="HEVCConfigurationBox"}parse(t){this.configurationVersion=t.readUint8();let e=t.readUint8();this.general_profile_space=e>>6,this.general_tier_flag=(e&32)>>5,this.general_profile_idc=e&31,this.general_profile_compatibility=t.readUint32(),this.general_constraint_indicator=t.readUint8Array(6),this.general_level_idc=t.readUint8(),this.min_spatial_segmentation_idc=t.readUint16()&4095,this.parallelismType=t.readUint8()&3,this.chroma_format_idc=t.readUint8()&3,this.bit_depth_luma_minus8=t.readUint8()&7,this.bit_depth_chroma_minus8=t.readUint8()&7,this.avgFrameRate=t.readUint16(),e=t.readUint8(),this.constantFrameRate=e>>6,this.numTemporalLayers=(e&13)>>3,this.temporalIdNested=(e&4)>>2,this.lengthSizeMinusOne=e&3,this.nalu_arrays=[];let s=t.readUint8();for(let i=0;i<s;i++){let r=[];this.nalu_arrays.push(r),e=t.readUint8(),r.completeness=(e&128)>>7,r.nalu_type=e&63;let a=t.readUint16();for(let n=0;n<a;n++){let o=t.readUint16();r.push({data:t.readUint8Array(o)})}}}write(t){this.size=23;for(let e=0;e<this.nalu_arrays.length;e++){this.size+=3;for(let s=0;s<this.nalu_arrays[e].length;s++)this.size+=2+this.nalu_arrays[e][s].data.length}this.writeHeader(t),t.writeUint8(this.configurationVersion),t.writeUint8((this.general_profile_space<<6)+(this.general_tier_flag<<5)+this.general_profile_idc),t.writeUint32(this.general_profile_compatibility),t.writeUint8Array(this.general_constraint_indicator),t.writeUint8(this.general_level_idc),t.writeUint16(this.min_spatial_segmentation_idc+(15<<24)),t.writeUint8(this.parallelismType+252),t.writeUint8(this.chroma_format_idc+252),t.writeUint8(this.bit_depth_luma_minus8+248),t.writeUint8(this.bit_depth_chroma_minus8+248),t.writeUint16(this.avgFrameRate),t.writeUint8((this.constantFrameRate<<6)+(this.numTemporalLayers<<3)+(this.temporalIdNested<<2)+this.lengthSizeMinusOne),t.writeUint8(this.nalu_arrays.length);for(let e=0;e<this.nalu_arrays.length;e++){t.writeUint8((this.nalu_arrays[e].completeness<<7)+this.nalu_arrays[e].nalu_type),t.writeUint16(this.nalu_arrays[e].length);for(let s=0;s<this.nalu_arrays[e].length;s++)t.writeUint16(this.nalu_arrays[e][s].data.length),t.writeUint8Array(this.nalu_arrays[e][s].data)}}},he.fourcc="hvcC",he),fn=(le=class extends p{constructor(...t){super(...t),this.box_name="MediaHeaderBox"}parse(t){this.parseFullHeader(t),this.version===1?(this.creation_time=t.readUint64(),this.modification_time=t.readUint64(),this.timescale=t.readUint32(),this.duration=t.readUint64()):(this.creation_time=t.readUint32(),this.modification_time=t.readUint32(),this.timescale=t.readUint32(),this.duration=t.readUint32()),this.parseLanguage(t),t.readUint16()}write(t){let e=this.modification_time>B||this.creation_time>B||this.duration>B||this.version===1;this.version=+!!e,this.size=20,this.size+=e?12:0,this.flags=0,this.writeHeader(t),e?(t.writeUint64(this.creation_time),t.writeUint64(this.modification_time),t.writeUint32(this.timescale),t.writeUint64(this.duration)):(t.writeUint32(this.creation_time),t.writeUint32(this.modification_time),t.writeUint32(this.timescale),t.writeUint32(this.duration)),t.writeUint16(this.language),t.writeUint16(0)}},le.fourcc="mdhd",le),mn=(de=class extends p{constructor(...t){super(...t),this.box_name="MovieExtendsHeaderBox"}parse(t){this.parseFullHeader(t),this.flags&1&&(d.warn("BoxParser","mehd box incorrectly uses flags set to 1, converting version to 1"),this.version=1),this.fragment_duration=this.version===1?t.readUint64():t.readUint32()}write(t){let e=this.fragment_duration>B||this.version===1;this.version=+!!e,this.size=4,this.size+=e?4:0,this.flags=0,this.writeHeader(t),e?t.writeUint64(this.fragment_duration):t.writeUint32(this.fragment_duration)}},de.fourcc="mehd",de),Fo=(ce=class extends p{constructor(...t){super(...t),this.box_name="ItemInfoEntry"}parse(t){this.parseFullHeader(t),(this.version===0||this.version===1)&&(this.item_ID=t.readUint16(),this.item_protection_index=t.readUint16(),this.item_name=t.readCString(),this.content_type=t.readCString(),this.isEndOfBox(t)||(this.content_encoding=t.readCString())),this.version===1?(this.extension_type=t.readString(4),d.warn("BoxParser","Cannot parse extension type"),t.seek(this.start+this.size)):this.version>=2&&(this.version===2?this.item_ID=t.readUint16():this.version===3&&(this.item_ID=t.readUint32()),this.item_protection_index=t.readUint16(),this.item_type=t.readString(4),this.item_name=t.readCString(),this.item_type==="mime"?(this.content_type=t.readCString(),this.content_encoding=t.readCString()):this.item_type==="uri "&&(this.item_uri_type=t.readCString()))}},ce.fourcc="infe",ce),To=(pe=class extends p{constructor(...t){super(...t),this.box_name="ItemInfoBox"}parse(t){this.parseFullHeader(t),this.entry_count=this.version===0?t.readUint16():t.readUint32(),this.item_infos=[];for(let e=0;e<this.entry_count;e++){let s=H(t,false,this.size-(t.getPosition()-this.start));if(s.code===1){let i=s.box;i.type==="infe"?this.item_infos[e]=i:d.error("BoxParser","Expected 'infe' box, got "+s.box.type,t.isofile)}else return}}},pe.fourcc="iinf",pe),Do=(ue=class extends p{constructor(...t){super(...t),this.box_name="ItemLocationBox"}parse(t){this.parseFullHeader(t);let e;e=t.readUint8(),this.offset_size=e>>4&15,this.length_size=e&15,e=t.readUint8(),this.base_offset_size=e>>4&15,this.index_size=this.version===1||this.version===2?e&15:0,this.items=[];let s=0;if(this.version<2)s=t.readUint16();else if(this.version===2)s=t.readUint32();else throw Error("version of iloc box not supported");for(let i=0;i<s;i++){let r=0,a=0,n=0;if(this.version<2)r=t.readUint16();else if(this.version===2)r=t.readUint32();else throw Error("version of iloc box not supported");a=this.version===1||this.version===2?t.readUint16()&15:0;let o=t.readUint16();switch(this.base_offset_size){case 0:n=0;break;case 4:n=t.readUint32();break;case 8:n=t.readUint64();break;default:throw Error("Error reading base offset size")}let l=[],h=t.readUint16();for(let c=0;c<h;c++){let u=0,m=0,_=0;if(this.version===1||this.version===2)switch(this.index_size){case 0:u=0;break;case 4:u=t.readUint32();break;case 8:u=t.readUint64();break;default:throw Error("Error reading extent index")}switch(this.offset_size){case 0:m=0;break;case 4:m=t.readUint32();break;case 8:m=t.readUint64();break;default:throw Error("Error reading extent index")}switch(this.length_size){case 0:_=0;break;case 4:_=t.readUint32();break;case 8:_=t.readUint64();break;default:throw Error("Error reading extent index")}l.push({extent_index:u,extent_length:_,extent_offset:m})}this.items.push({base_offset:n,construction_method:a,item_ID:r,data_reference_index:o,extents:l})}}},ue.fourcc="iloc",ue),Lo={auxl:"Auxiliary image item",base:"Pre-derived image item base",cdsc:"Item describes referenced item",dimg:"Derived image item",dpnd:"Item coding dependency",eroi:"Region",evir:"EVC slice",exbl:"Scalable image item","fdl ":"File delivery",font:"Font item",iloc:"Item data location",mask:"Region mask",mint:"Data integrity",pred:"Predictively coded item",prem:"Pre-multiplied item",tbas:"HEVC tile track base item",text:"Text item",thmb:"Thumbnail image item"},Ho=(tt=class _n extends p{constructor(...e){super(...e),this.box_name="ItemReferenceBox",this.references=[]}parse(e){for(this.parseFullHeader(e),this.references=[];e.getPosition()<this.start+this.size;){let s=H(e,true,this.size-(e.getPosition()-this.start));if(s.code===1){let i="Unknown item reference";_n.allowed_types.includes(s.type)?i=Lo[s.type]:d.warn("BoxParser",`Unknown item reference type: '${s.type}'`);let r=this.version===0?new Kn(s.type,s.size,i,s.hdr_size,s.start):new Jn(s.type,s.size,i,s.hdr_size,s.start);r.write===f.prototype.write&&r.type!=="mdat"&&(d.warn("BoxParser",r.type+" box writing not yet implemented, keeping unparsed data in memory for later write"),r.parseDataAndRewind(e)),r.parse(e),this.references.push(r)}else return}}},tt.fourcc="iref",tt.allowed_types=["auxl","base","cdsc","dimg","dpnd","eroi","evir","exbl","fdl ","font","iloc","mask","mint","pred","prem","tbas","text","thmb"],tt),Mo=(fe=class extends p{constructor(...t){super(...t),this.box_name="PrimaryItemBox"}parse(t){this.parseFullHeader(t),this.item_id=this.version===0?t.readUint16():t.readUint32()}},fe.fourcc="pitm",fe),Oo=(me=class extends p{constructor(...t){super(...t),this.box_name="MetaBox",this.isQT=false}parse(t){let e=t.getPosition();if(this.size>8){switch(t.readUint32(),t.readString(4)){case"hdlr":case"mhdr":case"keys":case"ilst":case"ctry":case"lang":this.isQT=true}t.seek(e)}this.isQT||this.parseFullHeader(t),x.prototype.parse.call(this,t)}},me.fourcc="meta",me),gn=(_e=class extends p{constructor(...t){super(...t),this.box_name="MovieFragmentHeaderBox"}parse(t){this.parseFullHeader(t),this.sequence_number=t.readUint32()}write(t){this.version=0,this.flags=0,this.size=4,this.writeHeader(t),t.writeUint32(this.sequence_number)}},_e.fourcc="mfhd",_e),xn=(ge=class extends p{constructor(...t){super(...t),this.box_name="MovieHeaderBox"}parse(t){this.parseFullHeader(t),this.version===1?(this.creation_time=t.readUint64(),this.modification_time=t.readUint64(),this.timescale=t.readUint32(),this.duration=t.readUint64()):(this.creation_time=t.readUint32(),this.modification_time=t.readUint32(),this.timescale=t.readUint32(),this.duration=t.readUint32()),this.rate=t.readUint32(),this.volume=t.readUint16()>>8,t.readUint16(),t.readUint32Array(2),this.matrix=t.readInt32Array(9),t.readUint32Array(6),this.next_track_id=t.readUint32()}write(t){let e=this.modification_time>B||this.creation_time>B||this.duration>B||this.version===1;this.version=+!!e,this.size=96,this.size+=e?12:0,this.flags=0,this.writeHeader(t),e?(t.writeUint64(this.creation_time),t.writeUint64(this.modification_time),t.writeUint32(this.timescale),t.writeUint64(this.duration)):(t.writeUint32(this.creation_time),t.writeUint32(this.modification_time),t.writeUint32(this.timescale),t.writeUint32(this.duration)),t.writeUint32(this.rate),t.writeUint16(this.volume<<8),t.writeUint16(0),t.writeUint32(0),t.writeUint32(0),t.writeInt32Array(this.matrix),t.writeUint32(0),t.writeUint32(0),t.writeUint32(0),t.writeUint32(0),t.writeUint32(0),t.writeUint32(0),t.writeUint32(this.next_track_id)}print(t){super.printHeader(t),t.log(t.indent+"creation_time: "+this.creation_time),t.log(t.indent+"modification_time: "+this.modification_time),t.log(t.indent+"timescale: "+this.timescale),t.log(t.indent+"duration: "+this.duration),t.log(t.indent+"rate: "+this.rate),t.log(t.indent+"volume: "+(this.volume>>8)),t.log(t.indent+"matrix: "+this.matrix.join(", ")),t.log(t.indent+"next_track_id: "+this.next_track_id)}},ge.fourcc="mvhd",ge),Ro=(xe=class extends J{parse(t){this.parseHeader(t),this.content_encoding=t.readCString(),this.mime_format=t.readCString(),this.parseFooter(t)}},xe.fourcc="mett",xe),No=(be=class extends J{parse(t){this.parseHeader(t),this.content_encoding=t.readCString(),this.namespace=t.readCString(),this.schema_location=t.readCString(),this.parseFooter(t)}},be.fourcc="metx",be),Vo=(ye=class extends f{constructor(...t){super(...t),this.box_name="AV1CodecConfigurationBox"}parse(t){let e=t.readUint8();if((e>>7&1)!=1){d.error("BoxParser","av1C marker problem",t.isofile);return}if(this.version=e&127,this.version!==1){d.error("BoxParser","av1C version "+this.version+" not supported",t.isofile);return}if(e=t.readUint8(),this.seq_profile=e>>5&7,this.seq_level_idx_0=e&31,e=t.readUint8(),this.seq_tier_0=e>>7&1,this.high_bitdepth=e>>6&1,this.twelve_bit=e>>5&1,this.monochrome=e>>4&1,this.chroma_subsampling_x=e>>3&1,this.chroma_subsampling_y=e>>2&1,this.chroma_sample_position=e&3,e=t.readUint8(),this.reserved_1=e>>5&7,this.reserved_1!==0){d.error("BoxParser","av1C reserved_1 parsing problem",t.isofile);return}if(this.initial_presentation_delay_present=e>>4&1,this.initial_presentation_delay_present===1)this.initial_presentation_delay_minus_one=e&15;else if(this.reserved_2=e&15,this.reserved_2!==0){d.error("BoxParser","av1C reserved_2 parsing problem",t.isofile);return}let s=this.size-this.hdr_size-4;this.configOBUs=t.readUint8Array(s)}},ye.fourcc="av1C",ye),Go=(Ue=class extends p{constructor(...t){super(...t),this.box_name="ElementaryStreamDescriptorBox"}parse(t){this.parseFullHeader(t);let e=t.readUint8Array(this.size-this.hdr_size);if("MPEG4DescriptorParser"in dt){let s=new dt.MPEG4DescriptorParser;this.esd=s.parseOneDescriptor(new C(e.buffer,0))}}},Ue.fourcc="esds",Ue),jo=(we=class extends x{constructor(...t){super(...t),this.box_name="siDecompressionParamBox"}},we.fourcc="wave",we),$o=(Se=class extends f{constructor(...t){super(...t),this.box_name="LCEVCConfigurationBox"}parse(t){if(this.configurationVersion=t.readUint8(),this.configurationVersion!==1){d.error("BoxParser","lvcC version "+this.configurationVersion+" not supported",t.isofile);return}this.LCEVCProfileIndication=t.readUint8(),this.LCEVCLevelIndication=t.readUint8();let e=t.readUint8();this.chroma_format_idc=e>>6&3,this.bit_depth_luma_minus8=e>>3&7,this.bit_depth_chroma_minus8=e&7,e=t.readUint8(),this.lengthSizeMinusOne=e>>6&3;let s=e&63;if(s!==63||(this.pic_width_in_luma_samples=t.readUint32(),this.pic_height_in_luma_samples=t.readUint32(),e=t.readUint8(),this.sc_in_stream=e>>7&1,this.gc_in_stream=e>>6&1,this.ai_in_stream=e>>5&1,s=e&31,s!==31)){d.error("BoxParser","lvcC reserved parsing problem",t.isofile);return}this.nalu_arrays=[];let i=t.readUint8();for(let r=0;r<i;r++){let a=[];if(this.nalu_arrays.push(a),e=t.readUint8(),s=e>>6&3,s!==0){d.error("BoxParser","lvcC reserved parsing problem",t.isofile);return}a.nalu_type=e&63;let n=t.readUint16();for(let o=0;o<n;o++){let l=t.readUint16();a.push({data:t.readUint8Array(l)})}}}},Se.fourcc="lvcC",Se),qo=(ve=class extends p{constructor(...t){super(...t),this.box_name="VPCodecConfigurationRecord"}parse(t){if(this.parseFullHeader(t),this.version===1){this.profile=t.readUint8(),this.level=t.readUint8();let e=t.readUint8();this.bitDepth=e>>4,this.chromaSubsampling=e>>1&7,this.videoFullRangeFlag=e&1,this.colourPrimaries=t.readUint8(),this.transferCharacteristics=t.readUint8(),this.matrixCoefficients=t.readUint8(),this.codecIntializationDataSize=t.readUint16(),this.codecIntializationData=t.readUint8Array(this.codecIntializationDataSize)}else{this.profile=t.readUint8(),this.level=t.readUint8();let e=t.readUint8();this.bitDepth=e>>4&15,this.colorSpace=e&15,e=t.readUint8(),this.chromaSubsampling=e>>4&15,this.transferFunction=e>>1&7,this.videoFullRangeFlag=e&1,this.codecIntializationDataSize=t.readUint16(),this.codecIntializationData=t.readUint8Array(this.codecIntializationDataSize)}}},ve.fourcc="vpcC",ve),Yo=(Be=class extends p{constructor(...t){super(...t),this.box_name="VvcConfigurationBox"}parse(t){this.parseFullHeader(t);let e={held_bits:void 0,num_held_bits:0,stream_read_1_bytes:function(i){this.held_bits=i.readUint8(),this.num_held_bits=8},stream_read_2_bytes:function(i){this.held_bits=i.readUint16(),this.num_held_bits=16},extract_bits:function(i){let r=this.held_bits>>this.num_held_bits-i&(1<<i)-1;return this.num_held_bits-=i,r}};if(e.stream_read_1_bytes(t),e.extract_bits(5),this.lengthSizeMinusOne=e.extract_bits(2),this.ptl_present_flag=e.extract_bits(1),this.ptl_present_flag){if(e.stream_read_2_bytes(t),this.ols_idx=e.extract_bits(9),this.num_sublayers=e.extract_bits(3),this.constant_frame_rate=e.extract_bits(2),this.chroma_format_idc=e.extract_bits(2),e.stream_read_1_bytes(t),this.bit_depth_minus8=e.extract_bits(3),e.extract_bits(5),e.stream_read_2_bytes(t),e.extract_bits(2),this.num_bytes_constraint_info=e.extract_bits(6),this.general_profile_idc=e.extract_bits(7),this.general_tier_flag=e.extract_bits(1),this.general_level_idc=t.readUint8(),e.stream_read_1_bytes(t),this.ptl_frame_only_constraint_flag=e.extract_bits(1),this.ptl_multilayer_enabled_flag=e.extract_bits(1),this.general_constraint_info=new Uint8Array(this.num_bytes_constraint_info),this.num_bytes_constraint_info){for(let i=0;i<this.num_bytes_constraint_info-1;i++){let r=e.extract_bits(6);e.stream_read_1_bytes(t);let a=e.extract_bits(2);this.general_constraint_info[i]=r<<2|a}this.general_constraint_info[this.num_bytes_constraint_info-1]=e.extract_bits(6)}else e.extract_bits(6);if(this.num_sublayers>1){e.stream_read_1_bytes(t),this.ptl_sublayer_present_mask=0;for(let i=this.num_sublayers-2;i>=0;--i){let r=e.extract_bits(1);this.ptl_sublayer_present_mask|=r<<i}for(let i=this.num_sublayers;i<=8&&this.num_sublayers>1;++i)e.extract_bits(1);this.sublayer_level_idc=[];for(let i=this.num_sublayers-2;i>=0;--i)this.ptl_sublayer_present_mask&1<<i&&(this.sublayer_level_idc[i]=t.readUint8())}if(this.ptl_num_sub_profiles=t.readUint8(),this.general_sub_profile_idc=[],this.ptl_num_sub_profiles)for(let i=0;i<this.ptl_num_sub_profiles;i++)this.general_sub_profile_idc.push(t.readUint32());this.max_picture_width=t.readUint16(),this.max_picture_height=t.readUint16(),this.avg_frame_rate=t.readUint16()}this.nalu_arrays=[];let s=t.readUint8();for(let i=0;i<s;i++){let r=[];this.nalu_arrays.push(r),e.stream_read_1_bytes(t),r.completeness=e.extract_bits(1),e.extract_bits(2),r.nalu_type=e.extract_bits(5);let a=1;r.nalu_type!==13&&r.nalu_type!==12&&(a=t.readUint16());for(let n=0;n<a;n++){let o=t.readUint16();r.push({data:t.readUint8Array(o),length:o})}}}},Be.fourcc="vvcC",Be),Wo=(ze=class extends f{constructor(...t){super(...t),this.box_name="ColourInformationBox"}parse(t){if(this.colour_type=t.readString(4),this.colour_type==="nclx"){this.colour_primaries=t.readUint16(),this.transfer_characteristics=t.readUint16(),this.matrix_coefficients=t.readUint16();let e=t.readUint8();this.full_range_flag=e>>7}else(this.colour_type==="rICC"||this.colour_type==="prof")&&(this.ICC_profile=t.readUint8Array(this.size-4))}},ze.fourcc="colr",ze);function j(t,e){let s=Number(t).toString(16);for(e=e===void 0?2:e;s.length<e;)s="0"+s;return s}var pt=class extends w{getCodec(){let t=super.getCodec();return this.avcC?`${t}.${j(this.avcC.AVCProfileIndication)}${j(this.avcC.profile_compatibility)}${j(this.avcC.AVCLevelIndication)}`:t}},Ko=(ke=class extends pt{constructor(...t){super(...t),this.box_name="AVCSampleEntry"}},ke.fourcc="avc1",ke),Jo=(Ie=class extends pt{constructor(...t){super(...t),this.box_name="AVC2SampleEntry"}},Ie.fourcc="avc2",Ie),Qo=(Ee=class extends pt{constructor(...t){super(...t),this.box_name="AVCSampleEntry"}},Ee.fourcc="avc3",Ee),Xo=(Ce=class extends pt{constructor(...t){super(...t),this.box_name="AVC2SampleEntry"}},Ce.fourcc="avc4",Ce),Zo=(Pe=class extends w{constructor(...t){super(...t),this.box_name="AV1SampleEntry"}getCodec(){let t=super.getCodec(),e=this.av1C.seq_level_idx_0,s=e<10?"0"+e:e,i;return this.av1C.seq_profile===2&&this.av1C.high_bitdepth===1?i=this.av1C.twelve_bit===1?"12":"10":this.av1C.seq_profile<=2&&(i=this.av1C.high_bitdepth===1?"10":"08"),t+"."+this.av1C.seq_profile+"."+s+(this.av1C.seq_tier_0?"H":"M")+"."+i}},Pe.fourcc="av01",Pe),th=(Ae=class extends w{},Ae.fourcc="dav1",Ae),ut=class extends w{getCodec(){let t=super.getCodec();if(this.hvcC){switch(t+=".",this.hvcC.general_profile_space){case 0:t+="";break;case 1:t+="A";break;case 2:t+="B";break;case 3:t+="C"}t+=this.hvcC.general_profile_idc,t+=".";let e=this.hvcC.general_profile_compatibility,s=0;for(let a=0;a<32&&(s|=e&1,a!==31);a++)s<<=1,e>>=1;t+=j(s,0),t+=".",this.hvcC.general_tier_flag===0?t+="L":t+="H",t+=this.hvcC.general_level_idc;let i=false,r="";for(let a=5;a>=0;a--)(this.hvcC.general_constraint_indicator[a]||i)&&(r="."+j(this.hvcC.general_constraint_indicator[a],0)+r,i=true);t+=r}return t}},eh=(Fe=class extends ut{constructor(...t){super(...t),this.box_name="HEVCSampleEntry"}},Fe.fourcc="hvc1",Fe),sh=(Te=class extends ut{},Te.fourcc="hvc2",Te),ih=(De=class extends ut{constructor(...t){super(...t),this.box_name="HEVCSampleEntry",this.colrs=[],this.subBoxNames=["colr"]}},De.fourcc="hev1",De),rh=(Le=class extends ut{},Le.fourcc="hev2",Le),ah=(He=class extends w{constructor(...t){super(...t),this.box_name="HEVCTileSampleSampleEntry"}},He.fourcc="hvt1",He),nh=(Me=class extends w{constructor(...t){super(...t),this.box_name="LHEVCSampleEntry"}},Me.fourcc="lhe1",Me),oh=(Oe=class extends w{constructor(...t){super(...t),this.box_name="LHEVCSampleEntry"}},Oe.fourcc="lhv1",Oe),hh=(Re=class extends w{constructor(...t){super(...t),this.box_name="LCEVCSampleEntry"}getCodec(){let t=super.getCodec();return this.lvcC&&(t+=".",t+="vprf",t+=this.lvcC.LCEVCProfileIndication,t+=".",t+="vlev",t+=this.lvcC.LCEVCLevelIndication),t}},Re.fourcc="lvc1",Re),lh=(Ne=class extends w{},Ne.fourcc="dvh1",Ne),dh=(Ve=class extends w{},Ve.fourcc="dvhe",Ve),bn=class extends w{getCodec(){let t=super.getCodec();if(this.vvcC){t+="."+this.vvcC.general_profile_idc,this.vvcC.general_tier_flag?t+=".H":t+=".L",t+=this.vvcC.general_level_idc;let e="";if(this.vvcC.general_constraint_info){let s=[],i=0;i|=this.vvcC.ptl_frame_only_constraint_flag<<7,i|=this.vvcC.ptl_multilayer_enabled_flag<<6;let r;for(let a=0;a<this.vvcC.general_constraint_info.length;++a)i|=this.vvcC.general_constraint_info[a]>>2&63,s.push(i),i&&(r=a),i=this.vvcC.general_constraint_info[a]>>2&3;if(r===void 0)e=".CA";else{e=".C";let a="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",n=0,o=0;for(let l=0;l<=r;++l)for(n=n<<8|s[l],o+=8;o>=5;){let h=n>>o-5&31;e+=a[h],o-=5,n&=(1<<o)-1}o&&(n<<=5-o,e+=a[n&31])}}t+=e}return t}},ch=(Ge=class extends bn{constructor(...t){super(...t),this.box_name="VvcSampleEntry"}},Ge.fourcc="vvc1",Ge),ph=(je=class extends bn{constructor(...t){super(...t),this.box_name="VvcSampleEntry"}},je.fourcc="vvi1",je),uh=($e=class extends w{constructor(...t){super(...t),this.box_name="VvcSampleEntry"}},$e.fourcc="vvs1",$e),fh=(qe=class extends w{constructor(...t){super(...t),this.box_name="VvcNonVCLSampleEntry"}},qe.fourcc="vvcN",qe),yn=class extends w{getCodec(){let t=super.getCodec(),e=this.vpcC.level;e===0&&(e="00");let s=this.vpcC.bitDepth;return s===8&&(s="08"),`${t}.0${this.vpcC.profile}.${e}.${s}`}},mh=(Ye=class extends yn{},Ye.fourcc="vp08",Ye),_h=(We=class extends yn{},We.fourcc="vp09",We),gh=(Ke=class extends w{},Ke.fourcc="avs3",Ke),xh=(Je=class extends w{constructor(...t){super(...t),this.box_name="J2KSampleEntry"}},Je.fourcc="j2ki",Je),bh=(Qe=class extends w{},Qe.fourcc="mjp2",Qe),yh=(Xe=class extends w{},Xe.fourcc="mjpg",Xe),Uh=(Ze=class extends w{constructor(...t){super(...t),this.box_name="UncompressedVideoSampleEntry"}},Ze.fourcc="uncv",Ze),wh=(ts=class extends w{constructor(...t){super(...t),this.box_name="MP4VisualSampleEntry"}},ts.fourcc="mp4v",ts),Un=(es=class extends A{constructor(...t){super(...t),this.box_name="MP4AudioSampleEntry"}getCodec(){var s;let t=super.getCodec(),e=this.esds??((s=this.wave)==null?void 0:s.esds);if(e&&e.esd){let i=e.esd.getOTI(),r=e.esd.getAudioConfig();return t+"."+j(i)+(r?"."+r:"")}return t}},es.fourcc="mp4a",es),Sh=(ss=class extends A{},ss.fourcc="m4ae",ss),vh=(is=class extends A{},is.fourcc="ac-3",is),Bh=(rs=class extends A{},rs.fourcc="ac-4",rs),zh=(as=class extends A{},as.fourcc="ec-3",as),kh=(ns=class extends A{},ns.fourcc="Opus",ns),Ih=(os=class extends A{},os.fourcc="mha1",os),Eh=(hs=class extends A{},hs.fourcc="mha2",hs),Ch=(ls=class extends A{},ls.fourcc="mhm1",ls),Ph=(ds=class extends A{},ds.fourcc="mhm2",ds),Ah=(cs=class extends A{},cs.fourcc="fLaC",cs),Fh=(ps=class extends w{},ps.fourcc="encv",ps),Th=(us=class extends A{},us.fourcc="enca",us),Dh=(fs=class extends G{constructor(...t){super(...t),this.subBoxNames=["sinf"],this.sinfs=[]}},fs.fourcc="encu",fs),Lh=(ms=class extends Qa{constructor(...t){super(...t),this.subBoxNames=["sinf"],this.sinfs=[]}},ms.fourcc="encs",ms),Hh=(_s=class extends Qa{},_s.fourcc="mp4s",_s),Mh=(gs=class extends ao{constructor(...t){super(...t),this.subBoxNames=["sinf"],this.sinfs=[]}},gs.fourcc="enct",gs),Oh=(xs=class extends J{constructor(...t){super(...t),this.subBoxNames=["sinf"],this.sinfs=[]}},xs.fourcc="encm",xs),Rh=(bs=class extends w{constructor(...t){super(...t),this.box_name="RestrictedVideoSampleEntry"}},bs.fourcc="resv",bs),Nh=(ys=class extends G{parse(t){this.parseHeader(t),this.content_encoding=t.readCString(),this.mime_format=t.readCString(),this.parseFooter(t)}},ys.fourcc="sbtt",ys),wn=(Us=class extends G{parse(t){this.parseHeader(t),this.namespace=t.readCString(),this.schema_location=t.readCString(),this.auxiliary_mime_types=t.readCString(),this.parseFooter(t)}write(t){this.writeHeader(t),this.size+=this.namespace.length+1+this.schema_location.length+1+this.auxiliary_mime_types.length+1,t.writeCString(this.namespace),t.writeCString(this.schema_location),t.writeCString(this.auxiliary_mime_types),this.writeFooter(t)}},Us.fourcc="stpp",Us),Vh=(ws=class extends G{parse(t){this.parseHeader(t),this.content_encoding=t.readCString(),this.mime_format=t.readCString(),this.parseFooter(t)}getCodec(){let t=super.getCodec();return this.mime_format?t+"."+this.mime_format:t}},ws.fourcc="stxt",ws),Gh=(Ss=class extends G{parse(t){this.parseHeader(t),this.displayFlags=t.readUint32(),this.horizontal_justification=t.readInt8(),this.vertical_justification=t.readInt8(),this.bg_color_rgba=t.readUint8Array(4),this.box_record=t.readInt16Array(4),this.style_record=t.readUint8Array(12),this.parseFooter(t)}},Ss.fourcc="tx3g",Ss),jh=(vs=class extends J{parse(t){this.parseHeader(t),this.parseFooter(t)}},vs.fourcc="wvtt",vs),$h=(Bs=class extends p{constructor(...t){super(...t),this.box_name="SampleToGroupBox"}parse(t){this.parseFullHeader(t),this.grouping_type=t.readString(4),this.grouping_type_parameter=this.version===1?t.readUint32():0,this.entries=[];let e=t.readUint32();for(let s=0;s<e;s++)this.entries.push({sample_count:t.readInt32(),group_description_index:t.readInt32()})}write(t){this.version=+!!this.grouping_type_parameter,this.flags=0,this.size=8+8*this.entries.length+(this.version===1?4:0),this.writeHeader(t),t.writeString(this.grouping_type,void 0,4),this.version===1&&t.writeUint32(this.grouping_type_parameter),t.writeUint32(this.entries.length);for(let e=0;e<this.entries.length;e++){let s=this.entries[e];t.writeInt32(s.sample_count),t.writeInt32(s.group_description_index)}}},Bs.fourcc="sbgp",Bs),qh=(zs=class extends p{constructor(...t){super(...t),this.box_name="SampleDependencyTypeBox"}parse(t){this.parseFullHeader(t);let e=this.size-this.hdr_size;this.is_leading=[],this.sample_depends_on=[],this.sample_is_depended_on=[],this.sample_has_redundancy=[];for(let s=0;s<e;s++){let i=t.readUint8();this.is_leading[s]=i>>6,this.sample_depends_on[s]=i>>4&3,this.sample_is_depended_on[s]=i>>2&3,this.sample_has_redundancy[s]=i&3}}},zs.fourcc="sdtp",zs),Yh=(ks=class extends p{constructor(...t){super(...t),this.box_name="SampleGroupDescriptionBox"}parse(t){this.parseFullHeader(t),this.grouping_type=t.readString(4),d.debug("BoxParser","Found Sample Groups of type "+this.grouping_type),this.default_length=this.version===1?t.readUint32():0,this.version>=2&&(this.default_group_description_index=t.readUint32()),this.entries=[];let e=t.readUint32();for(let s=0;s<e;s++){let i;i=this.grouping_type in P.sampleGroupEntry?new P.sampleGroupEntry[this.grouping_type](this.grouping_type):new v(this.grouping_type),this.entries.push(i),this.version===1&&this.default_length===0?i.description_length=t.readUint32():i.description_length=this.default_length,i.write===v.prototype.write&&(d.info("BoxParser","SampleGroup for type "+this.grouping_type+" writing not yet implemented, keeping unparsed data in memory for later write"),i.data=t.readUint8Array(i.description_length),t.seek(t.getPosition()-i.description_length)),i.parse(t)}}write(t){this.flags=0,this.size=12;for(let e=0;e<this.entries.length;e++){let s=this.entries[e];this.version===1&&(this.default_length===0&&(this.size+=4),this.size+=s.data.length)}this.writeHeader(t),t.writeString(this.grouping_type,void 0,4),this.version===1&&t.writeUint32(this.default_length),this.version>=2&&t.writeUint32(this.default_sample_description_index),t.writeUint32(this.entries.length);for(let e=0;e<this.entries.length;e++){let s=this.entries[e];this.version===1&&this.default_length===0&&t.writeUint32(s.description_length),s.write(t)}}},ks.fourcc="sgpd",ks),Wh=(Is=class extends p{constructor(...t){super(...t),this.box_name="CompressedSegmentIndexBox"}parse(t){this.parseFullHeader(t),this.reference_ID=t.readUint32(),this.timescale=t.readUint32(),this.version===0?(this.earliest_presentation_time=t.readUint32(),this.first_offset=t.readUint32()):(this.earliest_presentation_time=t.readUint64(),this.first_offset=t.readUint64()),t.readUint16(),this.references=[];let e=t.readUint16();for(let s=0;s<e;s++){let i=t.readUint32(),r=t.readUint32(),a=t.readUint32();this.references.push({reference_type:i>>31&1,referenced_size:i&2147483647,subsegment_duration:r,starts_with_SAP:a>>31&1,SAP_type:a>>28&7,SAP_delta_time:a&268435455})}}write(t){let e=this.earliest_presentation_time>B||this.first_offset>B||this.version===1;this.version=+!!e,this.size=12+12*this.references.length,this.size+=e?16:8,this.flags=0,this.writeHeader(t),t.writeUint32(this.reference_ID),t.writeUint32(this.timescale),e?(t.writeUint64(this.earliest_presentation_time),t.writeUint64(this.first_offset)):(t.writeUint32(this.earliest_presentation_time),t.writeUint32(this.first_offset)),t.writeUint16(0),t.writeUint16(this.references.length);for(let s=0;s<this.references.length;s++){let i=this.references[s];t.writeUint32(i.reference_type<<31|i.referenced_size),t.writeUint32(i.subsegment_duration),t.writeUint32(i.starts_with_SAP<<31|i.SAP_type<<28|i.SAP_delta_time)}}},Is.fourcc="sidx",Is),Sn=(Es=class extends p{constructor(...t){super(...t),this.box_name="SoundMediaHeaderBox"}parse(t){this.parseFullHeader(t),this.balance=t.readUint16(),t.readUint16()}write(t){this.version=0,this.size=4,this.writeHeader(t),t.writeUint16(this.balance),t.writeUint16(0)}},Es.fourcc="smhd",Es),vn=(Cs=class extends p{constructor(...t){super(...t),this.box_name="ChunkOffsetBox"}parse(t){this.parseFullHeader(t);let e=t.readUint32();if(this.chunk_offsets=[],this.version===0)for(let s=0;s<e;s++)this.chunk_offsets.push(t.readUint32())}write(t){this.version=0,this.flags=0,this.size=4+4*this.chunk_offsets.length,this.writeHeader(t),t.writeUint32(this.chunk_offsets.length),t.writeUint32Array(this.chunk_offsets)}unpack(t){for(let e=0;e<this.chunk_offsets.length;e++)t[e].offset=this.chunk_offsets[e]}},Cs.fourcc="stco",Cs),Bn=(Ps=class extends p{constructor(...t){super(...t),this.box_name="SubtitleMediaHeaderBox"}},Ps.fourcc="sthd",Ps),zn=(As=class extends p{constructor(...t){super(...t),this.box_name="SampleToChunkBox"}parse(t){this.parseFullHeader(t);let e=t.readUint32();if(this.first_chunk=[],this.samples_per_chunk=[],this.sample_description_index=[],this.version===0)for(let s=0;s<e;s++)this.first_chunk.push(t.readUint32()),this.samples_per_chunk.push(t.readUint32()),this.sample_description_index.push(t.readUint32())}write(t){this.version=0,this.flags=0,this.size=4+12*this.first_chunk.length,this.writeHeader(t),t.writeUint32(this.first_chunk.length);for(let e=0;e<this.first_chunk.length;e++)t.writeUint32(this.first_chunk[e]),t.writeUint32(this.samples_per_chunk[e]),t.writeUint32(this.sample_description_index[e])}unpack(t){let e=0,s=0;for(let i=0;i<this.first_chunk.length;i++)for(let r=0;r<(i+1<this.first_chunk.length?this.first_chunk[i+1]:1/0);r++){s++;for(let a=0;a<this.samples_per_chunk[i];a++){if(t[e])t[e].description_index=this.sample_description_index[i],t[e].chunk_index=s;else return;e++}}}},As.fourcc="stsc",As),kn=(Fs=class extends p{constructor(...t){super(...t),this.box_name="SampleDescriptionBox"}parse(t){this.parseFullHeader(t),this.entries=[];let e=t.readUint32();for(let s=1;s<=e;s++){let i=H(t,true,this.size-(t.getPosition()-this.start));if(i.code===1){let r;i.type in P.sampleEntry?(r=new P.sampleEntry[i.type](i.size),r.hdr_size=i.hdr_size,r.start=i.start):(d.warn("BoxParser",`Unknown sample entry type: '${i.type}'`),r=new M(i.size,i.hdr_size,i.start),r.type=i.type),r.write===M.prototype.write&&(d.info("BoxParser","SampleEntry "+r.type+" box writing not yet implemented, keeping unparsed data in memory for later write"),r.parseDataAndRewind(t)),r.parse(t),this.entries.push(r)}else return}}write(t){this.version=0,this.flags=0,this.size=0,this.writeHeader(t),t.writeUint32(this.entries.length),this.size+=4;for(let e=0;e<this.entries.length;e++)this.entries[e].write(t),this.size+=this.entries[e].size;d.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),t.adjustUint32(this.sizePosition,this.size)}},Fs.fourcc="stsd",Fs),In=(Ts=class extends p{constructor(...t){super(...t),this.box_name="SampleSizeBox"}parse(t){if(this.parseFullHeader(t),this.sample_sizes=[],this.version===0){this.sample_size=t.readUint32(),this.sample_count=t.readUint32();for(let e=0;e<this.sample_count;e++)this.sample_size===0?this.sample_sizes.push(t.readUint32()):this.sample_sizes[e]=this.sample_size}}write(t){let e=true;this.version=0,this.flags=0,this.sample_sizes.length>0&&this.sample_size===0&&(e=false),this.size=8,e||(this.size+=4*this.sample_sizes.length),this.writeHeader(t),t.writeUint32(this.sample_size),t.writeUint32(this.sample_sizes.length),e||t.writeUint32Array(this.sample_sizes)}unpack(t){for(let e=0;e<this.sample_sizes.length;e++)t[e].size=this.sample_sizes[e]}},Ts.fourcc="stsz",Ts),En=(Ds=class extends p{constructor(...t){super(...t),this.box_name="TimeToSampleBox",this.sample_counts=[],this.sample_deltas=[]}parse(t){this.parseFullHeader(t);let e=t.readUint32();if(this.sample_counts.length=0,this.sample_deltas.length=0,this.version===0)for(let s=0;s<e;s++){this.sample_counts.push(t.readUint32());let i=t.readInt32();i<0&&(d.warn("BoxParser","File uses negative stts sample delta, using value 1 instead, sync may be lost!"),i=1),this.sample_deltas.push(i)}}write(t){this.version=0,this.flags=0,this.size=4+8*this.sample_counts.length,this.writeHeader(t),t.writeUint32(this.sample_counts.length);for(let e=0;e<this.sample_counts.length;e++)t.writeUint32(this.sample_counts[e]),t.writeUint32(this.sample_deltas[e])}unpack(t){let e=0;for(let s=0;s<this.sample_counts.length;s++)for(let i=0;i<this.sample_counts[s];i++)e===0?t[e].dts=0:t[e].dts=t[e-1].dts+this.sample_deltas[s],e++}},Ds.fourcc="stts",Ds),Cn=(Ls=class extends p{constructor(...t){super(...t),this.box_name="TrackFragmentBaseMediaDecodeTimeBox"}parse(t){this.parseFullHeader(t),this.baseMediaDecodeTime=this.version===1?t.readUint64():t.readUint32()}write(t){let e=this.baseMediaDecodeTime>B||this.version===1;this.version=+!!e,this.size=4,this.size+=e?4:0,this.flags=0,this.writeHeader(t),e?t.writeUint64(this.baseMediaDecodeTime):t.writeUint32(this.baseMediaDecodeTime)}},Ls.fourcc="tfdt",Ls),Pn=(Hs=class extends p{constructor(...t){super(...t),this.box_name="TrackFragmentHeaderBox"}parse(t){this.parseFullHeader(t);let e=0;this.track_id=t.readUint32(),this.size-this.hdr_size>e&&this.flags&1?(this.base_data_offset=t.readUint64(),e+=8):this.base_data_offset=0,this.size-this.hdr_size>e&&this.flags&2?(this.default_sample_description_index=t.readUint32(),e+=4):this.default_sample_description_index=0,this.size-this.hdr_size>e&&this.flags&8?(this.default_sample_duration=t.readUint32(),e+=4):this.default_sample_duration=0,this.size-this.hdr_size>e&&this.flags&16?(this.default_sample_size=t.readUint32(),e+=4):this.default_sample_size=0,this.size-this.hdr_size>e&&this.flags&32?(this.default_sample_flags=t.readUint32(),e+=4):this.default_sample_flags=0}write(t){this.version=0,this.size=4,this.flags&1&&(this.size+=8),this.flags&2&&(this.size+=4),this.flags&8&&(this.size+=4),this.flags&16&&(this.size+=4),this.flags&32&&(this.size+=4),this.writeHeader(t),t.writeUint32(this.track_id),this.flags&1&&t.writeUint64(this.base_data_offset),this.flags&2&&t.writeUint32(this.default_sample_description_index),this.flags&8&&t.writeUint32(this.default_sample_duration),this.flags&16&&t.writeUint32(this.default_sample_size),this.flags&32&&t.writeUint32(this.default_sample_flags)}},Hs.fourcc="tfhd",Hs),An=(Ms=class extends p{constructor(...t){super(...t),this.box_name="TrackHeaderBox",this.layer=0,this.alternate_group=0}parse(t){this.parseFullHeader(t),this.version===1?(this.creation_time=t.readUint64(),this.modification_time=t.readUint64(),this.track_id=t.readUint32(),t.readUint32(),this.duration=t.readUint64()):(this.creation_time=t.readUint32(),this.modification_time=t.readUint32(),this.track_id=t.readUint32(),t.readUint32(),this.duration=t.readUint32()),t.readUint32Array(2),this.layer=t.readInt16(),this.alternate_group=t.readInt16(),this.volume=t.readInt16()>>8,t.readUint16(),this.matrix=t.readInt32Array(9),this.width=t.readUint32(),this.height=t.readUint32()}write(t){let e=this.modification_time>B||this.creation_time>B||this.duration>B||this.version===1;this.version=+!!e,this.size=80,this.size+=e?12:0,this.flags=this.flags??3,this.writeHeader(t),e?(t.writeUint64(this.creation_time),t.writeUint64(this.modification_time),t.writeUint32(this.track_id),t.writeUint32(0),t.writeUint64(this.duration)):(t.writeUint32(this.creation_time),t.writeUint32(this.modification_time),t.writeUint32(this.track_id),t.writeUint32(0),t.writeUint32(this.duration)),t.writeUint32Array([0,0]),t.writeInt16(this.layer),t.writeInt16(this.alternate_group),t.writeInt16(this.volume<<8),t.writeInt16(0),t.writeInt32Array(this.matrix),t.writeUint32(this.width),t.writeUint32(this.height)}print(t){super.printHeader(t),t.log(t.indent+"creation_time: "+this.creation_time),t.log(t.indent+"modification_time: "+this.modification_time),t.log(t.indent+"track_id: "+this.track_id),t.log(t.indent+"duration: "+this.duration),t.log(t.indent+"volume: "+(this.volume>>8)),t.log(t.indent+"matrix: "+this.matrix.join(", ")),t.log(t.indent+"layer: "+this.layer),t.log(t.indent+"alternate_group: "+this.alternate_group),t.log(t.indent+"width: "+this.width),t.log(t.indent+"height: "+this.height)}},Ms.fourcc="tkhd",Ms),Aa=(Os=class extends p{constructor(...t){super(...t),this.box_name="TrackExtendsBox"}parse(t){this.parseFullHeader(t),this.track_id=t.readUint32(),this.default_sample_description_index=t.readUint32(),this.default_sample_duration=t.readUint32(),this.default_sample_size=t.readUint32(),this.default_sample_flags=t.readUint32()}write(t){this.version=0,this.flags=0,this.size=20,this.writeHeader(t),t.writeUint32(this.track_id),t.writeUint32(this.default_sample_description_index),t.writeUint32(this.default_sample_duration),t.writeUint32(this.default_sample_size),t.writeUint32(this.default_sample_flags)}},Os.fourcc="trex",Os),Fn=(Rs=class extends p{constructor(...t){super(...t),this.box_name="TrackRunBox",this.sample_duration=[],this.sample_size=[],this.sample_flags=[],this.sample_composition_time_offset=[]}parse(t){this.parseFullHeader(t);let e=0;if(this.sample_count=t.readUint32(),e+=4,this.size-this.hdr_size>e&&this.flags&1?(this.data_offset=t.readInt32(),e+=4):this.data_offset=0,this.size-this.hdr_size>e&&this.flags&4?(this.first_sample_flags=t.readUint32(),e+=4):this.first_sample_flags=0,this.sample_duration=[],this.sample_size=[],this.sample_flags=[],this.sample_composition_time_offset=[],this.size-this.hdr_size>e)for(let s=0;s<this.sample_count;s++)this.flags&256&&(this.sample_duration[s]=t.readUint32()),this.flags&512&&(this.sample_size[s]=t.readUint32()),this.flags&1024&&(this.sample_flags[s]=t.readUint32()),this.flags&2048&&(this.version===0?this.sample_composition_time_offset[s]=t.readUint32():this.sample_composition_time_offset[s]=t.readInt32())}write(t){this.size=4,this.flags&1&&(this.size+=4),this.flags&4&&(this.size+=4),this.flags&256&&(this.size+=4*this.sample_duration.length),this.flags&512&&(this.size+=4*this.sample_size.length),this.flags&1024&&(this.size+=4*this.sample_flags.length),this.flags&2048&&(this.size+=4*this.sample_composition_time_offset.length),this.writeHeader(t),t.writeUint32(this.sample_count),this.flags&1&&(this.data_offset_position=t.getPosition(),t.writeInt32(this.data_offset)),this.flags&4&&t.writeUint32(this.first_sample_flags);for(let e=0;e<this.sample_count;e++)this.flags&256&&t.writeUint32(this.sample_duration[e]),this.flags&512&&t.writeUint32(this.sample_size[e]),this.flags&1024&&t.writeUint32(this.sample_flags[e]),this.flags&2048&&(this.version===0?t.writeUint32(this.sample_composition_time_offset[e]):t.writeInt32(this.sample_composition_time_offset[e]))}},Rs.fourcc="trun",Rs),Tn=(Ns=class extends p{constructor(...t){super(...t),this.box_name="DataEntryUrlBox"}parse(t){this.parseFullHeader(t),this.flags!==1&&(this.location=t.readCString())}write(t){this.version=0,this.location?(this.flags=0,this.size=this.location.length+1):(this.flags=1,this.size=0),this.writeHeader(t),this.location&&t.writeCString(this.location)}},Ns.fourcc="url ",Ns),Dn=(Vs=class extends p{constructor(...t){super(...t),this.box_name="VideoMediaHeaderBox"}parse(t){this.parseFullHeader(t),this.graphicsmode=t.readUint16(),this.opcolor=t.readUint16Array(3)}write(t){this.version=0,this.size=8,this.writeHeader(t),t.writeUint16(this.graphicsmode),t.writeUint16Array(this.opcolor)}},Vs.fourcc="vmhd",Vs),Ys=class{constructor(t,e,s){this.grouping_type=t,this.grouping_type_parameter=e,this.sbgp=s,this.last_sample_in_run=-1,this.entry_index=-1}},Kh=class L{constructor(e,s=true){this.boxes=[],this.mdats=[],this.moofs=[],this.isProgressive=false,this.moovStartFound=false,this.moovStartSent=false,this.readySent=false,this.sampleListBuilt=false,this.fragmentedTracks=[],this.extractedTracks=[],this.isFragmentationInitialized=false,this.sampleProcessingStarted=false,this.nextMoofNumber=0,this.itemListBuilt=false,this.sidxSent=false,this.items=[],this.entity_groups=[],this.itemsDataSize=0,this.lastMoofIndex=0,this.samplesDataSize=0,this.lastBoxStartPosition=0,this.nextParsePosition=0,this.discardMdatData=true,this.discardMdatData=s,e?(this.stream=e,this.parse()):this.stream=new at,this.stream.isofile=this}setSegmentOptions(e,s,i){let{sizePerSegment:r=2**53-1,rapAlignement:a=true,normalizeAudioSampleEntriesForMSE:n=true}=i,o=i.nbSamples??i.nbSamplesPerFragment??1e3,l=i.nbSamplesPerFragment??o;if(o<=0||l<=0||r<=0){d.error("ISOFile",`Invalid segment options: nbSamples=${o}, nbSamplesPerFragment=${l}, sizePerSegment=${r}`);return}if(o<l&&(d.warn("ISOFile",`nbSamples (${o}) is less than nbSamplesPerFragment (${l}), setting nbSamples to nbSamplesPerFragment`),o=l),this.fragmentedTracks.some(c=>c.nb_samples!==o)){d.error("ISOFile",`Cannot set segment options for track ${e}: nbSamples (${o}) does not match existing tracks`);return}let h=this.getTrackById(e);if(h){let c={id:e,user:s,trak:h,segmentStream:void 0,nb_samples:o,nb_samples_per_fragment:l,size_per_segment:r,rapAlignement:a,normalizeAudioSampleEntriesForMSE:n,state:{lastFragmentSampleNumber:0,lastSegmentSampleNumber:0,accumulatedSize:0}};this.fragmentedTracks.push(c),h.nextSample=0}this.discardMdatData&&d.warn("ISOFile","Segmentation options set but discardMdatData is true, samples will not be segmented")}unsetSegmentOptions(e){let s=-1;for(let i=0;i<this.fragmentedTracks.length;i++)this.fragmentedTracks[i].id===e&&(s=i);s>-1&&this.fragmentedTracks.splice(s,1)}setExtractionOptions(e,s,{nbSamples:i=1e3}={}){let r=this.getTrackById(e);r&&(this.extractedTracks.push({id:e,user:s,trak:r,nb_samples:i,samples:[]}),r.nextSample=0),this.discardMdatData&&d.warn("ISOFile","Extraction options set but discardMdatData is true, samples will not be extracted")}unsetExtractionOptions(e){let s=-1;for(let i=0;i<this.extractedTracks.length;i++)this.extractedTracks[i].id===e&&(s=i);s>-1&&this.extractedTracks.splice(s,1)}parse(){if(!this.restoreParsePosition||this.restoreParsePosition())for(;;)if(this.hasIncompleteMdat&&this.hasIncompleteMdat()){if(this.processIncompleteMdat())continue;return}else{this.saveParsePosition&&this.saveParsePosition();let e=H(this.stream,false);if(e.code===0){if(this.processIncompleteBox){if(this.processIncompleteBox(e))continue;return}return}if(e.code===1){let s=e.box;if(this.boxes.push(s),s.type==="uuid")this[s.uuid]!==void 0&&d.warn("ISOFile","Duplicate Box of uuid: "+s.uuid+", overriding previous occurrence"),this[s.uuid]=s;else switch(s.type){case"mdat":this.mdats.push(s),this.transferMdatData(s);break;case"moof":this.moofs.push(s);break;case"free":case"skip":break;case"moov":this.moovStartFound=true,this.mdats.length===0&&(this.isProgressive=true);default:this[s.type]===void 0?(this[s.type]=s,Array.isArray(this[s.type+"s"])&&this[s.type+"s"].push(s)):Array.isArray(this[s.type+"s"])?(d.info("ISOFile",`Found multiple boxes of type ${s.type} in ISOFile, adding to array`),this[s.type+"s"].push(s)):(d.warn("ISOFile",`Found multiple boxes of type ${s.type} but no array exists. Creating array dynamically.`),this[s.type+"s"]=[this[s.type],s])}this.updateUsedBytes&&this.updateUsedBytes(s,e)}else if(e.code===-1){d.error("ISOFile",`Invalid data found while parsing box of type '${e.type}' at position ${e.start}. Aborting parsing.`,this);break}}}checkBuffer(e){if(!e)throw Error("Buffer must be defined and non empty");return e.byteLength===0?(d.warn("ISOFile","Ignoring empty buffer (fileStart: "+e.fileStart+")"),this.stream.logBufferLevel(),false):(d.info("ISOFile","Processing buffer (fileStart: "+e.fileStart+")"),e.usedBytes=0,this.stream.insertBuffer(e),this.stream.logBufferLevel(),this.stream.initialized()?true:(d.warn("ISOFile","Not ready to start parsing"),false))}appendBuffer(e,s){let i;if(this.checkBuffer(e))return this.parse(),this.moovStartFound&&!this.moovStartSent&&(this.moovStartSent=true,this.onMoovStart&&this.onMoovStart()),this.moov?(this.sampleListBuilt||(this.buildSampleLists(),this.sampleListBuilt=true),this.updateSampleLists(),this.onReady&&!this.readySent&&(this.readySent=true,this.onReady(this.getInfo())),this.processSamples(s),this.nextSeekPosition?(i=this.nextSeekPosition,this.nextSeekPosition=void 0):i=this.nextParsePosition,this.stream.getEndFilePositionAfter&&(i=this.stream.getEndFilePositionAfter(i))):i=this.nextParsePosition?this.nextParsePosition:0,this.sidx&&this.onSidx&&!this.sidxSent&&(this.onSidx(this.sidx),this.sidxSent=true),this.meta&&(this.flattenItemInfo&&!this.itemListBuilt&&(this.flattenItemInfo(),this.itemListBuilt=true),this.processItems&&this.processItems(this.onItem)),this.stream.cleanBuffers&&(d.info("ISOFile","Done processing buffer (fileStart: "+e.fileStart+") - next buffer to fetch should have a fileStart position of "+i),this.stream.logBufferLevel(),this.stream.cleanBuffers(),this.stream.logBufferLevel(true),d.info("ISOFile","Sample data size in memory: "+this.getAllocatedSampleDataSize())),i}getFragmentDuration(){let e=this.getBox("mvex");if(!e)return;if(e.mehd)return{num:e.mehd.fragment_duration,den:this.moov.mvhd.timescale};let s=this.getBoxes("trak",false),i={num:0,den:1};for(let r of s){let a=r.samples_duration,n=r.mdia.mdhd.timescale;a&&n&&a/n>i.num/i.den&&(i={num:a,den:n})}return i}getInfo(){if(!this.moov)return{hasMoov:false,mime:""};let e=new Date("1904-01-01T00:00:00Z").getTime(),s=this.getBox("mvex")!==void 0,i={hasMoov:true,duration:this.moov.mvhd.duration,timescale:this.moov.mvhd.timescale,isFragmented:s,fragment_duration:this.getFragmentDuration(),isProgressive:this.isProgressive,hasIOD:this.moov.iods!==void 0,brands:[this.ftyp.major_brand].concat(this.ftyp.compatible_brands),created:new Date(e+this.moov.mvhd.creation_time*1e3),modified:new Date(e+this.moov.mvhd.modification_time*1e3),tracks:[],audioTracks:[],videoTracks:[],subtitleTracks:[],metadataTracks:[],hintTracks:[],otherTracks:[],mime:""};for(let r=0;r<this.moov.traks.length;r++){let a=this.moov.traks[r],n=a.mdia.minf.stbl.stsd.entries[0],o=a.samples_size,l=a.mdia.mdhd.timescale,h=a.samples_duration,c={samples_duration:h,bitrate:o*8*l/h,size:o,timescale:l,alternate_group:a.tkhd.alternate_group,codec:n.getCodec(),created:new Date(e+a.tkhd.creation_time*1e3),cts_shift:a.mdia.minf.stbl.cslg,duration:a.mdia.mdhd.duration,id:a.tkhd.track_id,kind:a.udta&&a.udta.kinds.length?a.udta.kinds[0]:{schemeURI:"",value:""},language:a.mdia.elng?a.mdia.elng.extended_language:a.mdia.mdhd.languageString,layer:a.tkhd.layer,matrix:a.tkhd.matrix,modified:new Date(e+a.tkhd.modification_time*1e3),movie_duration:a.tkhd.duration,movie_timescale:i.timescale,name:a.mdia.hdlr.name,nb_samples:a.samples.length,references:[],track_height:a.tkhd.height/65536,track_width:a.tkhd.width/65536,volume:a.tkhd.volume};if(i.tracks.push(c),a.tref)for(let u=0;u<a.tref.references.length;u++)c.references.push({type:a.tref.references[u].type,track_ids:a.tref.references[u].track_ids});a.edts!==void 0&&a.edts.elst!==void 0&&(c.edits=a.edts.elst.entries),n instanceof A?(c.type="audio",i.audioTracks.push(c),c.audio={sample_rate:n.getSampleRate(),channel_count:n.getChannelCount(),sample_size:n.getSampleSize()}):n instanceof w?(c.type="video",i.videoTracks.push(c),c.video={width:n.getWidth(),height:n.getHeight()}):n instanceof G?(c.type="subtitles",i.subtitleTracks.push(c)):n instanceof Ga?(c.type="metadata",i.hintTracks.push(c)):n instanceof J?(c.type="metadata",i.metadataTracks.push(c)):(c.type="metadata",i.otherTracks.push(c))}i.videoTracks&&i.videoTracks.length>0?i.mime+='video/mp4; codecs="':i.audioTracks&&i.audioTracks.length>0?i.mime+='audio/mp4; codecs="':i.mime+='application/mp4; codecs="';for(let r=0;r<i.tracks.length;r++)r!==0&&(i.mime+=","),i.mime+=i.tracks[r].codec;return i.mime+='"; profiles="',i.mime+=this.ftyp.compatible_brands.join(),i.mime+='"',i}setNextSeekPositionFromSample(e){e&&(this.nextSeekPosition=this.nextSeekPosition?Math.min(e.offset+e.alreadyRead,this.nextSeekPosition):e.offset+e.alreadyRead)}processSamples(e){if(this.sampleProcessingStarted){if(this.isFragmentationInitialized&&this.onSegment!==void 0){let s=new Set;for(;s.size<this.fragmentedTracks.length&&this.fragmentedTracks.some(i=>i.trak.nextSample<i.trak.samples.length)&&this.sampleProcessingStarted;)for(let i of this.fragmentedTracks){let r=i.trak;if(!s.has(i.id)){let a=r.nextSample<r.samples.length?this.getSample(r,r.nextSample):void 0;if(!a){this.setNextSeekPositionFromSample(r.samples[r.nextSample]),s.add(i.id);continue}i.state.accumulatedSize+=a.size;let n=r.nextSample+1,o=n-i.state.lastFragmentSampleNumber>i.nb_samples_per_fragment,l=n-i.state.lastSegmentSampleNumber>i.nb_samples,h=o||n%i.nb_samples_per_fragment===0,c=l||n%i.nb_samples===0,u=i.state.accumulatedSize>=i.size_per_segment,m=!i.rapAlignement||a.is_sync,_=e||r.nextSample+1>=r.samples.length;if(_&&!m&&d.warn("ISOFile","Flushing track #"+i.id+" at sample #"+r.nextSample+" which is not a RAP, this may lead to playback issues"),h=h&&m,c=c&&m,u=u&&m,h||u||_){o?d.warn("ISOFile","Fragment on track #"+i.id+" is overdue, creating it with samples ["+i.state.lastFragmentSampleNumber+", "+r.nextSample+"]"):d.debug("ISOFile","Creating media fragment on track #"+i.id+" for samples ["+i.state.lastFragmentSampleNumber+", "+r.nextSample+"]");let U=this.createFragment(i.id,i.state.lastFragmentSampleNumber,r.nextSample,i.segmentStream);if(U)i.segmentStream=U,i.state.lastFragmentSampleNumber=r.nextSample+1;else{s.add(i.id);continue}}(c||u||_)&&(l?d.warn("ISOFile","Segment on track #"+i.id+" is overdue, sending it with samples ["+Math.max(0,r.nextSample-i.nb_samples)+", "+(r.nextSample-1)+"]"):d.info("ISOFile","Sending fragmented data on track #"+i.id+" for samples ["+Math.max(0,r.nextSample-i.nb_samples)+", "+(r.nextSample-1)+"]"),d.info("ISOFile","Sample data size in memory: "+this.getAllocatedSampleDataSize()),this.onSegment&&this.onSegment(i.id,i.user,i.segmentStream.buffer,r.nextSample+1,e||r.nextSample+1>=r.samples.length),i.segmentStream=void 0,i.state.accumulatedSize=0,i.state.lastSegmentSampleNumber=r.nextSample+1),r.nextSample++}}}if(this.onSamples!==void 0)for(let s=0;s<this.extractedTracks.length;s++){let i=this.extractedTracks[s],r=i.trak;for(;r.nextSample<r.samples.length&&this.sampleProcessingStarted;){d.debug("ISOFile","Exporting on track #"+i.id+" sample #"+r.nextSample);let a=this.getSample(r,r.nextSample);if(a)r.nextSample++,i.samples.push(a);else{this.setNextSeekPositionFromSample(r.samples[r.nextSample]);break}if((r.nextSample%i.nb_samples===0||r.nextSample>=r.samples.length)&&(d.debug("ISOFile","Sending samples on track #"+i.id+" for sample "+r.nextSample),this.onSamples&&this.onSamples(i.id,i.user,i.samples),i.samples=[],i!==this.extractedTracks[s]))break}}}}getBox(e){let s=this.getBoxes(e,true);return s.length?s[0]:void 0}getBoxes(e,s){let i=[],r=a=>{a instanceof f&&a.type&&a.type===e&&i.push(a);let n=[];a.boxes&&n.push(...a.boxes),a.entries&&n.push(...a.entries),a.item_infos&&n.push(...a.item_infos),a.references&&n.push(...a.references);for(let o of n){if(i.length&&s)return;r(o)}};return r(this),i}getTrackSamplesInfo(e){let s=this.getTrackById(e);if(s)return s.samples}getTrackSample(e,s){let i=this.getTrackById(e);return this.getSample(i,s)}releaseUsedSamples(e,s){let i=0,r=this.getTrackById(e);r.lastValidSample||(r.lastValidSample=0);for(let a=r.lastValidSample;a<s;a++)i+=this.releaseSample(r,a);d.info("ISOFile","Track #"+e+" released samples up to "+s+" (released size: "+i+", remaining: "+this.samplesDataSize+")"),r.lastValidSample=s}start(){this.sampleProcessingStarted=true,this.processSamples(false)}stop(){this.sampleProcessingStarted=false}flush(){d.info("ISOFile","Flushing remaining samples"),this.updateSampleLists(),this.processSamples(true),this.stream.cleanBuffers(),this.stream.logBufferLevel(true)}seekTrack(e,s,i){let r=0,a=0,n;if(i.samples.length===0)return d.info("ISOFile","No sample in track, cannot seek! Using time "+d.getDurationString(0,1)+" and offset: 0"),{offset:0,time:0};for(let l=0;l<i.samples.length;l++){let h=i.samples[l];if(l===0)a=0,n=h.timescale;else if(h.cts>e*h.timescale){a=l-1;break}s&&h.is_sync&&(r=l)}for(s&&(a=r),e=i.samples[a].cts,i.nextSample=a,this.resetFragmentedTrackStateAfterSeek(i,a),this.resetExtractedTrackStateAfterSeek(i);i.samples[a].alreadyRead===i.samples[a].size&&i.samples[a+1];)a++;let o=i.samples[a].offset+i.samples[a].alreadyRead;return d.info("ISOFile","Seeking to "+(s?"RAP":"")+" sample #"+i.nextSample+" on track "+i.tkhd.track_id+", time "+d.getDurationString(e,n)+" and offset: "+o),{offset:o,time:e/n}}resetFragmentedTrackStateAfterSeek(e,s){let i=this.fragmentedTracks.find(r=>r.trak===e);i&&(i.state.lastFragmentSampleNumber=s,i.state.lastSegmentSampleNumber=s,i.state.accumulatedSize=0,i.segmentStream=void 0)}resetExtractedTrackStateAfterSeek(e){let s=this.extractedTracks.find(i=>i.trak===e);s&&(s.samples=[])}getTrackDuration(e){if(!e.samples)return 1/0;let s=e.samples[e.samples.length-1];return(s.cts+s.duration)/s.timescale}seek(e,s){let i=this.moov,r={offset:1/0,time:1/0};if(this.moov){for(let a=0;a<i.traks.length;a++){let n=i.traks[a];if(e>this.getTrackDuration(n))continue;let o=this.seekTrack(e,s,n);o.offset<r.offset&&(r.offset=o.offset),o.time<r.time&&(r.time=o.time)}return d.info("ISOFile","Seeking at time "+d.getDurationString(r.time,1)+" needs a buffer with a fileStart position of "+r.offset),r.offset===1/0?r={offset:this.nextParsePosition,time:0}:r.offset=this.stream.getEndFilePositionAfter(r.offset),d.info("ISOFile","Adjusted seek position (after checking data already in buffer): "+r.offset),r}throw Error("Cannot seek: moov not received!")}equal(e){let s=0;for(;s<this.boxes.length&&s<e.boxes.length;){let i=this.boxes[s],r=e.boxes[s];if(!Ja(i,r))return false;s++}return true}write(e){for(let s=0;s<this.boxes.length;s++)this.boxes[s].write(e)}createFragment(e,s,i,r){if(i<s)return d.warn("ISOFile",`Skipping fragment creation on track #${e}: invalid sample range [${s}, ${i}]`),r||new C;let a=[];for(let c=s;c<=i;c++){let u=this.getTrackById(e),m=this.getSample(u,c);if(!m){this.setNextSeekPositionFromSample(u.samples[c]);return}a.push(m)}let n=r||new C,o=this.createMoof(a);o.write(n),o.trafs[0].truns[0].data_offset=o.size+8,d.debug("MP4Box","Adjusting data_offset with new value "+o.trafs[0].truns[0].data_offset),n.adjustUint32(o.trafs[0].truns[0].data_offset_position,o.trafs[0].truns[0].data_offset);let l=new nt;l.stream=new at;let h=0;for(let c of a)if(c.data){let u=R.fromArrayBuffer(c.data.buffer,h);l.stream.insertBuffer(u),h+=c.data.byteLength}return l.write(n),n}static writeInitializationSegment(e,s,i,r){var o;d.debug("ISOFile","Generating initialization segment");let a=new C;e.write(a);let n=L.normalizeAudioSampleEntriesForMSEFragmentedInit(s.traks,r);try{let l=s.addBox(new Pa);if(i){let h=l.addBox(new mn);h.fragment_duration=i}for(let h=0;h<s.traks.length;h++){let c=l.addBox(new Aa);c.track_id=s.traks[h].tkhd.track_id,c.default_sample_description_index=1,c.default_sample_duration=((o=s.traks[h].samples[0])==null?void 0:o.duration)??0,c.default_sample_size=0,c.default_sample_flags=65536}s.write(a)}finally{for(let l=n.length-1;l>=0;l--)n[l]()}return a.buffer}save(e){let s=new C;return s.isofile=this,this.write(s),s.save(e)}getBuffer(){let e=new C;return e.isofile=this,this.write(e),e}static normalizeAudioSampleEntriesForMSEFragmentedInit(e,s){var r,a;let i=[];for(let n of e)if(s!=null&&s.has(n.tkhd.track_id))for(let o of((r=n.mdia.minf.stbl.stsd)==null?void 0:r.entries)??[]){if(!(o instanceof Un))continue;let l=(a=o.wave)==null?void 0:a.esds;if(o.esds||!l)continue;let h=o.esds,c=o.wave,u=o.boxes;i.push(()=>{o.esds=h,o.wave=c,o.boxes=u});let m=Array.isArray(o.boxes)?o.boxes.filter(_=>(_==null?void 0:_.type)!=="wave"&&(_==null?void 0:_.type)!=="esds"):[];o.esds=l,o.boxes=[...m,l],o.wave=void 0}return i}initializeSegmentation(e){var n,o,l;if(this.onSegment||d.warn("MP4Box","No segmentation callback set!"),e!==void 0&&e!=="combined"&&e!=="per-track")throw Error(`Invalid segmentation mode: ${e}`);this.isFragmentationInitialized||(this.isFragmentationInitialized=true,this.resetTables());let s=[];for(let h of this.fragmentedTracks){let c=this.getTrackById(h.id);c?s.push({id:h.id,user:h.user,trak:c}):d.warn("ISOFile",`Track with id ${h.id} not found, skipping fragmentation initialization`)}let i=(l=(o=(n=this.moov)==null?void 0:n.mvex)==null?void 0:o.mehd)==null?void 0:l.fragment_duration,r=new Set(this.fragmentedTracks.filter(h=>h.normalizeAudioSampleEntriesForMSE!==false).map(h=>h.id));if(e==="per-track")return s.map(({id:h,user:c,trak:u})=>{let m=new ot;return m.addBox(this.moov.mvhd),m.addBox(u),{id:h,user:c,buffer:L.writeInitializationSegment(this.ftyp,m,i,r)}});let a=new ot;a.addBox(this.moov.mvhd);for(let h of s)a.addBox(h.trak);return{tracks:s.map(({id:h,user:c})=>({id:h,user:c})),buffer:L.writeInitializationSegment(this.ftyp,a,i,r)}}resetTables(){this.initial_duration=this.moov.mvhd.duration,this.moov.mvhd.duration=0;for(let e=0;e<this.moov.traks.length;e++){let s=this.moov.traks[e];s.tkhd.duration=0,s.mdia.mdhd.duration=0;let i=s.mdia.minf.stbl.stco||s.mdia.minf.stbl.co64;i.chunk_offsets=[];let r=s.mdia.minf.stbl.stsc;r.first_chunk=[],r.samples_per_chunk=[],r.sample_description_index=[];let a=s.mdia.minf.stbl.stsz||s.mdia.minf.stbl.stz2;a.sample_sizes=[];let n=s.mdia.minf.stbl.stts;n.sample_counts=[],n.sample_deltas=[];let o=s.mdia.minf.stbl.ctts;o&&(o.sample_counts=[],o.sample_offsets=[]);let l=s.mdia.minf.stbl.stss,h=s.mdia.minf.stbl.boxes.indexOf(l);h!==-1&&(s.mdia.minf.stbl.boxes[h]=void 0)}}static initSampleGroups(e,s,i,r,a){s&&(s.sample_groups_info=[]),e.sample_groups_info||(e.sample_groups_info=[]);for(let n=0;n<i.length;n++){let o=i[n].grouping_type+"/"+i[n].grouping_type_parameter,l=new Ys(i[n].grouping_type,i[n].grouping_type_parameter,i[n]);s&&(s.sample_groups_info[o]=l),e.sample_groups_info[o]||(e.sample_groups_info[o]=l);for(let h=0;h<r.length;h++)r[h].grouping_type===i[n].grouping_type&&(l.description=r[h],l.description.used=true);if(a)for(let h=0;h<a.length;h++)a[h].grouping_type===i[n].grouping_type&&(l.fragment_description=a[h],l.fragment_description.used=true,l.is_fragment=true)}if(s){if(a){for(let n=0;n<a.length;n++)if(!a[n].used&&a[n].version>=2){let o=a[n].grouping_type+"/0",l=new Ys(a[n].grouping_type,0);l.is_fragment=true,s.sample_groups_info[o]||(s.sample_groups_info[o]=l)}}}else for(let n=0;n<r.length;n++)if(!r[n].used&&r[n].version>=2){let o=r[n].grouping_type+"/0",l=new Ys(r[n].grouping_type,0);e.sample_groups_info[o]||(e.sample_groups_info[o]=l)}}static setSampleGroupProperties(e,s,i,r){s.sample_groups=[];for(let a in r)if(s.sample_groups[a]={grouping_type:r[a].grouping_type,grouping_type_parameter:r[a].grouping_type_parameter},i>=r[a].last_sample_in_run&&(r[a].last_sample_in_run<0&&(r[a].last_sample_in_run=0),r[a].entry_index++,r[a].entry_index<=r[a].sbgp.entries.length-1&&(r[a].last_sample_in_run+=r[a].sbgp.entries[r[a].entry_index].sample_count)),r[a].entry_index<=r[a].sbgp.entries.length-1?s.sample_groups[a].group_description_index=r[a].sbgp.entries[r[a].entry_index].group_description_index:s.sample_groups[a].group_description_index=-1,s.sample_groups[a].group_description_index!==0){let n;if(n=r[a].fragment_description?r[a].fragment_description:r[a].description,s.sample_groups[a].group_description_index>0){let o;o=s.sample_groups[a].group_description_index>65535?(s.sample_groups[a].group_description_index>>16)-1:s.sample_groups[a].group_description_index-1,n&&o>=0&&(s.sample_groups[a].description=n.entries[o])}else n&&n.version>=2&&n.default_group_description_index>0&&(s.sample_groups[a].description=n.entries[n.default_group_description_index-1])}}static process_sdtp(e,s,i){s&&(e?(s.is_leading=e.is_leading[i],s.depends_on=e.sample_depends_on[i],s.is_depended_on=e.sample_is_depended_on[i],s.has_redundancy=e.sample_has_redundancy[i]):(s.is_leading=0,s.depends_on=0,s.is_depended_on=0,s.has_redundancy=0))}buildSampleLists(){for(let e=0;e<this.moov.traks.length;e++)this.buildTrakSampleLists(this.moov.traks[e])}buildTrakSampleLists(e){let s,i,r,a,n,o;e.samples=[],e.samples_duration=0,e.samples_size=0;let l=e.mdia.minf.stbl.stco||e.mdia.minf.stbl.co64,h=e.mdia.minf.stbl.stsc,c=e.mdia.minf.stbl.stsz||e.mdia.minf.stbl.stz2,u=e.mdia.minf.stbl.stts,m=e.mdia.minf.stbl.ctts,_=e.mdia.minf.stbl.stss,U=e.mdia.minf.stbl.stsd,y=e.mdia.minf.stbl.subs,z=e.mdia.minf.stbl.stdp,E=e.mdia.minf.stbl.sbgps,F=e.mdia.minf.stbl.sgpds,k=-1,S=-1,T=-1,q=-1,Q=0,D=0,O=0;if(L.initSampleGroups(e,void 0,E,F),c!==void 0){for(s=0;s<c.sample_sizes.length;s++){let g={number:s,track_id:e.tkhd.track_id,timescale:e.mdia.mdhd.timescale,alreadyRead:0,size:c.sample_sizes[s]};e.samples[s]=g,e.samples_size+=g.size,s===0?(r=1,i=0,g.chunk_index=r,g.chunk_run_index=i,o=h.samples_per_chunk[i],n=0,a=i+1<h.first_chunk.length?h.first_chunk[i+1]-1:1/0):s<o?(g.chunk_index=r,g.chunk_run_index=i):(r++,g.chunk_index=r,n=0,r<=a||(i++,a=i+1<h.first_chunk.length?h.first_chunk[i+1]-1:1/0),g.chunk_run_index=i,o+=h.samples_per_chunk[i]),g.description_index=h.sample_description_index[g.chunk_run_index]-1,g.description=U.entries[g.description_index],g.offset=l.chunk_offsets[g.chunk_index-1]+n,n+=g.size,s>k&&(S++,k<0&&(k=0),k+=u.sample_counts[S]),s>0?(e.samples[s-1].duration=u.sample_deltas[S],e.samples_duration+=e.samples[s-1].duration,g.dts=e.samples[s-1].dts+e.samples[s-1].duration):g.dts=0,m?(s>=T&&(q++,T<0&&(T=0),T+=m.sample_counts[q]),g.cts=e.samples[s].dts+m.sample_offsets[q]):g.cts=g.dts,_?(s===_.sample_numbers[Q]-1?(g.is_sync=true,Q++):(g.is_sync=false,g.degradation_priority=0),y&&y.entries[D].sample_delta+O===s+1&&(g.subsamples=y.entries[D].subsamples,O+=y.entries[D].sample_delta,D++)):g.is_sync=true,L.process_sdtp(e.mdia.minf.stbl.sdtp,g,g.number),g.degradation_priority=z?z.priority[s]:0,y&&y.entries[D].sample_delta+O===s&&(g.subsamples=y.entries[D].subsamples,O+=y.entries[D].sample_delta),(E.length>0||F.length>0)&&L.setSampleGroupProperties(e,g,s,e.sample_groups_info)}s>0&&(e.samples[s-1].duration=Math.max(e.mdia.mdhd.duration-e.samples[s-1].dts,0),e.samples_duration+=e.samples[s-1].duration)}}updateSampleLists(){let e,s,i,r,a;if(this.moov!==void 0)for(;this.lastMoofIndex<this.moofs.length;){let n=this.moofs[this.lastMoofIndex];if(this.lastMoofIndex++,n.type==="moof"){let o=n;for(let l=0;l<o.trafs.length;l++){let h=o.trafs[l],c=this.getTrackById(h.tfhd.track_id),u=this.getTrexById(h.tfhd.track_id);e=h.tfhd.flags&2?h.tfhd.default_sample_description_index:u?u.default_sample_description_index:1,s=h.tfhd.flags&8?h.tfhd.default_sample_duration:u?u.default_sample_duration:0,i=h.tfhd.flags&16?h.tfhd.default_sample_size:u?u.default_sample_size:0,r=h.tfhd.flags&32?h.tfhd.default_sample_flags:u?u.default_sample_flags:0,h.sample_number=0,h.sbgps.length>0&&L.initSampleGroups(c,h,h.sbgps,c.mdia.minf.stbl.sgpds,h.sgpds);for(let m=0;m<h.truns.length;m++){let _=h.truns[m];for(let U=0;U<_.sample_count;U++){let y=e-1,z=r;_.flags&1024?z=_.sample_flags[U]:U===0&&_.flags&4&&(z=_.first_sample_flags);let E=i;_.flags&512&&(E=_.sample_size[U]),c.samples_size+=E;let F=s;_.flags&256&&(F=_.sample_duration[U]),c.samples_duration+=F;let k;c.first_traf_merged||U>0?k=c.samples[c.samples.length-1].dts+c.samples[c.samples.length-1].duration:(k=h.tfdt?h.tfdt.baseMediaDecodeTime:0,c.first_traf_merged=true);let S=k;_.flags&2048&&(S=k+_.sample_composition_time_offset[U]);let T=!!(h.tfhd.flags&1),q=!!(h.tfhd.flags&131072),Q=!!(_.flags&1),D=0;D=T?h.tfhd.base_data_offset:q||m===0?o.start:a;let O;O=m===0&&U===0?Q?D+_.data_offset:D:a,a=O+E;let g=h.sample_number;h.sample_number++;let ft={cts:S,description_index:y,description:c.mdia.minf.stbl.stsd.entries[y],dts:k,duration:F,moof_number:this.lastMoofIndex,number_in_traf:g,number:c.samples.length,offset:O,size:E,timescale:c.mdia.mdhd.timescale,track_id:c.tkhd.track_id,is_sync:!(z>>16&1),is_leading:z>>26&3,depends_on:z>>24&3,is_depended_on:z>>22&3,has_redundancy:z>>20&3,degradation_priority:z&65535};h.first_sample_index=c.samples.length,c.samples.push(ft),(h.sbgps.length>0||h.sgpds.length>0||c.mdia.minf.stbl.sbgps.length>0||c.mdia.minf.stbl.sgpds.length>0)&&L.setSampleGroupProperties(c,ft,ft.number_in_traf,h.sample_groups_info)}}if(h.subs){c.has_fragment_subsamples=true;let m=h.first_sample_index;for(let _=0;_<h.subs.entries.length;_++){m+=h.subs.entries[_].sample_delta;let U=c.samples[m-1];U.subsamples=h.subs.entries[_].subsamples}}}}}}getSample(e,s){let i=e.samples[s];if(this.moov){if(!i.data)i.data=new Uint8Array(i.size),i.alreadyRead=0,this.samplesDataSize+=i.size,d.debug("ISOFile","Allocating sample #"+s+" on track #"+e.tkhd.track_id+" of size "+i.size+" (total: "+this.samplesDataSize+")");else if(i.alreadyRead===i.size)return i;for(;;){let r=this.stream,a=r.findPosition(true,i.offset+i.alreadyRead,false),n,o;if(a>-1)n=r.buffers[a],o=n.fileStart;else for(let l of this.mdats)if(!l.stream)d.debug("ISOFile","mdat stream not yet fully read for #"+this.mdats.indexOf(l)+" mdat");else if(a=l.stream.findPosition(true,i.offset+i.alreadyRead-l.start-l.hdr_size,false),a>-1){r=l.stream,n=l.stream.buffers[a],o=l.start+l.hdr_size+n.fileStart;break}if(n){let l=n.byteLength-(i.offset+i.alreadyRead-o);if(i.size-i.alreadyRead<=l)return d.debug("ISOFile","Getting sample #"+s+" data (alreadyRead: "+i.alreadyRead+" offset: "+(i.offset+i.alreadyRead-o)+" read size: "+(i.size-i.alreadyRead)+" full size: "+i.size+")"),C.memcpy(i.data.buffer,i.alreadyRead,n,i.offset+i.alreadyRead-o,i.size-i.alreadyRead),n.usedBytes+=i.size-i.alreadyRead,r.logBufferLevel(),i.alreadyRead=i.size,i;if(l===0)return;d.debug("ISOFile","Getting sample #"+s+" partial data (alreadyRead: "+i.alreadyRead+" offset: "+(i.offset+i.alreadyRead-o)+" read size: "+l+" full size: "+i.size+")"),C.memcpy(i.data.buffer,i.alreadyRead,n,i.offset+i.alreadyRead-o,l),i.alreadyRead+=l,n.usedBytes+=l,r.logBufferLevel()}else return}}}releaseSample(e,s){let i=e.samples[s];return i.data?(this.samplesDataSize-=i.size,i.data=void 0,i.alreadyRead=0,i.size):0}getAllocatedSampleDataSize(){return this.samplesDataSize}getCodecs(){let e="";for(let s=0;s<this.moov.traks.length;s++){let i=this.moov.traks[s];s>0&&(e+=","),e+=i.mdia.minf.stbl.stsd.entries[0].getCodec()}return e}getTrexById(e){if(this.moov&&this.moov.mvex)for(let s=0;s<this.moov.mvex.trexs.length;s++){let i=this.moov.mvex.trexs[s];if(i.track_id===e)return i}}getTrackById(e){if(this.moov)for(let s=0;s<this.moov.traks.length;s++){let i=this.moov.traks[s];if(i.tkhd.track_id===e)return i}}flattenItemInfo(){let e=this.items,s=this.entity_groups,i=this.meta;if(i&&i.hdlr&&i.iinf){for(let r=0;r<i.iinf.item_infos.length;r++){let a=i.iinf.item_infos[r].item_ID;e[a]={id:a,name:i.iinf.item_infos[r].item_name,ref_to:[],content_type:i.iinf.item_infos[r].content_type,content_encoding:i.iinf.item_infos[r].content_encoding,item_uri_type:i.iinf.item_infos[r].item_uri_type,type:i.iinf.item_infos[r].item_type?i.iinf.item_infos[r].item_type:"mime",protection:i.iinf.item_infos[r].item_protection_index>0?i.ipro.protections[i.iinf.item_infos[r].item_protection_index-1]:void 0}}if(i.grpl)for(let r=0;r<i.grpl.boxes.length;r++){let a=i.grpl.boxes[r];s[a.group_id]={id:a.group_id,entity_ids:a.entity_ids,type:a.type}}if(i.iloc)for(let r=0;r<i.iloc.items.length;r++){let a=i.iloc.items[r],n=e[a.item_ID];a.data_reference_index!==0&&(d.warn("Item storage with reference to other files: not supported"),n.source=i.dinf.boxes[a.data_reference_index-1]),n.extents=[],n.size=0;for(let o=0;o<a.extents.length;o++)n.extents[o]={offset:a.extents[o].extent_offset+a.base_offset,length:a.extents[o].extent_length,alreadyRead:0},a.construction_method===1&&(n.extents[o].offset+=i.idat.start+i.idat.hdr_size),n.size+=n.extents[o].length}if(i.pitm){let r=i.pitm.item_id;e[r]?e[r].primary=true:d.warn("ISOFile","Primary item_id #"+r+" does not exist in items")}if(i.iref)for(let r=0;r<i.iref.references.length;r++){let a=i.iref.references[r];for(let n=0;n<a.references.length;n++)e[a.from_item_ID].ref_to.push({type:a.type,id:a.references[n]})}if(i.iprp)for(let r=0;r<i.iprp.ipmas.length;r++){let a=i.iprp.ipmas[r];for(let n=0;n<a.associations.length;n++){let o=a.associations[n],l=e[o.id]??s[o.id];if(l){l.properties===void 0&&(l.properties={boxes:[]});for(let h=0;h<o.props.length;h++){let c=o.props[h];if(c.property_index>0&&c.property_index-1<i.iprp.ipco.boxes.length){let u=i.iprp.ipco.boxes[c.property_index-1];l.properties[u.type]=u,l.properties.boxes.push(u)}}}}}}}getItem(e){if(!this.meta)return;let s=this.items[e];if(!s.data&&s.size)s.data=new Uint8Array(s.size),s.alreadyRead=0,this.itemsDataSize+=s.size,d.debug("ISOFile","Allocating item #"+e+" of size "+s.size+" (total: "+this.itemsDataSize+")");else if(s.alreadyRead===s.size)return s;for(let i=0;i<s.extents.length;i++){let r=s.extents[i];if(r.alreadyRead!==r.length){let a=this.stream.findPosition(true,r.offset+r.alreadyRead,false);if(a>-1){let n=this.stream.buffers[a],o=n.byteLength-(r.offset+r.alreadyRead-n.fileStart);if(r.length-r.alreadyRead<=o)d.debug("ISOFile","Getting item #"+e+" extent #"+i+" data (alreadyRead: "+r.alreadyRead+" offset: "+(r.offset+r.alreadyRead-n.fileStart)+" read size: "+(r.length-r.alreadyRead)+" full extent size: "+r.length+" full item size: "+s.size+")"),C.memcpy(s.data.buffer,s.alreadyRead,n,r.offset+r.alreadyRead-n.fileStart,r.length-r.alreadyRead),(!this.parsingMdat||this.discardMdatData)&&(n.usedBytes+=r.length-r.alreadyRead),this.stream.logBufferLevel(),s.alreadyRead+=r.length-r.alreadyRead,r.alreadyRead=r.length;else{d.debug("ISOFile","Getting item #"+e+" extent #"+i+" partial data (alreadyRead: "+r.alreadyRead+" offset: "+(r.offset+r.alreadyRead-n.fileStart)+" read size: "+o+" full extent size: "+r.length+" full item size: "+s.size+")"),C.memcpy(s.data.buffer,s.alreadyRead,n,r.offset+r.alreadyRead-n.fileStart,o),r.alreadyRead+=o,s.alreadyRead+=o,(!this.parsingMdat||this.discardMdatData)&&(n.usedBytes+=o),this.stream.logBufferLevel();return}}else return}}if(s.alreadyRead===s.size)return s}releaseItem(e){let s=this.items[e];if(s.data){this.itemsDataSize-=s.size,s.data=void 0,s.alreadyRead=0;for(let i=0;i<s.extents.length;i++){let r=s.extents[i];r.alreadyRead=0}return s.size}return 0}processItems(e){for(let s in this.items){let i=this.items[s];this.getItem(i.id),e&&!i.sent&&(e(i),i.sent=true,i.data=void 0)}}hasItem(e){for(let s in this.items){let i=this.items[s];if(i.name===e)return i.id}return-1}getMetaHandler(){if(this.meta)return this.meta.hdlr.handler}getPrimaryItem(){if(this.meta&&this.meta.pitm)return this.getItem(this.meta.pitm.item_id)}itemToFragmentedTrackFile({itemId:e}={}){let s;if(s=e?this.getItem(e):this.getPrimaryItem(),!s)return;let i=new L;i.discardMdatData=false;let r={type:s.type,description_boxes:s.properties.boxes};s.properties.ispe&&(r.width=s.properties.ispe.image_width,r.height=s.properties.ispe.image_height);let a=i.addTrack(r);if(a)return i.addSample(a,s.data),i}processIncompleteBox(e){if(e.type==="mdat"){let s=new nt(e.size);return this.parsingMdat=s,this.boxes.push(s),this.mdats.push(s),s.start=e.start,s.hdr_size=e.hdr_size,s.original_size=e.original_size,this.stream.addUsedBytes(s.hdr_size),this.lastBoxStartPosition=s.start+s.size,this.stream.seek(s.start+s.size,false,this.discardMdatData)?(this.transferMdatData(),this.parsingMdat=void 0,true):(this.nextParsePosition=this.moovStartFound?this.stream.findEndContiguousBuf():s.start+s.size,false)}return e.type==="moov"&&(this.moovStartFound=true,this.mdats.length===0&&(this.isProgressive=true)),this.stream.mergeNextBuffer&&this.stream.mergeNextBuffer()?(this.nextParsePosition=this.stream.getEndPosition(),true):(this.nextParsePosition=e.type?this.moovStartFound?this.stream.getEndPosition():this.stream.getPosition()+e.size:this.stream.getEndPosition(),false)}hasIncompleteMdat(){return this.parsingMdat!==void 0}transferMdatData(e){let s=e??this.parsingMdat;if(this.discardMdatData){d.debug("ISOFile","Discarding 'mdat' data, not transferring it to the mdat box stream");return}if(!s){d.warn("ISOFile","Cannot transfer 'mdat' data, no mdat box is being parsed");return}let i=this.stream.findPosition(true,s.start+s.hdr_size,false),r=this.stream.findPosition(true,s.start+s.size,false);if(i===-1||r===-1)d.warn("ISOFile","Cannot transfer 'mdat' data, start or end buffer not found");else{s.stream=new at;for(let a=i;a<=r;a++){let n=this.stream.buffers[a],o=a===i?s.start+s.hdr_size-n.fileStart:0,l=a===r?s.start+s.size-n.fileStart:n.byteLength;if(l>o){d.debug("ISOFile","Transferring 'mdat' data from buffer #"+a+" ("+o+" to "+l+")");let h=l-o,c=new R(h),u=s.stream.getAbsoluteEndPosition();C.memcpy(c,0,n,o,h),c.fileStart=u,s.stream.insertBuffer(c),n.usedBytes+=h}}}}processIncompleteMdat(){let e=this.parsingMdat;return this.stream.seek(e.start+e.size,false,this.discardMdatData)?(d.debug("ISOFile","Found 'mdat' end in buffered data"),this.transferMdatData(),this.parsingMdat=void 0,true):(this.nextParsePosition=this.stream.findEndContiguousBuf(),false)}restoreParsePosition(){return this.stream.seek(this.lastBoxStartPosition,true,this.discardMdatData)}saveParsePosition(){this.lastBoxStartPosition=this.stream.getPosition()}updateUsedBytes(e,s){this.stream.addUsedBytes&&(e.type==="mdat"?(this.stream.addUsedBytes(e.hdr_size),this.discardMdatData&&this.stream.addUsedBytes(e.size-e.hdr_size)):this.stream.addUsedBytes(e.size))}addBox(e){return f.prototype.addBox.call(this,e)}init(e={}){let s=this.addBox(new cn);s.major_brand=e.brands&&e.brands[0]||"iso4",s.minor_version=0,s.compatible_brands=e.brands||["iso4"];let i=this.addBox(new ot);i.addBox(new Pa);let r=i.addBox(new xn);return r.timescale=e.timescale||600,r.rate=e.rate||65536,r.creation_time=0,r.modification_time=0,r.duration=e.duration||0,r.volume=e.width?0:256,r.matrix=[65536,0,0,0,65536,0,0,0,1073741824],r.next_track_id=1,this}addTrack(e={}){this.moov||this.init(e);let s=e||{};s.width=s.width||320,s.height=s.height||320,s.id=s.id||this.moov.mvhd.next_track_id,s.type=s.type||"avc1";let i=this.moov.addBox(new en);this.moov.mvhd.next_track_id=s.id+1;let r=i.addBox(new An);r.flags=7,r.creation_time=0,r.modification_time=0,r.track_id=s.id,r.duration=s.duration||0,r.layer=s.layer||0,r.alternate_group=0,r.volume=1,r.matrix=[65536,0,0,0,65536,0,0,0,1073741824],r.width=s.width<<16,r.height=s.height<<16;let a=i.addBox(new sn),n=a.addBox(new fn);n.creation_time=0,n.modification_time=0,n.timescale=s.timescale||1,n.duration=s.media_duration||0,n.language=s.language||"und";let o=a.addBox(new pn);o.handler=s.hdlr||"vide",o.name=s.name||"Track created with MP4Box.js";let l=a.addBox(new dn);l.extended_language=s.language||"fr-FR";let h=a.addBox(new rn),c=P.sampleEntry[s.type];if(!c)return;let u=new c;if(u.data_reference_index=1,u instanceof w){let S=u,T=h.addBox(new Dn);T.graphicsmode=0,T.opcolor=[0,0,0],S.width=s.width,S.height=s.height,S.horizresolution=72<<16,S.vertresolution=72<<16,S.frame_count=1,S.compressorname=s.type+" Compressor",S.depth=24,s.avcDecoderConfigRecord?S.addBox(new Xa(s.avcDecoderConfigRecord.byteLength)).parse(new C(s.avcDecoderConfigRecord)):s.hevcDecoderConfigRecord&&S.addBox(new un(s.hevcDecoderConfigRecord.byteLength)).parse(new C(s.hevcDecoderConfigRecord))}else if(u instanceof A){let S=u,T=h.addBox(new Sn);T.balance=s.balance||0,S.channel_count=s.channel_count||2,S.samplesize=s.samplesize||16,S.samplerate=s.samplerate||65536}else u instanceof Ga?h.addBox(new Za):u instanceof G?(h.addBox(new Bn),u instanceof wn&&(u.namespace=s.namespace||"nonamespace",u.schema_location=s.schema_location||"",u.auxiliary_mime_types=s.auxiliary_mime_types||"")):h.addBox(new tn);s.description&&u.addBox.call(u,s.description),s.description_boxes&&s.description_boxes.forEach(function(S){u.addBox.call(u,S)});let m=h.addBox(new an).addBox(new ln),_=new Tn;_.flags=1,m.addEntry(_);let U=h.addBox(new nn);U.addBox(new kn).addEntry(u);let y=U.addBox(new En);y.sample_counts=[],y.sample_deltas=[];let z=U.addBox(new zn);z.first_chunk=[],z.samples_per_chunk=[],z.sample_description_index=[];let E=U.addBox(new vn);E.chunk_offsets=[];let F=U.addBox(new In);F.sample_sizes=[];let k=this.moov.mvex.addBox(new Aa);return k.track_id=s.id,k.default_sample_description_index=s.default_sample_description_index||1,k.default_sample_duration=s.default_sample_duration||0,k.default_sample_size=s.default_sample_size||0,k.default_sample_flags=s.default_sample_flags||0,this.buildTrakSampleLists(i),s.id}addSample(e,s,{sample_description_index:i,duration:r=1,cts:a=0,dts:n=0,is_sync:o=false,is_leading:l=0,depends_on:h=0,is_depended_on:c=0,has_redundancy:u=0,degradation_priority:m=0,subsamples:_,offset:U=0}={}){let y=this.getTrackById(e);if(y===void 0)return;let z=i?i-1:0,E={number:y.samples.length,track_id:y.tkhd.track_id,timescale:y.mdia.mdhd.timescale,description_index:z,description:y.mdia.minf.stbl.stsd.entries[z],data:s,size:s.byteLength,alreadyRead:s.byteLength,duration:r,cts:a,dts:n,is_sync:o,is_leading:l,depends_on:h,is_depended_on:c,has_redundancy:u,degradation_priority:m,offset:U,subsamples:_};y.samples.push(E),y.samples_size+=E.size,y.samples_duration+=E.duration,y.first_dts===void 0&&(y.first_dts=n),this.processSamples();let F=this.addBox(this.createMoof([E]));F.computeSize(),F.trafs[0].truns[0].data_offset=F.size+8;let k=this.addBox(new nt);return k.data=new Uint8Array(s),E}createMoof(e){if(e.length===0)return;if(e.some(c=>c.track_id!==e[0].track_id))throw Error("Cannot create moof for samples from different tracks: "+e.map(c=>c.track_id).join(", "));let s=e[0].track_id,i=this.getTrackById(s);if(!i)throw Error("Cannot create moof for non-existing track: "+s);let r=new on,a=r.addBox(new gn);a.sequence_number=++this.nextMoofNumber;let n=r.addBox(new hn),o=n.addBox(new Pn);o.track_id=s,o.flags=Yn;let l=n.addBox(new Cn);l.baseMediaDecodeTime=e[0].dts-(i.first_dts||0);let h=n.addBox(new Fn);h.flags=3841,h.data_offset=0,h.first_sample_flags=0,h.sample_count=e.length;for(let c of e){let u=0;u=c.is_sync?1<<25:65536,h.sample_duration.push(c.duration),h.sample_size.push(c.size),h.sample_flags.push(u),h.sample_composition_time_offset.push(c.cts-c.dts)}return r}print(e){e.indent="";for(let s=0;s<this.boxes.length;s++)this.boxes[s]&&this.boxes[s].print(e)}};function Jh(t=false,e){return new Kh(e,!t)}var Qh=(Gs=class extends p{constructor(...t){super(...t),this.box_name="EventMessageBox"}parse(t){this.parseFullHeader(t),this.version===1?(this.timescale=t.readUint32(),this.presentation_time=t.readUint64(),this.event_duration=t.readUint32(),this.id=t.readUint32(),this.scheme_id_uri=t.readCString(),this.value=t.readCString()):(this.scheme_id_uri=t.readCString(),this.value=t.readCString(),this.timescale=t.readUint32(),this.presentation_time_delta=t.readUint32(),this.event_duration=t.readUint32(),this.id=t.readUint32());let e=this.size-this.hdr_size-(16+(this.scheme_id_uri.length+1)+(this.value.length+1));this.version===1&&(e-=4),this.message_data=t.readUint8Array(e)}write(t){this.version=0,this.flags=0,this.size=16+this.message_data.length+(this.scheme_id_uri.length+1)+(this.value.length+1),this.writeHeader(t),t.writeCString(this.scheme_id_uri),t.writeCString(this.value),t.writeUint32(this.timescale),t.writeUint32(this.presentation_time_delta),t.writeUint32(this.event_duration),t.writeUint32(this.id),t.writeUint8Array(this.message_data)}},Gs.fourcc="emsg",Gs),Xh=(js=class extends p{constructor(...t){super(...t),this.box_name="CompressedSubsegmentIndexBox"}parse(t){this.parseFullHeader(t),this.subsegments=[];let e=t.readUint32();for(let s=0;s<e;s++){let i={};this.subsegments.push(i),i.ranges=[];let r=t.readUint32();for(let a=0;a<r;a++){let n={};i.ranges.push(n),n.level=t.readUint8(),n.range_size=t.readUint24()}}}},js.fourcc="ssix",js),Zh=($s=class extends f{constructor(...t){super(...t),this.box_name="SegmentTypeBox"}parse(t){let e=this.size-this.hdr_size;this.major_brand=t.readString(4),this.minor_version=t.readUint32(),e-=8,this.compatible_brands=[];let s=0;for(;e>=4;)this.compatible_brands[s]=t.readString(4),e-=4,s++}write(t){this.size=8+4*this.compatible_brands.length,this.writeHeader(t),t.writeString(this.major_brand,void 0,4),t.writeUint32(this.minor_version);for(let e=0;e<this.compatible_brands.length;e++)t.writeString(this.compatible_brands[e],void 0,4)}},$s.fourcc="styp",$s),Vc=Vn({Box:()=>f,DataStream:()=>C,Descriptor:()=>N,ES_Descriptor:()=>Da,FullBox:()=>p,Log:()=>d,MPEG4DescriptorParser:()=>On,SampleGroupEntry:()=>v,TrackGroupTypeBox:()=>Wa,TrackReferenceTypeBox:()=>Ka,createFile:()=>Jh}),Ws,Ks,Js,Qs,Xs,Zs,ti,ei,si,ii,ri,ai,ni,oi,hi,li,di,ci,pi,ui,fi,mi,_i,gi,xi,bi,yi,Ui,wi,Si,vi,Bi,zi,ki,Ii,Ei,Ci,Pi,Ai,Fi,Ti,Di,Li,Hi,Mi,Oi,Ri,Ni,Vi,Gi,ji,$i,qi,Yi,Wi,Ki,Ji,Qi,Xi,Zi,tr,er,sr,ir,rr,ar,nr,or,hr,lr,dr,cr,pr,ur,st,fr,mr,_r,gr,xr,br,yr,Ur,wr,Sr,vr,Br,zr,kr,Ir,Er,Cr,Pr,Ar,Fr,Tr,Dr,Lr,Hr,Mr,Or,Rr,Nr,Vr,Gr,jr,it,$r,qr,Yr,Wr,Kr,Jr,Qr,Xr,Zr,ta,ea,sa,ia,ra,aa,na,oa,ha,la,da,ca,pa,ua,fa,ma,_a,ga,xa,ba,ya,Ua,wa,Sa,va,Ba,za,ka,Ia,tl=$a({Descriptor:()=>N,ES_Descriptor:()=>Da,MPEG4DescriptorParser:()=>On}),Ln=3,ct=4,Ta=5,Hn=6,N=class Mn{constructor(e,s){this.tag=e,this.size=s,this.descs=[]}parse(e){this.data=e.readUint8Array(this.size)}findDescriptor(e){for(let s=0;s<this.descs.length;s++)if(this.descs[s].tag===e)return this.descs[s]}parseOneDescriptor(e){let s=0,i=e.readUint8(),r=e.readUint8();for(;r&128;)s=(s<<7)+(r&127),r=e.readUint8();s=(s<<7)+(r&127),d.debug("Descriptor","Found "+(ht[i]||"Descriptor "+i)+", size "+s+" at position "+e.getPosition());let a=ht[i]?new el[ht[i]](s):new Mn(s);return a.parse(e),a}parseRemainingDescriptors(e){var i;let s=e.getPosition();for(;e.getPosition()<s+this.size;){let r=(i=this.parseOneDescriptor)==null?void 0:i.call(this,e);this.descs.push(r)}}},Da=class extends N{constructor(t){super(Ln,t)}parse(t){if(this.ES_ID=t.readUint16(),this.flags=t.readUint8(),this.size-=3,this.flags&128?(this.dependsOn_ES_ID=t.readUint16(),this.size-=2):this.dependsOn_ES_ID=0,this.flags&64){let e=t.readUint8();this.URL=t.readString(e),this.size-=e+1}else this.URL="";this.flags&32?(this.OCR_ES_ID=t.readUint16(),this.size-=2):this.OCR_ES_ID=0,this.parseRemainingDescriptors(t)}getOTI(){let t=this.findDescriptor(ct);return t?t.oti:0}getAudioConfig(){let t=this.findDescriptor(ct);if(!t)return;let e=t.findDescriptor(Ta);if(e&&e.data){let s=(e.data[0]&248)>>3;return s===31&&e.data.length>=2&&(s=32+((e.data[0]&7)<<3)+((e.data[1]&224)>>5)),s}}},el={Descriptor:N,ES_Descriptor:Da,DecoderConfigDescriptor:class extends N{constructor(t){super(ct,t)}parse(t){this.oti=t.readUint8(),this.streamType=t.readUint8(),this.upStream=!!(this.streamType>>1&1),this.streamType>>>=2,this.bufferSize=t.readUint24(),this.maxBitrate=t.readUint32(),this.avgBitrate=t.readUint32(),this.size-=13,this.parseRemainingDescriptors(t)}},DecoderSpecificInfo:class extends N{constructor(t){super(Ta,t)}},SLConfigDescriptor:class extends N{constructor(t){super(Hn,t)}}},ht={[Ln]:"ES_Descriptor",[ct]:"DecoderConfigDescriptor",[Ta]:"DecoderSpecificInfo",[Hn]:"SLConfigDescriptor"},On=class{constructor(){this.parseOneDescriptor=N.prototype.parseOneDescriptor}getDescriptorName(t){return ht[t]}},sl=(Ws=class extends f{constructor(...t){super(...t),this.box_name="AV1LayeredImageIndexingProperty"}parse(t){let e=((t.readUint8()&1)+1)*16;this.layer_size=[];for(let s=0;s<3;s++)e===16?this.layer_size[s]=t.readUint16():this.layer_size[s]=t.readUint32()}},Ws.fourcc="a1lx",Ws),il=(Ks=class extends f{constructor(...t){super(...t),this.box_name="OperatingPointSelectorProperty"}parse(t){this.op_index=t.readUint8()}},Ks.fourcc="a1op",Ks),rl=(Js=class extends p{constructor(...t){super(...t),this.box_name="AuxiliaryTypeProperty"}parse(t){this.parseFullHeader(t),this.aux_type=t.readCString();let e=this.size-this.hdr_size-(this.aux_type.length+1);this.aux_subtype=t.readUint8Array(e)}},Js.fourcc="auxC",Js),al=(Qs=class extends f{constructor(...t){super(...t),this.box_name="BitRateBox"}parse(t){this.bufferSizeDB=t.readUint32(),this.maxBitrate=t.readUint32(),this.avgBitrate=t.readUint32()}},Qs.fourcc="btrt",Qs),nl=(Xs=class extends p{constructor(...t){super(...t),this.box_name="CodingConstraintsBox"}parse(t){this.parseFullHeader(t);let e=t.readUint8();this.all_ref_pics_intra=(e&128)==128,this.intra_pred_used=(e&64)==64,this.max_ref_per_pic=(e&63)>>2,t.readUint24()}},Xs.fourcc="ccst",Xs),ol=(Zs=class extends f{constructor(...t){super(...t),this.box_name="ComponentDefinitionBox"}parse(t){this.channel_count=t.readUint16(),this.channel_indexes=[],this.channel_types=[],this.channel_associations=[];for(let e=0;e<this.channel_count;e++)this.channel_indexes.push(t.readUint16()),this.channel_types.push(t.readUint16()),this.channel_associations.push(t.readUint16())}},Zs.fourcc="cdef",Zs),hl=(ti=class extends f{constructor(...t){super(...t),this.box_name="CleanApertureBox"}parse(t){this.cleanApertureWidthN=t.readUint32(),this.cleanApertureWidthD=t.readUint32(),this.cleanApertureHeightN=t.readUint32(),this.cleanApertureHeightD=t.readUint32(),this.horizOffN=t.readUint32(),this.horizOffD=t.readUint32(),this.vertOffN=t.readUint32(),this.vertOffD=t.readUint32()}},ti.fourcc="clap",ti),ll=(ei=class extends f{constructor(...t){super(...t),this.box_name="ContentLightLevelBox"}parse(t){this.max_content_light_level=t.readUint16(),this.max_pic_average_light_level=t.readUint16()}},ei.fourcc="clli",ei),dl=(si=class extends f{constructor(...t){super(...t),this.box_name="CameraExtrinsicMatrixProperty"}parse(t){this.flags&1&&(this.pos_x=t.readInt32()),this.flags&2&&(this.pos_y=t.readInt32()),this.flags&4&&(this.pos_z=t.readInt32()),this.flags&8&&(this.version===0?this.flags&16?(this.quat_x=t.readInt32(),this.quat_y=t.readInt32(),this.quat_z=t.readInt32()):(this.quat_x=t.readInt16(),this.quat_y=t.readInt16(),this.quat_z=t.readInt16()):this.version),this.flags&32&&(this.id=t.readUint32())}},si.fourcc="cmex",si),cl=(ii=class extends f{constructor(...t){super(...t),this.box_name="CameraIntrinsicMatrixProperty"}parse(t){this.focal_length_x=t.readInt32(),this.principal_point_x=t.readInt32(),this.principal_point_y=t.readInt32(),this.flags&1&&(this.focal_length_y=t.readInt32(),this.skew_factor=t.readInt32())}},ii.fourcc="cmin",ii),pl=(ri=class extends p{constructor(...t){super(...t),this.box_name="CompressionConfigurationBox"}parse(t){this.parseFullHeader(t),this.compression_type=t.readString(4),this.compressed_unit_type=t.readUint8()}},ri.fourcc="cmpC",ri),ul=(ai=class extends f{constructor(...t){super(...t),this.box_name="ComponentDefinitionBox"}parse(t){this.component_count=t.readUint32(),this.component_types=[],this.component_type_urls=[];for(let e=0;e<this.component_count;e++){let s=t.readUint16();this.component_types.push(s),s>=32768&&this.component_type_urls.push(t.readCString())}}},ai.fourcc="cmpd",ai),fl=(ni=class extends p{constructor(...t){super(...t),this.box_name="ChunkLargeOffsetBox"}parse(t){this.parseFullHeader(t);let e=t.readUint32();if(this.chunk_offsets=[],this.version===0)for(let s=0;s<e;s++)this.chunk_offsets.push(t.readUint64())}write(t){this.version=0,this.flags=0,this.size=4+8*this.chunk_offsets.length,this.writeHeader(t),t.writeUint32(this.chunk_offsets.length);for(let e=0;e<this.chunk_offsets.length;e++)t.writeUint64(this.chunk_offsets[e])}},ni.fourcc="co64",ni),ml=(oi=class extends p{constructor(...t){super(...t),this.box_name="ContentLightLevelBox"}parse(t){this.parseFullHeader(t),this.maxCLL=t.readUint16(),this.maxFALL=t.readUint16()}},oi.fourcc="CoLL",oi),_l=class{toString(){let t="centre_azimuth: ";return t+=this.centre_azimuth,t+=" (",t+=this.centre_azimuth*2**-16,t+="\xB0), centre_elevation: ",t+=this.centre_elevation,t+=" (",t+=this.centre_elevation*2**-16,t+="\xB0), centre_tilt: ",t+=this.centre_tilt,t+=" (",t+=this.centre_tilt*2**-16,t+="\xB0)",this.range_included_flag&&(t+=", azimuth_range: ",t+=this.azimuth_range,t+=" (",t+=this.azimuth_range*2**-16,t+="\xB0), elevation_range: ",t+=this.elevation_range,t+=" (",t+=this.elevation_range*2**-16,t+="\xB0)"),this.interpolate_included_flag&&(t+=", interpolate: ",t+=this.interpolate),t}},gl=class{toString(){let t="";return this.view_idc&&(t+="view_idc: ",t+=this.view_idc,t+=", "),t+="sphere_region: {",t+=this.sphere_region,t+="}",t}},xl=(hi=class extends p{constructor(...t){super(...t),this.box_name="CoverageInformationBox"}parse(t){this.parseFullHeader(t),this.coverage_shape_type=t.readUint8();let e=t.readUint8(),s=t.readInt8(),i=s&128;i&&(this.default_view_idc=(s&96)>>5),this.coverage_regions=[];for(let r=0;r<e;r++){let a=new gl;i&&(a.view_idc=t.readUint8()>>6),a.sphere_region=this.parseSphereRegion(t,true,true),this.coverage_regions.push(a)}}parseSphereRegion(t,e,s){let i=new _l;return i.centre_azimuth=t.readInt32(),i.centre_elevation=t.readInt32(),i.centre_tilt=t.readInt32(),i.range_included_flag=e,e&&(i.azimuth_range=t.readUint32(),i.elevation_range=t.readUint32()),i.interpolate_included_flag=s,s&&(i.interpolate=(t.readUint8()&128)==128),i}},hi.fourcc="covi",hi),bl=(li=class extends p{constructor(...t){super(...t),this.box_name="CopyrightBox"}parse(t){this.parseFullHeader(t),this.parseLanguage(t),this.notice=t.readCString()}},li.fourcc="cprt",li),yl=(di=class extends p{constructor(...t){super(...t),this.box_name="CompatibleSchemeTypeBox"}parse(t){this.parseFullHeader(t),this.scheme_type=t.readString(4),this.scheme_version=t.readUint32(),this.flags&1&&(this.scheme_uri=t.readCString())}},di.fourcc="csch",di),W=2147483647,Ul=(ci=class extends p{constructor(...t){super(...t),this.box_name="CompositionToDecodeBox"}parse(t){this.parseFullHeader(t),this.version===0?(this.compositionToDTSShift=t.readInt32(),this.leastDecodeToDisplayDelta=t.readInt32(),this.greatestDecodeToDisplayDelta=t.readInt32(),this.compositionStartTime=t.readInt32(),this.compositionEndTime=t.readInt32()):this.version===1&&(this.compositionToDTSShift=t.readInt64(),this.leastDecodeToDisplayDelta=t.readInt64(),this.greatestDecodeToDisplayDelta=t.readInt64(),this.compositionStartTime=t.readInt64(),this.compositionEndTime=t.readInt64())}write(t){this.version=0,(this.compositionToDTSShift>W||this.leastDecodeToDisplayDelta>W||this.greatestDecodeToDisplayDelta>W||this.compositionStartTime>W||this.compositionEndTime>W)&&(this.version=1),this.flags=0,this.version===0?(this.size=20,this.writeHeader(t),t.writeInt32(this.compositionToDTSShift),t.writeInt32(this.leastDecodeToDisplayDelta),t.writeInt32(this.greatestDecodeToDisplayDelta),t.writeInt32(this.compositionStartTime),t.writeInt32(this.compositionEndTime)):this.version===1&&(this.size=40,this.writeHeader(t),t.writeInt64(this.compositionToDTSShift),t.writeInt64(this.leastDecodeToDisplayDelta),t.writeInt64(this.greatestDecodeToDisplayDelta),t.writeInt64(this.compositionStartTime),t.writeInt64(this.compositionEndTime))}},ci.fourcc="cslg",ci),wl=(pi=class extends p{constructor(...t){super(...t),this.box_name="CompositionOffsetBox"}parse(t){this.parseFullHeader(t);let e=t.readUint32();if(this.sample_counts=[],this.sample_offsets=[],this.version===0)for(let s=0;s<e;s++){this.sample_counts.push(t.readUint32());let i=t.readInt32();i<0&&d.warn("BoxParser","ctts box uses negative values without using version 1"),this.sample_offsets.push(i)}else if(this.version===1)for(let s=0;s<e;s++)this.sample_counts.push(t.readUint32()),this.sample_offsets.push(t.readInt32())}write(t){this.version=+!!this.sample_offsets.some(e=>e<0),this.flags=0,this.size=4+8*this.sample_counts.length,this.writeHeader(t),t.writeUint32(this.sample_counts.length);for(let e=0;e<this.sample_counts.length;e++)t.writeUint32(this.sample_counts[e]),this.version===1?t.writeInt32(this.sample_offsets[e]):t.writeUint32(this.sample_offsets[e])}unpack(t){let e=0;for(let s=0;s<this.sample_counts.length;s++)for(let i=0;i<this.sample_counts[s];i++)t[e].pts=t[e].dts+this.sample_offsets[s],e++}},pi.fourcc="ctts",pi),Sl=(ui=class extends f{constructor(...t){super(...t),this.box_name="AC3SpecificBox"}parse(t){let e=t.readUint8(),s=t.readUint8(),i=t.readUint8();this.fscod=e>>6,this.bsid=e>>1&31,this.bsmod=(e&1)<<2|s>>6&3,this.acmod=s>>3&7,this.lfeon=s>>2&1,this.bit_rate_code=s&3|i>>5&7}},ui.fourcc="dac3",ui),vl=(fi=class extends f{constructor(...t){super(...t),this.box_name="EC3SpecificBox"}parse(t){let e=t.readUint16();this.data_rate=e>>3,this.num_ind_sub=e&7,this.ind_subs=[];for(let s=0;s<this.num_ind_sub+1;s++){let i=t.readUint8(),r=t.readUint8(),a=t.readUint8(),n={fscod:i>>6,bsid:i>>1&31,bsmod:(i&1)<<4|r>>4&15,acmod:r>>1&7,lfeon:r&1,num_dep_sub:a>>1&15};this.ind_subs.push(n),n.num_dep_sub>0&&(n.chan_loc=(a&1)<<8|t.readUint8())}}},fi.fourcc="dec3",fi),Bl=(mi=class extends p{constructor(...t){super(...t),this.box_name="FLACSpecificBox"}parse(t){this.parseFullHeader(t);let e=[],s=["STREAMINFO","PADDING","APPLICATION","SEEKTABLE","VORBIS_COMMENT","CUESHEET","PICTURE","RESERVED"],i;do{i=t.readUint8();let r=Math.min(i&127,s.length-1);r?t.readUint8Array(t.readUint24()):(t.readUint8Array(13),this.samplerate=t.readUint32()>>12,t.readUint8Array(20)),e.push(s[r])}while(i&128);this.numMetadataBlocks=e.length+" ("+e.join(", ")+")"}},mi.fourcc="dfLa",mi),zl=(_i=class extends f{constructor(...t){super(...t),this.box_name="hintimmediateBytesSent"}parse(t){this.bytessent=t.readUint64()}},_i.fourcc="dimm",_i),kl=(gi=class extends f{constructor(...t){super(...t),this.box_name="hintlongestpacket"}parse(t){this.time=t.readUint32()}},gi.fourcc="dmax",gi),Il=(xi=class extends f{constructor(...t){super(...t),this.box_name="hintmediaBytesSent"}parse(t){this.bytessent=t.readUint64()}},xi.fourcc="dmed",xi),El=(bi=class extends f{constructor(...t){super(...t),this.box_name="OpusSpecificBox"}parse(t){if(this.Version=t.readUint8(),this.OutputChannelCount=t.readUint8(),this.PreSkip=t.readUint16(),this.InputSampleRate=t.readUint32(),this.OutputGain=t.readInt16(),this.ChannelMappingFamily=t.readUint8(),this.ChannelMappingFamily!==0){this.StreamCount=t.readUint8(),this.CoupledCount=t.readUint8(),this.ChannelMapping=[];for(let e=0;e<this.OutputChannelCount;e++)this.ChannelMapping[e]=t.readUint8()}}write(t){if(this.size=11,this.ChannelMappingFamily!==0&&(this.size+=2+this.OutputChannelCount),this.writeHeader(t),t.writeUint8(this.Version),t.writeUint8(this.OutputChannelCount),t.writeUint16(this.PreSkip),t.writeUint32(this.InputSampleRate),t.writeInt16(this.OutputGain),t.writeUint8(this.ChannelMappingFamily),this.ChannelMappingFamily!==0){t.writeUint8(this.StreamCount),t.writeUint8(this.CoupledCount);for(let e=0;e<this.OutputChannelCount;e++)t.writeUint8(this.ChannelMapping[e])}}},bi.fourcc="dOps",bi),Cl=(yi=class extends f{constructor(...t){super(...t),this.box_name="hintrepeatedBytesSent"}parse(t){this.bytessent=t.readUint64()}},yi.fourcc="drep",yi),Pl=(Ui=class extends p{constructor(...t){super(...t),this.box_name="EditListBox"}parse(t){this.parseFullHeader(t),this.entries=[];let e=t.readUint32();for(let s=0;s<e;s++){let i={segment_duration:this.version===1?t.readUint64():t.readUint32(),media_time:this.version===1?t.readInt64():t.readInt32(),media_rate_integer:t.readInt16(),media_rate_fraction:t.readInt16()};this.entries.push(i)}}write(t){let e=this.entries.some(s=>s.segment_duration>B||s.media_time>B)||this.version===1;this.version=+!!e,this.size=4+12*this.entries.length,this.size+=e?8*this.entries.length:0,this.writeHeader(t),t.writeUint32(this.entries.length);for(let s=0;s<this.entries.length;s++){let i=this.entries[s];e?(t.writeUint64(i.segment_duration),t.writeInt64(i.media_time)):(t.writeUint32(i.segment_duration),t.writeInt32(i.media_time)),t.writeInt16(i.media_rate_integer),t.writeInt16(i.media_rate_fraction)}}},Ui.fourcc="elst",Ui),I=class extends p{parse(t){this.parseFullHeader(t),this.group_id=t.readUint32(),this.num_entities_in_group=t.readUint32(),this.entity_ids=[];for(let e=0;e<this.num_entities_in_group;e++){let s=t.readUint32();this.entity_ids.push(s)}}},Al=(wi=class extends I{constructor(...t){super(...t),this.box_name="Auto exposure bracketing"}},wi.fourcc="aebr",wi),Fl=(Si=class extends I{constructor(...t){super(...t),this.box_name="Flash exposure information"}},Si.fourcc="afbr",Si),Tl=(vi=class extends I{constructor(...t){super(...t),this.box_name="Album collection"}},vi.fourcc="albc",vi),Dl=(Bi=class extends I{constructor(...t){super(...t),this.box_name="Alternative entity"}},Bi.fourcc="altr",Bi),Ll=(zi=class extends I{constructor(...t){super(...t),this.box_name="Burst image"}},zi.fourcc="brst",zi),Hl=(ki=class extends I{constructor(...t){super(...t),this.box_name="Depth of field bracketing"}},ki.fourcc="dobr",ki),Ml=(Ii=class extends I{constructor(...t){super(...t),this.box_name="Equivalent entity"}},Ii.fourcc="eqiv",Ii),Ol=(Ei=class extends I{constructor(...t){super(...t),this.box_name="Favorites collection"}},Ei.fourcc="favc",Ei),Rl=(Ci=class extends I{constructor(...t){super(...t),this.box_name="Focus bracketing"}},Ci.fourcc="fobr",Ci),Nl=(Pi=class extends I{constructor(...t){super(...t),this.box_name="Image item with an audio track"}},Pi.fourcc="iaug",Pi),Vl=(Ai=class extends I{constructor(...t){super(...t),this.box_name="Panorama"}},Ai.fourcc="pano",Ai),Gl=(Fi=class extends I{constructor(...t){super(...t),this.box_name="Slideshow"}},Fi.fourcc="slid",Fi),jl=(Ti=class extends I{constructor(...t){super(...t),this.box_name="Stereo"}},Ti.fourcc="ster",Ti),$l=(Di=class extends I{constructor(...t){super(...t),this.box_name="Time-synchronized capture"}},Di.fourcc="tsyn",Di),ql=(Li=class extends I{constructor(...t){super(...t),this.box_name="White balance bracketing"}},Li.fourcc="wbbr",Li),Yl=(Hi=class extends I{constructor(...t){super(...t),this.box_name="Progressive rendering"}},Hi.fourcc="prgr",Hi),Wl=(Mi=class extends I{constructor(...t){super(...t),this.box_name="Image pyramid"}parse(t){this.parseFullHeader(t),this.group_id=t.readUint32(),this.num_entities_in_group=t.readUint32(),this.entity_ids=[];for(let e=0;e<this.num_entities_in_group;e++){let s=t.readUint32();this.entity_ids.push(s)}this.tile_size_x=t.readUint16(),this.tile_size_y=t.readUint16(),this.layer_binning=[],this.tiles_in_layer_column_minus1=[],this.tiles_in_layer_row_minus1=[];for(let e=0;e<this.num_entities_in_group;e++)this.layer_binning[e]=t.readUint16(),this.tiles_in_layer_row_minus1[e]=t.readUint16(),this.tiles_in_layer_column_minus1[e]=t.readUint16()}},Mi.fourcc="pymd",Mi),Kl=(Oi=class extends f{constructor(...t){super(...t),this.box_name="FieldHandlingBox"}parse(t){this.fieldCount=t.readUint8(),this.fieldOrdering=t.readUint8()}},Oi.fourcc="fiel",Oi),Jl=(Ri=class extends f{constructor(...t){super(...t),this.box_name="OriginalFormatBox"}parse(t){this.data_format=t.readString(4)}},Ri.fourcc="frma",Ri),Ql=(Ni=class extends f{constructor(...t){super(...t),this.box_name="ImageMirror"}parse(t){let e=t.readUint8();this.reserved=e>>7,this.axis=e&1}},Ni.fourcc="imir",Ni),Xl=(Vi=class extends p{constructor(...t){super(...t),this.box_name="ItemPropertyAssociationBox"}parse(t){this.parseFullHeader(t);let e=t.readUint32();this.associations=[];for(let s=0;s<e;s++){let i=this.version<1?t.readUint16():t.readUint32(),r=[],a=t.readUint8();for(let n=0;n<a;n++){let o=t.readUint8();r.push({essential:(o&128)>>7==1,property_index:this.flags&1?(o&127)<<8|t.readUint8():o&127})}this.associations.push({id:i,props:r})}}},Vi.fourcc="ipma",Vi),Zl=(Gi=class extends f{constructor(...t){super(...t),this.box_name="ImageRotation"}parse(t){this.angle=t.readUint8()&3}},Gi.fourcc="irot",Gi),td=(ji=class extends p{constructor(...t){super(...t),this.box_name="ImageSpatialExtentsProperty"}parse(t){this.parseFullHeader(t),this.image_width=t.readUint32(),this.image_height=t.readUint32()}},ji.fourcc="ispe",ji),ed=($i=class extends p{constructor(...t){super(...t),this.box_name="TAITimestampBox"}parse(t){this.TAI_timestamp=t.readUint64();let e=t.readUint8();this.sychronization_state=e>>7&1,this.timestamp_generation_failure=e>>6&1,this.timestamp_is_modified=e>>5&1}},$i.fourcc="itai",$i),sd=(qi=class extends p{constructor(...t){super(...t),this.box_name="KindBox"}parse(t){this.parseFullHeader(t),this.schemeURI=t.readCString(),this.isEndOfBox(t)||(this.value=t.readCString())}write(t){this.version=0,this.flags=0,this.size=this.schemeURI.length+1+(this.value?this.value.length+1:0),this.writeHeader(t),t.writeCString(this.schemeURI),this.value&&t.writeCString(this.value)}},qi.fourcc="kind",qi),id=(Yi=class extends p{constructor(...t){super(...t),this.box_name="LevelAssignmentBox"}parse(t){this.parseFullHeader(t);let e=t.readUint8();this.levels=[];for(let s=0;s<e;s++){let i={};this.levels[s]=i,i.track_ID=t.readUint32();let r=t.readUint8();switch(i.padding_flag=r>>7,i.assignment_type=r&127,i.assignment_type){case 0:i.grouping_type=t.readString(4);break;case 1:i.grouping_type=t.readString(4),i.grouping_type_parameter=t.readUint32();break;case 2:break;case 3:break;case 4:i.sub_track_id=t.readUint32();break;default:d.warn("BoxParser",`Unknown level assignment type: ${i.assignment_type}`)}}}},Yi.fourcc="leva",Yi),rd=(Wi=class extends f{constructor(...t){super(...t),this.box_name="LHEVCConfigurationBox"}parse(t){this.configurationVersion=t.readUint8(),this.min_spatial_segmentation_idc=t.readUint16()&4095,this.parallelismType=t.readUint8()&3;let e=t.readUint8();this.numTemporalLayers=(e&13)>>3,this.temporalIdNested=(e&4)>>2,this.lengthSizeMinusOne=e&3,this.nalu_arrays=[];let s=t.readUint8();for(let i=0;i<s;i++){let r=[];this.nalu_arrays.push(r),e=t.readUint8(),r.completeness=(e&128)>>7,r.nalu_type=e&63;let a=t.readUint16();for(let n=0;n<a;n++){let o=t.readUint16();r.push({data:t.readUint8Array(o)})}}}},Wi.fourcc="lhvC",Wi),ad=(Ki=class extends f{constructor(...t){super(...t),this.box_name="LayerSelectorProperty"}parse(t){this.layer_id=t.readUint16()}},Ki.fourcc="lsel",Ki),nd=(Ji=class extends f{constructor(...t){super(...t),this.box_name="hintmaxrate"}parse(t){this.period=t.readUint32(),this.bytes=t.readUint32()}},Ji.fourcc="maxr",Ji),rt=class{constructor(t,e){this.x=t,this.y=e}toString(){return"("+this.x+","+this.y+")"}},od=(Qi=class extends f{constructor(...t){super(...t),this.box_name="MasteringDisplayColourVolumeBox"}parse(t){this.display_primaries=[],this.display_primaries[0]=new rt(t.readUint16(),t.readUint16()),this.display_primaries[1]=new rt(t.readUint16(),t.readUint16()),this.display_primaries[2]=new rt(t.readUint16(),t.readUint16()),this.white_point=new rt(t.readUint16(),t.readUint16()),this.max_display_mastering_luminance=t.readUint32(),this.min_display_mastering_luminance=t.readUint32()}},Qi.fourcc="mdcv",Qi),hd=(Xi=class extends p{constructor(...t){super(...t),this.box_name="MovieFragmentRandomAccessOffsetBox"}parse(t){this.parseFullHeader(t),this._size=t.readUint32()}},Xi.fourcc="mfro",Xi),ld=(Zi=class extends p{constructor(...t){super(...t),this.box_name="MaskConfigurationProperty"}parse(t){this.parseFullHeader(t),this.bits_per_pixel=t.readUint8()}},Zi.fourcc="mskC",Zi),dd=(tr=class extends f{constructor(...t){super(...t),this.box_name="hintPacketsSent"}parse(t){this.packetssent=t.readUint32()}},tr.fourcc="npck",tr),cd=(er=class extends f{constructor(...t){super(...t),this.box_name="hintPacketsSent"}parse(t){this.packetssent=t.readUint64()}},er.fourcc="nump",er),pd=class{constructor(t,e){this.pad1=t,this.pad2=e}},ud=(sr=class extends p{constructor(...t){super(...t),this.box_name="PaddingBitsBox"}parse(t){this.parseFullHeader(t);let e=t.readUint32();this.padbits=[];for(let s=0;s<Math.floor((e+1)/2);s++){let i=t.readUint8(),r=(i&112)>>4,a=i&7;this.padbits.push(new pd(r,a))}}},sr.fourcc="padb",sr),fd=(ir=class extends f{constructor(...t){super(...t),this.box_name="PixelAspectRatioBox"}parse(t){this.hSpacing=t.readUint32(),this.vSpacing=t.readUint32()}},ir.fourcc="pasp",ir),md=(rr=class extends f{constructor(...t){super(...t),this.box_name="CuePayloadBox"}parse(t){this.text=t.readString(this.size-this.hdr_size)}},rr.fourcc="payl",rr),_d=(ar=class extends f{constructor(...t){super(...t),this.box_name="hintpayloadID"}parse(t){this.payloadID=t.readUint32();let e=t.readUint8();this.rtpmap_string=t.readString(e)}},ar.fourcc="payt",ar),gd=(nr=class extends p{constructor(...t){super(...t),this.box_name="ProgressiveDownloadInfoBox",this.rate=[],this.initial_delay=[]}parse(t){this.parseFullHeader(t);let e=(this.size-this.hdr_size)/8;for(let s=0;s<e;s++)this.rate[s]=t.readUint32(),this.initial_delay[s]=t.readUint32()}},nr.fourcc="pdin",nr),xd=(or=class extends p{constructor(...t){super(...t),this.box_name="PixelInformationProperty"}parse(t){this.parseFullHeader(t),this.num_channels=t.readUint8(),this.bits_per_channels=[];for(let e=0;e<this.num_channels;e++)this.bits_per_channels[e]=t.readUint8()}},or.fourcc="pixi",or),bd=(hr=class extends f{constructor(...t){super(...t),this.box_name="hintlargestpacket"}parse(t){this.bytes=t.readUint32()}},hr.fourcc="pmax",hr),yd=(lr=class extends p{constructor(...t){super(...t),this.box_name="ProgressiveDerivedImageItemInformationProperty"}parse(t){if(this.parseFullHeader(t),this.step_count=t.readUint16(),this.item_count=[],this.flags&2)for(let e=0;e<this.step_count;e++)this.item_count[e]=t.readUint16()}},lr.fourcc="prdi",lr),Ud=(dr=class extends p{constructor(...t){super(...t),this.box_name="ProjectionFormatBox"}parse(t){this.parseFullHeader(t),this.projection_type=t.readUint8()&31}},dr.fourcc="prfr",dr),wd=(cr=class extends p{constructor(...t){super(...t),this.box_name="ProducerReferenceTimeBox"}parse(t){this.parseFullHeader(t),this.ref_track_id=t.readUint32(),this.ntp_timestamp=t.readUint64(),this.media_time=this.version===0?t.readUint32():t.readUint64()}},cr.fourcc="prft",cr),Sd=(pr=class extends p{constructor(...t){super(...t),this.box_name="ProtectionSystemSpecificHeaderBox"}parse(t){if(this.parseFullHeader(t),this.system_id=V(t),this.kid=[],this.version>0){let s=t.readUint32();for(let i=0;i<s;i++)this.kid[i]=V(t)}let e=t.readUint32();e>0&&(this.protection_data=t.readUint8Array(e))}},pr.fourcc="pssh",pr),vd=(ur=class extends p{constructor(...t){super(...t),this.box_name="TrackCleanApertureDimensionsBox"}parse(t){this.parseFullHeader(t),this.width=t.readUint32(),this.height=t.readUint32()}},ur.fourcc="clef",ur);function Bd(t,e){if(t===K.Types.UTF8)return new TextDecoder("utf-8").decode(e);let s=new DataView(e.buffer);if(t===K.Types.BE_UNSIGNED_INT){if(e.length===1)return s.getUint8(0);if(e.length===2)return s.getUint16(0,false);if(e.length===4)return s.getUint32(0,false);if(e.length===8)return s.getBigUint64(0,false);throw Error("Unsupported ITIF_TYPE_BE_UNSIGNED_INT length "+e.length)}if(t===K.Types.BE_SIGNED_INT){if(e.length===1)return s.getInt8(0);if(e.length===2)return s.getInt16(0,false);if(e.length===4)return s.getInt32(0,false);if(e.length===8)return s.getBigInt64(0,false);throw Error("Unsupported ITIF_TYPE_BE_SIGNED_INT length "+e.length)}if(t===K.Types.BE_FLOAT32)return s.getFloat32(0,false);d.warn("DataBox","Unsupported or unimplemented itif data type: "+t)}var K=(st=class extends f{constructor(...t){super(...t),this.box_name="DataBox"}parse(t){this.valueType=t.readUint32(),this.country=t.readUint16(),this.country>255&&(t.seek(t.getPosition()-2),this.countryString=t.readString(2)),this.language=t.readUint16(),this.language>255&&(t.seek(t.getPosition()-2),this.parseLanguage(t)),this.raw=t.readUint8Array(this.size-this.hdr_size-8),this.value=Bd(this.valueType,this.raw)}},st.fourcc="data",st.Types={RESERVED:0,UTF8:1,UTF16:2,SJIS:3,UTF8_SORT:4,UTF16_SORT:5,JPEG:13,PNG:14,BE_SIGNED_INT:21,BE_UNSIGNED_INT:22,BE_FLOAT32:23,BE_FLOAT64:24,BMP:27,QT_ATOM:28,BE_SIGNED_INT8:65,BE_SIGNED_INT16:66,BE_SIGNED_INT32:67,BE_FLOAT32_POINT:70,BE_FLOAT32_DIMENSIONS:71,BE_FLOAT32_RECT:72,BE_SIGNED_INT64:74,BE_UNSIGNED_INT8:75,BE_UNSIGNED_INT16:76,BE_UNSIGNED_INT32:77,BE_UNSIGNED_INT64:78,BE_FLOAT64_AFFINE_TRANSFORM:79},st),zd=(fr=class extends p{constructor(...t){super(...t),this.box_name="TrackEncodedPixelsDimensionsBox"}parse(t){this.parseFullHeader(t),this.width=t.readUint32(),this.height=t.readUint32()}},fr.fourcc="enof",fr),kd=(mr=class extends f{constructor(...t){super(...t),this.box_name="IlstBox"}parse(t){this.list={};let e=this.size-this.hdr_size;for(;e>0;){let s=t.readUint32(),i=t.readUint32(),r=H(t,false,s-8);r.code===1&&(this.list[i]=r.box),e-=s}}},mr.fourcc="ilst",mr),Id=(_r=class extends p{constructor(...t){super(...t),this.box_name="KeysBox"}parse(t){this.parseFullHeader(t),this.count=t.readUint32(),this.keys={};for(let e=0;e<this.count;e++){let s=t.readUint32();this.keys[e+1]=t.readString(s-4)}}},_r.fourcc="keys",_r),Ed=(gr=class extends p{constructor(...t){super(...t),this.box_name="TrackProductionApertureDimensionsBox"}parse(t){this.parseFullHeader(t),this.width=t.readUint32(),this.height=t.readUint32()}},gr.fourcc="prof",gr),Cd=(xr=class extends x{constructor(...t){super(...t),this.box_name="TrackApertureModeDimensionsBox",this.clefs=[],this.profs=[],this.enofs=[],this.subBoxNames=["clef","prof","enof"]}},xr.fourcc="tapt",xr),Pd=(br=class extends f{constructor(...t){super(...t),this.box_name="rtpmoviehintinformation"}parse(t){this.descriptionformat=t.readString(4),this.sdptext=t.readString(this.size-this.hdr_size-4)}},br.fourcc="rtp ",br),Ad=(yr=class extends p{constructor(...t){super(...t),this.box_name="SampleAuxiliaryInformationOffsetsBox"}parse(t){this.parseFullHeader(t),this.flags&1&&(this.aux_info_type=t.readString(4),this.aux_info_type_parameter=t.readUint32()),this.entry_count=t.readUint32(),this.offset=[];for(let e=0;e<this.entry_count;e++)this.version===0?this.offset[e]=t.readUint32():this.offset[e]=t.readUint64()}},yr.fourcc="saio",yr),Fd=(Ur=class extends p{constructor(...t){super(...t),this.box_name="SampleAuxiliaryInformationSizesBox"}parse(t){if(this.parseFullHeader(t),this.flags&1&&(this.aux_info_type=t.readString(4),this.aux_info_type_parameter=t.readUint32()),this.default_sample_info_size=t.readUint8(),this.sample_count=t.readUint32(),this.sample_info_size=[],this.default_sample_info_size===0)for(let e=0;e<this.sample_count;e++)this.sample_info_size[e]=t.readUint8()}},Ur.fourcc="saiz",Ur),Td=class{constructor(t,e){this.bad_pixel_row=t,this.bad_pixel_column=e}toString(){return"[row: "+this.bad_pixel_row+", column: "+this.bad_pixel_column+"]"}},Dd=(wr=class extends p{constructor(...t){super(...t),this.box_name="SensorBadPixelsMapBox"}parse(t){this.parseFullHeader(t),this.component_count=t.readUint16(),this.component_index=[];for(let s=0;s<this.component_count;s++)this.component_index.push(t.readUint16());let e=t.readUint8();this.correction_applied=(e&128)==128,this.num_bad_rows=t.readUint32(),this.num_bad_cols=t.readUint32(),this.num_bad_pixels=t.readUint32(),this.bad_rows=[],this.bad_columns=[],this.bad_pixels=[];for(let s=0;s<this.num_bad_rows;s++)this.bad_rows.push(t.readUint32());for(let s=0;s<this.num_bad_cols;s++)this.bad_columns.push(t.readUint32());for(let s=0;s<this.num_bad_pixels;s++){let i=t.readUint32(),r=t.readUint32();this.bad_pixels.push(new Td(i,r))}}},wr.fourcc="sbpm",wr),Ld=(Sr=class extends p{constructor(...t){super(...t),this.box_name="SchemeTypeBox"}parse(t){this.parseFullHeader(t),this.scheme_type=t.readString(4),this.scheme_version=t.readUint32(),this.flags&1&&(this.scheme_uri=t.readString(this.size-this.hdr_size-8))}},Sr.fourcc="schm",Sr),Hd=(vr=class extends f{constructor(...t){super(...t),this.box_name="rtptracksdphintinformation"}parse(t){this.sdptext=t.readString(this.size-this.hdr_size)}},vr.fourcc="sdp ",vr),Md=(Br=class extends p{constructor(...t){super(...t),this.box_name="SampleEncryptionBox"}},Br.fourcc="senc",Br),Od=(zr=class extends p{constructor(...t){super(...t),this.box_name="SMPTE2086MasteringDisplayMetadataBox"}parse(t){this.parseFullHeader(t),this.primaryRChromaticity_x=t.readUint16(),this.primaryRChromaticity_y=t.readUint16(),this.primaryGChromaticity_x=t.readUint16(),this.primaryGChromaticity_y=t.readUint16(),this.primaryBChromaticity_x=t.readUint16(),this.primaryBChromaticity_y=t.readUint16(),this.whitePointChromaticity_x=t.readUint16(),this.whitePointChromaticity_y=t.readUint16(),this.luminanceMax=t.readUint32(),this.luminanceMin=t.readUint32()}},zr.fourcc="SmDm",zr),Rd=(kr=class extends p{constructor(...t){super(...t),this.box_name="SamplingRateBox"}parse(t){this.parseFullHeader(t),this.sampling_rate=t.readUint32()}},kr.fourcc="srat",kr),Nd=(Ir=class extends p{constructor(...t){super(...t),this.box_name="DegradationPriorityBox"}parse(t){this.parseFullHeader(t);let e=(this.size-this.hdr_size)/2;this.priority=[];for(let s=0;s<e;s++)this.priority[s]=t.readUint16()}},Ir.fourcc="stdp",Ir),Vd=(Er=class extends p{constructor(...t){super(...t),this.box_name="SubTrackInformationBox"}parse(t){this.parseFullHeader(t),this.switch_group=t.readUint16(),this.alternate_group=t.readUint16(),this.sub_track_id=t.readUint32();let e=(this.size-this.hdr_size-8)/4;this.attribute_list=[];for(let s=0;s<e;s++)this.attribute_list[s]=t.readUint32()}},Er.fourcc="stri",Er),Gd=(Cr=class extends p{constructor(...t){super(...t),this.box_name="SubTrackSampleGroupBox"}parse(t){this.parseFullHeader(t),this.grouping_type=t.readUint32();let e=t.readUint16();this.group_description_index=[];for(let s=0;s<e;s++)this.group_description_index[s]=t.readUint32()}},Cr.fourcc="stsg",Cr),jd=(Pr=class extends p{constructor(...t){super(...t),this.box_name="ShadowSyncSampleBox"}parse(t){this.parseFullHeader(t);let e=t.readUint32();if(this.shadowed_sample_numbers=[],this.sync_sample_numbers=[],this.version===0)for(let s=0;s<e;s++)this.shadowed_sample_numbers.push(t.readUint32()),this.sync_sample_numbers.push(t.readUint32())}write(t){this.version=0,this.flags=0,this.size=4+8*this.shadowed_sample_numbers.length,this.writeHeader(t),t.writeUint32(this.shadowed_sample_numbers.length);for(let e=0;e<this.shadowed_sample_numbers.length;e++)t.writeUint32(this.shadowed_sample_numbers[e]),t.writeUint32(this.sync_sample_numbers[e])}},Pr.fourcc="stsh",Pr),$d=(Ar=class extends p{constructor(...t){super(...t),this.box_name="SyncSampleBox"}parse(t){this.parseFullHeader(t);let e=t.readUint32();if(this.version===0){this.sample_numbers=[];for(let s=0;s<e;s++)this.sample_numbers.push(t.readUint32())}}write(t){this.version=0,this.flags=0,this.size=4+4*this.sample_numbers.length,this.writeHeader(t),t.writeUint32(this.sample_numbers.length),t.writeUint32Array(this.sample_numbers)}},Ar.fourcc="stss",Ar),qd=(Fr=class extends p{constructor(...t){super(...t),this.box_name="StereoVideoBox"}parse(t){this.parseFullHeader(t);let e=t.readUint32();this.single_view_allowed=e&3,this.stereo_scheme=t.readUint32();let s=t.readUint32();for(this.stereo_indication_type=t.readString(s),this.boxes=[];t.getPosition()<this.start+this.size;){let i=H(t,false,this.size-(t.getPosition()-this.start));if(i.code===1){let r=i.box;this.boxes.push(r),this[r.type]=r}else return}}},Fr.fourcc="stvi",Fr),Yd=(Tr=class extends p{constructor(...t){super(...t),this.box_name="CompactSampleSizeBox"}parse(t){if(this.parseFullHeader(t),this.sample_sizes=[],this.version===0){this.reserved=t.readUint24(),this.field_size=t.readUint8();let e=t.readUint32();if(this.field_size===4)for(let s=0;s<e;s+=2){let i=t.readUint8();this.sample_sizes[s]=i>>4&15,this.sample_sizes[s+1]=i&15}else if(this.field_size===8)for(let s=0;s<e;s++)this.sample_sizes[s]=t.readUint8();else if(this.field_size===16)for(let s=0;s<e;s++)this.sample_sizes[s]=t.readUint16();else d.error("BoxParser","Error in length field in stz2 box",t.isofile)}}},Tr.fourcc="stz2",Tr),Wd=(Dr=class extends p{constructor(...t){super(...t),this.box_name="SubSampleInformationBox"}parse(t){this.parseFullHeader(t);let e=t.readUint32();this.entries=[];let s;for(let i=0;i<e;i++){let r={};if(this.entries[i]=r,r.sample_delta=t.readUint32(),r.subsamples=[],s=t.readUint16(),s>0)for(let a=0;a<s;a++){let n={};r.subsamples.push(n),n.size=this.version===1?t.readUint32():t.readUint16(),n.priority=t.readUint8(),n.discardable=t.readUint8(),n.codec_specific_parameters=t.readUint32()}}}},Dr.fourcc="subs",Dr),Kd=(Lr=class extends p{constructor(...t){super(...t),this.box_name="TAIClockInfoBox"}parse(t){this.time_uncertainty=t.readUint64(),this.clock_resolution=t.readUint32(),this.clock_drift_rate=t.readInt32();let e=t.readUint8();this.clock_type=(e&192)>>6}},Lr.fourcc="taic",Lr),Jd=(Hr=class extends p{constructor(...t){super(...t),this.box_name="TrackEncryptionBox"}parse(t){if(this.parseFullHeader(t),t.readUint8(),this.version===0)t.readUint8();else{let e=t.readUint8();this.default_crypt_byte_block=e>>4&15,this.default_skip_byte_block=e&15}this.default_isProtected=t.readUint8(),this.default_Per_Sample_IV_Size=t.readUint8(),this.default_KID=V(t),this.default_isProtected===1&&this.default_Per_Sample_IV_Size===0&&(this.default_constant_IV_size=t.readUint8(),this.default_constant_IV=t.readUint8Array(this.default_constant_IV_size))}},Hr.fourcc="tenc",Hr),Qd=class{},Xd=(Mr=class extends p{constructor(...t){super(...t),this.box_name="TrackFragmentRandomAccessBox"}parse(t){this.parseFullHeader(t),this.track_ID=t.readUint32(),t.readUint24();let e=t.readUint8();this.length_size_of_traf_num=e>>4&3,this.length_size_of_trun_num=e>>2&3,this.length_size_of_sample_num=e&3,this.entries=[];let s=t.readUint32();for(let i=0;i<s;i++){let r=new Qd;this.version===1?(r.time=t.readUint64(),r.moof_offset=t.readUint64()):(r.time=t.readUint32(),r.moof_offset=t.readUint32()),r.traf_number=t["readUint"+8*(this.length_size_of_traf_num+1)](),r.trun_number=t["readUint"+8*(this.length_size_of_trun_num+1)](),r.sample_delta=t["readUint"+8*(this.length_size_of_sample_num+1)](),this.entries.push(r)}}},Mr.fourcc="tfra",Mr),Zd=(Or=class extends f{constructor(...t){super(...t),this.box_name="hintmaxrelativetime"}parse(t){this.time=t.readUint32()}},Or.fourcc="tmax",Or),tc=(Rr=class extends f{constructor(...t){super(...t),this.box_name="hintminrelativetime"}parse(t){this.time=t.readUint32()}},Rr.fourcc="tmin",Rr),ec=(Nr=class extends f{constructor(...t){super(...t),this.box_name="hintBytesSent"}parse(t){this.bytessent=t.readUint32()}},Nr.fourcc="totl",Nr),sc=(Vr=class extends f{constructor(...t){super(...t),this.box_name="hintBytesSent"}parse(t){this.bytessent=t.readUint32()}},Vr.fourcc="tpay",Vr),ic=(Gr=class extends f{constructor(...t){super(...t),this.box_name="hintBytesSent"}parse(t){this.bytessent=t.readUint64()}},Gr.fourcc="tpyl",Gr),rc=(jr=class extends Wa{},jr.fourcc="msrc",jr),ac=(it=class Rn extends f{constructor(...e){super(...e),this.box_name="TrackReferenceBox",this.references=[]}parse(e){for(;e.getPosition()<this.start+this.size;){let s=H(e,true,this.size-(e.getPosition()-this.start));if(s.code===1){Rn.allowed_types.includes(s.type)||d.warn("BoxParser",`Unknown track reference type: '${s.type}'`);let i=new Ka(s.type,s.size,s.hdr_size,s.start);i.write===f.prototype.write&&i.type!=="mdat"&&(d.info("BoxParser","TrackReference "+i.type+" box writing not yet implemented, keeping unparsed data in memory for later write"),i.parseDataAndRewind(e)),i.parse(e),this.references.push(i)}else return}}},it.fourcc="tref",it.allowed_types=["hint","cdsc","font","hind","vdep","vplx","subt","thmb","auxl","cdtg","shsc","aest"],it),nc=($r=class extends p{constructor(...t){super(...t),this.box_name="TrackExtensionPropertiesBox"}parse(t){for(this.parseFullHeader(t),this.track_ID=t.readUint32(),this.boxes=[];t.getPosition()<this.start+this.size;){let e=H(t,false,this.size-(t.getPosition()-this.start));if(e.code===1){let s=e.box;this.boxes.push(s)}else return}}},$r.fourcc="trep",$r),oc=(qr=class extends f{constructor(...t){super(...t),this.box_name="hintBytesSent"}parse(t){this.bytessent=t.readUint64()}},qr.fourcc="trpy",qr),hc=(Yr=class extends p{constructor(...t){super(...t),this.box_name="TrackSelectionBox"}parse(t){this.parseFullHeader(t),this.switch_group=t.readUint32();let e=(this.size-this.hdr_size-4)/4;this.attribute_list=[];for(let s=0;s<e;s++)this.attribute_list[s]=t.readUint32()}},Yr.fourcc="tsel",Yr),lc=(Wr=class extends p{constructor(...t){super(...t),this.box_name="TextConfigBox"}parse(t){this.parseFullHeader(t),this.config=t.readCString()}},Wr.fourcc="txtc",Wr),dc=(Kr=class extends f{constructor(...t){super(...t),this.box_name="TypeCombinationBox"}parse(t){let e=(this.size-this.hdr_size)/4;this.compatible_brands=[];for(let s=0;s<e;s++)this.compatible_brands[s]=t.readString(4)}},Kr.fourcc="tyco",Kr),cc=(Jr=class extends p{constructor(...t){super(...t),this.box_name="UserDescriptionProperty"}parse(t){this.parseFullHeader(t),this.lang=t.readCString(),this.name=t.readCString(),this.description=t.readCString(),this.tags=t.readCString()}},Jr.fourcc="udes",Jr),pc=(Qr=class extends p{constructor(...t){super(...t),this.box_name="UncompressedFrameConfigBox"}parse(t){if(this.parseFullHeader(t),this.profile=t.readString(4),this.version!==1&&this.version===0){this.component_count=t.readUint32(),this.component_index=[],this.component_bit_depth_minus_one=[],this.component_format=[],this.component_align_size=[];for(let s=0;s<this.component_count;s++)this.component_index.push(t.readUint16()),this.component_bit_depth_minus_one.push(t.readUint8()),this.component_format.push(t.readUint8()),this.component_align_size.push(t.readUint8());this.sampling_type=t.readUint8(),this.interleave_type=t.readUint8(),this.block_size=t.readUint8();let e=t.readUint8();this.component_little_endian=e>>7&1,this.block_pad_lsb=e>>6&1,this.block_little_endian=e>>5&1,this.block_reversed=e>>4&1,this.pad_unknown=e>>3&1,this.pixel_size=t.readUint32(),this.row_align_size=t.readUint32(),this.tile_align_size=t.readUint32(),this.num_tile_cols_minus_one=t.readUint32(),this.num_tile_rows_minus_one=t.readUint32()}}},Qr.fourcc="uncC",Qr),uc=(Xr=class extends p{constructor(...t){super(...t),this.box_name="DataEntryUrnBox"}parse(t){this.parseFullHeader(t),this.name=t.readCString(),this.size-this.hdr_size-this.name.length-1>0&&(this.location=t.readCString())}write(t){this.version=0,this.flags=0,this.size=this.name.length+1+(this.location?this.location.length+1:0),this.writeHeader(t),t.writeCString(this.name),this.location&&t.writeCString(this.location)}},Xr.fourcc="urn ",Xr),fc=(Zr=class extends f{constructor(...t){super(...t),this.box_name="WebVTTConfigurationBox"}parse(t){this.text=t.readString(this.size-this.hdr_size)}},Zr.fourcc="vttC",Zr),mc=(ta=class extends p{constructor(...t){super(...t),this.box_name="VvcNALUConfigBox"}parse(t){this.parseFullHeader(t);let e=t.readUint8();this.lengthSizeMinusOne=e&3}},ta.fourcc="vvnC",ta),_c=(ea=class extends v{parse(t){let e=t.readUint16();this.first_output_sample=t.readUint16(),this.sample_offset=[];for(let i=0;i<e;i++)this.sample_offset[i]=t.readUint32();let s=this.description_length-4-4*e;this.num_output_samples=[],this.num_total_samples=[];for(let i=0;i<s/4;i++)this.num_output_samples[i]=t.readUint16(),this.num_total_samples[i]=t.readUint16()}},ea.grouping_type="alst",ea),gc=(sa=class extends v{parse(t){this.layerNumber=t.readUint8(),this.accurateStatisticsFlag=t.readUint8(),this.avgBitRate=t.readUint16(),this.avgFrameRate=t.readUint16()}},sa.grouping_type="avll",sa),xc=(ia=class extends v{parse(t){this.subSequenceIdentifier=t.readUint16(),this.layerNumber=t.readUint8();let e=t.readUint8();this.durationFlag=e>>7,this.avgRateFlag=e>>6&1,this.durationFlag&&(this.duration=t.readUint32()),this.avgRateFlag&&(this.accurateStatisticsFlag=t.readUint8(),this.avgBitRate=t.readUint16(),this.avgFrameRate=t.readUint16()),this.dependency=[];let s=t.readUint8();for(let i=0;i<s;i++)this.dependency.push({subSeqDirectionFlag:t.readUint8(),layerNumber:t.readUint8(),subSequenceIdentifier:t.readUint16()})}},ia.grouping_type="avss",ia),bc=(ra=class extends v{parse(t){d.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")}},ra.grouping_type="dtrt",ra),yc=(aa=class extends v{parse(t){d.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")}},aa.grouping_type="mvif",aa),Uc=(na=class extends v{parse(t){this.roll_distance=t.readInt16()}},na.grouping_type="prol",na),wc=(oa=class extends v{parse(t){let e=t.readUint8();this.num_leading_samples_known=e>>7,this.num_leading_samples=e&127}},oa.grouping_type="rap ",oa),Sc=(ha=class extends v{parse(t){if(this.operation_point_count=t.readUint16(),this.description_length!==2+(this.operation_point_count===1?2:this.operation_point_count*6)+9)d.warn("BoxParser","Mismatch in "+this.grouping_type+" sample group length"),this.data=t.readUint8Array(this.description_length-2);else{if(this.operation_point_count===1)this.target_rate_share=t.readUint16();else{this.target_rate_share=[],this.available_bitrate=[];for(let e=0;e<this.operation_point_count;e++)this.available_bitrate[e]=t.readUint32(),this.target_rate_share[e]=t.readUint16()}this.maximum_bitrate=t.readUint32(),this.minimum_bitrate=t.readUint32(),this.discard_priority=t.readUint8()}}},ha.grouping_type="rash",ha),vc=(la=class extends v{parse(t){this.roll_distance=t.readInt16()}},la.grouping_type="roll",la),Bc=(da=class extends v{parse(t){d.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")}},da.grouping_type="scif",da),zc=(ca=class extends v{parse(t){d.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")}},ca.grouping_type="scnm",ca),kc=(pa=class extends v{parse(t){this.reserved=t.readUint8();let e=t.readUint8();this.crypt_byte_block=e>>4,this.skip_byte_block=e&15,this.isProtected=t.readUint8(),this.Per_Sample_IV_Size=t.readUint8(),this.KID=V(t),this.constant_IV_size=0,this.constant_IV=0,this.isProtected===1&&this.Per_Sample_IV_Size===0&&(this.constant_IV_size=t.readUint8(),this.constant_IV=t.readUint8Array(this.constant_IV_size))}},pa.grouping_type="seig",pa),Ic=(ua=class extends v{parse(t){d.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")}},ua.grouping_type="stsa",ua),Ec=(fa=class extends v{parse(t){let e=t.readUint8();this.NAL_unit_type=e&63}},fa.grouping_type="sync",fa),Cc=(ma=class extends v{parse(t){let e=t.readUint8();this.level_independently_decodable=e>>7}},ma.grouping_type="tele",ma),Pc=(_a=class extends v{parse(t){d.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")}},_a.grouping_type="tsas",_a),Ac=(ga=class extends v{parse(t){d.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")}},ga.grouping_type="tscl",ga),Fc=(xa=class extends v{parse(t){d.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")}},xa.grouping_type="vipr",xa),Nn=(ba=class extends f{},ba.fourcc="uuid",ba),$=(ya=class extends p{},ya.fourcc="uuid",ya),Tc=(Ua=class extends ${constructor(...t){super(...t),this.box_name="LiveServerManifestBox"}parse(t){this.parseFullHeader(t),this.LiveServerManifest=t.readString(this.size-this.hdr_size).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}},Ua.uuid="a5d40b30e81411ddba2f0800200c9a66",Ua),Dc=(wa=class extends ${constructor(...t){super(...t),this.box_name="PiffProtectionSystemSpecificHeaderBox"}parse(t){this.parseFullHeader(t),this.system_id=V(t);let e=t.readUint32();e>0&&(this.data=t.readUint8Array(e))}},wa.uuid="d08a4f1810f34a82b6c832d8aba183d3",wa),Lc=(Sa=class extends ${constructor(...t){super(...t),this.box_name="PiffSampleEncryptionBox"}},Sa.uuid="a2394f525a9b4f14a2446c427c648df4",Sa),Hc=(va=class extends ${constructor(...t){super(...t),this.box_name="PiffTrackEncryptionBox"}parse(t){this.parseFullHeader(t),this.default_AlgorithmID=t.readUint24(),this.default_IV_size=t.readUint8(),this.default_KID=V(t)}},va.uuid="8974dbce7be74c5184f97148f9882554",va),Mc=(Ba=class extends ${constructor(...t){super(...t),this.box_name="TfrfBox"}parse(t){this.parseFullHeader(t),this.fragment_count=t.readUint8(),this.entries=[];for(let e=0;e<this.fragment_count;e++){let s=0,i=0;this.version===1?(s=t.readUint64(),i=t.readUint64()):(s=t.readUint32(),i=t.readUint32()),this.entries.push({absolute_time:s,absolute_duration:i})}}},Ba.uuid="d4807ef2ca3946958e5426cb9e46a79f",Ba),Oc=(za=class extends ${constructor(...t){super(...t),this.box_name="TfxdBox"}parse(t){this.parseFullHeader(t),this.version===1?(this.absolute_time=t.readUint64(),this.duration=t.readUint64()):(this.absolute_time=t.readUint32(),this.duration=t.readUint32())}},za.uuid="6d1d9b0542d544e680e2141daff757b2",za),Rc=(ka=class extends Nn{constructor(...t){super(...t),this.box_name="ItemContentIDProperty"}parse(t){this.content_id=t.readCString()}},ka.uuid="261ef3741d975bbaacbd9d2c8ea73522",ka),Nc=(Ia=class extends Nn{constructor(...t){super(...t),this.box_name="ItemComponentContentIDProperty"}parse(t){this.number_of_components=t.readUint32(),this.content_ids=[];for(let e=0;e<this.number_of_components;e++){let s=t.readCString();this.content_ids.push(s)}}},Ia.uuid="9db9dd6e373c5a4e811021fc83a911fd",Ia);so($a({CoLLBox:()=>ml,ItemComponentContentIDPropertyBox:()=>Nc,ItemContentIDPropertyBox:()=>Rc,OpusSampleEntry:()=>kh,SmDmBox:()=>Od,a1lxBox:()=>sl,a1opBox:()=>il,ac_3SampleEntry:()=>vh,ac_4SampleEntry:()=>Bh,aebrBox:()=>Al,afbrBox:()=>Fl,albcBox:()=>Tl,alstSampleGroupEntry:()=>_c,altrBox:()=>Dl,auxCBox:()=>rl,av01SampleEntry:()=>Zo,av1CBox:()=>Vo,avc1SampleEntry:()=>Ko,avc2SampleEntry:()=>Jo,avc3SampleEntry:()=>Qo,avc4SampleEntry:()=>Xo,avcCBox:()=>Xa,avllSampleGroupEntry:()=>gc,avs3SampleEntry:()=>gh,avssSampleGroupEntry:()=>xc,brstBox:()=>Ll,btrtBox:()=>al,bxmlBox:()=>po,ccstBox:()=>nl,cdefBox:()=>ol,clapBox:()=>hl,clefBox:()=>vd,clliBox:()=>ll,cmexBox:()=>dl,cminBox:()=>cl,cmpCBox:()=>pl,cmpdBox:()=>ul,co64Box:()=>fl,colrBox:()=>Wo,coviBox:()=>xl,cprtBox:()=>bl,cschBox:()=>yl,cslgBox:()=>Ul,cttsBox:()=>wl,dOpsBox:()=>El,dac3Box:()=>Sl,dataBox:()=>K,dav1SampleEntry:()=>th,dec3Box:()=>vl,dfLaBox:()=>Bl,dimmBox:()=>zl,dinfBox:()=>an,dmax:()=>kl,dmedBox:()=>Il,dobrBox:()=>Hl,drefBox:()=>ln,drepBox:()=>Cl,dtrtSampleGroupEntry:()=>bc,dvh1SampleEntry:()=>lh,dvheSampleEntry:()=>dh,ec_3SampleEntry:()=>zh,edtsBox:()=>fo,elngBox:()=>dn,elstBox:()=>Pl,emsgBox:()=>Qh,encaSampleEntry:()=>Th,encmSampleEntry:()=>Oh,encsSampleEntry:()=>Lh,enctSampleEntry:()=>Mh,encuSampleEntry:()=>Dh,encvSampleEntry:()=>Fh,enofBox:()=>zd,eqivBox:()=>Ml,esdsBox:()=>Go,etypBox:()=>Po,fLaCSampleEntry:()=>Ah,favcBox:()=>Ol,fielBox:()=>Kl,fobrBox:()=>Rl,freeBox:()=>oo,frmaBox:()=>Jl,ftypBox:()=>cn,grplBox:()=>Eo,hdlrBox:()=>pn,hev1SampleEntry:()=>ih,hev2SampleEntry:()=>rh,hinfBox:()=>bo,hmhdBox:()=>Za,hntiBox:()=>xo,hvc1SampleEntry:()=>eh,hvc2SampleEntry:()=>sh,hvcCBox:()=>un,hvt1SampleEntry:()=>ah,iaugBox:()=>Nl,idatBox:()=>no,iinfBox:()=>To,ilocBox:()=>Do,ilstBox:()=>kd,imirBox:()=>Ql,infeBox:()=>Fo,iodsBox:()=>lo,ipcoBox:()=>Io,ipmaBox:()=>Xl,iproBox:()=>uo,iprpBox:()=>ko,irefBox:()=>Ho,irotBox:()=>Zl,ispeBox:()=>td,itaiBox:()=>ed,j2kHBox:()=>Co,j2kiSampleEntry:()=>xh,keysBox:()=>Id,kindBox:()=>sd,levaBox:()=>id,lhe1SampleEntry:()=>nh,lhv1SampleEntry:()=>oh,lhvCBox:()=>rd,lselBox:()=>ad,lvc1SampleEntry:()=>hh,lvcCBox:()=>$o,m4aeSampleEntry:()=>Sh,maxrBox:()=>nd,mdatBox:()=>nt,mdcvBox:()=>od,mdhdBox:()=>fn,mdiaBox:()=>sn,mecoBox:()=>go,mehdBox:()=>mn,metaBox:()=>Oo,mettSampleEntry:()=>Ro,metxSampleEntry:()=>No,mfhdBox:()=>gn,mfraBox:()=>_o,mfroBox:()=>hd,mha1SampleEntry:()=>Ih,mha2SampleEntry:()=>Eh,mhm1SampleEntry:()=>Ch,mhm2SampleEntry:()=>Ph,minfBox:()=>rn,mjp2SampleEntry:()=>bh,mjpgSampleEntry:()=>yh,moofBox:()=>on,moovBox:()=>ot,mp4aSampleEntry:()=>Un,mp4sSampleEntry:()=>Hh,mp4vSampleEntry:()=>wh,mskCBox:()=>ld,msrcTrackGroupTypeBox:()=>rc,mvexBox:()=>Pa,mvhdBox:()=>xn,mvifSampleGroupEntry:()=>yc,nmhdBox:()=>tn,npckBox:()=>dd,numpBox:()=>cd,padbBox:()=>ud,panoBox:()=>Vl,paspBox:()=>fd,paylBox:()=>md,paytBox:()=>_d,pdinBox:()=>gd,piffLsmBox:()=>Tc,piffPsshBox:()=>Dc,piffSencBox:()=>Lc,piffTencBox:()=>Hc,piffTfrfBox:()=>Mc,piffTfxdBox:()=>Oc,pitmBox:()=>Mo,pixiBox:()=>xd,pmaxBox:()=>bd,povdBox:()=>Ao,prdiBox:()=>yd,prfrBox:()=>Ud,prftBox:()=>wd,prgrBox:()=>Yl,profBox:()=>Ed,prolSampleGroupEntry:()=>Uc,psshBox:()=>Sd,pymdBox:()=>Wl,rapSampleGroupEntry:()=>wc,rashSampleGroupEntry:()=>Sc,resvSampleEntry:()=>Rh,rinfBox:()=>So,rollSampleGroupEntry:()=>vc,rtp_Box:()=>Pd,saioBox:()=>Ad,saizBox:()=>Fd,sbgpBox:()=>$h,sbpmBox:()=>Dd,sbttSampleEntry:()=>Nh,schiBox:()=>vo,schmBox:()=>Ld,scifSampleGroupEntry:()=>Bc,scnmSampleGroupEntry:()=>zc,sdp_Box:()=>Hd,sdtpBox:()=>qh,seigSampleGroupEntry:()=>kc,sencBox:()=>Md,sgpdBox:()=>Yh,sidxBox:()=>Wh,sinfBox:()=>wo,skipBox:()=>ho,slidBox:()=>Gl,smhdBox:()=>Sn,sratBox:()=>Rd,ssixBox:()=>Xh,stblBox:()=>nn,stcoBox:()=>vn,stdpBox:()=>Nd,sterBox:()=>jl,sthdBox:()=>Bn,stppSampleEntry:()=>wn,strdBox:()=>Uo,striBox:()=>Vd,strkBox:()=>yo,stsaSampleGroupEntry:()=>Ic,stscBox:()=>zn,stsdBox:()=>kn,stsgBox:()=>Gd,stshBox:()=>jd,stssBox:()=>$d,stszBox:()=>In,sttsBox:()=>En,stviBox:()=>qd,stxtSampleEntry:()=>Vh,stypBox:()=>Zh,stz2Box:()=>Yd,subsBox:()=>Wd,syncSampleGroupEntry:()=>Ec,taicBox:()=>Kd,taptBox:()=>Cd,teleSampleGroupEntry:()=>Cc,tencBox:()=>Jd,tfdtBox:()=>Cn,tfhdBox:()=>Pn,tfraBox:()=>Xd,tkhdBox:()=>An,tmaxBox:()=>Zd,tminBox:()=>tc,totlBox:()=>ec,tpayBox:()=>sc,tpylBox:()=>ic,trafBox:()=>hn,trakBox:()=>en,trefBox:()=>ac,trepBox:()=>nc,trexBox:()=>Aa,trgrBox:()=>Bo,trpyBox:()=>oc,trunBox:()=>Fn,tsasSampleGroupEntry:()=>Pc,tsclSampleGroupEntry:()=>Ac,tselBox:()=>hc,tsynBox:()=>$l,tx3gSampleEntry:()=>Gh,txtcBox:()=>lc,tycoBox:()=>dc,udesBox:()=>cc,udtaBox:()=>zo,uncCBox:()=>pc,uncvSampleEntry:()=>Uh,urlBox:()=>Tn,urnBox:()=>uc,viprSampleGroupEntry:()=>Fc,vmhdBox:()=>Dn,vp08SampleEntry:()=>mh,vp09SampleEntry:()=>_h,vpcCBox:()=>qo,vttCBox:()=>fc,vttcBox:()=>mo,vvc1SampleEntry:()=>ch,vvcCBox:()=>Yo,vvcNSampleEntry:()=>fh,vvi1SampleEntry:()=>ph,vvnCBox:()=>mc,vvs1SampleEntry:()=>uh,waveBox:()=>jo,wbbrBox:()=>ql,wvttSampleEntry:()=>jh,xmlBox:()=>co})),io(tl);export{Vn as i,C as n,Jh as r,Vc as t};