PageSourceSearch

https://www.coolinarika.com/foodhacks/dist/c/c-M6YF3T7I.js

js coolinarika.com collected 2026-10-02 11:13:53 UTC 140,865 bytes, 2 lines download raw bytes

1import{b as M}from"https://st-p.rmcdn1.net/5f7ff697/dist/c/c-PIJB5DBS.js";var G=M(S=>{var l=function(){var t=new Date,e=4,i=3,s=2,n=1,a=e,o={setLogLevel:function(h){h==this.debug?a=n:h==this.info?a=s:h==this.warn?a=i:(h==this.error,a=e)},debug:function(h,d){console.debug===void 0&&(console.debug=console.log),n>=a&&console.debug("["+l.getDurationString(new Date-t,1e3)+"]","["+h+"]",d)},log:function(h,d){this.debug(h.msg)},info:function(h,d){s>=a&&console.info("["+l.getDurationString(new Date-t,1e3)+"]","["+h+"]",d)},warn:function(h,d){i>=a&&console.warn("["+l.getDurationString(new Date-t,1e3)+"]","["+h+"]",d)},error:function(h,d){e>=a&&console.error("["+l.getDurationString(new Date-t,1e3)+"]","["+h+"]",d)}};return o}();l.getDurationString=function(t,e){var i;function s(u,p){for(var y=""+u,g=y.split(".");g[0].length<p;)g[0]="0"+g[0];return g.join(".")}t<0?(i=!0,t=-t):i=!1;var n=e||1,a=t/n,o=Math.floor(a/3600);a-=o*3600;var h=Math.floor(a/60);a-=h*60;var d=a*1e3;return a=Math.floor(a),d-=a*1e3,d=Math.floor(d),(i?"-":"")+o+":"+s(h,2)+":"+s(a,2)+"."+s(d,3)};l.printRanges=function(t){var e=t.length;if(e>0){for(var i="",s=0;s<e;s++)s>0&&(i+=","),i+="["+l.getDurationString(t.start(s))+","+l.getDurationString(t.end(s))+"]";return i}else return"(empty)"};typeof S<"u"&&(S.Log=l);var m=function(t){if(t instanceof ArrayBuffer)this.buffer=t,this.dataview=new DataView(t);else throw"Needs an array buffer";this.position=0};m.prototype.getPosition=function(){return this.position};m.prototype.getEndPosition=function(){return this.buffer.byteLength};m.prototype.getLength=function(){return this.buffer.byteLength};m.prototype.seek=function(t){var e=Math.max(0,Math.min(this.buffer.byteLength,t));return this.position=isNaN(e)||!isFinite(e)?0:e,!0};m.prototype.isEos=function(){return this.getPosition()>=this.getEndPosition()};m.prototype.readAnyInt=function(t,e){var i=0;if(this.position+t<=this.buffer.byteLength){switch(t){case 1:e?i=this.dataview.getInt8(this.position):i=this.dataview.getUint8(this.position);break;case 2:e?i=this.dataview.getInt16(this.position):i=this.dataview.getUint16(this.position);break;case 3:if(e)throw"No method for reading signed 24 bits values";i=this.dataview.getUint8(this.position)<<16,i|=this.dataview.getUint8(this.position+1)<<8,i|=this.dataview.getUint8(this.position+2);break;case 4:e?i=this.dataview.getInt32(this.position):i=this.dataview.getUint32(this.position);break;case 8:if(e)throw"No method for reading signed 64 bits values";i=this.dataview.getUint32(this.position)<<32,i|=this.dataview.getUint32(this.position+4);break;default:throw"readInt method not implemented for size: "+t}return this.position+=t,i}else throw"Not enough bytes in buffer"};m.prototype.readUint8=function(){return this.readAnyInt(1,!1)};m.prototype.readUint16=function(){return this.readAnyInt(2,!1)};m.prototype.readUint24=function(){return this.readAnyInt(3,!1)};m.prototype.readUint32=function(){return this.readAnyInt(4,!1)};m.prototype.readUint64=function(){return this.readAnyInt(8,!1)};m.prototype.readString=function(t){if(this.position+t<=this.buffer.byteLength){for(var e="",i=0;i<t;i++)e+=String.fromCharCode(this.readUint8());return e}else throw"Not enough bytes in buffer"};m.prototype.readCString=function(){for(var t=[];;){var e=this.readUint8();if(e!==0)t.push(e);else break}return String.fromCharCode.apply(null,t)};m.prototype.readInt8=function(){return this.readAnyInt(1,!0)};m.prototype.readInt16=function(){return this.readAnyInt(2,!0)};m.prototype.readInt32=function(){return this.readAnyInt(4,!0)};m.prototype.readInt64=function(){return this.readAnyInt(8,!1)};m.prototype.readUint8Array=function(t){for(var e=new Uint8Array(t),i=0;i<t;i++)e[i]=this.readUint8();return e};m.prototype.readInt16Array=function(t){for(var e=new Int16Array(t),i=0;i<t;i++)e[i]=this.readInt16();return e};m.prototype.readUint16Array=function(t){for(var e=new Int16Array(t),i=0;i<t;i++)e[i]=this.readUint16();return e};m.prototype.readUint32Array=function(t){for(var e=new Uint32Array(t),i=0;i<t;i++)e[i]=this.readUint32();return e};m.prototype.readInt32Array=function(t){for(var e=new Int32Array(t),i=0;i<t;i++)e[i]=this.readInt32();return e};typeof S<"u"&&(S.MP4BoxStream=m);
1var f=function(t,e,i){this._byteOffset=e||0,t instanceof ArrayBuffer?this.buffer=t:typeof t=="object"?(this.dataView=t,e&&(this._byteOffset+=e)):this.buffer=new ArrayBuffer(t||0),this.position=0,this.endianness=i??f.LITTLE_ENDIAN};f.prototype={};f.prototype.getPosition=function(){return this.position};f.prototype._realloc=function(t){if(this._dynamicSize){var e=this._byteOffset+this.position+t,i=this._buffer.byteLength;if(e<=i){e>this._byteLength&&(this._byteLength=e);return}for(i<1&&(i=1);e>i;)i*=2;var s=new ArrayBuffer(i),n=new Uint8Array(this._buffer),a=new Uint8Array(s,0,n.length);a.set(n),this.buffer=s,this._byteLength=e}};f.prototype._trimAlloc=function(){if(this._byteLength!=this._buffer.byteLength){var t=new ArrayBuffer(this._byteLength),e=new Uint8Array(t),i=new Uint8Array(this._buffer,0,e.length);e.set(i),this.buffer=t}};f.BIG_ENDIAN=!1;f.LITTLE_ENDIAN=!0;f.prototype._byteLength=0;Object.defineProperty(f.prototype,"byteLength",{get:function(){return this._byteLength-this._byteOffset}});Object.defineProperty(f.prototype,"buffer",{get:function(){return this._trimAlloc(),this._buffer},set:function(t){this._buffer=t,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._buffer.byteLength}});Object.defineProperty(f.prototype,"byteOffset",{get:function(){return this._byteOffset},set:function(t){this._byteOffset=t,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._buffer.byteLength}});Object.defineProperty(f.prototype,"dataView",{get:function(){return this._dataView},set:function(t){this._byteOffset=t.byteOffset,this._buffer=t.buffer,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._byteOffset+t.byteLength}});f.prototype.seek=function(t){var e=Math.max(0,Math.min(this.byteLength,t));this.position=isNaN(e)||!isFinite(e)?0:e};f.prototype.isEof=function(){return this.position>=this._byteLength};f.prototype.mapUint8Array=function(t){this._realloc(t*1);var e=new Uint8Array(this._buffer,this.byteOffset+this.position,t);return this.position+=t*1,e};f.prototype.readInt32Array=function(t,e){t=t??this.byteLength-this.position/4;var i=new Int32Array(t);return f.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,t*i.BYTES_PER_ELEMENT),f.arrayToNative(i,e??this.endianness),this.position+=i.byteLength,i};f.prototype.readInt16Array=function(t,e){t=t??this.byteLength-this.position/2;var i=new Int16Array(t);return f.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,t*i.BYTES_PER_ELEMENT),f.arrayToNative(i,e??this.endianness),this.position+=i.byteLength,i};f.prototype.readInt8Array=function(t){t=t??this.byteLength-this.position;var e=new Int8Array(t);return f.memcpy(e.buffer,0,this.buffer,this.byteOffset+this.position,t*e.BYTES_PER_ELEMENT),this.position+=e.byteLength,e};f.prototype.readUint32Array=function(t,e){t=t??this.byteLength-this.position/4;var i=new Uint32Array(t);return f.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,t*i.BYTES_PER_ELEMENT),f.arrayToNative(i,e??this.endianness),this.position+=i.byteLength,i};f.prototype.readUint16Array=function(t,e){t=t??this.byteLength-this.position/2;var i=new Uint16Array(t);return f.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,t*i.BYTES_PER_ELEMENT),f.arrayToNative(i,e??this.endianness),this.position+=i.byteLength,i};f.prototype.readUint8Array=function(t){t=t??this.byteLength-this.position;var e=new Uint8Array(t);return f.memcpy(e.buffer,0,this.buffer,this.byteOffset+this.position,t*e.BYTES_PER_ELEMENT),this.position+=e.byteLength,e};f.prototype.readFloat64Array=function(t,e){t=t??this.byteLength-this.position/8;var i=new Float64Array(t);return f.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,t*i.BYTES_PER_ELEMENT),f.arrayToNative(i,e??this.endianness),this.position+=i.byteLength,i};f.prototype.readFloat32Array=function(t,e){t=t??this.byteLength-this.position/4;var i=new Float32Array(t);return f.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,t*i.BYTES_PER_ELEMENT),f.arrayToNative(i,e??this.endianness),this.position+=i.byteLength,i};f.prototype.readInt32=function(t){var e=this._dataView.getInt32(this.position,t??this.endianness);return this.position+=4,e};f.prototype.readInt16=function(t){var e=this._dataView.getInt16(this.position,t??this.endianness);return this.position+=2,e};f.prototype.readInt8=function(){var t=this._dataView.getInt8(this.position);return this.position+=1,t};f.prototype.readUint32=function(t){var e=this._dataView.getUint32(this.position,t??this.endianness);return this.position+=4,e};f.prototype.readUint16=function(t){var e=this._dataView.getUint16(this.position,t??this.endianness);return this.position+=2,e};f.prototype.readUint8=function(){var t=this._dataView.getUint8(this.position);return this.position+=1,t};f.prototype.readFloat32=function(t){var e=this._dataView.getFloat32(this.position,t??this.endianness);return this.position+=4,e};f.prototype.readFloat64=function(t){var e=this._dataView.getFloat64(this.position,t??this.endianness);return this.position+=8,e};f.endianness=new Int8Array(new Int16Array([1]).buffer)[0]>0;
1f.memcpy=function(t,e,i,s,n){var a=new Uint8Array(t,e,n),o=new Uint8Array(i,s,n);a.set(o)};f.arrayToNative=function(t,e){return e==this.endianness?t:this.flipArrayEndianness(t)};f.nativeToEndian=function(t,e){return this.endianness==e?t:this.flipArrayEndianness(t)};f.flipArrayEndianness=function(t){for(var e=new Uint8Array(t.buffer,t.byteOffset,t.byteLength),i=0;i<t.byteLength;i+=t.BYTES_PER_ELEMENT)for(var s=i+t.BYTES_PER_ELEMENT-1,n=i;s>n;s--,n++){var a=e[n];e[n]=e[s],e[s]=a}return t};f.prototype.failurePosition=0;String.fromCharCodeUint8=function(t){for(var e=[],i=0;i<t.length;i++)e[i]=t[i];return String.fromCharCode.apply(null,e)};f.prototype.readString=function(t,e){return e==null||e=="ASCII"?String.fromCharCodeUint8.apply(null,[this.mapUint8Array(t??this.byteLength-this.position)]):new TextDecoder(e).decode(this.mapUint8Array(t))};f.prototype.readCString=function(t){var e=this.byteLength-this.position,i=new Uint8Array(this._buffer,this._byteOffset+this.position),s=e;t!=null&&(s=Math.min(t,e));for(var n=0;n<s&&i[n]!==0;n++);var a=String.fromCharCodeUint8.apply(null,[this.mapUint8Array(n)]);return t!=null?this.position+=s-n:n!=e&&(this.position+=1),a};var B=Math.pow(2,32);f.prototype.readInt64=function(){return this.readInt32()*B+this.readUint32()};f.prototype.readUint64=function(){return this.readUint32()*B+this.readUint32()};f.prototype.readInt64=function(){return this.readUint32()*B+this.readUint32()};f.prototype.readUint24=function(){return(this.readUint8()<<16)+(this.readUint8()<<8)+this.readUint8()};typeof S<"u"&&(S.DataStream=f);f.prototype.save=function(t){var e=new Blob([this.buffer]);if(window.URL&&URL.createObjectURL){var i=window.URL.createObjectURL(e),s=document.createElement("a");document.body.appendChild(s),s.setAttribute("href",i),s.setAttribute("download",t),s.setAttribute("target","_self"),s.click(),window.URL.revokeObjectURL(i)}else throw"DataStream.save: Can't create object URL."};f.prototype._dynamicSize=!0;Object.defineProperty(f.prototype,"dynamicSize",{get:function(){return this._dynamicSize},set:function(t){t||this._trimAlloc(),this._dynamicSize=t}});f.prototype.shift=function(t){var e=new ArrayBuffer(this._byteLength-t),i=new Uint8Array(e),s=new Uint8Array(this._buffer,t,i.length);i.set(s),this.buffer=e,this.position-=t};f.prototype.writeInt32Array=function(t,e){if(this._realloc(t.length*4),t instanceof Int32Array&&this.byteOffset+this.position%t.BYTES_PER_ELEMENT===0)f.memcpy(this._buffer,this.byteOffset+this.position,t.buffer,0,t.byteLength),this.mapInt32Array(t.length,e);else for(var i=0;i<t.length;i++)this.writeInt32(t[i],e)};f.prototype.writeInt16Array=function(t,e){if(this._realloc(t.length*2),t instanceof Int16Array&&this.byteOffset+this.position%t.BYTES_PER_ELEMENT===0)f.memcpy(this._buffer,this.byteOffset+this.position,t.buffer,0,t.byteLength),this.mapInt16Array(t.length,e);else for(var i=0;i<t.length;i++)this.writeInt16(t[i],e)};f.prototype.writeInt8Array=function(t){if(this._realloc(t.length*1),t instanceof Int8Array&&this.byteOffset+this.position%t.BYTES_PER_ELEMENT===0)f.memcpy(this._buffer,this.byteOffset+this.position,t.buffer,0,t.byteLength),this.mapInt8Array(t.length);else for(var e=0;e<t.length;e++)this.writeInt8(t[e])};f.prototype.writeUint32Array=function(t,e){if(this._realloc(t.length*4),t instanceof Uint32Array&&this.byteOffset+this.position%t.BYTES_PER_ELEMENT===0)f.memcpy(this._buffer,this.byteOffset+this.position,t.buffer,0,t.byteLength),this.mapUint32Array(t.length,e);else for(var i=0;i<t.length;i++)this.writeUint32(t[i],e)};f.prototype.writeUint16Array=function(t,e){if(this._realloc(t.length*2),t instanceof Uint16Array&&this.byteOffset+this.position%t.BYTES_PER_ELEMENT===0)f.memcpy(this._buffer,this.byteOffset+this.position,t.buffer,0,t.byteLength),this.mapUint16Array(t.length,e);else for(var i=0;i<t.length;i++)this.writeUint16(t[i],e)};f.prototype.writeUint8Array=function(t){if(this._realloc(t.length*1),t instanceof Uint8Array&&this.byteOffset+this.position%t.BYTES_PER_ELEMENT===0)f.memcpy(this._buffer,this.byteOffset+this.position,t.buffer,0,t.byteLength),this.mapUint8Array(t.length);else for(var e=0;e<t.length;e++)this.writeUint8(t[e])};f.prototype.writeFloat64Array=function(t,e){if(this._realloc(t.length*8),t instanceof Float64Array&&this.byteOffset+this.position%t.BYTES_PER_ELEMENT===0)f.memcpy(this._buffer,this.byteOffset+this.position,t.buffer,0,t.byteLength),this.mapFloat64Array(t.length,e);else for(var i=0;i<t.length;i++)this.writeFloat64(t[i],e)};f.prototype.writeFloat32Array=function(t,e){if(this._realloc(t.length*4),t instanceof Float32Array&&this.byteOffset+this.position%t.BYTES_PER_ELEMENT===0)f.memcpy(this._buffer,this.byteOffset+this.position,t.buffer,0,t.byteLength),this.mapFloat32Array(t.length,e);else for(var i=0;i<t.length;i++)this.writeFloat32(t[i],e)};f.prototype.writeInt32=function(t,e){this._realloc(4),this._dataView.setInt32(this.position,t,e??this.endianness),this.position+=4};f.prototype.writeInt16=function(t,e){this._realloc(2),this._dataView.setInt16(this.position,t,e??this.endianness),this.position+=2};f.prototype.writeInt8=function(t){this._realloc(1),this._dataView.setInt8(this.position,t),this.position+=1};f.prototype.writeUint32=function(t,e){this._realloc(4),this._dataView.setUint32(this.position,t,e??this.endianness),this.position+=4};f.prototype.writeUint16=function(t,e){this._realloc(2),this._dataView.setUint16(this.position,t,e??this.endianness),this.position+=2};f.prototype.writeUint8=function(t){this._realloc(1),this._dataView.setUint8(this.position,t),this.position+=1};f.prototype.writeFloat32=function(t,e){this._realloc(4),this._dataView.setFloat32(this.position,t,e??this.endianness),this.position+=4};f.prototype.writeFloat64=function(t,e){this._realloc(8),this._dataView.setFloat64(this.position,t,e??this.endianness),this.position+=8};
1f.prototype.writeUCS2String=function(t,e,i){i==null&&(i=t.length);for(var s=0;s<t.length&&s<i;s++)this.writeUint16(t.charCodeAt(s),e);for(;s<i;s++)this.writeUint16(0)};f.prototype.writeString=function(t,e,i){var s=0;if(e==null||e=="ASCII")if(i!=null){var n=Math.min(t.length,i);for(s=0;s<n;s++)this.writeUint8(t.charCodeAt(s));for(;s<i;s++)this.writeUint8(0)}else for(s=0;s<t.length;s++)this.writeUint8(t.charCodeAt(s));else this.writeUint8Array(new TextEncoder(e).encode(t.substring(0,i)))};f.prototype.writeCString=function(t,e){var i=0;if(e!=null){var s=Math.min(t.length,e);for(i=0;i<s;i++)this.writeUint8(t.charCodeAt(i));for(;i<e;i++)this.writeUint8(0)}else{for(i=0;i<t.length;i++)this.writeUint8(t.charCodeAt(i));this.writeUint8(0)}};f.prototype.writeStruct=function(t,e){for(var i=0;i<t.length;i+=2){var s=t[i+1];this.writeType(s,e[t[i]],e)}};f.prototype.writeType=function(t,e,i){var s;if(typeof t=="function")return t(this,e);if(typeof t=="object"&&!(t instanceof Array))return t.set(this,e,i);var n=null,a="ASCII",o=this.position;switch(typeof t=="string"&&/:/.test(t)&&(s=t.split(":"),t=s[0],n=parseInt(s[1])),typeof t=="string"&&/,/.test(t)&&(s=t.split(","),t=s[0],a=parseInt(s[1])),t){case"uint8":this.writeUint8(e);break;case"int8":this.writeInt8(e);break;case"uint16":this.writeUint16(e,this.endianness);break;case"int16":this.writeInt16(e,this.endianness);break;case"uint32":this.writeUint32(e,this.endianness);break;case"int32":this.writeInt32(e,this.endianness);break;case"float32":this.writeFloat32(e,this.endianness);break;case"float64":this.writeFloat64(e,this.endianness);break;case"uint16be":this.writeUint16(e,f.BIG_ENDIAN);break;case"int16be":this.writeInt16(e,f.BIG_ENDIAN);break;case"uint32be":this.writeUint32(e,f.BIG_ENDIAN);break;case"int32be":this.writeInt32(e,f.BIG_ENDIAN);break;case"float32be":this.writeFloat32(e,f.BIG_ENDIAN);break;case"float64be":this.writeFloat64(e,f.BIG_ENDIAN);break;case"uint16le":this.writeUint16(e,f.LITTLE_ENDIAN);break;case"int16le":this.writeInt16(e,f.LITTLE_ENDIAN);break;case"uint32le":this.writeUint32(e,f.LITTLE_ENDIAN);break;case"int32le":this.writeInt32(e,f.LITTLE_ENDIAN);break;case"float32le":this.writeFloat32(e,f.LITTLE_ENDIAN);break;case"float64le":this.writeFloat64(e,f.LITTLE_ENDIAN);break;case"cstring":this.writeCString(e,n);break;case"string":this.writeString(e,a,n);break;case"u16string":this.writeUCS2String(e,this.endianness,n);break;case"u16stringle":this.writeUCS2String(e,f.LITTLE_ENDIAN,n);break;case"u16stringbe":this.writeUCS2String(e,f.BIG_ENDIAN,n);break;default:if(t.length==3){for(var h=t[1],d=0;d<e.length;d++)this.writeType(h,e[d]);break}else{this.writeStruct(t,e);break}}n!=null&&(this.position=o,this._realloc(n),this.position=o+n)};f.prototype.writeUint64=function(t){var e=Math.floor(t/B);this.writeUint32(e),this.writeUint32(t&4294967295)};f.prototype.writeUint24=function(t){this.writeUint8((t&16711680)>>16),this.writeUint8((t&65280)>>8),this.writeUint8(t&255)};f.prototype.adjustUint32=function(t,e){var i=this.position;this.seek(t),this.writeUint32(e),this.seek(i)};f.prototype.mapInt32Array=function(t,e){this._realloc(t*4);var i=new Int32Array(this._buffer,this.byteOffset+this.position,t);return f.arrayToNative(i,e??this.endianness),this.position+=t*4,i};f.prototype.mapInt16Array=function(t,e){this._realloc(t*2);var i=new Int16Array(this._buffer,this.byteOffset+this.position,t);return f.arrayToNative(i,e??this.endianness),this.position+=t*2,i};f.prototype.mapInt8Array=function(t){this._realloc(t*1);var e=new Int8Array(this._buffer,this.byteOffset+this.position,t);return this.position+=t*1,e};f.prototype.mapUint32Array=function(t,e){this._realloc(t*4);var i=new Uint32Array(this._buffer,this.byteOffset+this.position,t);return f.arrayToNative(i,e??this.endianness),this.position+=t*4,i};f.prototype.mapUint16Array=function(t,e){this._realloc(t*2);var i=new Uint16Array(this._buffer,this.byteOffset+this.position,t);return f.arrayToNative(i,e??this.endianness),this.position+=t*2,i};f.prototype.mapFloat64Array=function(t,e){this._realloc(t*8);var i=new Float64Array(this._buffer,this.byteOffset+this.position,t);return f.arrayToNative(i,e??this.endianness),this.position+=t*8,i};f.prototype.mapFloat32Array=function(t,e){this._realloc(t*4);var i=new Float32Array(this._buffer,this.byteOffset+this.position,t);return f.arrayToNative(i,e??this.endianness),this.position+=t*4,i};var b=function(t){this.buffers=[],this.bufferIndex=-1,t&&(this.insertBuffer(t),this.bufferIndex=0)};b.prototype=new f(new ArrayBuffer,0,f.BIG_ENDIAN);b.prototype.initialized=function(){var t;return this.bufferIndex>-1?!0:this.buffers.length>0?(t=this.buffers[0],t.fileStart===0?(this.buffer=t,this.bufferIndex=0,l.debug("MultiBufferStream","Stream ready for parsing"),!0):(l.warn("MultiBufferStream","The first buffer should have a fileStart of 0"),this.logBufferLevel(),!1)):(l.warn("MultiBufferStream","No buffer to start parsing from"),this.logBufferLevel(),!1)};ArrayBuffer.concat=function(t,e){l.debug("ArrayBuffer","Trying to create a new buffer of size: "+(t.byteLength+e.byteLength));var i=new Uint8Array(t.byteLength+e.byteLength);return i.set(new Uint8Array(t),0),i.set(new Uint8Array(e),t.byteLength),i.buffer};
1b.prototype.reduceBuffer=function(t,e,i){var s;return s=new Uint8Array(i),s.set(new Uint8Array(t,e,i)),s.buffer.fileStart=t.fileStart+e,s.buffer.usedBytes=0,s.buffer};b.prototype.insertBuffer=function(t){for(var e=!0,i=0;i<this.buffers.length;i++){var s=this.buffers[i];if(t.fileStart<=s.fileStart){if(t.fileStart===s.fileStart)if(t.byteLength>s.byteLength){this.buffers.splice(i,1),i--;continue}else l.warn("MultiBufferStream","Buffer (fileStart: "+t.fileStart+" - Length: "+t.byteLength+") already appended, ignoring");else t.fileStart+t.byteLength<=s.fileStart||(t=this.reduceBuffer(t,0,s.fileStart-t.fileStart)),l.debug("MultiBufferStream","Appending new buffer (fileStart: "+t.fileStart+" - Length: "+t.byteLength+")"),this.buffers.splice(i,0,t),i===0&&(this.buffer=t);e=!1;break}else if(t.fileStart<s.fileStart+s.byteLength){var n=s.fileStart+s.byteLength-t.fileStart,a=t.byteLength-n;if(a>0)t=this.reduceBuffer(t,n,a);else{e=!1;break}}}e&&(l.debug("MultiBufferStream","Appending new buffer (fileStart: "+t.fileStart+" - Length: "+t.byteLength+")"),this.buffers.push(t),i===0&&(this.buffer=t))};b.prototype.logBufferLevel=function(t){var e,i,s,n,a=[],o,h="";for(s=0,n=0,e=0;e<this.buffers.length;e++)i=this.buffers[e],e===0?(o={},a.push(o),o.start=i.fileStart,o.end=i.fileStart+i.byteLength,h+="["+o.start+"-"):o.end===i.fileStart?o.end=i.fileStart+i.byteLength:(o={},o.start=i.fileStart,h+=a[a.length-1].end-1+"], ["+o.start+"-",o.end=i.fileStart+i.byteLength,a.push(o)),s+=i.usedBytes,n+=i.byteLength;a.length>0&&(h+=o.end-1+"]");var d=t?l.info:l.debug;this.buffers.length===0?d("MultiBufferStream","No more buffer in memory"):d("MultiBufferStream",""+this.buffers.length+" stored buffer(s) ("+s+"/"+n+" bytes), continuous ranges: "+h)};b.prototype.cleanBuffers=function(){var t,e;for(t=0;t<this.buffers.length;t++)e=this.buffers[t],e.usedBytes===e.byteLength&&(l.debug("MultiBufferStream","Removing buffer #"+t),this.buffers.splice(t,1),t--)};b.prototype.mergeNextBuffer=function(){var t;if(this.bufferIndex+1<this.buffers.length)if(t=this.buffers[this.bufferIndex+1],t.fileStart===this.buffer.fileStart+this.buffer.byteLength){var e=this.buffer.byteLength,i=this.buffer.usedBytes,s=this.buffer.fileStart;return this.buffers[this.bufferIndex]=ArrayBuffer.concat(this.buffer,t),this.buffer=this.buffers[this.bufferIndex],this.buffers.splice(this.bufferIndex+1,1),this.buffer.usedBytes=i,this.buffer.fileStart=s,l.debug("ISOFile","Concatenating buffer for box parsing (length: "+e+"->"+this.buffer.byteLength+")"),!0}else return!1;else return!1};b.prototype.findPosition=function(t,e,i){var s,n=null,a=-1;for(t===!0?s=0:s=this.bufferIndex;s<this.buffers.length&&(n=this.buffers[s],n.fileStart<=e);){a=s,i&&(n.fileStart+n.byteLength<=e?n.usedBytes=n.byteLength:n.usedBytes=e-n.fileStart,this.logBufferLevel());s++}return a!==-1?(n=this.buffers[a],n.fileStart+n.byteLength>=e?(l.debug("MultiBufferStream","Found position in existing buffer #"+a),a):-1):-1};b.prototype.findEndContiguousBuf=function(t){var e,i,s,n=t!==void 0?t:this.bufferIndex;if(i=this.buffers[n],this.buffers.length>n+1)for(e=n+1;e<this.buffers.length&&(s=this.buffers[e],s.fileStart===i.fileStart+i.byteLength);e++)i=s;return i.fileStart+i.byteLength};b.prototype.getEndFilePositionAfter=function(t){var e=this.findPosition(!0,t,!1);return e!==-1?this.findEndContiguousBuf(e):t};b.prototype.addUsedBytes=function(t){this.buffer.usedBytes+=t,this.logBufferLevel()};b.prototype.setAllUsedBytes=function(){this.buffer.usedBytes=this.buffer.byteLength,this.logBufferLevel()};b.prototype.seek=function(t,e,i){var s;return s=this.findPosition(e,t,i),s!==-1?(this.buffer=this.buffers[s],this.bufferIndex=s,this.position=t-this.buffer.fileStart,l.debug("MultiBufferStream","Repositioning parser at buffer position: "+this.position),!0):(l.debug("MultiBufferStream","Position "+t+" not found in buffered data"),!1)};b.prototype.getPosition=function(){if(this.bufferIndex===-1||this.buffers[this.bufferIndex]===null)throw"Error accessing position in the MultiBufferStream";return this.buffers[this.bufferIndex].fileStart+this.position};b.prototype.getLength=function(){return this.byteLength};b.prototype.getEndPosition=function(){if(this.bufferIndex===-1||this.buffers[this.bufferIndex]===null)throw"Error accessing position in the MultiBufferStream";return this.buffers[this.bufferIndex].fileStart+this.byteLength};typeof S<"u"&&(S.MultiBufferStream=b);var k=function(){var t=3,e=4,i=5,s=6,n=[];n[t]="ES_Descriptor",n[e]="DecoderConfigDescriptor",n[i]="DecoderSpecificInfo",n[s]="SLConfigDescriptor",this.getDescriptorName=function(h){return n[h]};var a=this,o={};return this.parseOneDescriptor=function(h){var d=0,u=0,p,y,g;for(p=h.readUint8(),d++,g=h.readUint8(),d++;g&128;)u=(g&127)<<7,g=h.readUint8(),d++;return u+=g&127,l.debug("MPEG4DescriptorParser","Found "+(n[p]||"Descriptor "+p)+", size "+u+" at position "+h.getPosition()),n[p]?y=new o[n[p]](u):y=new o.Descriptor(u),y.parse(h),y},o.Descriptor=function(h,d){this.tag=h,this.size=d,this.descs=[]},o.Descriptor.prototype.parse=function(h){this.data=h.readUint8Array(this.size)},o.Descriptor.prototype.findDescriptor=function(h){for(var d=0;d<this.descs.length;d++)if(this.descs[d].tag==h)return this.descs[d];return null},o.Descriptor.prototype.parseRemainingDescriptors=function(h){for(var d=h.position;h.position<d+this.size;){var u=a.parseOneDescriptor(h);this.descs.push(u)}},o.ES_Descriptor=function(h){o.Descriptor.call(this,t,h)},o.ES_Descriptor.prototype=new o.Descriptor,o.ES_Descriptor.prototype.parse=function(h){if(this.ES_ID=h.readUint16(),this.flags=h.readUint8(),this.size-=3,this.flags&128?(this.dependsOn_ES_ID=h.readUint16(),this.size-=2):this.dependsOn_ES_ID=0,this.flags&64){var d=h.readUint8();this.URL=h.readString(d),this.size-=d+1}else this.URL="";this.flags&32?(this.OCR_ES_ID=h.readUint16(),this.size-=2):this.OCR_ES_ID=0,this.parseRemainingDescriptors(h)},o.ES_Descriptor.prototype.getOTI=function(h){var d=this.findDescriptor(e);return d?d.oti:0},o.ES_Descriptor.prototype.getAudioConfig=function(h){var d=this.findDescriptor(e);
1if(!d)return null;var u=d.findDescriptor(i);if(u&&u.data){var p=(u.data[0]&248)>>3;return p===31&&u.data.length>=2&&(p=32+((u.data[0]&7)<<3)+((u.data[1]&224)>>5)),p}else return null},o.DecoderConfigDescriptor=function(h){o.Descriptor.call(this,e,h)},o.DecoderConfigDescriptor.prototype=new o.Descriptor,o.DecoderConfigDescriptor.prototype.parse=function(h){this.oti=h.readUint8(),this.streamType=h.readUint8(),this.bufferSize=h.readUint24(),this.maxBitrate=h.readUint32(),this.avgBitrate=h.readUint32(),this.size-=13,this.parseRemainingDescriptors(h)},o.DecoderSpecificInfo=function(h){o.Descriptor.call(this,i,h)},o.DecoderSpecificInfo.prototype=new o.Descriptor,o.SLConfigDescriptor=function(h){o.Descriptor.call(this,s,h)},o.SLConfigDescriptor.prototype=new o.Descriptor,this};typeof S<"u"&&(S.MPEG4DescriptorParser=k);var r={ERR_INVALID_DATA:-1,ERR_NOT_ENOUGH_DATA:0,OK:1,BASIC_BOXES:["mdat","idat","free","skip","meco","strk"],FULL_BOXES:["hmhd","nmhd","iods","xml ","bxml","ipro","mere"],CONTAINER_BOXES:[["moov",["trak","pssh"]],["trak"],["edts"],["mdia"],["minf"],["dinf"],["stbl",["sgpd","sbgp"]],["mvex",["trex"]],["moof",["traf"]],["traf",["trun","sgpd","sbgp"]],["vttc"],["tref"],["iref"],["mfra",["tfra"]],["meco"],["hnti"],["hinf"],["strk"],["strd"],["sinf"],["rinf"],["schi"],["trgr"],["udta",["kind"]],["iprp",["ipma"]],["ipco"]],boxCodes:[],fullBoxCodes:[],containerBoxCodes:[],sampleEntryCodes:{},sampleGroupEntryCodes:[],trackGroupTypes:[],UUIDBoxes:{},UUIDs:[],initialize:function(){r.FullBox.prototype=new r.Box,r.ContainerBox.prototype=new r.Box,r.SampleEntry.prototype=new r.Box,r.TrackGroupTypeBox.prototype=new r.FullBox,r.BASIC_BOXES.forEach(function(t){r.createBoxCtor(t)}),r.FULL_BOXES.forEach(function(t){r.createFullBoxCtor(t)}),r.CONTAINER_BOXES.forEach(function(t){r.createContainerBoxCtor(t[0],null,t[1])})},Box:function(t,e,i){this.type=t,this.size=e,this.uuid=i},FullBox:function(t,e,i){r.Box.call(this,t,e,i),this.flags=0,this.version=0},ContainerBox:function(t,e,i){r.Box.call(this,t,e,i),this.boxes=[]},SampleEntry:function(t,e,i,s){r.ContainerBox.call(this,t,e),this.hdr_size=i,this.start=s},SampleGroupEntry:function(t){this.grouping_type=t},TrackGroupTypeBox:function(t,e){r.FullBox.call(this,t,e)},createBoxCtor:function(t,e){r.boxCodes.push(t),r[t+"Box"]=function(i){r.Box.call(this,t,i)},r[t+"Box"].prototype=new r.Box,e&&(r[t+"Box"].prototype.parse=e)},createFullBoxCtor:function(t,e){r[t+"Box"]=function(i){r.FullBox.call(this,t,i)},r[t+"Box"].prototype=new r.FullBox,r[t+"Box"].prototype.parse=function(i){this.parseFullHeader(i),e&&e.call(this,i)}},addSubBoxArrays:function(t){if(t){this.subBoxNames=t;for(var e=t.length,i=0;i<e;i++)this[t[i]+"s"]=[]}},createContainerBoxCtor:function(t,e,i){r[t+"Box"]=function(s){r.ContainerBox.call(this,t,s),r.addSubBoxArrays.call(this,i)},r[t+"Box"].prototype=new r.ContainerBox,e&&(r[t+"Box"].prototype.parse=e)},createMediaSampleEntryCtor:function(t,e,i){r.sampleEntryCodes[t]=[],r[t+"SampleEntry"]=function(s,n){r.SampleEntry.call(this,s,n),r.addSubBoxArrays.call(this,i)},r[t+"SampleEntry"].prototype=new r.SampleEntry,e&&(r[t+"SampleEntry"].prototype.parse=e)},createSampleEntryCtor:function(t,e,i,s){r.sampleEntryCodes[t].push(e),r[e+"SampleEntry"]=function(n){r[t+"SampleEntry"].call(this,e,n),r.addSubBoxArrays.call(this,s)},r[e+"SampleEntry"].prototype=new r[t+"SampleEntry"],i&&(r[e+"SampleEntry"].prototype.parse=i)},createEncryptedSampleEntryCtor:function(t,e,i){r.createSampleEntryCtor.call(this,t,e,i,["sinf"])},createSampleGroupCtor:function(t,e){r[t+"SampleGroupEntry"]=function(i){r.SampleGroupEntry.call(this,t,i)},r[t+"SampleGroupEntry"].prototype=new r.SampleGroupEntry,e&&(r[t+"SampleGroupEntry"].prototype.parse=e)},createTrackGroupCtor:function(t,e){r[t+"TrackGroupTypeBox"]=function(i){r.TrackGroupTypeBox.call(this,t,i)},r[t+"TrackGroupTypeBox"].prototype=new r.TrackGroupTypeBox,e&&(r[t+"TrackGroupTypeBox"].prototype.parse=e)},createUUIDBox:function(t,e,i,s){r.UUIDs.push(t),r.UUIDBoxes[t]=function(n){e?r.FullBox.call(this,"uuid",n,t):i?r.ContainerBox.call(this,"uuid",n,t):r.Box.call(this,"uuid",n,t)},r.UUIDBoxes[t].prototype=e?new r.FullBox:i?new r.ContainerBox:new r.Box,s&&(e?r.UUIDBoxes[t].prototype.parse=function(n){this.parseFullHeader(n),s&&s.call(this,n)}:r.UUIDBoxes[t].prototype.parse=s)}};r.initialize();r.TKHD_FLAG_ENABLED=1;r.TKHD_FLAG_IN_MOVIE=2;r.TKHD_FLAG_IN_PREVIEW=4;r.TFHD_FLAG_BASE_DATA_OFFSET=1;r.TFHD_FLAG_SAMPLE_DESC=2;r.TFHD_FLAG_SAMPLE_DUR=8;r.TFHD_FLAG_SAMPLE_SIZE=16;r.TFHD_FLAG_SAMPLE_FLAGS=32;r.TFHD_FLAG_DUR_EMPTY=65536;r.TFHD_FLAG_DEFAULT_BASE_IS_MOOF=131072;r.TRUN_FLAGS_DATA_OFFSET=1;r.TRUN_FLAGS_FIRST_FLAG=4;r.TRUN_FLAGS_DURATION=256;r.TRUN_FLAGS_SIZE=512;r.TRUN_FLAGS_FLAGS=1024;r.TRUN_FLAGS_CTS_OFFSET=2048;r.Box.prototype.add=function(t){return this.addBox(new r[t+"Box"])};r.Box.prototype.addBox=function(t){return this.boxes.push(t),this[t.type+"s"]?this[t.type+"s"].push(t):this[t.type]=t,t};r.Box.prototype.set=function(t,e){return this[t]=e,this};r.Box.prototype.addEntry=function(t,e){var i=e||"entries";return this[i]||(this[i]=[]),this[i].push(t),this};typeof S<"u"&&(S.BoxParser=r);r.parseUUID=function(t){return r.parseHex16(t)};r.parseHex16=function(t){for(var e="",i=0;i<16;i++){var s=t.readUint8().toString(16);e+=s.length===1?"0"+s:s}return e};
1r.parseOneBox=function(t,e,i){var s,n=t.getPosition(),a=0,o,h;if(t.getEndPosition()-n<8)return l.debug("BoxParser","Not enough data in stream to parse the type and size of the box"),{code:r.ERR_NOT_ENOUGH_DATA};if(i&&i<8)return l.debug("BoxParser","Not enough bytes left in the parent box to parse a new box"),{code:r.ERR_NOT_ENOUGH_DATA};var d=t.readUint32(),u=t.readString(4),p=u;if(l.debug("BoxParser","Found box of type '"+u+"' and size "+d+" at position "+n),a=8,u=="uuid"){if(t.getEndPosition()-t.getPosition()<16||i-a<16)return t.seek(n),l.debug("BoxParser","Not enough bytes left in the parent box to parse a UUID box"),{code:r.ERR_NOT_ENOUGH_DATA};h=r.parseUUID(t),a+=16,p=h}if(d==1){if(t.getEndPosition()-t.getPosition()<8||i&&i-a<8)return t.seek(n),l.warn("BoxParser",'Not enough data in stream to parse the extended size of the "'+u+'" box'),{code:r.ERR_NOT_ENOUGH_DATA};d=t.readUint64(),a+=8}else if(d===0){if(i)d=i;else if(u!=="mdat")return l.error("BoxParser","Unlimited box size not supported for type: '"+u+"'"),s=new r.Box(u,d),{code:r.OK,box:s,size:s.size}}return d!==0&&d<a?(l.error("BoxParser","Box of type "+u+" has an invalid size "+d+" (too small to be a box)"),{code:r.ERR_NOT_ENOUGH_DATA,type:u,size:d,hdr_size:a,start:n}):d!==0&&i&&d>i?(l.error("BoxParser","Box of type '"+u+"' has a size "+d+" greater than its container size "+i),{code:r.ERR_NOT_ENOUGH_DATA,type:u,size:d,hdr_size:a,start:n}):d!==0&&n+d>t.getEndPosition()?(t.seek(n),l.info("BoxParser","Not enough data in stream to parse the entire '"+u+"' box"),{code:r.ERR_NOT_ENOUGH_DATA,type:u,size:d,hdr_size:a,start:n}):e?{code:r.OK,type:u,size:d,hdr_size:a,start:n}:(r[u+"Box"]?s=new r[u+"Box"](d):u!=="uuid"?(l.warn("BoxParser","Unknown box type: '"+u+"'"),s=new r.Box(u,d),s.has_unparsed_data=!0):r.UUIDBoxes[h]?s=new r.UUIDBoxes[h](d):(l.warn("BoxParser","Unknown uuid type: '"+h+"'"),s=new r.Box(u,d),s.uuid=h,s.has_unparsed_data=!0),s.hdr_size=a,s.start=n,s.write===r.Box.prototype.write&&s.type!=="mdat"&&(l.info("BoxParser","'"+p+"' box writing not yet implemented, keeping unparsed data in memory for later write"),s.parseDataAndRewind(t)),s.parse(t),o=t.getPosition()-(s.start+s.size),o<0?(l.warn("BoxParser","Parsing of box '"+p+"' did not read the entire indicated box data size (missing "+-o+" bytes), seeking forward"),t.seek(s.start+s.size)):o>0&&(l.error("BoxParser","Parsing of box '"+p+"' read "+o+" more bytes than the indicated box data size, seeking backwards"),s.size!==0&&t.seek(s.start+s.size)),{code:r.OK,box:s,size:s.size})};r.Box.prototype.parse=function(t){this.type!="mdat"?this.data=t.readUint8Array(this.size-this.hdr_size):this.size===0?t.seek(t.getEndPosition()):t.seek(this.start+this.size)};r.Box.prototype.parseDataAndRewind=function(t){this.data=t.readUint8Array(this.size-this.hdr_size),t.position-=this.size-this.hdr_size};r.FullBox.prototype.parseDataAndRewind=function(t){this.parseFullHeader(t),this.data=t.readUint8Array(this.size-this.hdr_size),this.hdr_size-=4,t.position-=this.size-this.hdr_size};r.FullBox.prototype.parseFullHeader=function(t){this.version=t.readUint8(),this.flags=t.readUint24(),this.hdr_size+=4};r.FullBox.prototype.parse=function(t){this.parseFullHeader(t),this.data=t.readUint8Array(this.size-this.hdr_size)};r.ContainerBox.prototype.parse=function(t){for(var e,i;t.getPosition()<this.start+this.size;)if(e=r.parseOneBox(t,!1,this.size-(t.getPosition()-this.start)),e.code===r.OK)if(i=e.box,this.boxes.push(i),this.subBoxNames&&this.subBoxNames.indexOf(i.type)!=-1)this[this.subBoxNames[this.subBoxNames.indexOf(i.type)]+"s"].push(i);else{var s=i.type!=="uuid"?i.type:i.uuid;this[s]?l.warn("Box of type "+s+" already stored in field of this type"):this[s]=i}else return};r.Box.prototype.parseLanguage=function(t){this.language=t.readUint16();var 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)};r.SAMPLE_ENTRY_TYPE_VISUAL="Visual";r.SAMPLE_ENTRY_TYPE_AUDIO="Audio";r.SAMPLE_ENTRY_TYPE_HINT="Hint";r.SAMPLE_ENTRY_TYPE_METADATA="Metadata";r.SAMPLE_ENTRY_TYPE_SUBTITLE="Subtitle";r.SAMPLE_ENTRY_TYPE_SYSTEM="System";r.SAMPLE_ENTRY_TYPE_TEXT="Text";r.SampleEntry.prototype.parseHeader=function(t){t.readUint8Array(6),this.data_reference_index=t.readUint16(),this.hdr_size+=8};r.SampleEntry.prototype.parse=function(t){this.parseHeader(t),this.data=t.readUint8Array(this.size-this.hdr_size)};r.SampleEntry.prototype.parseDataAndRewind=function(t){this.parseHeader(t),this.data=t.readUint8Array(this.size-this.hdr_size),this.hdr_size-=8,t.position-=this.size-this.hdr_size};r.SampleEntry.prototype.parseFooter=function(t){r.ContainerBox.prototype.parse.call(this,t)};r.createMediaSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_HINT);r.createMediaSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_METADATA);r.createMediaSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_SUBTITLE);r.createMediaSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_SYSTEM);r.createMediaSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_TEXT);r.createMediaSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_VISUAL,function(t){var e;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(),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)});r.createMediaSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_AUDIO,function(t){this.parseHeader(t),t.readUint32Array(2),this.channel_c
1ount=t.readUint16(),this.samplesize=t.readUint16(),t.readUint16(),t.readUint16(),this.samplerate=t.readUint32()/65536,this.parseFooter(t)});r.createSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_VISUAL,"avc1");r.createSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_VISUAL,"avc2");r.createSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_VISUAL,"avc3");r.createSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_VISUAL,"avc4");r.createSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_VISUAL,"av01");r.createSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_VISUAL,"hvc1");r.createSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_VISUAL,"hev1");r.createSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_VISUAL,"vvc1");r.createSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_VISUAL,"vvi1");r.createSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_VISUAL,"vvs1");r.createSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_VISUAL,"vvcN");r.createSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_VISUAL,"vp08");r.createSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_VISUAL,"vp09");r.createSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_AUDIO,"mp4a");r.createSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_AUDIO,"ac-3");r.createSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_AUDIO,"ec-3");r.createSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_AUDIO,"Opus");r.createEncryptedSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_VISUAL,"encv");r.createEncryptedSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_AUDIO,"enca");r.createEncryptedSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_SUBTITLE,"encu");r.createEncryptedSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_SYSTEM,"encs");r.createEncryptedSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_TEXT,"enct");r.createEncryptedSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_METADATA,"encm");r.createBoxCtor("a1lx",function(t){var e=t.readUint8()&1,i=((e&1)+1)*16;this.layer_size=[];for(var s=0;s<3;s++)i==16?this.layer_size[s]=t.readUint16():this.layer_size[s]=t.readUint32()});r.createBoxCtor("a1op",function(t){this.op_index=t.readUint8()});r.createFullBoxCtor("auxC",function(t){this.aux_type=t.readCString();var e=this.size-this.hdr_size-(this.aux_type.length+1);this.aux_subtype=t.readUint8Array(e)});r.createBoxCtor("av1C",function(t){var e,i,s=t.readUint8();if(s>>7&!1){l.error("av1C marker problem");return}if(this.version=s&127,this.version!==1){l.error("av1C version "+this.version+" not supported");return}if(s=t.readUint8(),this.seq_profile=s>>5&7,this.seq_level_idx_0=s&31,s=t.readUint8(),this.seq_tier_0=s>>7&1,this.high_bitdepth=s>>6&1,this.twelve_bit=s>>5&1,this.monochrome=s>>4&1,this.chroma_subsampling_x=s>>3&1,this.chroma_subsampling_y=s>>2&1,this.chroma_sample_position=s&3,s=t.readUint8(),this.reserved_1=s>>5&7,this.reserved_1!==0){l.error("av1C reserved_1 parsing problem");return}if(this.initial_presentation_delay_present=s>>4&1,this.initial_presentation_delay_present===1)this.initial_presentation_delay_minus_one=s&15;else if(this.reserved_2=s&15,this.reserved_2!==0){l.error("av1C reserved_2 parsing problem");return}var n=this.size-this.hdr_size-4;this.configOBUs=t.readUint8Array(n)});r.createBoxCtor("avcC",function(t){var e,i;for(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,i=this.size-this.hdr_size-6,this.SPS=[],e=0;e<this.nb_SPS_nalus;e++)this.SPS[e]={},this.SPS[e].length=t.readUint16(),this.SPS[e].nalu=t.readUint8Array(this.SPS[e].length),i-=2+this.SPS[e].length;for(this.nb_PPS_nalus=t.readUint8(),i--,this.PPS=[],e=0;e<this.nb_PPS_nalus;e++)this.PPS[e]={},this.PPS[e].length=t.readUint16(),this.PPS[e].nalu=t.readUint8Array(this.PPS[e].length),i-=2+this.PPS[e].length;i>0&&(this.ext=t.readUint8Array(i))});r.createBoxCtor("btrt",function(t){this.bufferSizeDB=t.readUint32(),this.maxBitrate=t.readUint32(),this.avgBitrate=t.readUint32()});r.createBoxCtor("clap",function(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()});r.createBoxCtor("clli",function(t){this.max_content_light_level=t.readUint16(),this.max_pic_average_light_level=t.readUint16()});r.createFullBoxCtor("co64",function(t){var e,i;if(e=t.readUint32(),this.chunk_offsets=[],this.version===0)for(i=0;i<e;i++)this.chunk_offsets.push(t.readUint64())});r.createFullBoxCtor("CoLL",function(t){this.maxCLL=t.readUint16(),this.maxFALL=t.readUint16()});r.createBoxCtor("colr",function(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();var e=t.readUint8();this.full_range_flag=e>>7}else this.colour_type==="rICC"?this.ICC_profile=t.readUint8Array(this.size-4):this.colour_type==="prof"&&(this.ICC_profile=t.readUint8Array(this.size-4))});r.createFullBoxCtor("cprt",function(t){this.parseLanguage(t),this.notice=t.readCString()});r.createFullBoxCtor("cslg",function(t){var e;this.version===0&&(this.compositionToDTSShift=t.readInt32(),this.leastDecodeToDisplayDelta=t.readInt32(),this.greatestDecodeToDisplayDelta=t.readInt32(),this.compositionStartTime=t.readInt32(),this.compositionEndTime=t.readInt32())});r.createFullBoxCtor("ctts",function(t){var e,i;if(e=t.readUint32(),this.sample_counts=[],this.sample_offsets=[],this.version===0)for(i=0;i<e;i++){this.sample_counts.push(t.readUint32());var s=t.readInt32();s<0&&l.warn("BoxParser","ctts box uses negative values without using version 1"),this.sample_offsets.push(s)}else if(this.version==1)for(i=0;i<e;i++)this.sample_counts.push(t.readUint32()),this.sample_offsets.push(t.readInt32())});r.createBoxCtor("dac3",function(t){var e=t.readUint8(),i=t.readUint8(),s=t.readUint8();this.fscod=e>>6,this.bsid=e>>1&31,this.bsmod=(e&1)<<2|i>>6&3,this.acmod=i>>3&7,this.lfeon=i>>2&1,this.bit_rate_code=i&3|s>>5&7});r.createBoxCtor("dec3",function(t){var e=t.readUint16();this.data_rate=e>>3,this.num_ind_sub=e&7,this.ind_subs=[];for(var i=0;i<this.num_ind_sub+1;i++){var s={};this.ind_subs.push(s);var n=t.readUint8(),a=t.readUint8(),o=t.readUint8();s.fscod=n>>6,s.bsid=n>>1&31,s.bsmod=(n&1)<<4|a>>4&15,s.acmod=a>>1&7,s.lfeon=a&1,s.num_dep_sub=o>>1&15,s.num_dep_sub>0&&(s.chan_loc=(o&1)<<8|t.readUint8())}});r.createFullBoxCtor("dfLa",function(t){var e=127,i=128,s=[],n=["STREAMINFO","PADDING","APPLICATION","SEEKTABLE","VORBIS_COMMENT","CUESHEET","PICTURE","RESERVED"];this.parseFullHeader(t);do{var a=t.readUint8(),o=Math.min(a&e,n.length-1);if(o?t.readUint8Array(t.readUint24()):(t.readUint8Array(13),this.samplerate=t.readUint32()>>12,t.readUint8Array(20)),s.push(n[o]),a&i)break}while(!0);this.numMetadataBlocks=s.length+" ("+s.join(", ")+")"});r.createBoxCtor("dimm",function(t){this.bytessent=t.readUint64()});r.createBoxCtor("dmax",function(t){this.time=t.readUint32()});r.createBoxCtor("dmed",function(t){this.bytessent=t.readUint64()});r.createBoxCtor("dOps",function(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(var e=0;e<this.OutputChannelCount;e++)this.ChannelMapping[e]=t.readUint8()}});r.createFullBoxCtor("dref",function(t){var e,i;this.entries=[];for(var s=t.readUint32(),n=0;n<s;n++)if(e=r.parseOneBox(t,!1,this.size-(t.getPosition()-this.start)),e.code===r.OK)i=e.box,this.entries.push(i);else return});r.createBoxCtor("drep",function(t){this.bytessent=t.readUint64()});r.createFullBoxCtor("elng",function(t){this.extended_language=t.readString(this.size-this.hdr_size)});r.createFullBoxCtor("elst",function(t){this.entries=[];for(var e=t.readUint32(),i=0;i<e;i++){var s={};this.entries.push(s),this.version===1?(s.segment_duration=t.readUint64(),s.media_time=t.readInt64()):(s.segment_duration=t.readUint32(),s.media_time=t.readInt32()),s.media_rate_integer=t.readInt16(),s.media_rate_fraction=t.readInt16()}});r.createFullBoxCtor("emsg",function(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());var e=this.size-this.hdr_size-(4*4+(this.scheme_id_uri.length+1)+(this.value.length+1));this.version==1&&(e-=4),this.message_data=t.readUint8Array(e)});r.createFullBoxCtor("esds",function(t){var e=t.readUint8Array(this.size-this.hdr_size);if(typeof k<"u"){var i=new k;this.esd=i.parseOneDescriptor(new f(e.buffer,0,f.BIG_ENDIAN))}});r.createBoxCtor("fiel",function(t){this.fieldCount=t.readUint8(),this.fieldOrdering=t.readUint8()});r.createBoxCtor("frma",function(t){this.data_format=t.readString(4)});r.createBoxCtor("ftyp",function(t){var e=this.size-this.hdr_size;this.major_brand=t.readString(4),this.minor_version=t.readUint32(),e-=8,this.compatible_brands=[];for(var i=0;e>=4;)this.compatible_brands[i]=t.readString(4),e-=4,i++});r.createFullBoxCtor("hdlr",function(t){this.version===0&&(t.readUint32(),this.handler=t.readString(4),t.readUint32Array(3),this.name=t.readString(this.size-this.hdr_size-20),this.name[this.name.length-1]==="\0"&&(this.name=this.name.slice(0,-1)))});r.createBoxCtor("hvcC",function(t){var e,i,s,n,a;this.configurationVersion=t.readUint8(),a=t.readUint8(),this.general_profile_space
1=a>>6,this.general_tier_flag=(a&32)>>5,this.general_profile_idc=a&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(),a=t.readUint8(),this.constantFrameRate=a>>6,this.numTemporalLayers=(a&13)>>3,this.temporalIdNested=(a&4)>>2,this.lengthSizeMinusOne=a&3,this.nalu_arrays=[];var o=t.readUint8();for(e=0;e<o;e++){var h=[];this.nalu_arrays.push(h),a=t.readUint8(),h.completeness=(a&128)>>7,h.nalu_type=a&63;var d=t.readUint16();for(i=0;i<d;i++){var u={};h.push(u),n=t.readUint16(),u.data=t.readUint8Array(n)}}});r.createFullBoxCtor("iinf",function(t){var e;this.version===0?this.entry_count=t.readUint16():this.entry_count=t.readUint32(),this.item_infos=[];for(var i=0;i<this.entry_count;i++)if(e=r.parseOneBox(t,!1,this.size-(t.getPosition()-this.start)),e.code===r.OK)e.box.type!=="infe"&&l.error("BoxParser","Expected 'infe' box, got "+e.box.type),this.item_infos[i]=e.box;else return});r.createFullBoxCtor("iloc",function(t){var 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.version===1||this.version===2?this.index_size=e&15:this.index_size=0,this.items=[];var i=0;if(this.version<2)i=t.readUint16();else if(this.version===2)i=t.readUint32();else throw"version of iloc box not supported";for(var s=0;s<i;s++){var n={};if(this.items.push(n),this.version<2)n.item_ID=t.readUint16();else if(this.version===2)n.item_ID=t.readUint16();else throw"version of iloc box not supported";switch(this.version===1||this.version===2?n.construction_method=t.readUint16()&15:n.construction_method=0,n.data_reference_index=t.readUint16(),this.base_offset_size){case 0:n.base_offset=0;break;case 4:n.base_offset=t.readUint32();break;case 8:n.base_offset=t.readUint64();break;default:throw"Error reading base offset size"}var a=t.readUint16();n.extents=[];for(var o=0;o<a;o++){var h={};if(n.extents.push(h),this.version===1||this.version===2)switch(this.index_size){case 0:h.extent_index=0;break;case 4:h.extent_index=t.readUint32();break;case 8:h.extent_index=t.readUint64();break;default:throw"Error reading extent index"}switch(this.offset_size){case 0:h.extent_offset=0;break;case 4:h.extent_offset=t.readUint32();break;case 8:h.extent_offset=t.readUint64();break;default:throw"Error reading extent index"}switch(this.length_size){case 0:h.extent_length=0;break;case 4:h.extent_length=t.readUint32();break;case 8:h.extent_length=t.readUint64();break;default:throw"Error reading extent index"}}}});r.createBoxCtor("imir",function(t){var e=t.readUint8();this.reserved=e>>7,this.axis=e&1});r.createFullBoxCtor("infe",function(t){if((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.content_encoding=t.readCString()),this.version===1){this.extension_type=t.readString(4),l.warn("BoxParser","Cannot parse extension type"),t.seek(this.start+this.size);return}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()))});r.createFullBoxCtor("ipma",function(t){var e,i;for(entry_count=t.readUint32(),this.associations=[],e=0;e<entry_count;e++){var s={};this.associations.push(s),this.version<1?s.id=t.readUint16():s.id=t.readUint32();var n=t.readUint8();for(s.props=[],i=0;i<n;i++){var a=t.readUint8(),o={};s.props.push(o),o.essential=(a&128)>>7===1,this.flags&1?o.property_index=(a&127)<<8|t.readUint8():o.property_index=a&127}}});r.createFullBoxCtor("iref",function(t){var e,i,s;for(this.references=[];t.getPosition()<this.start+this.size;)if(e=r.parseOneBox(t,!0,this.size-(t.getPosition()-this.start)),e.code===r.OK)this.version===0?s=new r.SingleItemTypeReferenceBox(e.type,e.size,e.hdr_size,e.start):s=new r.SingleItemTypeReferenceBoxLarge(e.type,e.size,e.hdr_size,e.start),s.write===r.Box.prototype.write&&s.type!=="mdat"&&(l.warn("BoxParser",s.type+" box writing not yet implemented, keeping unparsed data in memory for later write"),s.parseDataAndRewind(t)),s.parse(t),this.references.push(s);else return});r.createBoxCtor("irot",function(t){this.angle=t.readUint8()&3});r.createFullBoxCtor("ispe",function(t){this.image_width=t.readUint32(),this.image_height=t.readUint32()});r.createFullBoxCtor("kind",function(t){this.schemeURI=t.readCString(),this.value=t.readCString()});r.createFullBoxCtor("leva",function(t){var e=t.readUint8();this.levels=[];for(var i=0;i<e;i++){var s={};this.levels[i]=s,s.track_ID=t.readUint32();var n=t.readUint8();switch(s.padding_flag=n>>7,s.assignment_type=n&127,s.assignment_type){case 0:s.grouping_type=t.readString(4);break;case 1:s.grouping_type=t.readString(4),s.grouping_type_parameter=t.readUint32();break;case 2:break;case 3:break;case 4:s.sub_track_id=t.readUint32();break;default:l.warn("BoxParser","Unknown leva assignement type")}}});r.createBoxCtor("lsel",function(t){this.layer_id=t.readUint16()});r.createBoxCtor("maxr",function(t){this.period=t.readUint32(),this.bytes=t.readUint32()});r.createBoxCtor("mdcv",function(t){this.display_primaries=[],this.display_primaries[0]={},this.display_primaries[0].x=t.readUint16(),this.display_primaries[0].y=t.readUint16(),this.display_primaries[1]={},this.display_primaries[1].x=t.readUint16(),this.display_primaries[1].y=t.readUint16(),this.display_primaries[2]={},this.display_primaries[2].x=t.readUint16(),this.display_primaries[2].y=t.readUint16(),this.white_point={},this.white_point.x=t.readUint16(),this.white_point.y=t.readUint16(),this.max_display_mastering_luminance=t.readUint32(),this.min_display_mastering_luminance=t.readUint32()});r.createFullBoxCtor("mdhd",function(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()});r.createFullBoxCtor("mehd",function(t){this.flags&1&&(l.warn("BoxParser","mehd box incorrectly uses flags set to 1, converting version to 1"),this.version=1),this.version==1?this.fragment_duration=t.readUint64():this.fragment_duration=t.readUint32()});r.createFullBoxCtor("meta",function(t){this.boxes=[],r.ContainerBox.prototype.parse.call(this,t)});r.createFullBoxCtor("mfhd",function(t){this.sequence_number=t.readUint32()});r.createFullBoxCtor("mfro",function(t){this._size=t.readUint32()});r.createFullBoxCtor("mvhd",function(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.readUint32Array(9),t.readUint32Array(6),this.next_track_id=t.readUint32()});r.createBoxCtor("npck",function(t){this.packetssent=t.readUint32()});r.createBoxCtor("nump",function(t){this.packetssent=t.readUint64()});r.createFullBoxCtor("padb",function(t){var e=t.readUint32();this.padbits=[];for(var i=0;i<Math.floor((e+1)/2);i++)this.padbits=t.readUint8()});r.createBoxCtor("pasp",function(t){this.hSpacing=t.readUint32(),this.vSpacing=t.readUint32()});r.createBoxCtor("payl",function(t){this.text=t.readString(this.size-this.hdr_size)});r.createBoxCtor("payt",function(t){this.payloadID=t.readUint32();var e=t.readUint8();this.rtpmap_string=t.readString(e)});r.createFullBoxCtor("pdin",function(t){var e=(this.size-this.hdr_size)/8;this.rate=[],this.initial_delay=[];for(var i=0;i<e;i++)this.rate[i]=t.readUint32(),this.initial_delay[i]=t.readUint32()});r.createFullBoxCtor("pitm",function(t){this.version===0?this.item_id=t.readUint16():this.item_id=t.readUint32()});r.createFullBoxCtor("pixi",function(t){var e;
1for(this.num_channels=t.readUint8(),this.bits_per_channels=[],e=0;e<this.num_channels;e++)this.bits_per_channels[e]=t.readUint8()});r.createBoxCtor("pmax",function(t){this.bytes=t.readUint32()});r.createFullBoxCtor("prft",function(t){this.ref_track_id=t.readUint32(),this.ntp_timestamp=t.readUint64(),this.version===0?this.media_time=t.readUint32():this.media_time=t.readUint64()});r.createFullBoxCtor("pssh",function(t){if(this.system_id=r.parseHex16(t),this.version>0){var e=t.readUint32();this.kid=[];for(var i=0;i<e;i++)this.kid[i]=r.parseHex16(t)}var s=t.readUint32();s>0&&(this.data=t.readUint8Array(s))});r.createFullBoxCtor("clef",function(t){this.width=t.readUint32(),this.height=t.readUint32()});r.createFullBoxCtor("enof",function(t){this.width=t.readUint32(),this.height=t.readUint32()});r.createFullBoxCtor("prof",function(t){this.width=t.readUint32(),this.height=t.readUint32()});r.createContainerBoxCtor("tapt",null,["clef","prof","enof"]);r.createBoxCtor("rtp ",function(t){this.descriptionformat=t.readString(4),this.sdptext=t.readString(this.size-this.hdr_size-4)});r.createFullBoxCtor("saio",function(t){this.flags&1&&(this.aux_info_type=t.readUint32(),this.aux_info_type_parameter=t.readUint32());var e=t.readUint32();this.offset=[];for(var i=0;i<e;i++)this.version===0?this.offset[i]=t.readUint32():this.offset[i]=t.readUint64()});r.createFullBoxCtor("saiz",function(t){this.flags&1&&(this.aux_info_type=t.readUint32(),this.aux_info_type_parameter=t.readUint32()),this.default_sample_info_size=t.readUint8();var e=t.readUint32();if(this.sample_info_size=[],this.default_sample_info_size===0)for(var i=0;i<e;i++)this.sample_info_size[i]=t.readUint8()});r.createSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_METADATA,"mett",function(t){this.parseHeader(t),this.content_encoding=t.readCString(),this.mime_format=t.readCString(),this.parseFooter(t)});r.createSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_METADATA,"metx",function(t){this.parseHeader(t),this.content_encoding=t.readCString(),this.namespace=t.readCString(),this.schema_location=t.readCString(),this.parseFooter(t)});r.createSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_SUBTITLE,"sbtt",function(t){this.parseHeader(t),this.content_encoding=t.readCString(),this.mime_format=t.readCString(),this.parseFooter(t)});r.createSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_SUBTITLE,"stpp",function(t){this.parseHeader(t),this.namespace=t.readCString(),this.schema_location=t.readCString(),this.auxiliary_mime_types=t.readCString(),this.parseFooter(t)});r.createSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_SUBTITLE,"stxt",function(t){this.parseHeader(t),this.content_encoding=t.readCString(),this.mime_format=t.readCString(),this.parseFooter(t)});r.createSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_SUBTITLE,"tx3g",function(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)});r.createSampleEntryCtor(r.SAMPLE_ENTRY_TYPE_METADATA,"wvtt",function(t){this.parseHeader(t),this.parseFooter(t)});r.createSampleGroupCtor("alst",function(t){var e,i=t.readUint16();for(this.first_output_sample=t.readUint16(),this.sample_offset=[],e=0;e<i;e++)this.sample_offset[e]=t.readUint32();var s=this.description_length-4-4*i;for(this.num_output_samples=[],this.num_total_samples=[],e=0;e<s/4;e++)this.num_output_samples[e]=t.readUint16(),this.num_total_samples[e]=t.readUint16()});r.createSampleGroupCtor("avll",function(t){this.layerNumber=t.readUint8(),this.accurateStatisticsFlag=t.readUint8(),this.avgBitRate=t.readUint16(),this.avgFrameRate=t.readUint16()});r.createSampleGroupCtor("avss",function(t){this.subSequenceIdentifier=t.readUint16(),this.layerNumber=t.readUint8();var 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=[];for(var i=t.readUint8(),s=0;s<i;s++){var n={};this.dependency.push(n),n.subSeqDirectionFlag=t.readUint8(),n.layerNumber=t.readUint8(),n.subSequenceIdentifier=t.readUint16()}});r.createSampleGroupCtor("dtrt",function(t){l.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")});r.createSampleGroupCtor("mvif",function(t){l.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")});r.createSampleGroupCtor("prol",function(t){this.roll_distance=t.readInt16()});r.createSampleGroupCtor("rap ",function(t){var e=t.readUint8();this.num_leading_samples_known=e>>7,this.num_leading_samples=e&127});r.createSampleGroupCtor("rash",function(t){if(this.operation_point_count=t.readUint16(),this.description_length!==2+(this.operation_point_count===1?2:this.operation_point_count*6)+9)l.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(var 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()}});r.createSampleGroupCtor("roll",function(t){this.roll_distance=t.readInt16()});r.SampleGroupEntry.prototype.parse=function(t){l.warn("BoxParser","Unknown Sample Group type: "+this.grouping_type),this.data=t.readUint8Array(this.description_length)};r.createSampleGroupCtor("scif",function(t){l.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")});r.createSampleGroupCtor("scnm",function(t){l.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")});r.createSampleGroupCtor("seig",function(t){this.reserved=t.readUint8();var 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=r.parseHex16(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))});r.createSampleGroupCtor("stsa",function(t){l.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")});r.createSampleGroupCtor("sync",function(t){var e=t.readUint8();this.NAL_unit_type=e&63});r.createSampleGroupCtor("tele",function(t){var e=t.readUint8();this.level_independently_decodable=e>>7});r.createSampleGroupCtor("tsas",function(t){l.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")});r.createSampleGroupCtor("tscl",function(t){l.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")});r.createSampleGroupCtor("vipr",function(t){l.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")});r.createFullBoxCtor("sbgp",function(t){this.grouping_type=t.readString(4),this.version===1?this.grouping_type_parameter=t.readUint32():this.grouping_type_parameter=0,this.entries=[];for(var e=t.readUint32(),i=0;i<e;i++){var s={};this.entries.push(s),s.sample_count=t.readInt32(),s.group_description_index=t.readInt32()}});r.createFullBoxCtor("schm",function(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))});r.createBoxCtor("sdp ",function(t){this.sdptext=t.readString(this.size-this.hdr_size)});r.createFullBoxCtor("sdtp",function(t){var e,i=this.size-this.hdr_size;this.is_leading=[],this.sample_depends_on=[],this.sample_is_depended_on=[],this.sample_has_redundancy=[];for(var s=0;s<i;s++)e=t.readUint8(),this.is_leading[s]=e>>6,this.sample_depends_on[s]=e>>4&3,this.sample_is_depended_on[s]=e>>2&3,this.sample_has_redundancy[s]=e&3});r.createFullBoxCtor("senc");r.createFullBoxCtor("sgpd",function(t){this.grouping_type=t.readString(4),l.debug("BoxParser","Found Sample Groups of type "+this.grouping_type),this.version===1?this.default_length=t.readUint32():this.default_length=0,this.version>=2&&(this.default_group_description_index=t.readUint32()),this.entries=[];for(var e=t.readUint32(),i=0;i<e;i++){var s;r[this.grouping_type+"SampleGroupEntry"]?s=new r[this.grouping_type+"SampleGroupEntry"](this.grouping_type):s=new r.SampleGroupEntry(this.grouping_type),this.entries.push(s),this.version===1?this.default_length===0?s.description_length=t.readUint32():s.description_length=this.default_length:s.description_length=this.default_length,s.write===r.SampleGroupEntry.prototype.write&&(l.info("BoxParser","SampleGroup for type "+this.grouping_type+" writing not yet implemented, keeping unparsed data in memory for later write"),s.data=t.readUint8Array(s.description_length),t.position-=s.description_length),s.parse(t)}});r.createFullBoxCtor("sidx",function(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=[];for(var e=t.readUint16(),i=0;i<e;i++){var s={};this.references.push(s);var n=t.readUint32();s.reference_type=n>>31&1,s.referenced_size=n&2147483647,s.subsegment_duration=t.readUint32(),n=t.readUint32(),s.starts_with_SAP=n>>31&1,s.SAP_type=n>>28&7,s.SAP_delta_time=n&268435455}});
1r.SingleItemTypeReferenceBox=function(t,e,i,s){r.Box.call(this,t,e),this.hdr_size=i,this.start=s};r.SingleItemTypeReferenceBox.prototype=new r.Box;r.SingleItemTypeReferenceBox.prototype.parse=function(t){this.from_item_ID=t.readUint16();var e=t.readUint16();this.references=[];for(var i=0;i<e;i++)this.references[i]=t.readUint16()};r.SingleItemTypeReferenceBoxLarge=function(t,e,i,s){r.Box.call(this,t,e),this.hdr_size=i,this.start=s};r.SingleItemTypeReferenceBoxLarge.prototype=new r.Box;r.SingleItemTypeReferenceBoxLarge.prototype.parse=function(t){this.from_item_ID=t.readUint32();var e=t.readUint16();this.references=[];for(var i=0;i<e;i++)this.references[i]=t.readUint32()};r.createFullBoxCtor("SmDm",function(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()});r.createFullBoxCtor("smhd",function(t){this.balance=t.readUint16(),t.readUint16()});r.createFullBoxCtor("ssix",function(t){this.subsegments=[];for(var e=t.readUint32(),i=0;i<e;i++){var s={};this.subsegments.push(s),s.ranges=[];for(var n=t.readUint32(),a=0;a<n;a++){var o={};s.ranges.push(o),o.level=t.readUint8(),o.range_size=t.readUint24()}}});r.createFullBoxCtor("stco",function(t){var e;if(e=t.readUint32(),this.chunk_offsets=[],this.version===0)for(var i=0;i<e;i++)this.chunk_offsets.push(t.readUint32())});r.createFullBoxCtor("stdp",function(t){var e=(this.size-this.hdr_size)/2;this.priority=[];for(var i=0;i<e;i++)this.priority[i]=t.readUint16()});r.createFullBoxCtor("sthd");r.createFullBoxCtor("stri",function(t){this.switch_group=t.readUint16(),this.alternate_group=t.readUint16(),this.sub_track_id=t.readUint32();var e=(this.size-this.hdr_size-8)/4;this.attribute_list=[];for(var i=0;i<e;i++)this.attribute_list[i]=t.readUint32()});r.createFullBoxCtor("stsc",function(t){var e,i;if(e=t.readUint32(),this.first_chunk=[],this.samples_per_chunk=[],this.sample_description_index=[],this.version===0)for(i=0;i<e;i++)this.first_chunk.push(t.readUint32()),this.samples_per_chunk.push(t.readUint32()),this.sample_description_index.push(t.readUint32())});r.createFullBoxCtor("stsd",function(t){var e,i,s,n;for(this.entries=[],s=t.readUint32(),e=1;e<=s;e++)if(i=r.parseOneBox(t,!0,this.size-(t.getPosition()-this.start)),i.code===r.OK)r[i.type+"SampleEntry"]?(n=new r[i.type+"SampleEntry"](i.size),n.hdr_size=i.hdr_size,n.start=i.start):(l.warn("BoxParser","Unknown sample entry type: "+i.type),n=new r.SampleEntry(i.type,i.size,i.hdr_size,i.start)),n.write===r.SampleEntry.prototype.write&&(l.info("BoxParser","SampleEntry "+n.type+" box writing not yet implemented, keeping unparsed data in memory for later write"),n.parseDataAndRewind(t)),n.parse(t),this.entries.push(n);else return});r.createFullBoxCtor("stsg",function(t){this.grouping_type=t.readUint32();var e=t.readUint16();this.group_description_index=[];for(var i=0;i<e;i++)this.group_description_index[i]=t.readUint32()});r.createFullBoxCtor("stsh",function(t){var e,i;if(e=t.readUint32(),this.shadowed_sample_numbers=[],this.sync_sample_numbers=[],this.version===0)for(i=0;i<e;i++)this.shadowed_sample_numbers.push(t.readUint32()),this.sync_sample_numbers.push(t.readUint32())});r.createFullBoxCtor("stss",function(t){var e,i;if(i=t.readUint32(),this.version===0)for(this.sample_numbers=[],e=0;e<i;e++)this.sample_numbers.push(t.readUint32())});r.createFullBoxCtor("stsz",function(t){var e;if(this.sample_sizes=[],this.version===0)for(this.sample_size=t.readUint32(),this.sample_count=t.readUint32(),e=0;e<this.sample_count;e++)this.sample_size===0?this.sample_sizes.push(t.readUint32()):this.sample_sizes[e]=this.sample_size});r.createFullBoxCtor("stts",function(t){var e,i,s;if(e=t.readUint32(),this.sample_counts=[],this.sample_deltas=[],this.version===0)for(i=0;i<e;i++)this.sample_counts.push(t.readUint32()),s=t.readInt32(),s<0&&(l.warn("BoxParser","File uses negative stts sample delta, using value 1 instead, sync may be lost!"),s=1),this.sample_deltas.push(s)});r.createFullBoxCtor("stvi",function(t){var e=t.readUint32();this.single_view_allowed=e&3,this.stereo_scheme=t.readUint32();var i=t.readUint32();this.stereo_indication_type=t.readString(i);var s,n;for(this.boxes=[];t.getPosition()<this.start+this.size;)if(s=r.parseOneBox(t,!1,this.size-(t.getPosition()-this.start)),s.code===r.OK)n=s.box,this.boxes.push(n),this[n.type]=n;else return});r.createBoxCtor("styp",function(t){r.ftypBox.prototype.parse.call(this,t)});r.createFullBoxCtor("stz2",function(t){var e,i,s;if(this.sample_sizes=[],this.version===0)if(this.reserved=t.readUint24(),this.field_size=t.readUint8(),s=t.readUint32(),this.field_size===4)for(e=0;e<s;e+=2){var n=t.readUint8();this.sample_sizes[e]=n>>4&15,this.sample_sizes[e+1]=n&15}else if(this.field_size===8)for(e=0;e<s;e++)this.sample_sizes[e]=t.readUint8();else if(this.field_size===16)for(e=0;e<s;e++)this.sample_sizes[e]=t.readUint16();else l.error("BoxParser","Error in length field in stz2 box")});r.createFullBoxCtor("subs",function(t){var e,i,s,n;for(s=t.readUint32(),this.entries=[],e=0;e<s;e++){var a={};if(this.entries[e]=a,a.sample_delta=t.readUint32(),a.subsamples=[],n=t.readUint16(),n>0)for(i=0;i<n;i++){var o={};a.subsamples.push(o),this.version==1?o.size=t.readUint32():o.size=t.readUint16(),o.priority=t.readUint8(),o.discardable=t.readUint8(),o.codec_specific_parameters=t.readUint32()}}});r.createFullBoxCtor("tenc",function(t){if(t.readUint8(),this.version===0)t.readUint8();else{var 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=r.parseHex16(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))});r.createFullBoxCtor("tfdt",function(t){this.version==1?this.baseMediaDecodeTime=t.readUint64():this.baseMediaDecodeTime=t.readUint32()});r.createFullBoxCtor("tfhd",function(t){var e=0;this.track_id=t.readUint32(),this.size-this.hdr_size>e&&this.flags&r.TFHD_FLAG_BASE_DATA_OFFSET?(this.base_data_offset=t.readUint64(),e+=8):this.base_data_offset=0,this.size-this.hdr_size>e&&this.flags&r.TFHD_FLAG_SAMPLE_DESC?(this.default_sample_description_index=t.readUint32(),e+=4):this.default_sample_description_index=0,this.size-this.hdr_size>e&&this.flags&r.TFHD_FLAG_SAMPLE_DUR?(this.default_sample_duration=t.readUint32(),e+=4):this.default_sample_duration=0,this.size-this.hdr_size>e&&this.flags&r.TFHD_FLAG_SAMPLE_SIZE?(this.default_sample_size=t.readUint32(),e+=4):this.default_sample_size=0,this.size-this.hdr_size>e&&this.flags&r.TFHD_FLAG_SAMPLE_FLAGS?(this.default_sample_flags=t.readUint32(),e+=4):this.default_sample_flags=0});r.createFullBoxCtor("tfra",function(t){this.track_ID=t.readUint32(),t.readUint24();var 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=[];for(var i=t.readUint32(),s=0;s<i;s++)this.version===1?(this.time=t.readUint64(),this.moof_offset=t.readUint64()):(this.time=t.readUint32(),this.moof_offset=t.readUint32()),this.traf_number=t["readUint"+8*(this.length_size_of_traf_num+1)](),this.trun_number=t["readUint"+8*(this.length_size_of_trun_num+1)](),this.sample_number=t["readUint"+8*(this.length_size_of_sample_num+1)]()});r.createFullBoxCtor("tkhd",function(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()});r.createBoxCtor("tmax",function(t){this.time=t.readUint32()});r.createBoxCtor("tmin",function(t){this.time=t.readUint32()});r.createBoxCtor("totl",function(t){this.bytessent=t.readUint32()});r.createBoxCtor("tpay",function(t){this.bytessent=t.readUint32()});r.createBoxCtor("tpyl",function(t){this.bytessent=t.readUint64()});r.TrackGroupTypeBox.prototype.parse=function(t){this.parseFullHeader(t),this.track_group_id=t.readUint32()};r.createTrackGroupCtor("msrc");
1r.TrackReferenceTypeBox=function(t,e,i,s){r.Box.call(this,t,e),this.hdr_size=i,this.start=s};r.TrackReferenceTypeBox.prototype=new r.Box;r.TrackReferenceTypeBox.prototype.parse=function(t){this.track_ids=t.readUint32Array((this.size-this.hdr_size)/4)};r.trefBox.prototype.parse=function(t){for(var e,i;t.getPosition()<this.start+this.size;)if(e=r.parseOneBox(t,!0,this.size-(t.getPosition()-this.start)),e.code===r.OK)i=new r.TrackReferenceTypeBox(e.type,e.size,e.hdr_size,e.start),i.write===r.Box.prototype.write&&i.type!=="mdat"&&(l.info("BoxParser","TrackReference "+i.type+" box writing not yet implemented, keeping unparsed data in memory for later write"),i.parseDataAndRewind(t)),i.parse(t),this.boxes.push(i);else return};r.createFullBoxCtor("trep",function(t){for(this.track_ID=t.readUint32(),this.boxes=[];t.getPosition()<this.start+this.size;)if(ret=r.parseOneBox(t,!1,this.size-(t.getPosition()-this.start)),ret.code===r.OK)box=ret.box,this.boxes.push(box);else return});r.createFullBoxCtor("trex",function(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()});r.createBoxCtor("trpy",function(t){this.bytessent=t.readUint64()});r.createFullBoxCtor("trun",function(t){var e=0;if(this.sample_count=t.readUint32(),e+=4,this.size-this.hdr_size>e&&this.flags&r.TRUN_FLAGS_DATA_OFFSET?(this.data_offset=t.readInt32(),e+=4):this.data_offset=0,this.size-this.hdr_size>e&&this.flags&r.TRUN_FLAGS_FIRST_FLAG?(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(var i=0;i<this.sample_count;i++)this.flags&r.TRUN_FLAGS_DURATION&&(this.sample_duration[i]=t.readUint32()),this.flags&r.TRUN_FLAGS_SIZE&&(this.sample_size[i]=t.readUint32()),this.flags&r.TRUN_FLAGS_FLAGS&&(this.sample_flags[i]=t.readUint32()),this.flags&r.TRUN_FLAGS_CTS_OFFSET&&(this.version===0?this.sample_composition_time_offset[i]=t.readUint32():this.sample_composition_time_offset[i]=t.readInt32())});r.createFullBoxCtor("tsel",function(t){this.switch_group=t.readUint32();var e=(this.size-this.hdr_size-4)/4;this.attribute_list=[];for(var i=0;i<e;i++)this.attribute_list[i]=t.readUint32()});r.createFullBoxCtor("txtC",function(t){this.config=t.readCString()});r.createFullBoxCtor("url ",function(t){this.flags!==1&&(this.location=t.readCString())});r.createFullBoxCtor("urn ",function(t){this.name=t.readCString(),this.size-this.hdr_size-this.name.length-1>0&&(this.location=t.readCString())});r.createUUIDBox("a5d40b30e81411ddba2f0800200c9a66",!0,!1,function(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;")});r.createUUIDBox("d08a4f1810f34a82b6c832d8aba183d3",!0,!1,function(t){this.system_id=r.parseHex16(t);var e=t.readUint32();e>0&&(this.data=t.readUint8Array(e))});r.createUUIDBox("a2394f525a9b4f14a2446c427c648df4",!0,!1);r.createUUIDBox("8974dbce7be74c5184f97148f9882554",!0,!1,function(t){this.default_AlgorithmID=t.readUint24(),this.default_IV_size=t.readUint8(),this.default_KID=r.parseHex16(t)});r.createUUIDBox("d4807ef2ca3946958e5426cb9e46a79f",!0,!1,function(t){this.fragment_count=t.readUint8(),this.entries=[];for(var e=0;e<this.fragment_count;e++){var i={},s=0,n=0;this.version===1?(s=t.readUint64(),n=t.readUint64()):(s=t.readUint32(),n=t.readUint32()),i.absolute_time=s,i.absolute_duration=n,this.entries.push(i)}});
1r.createUUIDBox("6d1d9b0542d544e680e2141daff757b2",!0,!1,function(t){this.version===1?(this.absolute_time=t.readUint64(),this.duration=t.readUint64()):(this.absolute_time=t.readUint32(),this.duration=t.readUint32())});r.createFullBoxCtor("vmhd",function(t){this.graphicsmode=t.readUint16(),this.opcolor=t.readUint16Array(3)});r.createFullBoxCtor("vpcC",function(t){var e;this.version===1?(this.profile=t.readUint8(),this.level=t.readUint8(),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)):(this.profile=t.readUint8(),this.level=t.readUint8(),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))});r.createBoxCtor("vttC",function(t){this.text=t.readString(this.size-this.hdr_size)});r.createFullBoxCtor("vvcC",function(t){var e,i,s={held_bits:void 0,num_held_bits:0,stream_read_1_bytes:function(_){this.held_bits=_.readUint8(),this.num_held_bits=8},stream_read_2_bytes:function(_){this.held_bits=_.readUint16(),this.num_held_bits=16},extract_bits:function(_){var U=this.held_bits>>this.num_held_bits-_&(1<<_)-1;return this.num_held_bits-=_,U}};if(s.stream_read_1_bytes(t),s.extract_bits(5),this.lengthSizeMinusOne=s.extract_bits(2),this.ptl_present_flag=s.extract_bits(1),this.ptl_present_flag){s.stream_read_2_bytes(t),this.ols_idx=s.extract_bits(9),this.num_sublayers=s.extract_bits(3),this.constant_frame_rate=s.extract_bits(2),this.chroma_format_idc=s.extract_bits(2),s.stream_read_1_bytes(t),this.bit_depth_minus8=s.extract_bits(3),s.extract_bits(5);{if(s.stream_read_2_bytes(t),s.extract_bits(2),this.num_bytes_constraint_info=s.extract_bits(6),this.general_profile_idc=s.extract_bits(7),this.general_tier_flag=s.extract_bits(1),this.general_level_idc=t.readUint8(),s.stream_read_1_bytes(t),this.ptl_frame_only_constraint_flag=s.extract_bits(1),this.ptl_multilayer_enabled_flag=s.extract_bits(1),this.general_constraint_info=new Uint8Array(this.num_bytes_constraint_info),this.num_bytes_constraint_info){for(e=0;e<this.num_bytes_constraint_info-1;e++){var n=s.extract_bits(6);s.stream_read_1_bytes(t);var a=s.extract_bits(2);this.general_constraint_info[e]=n<<2|a}this.general_constraint_info[this.num_bytes_constraint_info-1]=s.extract_bits(6)}else s.extract_bits(6);for(s.stream_read_1_bytes(t),this.ptl_sublayer_present_mask=0,i=this.num_sublayers-2;i>=0;--i){var o=s.extract_bits(1);this.ptl_sublayer_present_mask|=o<<i}for(i=this.num_sublayers;i<=8&&this.num_sublayers>1;++i)s.extract_bits(1);for(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(e=0;e<this.ptl_num_sub_profiles;e++)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()}var h=12,d=13;this.nalu_arrays=[];var u=t.readUint8();for(e=0;e<u;e++){var p=[];this.nalu_arrays.push(p),s.stream_read_1_bytes(t),p.completeness=s.extract_bits(1),s.extract_bits(2),p.nalu_type=s.extract_bits(5);var y=1;for(p.nalu_type!=d&&p.nalu_type!=h&&(y=t.readUint16()),i=0;i<y;i++){var g=t.readUint16();p.push({data:t.readUint8Array(g),length:g})}}});r.createFullBoxCtor("vvnC",function(t){var e=strm.readUint8();this.lengthSizeMinusOne=e&3});r.SampleEntry.prototype.isVideo=function(){return!1};r.SampleEntry.prototype.isAudio=function(){return!1};r.SampleEntry.prototype.isSubtitle=function(){return!1};r.SampleEntry.prototype.isMetadata=function(){return!1};r.SampleEntry.prototype.isHint=function(){return!1};r.SampleEntry.prototype.getCodec=function(){return this.type.replace(".","")};r.SampleEntry.prototype.getWidth=function(){return""};r.SampleEntry.prototype.getHeight=function(){return""};r.SampleEntry.prototype.getChannelCount=function(){return""};r.SampleEntry.prototype.getSampleRate=function(){return""};r.SampleEntry.prototype.getSampleSize=function(){return""};r.VisualSampleEntry.prototype.isVideo=function(){return!0};r.VisualSampleEntry.prototype.getWidth=function(){return this.width};r.VisualSampleEntry.prototype.getHeight=function(){return this.height};r.AudioSampleEntry.prototype.isAudio=function(){return!0};r.AudioSampleEntry.prototype.getChannelCount=function(){return this.channel_c
1ount};r.AudioSampleEntry.prototype.getSampleRate=function(){return this.samplerate};r.AudioSampleEntry.prototype.getSampleSize=function(){return this.samplesize};r.SubtitleSampleEntry.prototype.isSubtitle=function(){return!0};r.MetadataSampleEntry.prototype.isMetadata=function(){return!0};r.decimalToHex=function(t,e){var i=Number(t).toString(16);for(e=typeof e>"u"||e===null?e=2:e;i.length<e;)i="0"+i;return i};r.avc1SampleEntry.prototype.getCodec=r.avc2SampleEntry.prototype.getCodec=r.avc3SampleEntry.prototype.getCodec=r.avc4SampleEntry.prototype.getCodec=function(){var t=r.SampleEntry.prototype.getCodec.call(this);return this.avcC?t+"."+r.decimalToHex(this.avcC.AVCProfileIndication)+r.decimalToHex(this.avcC.profile_compatibility)+r.decimalToHex(this.avcC.AVCLevelIndication):t};r.hev1SampleEntry.prototype.getCodec=r.hvc1SampleEntry.prototype.getCodec=function(){var t,e=r.SampleEntry.prototype.getCodec.call(this);if(this.hvcC){switch(e+=".",this.hvcC.general_profile_space){case 0:e+="";break;case 1:e+="A";break;case 2:e+="B";break;case 3:e+="C";break}e+=this.hvcC.general_profile_idc,e+=".";var i=this.hvcC.general_profile_compatibility,s=0;for(t=0;t<32&&(s|=i&1,t!=31);t++)s<<=1,i>>=1;e+=r.decimalToHex(s,0),e+=".",this.hvcC.general_tier_flag===0?e+="L":e+="H",e+=this.hvcC.general_level_idc;var n=!1,a="";for(t=5;t>=0;t--)(this.hvcC.general_constraint_indicator[t]||n)&&(a="."+r.decimalToHex(this.hvcC.general_constraint_indicator[t],0)+a,n=!0);e+=a}return e};r.vvc1SampleEntry.prototype.getCodec=r.vvi1SampleEntry.prototype.getCodec=function(){var t,e=r.SampleEntry.prototype.getCodec.call(this);if(this.vvcC){e+="."+this.vvcC.general_profile_idc,this.vvcC.general_tier_flag?e+=".H":e+=".L",e+=this.vvcC.general_level_idc;var i="";if(this.vvcC.general_constraint_info){var s=[],n=0;n|=this.vvcC.ptl_frame_only_constraint<<7,n|=this.vvcC.ptl_multilayer_enabled<<6;var a;for(t=0;t<this.vvcC.general_constraint_info.length;++t)n|=this.vvcC.general_constraint_info[t]>>2&63,s.push(n),n&&(a=t),n=this.vvcC.general_constraint_info[t]>>2&3;if(a===void 0)i=".CA";else{i=".C";var o="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",h=0,d=0;for(t=0;t<=a;++t)for(h=h<<8|s[t],d+=8;d>=5;){var u=h>>d-5&31;i+=o[u],d-=5,h&=(1<<d)-1}d&&(h<<=5-d,i+=o[h&31])}}e+=i}return e};r.mp4aSampleEntry.prototype.getCodec=function(){var t=r.SampleEntry.prototype.getCodec.call(this);if(this.esds&&this.esds.esd){var e=this.esds.esd.getOTI(),i=this.esds.esd.getAudioConfig();return t+"."+r.decimalToHex(e)+(i?"."+i:"")}else return t};r.stxtSampleEntry.prototype.getCodec=function(){var t=r.SampleEntry.prototype.getCodec.call(this);return this.mime_format?t+"."+this.mime_format:t};r.vp08SampleEntry.prototype.getCodec=r.vp09SampleEntry.prototype.getCodec=function(){var t=r.SampleEntry.prototype.getCodec.call(this),e=this.vpcC.level;e==0&&(e="00");var i=this.vpcC.bitDepth;return i==8&&(i="08"),t+".0"+this.vpcC.profile+"."+e+"."+i};r.av01SampleEntry.prototype.getCodec=function(){var t=r.SampleEntry.prototype.getCodec.call(this),e=this.av1C.seq_level_idx_0;e<10&&(e="0"+e);var 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+"."+e+(this.av1C.seq_tier_0?"H":"M")+"."+i};r.Box.prototype.writeHeader=function(t,e){this.size+=8,this.size>B&&(this.size+=8),this.type==="uuid"&&(this.size+=16),l.debug("BoxWriter","Writing box "+this.type+" of size: "+this.size+" at position "+t.getPosition()+(e||"")),this.size>B?t.writeUint32(1):(this.sizePosition=t.getPosition(),t.writeUint32(this.size)),t.writeString(this.type,null,4),this.type==="uuid"&&t.writeUint8Array(this.uuid),this.size>B&&t.writeUint64(this.size)};r.FullBox.prototype.writeHeader=function(t){this.size+=4,r.Box.prototype.writeHeader.call(this,t," v="+this.version+" f="+this.flags),t.writeUint8(this.version),t.writeUint24(this.flags)};r.Box.prototype.write=function(t){this.type==="mdat"?this.data&&(this.size=this.data.length,this.writeHeader(t),t.writeUint8Array(this.data)):(this.size=this.data?this.data.length:0,this.writeHeader(t),this.data&&t.writeUint8Array(this.data))};r.ContainerBox.prototype.write=function(t){this.size=0,this.writeHeader(t);for(var e=0;e<this.boxes.length;e++)this.boxes[e]&&(this.boxes[e].write(t),this.size+=this.boxes[e].size);l.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),t.adjustUint32(this.sizePosition,this.size)};r.TrackReferenceTypeBox.prototype.write=function(t){this.size=this.track_ids.length*4,this.writeHeader(t),t.writeUint32Array(this.track_ids)};r.avcCBox.prototype.write=function(t){var e;
1for(this.size=7,e=0;e<this.SPS.length;e++)this.size+=2+this.SPS[e].length;for(e=0;e<this.PPS.length;e++)this.size+=2+this.PPS[e].length;for(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),e=0;e<this.SPS.length;e++)t.writeUint16(this.SPS[e].length),t.writeUint8Array(this.SPS[e].nalu);for(t.writeUint8(this.PPS.length),e=0;e<this.PPS.length;e++)t.writeUint16(this.PPS[e].length),t.writeUint8Array(this.PPS[e].nalu);this.ext&&t.writeUint8Array(this.ext)};r.co64Box.prototype.write=function(t){var e;for(this.version=0,this.flags=0,this.size=4+8*this.chunk_offsets.length,this.writeHeader(t),t.writeUint32(this.chunk_offsets.length),e=0;e<this.chunk_offsets.length;e++)t.writeUint64(this.chunk_offsets[e])};r.cslgBox.prototype.write=function(t){var e;this.version=0,this.flags=0,this.size=4*5,this.writeHeader(t),t.writeInt32(this.compositionToDTSShift),t.writeInt32(this.leastDecodeToDisplayDelta),t.writeInt32(this.greatestDecodeToDisplayDelta),t.writeInt32(this.compositionStartTime),t.writeInt32(this.compositionEndTime)};r.cttsBox.prototype.write=function(t){var e;for(this.version=0,this.flags=0,this.size=4+8*this.sample_counts.length,this.writeHeader(t),t.writeUint32(this.sample_counts.length),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])};r.drefBox.prototype.write=function(t){this.version=0,this.flags=0,this.size=4,this.writeHeader(t),t.writeUint32(this.entries.length);for(var e=0;e<this.entries.length;e++)this.entries[e].write(t),this.size+=this.entries[e].size;l.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),t.adjustUint32(this.sizePosition,this.size)};r.elngBox.prototype.write=function(t){this.version=0,this.flags=0,this.size=this.extended_language.length,this.writeHeader(t),t.writeString(this.extended_language)};r.elstBox.prototype.write=function(t){this.version=0,this.flags=0,this.size=4+12*this.entries.length,this.writeHeader(t),t.writeUint32(this.entries.length);for(var e=0;e<this.entries.length;e++){var i=this.entries[e];t.writeUint32(i.segment_duration),t.writeInt32(i.media_time),t.writeInt16(i.media_rate_integer),t.writeInt16(i.media_rate_fraction)}};r.emsgBox.prototype.write=function(t){this.version=0,this.flags=0,this.size=4*4+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)};r.ftypBox.prototype.write=function(t){this.size=8+4*this.compatible_brands.length,this.writeHeader(t),t.writeString(this.major_brand,null,4),t.writeUint32(this.minor_version);for(var e=0;e<this.compatible_brands.length;e++)t.writeString(this.compatible_brands[e],null,4)};r.hdlrBox.prototype.write=function(t){this.size=5*4+this.name.length+1,this.version=0,this.flags=0,this.writeHeader(t),t.writeUint32(0),t.writeString(this.handler,null,4),t.writeUint32(0),t.writeUint32(0),t.writeUint32(0),t.writeCString(this.name)};r.kindBox.prototype.write=function(t){this.version=0,this.flags=0,this.size=this.schemeURI.length+1+(this.value.length+1),this.writeHeader(t),t.writeCString(this.schemeURI),t.writeCString(this.value)};r.mdhdBox.prototype.write=function(t){this.size=4*4+2*2,this.flags=0,this.version=0,this.writeHeader(t),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)};r.mehdBox.prototype.write=function(t){this.version=0,this.flags=0,this.size=4,this.writeHeader(t),t.writeUint32(this.fragment_duration)};r.mfhdBox.prototype.write=function(t){this.version=0,this.flags=0,this.size=4,this.writeHeader(t),t.writeUint32(this.sequence_number)};r.mvhdBox.prototype.write=function(t){this.version=0,this.flags=0,this.size=23*4+2*2,this.writeHeader(t),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.writeUint32Array(this.matrix
1),t.writeUint32(0),t.writeUint32(0),t.writeUint32(0),t.writeUint32(0),t.writeUint32(0),t.writeUint32(0),t.writeUint32(this.next_track_id)};r.SampleEntry.prototype.writeHeader=function(t){this.size=8,r.Box.prototype.writeHeader.call(this,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)};r.SampleEntry.prototype.writeFooter=function(t){for(var e=0;e<this.boxes.length;e++)this.boxes[e].write(t),this.size+=this.boxes[e].size;l.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),t.adjustUint32(this.sizePosition,this.size)};r.SampleEntry.prototype.write=function(t){this.writeHeader(t),t.writeUint8Array(this.data),this.size+=this.data.length,l.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),t.adjustUint32(this.sizePosition,this.size)};r.VisualSampleEntry.prototype.write=function(t){this.writeHeader(t),this.size+=2*7+6*4+32,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,null,31),t.writeUint16(this.depth),t.writeInt16(-1),this.writeFooter(t)};r.AudioSampleEntry.prototype.write=function(t){this.writeHeader(t),this.size+=2*4+3*4,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)};r.stppSampleEntry.prototype.write=function(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)};r.SampleGroupEntry.prototype.write=function(t){t.writeUint8Array(this.data)};r.sbgpBox.prototype.write=function(t){this.version=1,this.flags=0,this.size=12+8*this.entries.length,this.writeHeader(t),t.writeString(this.grouping_type,null,4),t.writeUint32(this.grouping_type_parameter),t.writeUint32(this.entries.length);for(var e=0;e<this.entries.length;e++){var i=this.entries[e];t.writeInt32(i.sample_count),t.writeInt32(i.group_description_index)}};r.sgpdBox.prototype.write=function(t){var e,i;for(this.flags=0,this.size=12,e=0;e<this.entries.length;e++)i=this.entries[e],this.version===1&&(this.default_length===0&&(this.size+=4),this.size+=i.data.length);for(this.writeHeader(t),t.writeString(this.grouping_type,null,4),this.version===1&&t.writeUint32(this.default_length),this.version>=2&&t.writeUint32(this.default_sample_description_index),t.writeUint32(this.entries.length),e=0;e<this.entries.length;e++)i=this.entries[e],this.version===1&&this.default_length===0&&t.writeUint32(i.description_length),i.write(t)};r.sidxBox.prototype.write=function(t){this.version=0,this.flags=0,this.size=4*4+2+2+12*this.references.length,this.writeHeader(t),t.writeUint32(this.reference_ID),t.writeUint32(this.timescale),t.writeUint32(this.earliest_presentation_time),t.writeUint32(this.first_offset),t.writeUint16(0),t.writeUint16(this.references.length);for(var e=0;e<this.references.length;e++){var i=this.references[e];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)}};r.smhdBox.prototype.write=function(t){var e;this.version=0,this.flags=1,this.size=4,this.writeHeader(t),t.writeUint16(this.balance),t.writeUint16(0)};r.stcoBox.prototype.write=function(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)};r.stscBox.prototype.write=function(t){var e;for(this.version=0,this.flags=0,this.size=4+12*this.first_chunk.length,this.writeHeader(t),t.writeUint32(this.first_chunk.length),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])};r.stsdBox.prototype.write=function(t){var e;
1for(this.version=0,this.flags=0,this.size=0,this.writeHeader(t),t.writeUint32(this.entries.length),this.size+=4,e=0;e<this.entries.length;e++)this.entries[e].write(t),this.size+=this.entries[e].size;l.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),t.adjustUint32(this.sizePosition,this.size)};r.stshBox.prototype.write=function(t){var e;for(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),e=0;e<this.shadowed_sample_numbers.length;e++)t.writeUint32(this.shadowed_sample_numbers[e]),t.writeUint32(this.sync_sample_numbers[e])};r.stssBox.prototype.write=function(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)};r.stszBox.prototype.write=function(t){var e,i=!0;if(this.version=0,this.flags=0,this.sample_sizes.length>0)for(e=0;e+1<this.sample_sizes.length;)if(this.sample_sizes[e+1]!==this.sample_sizes[0]){i=!1;break}else e++;else i=!1;this.size=8,i||(this.size+=4*this.sample_sizes.length),this.writeHeader(t),i?t.writeUint32(this.sample_sizes[0]):t.writeUint32(0),t.writeUint32(this.sample_sizes.length),i||t.writeUint32Array(this.sample_sizes)};r.sttsBox.prototype.write=function(t){var e;for(this.version=0,this.flags=0,this.size=4+8*this.sample_counts.length,this.writeHeader(t),t.writeUint32(this.sample_counts.length),e=0;e<this.sample_counts.length;e++)t.writeUint32(this.sample_counts[e]),t.writeUint32(this.sample_deltas[e])};r.tfdtBox.prototype.write=function(t){var e=Math.pow(2,32)-1;this.version=this.baseMediaDecodeTime>e?1:0,this.flags=0,this.size=4,this.version===1&&(this.size+=4),this.writeHeader(t),this.version===1?t.writeUint64(this.baseMediaDecodeTime):t.writeUint32(this.baseMediaDecodeTime)};r.tfhdBox.prototype.write=function(t){this.version=0,this.size=4,this.flags&r.TFHD_FLAG_BASE_DATA_OFFSET&&(this.size+=8),this.flags&r.TFHD_FLAG_SAMPLE_DESC&&(this.size+=4),this.flags&r.TFHD_FLAG_SAMPLE_DUR&&(this.size+=4),this.flags&r.TFHD_FLAG_SAMPLE_SIZE&&(this.size+=4),this.flags&r.TFHD_FLAG_SAMPLE_FLAGS&&(this.size+=4),this.writeHeader(t),t.writeUint32(this.track_id),this.flags&r.TFHD_FLAG_BASE_DATA_OFFSET&&t.writeUint64(this.base_data_offset),this.flags&r.TFHD_FLAG_SAMPLE_DESC&&t.writeUint32(this.default_sample_description_index),this.flags&r.TFHD_FLAG_SAMPLE_DUR&&t.writeUint32(this.default_sample_duration),this.flags&r.TFHD_FLAG_SAMPLE_SIZE&&t.writeUint32(this.default_sample_size),this.flags&r.TFHD_FLAG_SAMPLE_FLAGS&&t.writeUint32(this.default_sample_flags)};r.tkhdBox.prototype.write=function(t){this.version=0,this.size=4*18+2*4,this.writeHeader(t),t.writeUint32(this.creation_time),t.writeUint32(this.modification_time),t.writeUint32(this.track_id),t.writeUint32(0),t.writeUint32(this.duration),t.writeUint32(0),t.writeUint32(0),t.writeInt16(this.layer),t.writeInt16(this.alternate_group),t.writeInt16(this.volume<<8),t.writeUint16(0),t.writeInt32Array(this.matrix),t.writeUint32(this.width),t.writeUint32(this.height)};r.trexBox.prototype.write=function(t){this.version=0,this.flags=0,this.size=4*5,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)};r.trunBox.prototype.write=function(t){this.version=0,this.size=4,this.flags&r.TRUN_FLAGS_DATA_OFFSET&&(this.size+=4),this.flags&r.TRUN_FLAGS_FIRST_FLAG&&(this.size+=4),this.flags&r.TRUN_FLAGS_DURATION&&(this.size+=4*this.sample_duration.length),this.flags&r.TRUN_FLAGS_SIZE&&(this.size+=4*this.sample_size.length),this.flags&r.TRUN_FLAGS_FLAGS&&(this.size+=4*this.sample_flags.length),this.flags&r.TRUN_FLAGS_CTS_OFFSET&&(this.size+=4*this.sample_composition_time_offset.length),this.writeHeader(t),t.writeUint32(this.sample_count),this.flags&r.TRUN_FLAGS_DATA_OFFSET&&(this.data_offset_position=t.getPosition(),t.writeInt32(this.data_offset)),this.flags&r.TRUN_FLAGS_FIRST_FLAG&&t.writeUint32(this.first_sample_flags);for(var e=0;e<this.sample_count;e++)this.flags&r.TRUN_FLAGS_DURATION&&t.writeUint32(this.sample_duration[e]),this.flags&r.TRUN_FLAGS_SIZE&&t.writeUint32(this.sample_size[e]),this.flags&r.TRUN_FLAGS_FLAGS&&t.writeUint32(this.sample_flags[e]),this.flags&r.TRUN_FLAGS_CTS_OFFSET&&(this.version===0?t.writeUint32(this.sample_composition_time_offset[e]):t.writeInt32(this.sample_composition_time_offset[e]))};r["url Box"].prototype.write=function(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)};r["urn Box"].prototype.write=function(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)};r.vmhdBox.prototype.write=function(t){var e;this.version=0,this.flags=1,this.size=8,this.writeHeader(t),t.writeUint16(this.graphicsmode),t.writeUint16Array(this.opcolor)};r.cttsBox.prototype.unpack=function(t){var e,i,s;for(s=0,e=0;e<this.sample_counts.length;e++)for(i=0;i<this.sample_counts[e];i++)t[s].pts=t[s].dts+this.sample_offsets[e],s++};r.sttsBox.prototype.unpack=function(t){var e,i,s;for(s=0,e=0;e<this.sample_counts.length;e++)for(i=0;i<this.sample_counts[e];i++)s===0?t[s].dts=0:t[s].dts=t[s-1].dts+this.sample_deltas[e],s++};r.stcoBox.prototype.unpack=function(t){var e;
1for(e=0;e<this.chunk_offsets.length;e++)t[e].offset=this.chunk_offsets[e]};r.stscBox.prototype.unpack=function(t){var e,i,s,n,a;for(n=0,a=0,e=0;e<this.first_chunk.length;e++)for(i=0;i<(e+1<this.first_chunk.length?this.first_chunk[e+1]:1/0);i++)for(a++,s=0;s<this.samples_per_chunk[e];s++){if(t[n])t[n].description_index=this.sample_description_index[e],t[n].chunk_index=a;else return;n++}};r.stszBox.prototype.unpack=function(t){var e;for(e=0;e<this.sample_sizes.length;e++)t[e].size=this.sample_sizes[e]};r.DIFF_BOXES_PROP_NAMES=["boxes","entries","references","subsamples","items","item_infos","extents","associations","subsegments","ranges","seekLists","seekPoints","esd","levels"];r.DIFF_PRIMITIVE_ARRAY_PROP_NAMES=["compatible_brands","matrix","opcolor","sample_counts","sample_counts","sample_deltas","first_chunk","samples_per_chunk","sample_sizes","chunk_offsets","sample_offsets","sample_description_index","sample_duration"];r.boxEqualFields=function(t,e){if(t&&!e)return!1;var i;for(i in t)if(!(r.DIFF_BOXES_PROP_NAMES.indexOf(i)>-1)){if(t[i]instanceof r.Box||e[i]instanceof r.Box)continue;if(typeof t[i]>"u"||typeof e[i]>"u")continue;if(typeof t[i]=="function"||typeof e[i]=="function")continue;if(t.subBoxNames&&t.subBoxNames.indexOf(i.slice(0,4))>-1||e.subBoxNames&&e.subBoxNames.indexOf(i.slice(0,4))>-1)continue;if(i==="data"||i==="start"||i==="size"||i==="creation_time"||i==="modification_time")continue;if(r.DIFF_PRIMITIVE_ARRAY_PROP_NAMES.indexOf(i)>-1)continue;if(t[i]!==e[i])return!1}return!0};r.boxEqual=function(t,e){if(!r.boxEqualFields(t,e))return!1;for(var i=0;i<r.DIFF_BOXES_PROP_NAMES.length;i++){var s=r.DIFF_BOXES_PROP_NAMES[i];if(t[s]&&e[s]&&!r.boxEqual(t[s],e[s]))return!1}return!0};var R=function(){};R.prototype.parseSample=function(t){var e,i,s=new m(t.buffer);for(e=[];!s.isEos();)i=r.parseOneBox(s,!1),i.code===r.OK&&i.box.type==="vttc"&&e.push(i.box);return e};R.prototype.getText=function(t,e,i){function s(u,p,y){return y=y||"0",u=u+"",u.length>=p?u:new Array(p-u.length+1).join(y)+u}function n(u){var p=Math.floor(u/3600),y=Math.floor((u-p*3600)/60),g=Math.floor(u-p*3600-y*60),_=Math.floor((u-p*3600-y*60-g)*1e3);return""+s(p,2)+":"+s(y,2)+":"+s(g,2)+"."+s(_,3)}for(var a=this.parseSample(i),o="",h=0;h<a.length;h++){var d=a[h];o+=n(t)+" --> "+n(e)+`\r
2`,o+=d.payl.text}return o};var N=function(){};N.prototype.parseSample=function(t){var e={},i;e.resources=[];var s=new m(t.data.buffer);if(!t.subsamples||t.subsamples.length===0)e.documentString=s.readString(t.data.length);else if(e.documentString=s.readString(t.subsamples[0].size),t.subsamples.length>1)for(i=1;i<t.subsamples.length;i++)e.resources[i]=s.readUint8Array(t.subsamples[i].size);return typeof DOMParser<"u"&&(e.document=new DOMParser().parseFromString(e.documentString,"application/xml")),e};var D=function(){};D.prototype.parseSample=function(t){var e,i=new m(t.data.buffer);return e=i.readString(t.data.length),e};D.prototype.parseConfig=function(t){var e,i=new m(t.buffer);return i.readUint32(),e=i.readCString(),e};typeof S<"u"&&(S.XMLSubtitlein4Parser=N,S.Textin4Parser=D);var c=function(t){this.stream=t||new b,this.boxes=[],this.mdats=[],this.moofs=[],this.isProgressive=!1,this.moovStartFound=!1,this.onMoovStart=null,this.moovStartSent=!1,this.onReady=null,this.readySent=!1,this.onSegment=null,this.onSamples=null,this.onError=null,this.sampleListBuilt=!1,this.fragmentedTracks=[],this.extractedTracks=[],this.isFragmentationInitialized=!1,this.sampleProcessingStarted=!1,this.nextMoofNumber=0,this.itemListBuilt=!1,this.onSidx=null,this.sidxSent=!1};c.prototype.setSegmentOptions=function(t,e,i){var s=this.getTrackById(t);if(s){var n={};this.fragmentedTracks.push(n),n.id=t,n.user=e,n.trak=s,s.nextSample=0,n.segmentStream=null,n.nb_samples=1e3,n.rapAlignement=!0,i&&(i.nbSamples&&(n.nb_samples=i.nbSamples),i.rapAlignement&&(n.rapAlignement=i.rapAlignement))}};c.prototype.unsetSegmentOptions=function(t){for(var e=-1,i=0;i<this.fragmentedTracks.length;i++){var s=this.fragmentedTracks[i];s.id==t&&(e=i)}e>-1&&this.fragmentedTracks.splice(e,1)};
2c.prototype.setExtractionOptions=function(t,e,i){var s=this.getTrackById(t);if(s){var n={};this.extractedTracks.push(n),n.id=t,n.user=e,n.trak=s,s.nextSample=0,n.nb_samples=1e3,n.samples=[],i&&i.nbSamples&&(n.nb_samples=i.nbSamples)}};c.prototype.unsetExtractionOptions=function(t){for(var e=-1,i=0;i<this.extractedTracks.length;i++){var s=this.extractedTracks[i];s.id==t&&(e=i)}e>-1&&this.extractedTracks.splice(e,1)};c.prototype.parse=function(){var t,e,i,s=!1;if(!(this.restoreParsePosition&&!this.restoreParsePosition()))for(;;)if(this.hasIncompleteMdat&&this.hasIncompleteMdat()){if(this.processIncompleteMdat())continue;return}else if(this.saveParsePosition&&this.saveParsePosition(),e=r.parseOneBox(this.stream,s),e.code===r.ERR_NOT_ENOUGH_DATA)if(this.processIncompleteBox){if(this.processIncompleteBox(e))continue;return}else return;else{var n;switch(i=e.box,n=i.type!=="uuid"?i.type:i.uuid,this.boxes.push(i),n){case"mdat":this.mdats.push(i);break;case"moof":this.moofs.push(i);break;case"moov":this.moovStartFound=!0,this.mdats.length===0&&(this.isProgressive=!0);default:this[n]!==void 0&&l.warn("ISOFile","Duplicate Box of type: "+n+", overriding previous occurrence"),this[n]=i;break}this.updateUsedBytes&&this.updateUsedBytes(i,e)}};c.prototype.checkBuffer=function(t){if(t==null)throw"Buffer must be defined and non empty";if(t.fileStart===void 0)throw"Buffer must have a fileStart property";return t.byteLength===0?(l.warn("ISOFile","Ignoring empty buffer (fileStart: "+t.fileStart+")"),this.stream.logBufferLevel(),!1):(l.info("ISOFile","Processing buffer (fileStart: "+t.fileStart+")"),t.usedBytes=0,this.stream.insertBuffer(t),this.stream.logBufferLevel(),this.stream.initialized()?!0:(l.warn("ISOFile","Not ready to start parsing"),!1))};c.prototype.appendBuffer=function(t,e){var i;if(this.checkBuffer(t))return this.parse(),this.moovStartFound&&!this.moovStartSent&&(this.moovStartSent=!0,this.onMoovStart&&this.onMoovStart()),this.moov?(this.sampleListBuilt||(this.buildSampleLists(),this.sampleListBuilt=!0),this.updateSampleLists(),this.onReady&&!this.readySent&&(this.readySent=!0,this.onReady(this.getInfo())),this.processSamples(e),this.nextSeekPosition?(i=this.nextSeekPosition,this.nextSeekPosition=void 0):i=this.nextParsePosition,this.stream.getEndFilePositionAfter&&(i=this.stream.getEndFilePositionAfter(i))):this.nextParsePosition?i=this.nextParsePosition:i=0,this.sidx&&this.onSidx&&!this.sidxSent&&(this.onSidx(this.sidx),this.sidxSent=!0),this.meta&&(this.flattenItemInfo&&!this.itemListBuilt&&(this.flattenItemInfo(),this.itemListBuilt=!0),this.processItems&&this.processItems(this.onItem)),this.stream.cleanBuffers&&(l.info("ISOFile","Done processing buffer (fileStart: "+t.fileStart+") - next buffer to fetch should have a fileStart position of "+i),this.stream.logBufferLevel(),this.stream.cleanBuffers(),this.stream.logBufferLevel(!0),l.info("ISOFile","Sample data size in memory: "+this.getAllocatedSampleDataSize())),i};c.prototype.getInfo=function(){var t,e,i={},s,n,a,o,h=new Date("1904-01-01T00:00:00Z").getTime();if(this.moov)for(i.hasMoov=!0,i.duration=this.moov.mvhd.duration,i.timescale=this.moov.mvhd.timescale,i.isFragmented=this.moov.mvex!=null,i.isFragmented&&this.moov.mvex.mehd&&(i.fragment_duration=this.moov.mvex.mehd.fragment_duration),i.isProgressive=this.isProgressive,i.hasIOD=this.moov.iods!=null,i.brands=[],i.brands.push(this.ftyp.major_brand),i.brands=i.brands.concat(this.ftyp.compatible_brands),i.created=new Date(h+this.moov.mvhd.creation_time*1e3),i.modified=new Date(h+this.moov.mvhd.modification_time*1e3),i.tracks=[],i.audioTracks=[],i.videoTracks=[],i.subtitleTracks=[],i.metadataTracks=[],i.hintTracks=[],i.otherTracks=[],t=0;t<this.moov.traks.length;t++){if(s=this.moov.traks[t],o=s.mdia.minf.stbl.stsd.entries[0],n={},i.tracks.push(n),n.id=s.tkhd.track_id,n.name=s.mdia.hdlr.name,n.references=[],s.tref)for(e=0;e<s.tref.boxes.length;e++)a={},n.references.push(a),a.type=s.tref.boxes[e].type,a.track_ids=s.tref.boxes[e].track_ids;s.edts&&(n.edits=s.edts.elst.entries),n.created=new Date(h+s.tkhd.creation_time*1e3),n.modified=new Date(h+s.tkhd.modification_time*1e3),n.movie_duration=s.tkhd.duration,n.movie_timescale=i.timescale,n.layer=s.tkhd.layer,n.alternate_group=s.tkhd.alternate_group,n.volume=s.tkhd.volume,n.matrix=s.tkhd.matrix,n.track_width=s.tkhd.width/65536,n.track_height=s.tkhd.height/65536,n.timescale=s.mdia.mdhd.timescale,n.cts_shift=s.mdia.minf.stbl.cslg,n.duration=s.mdia.mdhd.duration,n.samples_duration=s.samples_duration,n.codec=o.getCodec(),n.kind=s.udta&&s.udta.kinds.length?s.udta.kinds[0]:{schemeURI:"",value:""},n.language=s.mdia.elng?s.mdia.elng.extended_language:s.mdia.mdhd.languageString,n.nb_samples=s.samples.length,n.size=s.samples_size,n.bitrate=n.size*8*n.timescale/n.samples_duration,o.isAudio()?(n.type="audio",i.audioTracks.push(n),n.audio={}
2,n.audio.sample_rate=o.getSampleRate(),n.audio.channel_count=o.getChannelCount(),n.audio.sample_size=o.getSampleSize()):o.isVideo()?(n.type="video",i.videoTracks.push(n),n.video={},n.video.width=o.getWidth(),n.video.height=o.getHeight()):o.isSubtitle()?(n.type="subtitles",i.subtitleTracks.push(n)):o.isHint()?(n.type="metadata",i.hintTracks.push(n)):o.isMetadata()?(n.type="metadata",i.metadataTracks.push(n)):(n.type="metadata",i.otherTracks.push(n))}else i.hasMoov=!1;if(i.mime="",i.hasMoov&&i.tracks){for(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="',t=0;t<i.tracks.length;t++)t!==0&&(i.mime+=","),i.mime+=i.tracks[t].codec;i.mime+='"; profiles="',i.mime+=this.ftyp.compatible_brands.join(),i.mime+='"'}return i};c.prototype.processSamples=function(t){var e,i;if(this.sampleProcessingStarted){if(this.isFragmentationInitialized&&this.onSegment!==null)for(e=0;e<this.fragmentedTracks.length;e++){var s=this.fragmentedTracks[e];for(i=s.trak;i.nextSample<i.samples.length&&this.sampleProcessingStarted;){l.debug("ISOFile","Creating media fragment on track #"+s.id+" for sample "+i.nextSample);var n=this.createFragment(s.id,i.nextSample,s.segmentStream);if(n)s.segmentStream=n,i.nextSample++;else break;if((i.nextSample%s.nb_samples===0||t||i.nextSample>=i.samples.length)&&(l.info("ISOFile","Sending fragmented data on track #"+s.id+" for samples ["+Math.max(0,i.nextSample-s.nb_samples)+","+(i.nextSample-1)+"]"),l.info("ISOFile","Sample data size in memory: "+this.getAllocatedSampleDataSize()),this.onSegment&&this.onSegment(s.id,s.user,s.segmentStream.buffer,i.nextSample,t||i.nextSample>=i.samples.length),s.segmentStream=null,s!==this.fragmentedTracks[e]))break}}if(this.onSamples!==null)for(e=0;e<this.extractedTracks.length;e++){var a=this.extractedTracks[e];for(i=a.trak;i.nextSample<i.samples.length&&this.sampleProcessingStarted;){l.debug("ISOFile","Exporting on track #"+a.id+" sample #"+i.nextSample);var o=this.getSample(i,i.nextSample);if(o)i.nextSample++,a.samples.push(o);else break;if((i.nextSample%a.nb_samples===0||i.nextSample>=i.samples.length)&&(l.debug("ISOFile","Sending samples on track #"+a.id+" for sample "+i.nextSample),this.onSamples&&this.onSamples(a.id,a.user,a.samples),a.samples=[],a!==this.extractedTracks[e]))break}}}};c.prototype.getBox=function(t){var e=this.getBoxes(t,!0);return e.length?e[0]:null};c.prototype.getBoxes=function(t,e){var i=[];return c._sweep.call(this,t,i,e),i};c._sweep=function(t,e,i){this.type&&this.type==t&&e.push(this);for(var s in this.boxes){if(e.length&&i)return;c._sweep.call(this.boxes[s],t,e,i)}};c.prototype.getTrackSamplesInfo=function(t){var e=this.getTrackById(t);if(e)return e.samples};c.prototype.getTrackSample=function(t,e){var i=this.getTrackById(t),s=this.getSample(i,e);return s};c.prototype.releaseUsedSamples=function(t,e){var i=0,s=this.getTrackById(t);s.lastValidSample||(s.lastValidSample=0);for(var n=s.lastValidSample;n<e;n++)i+=this.releaseSample(s,n);l.info("ISOFile","Track #"+t+" released samples up to "+e+" (released size: "+i+", remaining: "+this.samplesDataSize+")"),s.lastValidSample=e};c.prototype.start=function(){this.sampleProcessingStarted=!0,this.processSamples(!1)};c.prototype.stop=function(){this.sampleProcessingStarted=!1};c.prototype.flush=function(){l.info("ISOFile","Flushing remaining samples"),this.updateSampleLists(),this.processSamples(!0),this.stream.cleanBuffers(),this.stream.logBufferLevel(!0)};c.prototype.seekTrack=function(t,e,i){var s,n,a=1/0,o=0,h=0,d;if(i.samples.length===0)return l.info("ISOFile","No sample in track, cannot seek! Using time "+l.getDurationString(0,1)+" and offset: 0"),{offset:0,time:0};for(s=0;s<i.samples.length;s++){if(n=i.samples[s],s===0)h=0,d=n.timescale;else if(n.cts>t*n.timescale){h=s-1;break}e&&n.is_sync&&(o=s)}for(e&&(h=o),t=i.samples[h].cts,i.nextSample=h;i.samples[h].alreadyRead===i.samples[h].size&&i.samples[h+1];)h++;return a=i.samples[h].offset+i.samples[h].alreadyRead,l.info("ISOFile","Seeking to "+(e?"RAP":"")+" sample #"+i.nextSample+" on track "+i.tkhd.track_id+", time "+l.getDurationString(t,d)+" and offset: "+a),{offset:a,time:t/d}};c.prototype.seek=function(t,e){var i=this.moov,s,n,a,o={offset:1/0,time:1/0};if(this.moov){for(a=0;a<i.traks.length;a++)s=i.traks[a],n=this.seekTrack(t,e,s),n.offset<o.offset&&(o.offset=n.offset),n.time<o.time&&(o.time=n.time);return l.info("ISOFile","Seeking at time "+l.getDurationString(o.time,1)+" needs a buffer with a fileStart position of "+o.offset),o.offset===1/0?o={offset:this.nextParsePosition,time:0}:o.offset=this.stream.getEndFilePositionAfter(o.offset),l.info("ISOFile","Adjusted seek position (after checking data already in buffer): "+o.offset),o}else throw"Cannot seek: moov not received!"};c.prototype.equal=function(t){for(var e=0;e<this.boxes.length&&e<t.boxes.length;){var i=this.boxes[e],s=t.boxes[e];if(!r.boxEqual(i,s))return!1;e++}return!0};typeof S<"u"&&(S.ISOFile=c);c.prototype.lastBoxStartPosition=0;c.prototype.parsingMdat=null;c.prototype.nextParsePosition=0;c.prototype.discardMdatData=!1;c.prototype.processIncompleteBox=function(t){var e,i,s;return t.type==="mdat"?(e=new r[t.type+"Box"](t.size),this.parsingMdat=e,this.boxes.push(e),this.mdats.push(e),e.start=t.start,e.hdr_size=t.hdr_size,this.stream.addUsedBytes(e.hdr_size),this.lastBoxStartPosition=e.start+e.size,s=this.stream.seek(e.start+e.size,!1,this.discardMdatData),s?(this.parsingMdat=null,!0):(this.moovStartFound?this.nextParsePosition=this.stream.findEndContiguousBuf():this.nextParsePosition=e.start+e.size,!1)):(t.type==="moov"&&(this.moovStartFound=!0,this.mdats.length===0&&(this.isProgressive=!0)),i=this.stream.mergeNextBuffer?this.stream.mergeNextBuffer():!1,i?(this.nextParsePosition=this.stream.getEndPosition(),!0):(t.type?this.moovStartFound?this.nextParsePosition=this.stream.getEndPosition():this.nextParsePosition=this.stream.getPosition()+t.size:this.nextParsePosition=this.stream.getEndPosition(),!1))};c.prototype.hasIncompleteMdat=function(){return this.parsingMdat!==null};c.prototype.processIncompleteMdat=function(){var t,e;return t=this.parsingMdat,e=this.stream.seek(t.start+t.size,!1,this.discardMdatData),e?(l.debug("ISOFile","Found 'mdat' end in buffered data"),this.parsingMdat=null,!0):(this.nextParsePosition=this.stream.findEndContiguousBuf(),!1)};c.prototype.restoreParsePosition=function(){return this.stream.seek(this.lastBoxStartPosition,!0,this.discardMdatData)};c.prototype.saveParsePosition=function(){this.lastBoxStartPosition=this.stream.getPosition()};c.prototype.updateUsedBytes=function(t,e){this.stream.addUsedBytes&&(t.type==="mdat"?(this.stream.addUsedBytes(t.hdr_size),this.discardMdatData&&this.stream.addUsedBytes(t.size-t.hdr_size)):this.stream.addUsedBytes(t.size))};c.prototype.add=r.Box.prototype.add;c.prototype.addBox=r.Box.prototype.addBox;c.prototype.init=function(t){var e=t||{},i=this.add("ftyp").set("major_brand",e.brands&&e.brands[0]||"iso4").set("minor_version",0).set("compatible_brands",e.brands||["iso4"]),s=this.add("moov");return s.add("mvhd").set("timescale",e.timescale||600).set("rate",e.rate||65536).set("creation_time",0).set("modification_time",0).set("duration",e.duration||0).set("volume",e.width?0:256).set("matrix",[65536,0,0,0,65536,0,0,0,1073741824]).set("next_track_id",1),s.add("mvex"),this};c.prototype.addTrack=function(t){this.moov||this.init(t);var e=t||{};e.width=e.width||320,e.height=e.height||320,e.id=e.id||this.moov.mvhd.next_track_id,e.type=e.type||"avc1";var i=this.moov.add("trak");this.moov.mvhd.next_track_id=e.id+1,i.add("tkhd").set("flags",r.TKHD_FLAG_ENABLED|r.TKHD_FLAG_IN_MOVIE|r.TKHD_FLAG_IN_PREVIEW).set("creation_time",0).set("modification_time",0).set("track_id",e.id).set("duration",e.duration||0).set("layer",e.layer||0).set("alternate_group",0).set("volume",1).set("matrix",[0,0,0,0,0,0,0,0,0]).set("width",e.width<<16).set("height",e.height<<16);var s=i.add("mdia");s.add("mdhd").set("creation_time",0).set("modification_time",0).set("timescale",e.timescale||1).set("duration",e.media_duration||0).set("language",e.language||"und"),s.add("hdlr").set("handler",e.hdlr||"vide").set("name",e.name||"Track created with MP4Box.js"),s.add("elng").set("extended_language",e.language||"fr-FR");var n=s.add("minf");if(r[e.type+"SampleEntry"]!==void 0){var a=new r[e.type+"SampleEntry"];a.data_reference_index=1;var o="";for(var h in r.sampleEntryCodes)for(var d=r.sampleEntryCodes[h],u=0;u<d.length;u++)if(d.indexOf(e.type)>-1){o=h;break}switch(o){case"Visual":if(n.add("vmhd").set("graphicsmode",0).set("opcolor",[0,0,0]),a.set("width",e.width).set("height",e.height).set("horizresolution",72<<16).set("vertresolution",72<<16).set("frame_count",1).set("compressorname",e.type+" Compressor").set("depth",24),e.avcDecoderConfigRecord){var p=new r.avcCBox,y=new m(e.avcDecoderConfigRecord);p.parse(y),a.addBox(p)}break;case"Audio":n.add("smhd").set("balance",e.balance||0),a.set("channel_c
2ount",e.channel_count||2).set("samplesize",e.samplesize||16).set("samplerate",e.samplerate||65536);break;case"Hint":n.add("hmhd");break;case"Subtitle":switch(n.add("sthd"),e.type){case"stpp":a.set("namespace",e.namespace||"nonamespace").set("schema_location",e.schema_location||"").set("auxiliary_mime_types",e.auxiliary_mime_types||"");break}break;case"Metadata":n.add("nmhd");break;case"System":n.add("nmhd");break;default:n.add("nmhd");break}e.description&&a.addBox(e.description),e.description_boxes&&e.description_boxes.forEach(function(_){a.addBox(_)}),n.add("dinf").add("dref").addEntry(new r["url Box"]().set("flags",1));var g=n.add("stbl");return g.add("stsd").addEntry(a),g.add("stts").set("sample_counts",[]).set("sample_deltas",[]),g.add("stsc").set("first_chunk",[]).set("samples_per_chunk",[]).set("sample_description_index",[]),g.add("stco").set("chunk_offsets",[]),g.add("stsz").set("sample_sizes",[]),this.moov.mvex.add("trex").set("track_id",e.id).set("default_sample_description_index",e.default_sample_description_index||1).set("default_sample_duration",e.default_sample_duration||0).set("default_sample_size",e.default_sample_size||0).set("default_sample_flags",e.default_sample_flags||0),this.buildTrakSampleLists(i),e.id}};r.Box.prototype.computeSize=function(t){var e=t||new f;e.endianness=f.BIG_ENDIAN,this.write(e)};c.prototype.addSample=function(t,e,i){var s=i||{},n={},a=this.getTrackById(t);if(a!==null){n.number=a.samples.length,n.track_id=a.tkhd.track_id,n.timescale=a.mdia.mdhd.timescale,n.description_index=s.sample_description_index?s.sample_description_index-1:0,n.description=a.mdia.minf.stbl.stsd.entries[n.description_index],n.data=e,n.size=e.byteLength,n.alreadyRead=n.size,n.duration=s.duration||1,n.cts=s.cts||0,n.dts=s.dts||0,n.is_sync=s.is_sync||!1,n.is_leading=s.is_leading||0,n.depends_on=s.depends_on||0,n.is_depended_on=s.is_depended_on||0,n.has_redundancy=s.has_redundancy||0,n.degradation_priority=s.degradation_priority||0,n.offset=0,n.subsamples=s.subsamples,a.samples.push(n),a.samples_size+=n.size,a.samples_duration+=n.duration,a.first_dts||(a.first_dts=s.dts),this.processSamples();var o=this.createSingleSampleMoof(n);return this.addBox(o),o.computeSize(),o.trafs[0].truns[0].data_offset=o.size+8,this.add("mdat").data=new Uint8Array(e),n}};c.prototype.createSingleSampleMoof=function(t){var e=0;t.is_sync?e=1<<25:e=65536;var i=new r.moofBox;i.add("mfhd").set("sequence_number",this.nextMoofNumber),this.nextMoofNumber++;var s=i.add("traf"),n=this.getTrackById(t.track_id);return s.add("tfhd").set("track_id",t.track_id).set("flags",r.TFHD_FLAG_DEFAULT_BASE_IS_MOOF),s.add("tfdt").set("baseMediaDecodeTime",t.dts-(n.first_dts||0)),s.add("trun").set("flags",r.TRUN_FLAGS_DATA_OFFSET|r.TRUN_FLAGS_DURATION|r.TRUN_FLAGS_SIZE|r.TRUN_FLAGS_FLAGS|r.TRUN_FLAGS_CTS_OFFSET).set("data_offset",0).set("first_sample_flags",0).set("sample_count",1).set("sample_duration",[t.duration]).set("sample_size",[t.size]).set("sample_flags",[e]).set("sample_composition_time_offset",[t.cts-t.dts]),i};c.prototype.lastMoofIndex=0;c.prototype.samplesDataSize=0;c.prototype.resetTables=function(){var t,e,i,s,n,a,o,h;for(this.initial_duration=this.moov.mvhd.duration,this.moov.mvhd.duration=0,t=0;t<this.moov.traks.length;t++){e=this.moov.traks[t],e.tkhd.duration=0,e.mdia.mdhd.duration=0,i=e.mdia.minf.stbl.stco||e.mdia.minf.stbl.co64,i.chunk_offsets=[],s=e.mdia.minf.stbl.stsc,s.first_chunk=[],s.samples_per_chunk=[],s.sample_description_index=[],n=e.mdia.minf.stbl.stsz||e.mdia.minf.stbl.stz2,n.sample_sizes=[],a=e.mdia.minf.stbl.stts,a.sample_counts=[],a.sample_deltas=[],o=e.mdia.minf.stbl.ctts,o&&(o.sample_counts=[],o.sample_offsets=[]),h=e.mdia.minf.stbl.stss;var d=e.mdia.minf.stbl.boxes.indexOf(h);d!=-1&&(e.mdia.minf.stbl.boxes[d]=null)}};c.initSampleGroups=function(t,e,i,s,n){var a,o,h,d,u;function p(y,g,_){this.grouping_type=y,this.grouping_type_parameter=g,this.sbgp=_,this.last_sample_in_run=-1,this.entry_index=-1}for(e&&(e.sample_groups_info=[]),t.sample_groups_info||(t.sample_groups_info=[]),o=0;o<i.length;o++){for(u=i[o].grouping_type+"/"+i[o].grouping_type_parameter,d=new p(i[o].grouping_type,i[o].grouping_type_parameter,i[o]),e&&(e.sample_groups_info[u]=d),t.sample_groups_info[u]||(t.sample_groups_info[u]=d),a=0;a<s.length;a++)s[a].grouping_type===i[o].grouping_type&&(d.description=s[a],d.description.used=!0);if(n)for(a=0;a<n.length;a++)n[a].grouping_type===i[o].grouping_type&&(d.fragment_description=n[a],d.fragment_description.used=!0,d.is_fragment=!0)}if(e){if(n)for(o=0;o<n.length;o++)!n[o].used&&n[o].version>=2&&(u=n[o].grouping_type+"/0",d=new p(n[o].grouping_type,0),d.is_fragment=!0,e.sample_groups_info[u]||(e.sample_groups_info[u]=d)
2)}else for(o=0;o<s.length;o++)!s[o].used&&s[o].version>=2&&(u=s[o].grouping_type+"/0",d=new p(s[o].grouping_type,0),t.sample_groups_info[u]||(t.sample_groups_info[u]=d))};c.setSampleGroupProperties=function(t,e,i,s){var n,a;e.sample_groups=[];for(n in s)if(e.sample_groups[n]={},e.sample_groups[n].grouping_type=s[n].grouping_type,e.sample_groups[n].grouping_type_parameter=s[n].grouping_type_parameter,i>=s[n].last_sample_in_run&&(s[n].last_sample_in_run<0&&(s[n].last_sample_in_run=0),s[n].entry_index++,s[n].entry_index<=s[n].sbgp.entries.length-1&&(s[n].last_sample_in_run+=s[n].sbgp.entries[s[n].entry_index].sample_count)),s[n].entry_index<=s[n].sbgp.entries.length-1?e.sample_groups[n].group_description_index=s[n].sbgp.entries[s[n].entry_index].group_description_index:e.sample_groups[n].group_description_index=-1,e.sample_groups[n].group_description_index!==0){var o;s[n].fragment_description?o=s[n].fragment_description:o=s[n].description,e.sample_groups[n].group_description_index>0?(e.sample_groups[n].group_description_index>65535?a=(e.sample_groups[n].group_description_index>>16)-1:a=e.sample_groups[n].group_description_index-1,o&&a>=0&&(e.sample_groups[n].description=o.entries[a])):o&&o.version>=2&&o.default_group_description_index>0&&(e.sample_groups[n].description=o.entries[o.default_group_description_index-1])}};c.process_sdtp=function(t,e,i){e&&(t?(e.is_leading=t.is_leading[i],e.depends_on=t.sample_depends_on[i],e.is_depended_on=t.sample_is_depended_on[i],e.has_redundancy=t.sample_has_redundancy[i]):(e.is_leading=0,e.depends_on=0,e.is_depended_on=0,e.has_redundancy=0))};c.prototype.buildSampleLists=function(){var t,e;for(t=0;t<this.moov.traks.length;t++)e=this.moov.traks[t],this.buildTrakSampleLists(e)};c.prototype.buildTrakSampleLists=function(t){var e,i,s,n,a,o,h,d,u,p,y,g,_,U,x,A,F,I,w,z,C,L,P,H,E,T;if(t.samples=[],t.samples_duration=0,t.samples_size=0,s=t.mdia.minf.stbl.stco||t.mdia.minf.stbl.co64,n=t.mdia.minf.stbl.stsc,a=t.mdia.minf.stbl.stsz||t.mdia.minf.stbl.stz2,o=t.mdia.minf.stbl.stts,h=t.mdia.minf.stbl.ctts,d=t.mdia.minf.stbl.stss,u=t.mdia.minf.stbl.stsd,p=t.mdia.minf.stbl.subs,_=t.mdia.minf.stbl.stdp,y=t.mdia.minf.stbl.sbgps,g=t.mdia.minf.stbl.sgpds,w=-1,z=-1,C=-1,L=-1,P=0,E=0,T=0,c.initSampleGroups(t,null,y,g),!(typeof a>"u")){for(e=0;e<a.sample_sizes.length;e++){var v={};v.number=e,v.track_id=t.tkhd.track_id,v.timescale=t.mdia.mdhd.timescale,v.alreadyRead=0,t.samples[e]=v,v.size=a.sample_sizes[e],t.samples_size+=v.size,e===0?(x=1,U=0,v.chunk_index=x,v.chunk_run_index=U,I=n.samples_per_chunk[U],F=0,U+1<n.first_chunk.length?A=n.first_chunk[U+1]-1:A=1/0):e<I?(v.chunk_index=x,v.chunk_run_index=U):(x++,v.chunk_index=x,F=0,x<=A||(U++,U+1<n.first_chunk.length?A=n.first_chunk[U+1]-1:A=1/0),v.chunk_run_index=U,I+=n.samples_per_chunk[U]),v.description_index=n.sample_description_index[v.chunk_run_index]-1,v.description=u.entries[v.description_index],v.offset=s.chunk_offsets[v.chunk_index-1]+F,F+=v.size,e>w&&(z++,w<0&&(w=0),w+=o.sample_counts[z]),e>0?(t.samples[e-1].duration=o.sample_deltas[z],t.samples_duration+=t.samples[e-1].duration,v.dts=t.samples[e-1].dts+t.samples[e-1].duration):v.dts=0,h?(e>=C&&(L++,C<0&&(C=0),C+=h.sample_counts[L]),v.cts=t.samples[e].dts+h.sample_offsets[L]):v.cts=v.dts,d?(e==d.sample_numbers[P]-1?(v.is_sync=!0,P++):(v.is_sync=!1,v.degradation_priority=0),p&&p.entries[E].sample_delta+T==e+1&&(v.subsamples=p.entries[E].subsamples,T+=p.entries[E].sample_delta,E++)):v.is_sync=!0,c.process_sdtp(t.mdia.minf.stbl.sdtp,v,v.number),_?v.degradation_priority=_.priority[e]:v.degradation_priority=0,p&&p.entries[E].sample_delta+T==e&&(v.subsamples=p.entries[E].subsamples,T+=p.entries[E].sample_delta),(y.length>0||g.length>0)&&c.setSampleGroupProperties(t,v,e,t.sample_groups_info)}e>0&&(t.samples[e-1].duration=Math.max(t.mdia.mdhd.duration-t.samples[e-1].dts,0),t.samples_duration+=t.samples[e-1].duration)}};c.prototype.updateSampleLists=function(){var t,e,i,s,n,a,o,h,d,u,p,y,g,_,U;if(this.moov!==void 0){for(;this.lastMoofIndex<this.moofs.length;)if(d=this.moofs[this.lastMoofIndex],this.lastMoofIndex++,d.type=="moof")for(u=d,t=0;t<u.trafs.length;t++){for(p=u.trafs[t],y=this.getTrackById(p.tfhd.track_id),g=this.getTrexById(p.tfhd.track_id),p.tfhd.flags&r.TFHD_FLAG_SAMPLE_DESC?s=p.tfhd.default_sample_description_index:s=g?g.default_sample_description_index:1,p.tfhd.flags&r.TFHD_FLAG_SAMPLE_DUR?n=p.tfhd.default_sample_duration:n=g?g.default_sample_duration:0,p.tfhd.flags&r.TFHD_FLAG_SAMPLE_SIZE?a=p.tfhd.default_sample_size:a=g?g.default_sample_size:0,p.tfhd.flags&r.TFHD_FLAG_SAMPLE_FLAGS?o=p.tfhd.default_sample_flags:o=g?g.default_sample_flags:0,p.sample_number=0,p.sbgps.length>0&&c.initSampleGroups(y,p,p.sbgps,y.mdia.minf.stbl.sgpds,p.sgpds),e=0;e<p.truns.length;e++){var x=p.truns[e];for(i=0;i<x.sample_count;i++){_={},_.moof_number=this.lastMoofIndex,_.number_in_traf=p.sample_number,p.sample_number++,_.number=y.samples.length,p.first_sample_index=y.samples.length,y.samples.push(_),_.track_id=y.tkhd.track_id,_.timescale=y.mdia.mdhd.timescale,_.description_index=s-1,_.description=y.mdia.minf.stbl.stsd.entries[_.description_index],_.size=a,x.flags&r.TRUN_FLAGS_SIZE&&(_.size=x.sample_size[i]),y.samples_size+=_.size,_.duration=n,x.flags&r.TRUN_FLAGS_DURATION&&(_.duration=x.sample_duration[i]),y.samples_duration+=_.duration,y.first_traf_merged||i>0?_.dts=y.samples[y.samples.length-2].dts+y.samples[y.samples.length-2].duration:(p.tfdt?_.dts=p.tfdt.baseMediaDecodeTime:_.dts=0,y.first_traf_merged=!0),_.cts=_.dts,x.flags&r.TRUN_FLAGS_CTS_OFFSET&&(_.cts=_.dts+x.sample_composition_time_offset[i]),U=o,x.flags&r.TRUN_FLAGS_FLAGS?U=x.sample_flags[i]:i===0&&x.flags&r.TRUN_FLAGS_FIRST_FLAG&&(U=x.first_sample_flags),_.is_sync=!(U>>16&1),_.is_leading=U>>26&3,_.depends_on=U>>24&3,_.is_depended_on=U>>22&3,_.has_redundancy=U>>20&3,_.degradation_priority=U&65535;var A=!!(p.tfhd.flags&r.TFHD_FLAG_BASE_DATA_OFFSET),F=!!(p.tfhd.flags&r.TFHD_FLAG_DEFAULT_BASE_IS_MOOF),I=!!(x.flags&r.TRUN_FLAGS_DATA_OFFSET),w=0;A?w=p.tfhd.base_data_offset:F||e===0?w=u.start:w=h,e===0&&i===0?I?_.offset=w+x.data_offset:_.offset=w:_.offset=h,h=_.offset+_.size,(p.sbgps.length>0||p.sgpds.length>0||y.mdia.minf.stbl.sbgps.length>0||y.mdia.minf.stbl.sgpds.length>0)&&c.setSampleGroupProperties(y,_,_.number_in_traf,p.sample_groups_info)}}if(p.subs){y.has_fragment_subsamples=!0;var z=p.first_sample_index;for(e=0;
2e<p.subs.entries.length;e++)z+=p.subs.entries[e].sample_delta,_=y.samples[z-1],_.subsamples=p.subs.entries[e].subsamples}}}};c.prototype.getSample=function(t,e){var i,s=t.samples[e];if(!this.moov)return null;if(!s.data)s.data=new Uint8Array(s.size),s.alreadyRead=0,this.samplesDataSize+=s.size,l.debug("ISOFile","Allocating sample #"+e+" on track #"+t.tkhd.track_id+" of size "+s.size+" (total: "+this.samplesDataSize+")");else if(s.alreadyRead==s.size)return s;for(;;){var n=this.stream.findPosition(!0,s.offset+s.alreadyRead,!1);if(n>-1){i=this.stream.buffers[n];var a=i.byteLength-(s.offset+s.alreadyRead-i.fileStart);if(s.size-s.alreadyRead<=a)return l.debug("ISOFile","Getting sample #"+e+" data (alreadyRead: "+s.alreadyRead+" offset: "+(s.offset+s.alreadyRead-i.fileStart)+" read size: "+(s.size-s.alreadyRead)+" full size: "+s.size+")"),f.memcpy(s.data.buffer,s.alreadyRead,i,s.offset+s.alreadyRead-i.fileStart,s.size-s.alreadyRead),i.usedBytes+=s.size-s.alreadyRead,this.stream.logBufferLevel(),s.alreadyRead=s.size,s;if(a===0)return null;l.debug("ISOFile","Getting sample #"+e+" partial data (alreadyRead: "+s.alreadyRead+" offset: "+(s.offset+s.alreadyRead-i.fileStart)+" read size: "+a+" full size: "+s.size+")"),f.memcpy(s.data.buffer,s.alreadyRead,i,s.offset+s.alreadyRead-i.fileStart,a),s.alreadyRead+=a,i.usedBytes+=a,this.stream.logBufferLevel()}else return null}};c.prototype.releaseSample=function(t,e){var i=t.samples[e];return i.data?(this.samplesDataSize-=i.size,i.data=null,i.alreadyRead=0,i.size):0};c.prototype.getAllocatedSampleDataSize=function(){return this.samplesDataSize};c.prototype.getCodecs=function(){var t,e="";for(t=0;t<this.moov.traks.length;t++){var i=this.moov.traks[t];t>0&&(e+=","),e+=i.mdia.minf.stbl.stsd.entries[0].getCodec()}return e};c.prototype.getTrexById=function(t){var e;if(!this.moov||!this.moov.mvex)return null;for(e=0;e<this.moov.mvex.trexs.length;e++){var i=this.moov.mvex.trexs[e];if(i.track_id==t)return i}return null};c.prototype.getTrackById=function(t){if(this.moov===void 0)return null;for(var e=0;e<this.moov.traks.length;e++){var i=this.moov.traks[e];if(i.tkhd.track_id==t)return i}return null};c.prototype.items=[];c.prototype.itemsDataSize=0;c.prototype.flattenItemInfo=function(){var t=this.items,e,i,s,n=this.meta;if(n!=null&&n.hdlr!==void 0&&n.iinf!==void 0){for(e=0;e<n.iinf.item_infos.length;e++)s={},s.id=n.iinf.item_infos[e].item_ID,t[s.id]=s,s.ref_to=[],s.name=n.iinf.item_infos[e].item_name,n.iinf.item_infos[e].protection_index>0&&(s.protection=n.ipro.protections[n.iinf.item_infos[e].protection_index-1]),n.iinf.item_infos[e].item_type?s.type=n.iinf.item_infos[e].item_type:s.type="mime",s.content_type=n.iinf.item_infos[e].content_type,s.content_encoding=n.iinf.item_infos[e].content_encoding;if(n.iloc)for(e=0;e<n.iloc.items.length;e++){var a,o=n.iloc.items[e];switch(s=t[o.item_ID],o.data_reference_index!==0&&(l.warn("Item storage with reference to other files: not supported"),s.source=n.dinf.boxes[o.data_reference_index-1]),o.construction_method){case 0:break;case 1:l.warn("Item storage with construction_method : not supported");break;case 2:l.warn("Item storage with construction_method : not supported");break}for(s.extents=[],s.size=0,i=0;i<o.extents.length;i++)s.extents[i]={},s.extents[i].offset=o.extents[i].extent_offset+o.base_offset,s.extents[i].length=o.extents[i].extent_length,s.extents[i].alreadyRead=0,s.size+=s.extents[i].length}if(n.pitm&&(t[n.pitm.item_id].primary=!0),n.iref)for(e=0;e<n.iref.references.length;e++){var h=n.iref.references[e];for(i=0;i<h.references.length;i++)t[h.from_item_ID].ref_to.push({type:h.type,id:h.references[i]})}if(n.iprp)for(var d=0;d<n.iprp.ipmas.length;d++){var u=n.iprp.ipmas[d];for(e=0;e<u.associations.length;e++){var p=u.associations[e];for(s=t[p.id],s.properties===void 0&&(s.properties={},s.properties.boxes=[]),i=0;i<p.props.length;i++){var y=p.props[i];if(y.property_index>0&&y.property_index-1<n.iprp.ipco.boxes.length){var g=n.iprp.ipco.boxes[y.property_index-1];s.properties[g.type]=g,s.properties.boxes.push(g)}}}}}};c.prototype.getItem=function(t){var e,i;if(!this.meta)return null;if(i=this.items[t],!i.data&&i.size)i.data=new Uint8Array(i.size),i.alreadyRead=0,this.itemsDataSize+=i.size,l.debug("ISOFile","Allocating item #"+t+" of size "+i.size+" (total: "+this.itemsDataSize+")");else if(i.alreadyRead===i.size)return i;for(var s=0;s<i.extents.length;s++){var n=i.extents[s];if(n.alreadyRead!==n.length){var a=this.stream.findPosition(!0,n.offset+n.alreadyRead,!1);if(a>-1){e=this.stream.buffers[a];var o=e.byteLength-(n.offset+n.alreadyRead-e.fileStart);if(n.length-n.alreadyRead<=o)l.debug("ISOFile","Getting item #"+t+" extent #"+s+" data (alreadyRead: "+n.alreadyRead+" offset: "+(n.offset+n.alreadyRead-e.fileStart)+" read size: "+(n.length-n.alreadyRead)+" full extent size: "+n.length+" full item size: "+i.size+")"),f.memcpy(i.data.buffer,i.alreadyRead,e,n.offset+n.alreadyRead-e.fileStart,n.length-n.alreadyRead),e.usedBytes+=n.length-n.alreadyRead,this.stream.logBufferLevel(),i.alreadyRead+=n.length-n.alreadyRead,n.alreadyRead=n.length;else return l.debug("ISOFile","Getting item #"+t+" extent #"+s+" partial data (alreadyRead: "+n.alreadyRead+" offset: "+(n.offset+n.alreadyRead-e.fileStart)+" read size: "+o+" full extent size: "+n.length+" full item size: "+i.size+")"),f.memcpy(i.data.buffer,i.alreadyRead,e,n.offset+n.alreadyRead-e.fileStart,o),n.alreadyRead+=o,i.alreadyRead+=o,e.usedBytes+=o,this.stream.logBufferLevel(),null}else return null}}return i.alreadyRead===i.size?i:null};c.prototype.releaseItem=function(t){var e=this.items[t];if(e.data){this.itemsDataSize-=e.size,e.data=null,e.alreadyRead=0;for(var i=0;i<e.extents.length;i++){var s=e.extents[i];s.alreadyRead=0}return e.size}else return 0};c.prototype.processItems=function(t){for(var e in this.items){var i=this.items[e];this.getItem(i.id),t&&!i.sent&&(t(i),i.sent=!0,i.data=null)}};c.prototype.hasItem=function(t){for(var e in this.items){var i=this.items[e];if(i.name===t)return i.id}return-1};c.prototype.getMetaHandler=function(){return this.meta?this.meta.hdlr.handler:null};c.prototype.getPrimaryItem=function(){return!this.meta||!this.meta.pitm?null:this.getItem(this.meta.pitm.item_id)};c.prototype.itemToFragmentedTrackFile=function(t){var e=t||{},i=null;if(e.itemId?i=this.getItem(e.itemId):i=this.getPrimaryItem(),i==null)return null;var s=new c;s.discardMdatData=!1;var n={type:i.type,description_boxes:i.properties.boxes};i.properties.ispe&&(n.width=i.properties.ispe.image_width,n.height=i.properties.ispe.image_height);var a=s.addTrack(n);return a?(s.addSample(a,i.data),s):null};c.prototype.write=function(t){for(var e=0;e<this.boxes.length;e++)this.boxes[e].write(t)};
2c.prototype.createFragment=function(t,e,i){var s=this.getTrackById(t),n=this.getSample(s,e);if(n==null)return n=s.samples[e],this.nextSeekPosition?this.nextSeekPosition=Math.min(n.offset+n.alreadyRead,this.nextSeekPosition):this.nextSeekPosition=s.samples[e].offset+n.alreadyRead,null;var a=i||new f;a.endianness=f.BIG_ENDIAN;var o=this.createSingleSampleMoof(n);o.write(a),o.trafs[0].truns[0].data_offset=o.size+8,l.debug("MP4Box","Adjusting data_offset with new value "+o.trafs[0].truns[0].data_offset),a.adjustUint32(o.trafs[0].truns[0].data_offset_position,o.trafs[0].truns[0].data_offset);var h=new r.mdatBox;return h.data=n.data,h.write(a),a};c.writeInitializationSegment=function(t,e,i,s){var n,a,o,h,d;l.debug("ISOFile","Generating initialization segment");var u=new f;u.endianness=f.BIG_ENDIAN,t.write(u);var p=e.add("mvex");for(i&&p.add("mehd").set("fragment_duration",i),n=0;n<e.traks.length;n++)p.add("trex").set("track_id",e.traks[n].tkhd.track_id).set("default_sample_description_index",1).set("default_sample_duration",s).set("default_sample_size",0).set("default_sample_flags",65536);return e.write(u),u.buffer};c.prototype.save=function(t){var e=new f;e.endianness=f.BIG_ENDIAN,this.write(e),e.save(t)};c.prototype.getBuffer=function(){var t=new f;return t.endianness=f.BIG_ENDIAN,this.write(t),t.buffer};c.prototype.initializeSegmentation=function(){var t,e,i,s,n,a;for(this.onSegment===null&&l.warn("MP4Box","No segmentation callback set!"),this.isFragmentationInitialized||(this.isFragmentationInitialized=!0,this.nextMoofNumber=0,this.resetTables()),s=[],t=0;t<this.fragmentedTracks.length;t++){var o=new r.moovBox;o.mvhd=this.moov.mvhd,o.boxes.push(o.mvhd),n=this.getTrackById(this.fragmentedTracks[t].id),o.boxes.push(n),o.traks.push(n),a={},a.id=n.tkhd.track_id,a.user=this.fragmentedTracks[t].user,a.buffer=c.writeInitializationSegment(this.ftyp,o,this.moov.mvex&&this.moov.mvex.mehd?this.moov.mvex.mehd.fragment_duration:void 0,this.moov.traks[t].samples.length>0?this.moov.traks[t].samples[0].duration:0),s.push(a)}return s};r.Box.prototype.printHeader=function(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)};r.FullBox.prototype.printHeader=function(t){this.size+=4,r.Box.prototype.printHeader.call(this,t),t.log(t.indent+"version:"+this.version),t.log(t.indent+"flags:"+this.flags)};r.Box.prototype.print=function(t){this.printHeader(t)};r.ContainerBox.prototype.print=function(t){this.printHeader(t);for(var e=0;e<this.boxes.length;e++)if(this.boxes[e]){var i=t.indent;t.indent+=" ",this.boxes[e].print(t),t.indent=i}};c.prototype.print=function(t){t.indent="";for(var e=0;e<this.boxes.length;e++)this.boxes[e]&&this.boxes[e].print(t)};r.mvhdBox.prototype.print=function(t){r.FullBox.prototype.printHeader.call(this,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)};r.tkhdBox.prototype.print=function(t){r.FullBox.prototype.printHeader.call(this,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)};var O={};O.createFile=function(t,e){var i=t!==void 0?t:!0,s=new c(e);return s.discardMdatData=!i,s};typeof S<"u"&&(S.createFile=O.createFile)});export default G();

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