@libmedia/avplayer 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- (self.webpackChunklibmedia=self.webpackChunklibmedia||[]).push([[543],{58121:(t,i,e)=>{e.d(i,{A:()=>r});var s=e(134);class r{constructor(){(0,s.A)(this,"signature",void 0),(0,s.A)(this,"version",void 0),(0,s.A)(this,"flags",void 0),(0,s.A)(this,"dataOffset",void 0),(0,s.A)(this,"hasVideo",void 0),(0,s.A)(this,"hasAudio",void 0),this.signature="FLV",this.version=1,this.flags=0,this.dataOffset=9,this.hasAudio=!1,this.hasVideo=!1}async read(t){this.signature=await t.readString(3),this.version=await t.readUint8(),this.flags=await t.readUint8(),this.dataOffset=await t.readUint32(),this.hasAudio=!!(4&this.flags),this.hasVideo=!!(1&this.flags)}write(t){this.flags=0,this.hasAudio&&(this.flags|=4),this.hasVideo&&(this.flags|=1),t.writeString(this.signature),t.writeUint8(this.version),t.writeUint8(this.flags),t.writeUint32(this.dataOffset)}}},68243:(t,i,e)=>{e.d(i,{A:()=>l});var s=e(134),r=e(35336),n=e(92647),a=e(4624),h=e(94889),o=e(9705),f=e(73040);class l{constructor(){(0,s.A)(this,"onMetaData",void 0),this.onMetaData={canSeekToEnd:!1}}async read(t,i){const e=t.getPos(),s=e+BigInt(Math.floor(i)),r=await(0,f.$x)(t,s),n=await(0,f.$x)(t,s);this[r]=n,s>t.getPos()&&await t.skip(Number(BigInt.asIntN(32,s-t.getPos())));const h=Number(t.getPos()-e),l=await t.readUint32();return h+11!==l?(a.R8(`script size not match, size: ${h+11}, previousTagSize: ${l}`,"src/avformat/formats/flv/FlvScriptTag.ts",63),o.LR):0}computeSize(){const t=[],i=new r.A;return i.onFlush=i=>(t.push(i.slice()),0),(0,f.bD)(i,"onMetaData"),(0,f.bD)(i,this.onMetaData),i.flush(),(0,n.A)(Uint8Array,t).length}write(t){if(this.onMetaData){const i=[],e=new r.A;e.onFlush=t=>(i.push(t.slice()),0),(0,f.bD)(e,"onMetaData"),(0,f.bD)(e,this.onMetaData),e.flush();const s=(0,n.A)(Uint8Array,i),a=t.getPos();h.xk(t,18,s.length,BigInt(0)),t.writeBuffer(s),t.writeUint32(Number(t.getPos()-a))}}dts2Position(t){if(this.canSeek()){let i=-1;const e=this.onMetaData.keyframes.times,s=this.onMetaData.keyframes.filepositions;let r;for(r=0;r<e.length;r++){if(e[r]===t){i=r;break}if(e[r]>t){i=Math.max(r-1,0);break}}return r&&r===e.length&&(i=e.length-1),{pos:s[i],dts:e[i]}}return{pos:-1,dts:-1}}position2DTS(t){if(this.canSeek()){let e=-1;const s=this.onMetaData.keyframes.times,r=this.onMetaData.keyframes.filepositions;let n=0;for(n=0;n<r.length;n++)if(r[n]>t){e=n;break}var i;return n===r.length?null!==(i=this.onMetaData.duration)&&void 0!==i?i:s[s.length-1]:s[e]}return-1}canSeek(){return!!(this.onMetaData.keyframes&&this.onMetaData.keyframes.filepositions&&this.onMetaData.keyframes.filepositions.length)}}},35028:(t,i,e)=>{e.d(i,{FJ:()=>s,U5:()=>r});const s={10:86018,2:86017,11:86051,1:69645,4:86049,5:86049,6:86049,7:65543,8:65542},r={7:27,12:173,13:196,9:12,2:4,3:86,4:92,5:106,6:131}},94889:(t,i,e)=>{function s(t,i,e,s){t.writeUint8(i),t.writeUint24(e),t.writeUint24(Number(s&BigInt(16777215))),t.writeUint8(Number(s>>BigInt(24)&BigInt(255))),t.writeUint24(0)}e.d(i,{xk:()=>s}),e(35028)},67543:(t,i,e)=>{e.r(i),e.d(i,{default:()=>b});var s=e(134),r=e(36773),n=e(14619),a=e(42383),h=e(82058),o=e(24175),f=e(34531),l=e(8507),u=e(35336),d=e(58121),p=e(68243),c=e(31865),w=e(73040),g=e(34677);class b extends r.A{constructor(...t){super(...t),(0,s.A)(this,"info",void 0),(0,s.A)(this,"socket",void 0),(0,s.A)(this,"session",void 0),(0,s.A)(this,"ioReader",void 0),(0,s.A)(this,"ioWriter",void 0),(0,s.A)(this,"flvWriter",void 0),(0,s.A)(this,"flvHeader",void 0),(0,s.A)(this,"packetQueue",void 0),(0,s.A)(this,"flvHeaderWrote",void 0),(0,s.A)(this,"hasMetadata",void 0),(0,s.A)(this,"bufferReader",void 0)}writeFlvData(t){this.flvWriter.writeUint8(t.type),this.flvWriter.writeUint24(t.payload.length),this.flvWriter.writeUint24(t.timestamp),this.flvWriter.writeUint8(t.timestamp>>24),this.flvWriter.writeUint24(0),this.flvWriter.writeBuffer(t.payload),this.flvWriter.writeUint32(t.payload.length+11),this.flvWriter.flush()}async handleRtmpPacket(t){if(this.flvHeaderWrote)this.writeFlvData(t);else{if(this.packetQueue.push(t),8===t.type)this.flvHeader.hasAudio=!0;else if(9===t.type)this.flvHeader.hasVideo=!0;else if(18===t.type&&(this.bufferReader?this.bufferReader.resetBuffer(t.payload):this.bufferReader=new c.A(t.payload),"onMetaData"===await w.$x(this.bufferReader,BigInt(t.payload.length)))){this.hasMetadata=!0;const i=await w.$x(this.bufferReader,BigInt(t.payload.length));this.flvHeader.hasAudio=(0,g.A)(i.audiocodecid),this.flvHeader.hasVideo=(0,g.A)(i.videocodecid)}if(this.packetQueue.length>10||this.hasMetadata){if(this.flvHeader.write(this.flvWriter),this.flvWriter.writeUint32(0),!this.hasMetadata&&this.session.getDuration()){const t=new p.A;t.onMetaData={duration:this.session.getDuration()},t.write(this.flvWriter)}this.packetQueue.forEach((t=>{this.writeFlvData(t)})),this.packetQueue.length=0,this.flvHeaderWrote=!0}}}async send(t){return this.socket?(await this.socket.send(t),0):-1048574}async open(t){this.info=t,this.status=1,3===t.subProtocol?(this.socket=new a.A(this.options),await this.socket.open({url:t.url,webtransportOptions:t.webtransportOptions})):(this.socket=new n.A(this.options),await this.socket.open({url:t.url})),this.ioReader=new o.A,this.ioReader.onFlush=async t=>this.socket.read(t),this.ioReader.onSeek=async t=>this.socket.seek(t),this.ioReader.onSize=async()=>this.socket.size(),this.ioWriter=new f.A,this.ioWriter.onFlush=async t=>this.socket.write(t),this.ioWriter.onSeek=async t=>this.socket.seek(t),this.flvWriter=new u.A,this.flvWriter.onFlush=t=>(this.readQueue.push(t.slice()),this.consume&&this.consume(),0),this.flvHeader=new d.A,this.packetQueue=[],this.flvHeaderWrote=!1,this.hasMetadata=!1,this.session=new h.A(this.ioReader,this.ioWriter,{isLive:this.options.isLive,isPull:!0}),this.session.onMediaPacket=async(t,i)=>this.handleRtmpPacket(t),this.session.onError=()=>{this.status=3,this.consume&&this.consume()},await this.session.handshake();const i=l.qg(this.info.uri),e=i.pathname.split("/");await this.session.connect(e[1],`rtmp://${i.host}${i.port?":"+i.port:""}/${e[1]}`);const s=e.slice(2);return this.session.play((s.length>1?s.join("/"):s[0])||""),0}async seek(t){return await this.session.seek(Number(t)),0}async size(){return BigInt(0)}async stop(){this.socket&&(await this.socket.stop(),this.socket=null),this.status=4}}},46084:(t,i,e)=>{e.d(i,{u:()=>r});var s=e(134);class r{constructor(t,i,e,r){(0,s.A)(this,"channelId",void 0),(0,s.A)(this,"type",void 0),(0,s.A)(this,"timestamp",void 0),(0,s.A)(this,"tsField",0),(0,s.A)(this,"extra",0),(0,s.A)(this,"payload",void 0),this.channelId=t,this.type=i,this.timestamp=e,this.payload=r instanceof Uint8Array?r:new Uint8Array(r)}}},82058:(t,i,e)=>{e.d(i,{A:()=>v});var s=e(134),r=e(80662),n=e.n(r),a=e(54001),h=e.n(a),o=e(46084),f=e(90519),l=e(86932),u=e(729),d=e(68680),p=e(73040),c=e(98951),w=e(31865),g=e(4624),b=e(72739),y=e(67672),m=e(13724),k=e(83229);const U="src/avprotocol/rtmp/RtmpSession.ts";class v{constructor(t,i,e){(0,s.A)(this,"ioReader",void 0),(0,s.A)(this,"ioWriter",void 0),(0,s.A)(this,"prevReadPacket",void 0),(0,s.A)(this,"prevWritePacket",void 0),(0,s.A)(this,"inChunkSize",void 0),(0,s.A)(this,"outChunkSize",void 0),(0,s.A)(this,"seq",void 0),(0,s.A)(this,"bufferWriter",void 0),(0,s.A)(this,"bufferReader",void 0),(0,s.A)(this,"requestMap",void 0),(0,s.A)(this,"state",void 0),(0,s.A)(this,"maxSentUnacked",void 0),(0,s.A)(this,"receiveReportSize",void 0),(0,s.A)(this,"duration",void 0),(0,s.A)(this,"options",void 0),(0,s.A)(this,"streamIdMap",void 0),(0,s.A)(this,"sendAsync",void 0),(0,s.A)(this,"onMediaPacket",void 0),(0,s.A)(this,"onError",void 0),this.ioReader=t,this.ioWriter=i,this.options=e,this.prevReadPacket=new(n()),this.prevWritePacket=new(n()),this.requestMap=new(n()),this.streamIdMap=new(n()),this.inChunkSize=128,this.outChunkSize=128,this.seq=0,this.maxSentUnacked=25e5,this.receiveReportSize=1048576,this.sendAsync=new k.an,this.bufferWriter=new u.A(new Uint8Array(1)),this.bufferReader=new w.A(new Uint8Array(1)),this.state=0}async handshake(){const t=(0,l.A)();await this.ioWriter.writeUint8(3),await this.ioWriter.writeUint32(0),await this.ioWriter.writeUint32(0);const i=new Uint8Array(1528);f.y(i),await this.ioWriter.writeBuffer(i),await this.ioWriter.flush(),await this.ioReader.readUint8();const e=await this.ioReader.readUint32();await this.ioReader.skip(4);const s=await this.ioReader.readBuffer(1528);await this.ioWriter.writeUint32(e),await this.ioWriter.writeUint32((0,l.A)()-t),await this.ioWriter.writeBuffer(s),await this.ioWriter.flush(),await this.ioReader.skip(1536),this.readRtmpPacket()}async sendPacket(t){await(0,k.s2)(this.sendAsync),await(0,c.U)(this.ioWriter,this.outChunkSize,t,this.prevWritePacket.get(t.channelId)),this.prevWritePacket.set(t.channelId,t),(0,k.Tl)(this.sendAsync)}async readPacket(){const t=await(0,c.w)(this.ioReader,this.inChunkSize,this.prevReadPacket);return this.prevReadPacket.set(t.channelId,t),t}handleChunkSize(t){t.payload.length>=4&&(this.bufferReader.resetBuffer(t.payload),this.inChunkSize=this.bufferReader.readUint32())}handleUserControl(t){t.payload.length>=2&&(this.bufferReader.resetBuffer(t.payload),6===this.bufferReader.readUint16()&&this.sendPong(t,this.bufferReader.readUint32()))}handleSetPeerBW(t){t.payload.length>=4&&(this.bufferReader.resetBuffer(t.payload),this.maxSentUnacked=this.bufferReader.readUint32(),g.Yz(`Max sent, unacked = ${this.maxSentUnacked}`,U,205))}handleWindowSizeACK(t){t.payload.length>=4&&(this.bufferReader.resetBuffer(t.payload),this.receiveReportSize=this.bufferReader.readUint32(),g.Yz(`Window acknowledgement size = ${this.receiveReportSize}`,U,212),this.receiveReportSize>>=1)}async handleInvoke(t){this.bufferReader.resetBuffer(t.payload);const i=BigInt(t.payload.length),e=await p.$x(this.bufferReader,i),s=await p.$x(this.bufferReader,i);if("_result"===e||"_error"===e){if(this.requestMap.has(s)){const t=await p.$x(this.bufferReader,i),r=await p.$x(this.bufferReader,i);"_result"===e?this.requestMap.get(s).resolve({options:t,info:r}):this.requestMap.get(s).reject({options:t,info:r}),this.requestMap.delete(s)}}else if("onStatus"===e){const t=await p.$x(this.bufferReader,i);let e=await p.$x(this.bufferReader,i);if("error"===e.level)g.z3(`Server error: ${e.description}, ${e.code}`,U,248),this.requestMap.has(s)?(this.requestMap.get(s).reject({options:t,info:e}),this.requestMap.delete(s)):this.onError&&this.onError();else{switch(e.code){case"NetStream.Play.Start":case"NetStream.Seek.Notify":this.state=3;break;case"NetStream.Play.Stop":case"NetStream.Play.UnpublishNotify":this.state=8;break;case"NetStream.Publish.Start":this.state=5}this.requestMap.has(s)&&(this.requestMap.get(s).resolve({options:t,info:e}),this.requestMap.delete(s))}}else"onBWDone"===e&&await this.sendCheckBW()}async handleNotify(t){this.bufferReader.resetBuffer(t.payload),"@setDataFrame"===await p.$x(this.bufferReader,BigInt(t.payload.length))&&(t.payload=t.payload.subarray(Number(this.bufferReader.getPos()))),t.payload.length&&this.onMediaPacket&&await this.onMediaPacket(t,this.streamIdMap.get(t.extra))}async readRtmpPacket(){for(;;)try{const t=await this.readPacket();switch(t.type){case 3:default:break;case 1:this.handleChunkSize(t);break;case 4:this.handleUserControl(t);break;case 6:this.handleSetPeerBW(t);break;case 5:this.handleWindowSizeACK(t);break;case 20:await this.handleInvoke(t);break;case 18:await this.handleNotify(t);break;case 22:case 8:case 9:this.onMediaPacket&&await this.onMediaPacket(t,this.streamIdMap.get(t.extra))}}catch(t){break}}async sendPong(t,i){if(t.payload.length<6)return void g.R8(`Too short ping packet (${t.payload.length})`,U,348);const e=new o.u(2,4,t.timestamp+1,6);this.bufferWriter.resetBuffer(e.payload),this.bufferWriter.writeUint16(7),this.bufferWriter.writeUint32(i),this.sendPacket(e)}async sendWindowAckSize(){const t=new o.u(2,5,0,4);this.bufferWriter.resetBuffer(t.payload),this.bufferWriter.writeUint32(this.maxSentUnacked),await this.sendPacket(t)}async sendBufferTime(t){const i=new o.u(2,4,1,10);this.bufferWriter.resetBuffer(i.payload),this.bufferWriter.writeUint16(3),this.bufferWriter.writeUint32(t),this.bufferWriter.writeUint32(this.options.clientBufferTime||3e3),await this.sendPacket(i)}async sendFCSubscribe(t){const i=new o.u(3,20,0,27+t.length);this.bufferWriter.resetBuffer(i.payload),p.bD(this.bufferWriter,"FCSubscribe"),p.bD(this.bufferWriter,++this.seq),p.bD(this.bufferWriter,null),p.bD(this.bufferWriter,t),await this.sendPacket(i)}async sendFCPublish(t){const i=new o.u(3,20,0,25+t.length);this.bufferWriter.resetBuffer(i.payload),p.bD(this.bufferWriter,"FCPublish"),p.bD(this.bufferWriter,++this.seq),p.bD(this.bufferWriter,null),p.bD(this.bufferWriter,t),await this.sendPacket(i)}async sendReleaseStream(t){const i=new o.u(3,20,0,29+t.length);this.bufferWriter.resetBuffer(i.payload),p.bD(this.bufferWriter,"releaseStream"),p.bD(this.bufferWriter,++this.seq),p.bD(this.bufferWriter,null),p.bD(this.bufferWriter,t),await this.sendPacket(i)}async sendCheckBW(){const t=new o.u(3,20,0,21);this.bufferWriter.resetBuffer(t.payload),p.bD(this.bufferWriter,"_checkbw"),p.bD(this.bufferWriter,++this.seq),p.bD(this.bufferWriter,null),await this.sendPacket(t)}async request(t,i){const e=new o.u(3,20,0,4096+d.iD);return this.bufferWriter.resetBuffer(e.payload),p.bD(this.bufferWriter,t),p.bD(this.bufferWriter,++this.seq),b.__(i,(t=>{p.bD(this.bufferWriter,t)})),e.payload=e.payload.subarray(0,this.bufferWriter.getPos()),new(h())(((t,i)=>{this.requestMap.set(this.seq,{resolve:t,reject:i}),this.sendPacket(e)}))}async connect(t,i){await this.request("connect",[{app:t,fourCcList:["hvc1","av01","vp09"],flashVer:"LNX 9,0,124,2",tcUrl:i,fpad:0,capabilities:15,audioCodecs:4071,videoCodecs:252,videoFunction:1}]),this.options.isPull&&await this.sendWindowAckSize()}async createStream(){return(await this.request("createStream",[null])).info}async play(t){const i=await this.createStream();if(this.streamIdMap.set(i,t),!this.options.isLive){const i=await h().race([this.request("getStreamLength",[null,t]),new m.A(1)]);y.ai(i)||(this.duration=i.info)}await this.sendFCSubscribe(t),this.request("play",[null,t,-1,-1,!0]),await this.sendBufferTime(i)}async publish(t){await this.sendReleaseStream(t),await this.sendFCPublish(t);const i=await this.createStream();this.streamIdMap.set(i,t),await this.request("publish",[null,t,"live"])}async sendStreamPacket(t,i){let e=0;this.streamIdMap.forEach(((t,s)=>{t===i&&(e=s)})),t.extra=e,await this.sendPacket(t)}async seek(t){const i=new o.u(3,20,0,26);this.bufferWriter.resetBuffer(i.payload),p.bD(this.bufferWriter,"seek"),p.bD(this.bufferWriter,0),p.bD(this.bufferWriter,null),p.bD(this.bufferWriter,t),await this.sendPacket(i)}async pause(t,i){const e=new o.u(3,20,0,29);this.bufferWriter.resetBuffer(e.payload),p.bD(this.bufferWriter,"pause"),p.bD(this.bufferWriter,0),p.bD(this.bufferWriter,null),p.bD(this.bufferWriter,t),p.bD(this.bufferWriter,i),await this.sendPacket(e)}getDuration(){return this.duration}}},68680:(t,i,e)=>{e.d(i,{iD:()=>s});const s=1024},98951:(t,i,e)=>{e.d(i,{U:()=>o,w:()=>f});var s=e(46084),r=e(92647),n=e(4624);const a="src/avprotocol/rtmp/util.ts";async function h(t,i,e){if(i<64)await t.writeUint8(i|e<<6);else if(i<320)await t.writeUint8(e<<6),await t.writeUint8(i-64);else{await t.writeUint8(1|e<<6);const s=i-64;await t.writeUint8(255&s),await t.writeUint8(s>>>8)}}async function o(t,i,e,s){const r=s&&s.extra===e.extra&&e.timestamp>=s.timestamp;let n=e.timestamp;r&&(n-=s.timestamp),e.tsField=n>16777215?16777215:n;let a=0;r&&(e.type===s.type&&e.payload.length===s.payload.length?(a=2,e.tsField===s.tsField&&(a=3)):a=1),await h(t,e.channelId,a),3!==a&&(await t.writeUint24(e.tsField),2!==a&&(await t.writeUint24(e.payload.length),await t.writeUint8(e.type),0===a&&(await t.writeUint8(e.extra),await t.writeUint8(e.extra>>8),await t.writeUint8(e.extra>>16),await t.writeUint8(e.extra>>24)))),16777215===e.tsField&&await t.writeUint32(n);let o=0;for(;o<e.payload.length;){const s=Math.min(i,e.payload.length-o);await t.writeBuffer(e.payload.subarray(o,o+s)),o+=s,o<e.payload.length&&(await h(t,e.channelId,3),16777215===e.tsField&&await t.writeUint32(n))}await t.flush()}async function f(t,i,e){const h=[],o=await t.readUint8();let f=63&o;f<2&&(f=0===await t.readUint8()?await t.readUint8()+64:64+(await t.readUint8()|await t.readUint8()<<8));const l=o>>>6,u=e.get(f);let d=u?u.payload.length:0,p=u?u.type:0,c=u?u.extra:0,w=0,g=0;if(3===l?w=u.tsField:(w=await t.readUint24(),2!==l&&(d=await t.readUint24(),p=await t.readUint8(),0===l&&(c=await t.readUint8(),c|=await t.readUint8()<<8,c|=await t.readUint8()<<16,c|=await t.readUint8()<<24))),g=16777215===w?await t.readUint32():w,0!==l&&(u?g+=u.timestamp:n.R8(`got invalid message fmt, channel id ${f} can not find prev message with fmt ${l}`,a,171)),d<i)h.push(await t.readBuffer(d));else{let e=d;for(;e;){const s=Math.min(i,e);if(h.push(await t.readBuffer(s)),e-=s,e){const i=63&await t.readUint8();i<2&&await t.skip(i+1),16777215===w&&await t.skip(4)}}}const b=new s.u(f,p,g,(0,r.A)(Uint8Array,h));return b.tsField=w,b.extra=c,b}},73040:(t,i,e)=>{e.d(i,{$x:()=>h,bD:()=>o});var s=e(67672),r=e(72739),n=e(95335);async function a(t,i){return{key:await t.readString(await t.readUint16()),value:await h(t,i)}}async function h(t,i){let e;switch(await t.readUint8()){case 0:e=await t.readDouble();break;case 1:e=!!await t.readUint8();break;case 2:e=await t.readString(await t.readUint16());break;case 3:for(e={};t.getPos()<i;){const{key:s,value:r}=await a(t,i);if(e[s]=r,9==(16777215&await t.peekUint24())){await t.skip(3);break}}break;case 8:for(e={},await t.skip(4);t.getPos()<i;){const{key:s,value:r}=await a(t,i);if(e[s]=r,9==(16777215&await t.peekUint24())){await t.skip(3);break}}break;case 9:case 5:e=null;break;case 10:e=[];const s=await t.readUint32();for(let r=0;r<s;r++)e.push(await h(t,i));break;case 11:const r=await t.readDouble(),n=await t.readInt16();e=new Date(r+60*n*1e3);break;case 12:e=await t.readString(await t.readUint32())}return e}function o(t,i){s.ai(i)?(t.writeUint8(0),t.writeDouble(i)):s.o(i)?(t.writeUint8(0),t.writeDouble(Number(i))):s.zM(i)?(t.writeUint8(1),t.writeUint8(i?1:0)):s.Yj(i)?i.length>=65536?(t.writeUint8(12),t.writeUint32(i.length),t.writeString(i)):(t.writeUint8(2),t.writeUint16(i.length),t.writeString(i)):s.YO(i)?(t.writeUint8(10),t.writeUint32(i.length),r.__(i,(i=>{o(t,i)}))):s.Ik(i)?(t.writeUint8(3),n.__(i,((i,e)=>{t.writeUint16(e.length),t.writeString(e),o(t,i)})),t.writeUint24(9)):i instanceof Date?(t.writeUint8(11),t.writeDouble(i.getTime()),t.writeInt16(0)):null==i&&t.writeUint8(5)}},90519:(t,i,e)=>{function s(t){crypto.getRandomValues(t)}e.d(i,{y:()=>s})},83229:(t,i,e)=>{e.d(i,{Tl:()=>o,an:()=>a,s2:()=>h});var s=e(134),r=e(54001),n=e.n(r);class a{constructor(){(0,s.A)(this,"list",[])}}async function h(t){return new(n())((i=>{t.list.push(i),1===t.list.length&&i()}))}function o(t){t.list.shift(),t.list.length&&t.list[0]()}},6498:(t,i,e)=>{e(67672),e(72739)},24175:(t,i,e)=>{e.d(i,{A:()=>o});var s=e(134),r=e(4624),n=e(50011),a=e(13724);const h="src/common/io/IOReader.ts";class o{constructor(t=1048576,i=!0,e){if((0,s.A)(this,"data",void 0),(0,s.A)(this,"buffer",void 0),(0,s.A)(this,"pointer",void 0),(0,s.A)(this,"endPointer",void 0),(0,s.A)(this,"pos",void 0),(0,s.A)(this,"size",void 0),(0,s.A)(this,"littleEndian",void 0),(0,s.A)(this,"fileSize_",void 0),(0,s.A)(this,"error",void 0),(0,s.A)(this,"onFlush",void 0),(0,s.A)(this,"onSeek",void 0),(0,s.A)(this,"onSize",void 0),(0,s.A)(this,"flags",void 0),this.pos=BigInt(0),this.pointer=0,this.error=0,this.endPointer=0,this.littleEndian=!i,this.flags=0,e&&e.view)this.size=e.length,this.buffer=e,this.data=e.view;else if(e&&!e.byteOffset)this.size=e.length,this.buffer=e,this.data=new DataView(this.buffer.buffer);else{if(e)throw new Error("not support subarray of ArrayBuffer");this.size=Math.max(t,102400),this.buffer=new Uint8Array(this.size),this.data=new DataView(this.buffer.buffer)}}async readUint8(){this.remainingLength()<1&&await this.flush(1);const t=this.data.getUint8(this.pointer);return this.pointer++,this.pos++,t}async peekUint8(){return this.remainingLength()<1&&await this.flush(1),this.data.getUint8(this.pointer)}async readUint16(){this.remainingLength()<2&&await this.flush(2);const t=this.data.getUint16(this.pointer,this.littleEndian);return this.pointer+=2,this.pos+=BigInt(2),t}async peekUint16(){return this.remainingLength()<2&&await this.flush(2),this.data.getUint16(this.pointer,this.littleEndian)}async readUint24(){this.remainingLength()<3&&await this.flush(3);const t=await this.readUint16(),i=await this.readUint8();return this.littleEndian?i<<16|t:t<<8|i}async peekUint24(){this.remainingLength()<3&&await this.flush(3);const t=this.pointer,i=this.pos,e=await this.readUint16(),s=await this.readUint8(),r=this.littleEndian?s<<16|e:e<<8|s;return this.pointer=t,this.pos=i,r}async readUint32(){this.remainingLength()<4&&await this.flush(4);const t=this.data.getUint32(this.pointer,this.littleEndian);return this.pointer+=4,this.pos+=BigInt(4),t}async peekUint32(){return this.remainingLength()<4&&await this.flush(4),this.data.getUint32(this.pointer,this.littleEndian)}async readUint64(){this.remainingLength()<8&&await this.flush(8);const t=this.data.getBigUint64(this.pointer,this.littleEndian);return this.pointer+=8,this.pos+=BigInt(8),t}async peekUint64(){return this.remainingLength()<8&&await this.flush(8),this.data.getBigUint64(this.pointer,this.littleEndian)}async readInt8(){this.remainingLength()<1&&await this.flush(1);const t=this.data.getInt8(this.pointer);return this.pointer++,this.pos++,t}async peekInt8(){return this.remainingLength()<1&&await this.flush(1),this.data.getInt8(this.pointer)}async readInt16(){this.remainingLength()<2&&await this.flush(2);const t=this.data.getInt16(this.pointer,this.littleEndian);return this.pointer+=2,this.pos+=BigInt(2),t}async peekInt16(){return this.remainingLength()<2&&await this.flush(2),this.data.getInt16(this.pointer,this.littleEndian)}async readInt24(){const t=await this.readUint24();return 8388608&t?t-16777216:t}async peekInt24(){const t=await this.peekUint24();return 8388608&t?t-16777216:t}async readInt32(){this.remainingLength()<4&&await this.flush(4);const t=this.data.getInt32(this.pointer,this.littleEndian);return this.pointer+=4,this.pos+=BigInt(4),t}async peekInt32(){return this.remainingLength()<4&&await this.flush(4),this.data.getInt32(this.pointer,this.littleEndian)}async readInt64(){this.remainingLength()<8&&await this.flush(8);const t=this.data.getBigInt64(this.pointer,this.littleEndian);return this.pointer+=8,this.pos+=BigInt(8),t}async peekInt64(){return this.remainingLength()<8&&await this.flush(8),this.data.getBigInt64(this.pointer,this.littleEndian)}async readFloat(){this.remainingLength()<4&&await this.flush(4);const t=this.data.getFloat32(this.pointer,this.littleEndian);return this.pointer+=4,this.pos+=BigInt(4),t}async peekFloat(){return this.remainingLength()<4&&await this.flush(4),this.data.getFloat32(this.pointer,this.littleEndian)}async readDouble(){this.remainingLength()<8&&await this.flush(8);const t=this.data.getFloat64(this.pointer,this.littleEndian);return this.pointer+=8,this.pos+=BigInt(8),t}async peekDouble(){return this.remainingLength()<8&&await this.flush(8),this.data.getFloat64(this.pointer,this.littleEndian)}async readHex(t=1){let i="";for(let e=0;e<t;e++){const t=(await this.readUint8()).toString(16);i+=1===t.length?"0"+t:t}return i}async peekHex(t=1){t>this.size&&(this.error=-1048574,r.h2("peekHex, length too large",h,414)),this.remainingLength()<t&&await this.flush(t);const i=this.pointer,e=this.pos;let s="";for(let i=0;i<t;i++){const t=(await this.readUint8()).toString(16);s+=1===t.length?"0"+t:t}return this.pointer=i,this.pos=e,s}async readBuffer(t,i){if(i||(i=new Uint8Array(t)),this.remainingLength()<t){let e=0;if(this.remainingLength()>0){const s=this.remainingLength();i.set(this.buffer.subarray(this.pointer,this.pointer+s),e),e+=s,this.pointer+=s,this.pos+=BigInt(s),t-=s}for(;t>0;){await this.flush();const s=Math.min(this.endPointer-this.pointer,t);i.set(this.buffer.subarray(this.pointer,this.pointer+s),e),e+=s,this.pointer+=s,this.pos+=BigInt(s),t-=s}}else i.set(this.buffer.subarray(this.pointer,this.pointer+t),0),this.pointer+=t,this.pos+=BigInt(t);return i}async peekBuffer(t,i){return t>this.size&&(this.error=-1048574,r.h2("peekBuffer, length too large",h,499)),this.remainingLength()<t&&await this.flush(t),i||(i=new Uint8Array(t)),i.set(this.buffer.subarray(this.pointer,this.pointer+t),0),i}async readToBuffer(t,i){if(this.remainingLength()<t){let e=0;if(this.remainingLength()>0){const s=this.remainingLength();i.set(this.buffer.subarray(this.pointer,this.pointer+s),e),e+=s,this.pointer+=s,this.pos+=BigInt(s),t-=s}for(;t>0;){try{await this.flush()}catch(t){if(-1048576===this.error&&e)return e;throw t}const s=Math.min(this.endPointer-this.pointer,t);i.set(this.buffer.subarray(this.pointer,this.pointer+s),e),e+=s,this.pointer+=s,this.pos+=BigInt(s),t-=s}return e}return i.set(this.buffer.subarray(this.pointer,this.pointer+t),0),this.pointer+=t,this.pos+=BigInt(t),t}async readString(t=1){const i=await this.readBuffer(t);return n.decode(i)}async peekString(t=1){const i=await this.peekBuffer(t);return n.decode(i)}async readLine(){let t="";for(;;){let i=!1;for(let e=this.pointer;e<this.endPointer;e++)if(10===this.buffer[e]||13===this.buffer[e]){e!==this.pointer&&(t+=await this.readString(e-this.pointer)),i=!0;break}if(i)break;t+=await this.readString(this.remainingLength()),await this.flush()}let i=await this.peekUint8();return 10!==i&&13!==i||(this.pointer++,13===i&&(i=await this.peekUint8(),10===i&&this.pointer++)),t}async peekLine(){if(this.remainingLength()<this.size)try{await this.flush()}catch(t){if(-1048576!==this.error)throw t}let t="",i=!1;for(let e=this.pointer;e<this.endPointer;e++)if(10===this.buffer[e]||13===this.buffer[e]){t+=await this.peekString(e-this.pointer),i=!0;break}return i||(this.error=-1048574,r.h2("peekLine, out of buffer",h,657)),t}getPointer(){return this.pointer}getPos(){return this.pos}async skip(t){const i=t;for(;this.remainingLength()<t;)t-=this.remainingLength(),this.pointer=this.endPointer,await this.flush();this.remainingLength()>=t&&(this.pointer+=t),this.pos+=BigInt(i)}remainingLength(){return this.endPointer-this.pointer}async flush_(t){for(;;){const i=await this.onFlush(t);if(-1048575!==i)return i;await new a.A(0)}}async flush(t=0){if(this.onFlush||(this.error=-1048574,r.h2("IOReader error, flush failed because of no flush callback",h,731)),!(this.size-this.remainingLength()<=0)){if(t=Math.min(t,this.size),this.pointer<this.endPointer?(this.buffer.set(this.buffer.subarray(this.pointer,this.endPointer),0),this.endPointer=this.endPointer-this.pointer):this.endPointer=0,this.pointer=0,t)for(;this.remainingLength()<t;){const t=await this.flush_(this.buffer.subarray(this.endPointer));if(t<0)throw this.error=t,new Error(`IOReader error, flush ${-1048576===t?"ended":"failed"}, ret: ${t}`);this.endPointer+=t}else{const t=await this.flush_(this.buffer.subarray(this.endPointer));if(t<0)throw this.error=t,new Error(`IOReader error, flush ${-1048576===t?"ended":"failed"}, ret: ${t}`);this.endPointer+=t}this.error=0}}async seek(t,i=!1,e=!0){if(!i){const i=Number(t-this.pos);if(i<0&&Math.abs(i)<this.pointer)return this.pointer+=i,void(this.pos=t);if(i>0&&this.pointer+i<this.endPointer)return this.pointer+=i,void(this.pos=t);if(0===i)return}this.onSeek||(this.error=-1048574,r.h2("IOReader error, seek failed because of no seek callback",h,802)),this.pointer=this.endPointer=0,this.pos=t;const s=await this.onSeek(t);0!==s&&(this.error=s,r.h2("IOReader error, seek failed",h,811)),e&&await this.flush()}getBuffer(){return this.buffer}appendBuffer(t){if(this.size-this.endPointer>=t.length)this.buffer.set(t,this.endPointer),this.endPointer+=t.length;else if(this.buffer.set(this.buffer.subarray(this.pointer,this.endPointer),0),this.endPointer=this.endPointer-this.pointer,this.pointer=0,this.size-this.endPointer>=t.length)this.buffer.set(t,this.endPointer),this.endPointer+=t.length;else{const i=Math.min(this.size-this.endPointer,t.length);this.buffer.set(t.subarray(0,i),this.endPointer),this.endPointer+=i,r.R8("IOReader, call appendBuffer but the buffer's size is lagger then the remaining size",h,849)}}reset(){this.pointer=this.endPointer=0,this.pos=BigInt(0),this.error=0}setEndian(t){this.littleEndian=!t}async fileSize(){if(this.fileSize_)return this.fileSize_;if(!this.onSize)return r.R8("IOReader error, fileSize failed because of no onSize callback",h,882),BigInt(0);try{this.fileSize_=await this.onSize()}catch(t){r.R8(`IOReader error, call fileSize failed: ${t}`,h,889),this.fileSize_=BigInt(0)}return this.fileSize_}getBufferSize(){return this.size}async pipe(t,i){if(i)if(this.remainingLength()<i){if(this.remainingLength()>0){const e=this.remainingLength();await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+e)),this.pointer+=e,this.pos+=BigInt(e),i-=e}for(;i>0;){await this.flush();const e=Math.min(this.remainingLength(),i);await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+e)),this.pointer+=e,this.pos+=BigInt(e),i-=e}}else await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+i)),this.pointer+=i,this.pos+=BigInt(i);else{if(this.remainingLength()>0){const i=this.remainingLength();await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+i)),this.pointer+=i,this.pos+=BigInt(i)}for(;await this.flush_(this.buffer.subarray(0))>0;){const i=this.remainingLength();await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+i)),this.pointer+=i,this.pos+=BigInt(i)}}}}},34531:(t,i,e)=>{e.d(i,{A:()=>n});var s=e(134),r=e(50011);class n{constructor(t=1048576,i=!0,e){if((0,s.A)(this,"data",void 0),(0,s.A)(this,"buffer",void 0),(0,s.A)(this,"pointer",void 0),(0,s.A)(this,"pos",void 0),(0,s.A)(this,"size",void 0),(0,s.A)(this,"littleEndian",void 0),(0,s.A)(this,"error",void 0),(0,s.A)(this,"onFlush",void 0),(0,s.A)(this,"onSeek",void 0),this.pointer=0,this.pos=BigInt(0),this.size=t,this.littleEndian=!i,this.error=0,e&&e.view)this.size=e.length,this.buffer=e,this.data=e.view;else if(e&&!e.byteOffset)this.size=e.length,this.buffer=e,this.data=new DataView(this.buffer.buffer);else{if(e)throw new Error("not support subarray of ArrayBuffer");this.buffer=new Uint8Array(this.size),this.data=new DataView(this.buffer.buffer)}}async writeUint8(t){this.remainingLength()<1&&await this.flush(),this.data.setUint8(this.pointer,t),this.pointer++,this.pos++}async writeUint16(t){this.remainingLength()<2&&await this.flush(),this.data.setUint16(this.pointer,t,this.littleEndian),this.pointer+=2,this.pos+=BigInt(2)}async writeUint24(t){this.remainingLength()<3&&await this.flush();const i=(16711680&t)>>16,e=(65280&t)>>8,s=255&t;this.littleEndian?(await this.writeUint8(s),await this.writeUint8(e),await this.writeUint8(i)):(await this.writeUint8(i),await this.writeUint8(e),await this.writeUint8(s))}async writeUint32(t){this.remainingLength()<4&&await this.flush(),this.data.setUint32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}async writeUint64(t){this.remainingLength()<8&&await this.flush(),this.data.setBigUint64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}async writeInt8(t){this.remainingLength()<1&&await this.flush(),this.data.setInt8(this.pointer,t),this.pointer++,this.pos++}async writeInt16(t){this.remainingLength()<2&&await this.flush(),this.data.setInt16(this.pointer,t,this.littleEndian),this.pointer+=2,this.pos+=BigInt(2)}async writeInt24(t){await this.writeUint24(t<0?t+16777216:t)}async writeInt32(t){this.remainingLength()<4&&await this.flush(),this.data.setInt32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}async writeInt64(t){this.remainingLength()<8&&await this.flush(),this.data.setBigInt64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}async writeFloat(t){this.remainingLength()<4&&await this.flush(),this.data.setFloat32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}async writeDouble(t){this.remainingLength()<8&&await this.flush(),this.data.setFloat64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}getPointer(){return this.pointer}getPos(){return this.pos}remainingLength(){return this.size-this.pointer}async writeBuffer(t){if(!t.length)return;let i=t.length;if(this.remainingLength()<i){let e=0;for(;i>0;){await this.flush();const s=Math.min(this.size,i);this.buffer.set(t.subarray(e,e+s),this.pointer),this.pointer+=s,this.pos+=BigInt(s),e+=s,i-=s}}else this.buffer.set(t,this.pointer),this.pointer+=i,this.pos+=BigInt(i)}async writeString(t){const i=r.encode(t);return await this.writeBuffer(i),i.length}async flush(){if(!this.onFlush)throw this.error=-1048574,Error("IOWriter error, flush failed because of no flush callback");if(this.pointer){const t=await this.onFlush(this.buffer.subarray(0,this.pointer));if(0!==t)throw this.error=t,Error("IOWriter error, flush failed")}this.pointer=0}async flushToPos(t){if(!this.onFlush)throw this.error=-1048574,Error("IOWriter error, flush failed because of no flush callback");if(this.pointer){const i=await this.onFlush(this.buffer.subarray(0,this.pointer),t);if(0!==i)throw this.error=i,Error("IOWriter error, flush failed")}this.pointer=0}async seek(t){if(!this.onSeek)throw this.error=-1048574,Error("IOWriter error, seek failed because of no seek callback");await this.flush();const i=await this.onSeek(t);if(0!==i)throw this.error=i,Error("IOWriter error, seek failed");this.pos=t}seekInline(t){const i=this.pointer;this.pointer=Math.max(0,Math.min(this.size,t)),this.pos+=BigInt(this.pointer-i)}skip(t){const i=this.pointer;this.pointer=Math.min(this.size,this.pointer+t),this.pos+=BigInt(this.pointer-i)}back(t){const i=this.pointer;this.pointer=Math.max(0,this.pointer-t),this.pos+=BigInt(this.pointer-i)}getBuffer(){return this.buffer.subarray(0,this.pointer)}setEndian(t){this.littleEndian=!t}reset(){this.pointer=0,this.pos=BigInt(0),this.error=0}getBufferSize(){return this.size}}},35336:(t,i,e)=>{e.d(i,{A:()=>n});var s=e(134),r=e(50011);class n{constructor(t=1048576,i=!0,e){if((0,s.A)(this,"data",void 0),(0,s.A)(this,"buffer",void 0),(0,s.A)(this,"pointer",void 0),(0,s.A)(this,"pos",void 0),(0,s.A)(this,"size",void 0),(0,s.A)(this,"littleEndian",void 0),(0,s.A)(this,"error",void 0),(0,s.A)(this,"onFlush",void 0),(0,s.A)(this,"onSeek",void 0),this.pointer=0,this.pos=BigInt(0),this.size=t,this.littleEndian=!i,this.error=0,e&&e.view)this.size=e.length,this.buffer=e,this.data=e.view;else if(e&&!e.byteOffset)this.size=e.length,this.buffer=e,this.data=new DataView(this.buffer.buffer);else{if(e)throw new Error("not support subarray of ArrayBuffer");this.buffer=new Uint8Array(this.size),this.data=new DataView(this.buffer.buffer)}}writeUint8(t){this.remainingLength()<1&&this.flush(),this.data.setUint8(this.pointer,t),this.pointer++,this.pos++}writeUint16(t){this.remainingLength()<2&&this.flush(),this.data.setUint16(this.pointer,t,this.littleEndian),this.pointer+=2,this.pos+=BigInt(2)}writeUint24(t){this.remainingLength()<3&&this.flush();const i=(16711680&t)>>16,e=(65280&t)>>8,s=255&t;this.littleEndian?(this.writeUint8(s),this.writeUint8(e),this.writeUint8(i)):(this.writeUint8(i),this.writeUint8(e),this.writeUint8(s))}writeUint32(t){this.remainingLength()<4&&this.flush(),this.data.setUint32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}writeUint64(t){this.remainingLength()<8&&this.flush(),this.data.setBigUint64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}writeInt8(t){this.remainingLength()<1&&this.flush(),this.data.setInt8(this.pointer,t),this.pointer++,this.pos++}writeInt16(t){this.remainingLength()<2&&this.flush(),this.data.setInt16(this.pointer,t,this.littleEndian),this.pointer+=2,this.pos+=BigInt(2)}writeInt24(t){this.writeUint24(t<0?t+16777216:t)}writeInt32(t){this.remainingLength()<4&&this.flush(),this.data.setInt32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}writeInt64(t){this.remainingLength()<8&&this.flush(),this.data.setBigInt64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}writeFloat(t){this.remainingLength()<4&&this.flush(),this.data.setFloat32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}writeDouble(t){this.remainingLength()<8&&this.flush(),this.data.setFloat64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}getPointer(){return this.pointer}getPos(){return this.pos}remainingLength(){return this.size-this.pointer}writeBuffer(t){if(!t.length)return;let i=t.length;if(this.remainingLength()<i){let e=0;for(;i>0;){this.flush();const s=Math.min(this.size,i);this.buffer.set(t.subarray(e,e+s),this.pointer),this.pointer+=s,this.pos+=BigInt(s),e+=s,i-=s}}else this.buffer.set(t,this.pointer),this.pointer+=i,this.pos+=BigInt(i)}writeString(t){const i=r.encode(t);return this.writeBuffer(i),i.length}flush(){if(!this.onFlush)throw this.error=-1048574,Error("IOWriter error, flush failed because of no flush callback");if(this.pointer){const t=this.onFlush(this.buffer.subarray(0,this.pointer));if(0!==t)throw this.error=t,Error("IOWriter error, flush failed")}this.pointer=0}flushToPos(t){if(!this.onFlush)throw this.error=-1048574,Error("IOWriter error, flush failed because of no flush callback");if(this.pointer){const i=this.onFlush(this.buffer.subarray(0,this.pointer),t);if(0!==i)throw this.error=i,Error("IOWriter error, flush failed")}this.pointer=0}seek(t){if(!this.onSeek)throw this.error=-1048574,Error("IOWriter error, seek failed because of no seek callback");this.flush();const i=this.onSeek(t);if(0!==i)throw this.error=i,Error("IOWriter error, seek failed");this.pos=t}seekInline(t){const i=this.pointer;this.pointer=Math.max(0,Math.min(this.size,t)),this.pos+=BigInt(this.pointer-i)}skip(t){const i=this.pointer;this.pointer=Math.min(this.size,this.pointer+t),this.pos+=BigInt(this.pointer-i)}back(t){const i=this.pointer;this.pointer=Math.max(0,this.pointer-t),this.pos+=BigInt(this.pointer-i)}getBuffer(){return this.buffer.subarray(0,this.pointer)}setEndian(t){this.littleEndian=!t}reset(){this.pointer=0,this.pos=BigInt(0),this.error=0}getBufferSize(){return this.size}}},8507:(t,i,e)=>{function s(t){const i=t,e=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],s=/:\/\/([^\/@]*@?)\[(\S+)\]/;let r="";s.test(t)&&(t=t.replace(s,((t,i,e)=>(r=e,`://${i||""}a.b`))));const n={},a=/^(?:(?![^:@\/]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@\/]*)(?::([^:@\/]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(t);let h=14;for(;h--;){var o;n[e[h]]=null!==(o=a[h])&&void 0!==o?o:""}return r&&(n.host=r,n.source=i,n.authority=r+(n.port?":"+n.port:"")),{protocol:n.protocol,file:n.file,host:n.host,port:n.port,user:n.user,password:n.password,origin:`${n.protocol}://${n.authority}`,pathname:n.path,search:`?${n.query}`,hash:n.anchor?`#${n.anchor}`:""}}e.d(i,{ll:()=>u,qg:()=>s}),e(73146),e(67672),e(6498),e(72739),e(95335);const r=/(?:\/|^)\.(?=\/)/g,n=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a=/^(?=([^\/?#]*))\1([^]*)$/,h=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/;function o(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}function f(t){const i=h.exec(t);return i?{scheme:i[1]||"",netLoc:i[2]||"",path:i[3]||"",params:i[4]||"",query:i[5]||"",fragment:i[6]||""}:null}function l(t){for(t=t.split("").reverse().join("").replace(r,"");t.length!==(t=t.replace(n,"")).length;);return t.split("").reverse().join("")}function u(t,i,e){if(e=e||{},t=t.trim(),!(i=i.trim())){if(!e.alwaysNormalize)return t;let i=f(t);if(!i)throw new Error("Error trying to parse base URL.");return i.path=l(i.path),o(i)}let s=f(i);if(!s)throw new Error("Error trying to parse relative URL.");if(s.scheme)return e.alwaysNormalize?(s.path=l(s.path),o(s)):i;let r=f(t);if(!r)throw new Error("Error trying to parse base URL.");if(!r.netLoc&&r.path&&"/"!==r.path[0]){let t=a.exec(r.path);r.netLoc=t[1],r.path=t[2]}r.netLoc&&!r.path&&(r.path="/");const n={scheme:r.scheme,netLoc:s.netLoc,path:null,params:s.params,query:s.query,fragment:s.fragment};if(!s.netLoc&&(n.netLoc=r.netLoc,"/"!==s.path[0]))if(s.path){let t=r.path,i=t.substring(0,t.lastIndexOf("/")+1)+s.path;n.path=l(i)}else n.path=r.path,s.params||(n.params=r.params,s.query||(n.query=r.query));return null===n.path&&(n.path=e.alwaysNormalize?l(s.path):s.path),o(n)}},85079:(t,i,e)=>{var s=e(46438),r=s.JSON||(s.JSON={stringify:JSON.stringify});t.exports=function(t){return r.stringify.apply(r,arguments)}},73146:(t,i,e)=>{t.exports=e(85079)}}]);
1
+ (self.webpackChunklibmedia=self.webpackChunklibmedia||[]).push([[543],{58121:(t,i,e)=>{e.d(i,{A:()=>r});var s=e(134);class r{constructor(){(0,s.A)(this,"signature",void 0),(0,s.A)(this,"version",void 0),(0,s.A)(this,"flags",void 0),(0,s.A)(this,"dataOffset",void 0),(0,s.A)(this,"hasVideo",void 0),(0,s.A)(this,"hasAudio",void 0),this.signature="FLV",this.version=1,this.flags=0,this.dataOffset=9,this.hasAudio=!1,this.hasVideo=!1}async read(t){this.signature=await t.readString(3),this.version=await t.readUint8(),this.flags=await t.readUint8(),this.dataOffset=await t.readUint32(),this.hasAudio=!!(4&this.flags),this.hasVideo=!!(1&this.flags)}write(t){this.flags=0,this.hasAudio&&(this.flags|=4),this.hasVideo&&(this.flags|=1),t.writeString(this.signature),t.writeUint8(this.version),t.writeUint8(this.flags),t.writeUint32(this.dataOffset)}}},68243:(t,i,e)=>{e.d(i,{A:()=>u});var s=e(134),r=e(35336),n=e(92647),a=e(4624),h=e(94889),o=e(9705),f=e(73040);class u{constructor(){(0,s.A)(this,"onMetaData",void 0),this.onMetaData={canSeekToEnd:!1}}async read(t,i){const e=t.getPos(),s=e+BigInt(Math.floor(i)),r=await(0,f.$x)(t,s),n=await(0,f.$x)(t,s);this[r]=n,s>t.getPos()&&await t.skip(Number(BigInt.asIntN(32,s-t.getPos())));const h=Number(t.getPos()-e),u=await t.readUint32();return h+11!==u?(a.R8(`script size not match, size: ${h+11}, previousTagSize: ${u}`,"src/avformat/formats/flv/FlvScriptTag.ts",63),o.LR):0}computeSize(){const t=[],i=new r.A;return i.onFlush=i=>(t.push(i.slice()),0),(0,f.bD)(i,"onMetaData"),(0,f.bD)(i,this.onMetaData),i.flush(),(0,n.A)(Uint8Array,t).length}write(t){if(this.onMetaData){const i=[],e=new r.A;e.onFlush=t=>(i.push(t.slice()),0),(0,f.bD)(e,"onMetaData"),(0,f.bD)(e,this.onMetaData),e.flush();const s=(0,n.A)(Uint8Array,i);h.M5(t,18,BigInt(0),void 0,s)}}dts2Position(t){if(this.canSeek()){let i=-1;const e=this.onMetaData.keyframes.times,s=this.onMetaData.keyframes.filepositions;let r;for(r=0;r<e.length;r++){if(e[r]===t){i=r;break}if(e[r]>t){i=Math.max(r-1,0);break}}return r&&r===e.length&&(i=e.length-1),{pos:s[i],dts:e[i]}}return{pos:-1,dts:-1}}position2DTS(t){if(this.canSeek()){let e=-1;const s=this.onMetaData.keyframes.times,r=this.onMetaData.keyframes.filepositions;let n=0;for(n=0;n<r.length;n++)if(r[n]>t){e=n;break}var i;return n===r.length?null!==(i=this.onMetaData.duration)&&void 0!==i?i:s[s.length-1]:s[e]}return-1}canSeek(){return!!(this.onMetaData.keyframes&&this.onMetaData.keyframes.filepositions&&this.onMetaData.keyframes.filepositions.length)}}},35028:(t,i,e)=>{e.d(i,{FJ:()=>s,U5:()=>r});const s={10:86018,2:86017,11:86051,1:69645,4:86049,5:86049,6:86049,7:65543,8:65542},r={7:27,12:173,9:12,2:4,3:86,4:92,5:106,6:131}},94889:(t,i,e)=>{e.d(i,{M5:()=>n}),e(35028),e(44328),e(77231),e(65977);var s=e(67672);function r(t,i,e){const s=t.getPos(),r=t.getPointer(),n=s-BigInt(Math.floor(r));i<s&&i>=n?(t.seekInline(r+Number(i-s)),t.writeUint24(e),t.seekInline(r)):(t.seek(i),t.writeUint24(e),t.seek(s))}function n(t,i,e,n,a,h){t.flush(),t.writeUint8(i);const o=t.getPos();t.writeUint24(0),t.writeUint24(Number(e&BigInt(16777215))),t.writeUint8(Number(e>>BigInt(24)&BigInt(255))),t.writeUint24(0);const f=t.getPos();n&&n(t),s.Pc(a)?(a(t),r(t,o,Number(t.getPos()-f))):a&&(r(t,o,a.length+Number(t.getPos()-f)),t.writeBuffer(a));const u=Number(t.getPos()-o)+1;h&&h(u),t.writeUint32(u)}},65977:(t,i,e)=>{e.d(i,{A:()=>n});var s=e(4624);const r="src/avformat/function/mktag.ts";function n(t){4!==t.length&&s.R8(`tag length is not 4, tag: ${t}`,r,30);let i=0;for(let e=0;e<4;e++)i=i<<8|t.charCodeAt(e);return i}},67543:(t,i,e)=>{e.r(i),e.d(i,{default:()=>b});var s=e(134),r=e(36773),n=e(14619),a=e(42383),h=e(82058),o=e(24175),f=e(34531),u=e(8507),l=e(35336),d=e(58121),p=e(68243),c=e(31865),w=e(73040),g=e(34677);class b extends r.A{constructor(...t){super(...t),(0,s.A)(this,"info",void 0),(0,s.A)(this,"socket",void 0),(0,s.A)(this,"session",void 0),(0,s.A)(this,"ioReader",void 0),(0,s.A)(this,"ioWriter",void 0),(0,s.A)(this,"flvWriter",void 0),(0,s.A)(this,"flvHeader",void 0),(0,s.A)(this,"packetQueue",void 0),(0,s.A)(this,"flvHeaderWrote",void 0),(0,s.A)(this,"hasMetadata",void 0),(0,s.A)(this,"bufferReader",void 0)}writeFlvData(t){this.flvWriter.writeUint8(t.type),this.flvWriter.writeUint24(t.payload.length),this.flvWriter.writeUint24(t.timestamp),this.flvWriter.writeUint8(t.timestamp>>24),this.flvWriter.writeUint24(0),this.flvWriter.writeBuffer(t.payload),this.flvWriter.writeUint32(t.payload.length+11),this.flvWriter.flush()}async handleRtmpPacket(t){if(this.flvHeaderWrote)this.writeFlvData(t);else{if(this.packetQueue.push(t),8===t.type)this.flvHeader.hasAudio=!0;else if(9===t.type)this.flvHeader.hasVideo=!0;else if(18===t.type&&(this.bufferReader?this.bufferReader.resetBuffer(t.payload):this.bufferReader=new c.A(t.payload),"onMetaData"===await w.$x(this.bufferReader,BigInt(t.payload.length)))){this.hasMetadata=!0;const i=await w.$x(this.bufferReader,BigInt(t.payload.length));this.flvHeader.hasAudio=(0,g.A)(i.audiocodecid),this.flvHeader.hasVideo=(0,g.A)(i.videocodecid)}if(this.packetQueue.length>10||this.hasMetadata){if(this.flvHeader.write(this.flvWriter),this.flvWriter.writeUint32(0),!this.hasMetadata&&this.session.getDuration()){const t=new p.A;t.onMetaData={duration:this.session.getDuration()},t.write(this.flvWriter)}this.packetQueue.forEach((t=>{this.writeFlvData(t)})),this.packetQueue.length=0,this.flvHeaderWrote=!0}}}async send(t){return this.socket?(await this.socket.send(t),0):-1048574}async open(t){this.info=t,this.status=1,3===t.subProtocol?(this.socket=new a.A(this.options),await this.socket.open({url:t.url,webtransportOptions:t.webtransportOptions})):(this.socket=new n.A(this.options),await this.socket.open({url:t.url})),this.ioReader=new o.A,this.ioReader.onFlush=async t=>this.socket.read(t),this.ioReader.onSeek=async t=>this.socket.seek(t),this.ioReader.onSize=async()=>this.socket.size(),this.ioWriter=new f.A,this.ioWriter.onFlush=async t=>this.socket.write(t),this.ioWriter.onSeek=async t=>this.socket.seek(t),this.flvWriter=new l.A,this.flvWriter.onFlush=t=>(this.readQueue.push(t.slice()),this.consume&&this.consume(),0),this.flvHeader=new d.A,this.packetQueue=[],this.flvHeaderWrote=!1,this.hasMetadata=!1,this.session=new h.A(this.ioReader,this.ioWriter,{isLive:this.options.isLive,isPull:!0}),this.session.onMediaPacket=async(t,i)=>this.handleRtmpPacket(t),this.session.onError=()=>{this.status=3,this.consume&&this.consume()},await this.session.handshake();const i=u.qg(this.info.uri),e=i.pathname.split("/");await this.session.connect(e[1],`rtmp://${i.host}${i.port?":"+i.port:""}/${e[1]}`);const s=e.slice(2);return this.session.play((s.length>1?s.join("/"):s[0])||""),0}async seek(t){return await this.session.seek(Number(t)),0}async size(){return BigInt(0)}async stop(){this.socket&&(await this.socket.stop(),this.socket=null),this.status=4}}},46084:(t,i,e)=>{e.d(i,{u:()=>r});var s=e(134);class r{constructor(t,i,e,r){(0,s.A)(this,"channelId",void 0),(0,s.A)(this,"type",void 0),(0,s.A)(this,"timestamp",void 0),(0,s.A)(this,"tsField",0),(0,s.A)(this,"extra",0),(0,s.A)(this,"payload",void 0),this.channelId=t,this.type=i,this.timestamp=e,this.payload=r instanceof Uint8Array?r:new Uint8Array(r)}}},82058:(t,i,e)=>{e.d(i,{A:()=>U});var s=e(134),r=e(80662),n=e.n(r),a=e(54001),h=e.n(a),o=e(46084),f=e(90519),u=e(86932),l=e(729),d=e(68680),p=e(73040),c=e(98951),w=e(31865),g=e(4624),b=e(72739),y=e(67672),m=e(13724),k=e(83229);const v="src/avprotocol/rtmp/RtmpSession.ts";class U{constructor(t,i,e){(0,s.A)(this,"ioReader",void 0),(0,s.A)(this,"ioWriter",void 0),(0,s.A)(this,"prevReadPacket",void 0),(0,s.A)(this,"prevWritePacket",void 0),(0,s.A)(this,"inChunkSize",void 0),(0,s.A)(this,"outChunkSize",void 0),(0,s.A)(this,"seq",void 0),(0,s.A)(this,"bufferWriter",void 0),(0,s.A)(this,"bufferReader",void 0),(0,s.A)(this,"requestMap",void 0),(0,s.A)(this,"state",void 0),(0,s.A)(this,"maxSentUnacked",void 0),(0,s.A)(this,"receiveReportSize",void 0),(0,s.A)(this,"duration",void 0),(0,s.A)(this,"options",void 0),(0,s.A)(this,"streamIdMap",void 0),(0,s.A)(this,"sendAsync",void 0),(0,s.A)(this,"onMediaPacket",void 0),(0,s.A)(this,"onError",void 0),this.ioReader=t,this.ioWriter=i,this.options=e,this.prevReadPacket=new(n()),this.prevWritePacket=new(n()),this.requestMap=new(n()),this.streamIdMap=new(n()),this.inChunkSize=128,this.outChunkSize=128,this.seq=0,this.maxSentUnacked=25e5,this.receiveReportSize=1048576,this.sendAsync=new k.an,this.bufferWriter=new l.A(new Uint8Array(1)),this.bufferReader=new w.A(new Uint8Array(1)),this.state=0}async handshake(){const t=(0,u.A)();await this.ioWriter.writeUint8(3),await this.ioWriter.writeUint32(0),await this.ioWriter.writeUint32(0);const i=new Uint8Array(1528);f.y(i),await this.ioWriter.writeBuffer(i),await this.ioWriter.flush(),await this.ioReader.readUint8();const e=await this.ioReader.readUint32();await this.ioReader.skip(4);const s=await this.ioReader.readBuffer(1528);await this.ioWriter.writeUint32(e),await this.ioWriter.writeUint32((0,u.A)()-t),await this.ioWriter.writeBuffer(s),await this.ioWriter.flush(),await this.ioReader.skip(1536),this.readRtmpPacket()}async sendPacket(t){await(0,k.s2)(this.sendAsync),await(0,c.U)(this.ioWriter,this.outChunkSize,t,this.prevWritePacket.get(t.channelId)),this.prevWritePacket.set(t.channelId,t),(0,k.Tl)(this.sendAsync)}async readPacket(){const t=await(0,c.w)(this.ioReader,this.inChunkSize,this.prevReadPacket);return this.prevReadPacket.set(t.channelId,t),t}handleChunkSize(t){t.payload.length>=4&&(this.bufferReader.resetBuffer(t.payload),this.inChunkSize=this.bufferReader.readUint32())}handleUserControl(t){t.payload.length>=2&&(this.bufferReader.resetBuffer(t.payload),6===this.bufferReader.readUint16()&&this.sendPong(t,this.bufferReader.readUint32()))}handleSetPeerBW(t){t.payload.length>=4&&(this.bufferReader.resetBuffer(t.payload),this.maxSentUnacked=this.bufferReader.readUint32(),g.Yz(`Max sent, unacked = ${this.maxSentUnacked}`,v,205))}handleWindowSizeACK(t){t.payload.length>=4&&(this.bufferReader.resetBuffer(t.payload),this.receiveReportSize=this.bufferReader.readUint32(),g.Yz(`Window acknowledgement size = ${this.receiveReportSize}`,v,212),this.receiveReportSize>>=1)}async handleInvoke(t){this.bufferReader.resetBuffer(t.payload);const i=BigInt(t.payload.length),e=await p.$x(this.bufferReader,i),s=await p.$x(this.bufferReader,i);if("_result"===e||"_error"===e){if(this.requestMap.has(s)){const t=await p.$x(this.bufferReader,i),r=await p.$x(this.bufferReader,i);"_result"===e?this.requestMap.get(s).resolve({options:t,info:r}):this.requestMap.get(s).reject({options:t,info:r}),this.requestMap.delete(s)}}else if("onStatus"===e){const t=await p.$x(this.bufferReader,i);let e=await p.$x(this.bufferReader,i);if("error"===e.level)g.z3(`Server error: ${e.description}, ${e.code}`,v,248),this.requestMap.has(s)?(this.requestMap.get(s).reject({options:t,info:e}),this.requestMap.delete(s)):this.onError&&this.onError();else{switch(e.code){case"NetStream.Play.Start":case"NetStream.Seek.Notify":this.state=3;break;case"NetStream.Play.Stop":case"NetStream.Play.UnpublishNotify":this.state=8;break;case"NetStream.Publish.Start":this.state=5}this.requestMap.has(s)&&(this.requestMap.get(s).resolve({options:t,info:e}),this.requestMap.delete(s))}}else"onBWDone"===e&&await this.sendCheckBW()}async handleNotify(t){this.bufferReader.resetBuffer(t.payload),"@setDataFrame"===await p.$x(this.bufferReader,BigInt(t.payload.length))&&(t.payload=t.payload.subarray(Number(this.bufferReader.getPos()))),t.payload.length&&this.onMediaPacket&&await this.onMediaPacket(t,this.streamIdMap.get(t.extra))}async readRtmpPacket(){for(;;)try{const t=await this.readPacket();switch(t.type){case 3:default:break;case 1:this.handleChunkSize(t);break;case 4:this.handleUserControl(t);break;case 6:this.handleSetPeerBW(t);break;case 5:this.handleWindowSizeACK(t);break;case 20:await this.handleInvoke(t);break;case 18:await this.handleNotify(t);break;case 22:case 8:case 9:this.onMediaPacket&&await this.onMediaPacket(t,this.streamIdMap.get(t.extra))}}catch(t){break}}async sendPong(t,i){if(t.payload.length<6)return void g.R8(`Too short ping packet (${t.payload.length})`,v,348);const e=new o.u(2,4,t.timestamp+1,6);this.bufferWriter.resetBuffer(e.payload),this.bufferWriter.writeUint16(7),this.bufferWriter.writeUint32(i),this.sendPacket(e)}async sendWindowAckSize(){const t=new o.u(2,5,0,4);this.bufferWriter.resetBuffer(t.payload),this.bufferWriter.writeUint32(this.maxSentUnacked),await this.sendPacket(t)}async sendBufferTime(t){const i=new o.u(2,4,1,10);this.bufferWriter.resetBuffer(i.payload),this.bufferWriter.writeUint16(3),this.bufferWriter.writeUint32(t),this.bufferWriter.writeUint32(this.options.clientBufferTime||3e3),await this.sendPacket(i)}async sendFCSubscribe(t){const i=new o.u(3,20,0,27+t.length);this.bufferWriter.resetBuffer(i.payload),p.bD(this.bufferWriter,"FCSubscribe"),p.bD(this.bufferWriter,++this.seq),p.bD(this.bufferWriter,null),p.bD(this.bufferWriter,t),await this.sendPacket(i)}async sendFCPublish(t){const i=new o.u(3,20,0,25+t.length);this.bufferWriter.resetBuffer(i.payload),p.bD(this.bufferWriter,"FCPublish"),p.bD(this.bufferWriter,++this.seq),p.bD(this.bufferWriter,null),p.bD(this.bufferWriter,t),await this.sendPacket(i)}async sendReleaseStream(t){const i=new o.u(3,20,0,29+t.length);this.bufferWriter.resetBuffer(i.payload),p.bD(this.bufferWriter,"releaseStream"),p.bD(this.bufferWriter,++this.seq),p.bD(this.bufferWriter,null),p.bD(this.bufferWriter,t),await this.sendPacket(i)}async sendCheckBW(){const t=new o.u(3,20,0,21);this.bufferWriter.resetBuffer(t.payload),p.bD(this.bufferWriter,"_checkbw"),p.bD(this.bufferWriter,++this.seq),p.bD(this.bufferWriter,null),await this.sendPacket(t)}async request(t,i){const e=new o.u(3,20,0,4096+d.iD);return this.bufferWriter.resetBuffer(e.payload),p.bD(this.bufferWriter,t),p.bD(this.bufferWriter,++this.seq),b.__(i,(t=>{p.bD(this.bufferWriter,t)})),e.payload=e.payload.subarray(0,this.bufferWriter.getPos()),new(h())(((t,i)=>{this.requestMap.set(this.seq,{resolve:t,reject:i}),this.sendPacket(e)}))}async connect(t,i){await this.request("connect",[{app:t,fourCcList:["hvc1","av01","vp09"],flashVer:"LNX 9,0,124,2",tcUrl:i,fpad:0,capabilities:15,audioCodecs:4071,videoCodecs:252,videoFunction:1}]),this.options.isPull&&await this.sendWindowAckSize()}async createStream(){return(await this.request("createStream",[null])).info}async play(t){const i=await this.createStream();if(this.streamIdMap.set(i,t),!this.options.isLive){const i=await h().race([this.request("getStreamLength",[null,t]),new m.A(1)]);y.ai(i)||(this.duration=i.info)}await this.sendFCSubscribe(t),this.request("play",[null,t,-1,-1,!0]),await this.sendBufferTime(i)}async publish(t){await this.sendReleaseStream(t),await this.sendFCPublish(t);const i=await this.createStream();this.streamIdMap.set(i,t),await this.request("publish",[null,t,"live"])}async sendStreamPacket(t,i){let e=0;this.streamIdMap.forEach(((t,s)=>{t===i&&(e=s)})),t.extra=e,await this.sendPacket(t)}async seek(t){const i=new o.u(3,20,0,26);this.bufferWriter.resetBuffer(i.payload),p.bD(this.bufferWriter,"seek"),p.bD(this.bufferWriter,0),p.bD(this.bufferWriter,null),p.bD(this.bufferWriter,t),await this.sendPacket(i)}async pause(t,i){const e=new o.u(3,20,0,29);this.bufferWriter.resetBuffer(e.payload),p.bD(this.bufferWriter,"pause"),p.bD(this.bufferWriter,0),p.bD(this.bufferWriter,null),p.bD(this.bufferWriter,t),p.bD(this.bufferWriter,i),await this.sendPacket(e)}getDuration(){return this.duration}}},68680:(t,i,e)=>{e.d(i,{iD:()=>s});const s=1024},98951:(t,i,e)=>{e.d(i,{U:()=>o,w:()=>f});var s=e(46084),r=e(92647),n=e(4624);const a="src/avprotocol/rtmp/util.ts";async function h(t,i,e){if(i<64)await t.writeUint8(i|e<<6);else if(i<320)await t.writeUint8(e<<6),await t.writeUint8(i-64);else{await t.writeUint8(1|e<<6);const s=i-64;await t.writeUint8(255&s),await t.writeUint8(s>>>8)}}async function o(t,i,e,s){const r=s&&s.extra===e.extra&&e.timestamp>=s.timestamp;let n=e.timestamp;r&&(n-=s.timestamp),e.tsField=n>16777215?16777215:n;let a=0;r&&(e.type===s.type&&e.payload.length===s.payload.length?(a=2,e.tsField===s.tsField&&(a=3)):a=1),await h(t,e.channelId,a),3!==a&&(await t.writeUint24(e.tsField),2!==a&&(await t.writeUint24(e.payload.length),await t.writeUint8(e.type),0===a&&(await t.writeUint8(e.extra),await t.writeUint8(e.extra>>8),await t.writeUint8(e.extra>>16),await t.writeUint8(e.extra>>24)))),16777215===e.tsField&&await t.writeUint32(n);let o=0;for(;o<e.payload.length;){const s=Math.min(i,e.payload.length-o);await t.writeBuffer(e.payload.subarray(o,o+s)),o+=s,o<e.payload.length&&(await h(t,e.channelId,3),16777215===e.tsField&&await t.writeUint32(n))}await t.flush()}async function f(t,i,e){const h=[],o=await t.readUint8();let f=63&o;f<2&&(f=0===await t.readUint8()?await t.readUint8()+64:64+(await t.readUint8()|await t.readUint8()<<8));const u=o>>>6,l=e.get(f);let d=l?l.payload.length:0,p=l?l.type:0,c=l?l.extra:0,w=0,g=0;if(3===u?w=l.tsField:(w=await t.readUint24(),2!==u&&(d=await t.readUint24(),p=await t.readUint8(),0===u&&(c=await t.readUint8(),c|=await t.readUint8()<<8,c|=await t.readUint8()<<16,c|=await t.readUint8()<<24))),g=16777215===w?await t.readUint32():w,0!==u&&(l?g+=l.timestamp:n.R8(`got invalid message fmt, channel id ${f} can not find prev message with fmt ${u}`,a,171)),d<i)h.push(await t.readBuffer(d));else{let e=d;for(;e;){const s=Math.min(i,e);if(h.push(await t.readBuffer(s)),e-=s,e){const i=63&await t.readUint8();i<2&&await t.skip(i+1),16777215===w&&await t.skip(4)}}}const b=new s.u(f,p,g,(0,r.A)(Uint8Array,h));return b.tsField=w,b.extra=c,b}},77231:(t,i,e)=>{e.d(i,{Dh:()=>r,FQ:()=>d,H3:()=>o,KR:()=>u,N_:()=>n,SF:()=>a,WT:()=>f,f7:()=>w,go:()=>p,i0:()=>l,qs:()=>h,zg:()=>c});var s=e(9599);const r=-BigInt(1),n=-1,a=1e6,h=1e3,o=1e9,f=BigInt(2208988800)*BigInt(1e6),u=new s.P({den:a,num:1}),l=new s.P({den:h,num:1}),d=new s.P({den:o,num:1}),p=(new s.P({den:1,num:1}),2147483647),c=65535,w=4294967295},9599:(t,i,e)=>{e.d(i,{P:()=>u});var s,r,n=e(134),a=e(80662),h=e.n(a),o=e(61499),f=e(12085);class u{constructor(t){(0,n.A)(this,"num",1),(0,n.A)(this,"den",1),t&&(this.den=t.den,this.num=t.num)}}s=u.prototype,(r=new(h())).set("num",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0}),r.set("den",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:4,8:0}),(0,f.A)(s,o.Og,!0),(0,f.A)(s,o.dc,4),(0,f.A)(s,o.g7,8),(0,f.A)(s,o.JY,r)},73040:(t,i,e)=>{e.d(i,{$x:()=>h,bD:()=>o});var s=e(67672),r=e(72739),n=e(95335);async function a(t,i){return{key:await t.readString(await t.readUint16()),value:await h(t,i)}}async function h(t,i){let e;switch(await t.readUint8()){case 0:e=await t.readDouble();break;case 1:e=!!await t.readUint8();break;case 2:e=await t.readString(await t.readUint16());break;case 3:for(e={};t.getPos()<i;){const{key:s,value:r}=await a(t,i);if(e[s]=r,9==(16777215&await t.peekUint24())){await t.skip(3);break}}break;case 8:for(e={},await t.skip(4);t.getPos()<i;){const{key:s,value:r}=await a(t,i);if(e[s]=r,9==(16777215&await t.peekUint24())){await t.skip(3);break}}break;case 9:case 5:e=null;break;case 10:e=[];const s=await t.readUint32();for(let r=0;r<s;r++)e.push(await h(t,i));break;case 11:const r=await t.readDouble(),n=await t.readInt16();e=new Date(r+60*n*1e3);break;case 12:e=await t.readString(await t.readUint32())}return e}function o(t,i){s.ai(i)?(t.writeUint8(0),t.writeDouble(i)):s.o(i)?(t.writeUint8(0),t.writeDouble(Number(i))):s.zM(i)?(t.writeUint8(1),t.writeUint8(i?1:0)):s.Yj(i)?i.length>=65536?(t.writeUint8(12),t.writeUint32(i.length),t.writeString(i)):(t.writeUint8(2),t.writeUint16(i.length),t.writeString(i)):s.YO(i)?(t.writeUint8(10),t.writeUint32(i.length),r.__(i,(i=>{o(t,i)}))):s.Ik(i)?(t.writeUint8(3),n.__(i,((i,e)=>{t.writeUint16(e.length),t.writeString(e),o(t,i)})),t.writeUint24(9)):i instanceof Date?(t.writeUint8(11),t.writeDouble(i.getTime()),t.writeInt16(0)):null==i&&t.writeUint8(5)}},90519:(t,i,e)=>{function s(t){crypto.getRandomValues(t)}e.d(i,{y:()=>s})},44328:(t,i,e)=>{e.d(i,{FP:()=>o,Mr:()=>h,iU:()=>l,j2:()=>u,k:()=>a,lb:()=>f});var s=e(63939),r=e(77231),n=e(31658);function a(t,i,e){return t*BigInt(i.num)*BigInt(e.den)/(BigInt(i.den)*BigInt(e.num))}function h(t,i,e){return t*BigInt(s.f[15](i))*BigInt(e.den)/(BigInt(s.f[15](i+4))*BigInt(e.num))}function o(t,i,e){return t*BigInt(i.num)*BigInt(s.f[15](e+4))/(BigInt(i.den)*BigInt(s.f[15](e)))}function f(t){return t.num/t.den}function u(t,i){if(isNaN(19))return{den:0,num:0};if(Math.abs(t)>r.go+3)return{den:0,num:t<0?-1:1};const e=t>1?{den:Math.floor(i/t+.5),num:i}:{den:i,num:Math.floor(t*i+.5)};return l(e),e}function l(t){const i=(0,n.A)(t.num,t.den);i<=1||(t.den/=i,t.num/=i)}},83229:(t,i,e)=>{e.d(i,{Tl:()=>o,an:()=>a,s2:()=>h});var s=e(134),r=e(54001),n=e.n(r);class a{constructor(){(0,s.A)(this,"list",[])}}async function h(t){return new(n())((i=>{t.list.push(i),1===t.list.length&&i()}))}function o(t){t.list.shift(),t.list.length&&t.list[0]()}},6498:(t,i,e)=>{e(67672),e(72739)},24175:(t,i,e)=>{e.d(i,{A:()=>o});var s=e(134),r=e(4624),n=e(50011),a=e(13724);const h="src/common/io/IOReader.ts";class o{constructor(t=1048576,i=!0,e){if((0,s.A)(this,"data",void 0),(0,s.A)(this,"buffer",void 0),(0,s.A)(this,"pointer",void 0),(0,s.A)(this,"endPointer",void 0),(0,s.A)(this,"pos",void 0),(0,s.A)(this,"size",void 0),(0,s.A)(this,"littleEndian",void 0),(0,s.A)(this,"fileSize_",void 0),(0,s.A)(this,"error",void 0),(0,s.A)(this,"onFlush",void 0),(0,s.A)(this,"onSeek",void 0),(0,s.A)(this,"onSize",void 0),(0,s.A)(this,"flags",void 0),this.pos=BigInt(0),this.pointer=0,this.error=0,this.endPointer=0,this.littleEndian=!i,this.flags=0,e&&e.view)this.size=e.length,this.buffer=e,this.data=e.view;else if(e&&!e.byteOffset)this.size=e.length,this.buffer=e,this.data=new DataView(this.buffer.buffer);else{if(e)throw new Error("not support subarray of ArrayBuffer");this.size=Math.max(t,102400),this.buffer=new Uint8Array(this.size),this.data=new DataView(this.buffer.buffer)}}async readUint8(){this.remainingLength()<1&&await this.flush(1);const t=this.data.getUint8(this.pointer);return this.pointer++,this.pos++,t}async peekUint8(){return this.remainingLength()<1&&await this.flush(1),this.data.getUint8(this.pointer)}async readUint16(){this.remainingLength()<2&&await this.flush(2);const t=this.data.getUint16(this.pointer,this.littleEndian);return this.pointer+=2,this.pos+=BigInt(2),t}async peekUint16(){return this.remainingLength()<2&&await this.flush(2),this.data.getUint16(this.pointer,this.littleEndian)}async readUint24(){this.remainingLength()<3&&await this.flush(3);const t=await this.readUint16(),i=await this.readUint8();return this.littleEndian?i<<16|t:t<<8|i}async peekUint24(){this.remainingLength()<3&&await this.flush(3);const t=this.pointer,i=this.pos,e=await this.readUint16(),s=await this.readUint8(),r=this.littleEndian?s<<16|e:e<<8|s;return this.pointer=t,this.pos=i,r}async readUint32(){this.remainingLength()<4&&await this.flush(4);const t=this.data.getUint32(this.pointer,this.littleEndian);return this.pointer+=4,this.pos+=BigInt(4),t}async peekUint32(){return this.remainingLength()<4&&await this.flush(4),this.data.getUint32(this.pointer,this.littleEndian)}async readUint64(){this.remainingLength()<8&&await this.flush(8);const t=this.data.getBigUint64(this.pointer,this.littleEndian);return this.pointer+=8,this.pos+=BigInt(8),t}async peekUint64(){return this.remainingLength()<8&&await this.flush(8),this.data.getBigUint64(this.pointer,this.littleEndian)}async readInt8(){this.remainingLength()<1&&await this.flush(1);const t=this.data.getInt8(this.pointer);return this.pointer++,this.pos++,t}async peekInt8(){return this.remainingLength()<1&&await this.flush(1),this.data.getInt8(this.pointer)}async readInt16(){this.remainingLength()<2&&await this.flush(2);const t=this.data.getInt16(this.pointer,this.littleEndian);return this.pointer+=2,this.pos+=BigInt(2),t}async peekInt16(){return this.remainingLength()<2&&await this.flush(2),this.data.getInt16(this.pointer,this.littleEndian)}async readInt24(){const t=await this.readUint24();return 8388608&t?t-16777216:t}async peekInt24(){const t=await this.peekUint24();return 8388608&t?t-16777216:t}async readInt32(){this.remainingLength()<4&&await this.flush(4);const t=this.data.getInt32(this.pointer,this.littleEndian);return this.pointer+=4,this.pos+=BigInt(4),t}async peekInt32(){return this.remainingLength()<4&&await this.flush(4),this.data.getInt32(this.pointer,this.littleEndian)}async readInt64(){this.remainingLength()<8&&await this.flush(8);const t=this.data.getBigInt64(this.pointer,this.littleEndian);return this.pointer+=8,this.pos+=BigInt(8),t}async peekInt64(){return this.remainingLength()<8&&await this.flush(8),this.data.getBigInt64(this.pointer,this.littleEndian)}async readFloat(){this.remainingLength()<4&&await this.flush(4);const t=this.data.getFloat32(this.pointer,this.littleEndian);return this.pointer+=4,this.pos+=BigInt(4),t}async peekFloat(){return this.remainingLength()<4&&await this.flush(4),this.data.getFloat32(this.pointer,this.littleEndian)}async readDouble(){this.remainingLength()<8&&await this.flush(8);const t=this.data.getFloat64(this.pointer,this.littleEndian);return this.pointer+=8,this.pos+=BigInt(8),t}async peekDouble(){return this.remainingLength()<8&&await this.flush(8),this.data.getFloat64(this.pointer,this.littleEndian)}async readHex(t=1){let i="";for(let e=0;e<t;e++){const t=(await this.readUint8()).toString(16);i+=1===t.length?"0"+t:t}return i}async peekHex(t=1){t>this.size&&(this.error=-1048574,r.h2("peekHex, length too large",h,414)),this.remainingLength()<t&&await this.flush(t);const i=this.pointer,e=this.pos;let s="";for(let i=0;i<t;i++){const t=(await this.readUint8()).toString(16);s+=1===t.length?"0"+t:t}return this.pointer=i,this.pos=e,s}async readBuffer(t,i){if(i||(i=new Uint8Array(t)),this.remainingLength()<t){let e=0;if(this.remainingLength()>0){const s=this.remainingLength();i.set(this.buffer.subarray(this.pointer,this.pointer+s),e),e+=s,this.pointer+=s,this.pos+=BigInt(s),t-=s}for(;t>0;){await this.flush();const s=Math.min(this.endPointer-this.pointer,t);i.set(this.buffer.subarray(this.pointer,this.pointer+s),e),e+=s,this.pointer+=s,this.pos+=BigInt(s),t-=s}}else i.set(this.buffer.subarray(this.pointer,this.pointer+t),0),this.pointer+=t,this.pos+=BigInt(t);return i}async peekBuffer(t,i){return t>this.size&&(this.error=-1048574,r.h2("peekBuffer, length too large",h,499)),this.remainingLength()<t&&await this.flush(t),i||(i=new Uint8Array(t)),i.set(this.buffer.subarray(this.pointer,this.pointer+t),0),i}async readToBuffer(t,i){if(this.remainingLength()<t){let e=0;if(this.remainingLength()>0){const s=this.remainingLength();i.set(this.buffer.subarray(this.pointer,this.pointer+s),e),e+=s,this.pointer+=s,this.pos+=BigInt(s),t-=s}for(;t>0;){try{await this.flush()}catch(t){if(-1048576===this.error&&e)return e;throw t}const s=Math.min(this.endPointer-this.pointer,t);i.set(this.buffer.subarray(this.pointer,this.pointer+s),e),e+=s,this.pointer+=s,this.pos+=BigInt(s),t-=s}return e}return i.set(this.buffer.subarray(this.pointer,this.pointer+t),0),this.pointer+=t,this.pos+=BigInt(t),t}async readString(t=1){const i=await this.readBuffer(t);return n.decode(i)}async peekString(t=1){const i=await this.peekBuffer(t);return n.decode(i)}async readLine(){let t="";for(;;){let i=!1;for(let e=this.pointer;e<this.endPointer;e++)if(10===this.buffer[e]||13===this.buffer[e]){e!==this.pointer&&(t+=await this.readString(e-this.pointer)),i=!0;break}if(i)break;t+=await this.readString(this.remainingLength()),await this.flush()}let i=await this.peekUint8();return 10!==i&&13!==i||(this.pointer++,13===i&&(i=await this.peekUint8(),10===i&&this.pointer++)),t}async peekLine(){if(this.remainingLength()<this.size)try{await this.flush()}catch(t){if(-1048576!==this.error)throw t}let t="",i=!1;for(let e=this.pointer;e<this.endPointer;e++)if(10===this.buffer[e]||13===this.buffer[e]){t+=await this.peekString(e-this.pointer),i=!0;break}return i||(this.error=-1048574,r.h2("peekLine, out of buffer",h,657)),t}getPointer(){return this.pointer}getPos(){return this.pos}async skip(t){const i=t;for(;this.remainingLength()<t;)t-=this.remainingLength(),this.pointer=this.endPointer,await this.flush();this.remainingLength()>=t&&(this.pointer+=t),this.pos+=BigInt(i)}remainingLength(){return this.endPointer-this.pointer}async flush_(t){for(;;){const i=await this.onFlush(t);if(-1048575!==i)return i;await new a.A(0)}}async flush(t=0){if(this.onFlush||(this.error=-1048574,r.h2("IOReader error, flush failed because of no flush callback",h,731)),!(this.size-this.remainingLength()<=0)){if(t=Math.min(t,this.size),this.pointer<this.endPointer?(this.buffer.set(this.buffer.subarray(this.pointer,this.endPointer),0),this.endPointer=this.endPointer-this.pointer):this.endPointer=0,this.pointer=0,t)for(;this.remainingLength()<t;){const t=await this.flush_(this.buffer.subarray(this.endPointer));if(t<0)throw this.error=t,new Error(`IOReader error, flush ${-1048576===t?"ended":"failed"}, ret: ${t}`);this.endPointer+=t}else{const t=await this.flush_(this.buffer.subarray(this.endPointer));if(t<0)throw this.error=t,new Error(`IOReader error, flush ${-1048576===t?"ended":"failed"}, ret: ${t}`);this.endPointer+=t}this.error=0}}async seek(t,i=!1,e=!0){if(!i){const i=Number(t-this.pos);if(i<0&&Math.abs(i)<this.pointer)return this.pointer+=i,void(this.pos=t);if(i>0&&this.pointer+i<this.endPointer)return this.pointer+=i,void(this.pos=t);if(0===i)return}this.onSeek||(this.error=-1048574,r.h2("IOReader error, seek failed because of no seek callback",h,802)),this.pointer=this.endPointer=0,this.pos=t;const s=await this.onSeek(t);0!==s&&(this.error=s,r.h2("IOReader error, seek failed",h,811)),e&&await this.flush()}getBuffer(){return this.buffer}appendBuffer(t){if(this.size-this.endPointer>=t.length)this.buffer.set(t,this.endPointer),this.endPointer+=t.length;else if(this.buffer.set(this.buffer.subarray(this.pointer,this.endPointer),0),this.endPointer=this.endPointer-this.pointer,this.pointer=0,this.size-this.endPointer>=t.length)this.buffer.set(t,this.endPointer),this.endPointer+=t.length;else{const i=Math.min(this.size-this.endPointer,t.length);this.buffer.set(t.subarray(0,i),this.endPointer),this.endPointer+=i,r.R8("IOReader, call appendBuffer but the buffer's size is lagger then the remaining size",h,849)}}reset(){this.pointer=this.endPointer=0,this.pos=BigInt(0),this.error=0}setEndian(t){this.littleEndian=!t}async fileSize(){if(this.fileSize_)return this.fileSize_;if(!this.onSize)return r.R8("IOReader error, fileSize failed because of no onSize callback",h,882),BigInt(0);try{this.fileSize_=await this.onSize()}catch(t){r.R8(`IOReader error, call fileSize failed: ${t}`,h,889),this.fileSize_=BigInt(0)}return this.fileSize_}getBufferSize(){return this.size}async pipe(t,i){if(i)if(this.remainingLength()<i){if(this.remainingLength()>0){const e=this.remainingLength();await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+e)),this.pointer+=e,this.pos+=BigInt(e),i-=e}for(;i>0;){await this.flush();const e=Math.min(this.remainingLength(),i);await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+e)),this.pointer+=e,this.pos+=BigInt(e),i-=e}}else await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+i)),this.pointer+=i,this.pos+=BigInt(i);else{if(this.remainingLength()>0){const i=this.remainingLength();await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+i)),this.pointer+=i,this.pos+=BigInt(i)}for(;await this.flush_(this.buffer.subarray(0))>0;){const i=this.remainingLength();await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+i)),this.pointer+=i,this.pos+=BigInt(i)}}}}},34531:(t,i,e)=>{e.d(i,{A:()=>n});var s=e(134),r=e(50011);class n{constructor(t=1048576,i=!0,e){if((0,s.A)(this,"data",void 0),(0,s.A)(this,"buffer",void 0),(0,s.A)(this,"pointer",void 0),(0,s.A)(this,"pos",void 0),(0,s.A)(this,"size",void 0),(0,s.A)(this,"littleEndian",void 0),(0,s.A)(this,"error",void 0),(0,s.A)(this,"onFlush",void 0),(0,s.A)(this,"onSeek",void 0),this.pointer=0,this.pos=BigInt(0),this.size=t,this.littleEndian=!i,this.error=0,e&&e.view)this.size=e.length,this.buffer=e,this.data=e.view;else if(e&&!e.byteOffset)this.size=e.length,this.buffer=e,this.data=new DataView(this.buffer.buffer);else{if(e)throw new Error("not support subarray of ArrayBuffer");this.buffer=new Uint8Array(this.size),this.data=new DataView(this.buffer.buffer)}}async writeUint8(t){this.remainingLength()<1&&await this.flush(),this.data.setUint8(this.pointer,t),this.pointer++,this.pos++}async writeUint16(t){this.remainingLength()<2&&await this.flush(),this.data.setUint16(this.pointer,t,this.littleEndian),this.pointer+=2,this.pos+=BigInt(2)}async writeUint24(t){this.remainingLength()<3&&await this.flush();const i=(16711680&t)>>16,e=(65280&t)>>8,s=255&t;this.littleEndian?(await this.writeUint8(s),await this.writeUint8(e),await this.writeUint8(i)):(await this.writeUint8(i),await this.writeUint8(e),await this.writeUint8(s))}async writeUint32(t){this.remainingLength()<4&&await this.flush(),this.data.setUint32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}async writeUint64(t){this.remainingLength()<8&&await this.flush(),this.data.setBigUint64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}async writeInt8(t){this.remainingLength()<1&&await this.flush(),this.data.setInt8(this.pointer,t),this.pointer++,this.pos++}async writeInt16(t){this.remainingLength()<2&&await this.flush(),this.data.setInt16(this.pointer,t,this.littleEndian),this.pointer+=2,this.pos+=BigInt(2)}async writeInt24(t){await this.writeUint24(t<0?t+16777216:t)}async writeInt32(t){this.remainingLength()<4&&await this.flush(),this.data.setInt32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}async writeInt64(t){this.remainingLength()<8&&await this.flush(),this.data.setBigInt64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}async writeFloat(t){this.remainingLength()<4&&await this.flush(),this.data.setFloat32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}async writeDouble(t){this.remainingLength()<8&&await this.flush(),this.data.setFloat64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}getPointer(){return this.pointer}getPos(){return this.pos}remainingLength(){return this.size-this.pointer}async writeBuffer(t){if(!t.length)return;let i=t.length;if(this.remainingLength()<i){let e=0;for(;i>0;){await this.flush();const s=Math.min(this.size,i);this.buffer.set(t.subarray(e,e+s),this.pointer),this.pointer+=s,this.pos+=BigInt(s),e+=s,i-=s}}else this.buffer.set(t,this.pointer),this.pointer+=i,this.pos+=BigInt(i)}async writeString(t){const i=r.encode(t);return await this.writeBuffer(i),i.length}async flush(){if(!this.onFlush)throw this.error=-1048574,Error("IOWriter error, flush failed because of no flush callback");if(this.pointer){const t=await this.onFlush(this.buffer.subarray(0,this.pointer));if(0!==t)throw this.error=t,Error("IOWriter error, flush failed")}this.pointer=0}async flushToPos(t){if(!this.onFlush)throw this.error=-1048574,Error("IOWriter error, flush failed because of no flush callback");if(this.pointer){const i=await this.onFlush(this.buffer.subarray(0,this.pointer),t);if(0!==i)throw this.error=i,Error("IOWriter error, flush failed")}this.pointer=0}async seek(t){if(!this.onSeek)throw this.error=-1048574,Error("IOWriter error, seek failed because of no seek callback");await this.flush();const i=await this.onSeek(t);if(0!==i)throw this.error=i,Error("IOWriter error, seek failed");this.pos=t}seekInline(t){const i=this.pointer;this.pointer=Math.max(0,Math.min(this.size,t)),this.pos+=BigInt(this.pointer-i)}skip(t){const i=this.pointer;this.pointer=Math.min(this.size,this.pointer+t),this.pos+=BigInt(this.pointer-i)}back(t){const i=this.pointer;this.pointer=Math.max(0,this.pointer-t),this.pos+=BigInt(this.pointer-i)}getBuffer(){return this.buffer.subarray(0,this.pointer)}setEndian(t){this.littleEndian=!t}reset(){this.pointer=0,this.pos=BigInt(0),this.error=0}getBufferSize(){return this.size}}},35336:(t,i,e)=>{e.d(i,{A:()=>n});var s=e(134),r=e(50011);class n{constructor(t=1048576,i=!0,e){if((0,s.A)(this,"data",void 0),(0,s.A)(this,"buffer",void 0),(0,s.A)(this,"pointer",void 0),(0,s.A)(this,"pos",void 0),(0,s.A)(this,"size",void 0),(0,s.A)(this,"littleEndian",void 0),(0,s.A)(this,"error",void 0),(0,s.A)(this,"onFlush",void 0),(0,s.A)(this,"onSeek",void 0),this.pointer=0,this.pos=BigInt(0),this.size=t,this.littleEndian=!i,this.error=0,e&&e.view)this.size=e.length,this.buffer=e,this.data=e.view;else if(e&&!e.byteOffset)this.size=e.length,this.buffer=e,this.data=new DataView(this.buffer.buffer);else{if(e)throw new Error("not support subarray of ArrayBuffer");this.buffer=new Uint8Array(this.size),this.data=new DataView(this.buffer.buffer)}}writeUint8(t){this.remainingLength()<1&&this.flush(),this.data.setUint8(this.pointer,t),this.pointer++,this.pos++}writeUint16(t){this.remainingLength()<2&&this.flush(),this.data.setUint16(this.pointer,t,this.littleEndian),this.pointer+=2,this.pos+=BigInt(2)}writeUint24(t){this.remainingLength()<3&&this.flush();const i=(16711680&t)>>16,e=(65280&t)>>8,s=255&t;this.littleEndian?(this.writeUint8(s),this.writeUint8(e),this.writeUint8(i)):(this.writeUint8(i),this.writeUint8(e),this.writeUint8(s))}writeUint32(t){this.remainingLength()<4&&this.flush(),this.data.setUint32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}writeUint64(t){this.remainingLength()<8&&this.flush(),this.data.setBigUint64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}writeInt8(t){this.remainingLength()<1&&this.flush(),this.data.setInt8(this.pointer,t),this.pointer++,this.pos++}writeInt16(t){this.remainingLength()<2&&this.flush(),this.data.setInt16(this.pointer,t,this.littleEndian),this.pointer+=2,this.pos+=BigInt(2)}writeInt24(t){this.writeUint24(t<0?t+16777216:t)}writeInt32(t){this.remainingLength()<4&&this.flush(),this.data.setInt32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}writeInt64(t){this.remainingLength()<8&&this.flush(),this.data.setBigInt64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}writeFloat(t){this.remainingLength()<4&&this.flush(),this.data.setFloat32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}writeDouble(t){this.remainingLength()<8&&this.flush(),this.data.setFloat64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}getPointer(){return this.pointer}getPos(){return this.pos}remainingLength(){return this.size-this.pointer}writeBuffer(t){if(!t.length)return;let i=t.length;if(this.remainingLength()<i){let e=0;for(;i>0;){this.flush();const s=Math.min(this.size,i);this.buffer.set(t.subarray(e,e+s),this.pointer),this.pointer+=s,this.pos+=BigInt(s),e+=s,i-=s}}else this.buffer.set(t,this.pointer),this.pointer+=i,this.pos+=BigInt(i)}writeString(t){const i=r.encode(t);return this.writeBuffer(i),i.length}flush(){if(!this.onFlush)throw this.error=-1048574,Error("IOWriter error, flush failed because of no flush callback");if(this.pointer){const t=this.onFlush(this.buffer.subarray(0,this.pointer));if(0!==t)throw this.error=t,Error("IOWriter error, flush failed")}this.pointer=0}flushToPos(t){if(!this.onFlush)throw this.error=-1048574,Error("IOWriter error, flush failed because of no flush callback");if(this.pointer){const i=this.onFlush(this.buffer.subarray(0,this.pointer),t);if(0!==i)throw this.error=i,Error("IOWriter error, flush failed")}this.pointer=0}seek(t){if(!this.onSeek)throw this.error=-1048574,Error("IOWriter error, seek failed because of no seek callback");this.flush();const i=this.onSeek(t);if(0!==i)throw this.error=i,Error("IOWriter error, seek failed");this.pos=t}seekInline(t){const i=this.pointer;this.pointer=Math.max(0,Math.min(this.size,t)),this.pos+=BigInt(this.pointer-i)}skip(t){const i=this.pointer;this.pointer=Math.min(this.size,this.pointer+t),this.pos+=BigInt(this.pointer-i)}back(t){const i=this.pointer;this.pointer=Math.max(0,this.pointer-t),this.pos+=BigInt(this.pointer-i)}getBuffer(){return this.buffer.subarray(0,this.pointer)}setEndian(t){this.littleEndian=!t}reset(){this.pointer=0,this.pos=BigInt(0),this.error=0}getBufferSize(){return this.size}}},31658:(t,i,e)=>{function s(t,i){for(;0!==i;)[t,i]=[i,t%i];return t}e.d(i,{A:()=>s})},8507:(t,i,e)=>{function s(t){const i=t,e=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],s=/:\/\/([^\/@]*@?)\[(\S+)\]/;let r="";s.test(t)&&(t=t.replace(s,((t,i,e)=>(r=e,`://${i||""}a.b`))));const n={},a=/^(?:(?![^:@\/]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@\/]*)(?::([^:@\/]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(t);let h=14;for(;h--;){var o;n[e[h]]=null!==(o=a[h])&&void 0!==o?o:""}return r&&(n.host=r,n.source=i,n.authority=r+(n.port?":"+n.port:"")),{protocol:n.protocol,file:n.file,host:n.host,port:n.port,user:n.user,password:n.password,origin:`${n.protocol}://${n.authority}`,pathname:n.path,search:`?${n.query}`,hash:n.anchor?`#${n.anchor}`:""}}e.d(i,{ll:()=>l,qg:()=>s}),e(73146),e(67672),e(6498),e(72739),e(95335);const r=/(?:\/|^)\.(?=\/)/g,n=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a=/^(?=([^\/?#]*))\1([^]*)$/,h=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/;function o(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}function f(t){const i=h.exec(t);return i?{scheme:i[1]||"",netLoc:i[2]||"",path:i[3]||"",params:i[4]||"",query:i[5]||"",fragment:i[6]||""}:null}function u(t){for(t=t.split("").reverse().join("").replace(r,"");t.length!==(t=t.replace(n,"")).length;);return t.split("").reverse().join("")}function l(t,i,e){if(e=e||{},t=t.trim(),!(i=i.trim())){if(!e.alwaysNormalize)return t;let i=f(t);if(!i)throw new Error("Error trying to parse base URL.");return i.path=u(i.path),o(i)}let s=f(i);if(!s)throw new Error("Error trying to parse relative URL.");if(s.scheme)return e.alwaysNormalize?(s.path=u(s.path),o(s)):i;let r=f(t);if(!r)throw new Error("Error trying to parse base URL.");if(!r.netLoc&&r.path&&"/"!==r.path[0]){let t=a.exec(r.path);r.netLoc=t[1],r.path=t[2]}r.netLoc&&!r.path&&(r.path="/");const n={scheme:r.scheme,netLoc:s.netLoc,path:null,params:s.params,query:s.query,fragment:s.fragment};if(!s.netLoc&&(n.netLoc=r.netLoc,"/"!==s.path[0]))if(s.path){let t=r.path,i=t.substring(0,t.lastIndexOf("/")+1)+s.path;n.path=u(i)}else n.path=r.path,s.params||(n.params=r.params,s.query||(n.query=r.query));return null===n.path&&(n.path=e.alwaysNormalize?u(s.path):s.path),o(n)}},85079:(t,i,e)=>{var s=e(46438),r=s.JSON||(s.JSON={stringify:JSON.stringify});t.exports=function(t){return r.stringify.apply(r,arguments)}},73146:(t,i,e)=>{t.exports=e(85079)}}]);
@@ -1 +1 @@
1
- (self.webpackChunklibmedia=self.webpackChunklibmedia||[]).push([[576],{41576:(e,t,i)=>{i.r(t),i.d(t,{default:()=>L});var s=i(134),a=i(80662),n=i.n(a),d=i(54001),o=i.n(d),r=i(13724),l=i(82800),m=i(95335),u=i(4624),h=i(78417),c=i(77580),g=i(86932),f=i(9705);const p="src/avnetwork/ioLoader/DashIOLoader.ts";class L extends l.A{constructor(...e){super(...e),(0,s.A)(this,"info",void 0),(0,s.A)(this,"range",void 0),(0,s.A)(this,"mediaPlayList",void 0),(0,s.A)(this,"fetchMediaPlayListPromise",void 0),(0,s.A)(this,"minBuffer",void 0),(0,s.A)(this,"audioResource",void 0),(0,s.A)(this,"videoResource",void 0),(0,s.A)(this,"subtitleResource",void 0)}createResource(e){return{type:e,fetchedMap:new(n()),fetchedHistoryList:[],loader:null,segmentIndex:0,currentUri:"",selectedIndex:0,segments:[],initSegmentPadding:"",initedSegment:""}}async fetchMediaPlayList(e){var t,i,s;if(!e){if(this.fetchMediaPlayListPromise)return;this.fetchMediaPlayListPromise=new(o())((t=>{e=t}))}const a={method:"GET",headers:{},mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};null!==(t=this.info.httpOptions)&&void 0!==t&&t.headers&&m.__(this.info.httpOptions.headers,((e,t)=>{a.headers[t]=e})),null!==(i=this.info.httpOptions)&&void 0!==i&&i.credentials&&(a.credentials=this.info.httpOptions.credentials),null!==(s=this.info.httpOptions)&&void 0!==s&&s.referrerPolicy&&(a.referrerPolicy=this.info.httpOptions.referrerPolicy);try{const t=await fetch(this.info.url,a),i=await t.text();if(this.mediaPlayList=(0,h.A)(i,this.info.url),this.minBuffer=this.mediaPlayList.minBufferTime,this.options.isLive){var n,d;const t=this.mediaPlayList.minBufferTime/this.mediaPlayList.maxSegmentDuration,i=Math.max(this.mediaPlayList.mediaList.audio&&(null===(n=this.mediaPlayList.mediaList.audio[0])||void 0===n?void 0:n.mediaSegments.length)||0,this.mediaPlayList.mediaList.video&&(null===(d=this.mediaPlayList.mediaList.video[0])||void 0===d?void 0:d.mediaSegments.length)||0);if(i<t)return await new r.A((t-i)*this.mediaPlayList.maxSegmentDuration),u.R8(`wait for min buffer time, buffer: ${i*this.mediaPlayList.maxSegmentDuration}, need: ${t*this.mediaPlayList.maxSegmentDuration}`,p,136),this.fetchMediaPlayList(e)}if("vod"===this.mediaPlayList.type?this.options.isLive=!1:this.options.isLive=!0,this.mediaPlayList.mediaList.audio.length){const e=this.mediaPlayList.mediaList.audio[this.audioResource.selectedIndex];e.file?this.audioResource.segments=[e.file]:this.options.isLive&&this.audioResource.initedSegment===e.initSegment?this.audioResource.segments=e.mediaSegments.map((e=>e.url)):(this.audioResource.segments=[e.initSegment].concat(e.mediaSegments.map((e=>e.url))),this.audioResource.initedSegment=e.initSegment)}if(this.mediaPlayList.mediaList.video.length){const e=this.mediaPlayList.mediaList.video[this.videoResource.selectedIndex];e.file?this.videoResource.segments=[e.file]:this.options.isLive&&this.videoResource.initedSegment===e.initSegment?this.videoResource.segments=e.mediaSegments.map((e=>e.url)):(this.videoResource.segments=[e.initSegment].concat(e.mediaSegments.map((e=>e.url))),this.videoResource.initedSegment=e.initSegment)}if(this.mediaPlayList.mediaList.subtitle.length){const e=this.mediaPlayList.mediaList.subtitle[this.subtitleResource.selectedIndex];e.file?this.subtitleResource.segments=[e.file]:this.options.isLive&&this.subtitleResource.initedSegment===e.initSegment?this.subtitleResource.segments=e.mediaSegments.map((e=>e.url)):(this.subtitleResource.segments=[e.initSegment].concat(e.mediaSegments.map((e=>e.url))),this.subtitleResource.initedSegment=e.initSegment)}return e(),this.fetchMediaPlayListPromise=null,this.status=2,this.retryCount=0,this.mediaPlayList}catch(t){if(this.retryCount<this.options.retryCount)return this.retryCount++,u.z3(`failed fetch mpd file, retry(${this.retryCount}/3)`,p,208),await new r.A(2===this.status?this.options.retryInterval:5),this.fetchMediaPlayList(e);this.status=3,e(),u.h2(`DashLoader: exception, fetch slice error, error: ${t.message}`,p,216)}}async open(e,t){return 0!==this.status?f.lh:(this.info=e,this.range=t,this.range.to||(this.range.to=-1),this.range.from=Math.max(this.range.from,0),this.videoResource=this.createResource("video"),this.audioResource=this.createResource("audio"),this.subtitleResource=this.createResource("subtitle"),this.status=1,this.retryCount=0,await this.fetchMediaPlayList(),0)}async readResource(e,t){let i=0;if(t.loader){if(i=await t.loader.read(e),-1048576!==i)return i;if(this.options.isLive)t.fetchedMap.set(t.currentUri,!0),10===t.fetchedHistoryList.length&&t.fetchedMap.delete(t.fetchedHistoryList.shift()),t.fetchedHistoryList.push(t.currentUri);else if(t.segmentIndex++,t.segmentIndex>=t.segments.length)return-1048576;t.loader=null}if(this.options.isLive){const i=t.segments.filter((e=>!t.fetchedMap.get(e)));if(!i.length){if(this.mediaPlayList.isEnd)return-1048576;const i=(this.mediaPlayList.duration||this.mediaPlayList.minimumUpdatePeriod)-((0,g.A)()-this.mediaPlayList.timestamp)/1e3;if(i>0&&await new r.A(Math.max(i,2)),this.fetchMediaPlayListPromise){if(await this.fetchMediaPlayListPromise,3===this.status)return-1048576}else await this.fetchMediaPlayList();return this.readResource(e,t)}return t.currentUri=i[0],t.loader=new c.A(m.X$({},this.options,{disableSegment:!0,loop:!1})),await t.loader.open(m.X$({},this.info,{url:t.currentUri}),{from:0,to:-1}),t.loader.read(e)}return t.loader=new c.A(m.X$({},this.options,{disableSegment:!0,loop:!1})),t.initSegmentPadding?(await t.loader.open(m.X$({},this.info,{url:t.initSegmentPadding}),{from:0,to:-1}),t.initSegmentPadding=null,t.segmentIndex--):await t.loader.open(m.X$({},this.info,{url:t.segments[t.segmentIndex]}),{from:0,to:-1}),t.loader.read(e)}async read(e,t){return"audio"===t.mediaType?this.readResource(e,this.audioResource):"video"===t.mediaType?this.readResource(e,this.videoResource):"subtitle"===t.mediaType?this.readResource(e,this.subtitleResource):f.UY}async seekResource(e,t){let i="";t.loader&&(i=t.loader.getUrl(),await t.loader.abort(),t.loader=null);let s=Number(BigInt.asIntN(32,e));if(t.segments){let e=0;const a="audio"===t.type?this.mediaPlayList.mediaList.audio:"video"===t.type?this.mediaPlayList.mediaList.video:this.mediaPlayList.mediaList.subtitle,n=a[t.selectedIndex].mediaSegments;if(null!=n&&n.length)for(let t=0;t<n.length;t++)if(s>=1e3*n[t].start&&s<1e3*n[t].end){e=t;break}t.segmentIndex=e+(a[t.selectedIndex].initSegment?1:0);let d="";"video"===t.type?d=this.mediaPlayList.mediaList.video[t.selectedIndex].initSegment:"audio"===t.type?d=this.mediaPlayList.mediaList.audio[t.selectedIndex].initSegment:"subtitle"===t.type&&(d=this.mediaPlayList.mediaList.subtitle[t.selectedIndex].initSegment),d&&d===i&&(t.initSegmentPadding=d)}}async seek(e,t){return"audio"===t.mediaType&&this.audioResource.loader&&await this.seekResource(e,this.audioResource),"video"===t.mediaType&&this.videoResource.loader&&await this.seekResource(e,this.videoResource),"subtitle"===t.mediaType&&this.subtitleResource.loader&&await this.seekResource(e,this.subtitleResource),4===this.status&&(this.status=2),0}async size(){return BigInt(0)}async abort(){this.videoResource.loader&&(await this.videoResource.loader.abort(),this.videoResource.loader=null),this.audioResource.loader&&(await this.audioResource.loader.abort(),this.audioResource.loader=null),this.subtitleResource.loader&&(await this.subtitleResource.loader.abort(),this.subtitleResource.loader=null)}async stop(){await this.abort(),this.status=0}getDuration(){return this.mediaPlayList.duration}hasVideo(){var e;return(null===(e=this.mediaPlayList)||void 0===e?void 0:e.mediaList.video.length)>0}hasAudio(){var e;return(null===(e=this.mediaPlayList)||void 0===e?void 0:e.mediaList.audio.length)>0}hasSubtitle(){var e;return(null===(e=this.mediaPlayList)||void 0===e?void 0:e.mediaList.subtitle.length)>0}getVideoList(){return this.hasVideo()?{list:this.mediaPlayList.mediaList.video.map((e=>({width:e.width,height:e.height,frameRate:e.frameRate,codecs:e.codecs}))),selectedIndex:this.videoResource.selectedIndex}:{list:[],selectedIndex:0}}getAudioList(){return this.hasAudio()?{list:this.mediaPlayList.mediaList.audio.map((e=>({lang:e.lang,codecs:e.codecs}))),selectedIndex:this.audioResource.selectedIndex}:{list:[],selectedIndex:0}}getSubtitleList(){return this.hasSubtitle()?{list:this.mediaPlayList.mediaList.subtitle.map((e=>({lang:e.lang,codecs:e.codecs}))),selectedIndex:this.subtitleResource.selectedIndex}:{list:[],selectedIndex:0}}selectVideo(e){if(e!==this.videoResource.selectedIndex&&this.hasVideo()&&e>=0&&e<this.mediaPlayList.mediaList.video.length){this.videoResource.selectedIndex=e;const t=this.mediaPlayList.mediaList.video[this.videoResource.selectedIndex];t.file?this.videoResource.segments=[t.file]:(this.videoResource.segments=[t.initSegment].concat(t.mediaSegments.map((e=>e.url))),this.videoResource.initSegmentPadding=t.initSegment)}}selectAudio(e){if(e!==this.audioResource.selectedIndex&&this.hasAudio()&&e>=0&&e<this.mediaPlayList.mediaList.audio.length){this.audioResource.selectedIndex=e;const t=this.mediaPlayList.mediaList.audio[this.audioResource.selectedIndex];t.file?this.audioResource.segments=[t.file]:(this.audioResource.segments=[t.initSegment].concat(t.mediaSegments.map((e=>e.url))),this.audioResource.initSegmentPadding=t.initSegment)}}selectSubtitle(e){if(e!==this.subtitleResource.selectedIndex&&this.hasSubtitle()&&e>=0&&e<this.mediaPlayList.mediaList.subtitle.length){this.subtitleResource.selectedIndex=e;const t=this.mediaPlayList.mediaList.subtitle[this.subtitleResource.selectedIndex];t.file?this.subtitleResource.segments=[t.file]:(this.subtitleResource.segments=[t.initSegment].concat(t.mediaSegments.map((e=>e.url))),this.subtitleResource.initSegmentPadding=t.initSegment)}}getMinBuffer(){return this.minBuffer}}},78417:(e,t,i)=>{i.d(t,{A:()=>g});var s=i(88032),a=i.n(s),n=i(29967),d=i.n(n),o=i(79331),r=i(67672),l=i(62100),m=i(86932);function u(e){let t=0,i=0,s=0;return(e=e.slice(e.indexOf("PT")+2)).indexOf("H")>-1&&e.indexOf("M")>-1&&e.indexOf("S")>-1?(t=a()(e.slice(0,e.indexOf("H"))),i=a()(e.slice(e.indexOf("H")+1,e.indexOf("M"))),s=a()(e.slice(e.indexOf("M")+1,e.indexOf("S")))):e.indexOf("H")<0&&e.indexOf("M")>0&&e.indexOf("S")>-1?(i=a()(e.slice(0,e.indexOf("M"))),s=a()(e.slice(e.indexOf("M")+1,e.indexOf("S")))):e.indexOf("H")<0&&e.indexOf("M")<0&&e.indexOf("S")>-1&&(s=a()(e.slice(0,e.indexOf("S")))),3600*t+60*i+s}function h(e,t){return(Array(t).join("0")+e).slice(-t)}function c(e){if(!e)return 0;if(e.indexOf("/")>-1){const t=e.split("/");return a()(t[0])/a()(t[1])}return a()(e)}function g(e,t){const i={source:e,mediaList:{audio:[],video:[],subtitle:[]},type:"live",isEnd:!1,duration:0,minBufferTime:0,maxSegmentDuration:0,minimumUpdatePeriod:0,timestamp:(0,m.A)()},s=[],n=(g=e,g?(0,o.A)(g,{aloneValueName:"value"}):null).MPD;var g;"static"===n.type&&(i.type="vod",i.isEnd=!0),n.minBufferTime&&(i.minBufferTime=u(n.minBufferTime)),n.maxSegmentDuration&&(i.maxSegmentDuration=u(n.maxSegmentDuration)),n.minimumUpdatePeriod&&(i.minimumUpdatePeriod=u(n.minimumUpdatePeriod)),n.mediaPresentationDuration&&(i.duration=u(n.mediaPresentationDuration));let f="";n.BaseURL&&(f=r.Yj(n.BaseURL)?n.BaseURL:n.BaseURL.value);const p=r.YO(n.Period)?n.Period[0]:n.Period;return!i.duration&&p&&p.duration&&(i.duration=u(p.duration)),(r.YO(p.AdaptationSet)?p.AdaptationSet:[p.AdaptationSet]).forEach(((e,n)=>{let o="video/mp4",m="avc1.64001E",u=640,g=360,p=640,L=360,S=25,y="1:1",R="1",P=588633,b=f,v="und";e.BaseURL&&(b+=e.BaseURL),e.lang&&(v=e.lang),e.mimeType?(o=e.mimeType,"video/mp4"===o?(m=e.codecs,u=a()(e.width),g=a()(e.height),e.maxWidth&&(p=a()(e.maxWidth)),e.maxHeight&&(L=a()(e.maxHeight)),e.frameRate&&(S=c(e.frameRate)),y=e.sar,R=e.startWithSAP,P=a()(e.bandwidth)):"audio/mp4"===o&&(m=e.codecs,R=e.startWithSAP,P=a()(e.bandwidth))):(e.maxWidth&&(p=a()(e.maxWidth)),e.maxHeight&&(L=a()(e.maxHeight)),e.frameRate&&(S=c(e.frameRate))),(r.YO(e.Representation)?e.Representation:[e.Representation]).forEach(((n,c)=>{s.indexOf(n.id)>-1&&(n.id=(d()(s[s.length-1])+1).toString()),s.push(n.id);let f="";const x=[];let w=0,A=0,I=t.slice(0,t.lastIndexOf("/")+1)+b;n.mimeType&&(o=n.mimeType),"video/mp4"===o?(n.codecs&&(m=n.codecs),n.width&&(u=a()(n.width)),n.height&&(g=a()(n.height)),n.maxWidth&&(p=a()(n.maxWidth)),n.maxHeight&&(L=a()(n.maxHeight)),n.frameRate&&(S=a()(n.frameRate)),n.sar&&(y=n.sar),n.startWithSAP&&(R=n.startWithSAP),n.bandwidth&&(P=a()(n.bandwidth))):(n.codecs&&(m=n.codecs),n.startWithSAP&&(R=n.startWithSAP),n.bandwidth&&(P=a()(n.bandwidth))),n.BaseURL&&(I+=n.BaseURL);let T=!1;if((e.ContentProtection||n.ContentProtection)&&(T=!0),n.SegmentBase)"video/mp4"===o?i.mediaList.video.push({id:n.id,file:I,mimeType:o,codecs:m,width:u,height:g,maxWidth:p,maxHeight:L,frameRate:S,sar:y,startWithSAP:"1"===R,bandwidth:P,timescale:w,duration:A,encrypted:T}):"audio/mp4"===o?i.mediaList.audio.push({id:n.id,file:I,mimeType:o,codecs:m,startWithSAP:"1"===R,bandwidth:P,timescale:w,duration:A,encrypted:T,lang:v}):"application/mp4"===o&&i.mediaList.subtitle.push({id:n.id,file:I,mimeType:o,codecs:m,startWithSAP:"1"===R,bandwidth:P,timescale:w,duration:A,encrypted:T,lang:v});else{let t;if(e.SegmentTemplate&&(t=r.YO(e.SegmentTemplate)?e.SegmentTemplate[0]:e.SegmentTemplate),n.SegmentTemplate&&(t=r.YO(n.SegmentTemplate)?n.SegmentTemplate[0]:n.SegmentTemplate),t){const e=d()(t.startNumber);if(f=t.initialization,w=a()(t.timescale||"1"),t.duration&&!t.SegmentTimeline){A=a()(t.duration);let s=A/w;const d=e+Math.ceil((i.duration||s)/s)-1;for(let a=e;a<=d;a++){const o=s*(a-e);let r=s*(a-e+1);a===d&&(s=i.duration-s*(d-e),r=i.duration),x.push({idx:a,start:o,end:r,url:I+t.media.replace(/\$RepresentationID\$/g,n.id).replace(/\$Number(%(\d+)d)?\$/g,((e,t,i)=>i?h(a,+i):(0,l.A)(a))),segmentDuration:s})}}else if(t.SegmentTimeline&&t.SegmentTimeline.S){const i=r.YO(t.SegmentTimeline.S)?t.SegmentTimeline.S:[t.SegmentTimeline.S];let s=0,o=e;for(let e=0;e<i.length;e++){let r=a()(i[e].d);i[e].t&&(s=a()(i[0].t));let m=1;i[e].r&&(m=d()(i[e].r)+1);for(let e=0;e<m;e++)x.push({idx:o,start:s/w,end:(s+r)/w,url:I+t.media.replace(/\$RepresentationID\$/g,n.id).replace(/\$Number(%(\d+)d)?\$/g,((e,t,i)=>i?h(o,+i):(0,l.A)(o))).replace(/\$Time\$/g,(0,l.A)(s)),segmentDuration:r/w}),o++,s+=r}}}else if(n.SegmentList){const e=r.YO(n.SegmentList.SegmentURL)?n.SegmentList.SegmentURL:[n.SegmentList.SegmentURL];let t=0,i=a()(n.SegmentList.duration);for(let s=0;s<e.length;s++)x.push({idx:s,start:t/w,end:(t+i)/w,url:I+e[s].media,segmentDuration:i/w}),t+=i}"video/mp4"===o?i.mediaList.video.push({id:n.id,baseURL:I,initSegment:I+f.replace(/\$RepresentationID\$/g,n.id).replace(/\$Bandwidth\$/g,(0,l.A)(P)),mediaSegments:x,mimeType:o,codecs:m,width:u,height:g,maxWidth:p,maxHeight:L,frameRate:S,sar:y,startWithSAP:"1"===R,bandwidth:P,timescale:w,duration:A,encrypted:T}):"audio/mp4"===o?i.mediaList.audio.push({id:n.id,baseURL:I,initSegment:I+f.replace(/\$RepresentationID\$/g,n.id).replace(/\$Bandwidth\$/g,(0,l.A)(P)),mediaSegments:x,mimeType:o,codecs:m,startWithSAP:"1"===R,bandwidth:P,timescale:w,duration:A,encrypted:T,lang:v}):"application/mp4"===o&&i.mediaList.subtitle.push({id:n.id,baseURL:I,initSegment:I+f.replace(/\$RepresentationID\$/g,n.id).replace(/\$Bandwidth\$/g,(0,l.A)(P)),mediaSegments:x,mimeType:o,codecs:m,startWithSAP:"1"===R,bandwidth:P,timescale:w,duration:A,encrypted:T,lang:v})}}))})),["video","audio"].forEach((e=>{i.mediaList[e].sort(((e,t)=>e.bandwidth-t.bandwidth))})),i}},79331:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(68632),a=i.n(s),n=i(72739);const d={aloneValueName:"_@attribute"},o=[" ","/",'"',"'","<",">"];function r(e,t=d){e=(e=(e=(e=e.replace(/<!--[\s\S]*?-->/g,"")).replace(/[\n\t\r]/g,"")).replace(/>[ \t]+</g,"><")).replace(/<\?[^>]*\?>/g,"");const i=[];let s=0;function r(e,s){const n=i[i.length-1];n&&(e===t.aloneValueName||null==n.obj[t.aloneValueName]?null==n.obj[e]?n.obj[e]=s:a()(n.obj[e])?n.obj[e].push(s):n.obj[e]=[n.obj[e],s]:n.obj[t.aloneValueName]=[n.obj[t.aloneValueName],{tagName:e,...s}])}function l(t){for(;s<e.length;){if(e[s]===t)return!0;s++}return!1}function m(){u();let t="";for(;s<e.length&&!n.zy(o,e[s]);)t+=e[s],s++;return t}function u(){for(;s<e.length&&/\s|\r|\n/.test(e[s]);)s++}const h=/\s/,c=/'/,g=/"/;function f(){if(s>=e.length)return!0;u();let t=h;'"'!==e[s]&&"'"!=e[s]||(t='"'===e[s]?g:c,s++);let i="";for(;s<e.length;){if(t.test(e[s])){s++;break}i+=e[s],s++}return i}function p(){u();let t="";for(;s<e.length&&"<"!==e[s];)t+=e[s],s++;return t}function L(){for(;"<"===e[s];){const t=s;if(s++,u(),"/"!==e[s]){s=t;break}if(s++,m()===i[i.length-1].tag){if(i.length>1){const e=i.pop();r(e.tag,e.obj)}l(">"),s++,u()}else i.pop(),l(">"),s++,u()}}return function a(){if(s>=e.length)return;let n=s;if(u(),"<"!==e[s])return s=n,r(t.aloneValueName,p()),L(),a();let d=l("<");if(!d)return;n=s,s++;const o=m();if(i.push({obj:{},tag:o,start:n}),function(){for(;u(),">"!==e[s]&&"/"!==e[s];){let e=m();if(!e)break;"="===e[e.length-1]?e=e.substring(0,e.length-1):(l("="),s++),r(e,f())}}(),u(),"/"===e[s]){if(s++,i.length>1){const e=i.pop();r(e.tag,e.obj)}return l(">"),s++,L(),a()}d=l(">"),d&&(s++,u(),"<"!==e[s]&&(r(t.aloneValueName,p()),u()),L(),a())}(),{[i[0].tag]:i[0].obj}}}}]);
1
+ (self.webpackChunklibmedia=self.webpackChunklibmedia||[]).push([[576],{41576:(e,t,i)=>{i.r(t),i.d(t,{default:()=>L});var s=i(134),a=i(80662),n=i.n(a),d=i(54001),o=i.n(d),r=i(13724),l=i(82800),m=i(95335),u=i(4624),h=i(78417),c=i(77580),g=i(86932),f=i(9705);const p="src/avnetwork/ioLoader/DashIOLoader.ts";class L extends l.A{constructor(...e){super(...e),(0,s.A)(this,"info",void 0),(0,s.A)(this,"range",void 0),(0,s.A)(this,"mediaPlayList",void 0),(0,s.A)(this,"fetchMediaPlayListPromise",void 0),(0,s.A)(this,"minBuffer",void 0),(0,s.A)(this,"audioResource",void 0),(0,s.A)(this,"videoResource",void 0),(0,s.A)(this,"subtitleResource",void 0)}createResource(e){return{type:e,fetchedMap:new(n()),fetchedHistoryList:[],loader:null,segmentIndex:0,currentUri:"",selectedIndex:0,segments:[],initSegmentPadding:"",initedSegment:""}}async fetchMediaPlayList(e){var t,i,s;if(!e){if(this.fetchMediaPlayListPromise)return;this.fetchMediaPlayListPromise=new(o())((t=>{e=t}))}const a={method:"GET",headers:{},mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};null!==(t=this.info.httpOptions)&&void 0!==t&&t.headers&&m.__(this.info.httpOptions.headers,((e,t)=>{a.headers[t]=e})),null!==(i=this.info.httpOptions)&&void 0!==i&&i.credentials&&(a.credentials=this.info.httpOptions.credentials),null!==(s=this.info.httpOptions)&&void 0!==s&&s.referrerPolicy&&(a.referrerPolicy=this.info.httpOptions.referrerPolicy);try{const t=await fetch(this.info.url,a),i=await t.text();if(this.mediaPlayList=(0,h.A)(i,this.info.url),this.minBuffer=this.mediaPlayList.minBufferTime,this.options.isLive){var n,d;const t=this.mediaPlayList.minBufferTime/this.mediaPlayList.maxSegmentDuration,i=Math.max(this.mediaPlayList.mediaList.audio&&(null===(n=this.mediaPlayList.mediaList.audio[0])||void 0===n?void 0:n.mediaSegments.length)||0,this.mediaPlayList.mediaList.video&&(null===(d=this.mediaPlayList.mediaList.video[0])||void 0===d?void 0:d.mediaSegments.length)||0);if(i<t)return await new r.A((t-i)*this.mediaPlayList.maxSegmentDuration),u.R8(`wait for min buffer time, buffer: ${i*this.mediaPlayList.maxSegmentDuration}, need: ${t*this.mediaPlayList.maxSegmentDuration}`,p,136),this.fetchMediaPlayList(e)}if("vod"===this.mediaPlayList.type?this.options.isLive=!1:this.options.isLive=!0,this.mediaPlayList.mediaList.audio.length){const e=this.mediaPlayList.mediaList.audio[this.audioResource.selectedIndex];e.file?this.audioResource.segments=[e.file]:this.options.isLive&&this.audioResource.initedSegment===e.initSegment?this.audioResource.segments=e.mediaSegments.map((e=>e.url)):(this.audioResource.segments=[e.initSegment].concat(e.mediaSegments.map((e=>e.url))),this.audioResource.initedSegment=e.initSegment)}if(this.mediaPlayList.mediaList.video.length){const e=this.mediaPlayList.mediaList.video[this.videoResource.selectedIndex];e.file?this.videoResource.segments=[e.file]:this.options.isLive&&this.videoResource.initedSegment===e.initSegment?this.videoResource.segments=e.mediaSegments.map((e=>e.url)):(this.videoResource.segments=[e.initSegment].concat(e.mediaSegments.map((e=>e.url))),this.videoResource.initedSegment=e.initSegment)}if(this.mediaPlayList.mediaList.subtitle.length){const e=this.mediaPlayList.mediaList.subtitle[this.subtitleResource.selectedIndex];e.file?this.subtitleResource.segments=[e.file]:this.options.isLive&&this.subtitleResource.initedSegment===e.initSegment?this.subtitleResource.segments=e.mediaSegments.map((e=>e.url)):(this.subtitleResource.segments=[e.initSegment].concat(e.mediaSegments.map((e=>e.url))),this.subtitleResource.initedSegment=e.initSegment)}return e(),this.fetchMediaPlayListPromise=null,this.status=2,this.retryCount=0,this.mediaPlayList}catch(t){if(this.retryCount<this.options.retryCount)return this.retryCount++,u.z3(`failed fetch mpd file, retry(${this.retryCount}/3)`,p,208),await new r.A(2===this.status?this.options.retryInterval:5),this.fetchMediaPlayList(e);this.status=3,e(),u.h2(`DashLoader: exception, fetch slice error, error: ${t.message}`,p,216)}}async open(e,t){return 0!==this.status?f.lh:(this.info=e,this.range=t,this.range.to||(this.range.to=-1),this.range.from=Math.max(this.range.from,0),this.videoResource=this.createResource("video"),this.audioResource=this.createResource("audio"),this.subtitleResource=this.createResource("subtitle"),this.status=1,this.retryCount=0,await this.fetchMediaPlayList(),0)}async readResource(e,t){let i=0;if(t.loader){if(i=await t.loader.read(e),-1048576!==i)return i;if(this.options.isLive)t.fetchedMap.set(t.currentUri,!0),10===t.fetchedHistoryList.length&&t.fetchedMap.delete(t.fetchedHistoryList.shift()),t.fetchedHistoryList.push(t.currentUri);else if(t.segmentIndex++,t.segmentIndex>=t.segments.length)return-1048576;t.loader=null}if(this.options.isLive){const i=t.segments.filter((e=>!t.fetchedMap.get(e)));if(!i.length){if(this.mediaPlayList.isEnd)return-1048576;const i=(this.mediaPlayList.duration||this.mediaPlayList.minimumUpdatePeriod)-((0,g.A)()-this.mediaPlayList.timestamp)/1e3;if(i>0&&await new r.A(Math.max(i,2)),this.fetchMediaPlayListPromise){if(await this.fetchMediaPlayListPromise,3===this.status)return-1048576}else await this.fetchMediaPlayList();return this.readResource(e,t)}return t.currentUri=i[0],t.loader=new c.A(m.X$({},this.options,{disableSegment:!0,loop:!1})),await t.loader.open(m.X$({},this.info,{url:t.currentUri}),{from:0,to:-1}),t.loader.read(e)}return t.loader=new c.A(m.X$({},this.options,{disableSegment:!0,loop:!1})),t.initSegmentPadding?(await t.loader.open(m.X$({},this.info,{url:t.initSegmentPadding}),{from:0,to:-1}),t.initSegmentPadding=null,t.segmentIndex--):await t.loader.open(m.X$({},this.info,{url:t.segments[t.segmentIndex]}),{from:0,to:-1}),t.loader.read(e)}async read(e,t){return"audio"===t.mediaType?this.readResource(e,this.audioResource):"video"===t.mediaType?this.readResource(e,this.videoResource):"subtitle"===t.mediaType?this.readResource(e,this.subtitleResource):f.UY}async seekResource(e,t){let i="";t.loader&&(i=t.loader.getUrl(),await t.loader.abort(),t.loader=null);let s=Number(BigInt.asIntN(32,e));if(t.segments){let e=0;const a="audio"===t.type?this.mediaPlayList.mediaList.audio:"video"===t.type?this.mediaPlayList.mediaList.video:this.mediaPlayList.mediaList.subtitle,n=a[t.selectedIndex].mediaSegments;if(null!=n&&n.length)for(let t=0;t<n.length;t++)if(s>=1e3*n[t].start&&s<1e3*n[t].end){e=t;break}t.segmentIndex=e+(a[t.selectedIndex].initSegment?1:0);let d="";"video"===t.type?d=this.mediaPlayList.mediaList.video[t.selectedIndex].initSegment:"audio"===t.type?d=this.mediaPlayList.mediaList.audio[t.selectedIndex].initSegment:"subtitle"===t.type&&(d=this.mediaPlayList.mediaList.subtitle[t.selectedIndex].initSegment),d&&d===i&&(t.initSegmentPadding=d)}}async seek(e,t){return"audio"===t.mediaType&&this.audioResource.loader&&await this.seekResource(e,this.audioResource),"video"===t.mediaType&&this.videoResource.loader&&await this.seekResource(e,this.videoResource),"subtitle"===t.mediaType&&this.subtitleResource.loader&&await this.seekResource(e,this.subtitleResource),4===this.status&&(this.status=2),0}async size(){return BigInt(0)}async abort(){this.videoResource.loader&&(await this.videoResource.loader.abort(),this.videoResource.loader=null),this.audioResource.loader&&(await this.audioResource.loader.abort(),this.audioResource.loader=null),this.subtitleResource.loader&&(await this.subtitleResource.loader.abort(),this.subtitleResource.loader=null)}async stop(){await this.abort(),this.status=0}getDuration(){return this.mediaPlayList.duration}hasVideo(){var e;return(null===(e=this.mediaPlayList)||void 0===e?void 0:e.mediaList.video.length)>0}hasAudio(){var e;return(null===(e=this.mediaPlayList)||void 0===e?void 0:e.mediaList.audio.length)>0}hasSubtitle(){var e;return(null===(e=this.mediaPlayList)||void 0===e?void 0:e.mediaList.subtitle.length)>0}getVideoList(){return this.hasVideo()?{list:this.mediaPlayList.mediaList.video.map((e=>({width:e.width,height:e.height,frameRate:e.frameRate,codecs:e.codecs}))),selectedIndex:this.videoResource.selectedIndex}:{list:[],selectedIndex:0}}getAudioList(){return this.hasAudio()?{list:this.mediaPlayList.mediaList.audio.map((e=>({lang:e.lang,codecs:e.codecs}))),selectedIndex:this.audioResource.selectedIndex}:{list:[],selectedIndex:0}}getSubtitleList(){return this.hasSubtitle()?{list:this.mediaPlayList.mediaList.subtitle.map((e=>({lang:e.lang,codecs:e.codecs}))),selectedIndex:this.subtitleResource.selectedIndex}:{list:[],selectedIndex:0}}selectVideo(e){if(e!==this.videoResource.selectedIndex&&this.hasVideo()&&e>=0&&e<this.mediaPlayList.mediaList.video.length){this.videoResource.selectedIndex=e;const t=this.mediaPlayList.mediaList.video[this.videoResource.selectedIndex];t.file?this.videoResource.segments=[t.file]:(this.videoResource.segments=[t.initSegment].concat(t.mediaSegments.map((e=>e.url))),this.videoResource.initSegmentPadding=t.initSegment)}}selectAudio(e){if(e!==this.audioResource.selectedIndex&&this.hasAudio()&&e>=0&&e<this.mediaPlayList.mediaList.audio.length){this.audioResource.selectedIndex=e;const t=this.mediaPlayList.mediaList.audio[this.audioResource.selectedIndex];t.file?this.audioResource.segments=[t.file]:(this.audioResource.segments=[t.initSegment].concat(t.mediaSegments.map((e=>e.url))),this.audioResource.initSegmentPadding=t.initSegment)}}selectSubtitle(e){if(e!==this.subtitleResource.selectedIndex&&this.hasSubtitle()&&e>=0&&e<this.mediaPlayList.mediaList.subtitle.length){this.subtitleResource.selectedIndex=e;const t=this.mediaPlayList.mediaList.subtitle[this.subtitleResource.selectedIndex];t.file?this.subtitleResource.segments=[t.file]:(this.subtitleResource.segments=[t.initSegment].concat(t.mediaSegments.map((e=>e.url))),this.subtitleResource.initSegmentPadding=t.initSegment)}}getMinBuffer(){return this.minBuffer}}},78417:(e,t,i)=>{i.d(t,{A:()=>g});var s=i(88032),a=i.n(s),n=i(29967),d=i.n(n),o=i(79331),r=i(67672),l=i(62100),m=i(86932);function u(e){let t=0,i=0,s=0;return(e=e.slice(e.indexOf("PT")+2)).indexOf("H")>-1&&e.indexOf("M")>-1&&e.indexOf("S")>-1?(t=a()(e.slice(0,e.indexOf("H"))),i=a()(e.slice(e.indexOf("H")+1,e.indexOf("M"))),s=a()(e.slice(e.indexOf("M")+1,e.indexOf("S")))):e.indexOf("H")<0&&e.indexOf("M")>0&&e.indexOf("S")>-1?(i=a()(e.slice(0,e.indexOf("M"))),s=a()(e.slice(e.indexOf("M")+1,e.indexOf("S")))):e.indexOf("H")<0&&e.indexOf("M")<0&&e.indexOf("S")>-1&&(s=a()(e.slice(0,e.indexOf("S")))),3600*t+60*i+s}function h(e,t){return(Array(t).join("0")+e).slice(-t)}function c(e){if(!e)return 0;if(e.indexOf("/")>-1){const t=e.split("/");return a()(t[0])/a()(t[1])}return a()(e)}function g(e,t){const i={source:e,mediaList:{audio:[],video:[],subtitle:[]},type:"live",isEnd:!1,duration:0,minBufferTime:0,maxSegmentDuration:0,minimumUpdatePeriod:0,timestamp:(0,m.A)()},s=[],n=(g=e,g?(0,o.A)(g,{aloneValueName:"value"}):null).MPD;var g;"static"===n.type&&(i.type="vod",i.isEnd=!0),n.minBufferTime&&(i.minBufferTime=u(n.minBufferTime)),n.maxSegmentDuration&&(i.maxSegmentDuration=u(n.maxSegmentDuration)),n.minimumUpdatePeriod&&(i.minimumUpdatePeriod=u(n.minimumUpdatePeriod)),n.mediaPresentationDuration&&(i.duration=u(n.mediaPresentationDuration));let f="";n.BaseURL&&(f=r.Yj(n.BaseURL)?n.BaseURL:n.BaseURL.value);const p=r.YO(n.Period)?n.Period[0]:n.Period;return!i.duration&&p&&p.duration&&(i.duration=u(p.duration)),(r.YO(p.AdaptationSet)?p.AdaptationSet:[p.AdaptationSet]).forEach(((e,n)=>{let o="video/mp4",m="video",u="avc1.64001E",g=640,p=360,L=640,S=360,y=25,R="1:1",P="1",v=588633,b=f,x="und";e.BaseURL&&(b+=e.BaseURL),e.lang&&(x=e.lang),e.mimeType||e.contentType?(o=e.mimeType,m=e.contentType,"video/mp4"===o||"video"===m?(u=e.codecs,g=a()(e.width),p=a()(e.height),e.maxWidth&&(L=a()(e.maxWidth)),e.maxHeight&&(S=a()(e.maxHeight)),e.frameRate&&(y=c(e.frameRate)),R=e.sar,P=e.startWithSAP,v=a()(e.bandwidth)):"audio/mp4"!==o&&"audio"!==m||(u=e.codecs,P=e.startWithSAP,v=a()(e.bandwidth))):(e.maxWidth&&(L=a()(e.maxWidth)),e.maxHeight&&(S=a()(e.maxHeight)),e.frameRate&&(y=c(e.frameRate))),(r.YO(e.Representation)?e.Representation:[e.Representation]).forEach(((n,c)=>{s.indexOf(n.id)>-1&&(n.id=(d()(s[s.length-1])+1).toString()),s.push(n.id);let f="";const w=[];let A=0,I=0,T=t.slice(0,t.lastIndexOf("/")+1)+b;n.mimeType&&(o=n.mimeType),"video/mp4"===o||"video"===m?(n.codecs&&(u=n.codecs),n.width&&(g=a()(n.width)),n.height&&(p=a()(n.height)),n.maxWidth&&(L=a()(n.maxWidth)),n.maxHeight&&(S=a()(n.maxHeight)),n.frameRate&&(y=a()(n.frameRate)),n.sar&&(R=n.sar),n.startWithSAP&&(P=n.startWithSAP),n.bandwidth&&(v=a()(n.bandwidth))):(n.codecs&&(u=n.codecs),n.startWithSAP&&(P=n.startWithSAP),n.bandwidth&&(v=a()(n.bandwidth))),n.BaseURL&&(T+=r.Yj(n.BaseURL)?n.BaseURL:n.BaseURL.value);let O=!1;if((e.ContentProtection||n.ContentProtection)&&(O=!0),n.SegmentBase)"video/mp4"===o||"video"===m?i.mediaList.video.push({id:n.id,file:T,mimeType:o,codecs:u,width:g,height:p,maxWidth:L,maxHeight:S,frameRate:y,sar:R,startWithSAP:"1"===P,bandwidth:v,timescale:A,duration:I,encrypted:O}):"audio/mp4"===o||"audio"===m?i.mediaList.audio.push({id:n.id,file:T,mimeType:o,codecs:u,startWithSAP:"1"===P,bandwidth:v,timescale:A,duration:I,encrypted:O,lang:x}):"application/mp4"!==o&&"text"!==m||i.mediaList.subtitle.push({id:n.id,file:T,mimeType:o,codecs:u,startWithSAP:"1"===P,bandwidth:v,timescale:A,duration:I,encrypted:O,lang:x});else{let t;if(e.SegmentTemplate&&(t=r.YO(e.SegmentTemplate)?e.SegmentTemplate[0]:e.SegmentTemplate),n.SegmentTemplate&&(t=r.YO(n.SegmentTemplate)?n.SegmentTemplate[0]:n.SegmentTemplate),t){const e=d()(t.startNumber);if(f=t.initialization,A=a()(t.timescale||"1"),t.duration&&!t.SegmentTimeline){I=a()(t.duration);let s=I/A;const d=e+Math.ceil((i.duration||s)/s)-1;for(let a=e;a<=d;a++){const o=s*(a-e);let r=s*(a-e+1);a===d&&(s=i.duration-s*(d-e),r=i.duration),w.push({idx:a,start:o,end:r,url:T+t.media.replace(/\$RepresentationID\$/g,n.id).replace(/\$Number(%(\d+)d)?\$/g,((e,t,i)=>i?h(a,+i):(0,l.A)(a))),segmentDuration:s})}}else if(t.SegmentTimeline&&t.SegmentTimeline.S){const i=r.YO(t.SegmentTimeline.S)?t.SegmentTimeline.S:[t.SegmentTimeline.S];let s=0,o=e;for(let e=0;e<i.length;e++){let r=a()(i[e].d);i[e].t&&(s=a()(i[0].t));let m=1;i[e].r&&(m=d()(i[e].r)+1);for(let e=0;e<m;e++)w.push({idx:o,start:s/A,end:(s+r)/A,url:T+t.media.replace(/\$RepresentationID\$/g,n.id).replace(/\$Number(%(\d+)d)?\$/g,((e,t,i)=>i?h(o,+i):(0,l.A)(o))).replace(/\$Time\$/g,(0,l.A)(s)),segmentDuration:r/A}),o++,s+=r}}}else if(n.SegmentList){const e=r.YO(n.SegmentList.SegmentURL)?n.SegmentList.SegmentURL:[n.SegmentList.SegmentURL];let t=0,i=a()(n.SegmentList.duration);for(let s=0;s<e.length;s++)w.push({idx:s,start:t/A,end:(t+i)/A,url:T+e[s].media,segmentDuration:i/A}),t+=i}"video/mp4"===o||"video"===m?i.mediaList.video.push({id:n.id,baseURL:T,initSegment:T+f.replace(/\$RepresentationID\$/g,n.id).replace(/\$Bandwidth\$/g,(0,l.A)(v)),mediaSegments:w,mimeType:o,codecs:u,width:g,height:p,maxWidth:L,maxHeight:S,frameRate:y,sar:R,startWithSAP:"1"===P,bandwidth:v,timescale:A,duration:I,encrypted:O}):"audio/mp4"===o||"audio"===m?i.mediaList.audio.push({id:n.id,baseURL:T,initSegment:T+f.replace(/\$RepresentationID\$/g,n.id).replace(/\$Bandwidth\$/g,(0,l.A)(v)),mediaSegments:w,mimeType:o,codecs:u,startWithSAP:"1"===P,bandwidth:v,timescale:A,duration:I,encrypted:O,lang:x}):"application/mp4"!==o&&"text"!==m||i.mediaList.subtitle.push({id:n.id,baseURL:T,initSegment:T+f.replace(/\$RepresentationID\$/g,n.id).replace(/\$Bandwidth\$/g,(0,l.A)(v)),mediaSegments:w,mimeType:o,codecs:u,startWithSAP:"1"===P,bandwidth:v,timescale:A,duration:I,encrypted:O,lang:x})}}))})),["video","audio"].forEach((e=>{i.mediaList[e].sort(((e,t)=>e.bandwidth-t.bandwidth))})),i}},79331:(e,t,i)=>{i.d(t,{A:()=>r});var s=i(68632),a=i.n(s),n=i(72739);const d={aloneValueName:"_@attribute"},o=[" ","/",'"',"'","<",">"];function r(e,t=d){e=(e=(e=(e=e.replace(/<!--[\s\S]*?-->/g,"")).replace(/[\n\t\r]/g,"")).replace(/>[ \t]+</g,"><")).replace(/<\?[^>]*\?>/g,"");const i=[];let s=0;function r(e,s){const n=i[i.length-1];n&&(e===t.aloneValueName||null==n.obj[t.aloneValueName]?null==n.obj[e]?n.obj[e]=s:a()(n.obj[e])?n.obj[e].push(s):n.obj[e]=[n.obj[e],s]:n.obj[t.aloneValueName]=[n.obj[t.aloneValueName],{tagName:e,...s}])}function l(t){for(;s<e.length;){if(e[s]===t)return!0;s++}return!1}function m(){u();let t="";for(;s<e.length&&!n.zy(o,e[s]);)t+=e[s],s++;return t}function u(){for(;s<e.length&&/\s|\r|\n/.test(e[s]);)s++}const h=/\s/,c=/'/,g=/"/;function f(){if(s>=e.length)return!0;u();let t=h;'"'!==e[s]&&"'"!=e[s]||(t='"'===e[s]?g:c,s++);let i="";for(;s<e.length;){if(t.test(e[s])){s++;break}i+=e[s],s++}return i}function p(){u();let t="";for(;s<e.length&&"<"!==e[s];)t+=e[s],s++;return t}function L(){for(;"<"===e[s];){const t=s;if(s++,u(),"/"!==e[s]){s=t;break}if(s++,m()===i[i.length-1].tag){if(i.length>1){const e=i.pop();r(e.tag,e.obj)}l(">"),s++,u()}else i.pop(),l(">"),s++,u()}}return function a(){if(s>=e.length)return;let n=s;if(u(),"<"!==e[s])return s=n,r(t.aloneValueName,p()),L(),a();let d=l("<");if(!d)return;n=s,s++;const o=m();if(i.push({obj:{},tag:o,start:n}),function(){for(;u(),">"!==e[s]&&"/"!==e[s];){let e=m();if(!e)break;"="===e[e.length-1]?e=e.substring(0,e.length-1):(l("="),s++),r(e,f())}}(),u(),"/"===e[s]){if(s++,i.length>1){const e=i.pop();r(e.tag,e.obj)}return l(">"),s++,L(),a()}d=l(">"),d&&(s++,u(),"<"!==e[s]&&(r(t.aloneValueName,p()),u()),L(),a())}(),{[i[0].tag]:i[0].obj}}}}]);
@@ -1 +1 @@
1
- (self.webpackChunklibmedia=self.webpackChunklibmedia||[]).push([[904],{85947:(t,e,i)=>{i.d(e,{A:()=>r});var s=i(134);class r{constructor(){(0,s.A)(this,"type",-1),(0,s.A)(this,"onStreamAdd",void 0)}async destroy(t){}}},38743:(t,e,i)=>{i.d(e,{B:()=>o,h:()=>h});var s=i(134),r=i(77231),a=i(50011);class n{constructor(){(0,s.A)(this,"list",void 0),this.list=[]}read(t,e){for(let i=0;i<e;i++){const e=t.readUint32();this.list.push(t.readString(e))}}write(t){for(let e=0;e<this.list.length;e++){const i=a.encode(this.list[e]);t.writeUint32(i.length),t.writeBuffer(i)}}addComment(t){this.list.push(t)}}class o{constructor(){(0,s.A)(this,"capturePattern",void 0),(0,s.A)(this,"streamStructureVersion",void 0),(0,s.A)(this,"headerTypeFlag",void 0),(0,s.A)(this,"granulePosition",void 0),(0,s.A)(this,"serialNumber",void 0),(0,s.A)(this,"pageSequenceNumber",void 0),(0,s.A)(this,"crcCheckSum",void 0),(0,s.A)(this,"numberPageSegments",void 0),(0,s.A)(this,"segmentTable",void 0),(0,s.A)(this,"payload",void 0),(0,s.A)(this,"pos",void 0),this.reset()}reset(){this.capturePattern="OggS",this.streamStructureVersion=0,this.headerTypeFlag=0,this.granulePosition=r.Dh,this.serialNumber=0,this.pageSequenceNumber=0,this.crcCheckSum=0,this.numberPageSegments=0,this.segmentTable=[],this.pos=BigInt(0)}async read(t){this.pos=t.getPos(),await this.readPageHeader(t);const e=this.segmentTable.reduce(((t,e)=>t+e),0);e&&(this.payload=await t.readBuffer(e))}async readPageHeader(t){if(this.capturePattern=await t.readString(4),this.streamStructureVersion=await t.readUint8(),this.headerTypeFlag=await t.readUint8(),this.granulePosition=await t.readUint64(),this.serialNumber=await t.readUint32(),this.pageSequenceNumber=await t.readUint32(),this.crcCheckSum=await t.readUint32(),this.numberPageSegments=await t.readUint8(),this.numberPageSegments)for(let e=0;e<this.numberPageSegments;e++){const e=await t.readUint8();this.segmentTable.push(e)}}write(t){if(this.pos=t.getPos(),t.writeString(this.capturePattern),t.writeUint8(this.streamStructureVersion),t.writeUint8(this.headerTypeFlag),t.writeUint64(this.granulePosition),t.writeUint32(this.serialNumber),t.writeUint32(this.pageSequenceNumber),t.writeUint32(this.crcCheckSum),this.payload){this.numberPageSegments=Math.floor(this.payload.length/255)+1;const e=this.payload.length%255;t.writeUint8(this.numberPageSegments);for(let e=0;e<this.numberPageSegments-1;e++)t.writeUint8(255);t.writeUint8(e),t.writeBuffer(this.payload)}else t.writeUint8(0)}}class h{constructor(){(0,s.A)(this,"streamIndex",void 0),(0,s.A)(this,"signature",void 0),(0,s.A)(this,"vendorStringLength",void 0),(0,s.A)(this,"vendorString",void 0),(0,s.A)(this,"userCommentListLength",void 0),(0,s.A)(this,"comments",void 0),this.vendorString="v0.6.1-60-g6901845",this.vendorStringLength=this.vendorString.length,this.userCommentListLength=0,this.comments=new n}read(t){this.vendorStringLength=t.readUint32(),this.vendorString=t.readString(this.vendorStringLength),this.userCommentListLength=t.readUint32(),this.userCommentListLength&&this.comments.read(t,this.userCommentListLength)}write(t){const e=a.encode(this.vendorString);t.writeUint32(e.length),t.writeBuffer(e),t.writeUint32(this.comments.list.length),this.comments.write(t)}addComment(t){this.comments.addComment(t)}setCodec(t){}}},87400:(t,e,i)=>{i.d(e,{GM:()=>h,mS:()=>o,ol:()=>n});var s=i(134),r=i(38743);i(95335),i(34677);const a={album:"album",artist:"artist",description:"description",encoder:"encoder",title:"title",tracknumber:"track",date:"date",genre:"genre",comment:"comment",albumartist:"albumArtist",composer:"composer",performer:"performer",discnumber:"disc",organization:"vendor",copyright:"copyright",license:"license",isrc:"isrc",lyrics:"lyrics",language:"language",label:"vendor",script:"lyrics",encoded_by:"vendor"};function n(t,e){t&&t.forEach((t=>{const i=t.split("=");if(2===i.length){const t=i[0].trim().toLowerCase(),s=i[1].trim();a[t]?e[a[t]]=s:e[t.toLowerCase()]=s}}))}class o{constructor(t="vorbis"){(0,s.A)(this,"streamIndex",void 0),(0,s.A)(this,"packetType",void 0),(0,s.A)(this,"signature",void 0),(0,s.A)(this,"version",void 0),(0,s.A)(this,"channels",void 0),(0,s.A)(this,"sampleRate",void 0),(0,s.A)(this,"bitrateMaximum",void 0),(0,s.A)(this,"bitrateNominal",void 0),(0,s.A)(this,"bitrateMinimum",void 0),(0,s.A)(this,"blocksize0",void 0),(0,s.A)(this,"blocksize1",void 0),(0,s.A)(this,"framingFlag",void 0),this.signature=t,this.version=0,this.channels=1,this.sampleRate=48e3,this.bitrateMaximum=0,this.bitrateNominal=0,this.bitrateMinimum=0,this.blocksize0=2048,this.blocksize1=256}read(t){this.packetType=t.readUint8(),this.signature=t.readString(6),this.version=t.readUint32(),this.channels=t.readUint8(),this.sampleRate=t.readInt32(),this.bitrateMaximum=t.readInt32(),this.bitrateNominal=t.readInt32(),this.bitrateMinimum=t.readInt32();const e=255&t.readUint8();this.blocksize0=Math.pow(2,e>>>4),this.blocksize1=Math.pow(2,15&e),this.framingFlag=t.readUint8()}write(t){t.writeUint8(1),t.writeString(this.signature),t.writeUint32(this.version),t.writeUint8(this.channels),t.writeInt32(this.sampleRate),t.writeInt32(this.bitrateMaximum),t.writeInt32(this.bitrateNominal),t.writeInt32(this.bitrateMinimum),t.writeUint8(Math.log2(this.blocksize0)<<4|Math.log2(this.blocksize1)),t.writeUint8(1)}setCodec(t){this.sampleRate=t.sampleRate,this.channels=t.chLayout.nbChannels}}class h extends r.h{constructor(t="vorbis"){super(),(0,s.A)(this,"packetType",void 0),(0,s.A)(this,"framingFlag",void 0),this.signature=t,this.packetType=1,this.framingFlag=1}read(t){this.packetType=t.readUint8(),this.signature=t.readString(6),super.read(t),"vorbis"===this.signature&&(this.framingFlag=t.readUint8())}write(t){t.writeUint8(this.packetType),t.writeString(this.signature),super.write(t),"vorbis"===this.signature&&t.writeUint8(this.framingFlag)}addComment(t){this.comments.addComment(t)}setCodec(t){}}},2187:(t,e,i)=>{i.d(e,{d:()=>n});var s=i(72739),r=i(44328),a=i(77231);function n(t,e,i){let n=BigInt(0);return s.__(t,(t=>{n+=t.codecpar.bitrate*(0,r.k)(e,i,a.i0)/BigInt(8e3)})),n}},52071:(t,e,i)=>{i.d(e,{A:()=>c});var s=i(63939),r=(i(9599),i(77231)),a=i(44328),n=i(2187),o=i(71517),h=i(9705),d=i(4624);const m="src/avformat/function/seekInBytes.ts";async function c(t,e,i,c,g,l){const u=t.ioReader.getPos(),p=await t.ioReader.fileSize();let w=r.Dh,b=i;e.startTime!==r.Dh?b-=e.startTime:b-=e.firstDTS;const v=(0,a.k)(i,e.timeBase,r.i0);if(v<BigInt(1e4))return d.Yz(`seek pts is earlier then 10s, seek to first packet pos(${c}) directly`,m,62),await t.ioReader.seek(c),u;let f=(0,n.d)(t.streams,b,e.timeBase);const k=p-(0,n.d)(t.streams,BigInt(1e4),r.i0),S=(0,n.d)(t.streams,BigInt(1e4),r.i0);if(f>k&&(f=k),f<c)return await t.ioReader.seek(c),u;const A=(0,o._5)();let U=p,y=BigInt(0);for(;;){if(U-y<S){w=y;break}if(await t.ioReader.seek(f),await l(t),8&t.ioReader.flags)break;const e=t.ioReader.getPos();if(!(await g(t,A)>=0)){w=r.Dh;break}{const t=(0,a.Mr)(s.f[17](A+8),A+72,r.i0),i=t-v;if(d.Yz(`try to seek to pos: ${f}, got packet pts: ${s.f[17](A+8)}(${t}ms), diff: ${i}ms`,m,100),i<=BigInt(0)&&-i<BigInt(1e4)){w=e;break}i>BigInt(0)?(U=f,f=y+U>>BigInt(1)):(y=f,f=y+U>>BigInt(1))}if(8&t.ioReader.flags)break}return(0,o.Qe)(A),w!==r.Dh?(d.Yz(`finally seek to pos ${w}`,m,131),await t.ioReader.seek(w),await l(t),u):(await t.ioReader.seek(u),8&t.ioReader.flags?BigInt(h.LT):BigInt(h.E$))}}}]);
1
+ (self.webpackChunklibmedia=self.webpackChunklibmedia||[]).push([[904],{85947:(t,e,i)=>{i.d(e,{A:()=>r});var s=i(134);class r{constructor(){(0,s.A)(this,"type",-1),(0,s.A)(this,"onStreamAdd",void 0)}async destroy(t){}}},38743:(t,e,i)=>{i.d(e,{B:()=>o,h:()=>h});var s=i(134),r=i(77231),a=i(50011);class n{constructor(){(0,s.A)(this,"list",void 0),this.list=[]}read(t,e){for(let i=0;i<e;i++){const e=t.readUint32();this.list.push(t.readString(e))}}write(t){for(let e=0;e<this.list.length;e++){const i=a.encode(this.list[e]);t.writeUint32(i.length),t.writeBuffer(i)}}addComment(t){this.list.push(t)}}class o{constructor(){(0,s.A)(this,"capturePattern",void 0),(0,s.A)(this,"streamStructureVersion",void 0),(0,s.A)(this,"headerTypeFlag",void 0),(0,s.A)(this,"granulePosition",void 0),(0,s.A)(this,"serialNumber",void 0),(0,s.A)(this,"pageSequenceNumber",void 0),(0,s.A)(this,"crcCheckSum",void 0),(0,s.A)(this,"numberPageSegments",void 0),(0,s.A)(this,"segmentTable",void 0),(0,s.A)(this,"payload",void 0),(0,s.A)(this,"pos",void 0),this.reset()}reset(){this.capturePattern="OggS",this.streamStructureVersion=0,this.headerTypeFlag=0,this.granulePosition=r.Dh,this.serialNumber=0,this.pageSequenceNumber=0,this.crcCheckSum=0,this.numberPageSegments=0,this.segmentTable=[],this.pos=BigInt(0)}async read(t){this.pos=t.getPos(),await this.readPageHeader(t);const e=this.segmentTable.reduce(((t,e)=>t+e),0);e&&(this.payload=await t.readBuffer(e))}async readPageHeader(t){if(this.capturePattern=await t.readString(4),this.streamStructureVersion=await t.readUint8(),this.headerTypeFlag=await t.readUint8(),this.granulePosition=await t.readUint64(),this.serialNumber=await t.readUint32(),this.pageSequenceNumber=await t.readUint32(),this.crcCheckSum=await t.readUint32(),this.numberPageSegments=await t.readUint8(),this.numberPageSegments)for(let e=0;e<this.numberPageSegments;e++){const e=await t.readUint8();this.segmentTable.push(e)}}write(t){if(this.pos=t.getPos(),t.writeString(this.capturePattern),t.writeUint8(this.streamStructureVersion),t.writeUint8(this.headerTypeFlag),t.writeUint64(this.granulePosition),t.writeUint32(this.serialNumber),t.writeUint32(this.pageSequenceNumber),t.writeUint32(this.crcCheckSum),this.payload){this.numberPageSegments=Math.floor(this.payload.length/255)+1;const e=this.payload.length%255;t.writeUint8(this.numberPageSegments);for(let e=0;e<this.numberPageSegments-1;e++)t.writeUint8(255);t.writeUint8(e),t.writeBuffer(this.payload)}else t.writeUint8(0)}}class h{constructor(){(0,s.A)(this,"streamIndex",void 0),(0,s.A)(this,"signature",void 0),(0,s.A)(this,"vendorStringLength",void 0),(0,s.A)(this,"vendorString",void 0),(0,s.A)(this,"userCommentListLength",void 0),(0,s.A)(this,"comments",void 0),this.vendorString="v0.7.0-41-g43c066b",this.vendorStringLength=this.vendorString.length,this.userCommentListLength=0,this.comments=new n}read(t){this.vendorStringLength=t.readUint32(),this.vendorString=t.readString(this.vendorStringLength),this.userCommentListLength=t.readUint32(),this.userCommentListLength&&this.comments.read(t,this.userCommentListLength)}write(t){const e=a.encode(this.vendorString);t.writeUint32(e.length),t.writeBuffer(e),t.writeUint32(this.comments.list.length),this.comments.write(t)}addComment(t){this.comments.addComment(t)}setCodec(t){}}},87400:(t,e,i)=>{i.d(e,{GM:()=>h,mS:()=>o,ol:()=>n});var s=i(134),r=i(38743);i(95335),i(34677);const a={album:"album",artist:"artist",description:"description",encoder:"encoder",title:"title",tracknumber:"track",date:"date",genre:"genre",comment:"comment",albumartist:"albumArtist",composer:"composer",performer:"performer",discnumber:"disc",organization:"vendor",copyright:"copyright",license:"license",isrc:"isrc",lyrics:"lyrics",language:"language",label:"vendor",script:"lyrics",encoded_by:"vendor"};function n(t,e){t&&t.forEach((t=>{const i=t.split("=");if(2===i.length){const t=i[0].trim().toLowerCase(),s=i[1].trim();a[t]?e[a[t]]=s:e[t.toLowerCase()]=s}}))}class o{constructor(t="vorbis"){(0,s.A)(this,"streamIndex",void 0),(0,s.A)(this,"packetType",void 0),(0,s.A)(this,"signature",void 0),(0,s.A)(this,"version",void 0),(0,s.A)(this,"channels",void 0),(0,s.A)(this,"sampleRate",void 0),(0,s.A)(this,"bitrateMaximum",void 0),(0,s.A)(this,"bitrateNominal",void 0),(0,s.A)(this,"bitrateMinimum",void 0),(0,s.A)(this,"blocksize0",void 0),(0,s.A)(this,"blocksize1",void 0),(0,s.A)(this,"framingFlag",void 0),this.signature=t,this.version=0,this.channels=1,this.sampleRate=48e3,this.bitrateMaximum=0,this.bitrateNominal=0,this.bitrateMinimum=0,this.blocksize0=2048,this.blocksize1=256}read(t){this.packetType=t.readUint8(),this.signature=t.readString(6),this.version=t.readUint32(),this.channels=t.readUint8(),this.sampleRate=t.readInt32(),this.bitrateMaximum=t.readInt32(),this.bitrateNominal=t.readInt32(),this.bitrateMinimum=t.readInt32();const e=255&t.readUint8();this.blocksize0=Math.pow(2,e>>>4),this.blocksize1=Math.pow(2,15&e),this.framingFlag=t.readUint8()}write(t){t.writeUint8(1),t.writeString(this.signature),t.writeUint32(this.version),t.writeUint8(this.channels),t.writeInt32(this.sampleRate),t.writeInt32(this.bitrateMaximum),t.writeInt32(this.bitrateNominal),t.writeInt32(this.bitrateMinimum),t.writeUint8(Math.log2(this.blocksize0)<<4|Math.log2(this.blocksize1)),t.writeUint8(1)}setCodec(t){this.sampleRate=t.sampleRate,this.channels=t.chLayout.nbChannels}}class h extends r.h{constructor(t="vorbis"){super(),(0,s.A)(this,"packetType",void 0),(0,s.A)(this,"framingFlag",void 0),this.signature=t,this.packetType=1,this.framingFlag=1}read(t){this.packetType=t.readUint8(),this.signature=t.readString(6),super.read(t),"vorbis"===this.signature&&(this.framingFlag=t.readUint8())}write(t){t.writeUint8(this.packetType),t.writeString(this.signature),super.write(t),"vorbis"===this.signature&&t.writeUint8(this.framingFlag)}addComment(t){this.comments.addComment(t)}setCodec(t){}}},2187:(t,e,i)=>{i.d(e,{d:()=>n});var s=i(72739),r=i(44328),a=i(77231);function n(t,e,i){let n=BigInt(0);return s.__(t,(t=>{n+=t.codecpar.bitrate*(0,r.k)(e,i,a.i0)/BigInt(8e3)})),n}},52071:(t,e,i)=>{i.d(e,{A:()=>c});var s=i(63939),r=(i(9599),i(77231)),a=i(44328),n=i(2187),o=i(71517),h=i(9705),d=i(4624);const m="src/avformat/function/seekInBytes.ts";async function c(t,e,i,c,g,l){const u=t.ioReader.getPos(),p=await t.ioReader.fileSize();let b=r.Dh,w=i;e.startTime!==r.Dh?w-=e.startTime:w-=e.firstDTS;const v=(0,a.k)(i,e.timeBase,r.i0);if(v<BigInt(1e4))return d.Yz(`seek pts is earlier then 10s, seek to first packet pos(${c}) directly`,m,62),await t.ioReader.seek(c),u;let f=(0,n.d)(t.streams,w,e.timeBase);const k=p-(0,n.d)(t.streams,BigInt(1e4),r.i0),S=(0,n.d)(t.streams,BigInt(1e4),r.i0);if(f>k&&(f=k),f<c)return await t.ioReader.seek(c),u;const A=(0,o._5)();let U=p,y=BigInt(0);for(;;){if(U-y<S){b=y;break}if(await t.ioReader.seek(f),await l(t),8&t.ioReader.flags)break;const e=t.ioReader.getPos();if(!(await g(t,A)>=0)){b=r.Dh;break}{const t=(0,a.Mr)(s.f[17](A+8),A+72,r.i0),i=t-v;if(d.Yz(`try to seek to pos: ${f}, got packet pts: ${s.f[17](A+8)}(${t}ms), diff: ${i}ms`,m,100),i<=BigInt(0)&&-i<BigInt(1e4)){b=e;break}i>BigInt(0)?(U=f,f=y+U>>BigInt(1)):(y=f,f=y+U>>BigInt(1))}if(8&t.ioReader.flags)break}return(0,o.Qe)(A),b!==r.Dh?(d.Yz(`finally seek to pos ${b}`,m,131),await t.ioReader.seek(b),await l(t),u):(await t.ioReader.seek(u),8&t.ioReader.flags?BigInt(h.LT):BigInt(h.E$))}}}]);
@@ -1 +1 @@
1
- (self.webpackChunklibmedia=self.webpackChunklibmedia||[]).push([[941],{85947:(e,t,a)=>{a.d(t,{A:()=>r});var i=a(134);class r{constructor(){(0,i.A)(this,"type",-1),(0,i.A)(this,"onStreamAdd",void 0)}async destroy(e){}}},34577:(e,t,a)=>{a.r(t),a.d(t,{default:()=>H});var i=a(134),r=a(80662),n=a.n(r),c=a(97860),o=a.n(c),d=a(14686),s=a(61499),l=a(63939),p=a(50932),f=(a(9599),a(4624)),h=a(9705),m=a(85947),u=a(37837),g=a(71517),A=a(77231),y=a(31866),I=a(33919),N=a(72739),x=a(62815),b=a(67659),S=a(59166),P=a(97077),R=a(82014),k=a(21477),B=a(64093),v=a(22576),w=a(95832),U=a(14769),V=a(44328),C=a(31865),L=a(93082),_=a(5783),M=a(82774),D=a(67672),T=a(95335),E=a(53260),z=a(13663),X=a(92647),G=a(50011),O=a(34677),F=a(60264);const W="src/avformat/formats/IMatroskaFormat.ts";class H extends m.A{constructor(){super(),(0,i.A)(this,"type",8),(0,i.A)(this,"context",void 0),(0,i.A)(this,"blockReader",void 0)}init(e){e.ioReader&&e.ioReader.setEndian(!0);const t={isLive:!0,firstCluster:-BigInt(1),segmentStart:-BigInt(1),header:{version:0,readVersion:0,maxIdLength:4,maxSizeLength:8,docType:"",docTypeVersion:0,docTypeReadVersion:0},seekHead:null,info:null,tracks:null,attachments:null,chapters:null,cues:null,tags:null,maxPts:A.Dh,currentCluster:{timeCode:BigInt(0),pos:-BigInt(1),block:{pos:-BigInt(1),size:-BigInt(1)},blockGroup:{block:null}},clusterIndexes:[],clusterIndexesPosMap:new(n())};e.privateData=this.context=t}analyzeStreams(e){const t="webm"===this.context.header.docType?y.N:y.e;this.context.tracks&&N.__(this.context.tracks.entry,(a=>{var i,r,n;const c=e.createStream();switch(c.privData=a,c.codecpar.codecId=t[a.codecId]||0,a.type){case 2:c.codecpar.codecType=1;break;case 1:c.codecpar.codecType=0;break;case 17:c.codecpar.codecType=3;break;default:c.codecpar.codecType=-1}a.language&&(c.metadata.language=a.language),a.name&&(c.metadata.title=a.name),a.audio?("A_PCM/FLOAT/IEEE"===a.codecName?64===a.audio.bitDepth?c.codecpar.codecId=65559:32===a.audio.bitDepth&&(c.codecpar.codecId=65557):"A_PCM/INT/BIG"===a.codecName?16===a.audio.bitDepth?c.codecpar.codecId=65537:24===a.audio.bitDepth?c.codecpar.codecId=65549:32===a.audio.bitDepth&&(c.codecpar.codecId=65545):"A_PCM/INT/LIT"===a.codecName&&(8===a.audio.bitDepth?c.codecpar.codecId=65541:16===a.audio.bitDepth?c.codecpar.codecId=65536:24===a.audio.bitDepth?c.codecpar.codecId=65548:32===a.audio.bitDepth&&(c.codecpar.codecId=65544)),c.codecpar.chLayout.nbChannels=a.audio.channels,c.codecpar.sampleRate=0|a.audio.sampleRate,c.codecpar.bitsPerCodedSample=a.audio.bitDepth):a.video&&(c.codecpar.width=a.video.pixelWidth,c.codecpar.height=a.video.pixelHeight,a.video.color&&(D.ai(a.video.color.primaries)&&(c.codecpar.colorPrimaries=a.video.color.primaries),D.ai(a.video.color.transferCharacteristics)&&(c.codecpar.colorTrc=a.video.color.transferCharacteristics),D.ai(a.video.color.range)&&(c.codecpar.colorRange=a.video.color.range),D.ai(a.video.color.matrixCoefficients)&&(c.codecpar.colorSpace=a.video.color.matrixCoefficients)));let o=0;if("V_MS/VFW/FOURCC"===a.codecId&&(null===(i=a.codecPrivate)||void 0===i?void 0:i.size)>=40)c.codecpar.bitsPerCodedSample=a.codecPrivate.data[15]<<8|a.codecPrivate.data[14],c.codecpar.codecTag=a.codecPrivate.data[19]<<24|a.codecPrivate.data[18]<<16|a.codecPrivate.data[17]<<8|a.codecPrivate.data[16],c.codecpar.codecId=E.n[c.codecpar.codecTag]||0,0===c.codecpar.codecId&&(c.codecpar.codecId,z.h[c.codecpar.codecTag]),o=40;else if("V_QUICKTIME"===a.codecId&&(null===(r=a.codecPrivate)||void 0===r?void 0:r.size)>=21){const e=1===c.codecpar.codecType?z.u:z.h;c.codecpar.codecTag=a.codecPrivate.data[3]<<24|a.codecPrivate.data[2]<<16|a.codecPrivate.data[1]<<8|a.codecPrivate.data[0];const t=e[c.codecpar.codecTag];if(t){const e=new Uint8Array(4),t=Number(BigInt.asIntN(32,a.codecPrivate.size));e[0]=t>>>24&255,e[1]=t>>>16&255,e[2]=t>>>8&255,e[3]=255&t,a.codecPrivate.size+=BigInt(4),a.codecPrivate.data=(0,X.A)(Uint8Array,[e,a.codecPrivate.data])}c.codecpar.codecId=t||0}if(null!==(n=a.codecPrivate)&&void 0!==n&&n.data&&a.codecPrivate.size-BigInt(Math.floor(o))>0){let e=a.codecPrivate.data.subarray(o);if(94212===c.codecpar.codecId||94230===c.codecpar.codecId){let t=G.decode(e).split(/\r?\n/);for(let e=0;e<t.length;e++)if("[Events]"===t[e].trim()){t=t.slice(0,e);break}t.push("[Events]"),t.push("Format: ReadOrder, Layer, Style, Name, MarginL, MarginR, MarginV, Effect, Text"),e=G.encode(t.join("\n"))}if(c.codecpar.extradataSize=e.length,c.codecpar.extradata=(0,u.sY)(e.length),(0,d.lW)(c.codecpar.extradata,e.length,e),c.codecpar.extradata)switch(c.codecpar.codecId){case 27:{const e=(0,d.s3)(c.codecpar.extradata,c.codecpar.extradataSize);x.XC(c,e),F.Bs(e)?c.codecpar.bitFormat=2:c.codecpar.bitFormat=1;break}case 173:{const e=(0,d.s3)(c.codecpar.extradata,c.codecpar.extradataSize);b.XC(c,e),F.Bs(e)?c.codecpar.bitFormat=2:c.codecpar.bitFormat=1;break}case 196:{const e=(0,d.s3)(c.codecpar.extradata,c.codecpar.extradataSize);S.XC(c,e),F.Bs(e)?c.codecpar.bitFormat=2:c.codecpar.bitFormat=1;break}case 225:k.XC(c,(0,d.s3)(c.codecpar.extradata,c.codecpar.extradataSize));break;case 139:P.XC(c,(0,d.s3)(c.codecpar.extradata,c.codecpar.extradataSize));break;case 167:R.XC(c,(0,d.s3)(c.codecpar.extradata,c.codecpar.extradataSize));break;case 86018:w.XC(c,(0,d.s3)(c.codecpar.extradata,c.codecpar.extradataSize));break;case 86017:B.XC(c,(0,d.s3)(c.codecpar.extradata,c.codecpar.extradataSize));break;case 86076:v.XC(c,(0,d.s3)(c.codecpar.extradata,c.codecpar.extradataSize));break;case 86028:if(c.codecpar.extradataSize>U.ob){const e=new C.A((0,d.s3)(c.codecpar.extradata,c.codecpar.extradataSize));if("fLaC"===e.readString(4))for(;e.remainingSize();){const t=e.readUint8(),a=e.readUint24(),i=-129&t;if(0===i){const t=e.readBuffer(a);(0,u.Eb)(c.codecpar.extradata),c.codecpar.extradata=(0,u.sY)(t.length),c.codecpar.extradataSize=t.length,(0,d.lW)(c.codecpar.extradata,t.length,t);break}e.skip(i)}}c.codecpar.extradataSize===U.ob&&U.XC(c,(0,d.s3)(c.codecpar.extradata,c.codecpar.extradataSize))}else{let e;86018===c.codecpar.codecId&&(e=w.Ij(c.codecpar)),e&&(c.codecpar.extradataSize=e.length,c.codecpar.extradata=(0,u.sY)(c.codecpar.extradataSize),(0,d.lW)(c.codecpar.extradata,c.codecpar.extradataSize,e))}}this.context.info&&(c.timeBase.num=1,this.context.info.timestampScale?c.timeBase.den=1e3*A.SF/this.context.info.timestampScale|0:(c.timeBase.den=1e3,this.context.info.timestampScale=A.SF),this.context.info.duration&&(c.duration=BigInt(Math.floor(this.context.info.duration)))),(null==a.default||a.default)&&(c.disposition|=1),a.encodings&&N.__(a.encodings.entry,(e=>{e.compression&&(0,O.A)(e.compression.algo)&&(a.needDecompression=!0),e.encryption&&(0,O.A)(e.encryption.algo)&&(a.needDecryption=!0)}))})),this.context.attachments&&N.__(this.context.attachments.entry,(t=>{const a=e.createStream();a.codecpar.codecType=4,a.privData=t,t.data&&(a.codecpar.extradataSize=Number(BigInt.asIntN(32,t.data.size)),a.codecpar.extradata=(0,u.sY)(a.codecpar.extradataSize),(0,d.lW)(a.codecpar.extradata,a.codecpar.extradataSize,t.data.data))})),this.context.tags&&N.__(this.context.tags.entry,(t=>{var a;if("DURATION"===(null===(a=t.tag)||void 0===a?void 0:a.name)){let a=t.tag.string.replaceAll("\0","").split("."),i=a[0].split(":"),r=BigInt(+i[0])*BigInt(36e8)+BigInt(+i[1])*BigInt(6e7)+BigInt(+i[2])*BigInt(1e6)+BigInt(+a[1])/BigInt(1e3);const n=(0,L.A)(e.streams,t.target.trackUid);n&&(n.duration=(0,V.k)(r,A.KR,n.timeBase))}})),this.context.chapters&&N.__(this.context.chapters.entry,(t=>{const a=t.atom;a&&N.__(a,(t=>{var a,i;e.chapters.push({id:t.uid,start:t.start,end:t.end,timeBase:{num:1,den:1e9},metadata:{title:(null===(a=t.display)||void 0===a?void 0:a.title)||"",language:(null===(i=t.display)||void 0===i?void 0:i.language)||""}})}))}))}async readHeader(e){if(440786851!==await(0,I.aL)(e,this.context.header.maxIdLength))return f.z3("not matroska format",W,460),h.LR;const t=await(0,I.Qb)(e.ioReader,this.context.header.maxSizeLength);if(this.context.header=T.X$(this.context.header,await(0,I.Pb)(e,t,I.jt)),408125543!==await(0,I.aL)(e,this.context.header.maxIdLength))return f.z3("not matroska format",W,469),h.LR;const a=await(0,I.Qb)(e.ioReader,this.context.header.maxSizeLength);this.context.segmentStart=e.ioReader.getPos();const i=e.ioReader.getPos()+a,r=new(o());let n=!1,c=!1;for(;e.ioReader.getPos()<i||!n||!c;){const t=e.ioReader.getPos(),a=await(0,I.aL)(e,this.context.header.maxIdLength);if(a===h.LR){await this.syncTopLevelElement(e,2);continue}const i=await(0,I.Qb)(e.ioReader,this.context.header.maxSizeLength);if(i!==BigInt(0|h.LR)){if(290298740===a)this.context.isLive=!1,this.context.seekHead=await(0,I.Pb)(e,i,I.Cr);else if(475249515===a)this.context.isLive=!1,this.context.cues=await(0,I.Pb)(e,i,I.eG);else if(272869232===a)this.context.isLive=!1,this.context.chapters=await(0,I.Pb)(e,i,I.Y0);else if(357149030===a)this.context.info=await(0,I.Pb)(e,i,I.qi);else if(307544935===a)this.context.tags=await(0,I.Pb)(e,i,I.hK);else if(423732329===a)this.context.attachments=await(0,I.Pb)(e,i,I.qp);else if(374648427===a)n=!0,this.context.tracks=await(0,I.Pb)(e,i,I.Wy);else if(524531317===a){if(c=!0,this.context.firstCluster=t,this.context.isLive||!this.context.seekHead||!(1&e.ioReader.flags))break;const a=this.context.seekHead.entry;let i=0;for(;i<a.length;i++)if(!r.has(a[i].id)){await e.ioReader.seek(a[i].pos+this.context.segmentStart);break}if(i===a.length)break}else await e.ioReader.skip(Number(BigInt.asIntN(32,i)));r.add(a)}else await this.syncTopLevelElement(e,2)}return this.context.firstCluster>0&&await e.ioReader.seek(this.context.firstCluster),this.analyzeStreams(e),0}parseAdditions(e,t){for(let i=0;i<t.entry.length;i++){var a;const r=t.entry[i];if(null!==(a=r.additional)&&void 0!==a&&a.size){4===r.additionalId&&f.R8("ITU_T_T35 not support now",W,563);const t=(0,u.sY)(r.additional.data.length+8);M.Cv(t,BigInt(r.additionalId>>>0)),(0,d.lW)(t+8,r.additional.data.length,r.additional.data),(0,g.Ow)(e,15,t,r.additional.data.length+8)}}}async parseBlock(e,t){var a,i,r;const n=(null===(a=this.context.currentCluster.block)||void 0===a?void 0:a.data)||this.context.currentCluster.blockGroup.block.data;let c=null===(i=this.context.currentCluster.block)||void 0===i?void 0:i.pos;c<0&&(c=this.context.currentCluster.blockGroup.block.pos);let o,m=-1,y=BigInt(0);null!==(r=this.context.currentCluster.blockGroup)&&void 0!==r&&r.block&&(o=this.context.currentCluster.blockGroup.additions,m=this.context.currentCluster.blockGroup.reference?0===this.context.currentCluster.blockGroup.reference.length?1:0:1,this.context.currentCluster.blockGroup.duration&&(y=this.context.currentCluster.blockGroup.duration)),this.blockReader?this.blockReader.resetBuffer(n):this.blockReader=new C.A(n);const N=this.blockReader.getPos(),x=Number(BigInt.asUintN(32,await(0,I.Qb)(this.blockReader,8))),b=(0,_.A)(e.streams,x);if(!b)return f.z3(`invalid track number ${x}`,W,613),h.OY;const S=this.blockReader.readInt16(),P=this.blockReader.readUint8();-1===m&&(m=128&P?1:0);let R=0,k=[];switch(P>>>1&3){case 1:{R=this.blockReader.readUint8()+1;let e=0;for(let t=0;t<R-1;t++){let t=0;for(;;){const e=this.blockReader.readUint8();if(0===e)break;if(255!==e){t+=e;break}t+=255}e+=t,k.push(t)}k.push(n.length-Number(BigInt.asIntN(32,this.blockReader.getPos()-N))-e);break}case 3:{R=this.blockReader.readUint8()+1,k.push(await(0,I.Ag)(this.blockReader,4));let e=k[0];for(let t=1;t<R-1;t++){let a=await(0,I.pf)(this.blockReader,4)+k[t-1];e+=a,k.push(a)}k.push(n.length-Number(BigInt.asIntN(32,this.blockReader.getPos()-N))-e);break}case 2:R=this.blockReader.readUint8()+1;const e=(n.length-Number(BigInt.asIntN(32,this.blockReader.getPos()-N)))/R;for(let t=0;t<R;t++)k.push(e);break;case 0:R=1,k.push(n.length-Number(BigInt.asIntN(32,this.blockReader.getPos()-N)))}const B=b.privData,v=B.timeScale||1;if(B.needDecryption)throw new Error("not support encryption stream");let w=(this.context.currentCluster.timeCode+BigInt(Math.floor(S*v)))*BigInt(0|this.context.info.timestampScale);B.codecDelay&&(w-=B.codecDelay),w/=BigInt(1e3),w=(0,V.k)(w,A.KR,b.timeBase),y=BigInt(Math.floor(Number(BigInt.asIntN(32,y))*v))*BigInt(0|this.context.info.timestampScale),y/=BigInt(1e3),y=(0,V.k)(y,A.KR,b.timeBase);for(let a=0;a<R;a++){const i=0!==a?(0,g._5)():t;let r,n=k[a],h=0;if(B.needDecompression){const e=B.encodings.entry.find((e=>!!e.compression));3===e.compression.algo?(r=e.compression.settings.data,n+=r.length,h=r.length):f.h2(`not support compression stream, algo: ${e.compression.algo}`,W,723)}p.M[17](i+56,c+this.blockReader.getPos()),p.M[15](i+32,b.index),(0,d.Mr)(i+72,b.timeBase[s.o9],8),p.M[17](i+8,w),p.M[15](i+28,n),p.M[17](i+48,y);const A=(0,u.sY)(n);r&&(0,d.lW)(A,h,r),(0,d.lW)(A+h,k[a],this.blockReader.readBuffer(k[a])),(0,g.NX)(i,A,n),0!==b.codecpar.codecType?(p.M[15](i+36,1|l.f[15](i+36)),p.M[17](i+16,w)):(m&&p.M[15](i+36,1|l.f[15](i+36)),27!==b.codecpar.codecId&&173!==b.codecpar.codecId&&196!==b.codecpar.codecId||p.M[15](i+80,b.codecpar.bitFormat)),o&&this.parseAdditions(i,o),0!==a&&e.interval.packetBuffer.push(i),this.context.maxPts<w&&(this.context.maxPts=w)}return this.context.currentCluster.block={pos:-BigInt(1),size:-BigInt(1)},this.context.currentCluster.blockGroup={block:null},0}addClusterIndex(e){if(this.context.clusterIndexesPosMap.has(e.pos))return;const t=N.El(this.context.clusterIndexes,(t=>t.time<e.time?1:-1));t>-1?(this.context.clusterIndexesPosMap.set(e.pos,t),this.context.clusterIndexes.splice(t,0,e)):(this.context.clusterIndexesPosMap.set(e.pos,this.context.clusterIndexes.length),this.context.clusterIndexes.push(e))}async readAVPacket_(e,t){const a=e.ioReader.getPos(),i=await(0,I.aL)(e,this.context.header.maxIdLength);if(i===h.LR)return await this.syncTopLevelElement(e),this.readAVPacket_(e,t);const r=await(0,I.Qb)(e.ioReader,this.context.header.maxSizeLength);if(r===BigInt(h.LR))return await this.syncTopLevelElement(e),this.readAVPacket_(e,t);if(524531317===i){this.context.currentCluster.pos=a,this.context.currentCluster.timeCode=BigInt(0),await(0,I.Pb)(e,r,I.GZ,this.context.currentCluster,[163,160]),this.context.isLive||this.addClusterIndex({time:this.context.currentCluster.timeCode,pos:a});let i=await this.parseBlock(e,t);if(i===h.OY)return this.readAVPacket_(e,t);if(i<0)return i}else if(163===i){this.context.currentCluster.block={pos:e.ioReader.getPos(),size:r,data:await e.ioReader.readBuffer(Number(BigInt.asIntN(32,r)))};let a=await this.parseBlock(e,t);if(a===h.OY)return this.readAVPacket_(e,t);if(a<0)return a}else{if(160!==i)return 475249515===i||307544935===i||423732329===i||272869232===i||357149030===i||374648427===i||290298740===i?(await e.ioReader.skip(Number(BigInt.asIntN(32,r))),this.readAVPacket_(e,t)):(await this.syncTopLevelElement(e),this.readAVPacket_(e,t));{await(0,I.Pb)(e,r,I.Wg,this.context.currentCluster.blockGroup);let a=await this.parseBlock(e,t);if(a===h.OY)return this.readAVPacket_(e,t);if(a<0)return a}}return 0}async readAVPacket(e,t){try{return await this.readAVPacket_(e,t)}catch(t){return-1048576!==e.ioReader.error?(f.z3(`read packet error, ${t}`,W,900),h.LR):e.ioReader.error}}async syncTopLevelElement(e,t=3){let a=A.Dh;for(;;)try{if(8&e.ioReader.flags)break;const i=e.ioReader.getPos(),r=await e.ioReader.peekUint32();if(524531317===r||475249515===r||307544935===r||423732329===r||272869232===r||357149030===r||374648427===r||290298740===r){a=i;let r=0;await e.ioReader.skip(4);const n=await(0,I.Qb)(e.ioReader,this.context.header.maxSizeLength);if(n===BigInt(h.LR)){await e.ioReader.seek(i+BigInt(1));continue}for(await e.ioReader.skip(Number(BigInt.asIntN(32,n)));r<=t;){const t=await(0,I.aL)(e,this.context.header.maxIdLength),a=await(0,I.Qb)(e.ioReader,this.context.header.maxSizeLength);if(524531317!==t&&475249515!==t&&307544935!==t&&423732329!==t&&272869232!==t&&357149030!==t&&374648427!==t&&290298740!==t)break;r++,await e.ioReader.skip(Number(BigInt.asIntN(32,a)))}if(!(r<t))break;await e.ioReader.seek(a+BigInt(1)),a=A.Dh}else await e.ioReader.skip(1),a=A.Dh}catch(e){break}a!==A.Dh&&await e.ioReader.seek(a)}async seek(e,t,a,i){var r;const n=e.ioReader.getPos(),c=(0,V.k)(a,t.timeBase,A.KR);let o=A.Dh;if(null!==(r=this.context.cues)&&void 0!==r&&r.entry.length){const e=t.privData;for(let t=0;t<this.context.cues.entry.length;t++)if((this.context.cues.entry[t].time||BigInt(0))*BigInt(0|this.context.info.timestampScale)/BigInt(1e3)>c){const a=this.context.cues.entry[Math.max(t-1,0)].pos;if(a.length){const t=a.find((t=>t.track===e.number));if(t){o=t.pos+this.context.segmentStart;break}}}}if(o===A.Dh&&this.context.clusterIndexes.length){for(let e=0;e<this.context.clusterIndexes.length;e++)if(this.context.clusterIndexes[e].time*BigInt(0|this.context.info.timestampScale)/BigInt(1e3)>c){o=this.context.clusterIndexes[Math.max(e-1,0)].pos;break}o===A.Dh&&(o=this.context.clusterIndexes[this.context.clusterIndexes.length-1].pos)}return o!==A.Dh?(await e.ioReader.seek(o),n):BigInt(h.E$)}getAnalyzeStreamsCount(){return 0}}},13663:(e,t,a)=>{a.d(t,{h:()=>r,u:()=>n});var i=a(79682);const r={[(0,i.A)("mp4v")]:12,[(0,i.A)("DIVX")]:12,[(0,i.A)("XVID")]:12,[(0,i.A)("3IV2")]:12,[(0,i.A)("vvc1")]:196,[(0,i.A)("vvi1")]:196,[(0,i.A)("hev1")]:173,[(0,i.A)("hvc1")]:173,[(0,i.A)("dvhe")]:173,[(0,i.A)("hev1")]:173,[(0,i.A)("avc1")]:27,[(0,i.A)("avc2")]:27,[(0,i.A)("avc3")]:27,[(0,i.A)("avc4")]:27,[(0,i.A)("ai5p")]:27,[(0,i.A)("ai5q")]:27,[(0,i.A)("ai52")]:27,[(0,i.A)("ai53")]:27,[(0,i.A)("ai55")]:27,[(0,i.A)("ai56")]:27,[(0,i.A)("ai1p")]:27,[(0,i.A)("ai1q")]:27,[(0,i.A)("ai12")]:27,[(0,i.A)("ai13")]:27,[(0,i.A)("ai15")]:27,[(0,i.A)("ai16")]:27,[(0,i.A)("AVin")]:27,[(0,i.A)("aivx")]:27,[(0,i.A)("rv64")]:27,[(0,i.A)("xalg")]:27,[(0,i.A)("avlg")]:27,[(0,i.A)("dva1")]:27,[(0,i.A)("dvav")]:27,[(0,i.A)("vp08")]:139,[(0,i.A)("vp09")]:167,[(0,i.A)("av01")]:225},n={[(0,i.A)("mp4a")]:86018,[(0,i.A)("ac-3")]:86019,[(0,i.A)("sac3")]:86019,[(0,i.A)("ac-4")]:86119,[(0,i.A)("dtsc")]:86020,[(0,i.A)("dtsh")]:86020,[(0,i.A)("dtsl")]:86020,[(0,i.A)("dtse")]:86020,[(0,i.A)("DTS ")]:86020,[(0,i.A)("ec-3")]:86056,[(0,i.A)(".mp3")]:86017,[(0,i.A)("mp3 ")]:86017,1836253269:86017,[(0,i.A)("spex")]:86051,[(0,i.A)("SPXN")]:86051,[(0,i.A)("fLaC")]:86028,[(0,i.A)("Opus")]:86076,[(0,i.A)("alaw")]:65543,[(0,i.A)("ulaw")]:65542,[(0,i.A)("fl32")]:65557,[(0,i.A)("fl64")]:65559,[(0,i.A)("twos")]:65537,[(0,i.A)("lpcm")]:65536,[(0,i.A)("sowt")]:65536,[(0,i.A)("in24")]:65548,[(0,i.A)("in32")]:65544,[(0,i.A)("sowt")]:65540,[(0,i.A)("raw ")]:65541,[(0,i.A)("NONE")]:65541}},5783:(e,t,a)=>{function i(e,t){for(let a=0;a<e.length;a++)if(e[a].privData.number===t)return e[a]}a.d(t,{A:()=>i})},93082:(e,t,a)=>{function i(e,t){for(let a=0;a<e.length;a++)if(e[a].privData.uid===t)return e[a]}a.d(t,{A:()=>i})},33919:(e,t,a)=>{a.d(t,{Ag:()=>N,Cr:()=>s,GZ:()=>y,Pb:()=>k,Qb:()=>b,Wg:()=>A,Wy:()=>p,Y0:()=>h,aL:()=>R,eG:()=>m,hK:()=>g,jt:()=>I,pf:()=>x,qi:()=>l,qp:()=>f});var i=a(4624),r=a(9705),n=a(67672),c=a(72739);const o="src/avformat/formats/matroska/imatroska.ts",d=BigInt(20971520),s={19899:{type:9,isArray:!0,filedName:"entry",child:{21419:{type:1,filedName:"id"},21420:{type:2,filedName:"pos"}}}},l={29604:{type:2,filedName:"segmentUUID"},2807729:{type:1,filedName:"timestampScale"},17545:{type:5,filedName:"duration"},31657:{type:7,filedName:"title"},19840:{type:7,filedName:"muxingApp"},22337:{type:7,filedName:"writingApp"},17505:{type:8,filedName:"dateUTC"}},p={174:{type:9,isArray:!0,filedName:"entry",child:{215:{type:1,filedName:"number"},29637:{type:1,filedName:"uid"},131:{type:1,filedName:"type"},21358:{type:7,filedName:"name"},136:{type:10,filedName:"default"},185:{type:10,filedName:"enabled"},2274716:{type:7,filedName:"language"},2306383:{type:6,filedName:"timeScale"},134:{type:7,filedName:"codecId"},2459272:{type:7,filedName:"codecName"},25506:{type:8,filedName:"codecPrivate"},225:{type:9,filedName:"audio",child:{181:{type:5,filedName:"sampleRate"},30901:{type:5,filedName:"outSampleRate"},25188:{type:1,filedName:"bitDepth"},159:{type:1,filedName:"channels"}}},224:{type:9,filedName:"video",child:{2327523:{type:1,filedName:"framerate"},21680:{type:1,filedName:"displayWidth"},21690:{type:1,filedName:"displayHeight"},176:{type:1,filedName:"pixelWidth"},186:{type:1,filedName:"pixelHeight"},3061028:{type:8,filedName:"colorSpace"},21440:{type:1,filedName:"alphaMode"},21936:{type:9,filedName:"color",child:{21937:{type:1,filedName:"matrixCoefficients"},21938:{type:1,filedName:"bitsPerChannel"},21941:{type:1,filedName:"cbSubHorz"},21942:{type:1,filedName:"cbSubVert"},21939:{type:1,filedName:"chromaSubHorz"},21940:{type:1,filedName:"chromaSubVert"},21943:{type:1,filedName:"chromaSitingHorz"},21944:{type:1,filedName:"chromaSitingVert"},21945:{type:1,filedName:"range"},21946:{type:1,filedName:"transferCharacteristics"},21947:{type:1,filedName:"primaries"},21948:{type:1,filedName:"maxCll"},21949:{type:1,filedName:"maxFall"},21968:{type:9,filedName:"masteringMeta",child:{21969:{type:5,filedName:"rx"},21970:{type:5,filedName:"ry"},21971:{type:5,filedName:"gx"},21972:{type:5,filedName:"gy"},21973:{type:5,filedName:"bx"},21974:{type:5,filedName:"by"},21975:{type:5,filedName:"whiteX"},21976:{type:5,filedName:"whiteY"},21978:{type:5,isArray:!0,filedName:"minLuminance"},21977:{type:5,filedName:"maxLuminance"}}}}},30320:{type:9,filedName:"projection",child:{30321:{type:1,filedName:"type"},30322:{type:8,filedName:"private"},30323:{type:5,filedName:"yaw"},30324:{type:5,filedName:"pitch"},30325:{type:5,filedName:"roll"}}},21682:{type:1,filedName:"displayUnit"},154:{type:1,filedName:"interlaced"},157:{type:1,filedName:"fieldOrder"},21432:{type:1,filedName:"stereoMode"},21683:{type:1,filedName:"aspectRatio"}}},226:{type:9,filedName:"operations",child:{227:{type:9,isArray:!0,filedName:"entry",child:{228:{type:9,isArray:!0,filedName:"planes",child:{230:{type:1,filedName:"type"},229:{type:1,filedName:"uid"}}}}}}},28032:{type:9,filedName:"encodings",child:{25152:{type:9,isArray:!0,filedName:"entry",child:{20530:{type:1,filedName:"scope"},20531:{type:1,filedName:"type"},20532:{type:9,filedName:"compression",child:{16980:{type:1,filedName:"algo"},16981:{type:8,filedName:"settings"}}},20533:{type:9,filedName:"encryption",child:{18401:{type:1,filedName:"algo"},18402:{type:8,filedName:"keyId"}}}}}}}}}},f={24999:{type:9,isArray:!0,filedName:"entry",child:{18094:{type:1,filedName:"uid"},18030:{type:7,filedName:"name"},18016:{type:7,filedName:"mime"},18046:{type:7,filedName:"description"},18012:{type:8,filedName:"data"}}}},h={17849:{type:9,isArray:!0,filedName:"entry",child:{182:{type:9,isArray:!0,filedName:"atom",child:{145:{type:2,filedName:"start"},146:{type:2,filedName:"end"},29636:{type:1,filedName:"uid"},128:{type:9,filedName:"display",child:{133:{type:7,filedName:"title"},17276:{type:7,filedName:"language"}}}}}}}},m={187:{type:9,isArray:!0,filedName:"entry",child:{179:{type:2,filedName:"time"},183:{type:9,isArray:!0,filedName:"pos",child:{247:{type:1,filedName:"track"},241:{type:2,filedName:"pos"}}}}}},u={17827:{type:7,filedName:"name"},17543:{type:7,filedName:"string"},17530:{type:7,filedName:"language"},17540:{type:1,filedName:"default"},17588:{type:1,filedName:"default"},26568:{type:9,filedName:"sub"}};u[26568].child=u;const g={29555:{type:9,isArray:!0,filedName:"entry",child:{26568:{type:9,filedName:"tag",child:u},25536:{type:9,filedName:"target",child:{25546:{type:7,filedName:"type"},26826:{type:1,filedName:"typeValue"},25541:{type:1,filedName:"trackUid"},25540:{type:1,filedName:"chapterUid"},25542:{type:1,filedName:"attachUid"}}}}}},A={161:{type:8,filedName:"block"},30113:{type:9,filedName:"additions",child:{166:{type:9,isArray:!0,filedName:"entry",child:{238:{type:1,filedName:"additionalId"},165:{type:8,filedName:"additional"}}}}},155:{type:2,filedName:"duration"},30114:{type:4,filedName:"discardPadding"},251:{type:4,isArray:!0,filedName:"reference"},164:{type:10,filedName:"nonSimple"}},y={163:{type:8,filedName:"block"},160:{type:9,filedName:"blockGroup",child:A},231:{type:2,filedName:"timeCode"},167:{type:2,filedName:"pos"},171:{type:2,filedName:"prevSize"}},I={17030:{type:1,filedName:"version"},17143:{type:1,filedName:"readVersion"},17138:{type:1,filedName:"maxIdLength"},17139:{type:1,filedName:"maxSizeLength"},17026:{type:7,filedName:"docType"},17031:{type:1,filedName:"docTypeVersion"},17029:{type:1,filedName:"docTypeReadVersion"}};async function N(e,t){const a=e.getPos();let n=await e.readUint8();if(!n)return i.z3(`0x00 as pos ${a} invalid as first byte of an EBML number`,o,766),r.LR;let c=1;for(;!(128&n);)c++,n<<=1;if(n&=127,c>t)return i.z3(`Length ${c} indicated by an EBML number's first byte ${n.toString(16)} at pos ${a} exceeds max length ${t}.`,o,779),r.LR;let d=n>>>c-1;for(;--c;)d<<=8,d|=await e.readUint8();return d}async function x(e,t){const a=e.getPos();return await N(e,t)-((1<<7*Number(BigInt.asIntN(32,e.getPos()-a))-1)-1)}async function b(e,t){const a=e.getPos();let n=await e.readUint8(),c=1;if(!n)return i.z3(`0x00 as pos ${a} invalid as first byte of an EBML number`,o,813),BigInt(r.LR);for(;!(128&n);)c++,n<<=1;if(n&=127,c>t)return i.z3(`Length ${c} indicated by an EBML number's first byte ${n.toString(16)} at pos ${a} exceeds max length ${t}.`,o,824),BigInt(r.LR);let d=BigInt(Math.floor(n>>>c-1));for(;--c;){d<<=BigInt(8);const t=await e.readUint8();d|=BigInt(Math.floor(t))}return d}async function S(e,t){switch(t){case BigInt(0):return 0;case BigInt(1):return e.ioReader.readUint8();case BigInt(2):return e.ioReader.readUint16();case BigInt(3):return e.ioReader.readUint24();case BigInt(4):return e.ioReader.readUint32();case BigInt(8):return e.ioReader.readUint64()}let a=BigInt(0),i=0;for(;i++<t;){const t=await e.ioReader.readUint8();a=a<<BigInt(8)|BigInt.asUintN(64,BigInt(Math.floor(t)))}return a}async function P(e,t){switch(t){case BigInt(0):return 0;case BigInt(1):return e.ioReader.readInt8();case BigInt(2):return e.ioReader.readInt16();case BigInt(4):return e.ioReader.readInt32();case BigInt(8):return e.ioReader.readInt64()}let a=BigInt(0),i=0;for(;i++<t;){const t=await e.ioReader.readUint8();a=a<<BigInt(8)|BigInt.asUintN(64,BigInt(Math.floor(t)))}return t===BigInt(3)?Number(BigInt.asIntN(32,BigInt.asIntN(24,a))):BigInt.asIntN(64,a)}async function R(e,t){const a=e.ioReader.getPos();let n=await e.ioReader.peekUint8();if(!n)return i.z3(`0x00 as pos ${a} invalid as first byte of an EBML number`,o,909),r.LR;let c=1;for(;!(128&n);)c++,n<<=1;if(c>t)return i.z3(`Length ${c} indicated by an EBML number's first byte ${n.toString(16)} at pos ${a} exceeds max length ${t}.`,o,921),r.LR;let d=0;for(;c--;)d<<=8,d|=await e.ioReader.readUint8();return d}async function k(e,t,a,i={},r=[]){return await async function(e,t,a){const i=e.privateData,r=e.ioReader.getPos();for(;e.ioReader.getPos()<r+t;){const t=await R(e,i.header.maxIdLength),r=await b(e.ioReader,i.header.maxSizeLength);if(e.ioReader.getPos(),!1===await a(t,r))return}}(e,t,(async(t,o)=>{if(a[t]){const r=a[t];let c;switch(r.type){case 1:c=await S(e,o);break;case 2:c=await S(e,o),n.ai(c)&&(c=BigInt(c));break;case 3:c=await P(e,o);break;case 4:c=await P(e,o),n.ai(c)&&(c=BigInt(c));break;case 6:case 5:c=await async function(e,t){return t===BigInt(4)?e.ioReader.readFloat():t===BigInt(8)?e.ioReader.readDouble():(await e.ioReader.skip(Number(BigInt.asIntN(32,t))),0)}(e,o);break;case 7:c=await e.ioReader.readString(Number(BigInt.asIntN(32,o)));break;case 10:c=!!await S(e,o);break;case 8:c={pos:e.ioReader.getPos(),size:o,data:o<d?await e.ioReader.readBuffer(Number(BigInt.asIntN(32,o))):null};break;case 9:c=r.child?await k(e,o,r.child):{};break;default:await e.ioReader.skip(Number(BigInt.asIntN(32,o)))}if(null!=c)if(r.isArray){const e=i[r.filedName]||[];e.push(c),i[r.filedName]=e}else i[r.filedName]=c}else await e.ioReader.skip(Number(BigInt.asIntN(32,o)));if(r.length&&c.zy(r,t))return!1})),i}},31866:(e,t,a)=>{a.d(t,{N:()=>r,e:()=>i});const i={A_AAC:86018,A_AC3:86019,A_ALAC:86032,A_DTS:86020,A_EAC3:86056,A_FLAC:86028,A_MLP:86045,"A_MPEG/L2":86016,"A_MPEG/L1":86058,"A_MPEG/L3":86017,A_OPUS:86076,"A_OPUS/EXPERIMENTAL":86076,"A_PCM/FLOAT/IEEE":65557,"A_PCM/INT/BIG":65537,"A_PCM/INT/LIT":65536,"A_QUICKTIME/QDMC":86066,"A_QUICKTIME/QDM2":86035,"A_REAL/14_4":77824,"A_REAL/28_8":77825,"A_REAL/ATRC":86047,"A_REAL/COOK":86036,"A_REAL/SIPR":86057,A_TRUEHD:86060,A_TTA1:86038,A_VORBIS:86021,A_WAVPACK4:86041,"D_WEBVTT/SUBTITLES":94226,"D_WEBVTT/CAPTIONS":94226,"D_WEBVTT/DESCRIPTIONS":94226,"D_WEBVTT/METADATA":94226,"S_TEXT/UTF8":94225,"S_TEXT/ASCII":94210,"S_TEXT/ASS":94230,"S_TEXT/SSA":94230,S_ASS:94230,S_SSA:94230,S_VOBSUB:94208,S_DVBSUB:94209,"S_HDMV/PGS":94214,"S_HDMV/TEXTST":94231,V_AV1:225,V_DIRAC:116,V_FFV1:33,V_MJPEG:7,V_MPEG1:1,V_MPEG2:2,"V_MPEG4/ISO/ASP":12,"V_MPEG4/ISO/AP":12,"V_MPEG4/ISO/SP":12,"V_MPEG4/ISO/AVC":27,"V_MPEGH/ISO/HEVC":173,"V_MPEGH/ISO/VVC":196,"V_MPEG4/MS/V3":16,V_PRORES:147,"V_REAL/RV10":5,"V_REAL/RV20":6,"V_REAL/RV30":68,"V_REAL/RV40":69,V_SNOW:208,V_THEORA:30,V_UNCOMPRESSED:13,V_VP8:139,V_VP9:167},r={V_VP8:139,V_VP9:167,V_AV1:225,A_VORBIS:86021,A_OPUS:86076,"D_WEBVTT/SUBTITLES":94226,"D_WEBVTT/CAPTIONS":94226,"D_WEBVTT/DESCRIPTIONS":94226,"D_WEBVTT/METADATA":94226}},53260:(e,t,a)=>{a.d(t,{g:()=>r,n:()=>n});var i=a(79682);const r={1:65541,2:69638,3:65557,6:65543,7:65542,10:86052,16:69664,17:69633,23:69664,32:69646,34:86037,49:86046,50:86046,56:73728,66:86068,69:69643,20:69643,64:69643,97:69635,98:69634,100:69643,105:69633,117:86079,131:86069,255:86018,273:86068,5632:86018,5634:86065,8192:86019},n={[(0,i.A)("H264")]:27,[(0,i.A)("h264")]:27,[(0,i.A)("X264")]:27,[(0,i.A)("x264")]:27,[(0,i.A)("avc1")]:27,[(0,i.A)("DAVC")]:27,[(0,i.A)("SMV2")]:27,[(0,i.A)("VSSH")]:27,[(0,i.A)("Q264")]:27,[(0,i.A)("V264")]:27,[(0,i.A)("GAVC")]:27,[(0,i.A)("UMSV")]:27,[(0,i.A)("tshd")]:27,[(0,i.A)("INMC")]:27,[(0,i.A)("FMP4")]:12,[(0,i.A)("DIVX")]:12,[(0,i.A)("DX50")]:12,[(0,i.A)("XVID")]:12,[(0,i.A)("MP4S")]:12,[(0,i.A)("M4S2")]:12,[(0,i.A)("DIVX")]:12,4:12,[(0,i.A)("ZMP4")]:12,[(0,i.A)("DIV1")]:12,[(0,i.A)("BLZ0")]:12,[(0,i.A)("mp4v")]:12,[(0,i.A)("UMP4")]:12,[(0,i.A)("WV1F")]:12,[(0,i.A)("SEDG")]:12,[(0,i.A)("RMP4")]:12,[(0,i.A)("3IV2")]:12,[(0,i.A)("WAWV")]:12,[(0,i.A)("FFDS")]:12,[(0,i.A)("FVFW")]:12,[(0,i.A)("DCOD")]:12,[(0,i.A)("MVXM")]:12,[(0,i.A)("PM4V")]:12,[(0,i.A)("SMP4")]:12,[(0,i.A)("DXGM")]:12,[(0,i.A)("VIDM")]:12,[(0,i.A)("M4T3")]:12,[(0,i.A)("GEOX")]:12,[(0,i.A)("G264")]:12,[(0,i.A)("HDX4")]:12,[(0,i.A)("DM4V")]:12,[(0,i.A)("DMK2")]:12,[(0,i.A)("DYM4")]:12,[(0,i.A)("DIGI")]:12,[(0,i.A)("EPHV")]:12,[(0,i.A)("EM4A")]:12,[(0,i.A)("M4CC")]:12,[(0,i.A)("SN40")]:12,[(0,i.A)("VSPX")]:12,[(0,i.A)("ULDX")]:12,[(0,i.A)("GEOV")]:12,[(0,i.A)("SIPP")]:12,[(0,i.A)("SM4V")]:12,[(0,i.A)("XVIX")]:12,[(0,i.A)("DreX")]:12,[(0,i.A)("QMP4")]:12,[(0,i.A)("PLV1")]:12,[(0,i.A)("GLV4")]:12,[(0,i.A)("GMP4")]:12,[(0,i.A)("MNM4")]:12,[(0,i.A)("GTM4")]:12,[(0,i.A)("MPG4")]:14,[(0,i.A)("MP41")]:14,[(0,i.A)("MP42")]:15,[(0,i.A)("DIV2")]:15,[(0,i.A)("MP43")]:16,[(0,i.A)("DIV3")]:16,[(0,i.A)("MPG3")]:16,[(0,i.A)("DIV5")]:16,[(0,i.A)("DIV6")]:16,[(0,i.A)("DIV4")]:16,[(0,i.A)("DVX3")]:16,[(0,i.A)("AP41")]:16,[(0,i.A)("COL1")]:16,[(0,i.A)("COL0")]:16,[(0,i.A)("VP80")]:139,[(0,i.A)("VP90")]:167}},79682:(e,t,a)=>{a.d(t,{A:()=>n});var i=a(4624);const r="src/avformat/function/mktagle.ts";function n(e){4!==e.length&&i.R8(`tag length is not 4, tag: ${e}`,r,30);let t=0;for(let a=3;a>=0;a--)t=t<<8|e.charCodeAt(a);return t}},95832:(e,t,a)=>{a.d(t,{Bq:()=>p,Ij:()=>l,XC:()=>s,f7:()=>f,uF:()=>n});var i=a(77231),r=a(37246);const n={1:"Main",2:"LC",3:"LC",4:"LC",5:"HE",6:"HE"},c={96e3:0,88200:1,64e3:2,48e3:3,44100:4,32e3:5,24e3:6,22050:7,16e3:8,12e3:9,11025:10,8e3:11,7350:12},o=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350,i.N_,i.N_,i.N_],d=[i.N_,1,2,3,4,5,6,7];function s(e,t){if(!t&&e.sideData[1]&&(t=e.sideData[1]),t){const{profile:a,sampleRate:r,channels:n}=function(e){let t=i.N_,a=i.N_,r=i.N_;return e.length>=2&&(t=e[0]>>3&31,a=o[(7&e[0])<<1|e[1]>>7],r=d[e[1]>>3&15]),{profile:t,sampleRate:a,channels:r}}(t);e.codecpar.profile=a,e.codecpar.sampleRate=r,e.codecpar.chLayout.nbChannels=n,e.codecpar.frameSize=5===a?2048:1024,e.codecpar.format=8}}function l(e){const t=c[e.sampleRate],a=e.chLayout.nbChannels,r=e.profile===i.N_?2:e.profile,n=new Uint8Array(2);return n[0]=(31&r)<<3|(14&t)>>1,n[1]=(1&t)<<7|(15&a)<<3,n}function p(e){if(e.length<7)return-1;const t=e[0]<<4|e[1]>>4;if(4095!==t)return-1;const a=1&e[1],i=(192&e[2])>>>6,r=(60&e[2])>>>2,n=(1&e[2])<<2|(192&e[3])>>>6,c=(3&e[3])<<11|e[4]<<3|(224&e[5])>>>5,s=3&e[6];let l=1===a?7:9,p=c-l;return{syncWord:t,profile:i+1,sampleRate:o[r],channels:d[n],aacFrameLength:c,numberOfRawDataBlocksInFrame:s,headerLength:l,framePayloadLength:p}}function f(e,t){function a(){const e=t.readU(2);let a=0;for(let i=0;i<=e;i++)a<<=8,a|=t.readU(8);return a}t||(t=new r.A).appendBuffer(e);const i=t.getPointer(),n={syncWord:0,profile:0,sampleRate:0,channels:0,useSameStreamMux:!1,headerLength:0,framePayloadLength:0,muxLengthBytes:0},c=t.readU(11);if(695!==c)return-1;n.syncWord=c,n.muxLengthBytes=t.readU(13);const s=1===t.readU1();if(n.useSameStreamMux=s,!s){const e=1===t.readU1();if(e&&1===t.readU1())return-1;if(e&&a(),1!==t.readU1())return-1;if(0!==t.readU(6))return-1;if(0!==t.readU(4))return-1;if(0!==t.readU(3))return-1;let i=e?a():0;const r=t.readU(5);i-=5;const c=t.readU(4);i-=4;const s=t.readU(4);if(i-=4,t.readU(3),i-=3,i>0&&t.readU(i),0!==t.readU(3))return-1;if(t.readU(8),1===t.readU1())if(e)a();else{let e=0;for(;;){e<<=8;const a=1===t.readU1();if(e+=t.readU(8),!a)break}}1===t.readU1()&&t.readU(8),n.profile=r+1,n.sampleRate=o[c],n.channels=d[s]}let l=0;for(;;){const e=t.readU(8);if(l+=e,255!==e)break}return n.framePayloadLength=l,n.headerLength=t.getPointer()-i+(8===t.getBitLeft()?0:1),n}},21477:(e,t,a)=>{a.d(t,{Ui:()=>c,XC:()=>n,zk:()=>r});var i=a(37246);a(83314),a(97317);const r={0:"Main",1:"High",2:"Professional"};function n(e,t){if(!t&&e.sideData[1]&&(t=e.sideData[1]),t&&t.length>=4){const a=c(t);e.codecpar.profile=a.profile,e.codecpar.level=a.level}}function c(e){const t=new i.A(e.length);t.appendBuffer(e),t.readU1(),t.readU(7);const a=t.readU(3),r=t.readU(5),n=t.readU1();let c=t.readU1()?10:8;return t.readU1()&&(c=12),{profile:a,level:r,tier:n,bitDepth:c,monochrome:t.readU1(),chromaSubsamplingX:t.readU1(),chromaSubsamplingY:t.readU1(),chromaSamplePosition:t.readU(2)}}},14769:(e,t,a)=>{a.d(t,{DK:()=>o,XC:()=>s,Xr:()=>d,jA:()=>n,ob:()=>r,oe:()=>c});var i=a(31865);const r=34,n=8,c=[0,8,12,0,16,20,24,32],o=[0,88200,176400,192e3,8e3,16e3,22050,24e3,32e3,44100,48e3,96e3,0,0,0,0],d=[0,192,576,1152,2304,4608,0,0,256,512,1024,2048,4096,8192,16384,32768];function s(e,t){if(!t&&e.sideData[1]&&(t=e.sideData[1]),t&&t.length===r){const{bitsPerRawSample:a,sampleRate:r,channels:n}=function(e){const t=new i.A(e);t.skip(10);const a=t.readUint24();return{sampleRate:a>>4,channels:1+((15&a)>>>1),bitsPerRawSample:1+((1&a)<<4|(240&t.readUint8())>>>4)}}(t);e.codecpar.bitsPerRawSample=a,e.codecpar.sampleRate=r,e.codecpar.chLayout.nbChannels=n}}},64093:(e,t,a)=>{a.d(t,{Au:()=>y,He:()=>I,XC:()=>N,Y2:()=>u,hG:()=>g,oz:()=>A});var i=a(77231);const r=[44100,48e3,32e3,0],n=[22050,24e3,16e3,0],c=[11025,12e3,8e3,0],o=[0,1152,1152,384],d=[0,576,1152,384],s=[0,576,1152,384],l=[0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,-1],p=[0,32,48,56,64,80,96,112,128,160,192,224,256,320,384,-1],f=[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1],h=[0,32,48,56,64,80,96,112,128,144,160,176,192,224,256,-1],m=[0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,-1];function u(e,t){switch(e){case 0:return c[t];case 2:return n[t];case 3:return r[t]}return i.N_}function g(e,t){switch(e){case 0:return s[t];case 2:return d[t];case 3:return o[t]}return i.N_}function A(e,t,a){switch(t){case 1:switch(e){case 0:case 2:return m[a];case 3:return f[a]}break;case 2:switch(e){case 0:case 2:return m[a];case 3:return p[a]}case 3:switch(e){case 0:case 2:return h[a];case 3:return l[a]}}return i.N_}function y(e){switch(e){case 1:return 34;case 2:return 33;case 3:return 32}return i.N_}const I={32:"Layer1",33:"Layer2",34:"Layer3"};function N(e,t){if(t&&t.length>=4){const a=t[1]>>>3&3,i=(6&t[1])>>1,r=(12&t[2])>>>2,n=3&~(t[3]>>>6)?2:1,c=y(i),o=u(a,r);e.codecpar.profile=c,e.codecpar.sampleRate=o,e.codecpar.chLayout.nbChannels=n}}},22576:(e,t,a)=>{a.d(t,{Ij:()=>s,XC:()=>d,kt:()=>o});var i=a(31865),r=a(729),n=a(44328);const c=[480,960,1920,2880,480,960,1920,2880,480,960,1920,2880,480,960,480,960,120,240,480,960,120,240,480,960,120,240,480,960,120,240,480,960];function o(e){let t=0,a=0,i=0;if(e.length<1)return 0;switch(t=e[0],a=c[t>>3],3&t){case 0:i=1;break;case 1:case 2:i=2;break;case 3:if(e.length<2)return 0;i=63&e[1]}return i*a}function d(e,t){if(!t&&e.sideData[1]&&(t=e.sideData[1]),t&&t.length>=19){const a=new i.A(t,!1);a.skip(9),e.codecpar.chLayout.nbChannels=a.readUint8(),e.codecpar.initialPadding=a.readUint16(),e.codecpar.sampleRate=a.readUint32(),e.codecpar.seekPreroll=Number((0,n.k)(BigInt(80),{den:1e3,num:1},{den:48e3,num:1}))}}function s(e){const t=new Uint8Array(19),a=new r.A(t,!1);return a.writeString("OpusHead"),a.writeUint8(1),a.writeUint8(e.chLayout.nbChannels),a.writeUint16(e.initialPadding),a.writeUint32(e.sampleRate),t}},97077:(e,t,a)=>{a.d(t,{Ui:()=>n,XC:()=>r});var i=a(37246);function r(e,t){if(!t&&e.sideData[1]&&(t=e.sideData[1]),t&&t.length>=6){const a=n(t);e.codecpar.profile=a.profile,e.codecpar.level=a.level}}function n(e){const t=new i.A(e.length);return t.appendBuffer(e.subarray(4)),{profile:t.readU(8),level:t.readU(8),bitDepth:t.readU(4),chromaSubsampling:t.readU(3),fullRangeFlag:t.readU1(),colorPrimaries:t.readU(8),colorTrc:t.readU(8),colorSpace:t.readU(8)}}},82014:(e,t,a)=>{a.d(t,{Ui:()=>c,XC:()=>n,wN:()=>r}),a(9599);var i=a(37246);a(77231),a(97317),a(729);const r={0:"Profile0",1:"Profile1",2:"Profile2",3:"Profile3"};function n(e,t){if(!t&&e.sideData[1]&&(t=e.sideData[1]),t&&t.length>=6){const a=c(t);e.codecpar.profile=a.profile,e.codecpar.level=a.level}}function c(e){const t=new i.A(e.length);return t.appendBuffer(e),{profile:t.readU(8),level:t.readU(8),bitDepth:t.readU(4),chromaSubsampling:t.readU(3),fullRangeFlag:t.readU1(),colorPrimaries:t.readU(8),colorTrc:t.readU(8),colorSpace:t.readU(8)}}},null:()=>{},28795:(e,t,a)=>{a(78978),a(97863),a(7914),a(21640),a(871),a(52584),a(98345),e.exports=a(46438).Set},21640:(e,t,a)=>{var i=a(95933),r=a(6096);e.exports=a(99373)("Set",(function(e){return function(){return e(this,arguments.length>0?arguments[0]:void 0)}}),{add:function(e){return i.def(r(this,"Set"),e=0===e?0:e,e)}},i)},98345:(e,t,a)=>{a(643)("Set")},52584:(e,t,a)=>{a(44398)("Set")},871:(e,t,a)=>{var i=a(88535);i(i.P+i.R,"Set",{toJSON:a(5874)("Set")})},97860:(e,t,a)=>{e.exports=a(28795)}}]);
1
+ (self.webpackChunklibmedia=self.webpackChunklibmedia||[]).push([[941],{85947:(e,t,a)=>{a.d(t,{A:()=>r});var i=a(134);class r{constructor(){(0,i.A)(this,"type",-1),(0,i.A)(this,"onStreamAdd",void 0)}async destroy(e){}}},34577:(e,t,a)=>{a.r(t),a.d(t,{default:()=>H});var i=a(134),r=a(80662),n=a.n(r),c=a(97860),o=a.n(c),d=a(14686),s=a(61499),l=a(63939),p=a(50932),f=(a(9599),a(4624)),h=a(9705),m=a(85947),u=a(37837),g=a(71517),A=a(77231),y=a(31866),I=a(33919),N=a(72739),x=a(62815),b=a(67659),S=a(59166),P=a(97077),R=a(82014),k=a(21477),B=a(64093),v=a(22576),w=a(95832),U=a(14769),V=a(44328),C=a(31865),L=a(93082),_=a(5783),M=a(82774),D=a(67672),T=a(95335),E=a(53260),z=a(13663),X=a(92647),G=a(50011),O=a(34677),F=a(60264);const W="src/avformat/formats/IMatroskaFormat.ts";class H extends m.A{constructor(){super(),(0,i.A)(this,"type",8),(0,i.A)(this,"context",void 0),(0,i.A)(this,"blockReader",void 0)}init(e){e.ioReader&&e.ioReader.setEndian(!0);const t={isLive:!0,firstCluster:-BigInt(1),segmentStart:-BigInt(1),header:{version:0,readVersion:0,maxIdLength:4,maxSizeLength:8,docType:"",docTypeVersion:0,docTypeReadVersion:0},seekHead:null,info:null,tracks:null,attachments:null,chapters:null,cues:null,tags:null,maxPts:A.Dh,currentCluster:{timeCode:BigInt(0),pos:-BigInt(1),block:{pos:-BigInt(1),size:-BigInt(1)},blockGroup:{block:null}},clusterIndexes:[],clusterIndexesPosMap:new(n())};e.privateData=this.context=t}analyzeStreams(e){const t="webm"===this.context.header.docType?y.N:y.e;this.context.tracks&&N.__(this.context.tracks.entry,(a=>{var i,r,n;const c=e.createStream();switch(c.privData=a,c.codecpar.codecId=t[a.codecId]||0,a.type){case 2:c.codecpar.codecType=1;break;case 1:c.codecpar.codecType=0;break;case 17:c.codecpar.codecType=3;break;default:c.codecpar.codecType=-1}a.language&&(c.metadata.language=a.language),a.name&&(c.metadata.title=a.name),a.audio?("A_PCM/FLOAT/IEEE"===a.codecName?64===a.audio.bitDepth?c.codecpar.codecId=65559:32===a.audio.bitDepth&&(c.codecpar.codecId=65557):"A_PCM/INT/BIG"===a.codecName?16===a.audio.bitDepth?c.codecpar.codecId=65537:24===a.audio.bitDepth?c.codecpar.codecId=65549:32===a.audio.bitDepth&&(c.codecpar.codecId=65545):"A_PCM/INT/LIT"===a.codecName&&(8===a.audio.bitDepth?c.codecpar.codecId=65541:16===a.audio.bitDepth?c.codecpar.codecId=65536:24===a.audio.bitDepth?c.codecpar.codecId=65548:32===a.audio.bitDepth&&(c.codecpar.codecId=65544)),c.codecpar.chLayout.nbChannels=a.audio.channels,c.codecpar.sampleRate=0|a.audio.sampleRate,c.codecpar.bitsPerCodedSample=a.audio.bitDepth):a.video&&(c.codecpar.width=a.video.pixelWidth,c.codecpar.height=a.video.pixelHeight,a.video.color&&(D.ai(a.video.color.primaries)&&(c.codecpar.colorPrimaries=a.video.color.primaries),D.ai(a.video.color.transferCharacteristics)&&(c.codecpar.colorTrc=a.video.color.transferCharacteristics),D.ai(a.video.color.range)&&(c.codecpar.colorRange=a.video.color.range),D.ai(a.video.color.matrixCoefficients)&&(c.codecpar.colorSpace=a.video.color.matrixCoefficients)));let o=0;if("V_MS/VFW/FOURCC"===a.codecId&&(null===(i=a.codecPrivate)||void 0===i?void 0:i.size)>=40)c.codecpar.bitsPerCodedSample=a.codecPrivate.data[15]<<8|a.codecPrivate.data[14],c.codecpar.codecTag=a.codecPrivate.data[19]<<24|a.codecPrivate.data[18]<<16|a.codecPrivate.data[17]<<8|a.codecPrivate.data[16],c.codecpar.codecId=E.n[c.codecpar.codecTag]||0,0===c.codecpar.codecId&&(c.codecpar.codecId,z.h[c.codecpar.codecTag]),o=40;else if("V_QUICKTIME"===a.codecId&&(null===(r=a.codecPrivate)||void 0===r?void 0:r.size)>=21){const e=1===c.codecpar.codecType?z.u:z.h;c.codecpar.codecTag=a.codecPrivate.data[3]<<24|a.codecPrivate.data[2]<<16|a.codecPrivate.data[1]<<8|a.codecPrivate.data[0];const t=e[c.codecpar.codecTag];if(t){const e=new Uint8Array(4),t=Number(BigInt.asIntN(32,a.codecPrivate.size));e[0]=t>>>24&255,e[1]=t>>>16&255,e[2]=t>>>8&255,e[3]=255&t,a.codecPrivate.size+=BigInt(4),a.codecPrivate.data=(0,X.A)(Uint8Array,[e,a.codecPrivate.data])}c.codecpar.codecId=t||0}if(null!==(n=a.codecPrivate)&&void 0!==n&&n.data&&a.codecPrivate.size-BigInt(Math.floor(o))>0){let e=a.codecPrivate.data.subarray(o);if(94212===c.codecpar.codecId||94230===c.codecpar.codecId){let t=G.decode(e).split(/\r?\n/);for(let e=0;e<t.length;e++)if("[Events]"===t[e].trim()){t=t.slice(0,e);break}t.push("[Events]"),t.push("Format: ReadOrder, Layer, Style, Name, MarginL, MarginR, MarginV, Effect, Text"),e=G.encode(t.join("\n"))}if(c.codecpar.extradataSize=e.length,c.codecpar.extradata=(0,u.sY)(e.length),(0,d.lW)(c.codecpar.extradata,e.length,e),c.codecpar.extradata)switch(c.codecpar.codecId){case 27:{const e=(0,d.s3)(c.codecpar.extradata,c.codecpar.extradataSize);x.XC(c,e),F.Bs(e)?c.codecpar.bitFormat=2:c.codecpar.bitFormat=1;break}case 173:{const e=(0,d.s3)(c.codecpar.extradata,c.codecpar.extradataSize);b.XC(c,e),F.Bs(e)?c.codecpar.bitFormat=2:c.codecpar.bitFormat=1;break}case 196:{const e=(0,d.s3)(c.codecpar.extradata,c.codecpar.extradataSize);S.XC(c,e),F.Bs(e)?c.codecpar.bitFormat=2:c.codecpar.bitFormat=1;break}case 225:k.XC(c,(0,d.s3)(c.codecpar.extradata,c.codecpar.extradataSize));break;case 139:P.XC(c,(0,d.s3)(c.codecpar.extradata,c.codecpar.extradataSize));break;case 167:R.XC(c,(0,d.s3)(c.codecpar.extradata,c.codecpar.extradataSize));break;case 86018:w.XC(c,(0,d.s3)(c.codecpar.extradata,c.codecpar.extradataSize));break;case 86017:B.XC(c,(0,d.s3)(c.codecpar.extradata,c.codecpar.extradataSize));break;case 86076:v.XC(c,(0,d.s3)(c.codecpar.extradata,c.codecpar.extradataSize));break;case 86028:if(c.codecpar.extradataSize>U.ob){const e=new C.A((0,d.s3)(c.codecpar.extradata,c.codecpar.extradataSize));if("fLaC"===e.readString(4))for(;e.remainingSize();){const t=e.readUint8(),a=e.readUint24(),i=-129&t;if(0===i){const t=e.readBuffer(a);(0,u.Eb)(c.codecpar.extradata),c.codecpar.extradata=(0,u.sY)(t.length),c.codecpar.extradataSize=t.length,(0,d.lW)(c.codecpar.extradata,t.length,t);break}e.skip(i)}}c.codecpar.extradataSize===U.ob&&U.XC(c,(0,d.s3)(c.codecpar.extradata,c.codecpar.extradataSize))}else{let e;86018===c.codecpar.codecId&&(e=w.Ij(c.codecpar)),e&&(c.codecpar.extradataSize=e.length,c.codecpar.extradata=(0,u.sY)(c.codecpar.extradataSize),(0,d.lW)(c.codecpar.extradata,c.codecpar.extradataSize,e))}}this.context.info&&(c.timeBase.num=1,this.context.info.timestampScale?c.timeBase.den=1e3*A.SF/this.context.info.timestampScale|0:(c.timeBase.den=1e3,this.context.info.timestampScale=A.SF),this.context.info.duration&&(c.duration=BigInt(Math.floor(this.context.info.duration)))),(null==a.default||a.default)&&(c.disposition|=1),a.encodings&&N.__(a.encodings.entry,(e=>{e.compression&&(0,O.A)(e.compression.algo)&&(a.needDecompression=!0),e.encryption&&(0,O.A)(e.encryption.algo)&&(a.needDecryption=!0)}))})),this.context.attachments&&N.__(this.context.attachments.entry,(t=>{const a=e.createStream();a.codecpar.codecType=4,a.privData=t,t.data&&(a.codecpar.extradataSize=Number(BigInt.asIntN(32,t.data.size)),a.codecpar.extradata=(0,u.sY)(a.codecpar.extradataSize),(0,d.lW)(a.codecpar.extradata,a.codecpar.extradataSize,t.data.data))})),this.context.tags&&N.__(this.context.tags.entry,(t=>{var a;if("DURATION"===(null===(a=t.tag)||void 0===a?void 0:a.name)){let a=t.tag.string.replaceAll("\0","").split("."),i=a[0].split(":"),r=BigInt(+i[0])*BigInt(36e8)+BigInt(+i[1])*BigInt(6e7)+BigInt(+i[2])*BigInt(1e6)+BigInt(+a[1])/BigInt(1e3);const n=(0,L.A)(e.streams,t.target.trackUid);n&&(n.duration=(0,V.k)(r,A.KR,n.timeBase))}})),this.context.chapters&&N.__(this.context.chapters.entry,(t=>{const a=t.atom;a&&N.__(a,(t=>{var a,i;e.chapters.push({id:t.uid,start:t.start,end:t.end,timeBase:{num:1,den:1e9},metadata:{title:(null===(a=t.display)||void 0===a?void 0:a.title)||"",language:(null===(i=t.display)||void 0===i?void 0:i.language)||""}})}))}))}async readHeader(e){if(440786851!==await(0,I.aL)(e,this.context.header.maxIdLength))return f.z3("not matroska format",W,460),h.LR;const t=await(0,I.Qb)(e.ioReader,this.context.header.maxSizeLength);if(this.context.header=T.X$(this.context.header,await(0,I.Pb)(e,t,I.jt)),408125543!==await(0,I.aL)(e,this.context.header.maxIdLength))return f.z3("not matroska format",W,469),h.LR;const a=await(0,I.Qb)(e.ioReader,this.context.header.maxSizeLength);this.context.segmentStart=e.ioReader.getPos();const i=e.ioReader.getPos()+a,r=new(o());let n=!1,c=!1;for(;e.ioReader.getPos()<i||!n||!c;){const t=e.ioReader.getPos(),a=await(0,I.aL)(e,this.context.header.maxIdLength);if(a===h.LR){await this.syncTopLevelElement(e,2);continue}const i=await(0,I.Qb)(e.ioReader,this.context.header.maxSizeLength);if(i!==BigInt(0|h.LR)){if(290298740===a)this.context.isLive=!1,this.context.seekHead=await(0,I.Pb)(e,i,I.Cr);else if(475249515===a)this.context.isLive=!1,this.context.cues=await(0,I.Pb)(e,i,I.eG);else if(272869232===a)this.context.isLive=!1,this.context.chapters=await(0,I.Pb)(e,i,I.Y0);else if(357149030===a)this.context.info=await(0,I.Pb)(e,i,I.qi);else if(307544935===a)this.context.tags=await(0,I.Pb)(e,i,I.hK);else if(423732329===a)this.context.attachments=await(0,I.Pb)(e,i,I.qp);else if(374648427===a)n=!0,this.context.tracks=await(0,I.Pb)(e,i,I.Wy);else if(524531317===a){if(c=!0,this.context.firstCluster=t,this.context.isLive||!this.context.seekHead||!(1&e.ioReader.flags))break;const a=this.context.seekHead.entry;let i=0;for(;i<a.length;i++)if(!r.has(a[i].id)){await e.ioReader.seek(a[i].pos+this.context.segmentStart);break}if(i===a.length)break}else await e.ioReader.skip(Number(BigInt.asIntN(32,i)));r.add(a)}else await this.syncTopLevelElement(e,2)}return this.context.firstCluster>0&&await e.ioReader.seek(this.context.firstCluster),this.analyzeStreams(e),0}parseAdditions(e,t){for(let i=0;i<t.entry.length;i++){var a;const r=t.entry[i];if(null!==(a=r.additional)&&void 0!==a&&a.size){4===r.additionalId&&f.R8("ITU_T_T35 not support now",W,563);const t=(0,u.sY)(r.additional.data.length+8);M.Cv(t,BigInt(r.additionalId>>>0)),(0,d.lW)(t+8,r.additional.data.length,r.additional.data),(0,g.Ow)(e,15,t,r.additional.data.length+8)}}}async parseBlock(e,t){var a,i,r;const n=(null===(a=this.context.currentCluster.block)||void 0===a?void 0:a.data)||this.context.currentCluster.blockGroup.block.data;let c=null===(i=this.context.currentCluster.block)||void 0===i?void 0:i.pos;c<0&&(c=this.context.currentCluster.blockGroup.block.pos);let o,m=-1,y=BigInt(0);null!==(r=this.context.currentCluster.blockGroup)&&void 0!==r&&r.block&&(o=this.context.currentCluster.blockGroup.additions,m=this.context.currentCluster.blockGroup.reference?0===this.context.currentCluster.blockGroup.reference.length?1:0:1,this.context.currentCluster.blockGroup.duration&&(y=this.context.currentCluster.blockGroup.duration)),this.blockReader?this.blockReader.resetBuffer(n):this.blockReader=new C.A(n);const N=this.blockReader.getPos(),x=Number(BigInt.asUintN(32,await(0,I.Qb)(this.blockReader,8))),b=(0,_.A)(e.streams,x);if(!b)return f.z3(`invalid track number ${x}`,W,613),h.OY;const S=this.blockReader.readInt16(),P=this.blockReader.readUint8();-1===m&&(m=128&P?1:0);let R=0,k=[];switch(P>>>1&3){case 1:{R=this.blockReader.readUint8()+1;let e=0;for(let t=0;t<R-1;t++){let t=0;for(;;){const e=this.blockReader.readUint8();if(0===e)break;if(255!==e){t+=e;break}t+=255}e+=t,k.push(t)}k.push(n.length-Number(BigInt.asIntN(32,this.blockReader.getPos()-N))-e);break}case 3:{R=this.blockReader.readUint8()+1,k.push(await(0,I.Ag)(this.blockReader,4));let e=k[0];for(let t=1;t<R-1;t++){let a=await(0,I.pf)(this.blockReader,4)+k[t-1];e+=a,k.push(a)}k.push(n.length-Number(BigInt.asIntN(32,this.blockReader.getPos()-N))-e);break}case 2:R=this.blockReader.readUint8()+1;const e=(n.length-Number(BigInt.asIntN(32,this.blockReader.getPos()-N)))/R;for(let t=0;t<R;t++)k.push(e);break;case 0:R=1,k.push(n.length-Number(BigInt.asIntN(32,this.blockReader.getPos()-N)))}const B=b.privData,v=B.timeScale||1;if(B.needDecryption)throw new Error("not support encryption stream");let w=(this.context.currentCluster.timeCode+BigInt(Math.floor(S*v)))*BigInt(0|this.context.info.timestampScale);B.codecDelay&&(w-=B.codecDelay),w/=BigInt(1e3),w=(0,V.k)(w,A.KR,b.timeBase),y=BigInt(Math.floor(Number(BigInt.asIntN(32,y))*v))*BigInt(0|this.context.info.timestampScale),y/=BigInt(1e3),y=(0,V.k)(y,A.KR,b.timeBase);for(let a=0;a<R;a++){const i=0!==a?(0,g._5)():t;let r,n=k[a],h=0;if(B.needDecompression){const e=B.encodings.entry.find((e=>!!e.compression));3===e.compression.algo?(r=e.compression.settings.data,n+=r.length,h=r.length):f.h2(`not support compression stream, algo: ${e.compression.algo}`,W,723)}p.M[17](i+56,c+this.blockReader.getPos()),p.M[15](i+32,b.index),(0,d.Mr)(i+72,b.timeBase[s.o9],8),p.M[17](i+8,w),p.M[15](i+28,n),p.M[17](i+48,y);const A=(0,u.sY)(n);r&&(0,d.lW)(A,h,r),(0,d.lW)(A+h,k[a],this.blockReader.readBuffer(k[a])),(0,g.NX)(i,A,n),0!==b.codecpar.codecType?(p.M[15](i+36,1|l.f[15](i+36)),p.M[17](i+16,w)):(m&&p.M[15](i+36,1|l.f[15](i+36)),27!==b.codecpar.codecId&&173!==b.codecpar.codecId&&196!==b.codecpar.codecId||p.M[15](i+80,b.codecpar.bitFormat)),o&&this.parseAdditions(i,o),0!==a&&e.interval.packetBuffer.push(i),this.context.maxPts<w&&(this.context.maxPts=w)}return this.context.currentCluster.block={pos:-BigInt(1),size:-BigInt(1)},this.context.currentCluster.blockGroup={block:null},0}addClusterIndex(e){if(this.context.clusterIndexesPosMap.has(e.pos))return;const t=N.El(this.context.clusterIndexes,(t=>t.time<e.time?1:-1));t>-1?(this.context.clusterIndexesPosMap.set(e.pos,t),this.context.clusterIndexes.splice(t,0,e)):(this.context.clusterIndexesPosMap.set(e.pos,this.context.clusterIndexes.length),this.context.clusterIndexes.push(e))}async readAVPacket_(e,t){const a=e.ioReader.getPos(),i=await(0,I.aL)(e,this.context.header.maxIdLength);if(i===h.LR)return await this.syncTopLevelElement(e),this.readAVPacket_(e,t);const r=await(0,I.Qb)(e.ioReader,this.context.header.maxSizeLength);if(r===BigInt(h.LR))return await this.syncTopLevelElement(e),this.readAVPacket_(e,t);if(524531317===i){this.context.currentCluster.pos=a,this.context.currentCluster.timeCode=BigInt(0),await(0,I.Pb)(e,r,I.GZ,this.context.currentCluster,[163,160]),this.context.isLive||this.addClusterIndex({time:this.context.currentCluster.timeCode,pos:a});let i=await this.parseBlock(e,t);if(i===h.OY)return this.readAVPacket_(e,t);if(i<0)return i}else if(163===i){this.context.currentCluster.block={pos:e.ioReader.getPos(),size:r,data:await e.ioReader.readBuffer(Number(BigInt.asIntN(32,r)))};let a=await this.parseBlock(e,t);if(a===h.OY)return this.readAVPacket_(e,t);if(a<0)return a}else{if(160!==i)return 475249515===i||307544935===i||423732329===i||272869232===i||357149030===i||374648427===i||290298740===i?(await e.ioReader.skip(Number(BigInt.asIntN(32,r))),this.readAVPacket_(e,t)):(await this.syncTopLevelElement(e),this.readAVPacket_(e,t));{await(0,I.Pb)(e,r,I.Wg,this.context.currentCluster.blockGroup);let a=await this.parseBlock(e,t);if(a===h.OY)return this.readAVPacket_(e,t);if(a<0)return a}}return 0}async readAVPacket(e,t){try{return await this.readAVPacket_(e,t)}catch(t){return-1048576!==e.ioReader.error?(f.z3(`read packet error, ${t}`,W,900),h.LR):e.ioReader.error}}async syncTopLevelElement(e,t=3){let a=A.Dh;for(;;)try{if(8&e.ioReader.flags)break;const i=e.ioReader.getPos(),r=await e.ioReader.peekUint32();if(524531317===r||475249515===r||307544935===r||423732329===r||272869232===r||357149030===r||374648427===r||290298740===r){a=i;let r=0;await e.ioReader.skip(4);const n=await(0,I.Qb)(e.ioReader,this.context.header.maxSizeLength);if(n===BigInt(h.LR)){await e.ioReader.seek(i+BigInt(1));continue}for(await e.ioReader.skip(Number(BigInt.asIntN(32,n)));r<=t;){const t=await(0,I.aL)(e,this.context.header.maxIdLength),a=await(0,I.Qb)(e.ioReader,this.context.header.maxSizeLength);if(524531317!==t&&475249515!==t&&307544935!==t&&423732329!==t&&272869232!==t&&357149030!==t&&374648427!==t&&290298740!==t)break;r++,await e.ioReader.skip(Number(BigInt.asIntN(32,a)))}if(!(r<t))break;await e.ioReader.seek(a+BigInt(1)),a=A.Dh}else await e.ioReader.skip(1),a=A.Dh}catch(e){break}a!==A.Dh&&await e.ioReader.seek(a)}async seek(e,t,a,i){var r;const n=e.ioReader.getPos(),c=(0,V.k)(a,t.timeBase,A.KR);let o=A.Dh;if(null!==(r=this.context.cues)&&void 0!==r&&r.entry.length){const e=t.privData;for(let t=0;t<this.context.cues.entry.length;t++)if((this.context.cues.entry[t].time||BigInt(0))*BigInt(0|this.context.info.timestampScale)/BigInt(1e3)>c){const a=this.context.cues.entry[Math.max(t-1,0)].pos;if(a.length){const t=a.find((t=>t.track===e.number));if(t){o=t.pos+this.context.segmentStart;break}}}}if(o===A.Dh&&this.context.clusterIndexes.length){for(let e=0;e<this.context.clusterIndexes.length;e++)if(this.context.clusterIndexes[e].time*BigInt(0|this.context.info.timestampScale)/BigInt(1e3)>c){o=this.context.clusterIndexes[Math.max(e-1,0)].pos;break}o===A.Dh&&(o=this.context.clusterIndexes[this.context.clusterIndexes.length-1].pos)}return o!==A.Dh?(await e.ioReader.seek(o),n):BigInt(h.E$)}getAnalyzeStreamsCount(){return 0}}},13663:(e,t,a)=>{a.d(t,{h:()=>r,u:()=>n});var i=a(79682);const r={[(0,i.A)("mp4v")]:12,[(0,i.A)("DIVX")]:12,[(0,i.A)("XVID")]:12,[(0,i.A)("3IV2")]:12,[(0,i.A)("vvc1")]:196,[(0,i.A)("vvi1")]:196,[(0,i.A)("hev1")]:173,[(0,i.A)("hvc1")]:173,[(0,i.A)("dvhe")]:173,[(0,i.A)("hev1")]:173,[(0,i.A)("avc1")]:27,[(0,i.A)("avc2")]:27,[(0,i.A)("avc3")]:27,[(0,i.A)("avc4")]:27,[(0,i.A)("ai5p")]:27,[(0,i.A)("ai5q")]:27,[(0,i.A)("ai52")]:27,[(0,i.A)("ai53")]:27,[(0,i.A)("ai55")]:27,[(0,i.A)("ai56")]:27,[(0,i.A)("ai1p")]:27,[(0,i.A)("ai1q")]:27,[(0,i.A)("ai12")]:27,[(0,i.A)("ai13")]:27,[(0,i.A)("ai15")]:27,[(0,i.A)("ai16")]:27,[(0,i.A)("AVin")]:27,[(0,i.A)("aivx")]:27,[(0,i.A)("rv64")]:27,[(0,i.A)("xalg")]:27,[(0,i.A)("avlg")]:27,[(0,i.A)("dva1")]:27,[(0,i.A)("dvav")]:27,[(0,i.A)("vp08")]:139,[(0,i.A)("vp09")]:167,[(0,i.A)("av01")]:225},n={[(0,i.A)("mp4a")]:86018,[(0,i.A)("ac-3")]:86019,[(0,i.A)("sac3")]:86019,[(0,i.A)("ac-4")]:86119,[(0,i.A)("dtsc")]:86020,[(0,i.A)("dtsh")]:86020,[(0,i.A)("dtsl")]:86020,[(0,i.A)("dtse")]:86020,[(0,i.A)("DTS ")]:86020,[(0,i.A)("ec-3")]:86056,[(0,i.A)(".mp3")]:86017,[(0,i.A)("mp3 ")]:86017,1836253269:86017,[(0,i.A)("spex")]:86051,[(0,i.A)("SPXN")]:86051,[(0,i.A)("fLaC")]:86028,[(0,i.A)("Opus")]:86076,[(0,i.A)("alaw")]:65543,[(0,i.A)("ulaw")]:65542,[(0,i.A)("fl32")]:65557,[(0,i.A)("fl64")]:65559,[(0,i.A)("twos")]:65537,[(0,i.A)("lpcm")]:65536,[(0,i.A)("sowt")]:65536,[(0,i.A)("in24")]:65548,[(0,i.A)("in32")]:65544,[(0,i.A)("sowt")]:65540,[(0,i.A)("raw ")]:65541,[(0,i.A)("NONE")]:65541}},5783:(e,t,a)=>{function i(e,t){for(let a=0;a<e.length;a++)if(e[a].privData.number===t)return e[a]}a.d(t,{A:()=>i})},93082:(e,t,a)=>{function i(e,t){for(let a=0;a<e.length;a++)if(e[a].privData.uid===t)return e[a]}a.d(t,{A:()=>i})},33919:(e,t,a)=>{a.d(t,{Ag:()=>N,Cr:()=>s,GZ:()=>y,Pb:()=>k,Qb:()=>b,Wg:()=>A,Wy:()=>p,Y0:()=>h,aL:()=>R,eG:()=>m,hK:()=>g,jt:()=>I,pf:()=>x,qi:()=>l,qp:()=>f});var i=a(4624),r=a(9705),n=a(67672),c=a(72739);const o="src/avformat/formats/matroska/imatroska.ts",d=BigInt(20971520),s={19899:{type:9,isArray:!0,filedName:"entry",child:{21419:{type:1,filedName:"id"},21420:{type:2,filedName:"pos"}}}},l={29604:{type:2,filedName:"segmentUUID"},2807729:{type:1,filedName:"timestampScale"},17545:{type:5,filedName:"duration"},31657:{type:7,filedName:"title"},19840:{type:7,filedName:"muxingApp"},22337:{type:7,filedName:"writingApp"},17505:{type:8,filedName:"dateUTC"}},p={174:{type:9,isArray:!0,filedName:"entry",child:{215:{type:1,filedName:"number"},29637:{type:1,filedName:"uid"},131:{type:1,filedName:"type"},21358:{type:7,filedName:"name"},136:{type:10,filedName:"default"},185:{type:10,filedName:"enabled"},2274716:{type:7,filedName:"language"},2306383:{type:6,filedName:"timeScale"},134:{type:7,filedName:"codecId"},2459272:{type:7,filedName:"codecName"},25506:{type:8,filedName:"codecPrivate"},225:{type:9,filedName:"audio",child:{181:{type:5,filedName:"sampleRate"},30901:{type:5,filedName:"outSampleRate"},25188:{type:1,filedName:"bitDepth"},159:{type:1,filedName:"channels"}}},224:{type:9,filedName:"video",child:{2327523:{type:1,filedName:"framerate"},21680:{type:1,filedName:"displayWidth"},21690:{type:1,filedName:"displayHeight"},176:{type:1,filedName:"pixelWidth"},186:{type:1,filedName:"pixelHeight"},3061028:{type:8,filedName:"colorSpace"},21440:{type:1,filedName:"alphaMode"},21936:{type:9,filedName:"color",child:{21937:{type:1,filedName:"matrixCoefficients"},21938:{type:1,filedName:"bitsPerChannel"},21941:{type:1,filedName:"cbSubHorz"},21942:{type:1,filedName:"cbSubVert"},21939:{type:1,filedName:"chromaSubHorz"},21940:{type:1,filedName:"chromaSubVert"},21943:{type:1,filedName:"chromaSitingHorz"},21944:{type:1,filedName:"chromaSitingVert"},21945:{type:1,filedName:"range"},21946:{type:1,filedName:"transferCharacteristics"},21947:{type:1,filedName:"primaries"},21948:{type:1,filedName:"maxCll"},21949:{type:1,filedName:"maxFall"},21968:{type:9,filedName:"masteringMeta",child:{21969:{type:5,filedName:"rx"},21970:{type:5,filedName:"ry"},21971:{type:5,filedName:"gx"},21972:{type:5,filedName:"gy"},21973:{type:5,filedName:"bx"},21974:{type:5,filedName:"by"},21975:{type:5,filedName:"whiteX"},21976:{type:5,filedName:"whiteY"},21978:{type:5,isArray:!0,filedName:"minLuminance"},21977:{type:5,filedName:"maxLuminance"}}}}},30320:{type:9,filedName:"projection",child:{30321:{type:1,filedName:"type"},30322:{type:8,filedName:"private"},30323:{type:5,filedName:"yaw"},30324:{type:5,filedName:"pitch"},30325:{type:5,filedName:"roll"}}},21682:{type:1,filedName:"displayUnit"},154:{type:1,filedName:"interlaced"},157:{type:1,filedName:"fieldOrder"},21432:{type:1,filedName:"stereoMode"},21683:{type:1,filedName:"aspectRatio"}}},226:{type:9,filedName:"operations",child:{227:{type:9,isArray:!0,filedName:"entry",child:{228:{type:9,isArray:!0,filedName:"planes",child:{230:{type:1,filedName:"type"},229:{type:1,filedName:"uid"}}}}}}},28032:{type:9,filedName:"encodings",child:{25152:{type:9,isArray:!0,filedName:"entry",child:{20530:{type:1,filedName:"scope"},20531:{type:1,filedName:"type"},20532:{type:9,filedName:"compression",child:{16980:{type:1,filedName:"algo"},16981:{type:8,filedName:"settings"}}},20533:{type:9,filedName:"encryption",child:{18401:{type:1,filedName:"algo"},18402:{type:8,filedName:"keyId"}}}}}}}}}},f={24999:{type:9,isArray:!0,filedName:"entry",child:{18094:{type:1,filedName:"uid"},18030:{type:7,filedName:"name"},18016:{type:7,filedName:"mime"},18046:{type:7,filedName:"description"},18012:{type:8,filedName:"data"}}}},h={17849:{type:9,isArray:!0,filedName:"entry",child:{182:{type:9,isArray:!0,filedName:"atom",child:{145:{type:2,filedName:"start"},146:{type:2,filedName:"end"},29636:{type:1,filedName:"uid"},128:{type:9,filedName:"display",child:{133:{type:7,filedName:"title"},17276:{type:7,filedName:"language"}}}}}}}},m={187:{type:9,isArray:!0,filedName:"entry",child:{179:{type:2,filedName:"time"},183:{type:9,isArray:!0,filedName:"pos",child:{247:{type:1,filedName:"track"},241:{type:2,filedName:"pos"}}}}}},u={17827:{type:7,filedName:"name"},17543:{type:7,filedName:"string"},17530:{type:7,filedName:"language"},17540:{type:1,filedName:"default"},17588:{type:1,filedName:"default"},26568:{type:9,filedName:"sub"}};u[26568].child=u;const g={29555:{type:9,isArray:!0,filedName:"entry",child:{26568:{type:9,filedName:"tag",child:u},25536:{type:9,filedName:"target",child:{25546:{type:7,filedName:"type"},26826:{type:1,filedName:"typeValue"},25541:{type:1,filedName:"trackUid"},25540:{type:1,filedName:"chapterUid"},25542:{type:1,filedName:"attachUid"}}}}}},A={161:{type:8,filedName:"block"},30113:{type:9,filedName:"additions",child:{166:{type:9,isArray:!0,filedName:"entry",child:{238:{type:1,filedName:"additionalId"},165:{type:8,filedName:"additional"}}}}},155:{type:2,filedName:"duration"},30114:{type:4,filedName:"discardPadding"},251:{type:4,isArray:!0,filedName:"reference"},164:{type:10,filedName:"nonSimple"}},y={163:{type:8,filedName:"block"},160:{type:9,filedName:"blockGroup",child:A},231:{type:2,filedName:"timeCode"},167:{type:2,filedName:"pos"},171:{type:2,filedName:"prevSize"}},I={17030:{type:1,filedName:"version"},17143:{type:1,filedName:"readVersion"},17138:{type:1,filedName:"maxIdLength"},17139:{type:1,filedName:"maxSizeLength"},17026:{type:7,filedName:"docType"},17031:{type:1,filedName:"docTypeVersion"},17029:{type:1,filedName:"docTypeReadVersion"}};async function N(e,t){const a=e.getPos();let n=await e.readUint8();if(!n)return i.z3(`0x00 as pos ${a} invalid as first byte of an EBML number`,o,766),r.LR;let c=1;for(;!(128&n);)c++,n<<=1;if(n&=127,c>t)return i.z3(`Length ${c} indicated by an EBML number's first byte ${n.toString(16)} at pos ${a} exceeds max length ${t}.`,o,779),r.LR;let d=n>>>c-1;for(;--c;)d<<=8,d|=await e.readUint8();return d}async function x(e,t){const a=e.getPos();return await N(e,t)-((1<<7*Number(BigInt.asIntN(32,e.getPos()-a))-1)-1)}async function b(e,t){const a=e.getPos();let n=await e.readUint8(),c=1;if(!n)return i.z3(`0x00 as pos ${a} invalid as first byte of an EBML number`,o,813),BigInt(r.LR);for(;!(128&n);)c++,n<<=1;if(n&=127,c>t)return i.z3(`Length ${c} indicated by an EBML number's first byte ${n.toString(16)} at pos ${a} exceeds max length ${t}.`,o,824),BigInt(r.LR);let d=BigInt(Math.floor(n>>>c-1));for(;--c;){d<<=BigInt(8);const t=await e.readUint8();d|=BigInt(Math.floor(t))}return d}async function S(e,t){switch(t){case BigInt(0):return 0;case BigInt(1):return e.ioReader.readUint8();case BigInt(2):return e.ioReader.readUint16();case BigInt(3):return e.ioReader.readUint24();case BigInt(4):return e.ioReader.readUint32();case BigInt(8):return e.ioReader.readUint64()}let a=BigInt(0),i=0;for(;i++<t;){const t=await e.ioReader.readUint8();a=a<<BigInt(8)|BigInt.asUintN(64,BigInt(Math.floor(t)))}return a}async function P(e,t){switch(t){case BigInt(0):return 0;case BigInt(1):return e.ioReader.readInt8();case BigInt(2):return e.ioReader.readInt16();case BigInt(4):return e.ioReader.readInt32();case BigInt(8):return e.ioReader.readInt64()}let a=BigInt(0),i=0;for(;i++<t;){const t=await e.ioReader.readUint8();a=a<<BigInt(8)|BigInt.asUintN(64,BigInt(Math.floor(t)))}return t===BigInt(3)?Number(BigInt.asIntN(32,BigInt.asIntN(24,a))):BigInt.asIntN(64,a)}async function R(e,t){const a=e.ioReader.getPos();let n=await e.ioReader.peekUint8();if(!n)return i.z3(`0x00 as pos ${a} invalid as first byte of an EBML number`,o,909),r.LR;let c=1;for(;!(128&n);)c++,n<<=1;if(c>t)return i.z3(`Length ${c} indicated by an EBML number's first byte ${n.toString(16)} at pos ${a} exceeds max length ${t}.`,o,921),r.LR;let d=0;for(;c--;)d<<=8,d|=await e.ioReader.readUint8();return d}async function k(e,t,a,i={},r=[]){return await async function(e,t,a){const i=e.privateData,r=e.ioReader.getPos();for(;e.ioReader.getPos()<r+t;){const t=await R(e,i.header.maxIdLength),r=await b(e.ioReader,i.header.maxSizeLength);if(e.ioReader.getPos(),!1===await a(t,r))return}}(e,t,(async(t,o)=>{if(a[t]){const r=a[t];let c;switch(r.type){case 1:c=await S(e,o);break;case 2:c=await S(e,o),n.ai(c)&&(c=BigInt(c));break;case 3:c=await P(e,o);break;case 4:c=await P(e,o),n.ai(c)&&(c=BigInt(c));break;case 6:case 5:c=await async function(e,t){return t===BigInt(4)?e.ioReader.readFloat():t===BigInt(8)?e.ioReader.readDouble():(await e.ioReader.skip(Number(BigInt.asIntN(32,t))),0)}(e,o);break;case 7:c=await e.ioReader.readString(Number(BigInt.asIntN(32,o)));break;case 10:c=!!await S(e,o);break;case 8:c={pos:e.ioReader.getPos(),size:o,data:o<d?await e.ioReader.readBuffer(Number(BigInt.asIntN(32,o))):null};break;case 9:c=r.child?await k(e,o,r.child):{};break;default:await e.ioReader.skip(Number(BigInt.asIntN(32,o)))}if(null!=c)if(r.isArray){const e=i[r.filedName]||[];e.push(c),i[r.filedName]=e}else i[r.filedName]=c}else await e.ioReader.skip(Number(BigInt.asIntN(32,o)));if(r.length&&c.zy(r,t))return!1})),i}},31866:(e,t,a)=>{a.d(t,{N:()=>r,e:()=>i});const i={A_AAC:86018,A_AC3:86019,A_ALAC:86032,A_DTS:86020,A_EAC3:86056,A_FLAC:86028,A_MLP:86045,"A_MPEG/L2":86016,"A_MPEG/L1":86058,"A_MPEG/L3":86017,A_OPUS:86076,"A_OPUS/EXPERIMENTAL":86076,"A_PCM/FLOAT/IEEE":65557,"A_PCM/INT/BIG":65537,"A_PCM/INT/LIT":65536,"A_QUICKTIME/QDMC":86066,"A_QUICKTIME/QDM2":86035,"A_REAL/14_4":77824,"A_REAL/28_8":77825,"A_REAL/ATRC":86047,"A_REAL/COOK":86036,"A_REAL/SIPR":86057,A_TRUEHD:86060,A_TTA1:86038,A_VORBIS:86021,A_WAVPACK4:86041,"D_WEBVTT/SUBTITLES":94226,"D_WEBVTT/CAPTIONS":94226,"D_WEBVTT/DESCRIPTIONS":94226,"D_WEBVTT/METADATA":94226,"S_TEXT/UTF8":94225,"S_TEXT/ASCII":94210,"S_TEXT/ASS":94230,"S_TEXT/SSA":94230,S_ASS:94230,S_SSA:94230,S_VOBSUB:94208,S_DVBSUB:94209,"S_HDMV/PGS":94214,"S_HDMV/TEXTST":94231,V_AV1:225,V_DIRAC:116,V_FFV1:33,V_MJPEG:7,V_MPEG1:1,V_MPEG2:2,"V_MPEG4/ISO/ASP":12,"V_MPEG4/ISO/AP":12,"V_MPEG4/ISO/SP":12,"V_MPEG4/ISO/AVC":27,"V_MPEGH/ISO/HEVC":173,"V_MPEGH/ISO/VVC":196,"V_MPEG4/MS/V3":16,V_PRORES:147,"V_REAL/RV10":5,"V_REAL/RV20":6,"V_REAL/RV30":68,"V_REAL/RV40":69,V_SNOW:208,V_THEORA:30,V_UNCOMPRESSED:13,V_VP8:139,V_VP9:167},r={V_VP8:139,V_VP9:167,V_AV1:225,A_VORBIS:86021,A_OPUS:86076,"D_WEBVTT/SUBTITLES":94226,"D_WEBVTT/CAPTIONS":94226,"D_WEBVTT/DESCRIPTIONS":94226,"D_WEBVTT/METADATA":94226}},53260:(e,t,a)=>{a.d(t,{g:()=>r,n:()=>n});var i=a(79682);const r={1:65541,2:69638,3:65557,6:65543,7:65542,10:86052,16:69664,17:69633,23:69664,32:69646,34:86037,49:86046,50:86046,56:73728,66:86068,69:69643,20:69643,64:69643,97:69635,98:69634,100:69643,105:69633,117:86079,131:86069,255:86018,273:86068,5632:86018,5634:86065,8192:86019},n={[(0,i.A)("H264")]:27,[(0,i.A)("h264")]:27,[(0,i.A)("X264")]:27,[(0,i.A)("x264")]:27,[(0,i.A)("avc1")]:27,[(0,i.A)("DAVC")]:27,[(0,i.A)("SMV2")]:27,[(0,i.A)("VSSH")]:27,[(0,i.A)("Q264")]:27,[(0,i.A)("V264")]:27,[(0,i.A)("GAVC")]:27,[(0,i.A)("UMSV")]:27,[(0,i.A)("tshd")]:27,[(0,i.A)("INMC")]:27,[(0,i.A)("FMP4")]:12,[(0,i.A)("DIVX")]:12,[(0,i.A)("DX50")]:12,[(0,i.A)("XVID")]:12,[(0,i.A)("MP4S")]:12,[(0,i.A)("M4S2")]:12,[(0,i.A)("DIVX")]:12,4:12,[(0,i.A)("ZMP4")]:12,[(0,i.A)("DIV1")]:12,[(0,i.A)("BLZ0")]:12,[(0,i.A)("mp4v")]:12,[(0,i.A)("UMP4")]:12,[(0,i.A)("WV1F")]:12,[(0,i.A)("SEDG")]:12,[(0,i.A)("RMP4")]:12,[(0,i.A)("3IV2")]:12,[(0,i.A)("WAWV")]:12,[(0,i.A)("FFDS")]:12,[(0,i.A)("FVFW")]:12,[(0,i.A)("DCOD")]:12,[(0,i.A)("MVXM")]:12,[(0,i.A)("PM4V")]:12,[(0,i.A)("SMP4")]:12,[(0,i.A)("DXGM")]:12,[(0,i.A)("VIDM")]:12,[(0,i.A)("M4T3")]:12,[(0,i.A)("GEOX")]:12,[(0,i.A)("G264")]:12,[(0,i.A)("HDX4")]:12,[(0,i.A)("DM4V")]:12,[(0,i.A)("DMK2")]:12,[(0,i.A)("DYM4")]:12,[(0,i.A)("DIGI")]:12,[(0,i.A)("EPHV")]:12,[(0,i.A)("EM4A")]:12,[(0,i.A)("M4CC")]:12,[(0,i.A)("SN40")]:12,[(0,i.A)("VSPX")]:12,[(0,i.A)("ULDX")]:12,[(0,i.A)("GEOV")]:12,[(0,i.A)("SIPP")]:12,[(0,i.A)("SM4V")]:12,[(0,i.A)("XVIX")]:12,[(0,i.A)("DreX")]:12,[(0,i.A)("QMP4")]:12,[(0,i.A)("PLV1")]:12,[(0,i.A)("GLV4")]:12,[(0,i.A)("GMP4")]:12,[(0,i.A)("MNM4")]:12,[(0,i.A)("GTM4")]:12,[(0,i.A)("MPG4")]:14,[(0,i.A)("MP41")]:14,[(0,i.A)("MP42")]:15,[(0,i.A)("DIV2")]:15,[(0,i.A)("MP43")]:16,[(0,i.A)("DIV3")]:16,[(0,i.A)("MPG3")]:16,[(0,i.A)("DIV5")]:16,[(0,i.A)("DIV6")]:16,[(0,i.A)("DIV4")]:16,[(0,i.A)("DVX3")]:16,[(0,i.A)("AP41")]:16,[(0,i.A)("COL1")]:16,[(0,i.A)("COL0")]:16,[(0,i.A)("VP80")]:139,[(0,i.A)("VP90")]:167}},79682:(e,t,a)=>{a.d(t,{A:()=>n});var i=a(4624);const r="src/avformat/function/mktagle.ts";function n(e){4!==e.length&&i.R8(`tag length is not 4, tag: ${e}`,r,30);let t=0;for(let a=3;a>=0;a--)t=t<<8|e.charCodeAt(a);return t}},95832:(e,t,a)=>{a.d(t,{Bq:()=>p,Ij:()=>l,XC:()=>s,f7:()=>f,uF:()=>n});var i=a(77231),r=a(37246);const n={1:"Main",2:"LC",3:"LC",4:"LC",5:"HE",6:"HE"},c={96e3:0,88200:1,64e3:2,48e3:3,44100:4,32e3:5,24e3:6,22050:7,16e3:8,12e3:9,11025:10,8e3:11,7350:12},o=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350,i.N_,i.N_,i.N_],d=[i.N_,1,2,3,4,5,6,7];function s(e,t){if(!t&&e.sideData[1]&&(t=e.sideData[1]),t){const{profile:a,sampleRate:r,channels:n}=function(e){let t=i.N_,a=i.N_,r=i.N_;return e.length>=2&&(t=e[0]>>3&31,a=o[(7&e[0])<<1|e[1]>>7],r=d[e[1]>>3&15]),{profile:t,sampleRate:a,channels:r}}(t);e.codecpar.profile=a,e.codecpar.sampleRate=r,e.codecpar.chLayout.nbChannels=n,e.codecpar.frameSize=5===a?2048:1024,e.codecpar.format=8}}function l(e){const t=c[e.sampleRate],a=e.chLayout.nbChannels,r=e.profile===i.N_?2:e.profile,n=new Uint8Array(2);return n[0]=(31&r)<<3|(14&t)>>1,n[1]=(1&t)<<7|(15&a)<<3,n}function p(e){if(e.length<7)return-1;const t=e[0]<<4|e[1]>>4;if(4095!==t)return-1;const a=1&e[1],i=(192&e[2])>>>6,r=(60&e[2])>>>2,n=(1&e[2])<<2|(192&e[3])>>>6,c=(3&e[3])<<11|e[4]<<3|(224&e[5])>>>5,s=3&e[6];let l=1===a?7:9,p=c-l;return{syncWord:t,profile:i+1,sampleRate:o[r],channels:d[n],aacFrameLength:c,numberOfRawDataBlocksInFrame:s,headerLength:l,framePayloadLength:p}}function f(e,t){function a(){const e=t.readU(2);let a=0;for(let i=0;i<=e;i++)a<<=8,a|=t.readU(8);return a}t||(t=new r.A).appendBuffer(e);const i=t.getPointer(),n={syncWord:0,profile:0,sampleRate:0,channels:0,useSameStreamMux:!1,headerLength:0,framePayloadLength:0,muxLengthBytes:0},c=t.readU(11);if(695!==c)return-1;n.syncWord=c,n.muxLengthBytes=t.readU(13);const s=1===t.readU1();if(n.useSameStreamMux=s,!s){const e=1===t.readU1();if(e&&1===t.readU1())return-1;if(e&&a(),1!==t.readU1())return-1;if(0!==t.readU(6))return-1;if(0!==t.readU(4))return-1;if(0!==t.readU(3))return-1;let i=e?a():0;const r=t.readU(5);i-=5;const c=t.readU(4);i-=4;const s=t.readU(4);if(i-=4,t.readU(3),i-=3,i>0&&t.readU(i),0!==t.readU(3))return-1;if(t.readU(8),1===t.readU1())if(e)a();else{let e=0;for(;;){e<<=8;const a=1===t.readU1();if(e+=t.readU(8),!a)break}}1===t.readU1()&&t.readU(8),n.profile=r+1,n.sampleRate=o[c],n.channels=d[s]}let l=0;for(;;){const e=t.readU(8);if(l+=e,255!==e)break}return n.framePayloadLength=l,n.headerLength=t.getPointer()-i+(8===t.getBitLeft()?0:1),n}},21477:(e,t,a)=>{a.d(t,{Ui:()=>c,XC:()=>n,zk:()=>r});var i=a(37246);a(83314),a(97317);const r={0:"Main",1:"High",2:"Professional"};function n(e,t){if(!t&&e.sideData[1]&&(t=e.sideData[1]),t&&t.length>=4){const a=c(t);e.codecpar.profile=a.profile,e.codecpar.level=a.level}}function c(e){const t=new i.A(e.length);t.appendBuffer(e),t.readU1(),t.readU(7);const a=t.readU(3),r=t.readU(5),n=t.readU1();let c=t.readU1()?10:8;return t.readU1()&&(c=12),{profile:a,level:r,tier:n,bitDepth:c,monochrome:t.readU1(),chromaSubsamplingX:t.readU1(),chromaSubsamplingY:t.readU1(),chromaSamplePosition:t.readU(2)}}},14769:(e,t,a)=>{a.d(t,{DK:()=>o,XC:()=>s,Xr:()=>d,jA:()=>n,ob:()=>r,oe:()=>c});var i=a(31865);const r=34,n=8,c=[0,8,12,0,16,20,24,32],o=[0,88200,176400,192e3,8e3,16e3,22050,24e3,32e3,44100,48e3,96e3,0,0,0,0],d=[0,192,576,1152,2304,4608,0,0,256,512,1024,2048,4096,8192,16384,32768];function s(e,t){if(!t&&e.sideData[1]&&(t=e.sideData[1]),t&&t.length===r){const{bitsPerRawSample:a,sampleRate:r,channels:n}=function(e){const t=new i.A(e);t.skip(10);const a=t.readUint24();return{sampleRate:a>>4,channels:1+((15&a)>>>1),bitsPerRawSample:1+((1&a)<<4|(240&t.readUint8())>>>4)}}(t);e.codecpar.bitsPerRawSample=a,e.codecpar.sampleRate=r,e.codecpar.chLayout.nbChannels=n}}},64093:(e,t,a)=>{a.d(t,{Au:()=>y,He:()=>I,XC:()=>N,Y2:()=>u,hG:()=>g,oz:()=>A});var i=a(77231);const r=[44100,48e3,32e3,0],n=[22050,24e3,16e3,0],c=[11025,12e3,8e3,0],o=[0,1152,1152,384],d=[0,576,1152,384],s=[0,576,1152,384],l=[0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,-1],p=[0,32,48,56,64,80,96,112,128,160,192,224,256,320,384,-1],f=[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1],h=[0,32,48,56,64,80,96,112,128,144,160,176,192,224,256,-1],m=[0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,-1];function u(e,t){switch(e){case 0:return c[t];case 2:return n[t];case 3:return r[t]}return i.N_}function g(e,t){switch(e){case 0:return s[t];case 2:return d[t];case 3:return o[t]}return i.N_}function A(e,t,a){switch(t){case 1:switch(e){case 0:case 2:return m[a];case 3:return f[a]}break;case 2:switch(e){case 0:case 2:return m[a];case 3:return p[a]}case 3:switch(e){case 0:case 2:return h[a];case 3:return l[a]}}return i.N_}function y(e){switch(e){case 1:return 34;case 2:return 33;case 3:return 32}return i.N_}const I={32:"Layer1",33:"Layer2",34:"Layer3"};function N(e,t){if(t&&t.length>=4){const a=t[1]>>>3&3,i=(6&t[1])>>1,r=(12&t[2])>>>2,n=3&~(t[3]>>>6)?2:1,c=y(i),o=u(a,r);e.codecpar.profile=c,e.codecpar.sampleRate=o,e.codecpar.chLayout.nbChannels=n}}},22576:(e,t,a)=>{a.d(t,{Ij:()=>s,XC:()=>d,kt:()=>o});var i=a(31865),r=a(729),n=a(44328);const c=[480,960,1920,2880,480,960,1920,2880,480,960,1920,2880,480,960,480,960,120,240,480,960,120,240,480,960,120,240,480,960,120,240,480,960];function o(e){let t=0,a=0,i=0;if(e.length<1)return 0;switch(t=e[0],a=c[t>>3],3&t){case 0:i=1;break;case 1:case 2:i=2;break;case 3:if(e.length<2)return 0;i=63&e[1]}return i*a}function d(e,t){if(!t&&e.sideData[1]&&(t=e.sideData[1]),t&&t.length>=19){const a=new i.A(t,!1);a.skip(9),e.codecpar.chLayout.nbChannels=a.readUint8(),e.codecpar.initialPadding=a.readUint16(),e.codecpar.sampleRate=a.readUint32(),e.codecpar.seekPreroll=Number((0,n.k)(BigInt(80),{den:1e3,num:1},{den:48e3,num:1}))}}function s(e){const t=new Uint8Array(19),a=new r.A(t,!1);return a.writeString("OpusHead"),a.writeUint8(1),a.writeUint8(e.chLayout.nbChannels),a.writeUint16(e.initialPadding),a.writeUint32(e.sampleRate),t}},97077:(e,t,a)=>{a.d(t,{Ui:()=>n,XC:()=>r});var i=a(37246);function r(e,t){if(!t&&e.sideData[1]&&(t=e.sideData[1]),t&&t.length>=6){const a=n(t);e.codecpar.profile=a.profile,e.codecpar.level=a.level}}function n(e){const t=new i.A(e.length);return t.appendBuffer(e.subarray(4)),{profile:t.readU(8),level:t.readU(8),bitDepth:t.readU(4),chromaSubsampling:t.readU(3),fullRangeFlag:t.readU1(),colorPrimaries:t.readU(8),colorTrc:t.readU(8),colorSpace:t.readU(8)}}},82014:(e,t,a)=>{a.d(t,{Ui:()=>c,XC:()=>n,wN:()=>r}),a(9599);var i=a(37246);a(77231),a(97317),a(44328),a(729);const r={0:"Profile0",1:"Profile1",2:"Profile2",3:"Profile3"};function n(e,t){if(!t&&e.sideData[1]&&(t=e.sideData[1]),t&&t.length>=6){const a=c(t);e.codecpar.profile=a.profile,e.codecpar.level=a.level}}function c(e){const t=new i.A(e.length);return t.appendBuffer(e),{profile:t.readU(8),level:t.readU(8),bitDepth:t.readU(4),chromaSubsampling:t.readU(3),fullRangeFlag:t.readU1(),colorPrimaries:t.readU(8),colorTrc:t.readU(8),colorSpace:t.readU(8)}}},null:()=>{},28795:(e,t,a)=>{a(78978),a(97863),a(7914),a(21640),a(871),a(52584),a(98345),e.exports=a(46438).Set},21640:(e,t,a)=>{var i=a(95933),r=a(6096);e.exports=a(99373)("Set",(function(e){return function(){return e(this,arguments.length>0?arguments[0]:void 0)}}),{add:function(e){return i.def(r(this,"Set"),e=0===e?0:e,e)}},i)},98345:(e,t,a)=>{a(643)("Set")},52584:(e,t,a)=>{a(44398)("Set")},871:(e,t,a)=>{var i=a(88535);i(i.P+i.R,"Set",{toJSON:a(5874)("Set")})},97860:(e,t,a)=>{e.exports=a(28795)}}]);