@libmedia/avplayer 0.9.0 → 0.11.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.
Files changed (46) hide show
  1. package/dist/esm/118.avplayer.js +1 -1
  2. package/dist/esm/217.avplayer.js +1 -1
  3. package/dist/esm/299.avplayer.js +1 -1
  4. package/dist/esm/331.avplayer.js +1 -1
  5. package/dist/esm/433.avplayer.js +1 -1
  6. package/dist/esm/453.avplayer.js +1 -1
  7. package/dist/esm/487.avplayer.js +1 -1
  8. package/dist/esm/522.avplayer.js +1 -1
  9. package/dist/esm/527.avplayer.js +1 -0
  10. package/dist/esm/531.avplayer.js +1 -1
  11. package/dist/esm/543.avplayer.js +1 -1
  12. package/dist/esm/576.avplayer.js +1 -1
  13. package/dist/esm/634.avplayer.js +1 -1
  14. package/dist/esm/791.avplayer.js +1 -1
  15. package/dist/esm/808.avplayer.js +1 -1
  16. package/dist/esm/855.avplayer.js +1 -1
  17. package/dist/esm/897.avplayer.js +1 -0
  18. package/dist/esm/904.avplayer.js +1 -1
  19. package/dist/esm/941.avplayer.js +1 -1
  20. package/dist/esm/969.avplayer.js +1 -1
  21. package/dist/esm/avplayer.js +1 -1
  22. package/dist/types/AVPlayer.d.ts +22 -0
  23. package/dist/types/Controller.d.ts +1 -0
  24. package/dist/types/mse/MSEPipeline.d.ts +1 -0
  25. package/dist/umd/118.avplayer.js +1 -1
  26. package/dist/umd/217.avplayer.js +1 -1
  27. package/dist/umd/299.avplayer.js +1 -1
  28. package/dist/umd/331.avplayer.js +1 -1
  29. package/dist/umd/433.avplayer.js +1 -1
  30. package/dist/umd/453.avplayer.js +1 -1
  31. package/dist/umd/487.avplayer.js +1 -1
  32. package/dist/umd/522.avplayer.js +1 -1
  33. package/dist/umd/527.avplayer.js +1 -0
  34. package/dist/umd/531.avplayer.js +1 -1
  35. package/dist/umd/543.avplayer.js +1 -1
  36. package/dist/umd/576.avplayer.js +1 -1
  37. package/dist/umd/634.avplayer.js +1 -1
  38. package/dist/umd/791.avplayer.js +1 -1
  39. package/dist/umd/808.avplayer.js +1 -1
  40. package/dist/umd/855.avplayer.js +1 -1
  41. package/dist/umd/897.avplayer.js +1 -0
  42. package/dist/umd/904.avplayer.js +1 -1
  43. package/dist/umd/941.avplayer.js +1 -1
  44. package/dist/umd/969.avplayer.js +1 -1
  45. package/dist/umd/avplayer.js +1 -1
  46. package/package.json +12 -12
@@ -1 +1 @@
1
- (self.webpackChunklibmedia=self.webpackChunklibmedia||[]).push([[433],{70509:(t,e,i)=>{i.d(e,{A:()=>a});var s=i(134);class a{constructor(){(0,s.A)(this,"onFlush",void 0)}}},97801:(t,e,i)=>{i.d(e,{A:()=>p});var s=i(134),a=i(70509),r=i(13258),n=i(51678),o=i(13724),h=i(4624);const l="src/avnetwork/bsp/aes/AESDecryptPipe.ts",d=16;let u=!0;const c=new Uint8Array(d).fill(d);class p extends a.A{constructor(t=0,e=1048576){super(),(0,s.A)(this,"buffer",void 0),(0,s.A)(this,"aesSoftDecryptor",void 0),(0,s.A)(this,"aesWebDecryptor",void 0),(0,s.A)(this,"aesTargetDecryptor",void 0),(0,s.A)(this,"pointer",void 0),(0,s.A)(this,"endPointer",void 0),(0,s.A)(this,"size",void 0),(0,s.A)(this,"ended",void 0),(0,s.A)(this,"iv",void 0),(0,s.A)(this,"key",void 0),(0,s.A)(this,"mode",void 0),(0,s.A)(this,"pos",void 0),this.mode=t,this.size=e,this.pointer=0,this.endPointer=0,this.pos=0,this.ended=!1,this.buffer=new Uint8Array(e),this.aesSoftDecryptor=new r.A(t),n.A.isSupport()&&u&&(this.aesWebDecryptor=new n.A(t)),this.aesTargetDecryptor=this.aesWebDecryptor||this.aesSoftDecryptor}remainingLength(){return this.endPointer-this.pointer}async expandKey(t,e){this.key=t,this.iv=e,this.aesWebDecryptor&&await this.aesWebDecryptor.expandKey(t),t.byteLength<=8&&this.aesSoftDecryptor.expandKey(t)}async flush_(t){for(;;){const e=await this.onFlush(t);if(-1048575!==e)return e;await new o.A(0)}}async flush(){if(this.size-this.remainingLength()<=0)return;this.pointer<this.endPointer?this.pointer&&(this.buffer.set(this.buffer.subarray(this.pointer,this.endPointer),0),this.endPointer=this.endPointer-this.pointer):this.endPointer=0,this.pointer=0;const t=await this.flush_(this.buffer.subarray(this.endPointer));if(t<0){if(-1048576===t)return void(this.ended=!0);h.h2(`AESPipe error, flush failed, ret: ${t}`,l,128)}this.endPointer+=t}removePadding(t){const e=t.length,i=e&&new DataView(t.buffer).getUint8(e-1);return i?t.subarray(0,e-i):t}async decryptCBC(t){let e,i=0;this.aesTargetDecryptor!==this.aesWebDecryptor||this.ended||(e=this.buffer.subarray(this.pointer+t,this.pointer+t+d).slice(),this.buffer.set((await this.aesWebDecryptor.encryptPadding(c,this.buffer.subarray(this.pointer+t-d,this.pointer+t))).subarray(0,d),this.pointer+t),i=d);try{const s=this.buffer.subarray(this.pointer,this.pointer+t+i),a=await this.aesTargetDecryptor.decrypt(s,this.iv);return this.iv=s.slice(s.length-d-i,s.length-i).buffer,e&&this.buffer.set(e,this.pointer+t),this.pointer+=t,this.pos+=t,new Uint8Array(a)}catch(i){if(this.aesTargetDecryptor===this.aesWebDecryptor&&this.key.byteLength<=8)return h.R8("web aes decrypt failed, try to use soft decryptor",l,178),e&&this.buffer.set(e,this.pointer+t),this.aesTargetDecryptor=this.aesSoftDecryptor,u=!1,this.decryptCBC(t);h.h2("aes decrypt failed",l,188)}}getCTRIv(){const t=new Uint8Array(this.iv).slice();let e=Math.floor(this.pos/d);for(let i=15;i>=0&&e>0;i--){const s=t[i]+(255&e);t[i]=255&s,e=(e>>>8)+(s>>8)}return t.buffer}async decryptCTR(t){try{const e=this.buffer.subarray(this.pointer,this.pointer+t),i=await this.aesTargetDecryptor.decrypt(e,this.getCTRIv());return this.pointer+=t,this.pos+=t,new Uint8Array(i)}catch(e){if(this.aesTargetDecryptor===this.aesWebDecryptor&&this.key.byteLength<=8)return h.R8("web aes decrypt failed, try to use soft decryptor",l,214),this.aesTargetDecryptor=this.aesSoftDecryptor,u=!1,this.decryptCTR(t);h.h2("aes decrypt failed",l,220)}}async read(t){for(;!this.ended&&this.remainingLength()<48;)await this.flush();if(0===this.remainingLength())return-1048576;if(0===this.mode){const e=Math.min(Math.floor((this.remainingLength()-(this.ended?0:32))/d)*d,t.length);let i=await this.decryptCBC(e);return this.ended&&this.aesTargetDecryptor===this.aesSoftDecryptor&&(i=this.removePadding(i)),t.set(i),i.length}{const e=this.ended?this.remainingLength():Math.min(Math.floor(this.remainingLength()/d)*d,t.length);let i=await this.decryptCTR(e);return t.set(i),i.length}}}},15433:(t,e,i)=>{i.r(e),i.d(e,{default:()=>b});var s=i(134),a=i(54001),r=i.n(a),n=i(80662),o=i.n(n),h=i(13724),l=i(82800),d=i(95335),u=i(8507),c=i(48182),p=i(77580),T=i(86932),m=i(4624),E=i(97801),f=i(67672),y=i(9705),A=i(51678),g=i(62751);const v="src/avnetwork/ioLoader/HlsIOLoader.ts";function I(t,e="GET"){var i,s,a;const r={method:"GET",headers:{},mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};return null!==(i=t.httpOptions)&&void 0!==i&&i.headers&&d.__(t.httpOptions.headers,((t,e)=>{r.headers[e]=t})),null!==(s=t.httpOptions)&&void 0!==s&&s.credentials&&(r.credentials=t.httpOptions.credentials),null!==(a=t.httpOptions)&&void 0!==a&&a.referrerPolicy&&(r.referrerPolicy=t.httpOptions.referrerPolicy),r}async function S(t,e,i,s){return new(r())(((a,r)=>{let n=0;!async function o(){try{const r=await fetch(t,{...I(e),signal:s}),d=await r.text(),u=(0,c.A)(d);if(i.isLive&&(!u.segments||u.segments.length<2)){var l;let t=5;null!==(l=u.segments)&&void 0!==l&&l.length&&(t=u.segments[0].duration*(2-u.segments.length)),m.R8(`wait for min buffer time, now segments: ${u.segments.length}`,v,92),await new h.A(t),n=0,o()}a(u)}catch(t){if("AbortError"===(null==t?void 0:t.name))return void a(null);if(n<i.retryCount)return n++,m.z3(`failed fetch m3u8 file, retry(${n}/3)`,v,106),await new h.A(i.retryInterval),o();m.z3("HLSLoader: exception, fetch slice error",v,111),r()}}()}))}class X{constructor(t,e,i,a){(0,s.A)(this,"options",void 0),(0,s.A)(this,"info",void 0),(0,s.A)(this,"mediaPlayList",void 0),(0,s.A)(this,"fetchedMap",void 0),(0,s.A)(this,"fetchedHistoryList",void 0),(0,s.A)(this,"mediaListUrl",void 0),(0,s.A)(this,"segmentIndex",void 0),(0,s.A)(this,"currentUri",void 0),(0,s.A)(this,"loader",void 0),(0,s.A)(this,"keyMap",void 0),(0,s.A)(this,"currentIV",void 0),(0,s.A)(this,"currentKey",void 0),(0,s.A)(this,"aesDecryptPipe",void 0),(0,s.A)(this,"initLoaded",void 0),(0,s.A)(this,"isInitLoader",void 0),(0,s.A)(this,"minBuffer",void 0),(0,s.A)(this,"pendingBuffer",void 0),(0,s.A)(this,"magicAdded",void 0),(0,s.A)(this,"sleep",void 0),(0,s.A)(this,"aborted",void 0),(0,s.A)(this,"signal",void 0),this.options=t,this.info=e,this.segmentIndex=0,this.fetchedMap=new(o()),this.fetchedHistoryList=[],this.keyMap=new(o()),this.aborted=!1,i&&a&&this.setMediaPlayList(i,a)}setMediaPlayList(t,e){if(this.options.isLive){this.fetchedMap.clear(),this.fetchedHistoryList.length=0,this.segmentIndex=0;const t=e.segments.find((t=>t.uri===this.currentUri));if(t)for(e.segments.forEach(((e,i)=>{e.mediaSequenceNumber===t.mediaSequenceNumber+1?this.segmentIndex=i:e.mediaSequenceNumber<=t.mediaSequenceNumber&&(this.fetchedMap.set(e.uri,!0),this.fetchedHistoryList.push(e.uri))}));this.fetchedHistoryList.length>=10;)this.fetchedMap.delete(this.fetchedHistoryList.shift())}if(this.mediaListUrl=t,this.mediaPlayList=e,this.minBuffer=this.mediaPlayList.duration||0,this.mediaPlayList.endlist&&(this.options.isLive=!1),this.initLoaded=!0,this.mediaPlayList.segments.length&&this.mediaPlayList.segments[0].map&&(this.initLoaded=!1),this.mediaPlayList.lowLatencyCompatibility){const t=this.mediaPlayList.lowLatencyCompatibility.partHoldBack||this.mediaPlayList.lowLatencyCompatibility.holdBack||this.minBuffer;let e=0,s=!1,a=0;for(let r=this.mediaPlayList.segments.length-1;r>=0;r--){var i;const n=this.mediaPlayList.segments[r];if(null!==(i=n.parts)&&void 0!==i&&i.length){if(!n.uri)continue;for(let i=n.parts.length-1;i>=0;i--){const o=n.parts[i];if(!o.hint&&(e+=o.duration,o.independent&&(s=!0),e>=t&&s)){a=r;break}}if(e>=t&&s)break}else if(e+=n.duration,s=!0,e>=t&&s){a=r;break}}this.fetchedMap.clear(),this.fetchedHistoryList.length=0;for(let t=0;t<a;t++){const e=this.mediaPlayList.segments[t];this.fetchedMap.set(e.uri,!0),this.fetchedHistoryList.push(e.uri)}for(;this.fetchedHistoryList.length>=10;)this.fetchedMap.delete(this.fetchedHistoryList.shift());this.segmentIndex=a,this.minBuffer=e}}getMediaListUrl(){return this.mediaListUrl}async checkNeedDecrypt(t,e,i){if(!t)return void(this.aesDecryptPipe=null);if("aes-128"!==t.method.toLocaleLowerCase()&&"aes-128-ctr"!==t.method.toLocaleLowerCase()&&("aes-256"!==t.method.toLocaleLowerCase()&&"aes-256-ctr"!==t.method.toLocaleLowerCase()||!A.A.isSupport())){if("mp4"===e.split(".").pop())return void(this.aesDecryptPipe=null);m.h2(`m3u8 ts not support EXT-X-KEY METHOD ${t.method}`,v,284)}const s=t.uri;if(this.keyMap.has(s)?this.currentKey=this.keyMap.get(s):(this.currentKey=await(await fetch((0,u.ll)(this.mediaListUrl,s),I(this.info))).arrayBuffer(),this.keyMap.set(s,this.currentKey)),t.iv)this.currentIV=t.iv.buffer;else{const t=new Uint8Array(16);new DataView(t.buffer).setUint32(12,i,!1),this.currentIV=t.buffer}this.aesDecryptPipe=new E.A(t.method.toLocaleLowerCase().indexOf("ctr")>0?1:0),this.aesDecryptPipe.onFlush=async t=>this.loader.read(t),await this.aesDecryptPipe.expandKey(this.currentKey,this.currentIV)}handleSlice(t,e){const i=this.loader.getUrl().split(".").pop();if("mp3"!==i&&!this.magicAdded&&73===e[0]&&68===e[1]&&51===e[2]){var s;const a=null!==(s=g.HR[i])&&void 0!==s?s:-1;return-1===a?t:(t+6>e.length&&(this.pendingBuffer=e.slice(t-6)),e.set(e.slice(0,t-6),6),e[0]=76,e[1]=73,e[2]=77,e[3]=65,e[4]=a>>>8&255,e[5]=255&a,this.magicAdded=!0,this.pendingBuffer?t:t+6)}return t}async read(t){if(this.pendingBuffer){let e=this.pendingBuffer.length;return t.set(this.pendingBuffer),this.pendingBuffer=null,e}let e=0;if(this.loader){if(e=this.aesDecryptPipe?await this.aesDecryptPipe.read(t):await this.loader.read(t),-1048576!==e)return e;if(this.isInitLoader)this.initLoaded=!0;else if(this.options.isLive)this.fetchedMap.set(this.currentUri,!0),10===this.fetchedHistoryList.length&&this.fetchedMap.delete(this.fetchedHistoryList.shift()),this.fetchedHistoryList.push(this.currentUri),this.segmentIndex++;else if(this.segmentIndex++,this.segmentIndex>=this.mediaPlayList.segments.length)return-1048576;this.loader=null}if(this.options.isLive){var i,s;const e=this.mediaPlayList.segments.filter((t=>t.uri&&!this.fetchedMap.get(t.uri)));if(!e.length){var a;if(this.mediaPlayList.endlist)return-1048576;const e=(this.minBuffer-((0,T.A)()-this.mediaPlayList.timestamp)/1e3)/2;return e>0&&(this.sleep=new h.A(e),await this.sleep,this.sleep=null,this.aborted)?-1048576:("function"==typeof AbortController&&(this.signal=new AbortController),this.mediaPlayList=await S(this.mediaListUrl,this.info,this.options,null===(a=this.signal)||void 0===a?void 0:a.signal),this.signal=null,this.aborted?-1048576:this.read(t))}this.isInitLoader=!(null===(i=e[0].map)||void 0===i||!i.uri||this.initLoaded),this.currentUri=e[0].uri,this.isInitLoader?null!==(s=e[0].map)&&void 0!==s&&s.key&&await this.checkNeedDecrypt(e[0].map.key,e[0].map.uri,this.segmentIndex+(this.mediaPlayList.mediaSequenceBase||0)):await this.checkNeedDecrypt(e[0].key,this.currentUri,this.segmentIndex+(this.mediaPlayList.mediaSequenceBase||0)),this.loader=new p.A(d.X$({},this.options,{disableSegment:!0,loop:!1}));const r=(0,u.ll)(this.mediaListUrl,this.isInitLoader?e[0].map.uri:this.currentUri),n={from:0,to:-1},o=this.isInitLoader?e[0].map.byterange:e[0].byterange;o&&(n.from=o.offset,n.to=o.offset+o.length),await this.loader.open(d.X$({},this.info,{url:r}),n);const l=await(this.aesDecryptPipe?this.aesDecryptPipe.read(t):this.loader.read(t));return l>10?this.handleSlice(l,t):l}{var r,n;this.loader=new p.A(d.X$({},this.options,{disableSegment:!0,loop:!1}));let e=this.mediaPlayList.segments[this.segmentIndex];for(;e&&!e.uri;)e=this.mediaPlayList.segments[++this.segmentIndex];this.isInitLoader=!(null===(r=e.map)||void 0===r||!r.uri||this.initLoaded),this.isInitLoader?null!==(n=e.map)&&void 0!==n&&n.key&&await this.checkNeedDecrypt(e.map.key,e.map.uri,this.segmentIndex+(this.mediaPlayList.mediaSequenceBase||0)):await this.checkNeedDecrypt(e.key,e.uri,this.segmentIndex+(this.mediaPlayList.mediaSequenceBase||0));const i=(0,u.ll)(this.mediaListUrl,this.isInitLoader?e.map.uri:e.uri),s={from:0,to:-1},a=this.isInitLoader?e.map.byterange:e.byterange;a&&(s.from=a.offset,s.to=a.offset+a.length),await this.loader.open(d.X$({},this.info,{url:i}),s);const o=await(this.aesDecryptPipe?this.aesDecryptPipe.read(t):this.loader.read(t));return o>10?this.handleSlice(o,t):o}}async seek(t){this.loader&&(await this.loader.abort(),this.loader=null);let e=0,i=Number(t),s=0;for(let t=0;t<this.mediaPlayList.segments.length;t++)if(f.ai(this.mediaPlayList.segments[t].duration)&&(e+=this.mediaPlayList.segments[t].duration,1e3*e>=i)){s=t;break}return this.segmentIndex=s,this.aborted=!1,0}abortSleep(){this.aborted=!0,this.loader&&this.loader.abortSleep(),this.sleep&&(this.sleep.stop(),this.sleep=null)}async abort(){this.abortSleep(),this.signal&&(this.signal.abort(),this.signal=null),this.loader&&(await this.loader.abort(),this.loader=null)}getMinBuffer(){return this.minBuffer}getDuration(){return this.mediaPlayList.duration}}class b extends l.A{constructor(...t){super(...t),(0,s.A)(this,"info",void 0),(0,s.A)(this,"masterPlaylist",void 0),(0,s.A)(this,"mediaPlayListIndex",void 0),(0,s.A)(this,"mainLoader",void 0),(0,s.A)(this,"loaders",void 0),(0,s.A)(this,"audioSelectedIndex",void 0),(0,s.A)(this,"subtitleSelectedIndex",void 0),(0,s.A)(this,"sleep",void 0),(0,s.A)(this,"aborted",void 0)}async fetchMasterPlayList(){try{const e=await fetch(this.info.url,I(this.info)),i=await e.text(),s=(0,c.A)(i);if(s.isMasterPlaylist)this.masterPlaylist=s;else{const e=s;if(this.options.isLive&&(!e.segments||e.segments.length<2)){var t;let i=5;return null!==(t=e.segments)&&void 0!==t&&t.length&&(i=e.segments[0].duration*(2-e.segments.length)),m.R8(`wait for min buffer time, now segments: ${e.segments.length}`,v,579),await new h.A(i),this.fetchMasterPlayList()}this.mainLoader=new X(this.options,this.info,this.info.url,e),this.loaders.set(0,this.mainLoader)}return s}catch(t){if(this.retryCount<this.options.retryCount)return this.retryCount++,m.z3(`failed fetch m3u8 file, retry(${this.retryCount}/3)`,v,596),this.sleep=new h.A(3),await this.sleep,this.sleep=null,this.aborted&&m.h2("HLSLoader: exception, fetch abort",v,601),this.fetchMasterPlayList();this.status=3,m.h2("HLSLoader: exception, fetch slice error",v,607)}}buildUrl(t){return/^https?/.test(t)||(t=u.ll(this.info.url,t)),t}async createLoader(){if(this.masterPlaylist){const t=this.masterPlaylist.variants[this.mediaPlayListIndex];if(t||m.h2("no media playlist",v,623),t.audio.length){const e=this.buildUrl(t.audio[this.audioSelectedIndex].uri);this.loaders.set(1,new X(this.options,this.info,e,await S(e,this.info,this.options)))}if(t.subtitles.length){const e=this.buildUrl(t.subtitles[this.subtitleSelectedIndex].uri);this.loaders.set(3,new X(this.options,this.info,e,await S(e,this.info,this.options)))}const e=this.buildUrl(t.uri);this.mainLoader=new X(this.options,this.info,e,await S(e,this.info,this.options)),this.loaders.set(0,this.mainLoader)}}async open(t){return 2===this.status?0:0!==this.status?y.lh:(this.info=t,this.mediaPlayListIndex=0,this.audioSelectedIndex=0,this.subtitleSelectedIndex=0,this.loaders=new(o()),this.status=1,this.retryCount=0,this.aborted=!1,await this.fetchMasterPlayList(),!this.loaders.size&&this.masterPlaylist&&await this.createLoader(),this.status=2,0)}async read(t,e){if(!e)return y.UY;const i=await this.loaders.get(e.mediaType).read(t);return i<0&&-1048575!==i&&(this.status=-1048576===i?4:3),i}async seek(t,e){return e?(await this.loaders.get(e.mediaType).seek(t),4===this.status&&(this.status=2),0):y.UY}async size(){return BigInt(0)}async abort(){for(let t of this.loaders)await t[1].abort();this.aborted=!0,this.sleep&&(this.sleep.stop(),this.sleep=null)}async stop(){await this.abort(),this.status=0}getDuration(){var t,e;return null!==(t=null===(e=this.mainLoader)||void 0===e?void 0:e.getDuration())&&void 0!==t?t:0}hasVideo(){return this.masterPlaylist?this.masterPlaylist.variants.length>0:!!this.mainLoader}hasAudio(){if(this.masterPlaylist)return this.masterPlaylist.variants[this.mediaPlayListIndex].audio.length>0}hasSubtitle(){if(this.masterPlaylist)return this.masterPlaylist.variants[this.mediaPlayListIndex].subtitles.length>0}getVideoList(){var t,e;return{list:null!==(t=null===(e=this.masterPlaylist)||void 0===e?void 0:e.variants.map((t=>{var e,i,s,a,r;return{width:null!==(e=null===(i=t.resolution)||void 0===i?void 0:i.width)&&void 0!==e?e:0,height:null!==(s=null===(a=t.resolution)||void 0===a?void 0:a.height)&&void 0!==s?s:0,frameRate:null!==(r=t.frameRate)&&void 0!==r?r:0,codec:t.codecs,bandwidth:t.bandwidth}})))&&void 0!==t?t:[],selectedIndex:this.mediaPlayListIndex||0}}getAudioList(){return this.masterPlaylist&&this.hasAudio()?{list:this.masterPlaylist.variants[this.mediaPlayListIndex].audio.map((t=>({lang:t.language,codec:t.name}))),selectedIndex:this.audioSelectedIndex}:{list:[],selectedIndex:0}}getSubtitleList(){return this.masterPlaylist&&this.hasSubtitle()?{list:this.masterPlaylist.variants[this.mediaPlayListIndex].subtitles.map((t=>({lang:t.language,codec:t.name}))),selectedIndex:this.subtitleSelectedIndex}:{list:[],selectedIndex:0}}selectVideo(t){if(this.masterPlaylist){const e=this.masterPlaylist.variants[t];if(e){const i=this.buildUrl(e.uri);if(S(i,this.info,this.options).then((e=>{this.loaders.get(0).setMediaPlayList(i,e),this.mediaPlayListIndex=t})),1===e.audio.length&&this.loaders.has(1)&&this.buildUrl(e.audio[0].uri)!==this.loaders.get(1).getMediaListUrl()){const t=this.buildUrl(e.audio[0].uri);S(t,this.info,this.options).then((e=>{this.loaders.get(1).setMediaPlayList(t,e)}))}if(1===e.subtitles.length&&this.loaders.has(3)&&this.buildUrl(e.subtitles[0].uri)!==this.loaders.get(3).getMediaListUrl()){const t=this.buildUrl(e.subtitles[0].uri);S(t,this.info,this.options).then((e=>{this.loaders.get(3).setMediaPlayList(t,e)}))}}}}selectAudio(t){if(this.masterPlaylist){const e=this.masterPlaylist.variants[this.mediaPlayListIndex];if(null!=e&&e.audio[t]){const i=this.buildUrl(e.audio[t].uri);S(i,this.info,this.options).then((e=>{this.loaders.get(1).setMediaPlayList(i,e),this.audioSelectedIndex=t}))}}}selectSubtitle(t){if(this.masterPlaylist){const e=this.masterPlaylist.variants[this.mediaPlayListIndex];if(null!=e&&e.subtitles[t]){const i=this.buildUrl(e.subtitles[t].uri);S(i,this.info,this.options).then((e=>{this.loaders.get(3).setMediaPlayList(i,e),this.subtitleSelectedIndex=t}))}}}getMinBuffer(){var t,e;return null!==(t=null===(e=this.mainLoader)||void 0===e?void 0:e.getMinBuffer())&&void 0!==t?t:0}}},48182:(t,e,i)=>{i.d(e,{A:()=>O});var s=i(7210),a=i.n(s),r=i(43929),n=i.n(r),o=i(69736),h=i.n(o),l=i(80662),d=i.n(l),u=i(67756),c=i(64608),p=i(4624);const T="src/avprotocol/m3u8/parser.ts";function m(t){return u.Bq(t,'"')}function E(t){const e=u.gI(t,",");return{duration:u.Ro(e[0]),title:decodeURIComponent(escape(e[1]))}}function f(t){const e=u.gI(t,"@");return{length:u.Ro(e[0]),offset:e[1]?u.Ro(e[1]):-1}}function y(t){const e=u.gI(t,"x");return{width:u.Ro(e[0]),height:u.Ro(e[1])}}function A(t){const e="ALLOWED-CPC: Each entry must consit of KEYFORMAT and Content Protection Configuration",i=t.split(",");0===i.length&&p.z3(e,T,102);const s=[];for(const t of i){const[i,a]=u.gI(t,":");i&&a?s.push({format:i,cpcList:a.split("/")}):p.z3(e,T,108)}return s}function g(t){const e=u.m2(t);return 16!==e.length&&p.z3("IV must be a 128-bit unsigned integer",T,119),e}function v(t,e){e.IV&&t.compatibleVersion<2&&(t.compatibleVersion=2),(e.KEYFORMAT||e.KEYFORMATVERSIONS)&&t.compatibleVersion<5&&(t.compatibleVersion=5)}function I(t){const e={};for(const s of u.HG(t)){const[t,a]=u.gI(s,"="),r=m(a);switch(t){case"URI":e[t]=r;break;case"START-DATE":case"END-DATE":e[t]=new Date(r);break;case"IV":e[t]=g(r);break;case"BYTERANGE":e[t]=f(r);break;case"RESOLUTION":e[t]=y(r);break;case"ALLOWED-CPC":e[t]=A(r);break;case"END-ON-NEXT":case"DEFAULT":case"AUTOSELECT":case"FORCED":case"PRECISE":case"CAN-BLOCK-RELOAD":case"INDEPENDENT":case"GAP":e[t]="YES"===r;break;case"DURATION":case"PLANNED-DURATION":case"BANDWIDTH":case"AVERAGE-BANDWIDTH":case"FRAME-RATE":case"TIME-OFFSET":case"CAN-SKIP-UNTIL":case"HOLD-BACK":case"PART-HOLD-BACK":case"PART-TARGET":case"BYTERANGE-START":case"BYTERANGE-LENGTH":case"LAST-MSN":case"LAST-PART":case"SKIPPED-SEGMENTS":case"SCORE":case"PROGRAM-ID":e[t]=u.Ro(r);break;default:t.startsWith("SCTE35-")?e[t]=u.m2(r):t.startsWith("X-")?e[t]=(i=a).startsWith('"')?m(i):i.startsWith("0x")||i.startsWith("0X")?u.m2(i):u.Ro(i):("VIDEO-RANGE"===t&&"SDR"!==r&&"HLG"!==r&&"PQ"!==r&&p.h2(`VIDEO-RANGE: unknown value "${r}"`,T,206),e[t]=r)}}var i;return e}function S(t,e,i){const s=function({attributes:t}){return new c.ru({type:t.TYPE,uri:t.URI,groupId:t["GROUP-ID"],language:t.LANGUAGE,assocLanguage:t["ASSOC-LANGUAGE"],name:t.NAME,isDefault:t.DEFAULT,autoselect:t.AUTOSELECT,forced:t.FORCED,instreamId:t["INSTREAM-ID"],characteristics:t.CHARACTERISTICS,channels:t.CHANNELS})}(e),a=t[u.Th(i)],r=function(t,e){let i=!1;for(const s of t){if(s.name===e.name)return"All EXT-X-MEDIA tags in the same Group MUST have different NAME attributes.";s.isDefault&&(i=!0)}return i&&e.isDefault?"EXT-X-MEDIA A Group MUST NOT have more than one member with a DEFAULT attribute of YES.":""}(a,s);r&&p.h2(r,T,315),a.push(s),s.isDefault&&(t.currentRenditions[u.Th(i)]=a.length-1)}function X(t,e,i,s,a){const r=new c.KT({uri:i,bandwidth:e.BANDWIDTH,averageBandwidth:e["AVERAGE-BANDWIDTH"],score:e.SCORE,codecs:e.CODECS,resolution:e.RESOLUTION,frameRate:e["FRAME-RATE"],hdcpLevel:e["HDCP-LEVEL"],allowedCpc:e["ALLOWED-CPC"],videoRange:e["VIDEO-RANGE"],stableVariantId:e["STABLE-VARIANT-ID"],programId:e["PROGRAM-ID"]});for(const i of t)if("EXT-X-MEDIA"===i.name){const t=i.attributes,s=t.TYPE;if(s&&t["GROUP-ID"]||p.h2("EXT-X-MEDIA TYPE attribute is REQUIRED.",T,355),e[s]===t["GROUP-ID"]&&(S(r,i,s),"CLOSED-CAPTIONS"===s))for(const{instreamId:t}of r.closedCaptions)if(t&&t.startsWith("SERVICE")&&a.compatibleVersion<7){a.compatibleVersion=7;break}}return function(t,e,i){for(const s of["AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS"])"CLOSED-CAPTIONS"===s&&"NONE"===t[s]?(i.isClosedCaptionsNone=!0,e.closedCaptions=[]):t[s]&&!e[u.Th(s)].some((e=>e.groupId===t[s]))&&p.h2(`${s} attribute MUST match the value of the GROUP-ID attribute of an EXT-X-MEDIA tag whose TYPE attribute is ${s}.`,T,330)}(e,r,a),r.isIFrameOnly=s,r}function b(t,e){if(t.method!==e.method)return!1;if(t.uri!==e.uri)return!1;if(t.iv){if(!e.iv)return!1;if(t.iv.length!==e.iv.length)return!1;for(let i=0;i<t.iv.length;i++)if(t.iv[i]!==e.iv[i])return!1}else if(e.iv)return!1;return t.format===e.format&&t.formatVersion===e.formatVersion}function N(t,e,i,s,a,r,o){const l=new c.Y4({uri:e,mediaSequenceNumber:a,discontinuitySequence:r});let d=!1,u=!1;for(let e=i;e<=s;e++){const{name:i,value:s,attributes:a}=t[e];if("EXTINF"===i)!n()(s.duration)&&o.compatibleVersion<3&&(o.compatibleVersion=3),Math.round(s.duration)>o.targetDuration&&p.h2("EXTINF duration, when rounded to the nearest integer, MUST be less than or equal to the target duration",T,517),l.duration=s.duration,l.title=s.title;else if("EXT-X-BYTERANGE"===i)o.compatibleVersion<4&&(o.compatibleVersion=4),l.byterange=s;else if("EXT-X-DISCONTINUITY"===i)l.parts.length>0&&p.h2("EXT-X-DISCONTINUITY must appear before the first EXT-X-PART tag of the Parent Segment.",T,530),l.discontinuity=!0;else if("EXT-X-KEY"===i)l.parts.length>0&&p.h2("EXT-X-KEY must appear before the first EXT-X-PART tag of the Parent Segment.",T,536),"NONE"!==a.METHOD?(v(o,a),l.key=new c.Uz({method:a.METHOD,uri:a.URI,iv:a.IV,format:a.KEYFORMAT,formatVersion:a.KEYFORMATVERSIONS})):l.key=null;else if("EXT-X-MAP"===i)l.parts.length>0&&p.h2("EXT-X-MAP must appear before the first EXT-X-PART tag of the Parent Segment.",T,555),o.compatibleVersion<5&&(o.compatibleVersion=5),o.hasMap=!0,l.map=new c.qP({uri:a.URI,byterange:a.BYTERANGE,key:l.key});else if("EXT-X-PROGRAM-DATE-TIME"===i)l.programDateTime=s;else if("EXT-X-DATERANGE"===i){const t={};for(const e of h()(a))(e.startsWith("SCTE35-")||e.startsWith("X-"))&&(t[e]=a[e]);l.dateRange=new c.ad({id:a.ID,classId:a.CLASS,start:a["START-DATE"],end:a["END-DATE"],duration:a.DURATION,plannedDuration:a["PLANNED-DURATION"],endOnNext:a["END-ON-NEXT"],attributes:t})}else if("EXT-X-CUE-OUT"===i)l.markers.push(new c.xC({type:"OUT",duration:a&&a.DURATION||s}));else if("EXT-X-CUE-IN"===i)l.markers.push(new c.xC({type:"IN"}));else if("EXT-X-CUE-OUT-CONT"===i||"EXT-X-CUE"===i||"EXT-OATCLS-SCTE35"===i||"EXT-X-ASSET"===i||"EXT-X-SCTE35"===i)l.markers.push(new c.xC({type:"RAW",tagName:i,value:s}));else if("EXT-X-PRELOAD-HINT"!==i||a.TYPE)if("EXT-X-PRELOAD-HINT"===i&&"PART"===a.TYPE&&u)p.h2("Servers should not add more than one EXT-X-PRELOAD-HINT tag with the same TYPE attribute to a Playlist.",T,616);else if("EXT-X-PART"!==i&&"EXT-X-PRELOAD-HINT"!==i||a.URI){if("EXT-X-PRELOAD-HINT"===i&&"MAP"===a.TYPE)d&&p.h2("Servers should not add more than one EXT-X-PRELOAD-HINT tag with the same TYPE attribute to a Playlist.",T,623),d=!0,o.hasMap=!0,l.map=new c.qP({hint:!0,uri:a.URI,byterange:{length:a["BYTERANGE-LENGTH"],offset:a["BYTERANGE-START"]||0}});else if("EXT-X-PART"===i||"EXT-X-PRELOAD-HINT"===i&&"PART"===a.TYPE){"EXT-X-PART"!==i||a.DURATION||p.h2("EXT-X-PART: DURATION attribute is mandatory",T,635),"EXT-X-PRELOAD-HINT"===i&&(u=!0);const t=new c.nw({hint:"EXT-X-PRELOAD-HINT"===i,uri:a.URI,byterange:"EXT-X-PART"===i?a.BYTERANGE:{length:a["BYTERANGE-LENGTH"],offset:a["BYTERANGE-START"]||0},duration:a.DURATION,independent:a.INDEPENDENT,gap:a.GAP});l.parts.push(t)}}else p.h2("EXT-X-PART / EXT-X-PRELOAD-HINT: URI attribute is mandatory",T,619);else p.h2("EXT-X-PRELOAD-HINT: TYPE attribute is mandatory",T,613)}return l}function R(t,e,i,s,a,r,n){const o=new c.Vd({uri:e,mediaSequenceNumber:a,discontinuitySequence:r});for(let e=i;e<=s;e++){const{name:i,attributes:s}=t[e];"EXTINF"===i?p.h2("A prefetch segment must not be advertised with an EXTINF tag.",T,667):"EXT-X-DISCONTINUITY"===i?p.h2("A prefetch segment must not be advertised with an EXT-X-DISCONTINUITY tag.",T,670):"EXT-X-PREFETCH-DISCONTINUITY"===i?o.discontinuity=!0:"EXT-X-KEY"===i?"NONE"!==s.METHOD&&(v(n,s),o.key=new c.Uz({method:s.METHOD,uri:s.URI,iv:s.IV,format:s.KEYFORMAT,formatVersion:s.KEYFORMATVERSIONS})):"EXT-X-MAP"===i&&p.h2("Prefetch segments must not be advertised with an EXT-X-MAP tag.",T,688)}return o}function P(t,e,i,s,a){const{discontinuity:r,key:n,map:o,byterange:h,uri:l}=e;if(r&&(e.discontinuitySequence=i+1),n||(e.key=s),o||(e.map=a),h&&-1===h.offset){const{segments:e}=t;if(e.length>0){const t=e[e.length-1];t.byterange&&t.uri===l?h.offset=t.byterange.offset+t.byterange.length:p.h2("If offset of EXT-X-BYTERANGE is not present, a previous Media Segment MUST be a sub-range of the same media resource",T,912)}else p.h2("If offset of EXT-X-BYTERANGE is not present, a previous Media Segment MUST appear in the Playlist file",T,916)}return t.segments.push(e),[e.discontinuitySequence,e.key,e.map]}function D(t,e){const[i,s]=function(t){const e=t.indexOf(":");return-1===e?[t.slice(1).trim(),null]:[t.slice(1,e).trim(),t.slice(e+1).trim()]}(t),r=function(t){switch(t){case"EXTM3U":case"EXT-X-VERSION":return"Basic";case"EXTINF":case"EXT-X-BYTERANGE":case"EXT-X-DISCONTINUITY":case"EXT-X-PREFETCH-DISCONTINUITY":case"EXT-X-KEY":case"EXT-X-MAP":case"EXT-X-PROGRAM-DATE-TIME":case"EXT-X-DATERANGE":case"EXT-X-CUE-OUT":case"EXT-X-CUE-IN":case"EXT-X-CUE-OUT-CONT":case"EXT-X-CUE":case"EXT-OATCLS-SCTE35":case"EXT-X-ASSET":case"EXT-X-SCTE35":case"EXT-X-PART":case"EXT-X-PRELOAD-HINT":return"Segment";case"EXT-X-TARGETDURATION":case"EXT-X-MEDIA-SEQUENCE":case"EXT-X-DISCONTINUITY-SEQUENCE":case"EXT-X-ENDLIST":case"EXT-X-PLAYLIST-TYPE":case"EXT-X-I-FRAMES-ONLY":case"EXT-X-SERVER-CONTROL":case"EXT-X-PART-INF":case"EXT-X-PREFETCH":case"EXT-X-RENDITION-REPORT":case"EXT-X-SKIP":return"MediaPlaylist";case"EXT-X-MEDIA":case"EXT-X-STREAM-INF":case"EXT-X-I-FRAME-STREAM-INF":case"EXT-X-SESSION-DATA":case"EXT-X-SESSION-KEY":return"MasterPlaylist";case"EXT-X-INDEPENDENT-SEGMENTS":case"EXT-X-START":return"MediaorMasterPlaylist";default:return"Unknown"}}(i);if(function(t,e){if("Segment"===t||"MediaPlaylist"===t)return void 0===e.isMasterPlaylist?void(e.isMasterPlaylist=!1):void(e.isMasterPlaylist&&p.h2("The file contains both media and master playlist tags.",T,1023));if("MasterPlaylist"===t){if(void 0===e.isMasterPlaylist)return void(e.isMasterPlaylist=!0);!1===e.isMasterPlaylist&&p.h2("The file contains both media and master playlist tags.",T,1033)}}(r,e),"Unknown"===r)return null;"MediaPlaylist"===r&&"EXT-X-RENDITION-REPORT"!==i&&"EXT-X-PREFETCH"!==i&&(e.hash[i]&&p.h2("There MUST NOT be more than one Media Playlist tag of each type in any Media Playlist",T,1054),e.hash[i]=!0);const[n,o]=function(t,e){switch(t){case"EXTM3U":case"EXT-X-DISCONTINUITY":case"EXT-X-ENDLIST":case"EXT-X-I-FRAMES-ONLY":case"EXT-X-INDEPENDENT-SEGMENTS":case"EXT-X-CUE-IN":return[null,null];case"EXT-X-VERSION":case"EXT-X-TARGETDURATION":case"EXT-X-MEDIA-SEQUENCE":case"EXT-X-DISCONTINUITY-SEQUENCE":return[u.Ro(e),null];case"EXT-X-CUE-OUT":return a()(Number(e))?[null,I(e)]:[u.Ro(e),null];case"EXT-X-KEY":case"EXT-X-MAP":case"EXT-X-DATERANGE":case"EXT-X-MEDIA":case"EXT-X-STREAM-INF":case"EXT-X-I-FRAME-STREAM-INF":case"EXT-X-SESSION-DATA":case"EXT-X-SESSION-KEY":case"EXT-X-START":case"EXT-X-SERVER-CONTROL":case"EXT-X-PART-INF":case"EXT-X-PART":case"EXT-X-PRELOAD-HINT":case"EXT-X-RENDITION-REPORT":case"EXT-X-SKIP":return[null,I(e)];case"EXTINF":return[E(e),null];case"EXT-X-BYTERANGE":return[f(e),null];case"EXT-X-PROGRAM-DATE-TIME":return[new Date(e),null];default:return[e,null]}}(i,s);return{name:i,category:r,value:n,attributes:o}}function L(t,e){let i;return e.isMasterPlaylist?i=function(t,e){const i=new c.ts;let s=!1;for(const[a,{name:r,value:n,attributes:o}]of t.entries())if("EXT-X-VERSION"===r)i.version=n;else if("EXT-X-STREAM-INF"===r){const r=t[a+1];("string"!=typeof r||r.startsWith("#EXT"))&&p.h2("EXT-X-STREAM-INF must be followed by a URI line",T,417);const n=X(t,o,r,!1,e);n&&("number"==typeof n.score&&(s=!0,n.score<0&&p.h2("SCORE attribute on EXT-X-STREAM-INF must be positive decimal-floating-point number.",T,424)),i.variants.push(n))}else if("EXT-X-I-FRAME-STREAM-INF"===r){const s=X(t,o,o.URI,!0,e);s&&i.variants.push(s)}else if("EXT-X-SESSION-DATA"===r){const t=new c.pf({id:o["DATA-ID"],value:o.VALUE,uri:o.URI,language:o.LANGUAGE});i.sessionDataList.some((e=>e.id===t.id&&e.language===t.language))&&p.h2("A Playlist MUST NOT contain more than one EXT-X-SESSION-DATA tag with the same DATA-ID attribute and the same LANGUAGE attribute.",T,444),i.sessionDataList.push(t)}else if("EXT-X-SESSION-KEY"===r){"NONE"===o.METHOD&&p.h2("EXT-X-SESSION-KEY: The value of the METHOD attribute MUST NOT be NONE",T,450);const t=new c.Uz({method:o.METHOD,uri:o.URI,iv:o.IV,format:o.KEYFORMAT,formatVersion:o.KEYFORMATVERSIONS});i.sessionKeyList.some((e=>b(e,t)))&&p.h2("A Master Playlist MUST NOT contain more than one EXT-X-SESSION-KEY tag with the same METHOD, URI, IV, KEYFORMAT, and KEYFORMATVERSIONS attribute values.",T,460),v(e,o),i.sessionKeyList.push(t)}else"EXT-X-INDEPENDENT-SEGMENTS"===r?(i.independentSegments&&p.h2("EXT-X-INDEPENDENT-SEGMENTS tag MUST NOT appear more than once in a Playlist",T,467),i.independentSegments=!0):"EXT-X-START"===r&&(i.start&&p.h2("EXT-X-START tag MUST NOT appear more than once in a Playlist",T,473),"number"!=typeof o["TIME-OFFSET"]&&p.h2("EXT-X-START: TIME-OFFSET attribute is REQUIRED",T,476),i.start={offset:o["TIME-OFFSET"],precise:o.PRECISE||!1});if(s)for(const t of i.variants)"number"!=typeof t.score&&p.h2("If any Variant Stream contains the SCORE attribute, then all Variant Streams in the Master Playlist SHOULD have a SCORE attribute",T,484);if(e.isClosedCaptionsNone)for(const t of i.variants)t.closedCaptions.length>0&&p.h2("If there is a variant with CLOSED-CAPTIONS attribute of NONE, all EXT-X-STREAM-INF tags MUST have this attribute with a value of NONE",T,491);return i}(t,e):(i=function(t,e){const i=new c.tk;let s=-1,a=0,r=!1,n=!1,o=0,h=null,l=null,u=!1;for(const[d,m]of t.entries()){const{name:E,value:f,attributes:y,category:A}=m;if("Segment"!==A){if("EXT-X-VERSION"===E)void 0===i.version?i.version=f:p.h2("A Playlist file MUST NOT contain more than one EXT-X-VERSION tag.",T,720);else if("EXT-X-TARGETDURATION"===E)i.targetDuration=e.targetDuration=f;else if("EXT-X-MEDIA-SEQUENCE"===E)i.segments.length>0&&p.h2("The EXT-X-MEDIA-SEQUENCE tag MUST appear before the first Media Segment in the Playlist.",T,728),i.mediaSequenceBase=a=f;else if("EXT-X-DISCONTINUITY-SEQUENCE"===E)i.segments.length>0&&p.h2("The EXT-X-DISCONTINUITY-SEQUENCE tag MUST appear before the first Media Segment in the Playlist.",T,734),r&&p.h2("The EXT-X-DISCONTINUITY-SEQUENCE tag MUST appear before any EXT-X-DISCONTINUITY tag.",T,737),i.discontinuitySequenceBase=o=f;else if("EXT-X-ENDLIST"===E)i.endlist=!0;else if("EXT-X-PLAYLIST-TYPE"===E)i.playlistType=f;else if("EXT-X-I-FRAMES-ONLY"===E)e.compatibleVersion<4&&(e.compatibleVersion=4),i.isIFrame=!0;else if("EXT-X-INDEPENDENT-SEGMENTS"===E)i.independentSegments&&p.h2("EXT-X-INDEPENDENT-SEGMENTS tag MUST NOT appear more than once in a Playlist",T,755),i.independentSegments=!0;else if("EXT-X-START"===E)i.start&&p.h2("EXT-X-START tag MUST NOT appear more than once in a Playlist",T,761),"number"!=typeof y["TIME-OFFSET"]&&p.h2("EXT-X-START: TIME-OFFSET attribute is REQUIRED",T,764),i.start={offset:y["TIME-OFFSET"],precise:y.PRECISE||!1};else if("EXT-X-SERVER-CONTROL"===E)y["CAN-BLOCK-RELOAD"]||p.h2("EXT-X-SERVER-CONTROL: CAN-BLOCK-RELOAD=YES is mandatory for Low-Latency HLS",T,770),i.lowLatencyCompatibility={canBlockReload:y["CAN-BLOCK-RELOAD"],canSkipUntil:y["CAN-SKIP-UNTIL"],holdBack:y["HOLD-BACK"],partHoldBack:y["PART-HOLD-BACK"]};else if("EXT-X-PART-INF"===E)y["PART-TARGET"]||p.h2("EXT-X-PART-INF: PART-TARGET attribute is mandatory",T,781),i.partTargetDuration=y["PART-TARGET"];else if("EXT-X-RENDITION-REPORT"===E)y.URI||p.h2("EXT-X-RENDITION-REPORT: URI attribute is mandatory",T,787),0===y.URI.search(/^[a-z]+:/)&&p.h2("EXT-X-RENDITION-REPORT: URI must be relative to the playlist uri",T,790),i.renditionReports.push(new c.h4({uri:y.URI,lastMSN:y["LAST-MSN"],lastPart:y["LAST-PART"]}));else if("EXT-X-SKIP"===E)y["SKIPPED-SEGMENTS"]||p.h2("EXT-X-SKIP: SKIPPED-SEGMENTS attribute is mandatory",T,800),e.compatibleVersion<9&&(e.compatibleVersion=9),i.skip=y["SKIPPED-SEGMENTS"],a+=i.skip;else if("EXT-X-PREFETCH"===E){const r=R(t,f,-1===s?d:s,d-1,a++,o,e);r&&(r.discontinuity&&(r.discontinuitySequence++,o=r.discontinuitySequence),r.key?h=r.key:null===r.key?h=void 0:r.key=h,i.prefetchSegments.push(r)),n=!0,s=-1}else if("string"==typeof m){-1===s&&p.h2("A URI line is not preceded by any segment tags",T,840),i.targetDuration||p.h2("The EXT-X-TARGETDURATION tag is REQUIRED",T,843),n&&p.h2("These segments must appear after all complete segments.",T,846);const r=N(t,m,s,d-1,a++,o,e);r&&(null===r.key&&(h=void 0),[o,h,l]=P(i,r,o,h,l),!u&&r.parts.length>0&&(u=!0)),s=-1}}else-1===s&&(s=d),"EXT-X-DISCONTINUITY"===E&&(r=!0)}if(-1!==s){const r=N(t,"",s,t.length-1,a++,o,e);if(r){var m;null===r.key&&(h=void 0);const{parts:t}=r;!(t.length>0)||i.endlist||null!==(m=t[t.length-1])&&void 0!==m&&m.hint||p.h2("If the Playlist contains EXT-X-PART tags and does not contain an EXT-X-ENDLIST tag, the Playlist must contain an EXT-X-PRELOAD-HINT tag with a TYPE=PART attribute",T,869),P(i,r,o,h,l),!u&&r.parts.length>0&&(u=!0)}}return function(t){const e=new(d()),i=new(d());let s=!1,a=!1;for(let r=t.length-1;r>=0;r--){const{programDateTime:n,dateRange:o}=t[r];if(n&&(a=!0),o&&o.start){s=!0,o.endOnNext&&(o.end||o.duration)&&p.h2("An EXT-X-DATERANGE tag with an END-ON-NEXT=YES attribute MUST NOT contain DURATION or END-DATE attributes.",T,936);const t=o.start.getTime(),a=o.duration||0;o.end&&o.duration&&t+1e3*a!==o.end.getTime()&&p.h2("END-DATE MUST be equal to the value of the START-DATE attribute plus the value of the DURATION",T,942),o.endOnNext&&(o.end=e.get(o.classId)),e.set(o.classId,o.start);const r=o.end?o.end.getTime():o.start.getTime()+1e3*(o.duration||0),n=i.get(o.classId);if(n){for(const e of n)(e.start<=t&&e.end>t||e.start>=t&&e.start<r)&&p.h2("DATERANGE tags with the same CLASS should not overlap",T,954);n.push({start:t,end:r})}else o.classId&&i.set(o.classId,[{start:t,end:r}])}}s&&!a&&p.h2("If a Playlist contains an EXT-X-DATERANGE tag, it MUST also contain at least one EXT-X-PROGRAM-DATE-TIME tag.",T,965)}(i.segments),i.lowLatencyCompatibility&&function({lowLatencyCompatibility:t,targetDuration:e,partTargetDuration:i,segments:s,renditionReports:a},r){const{canSkipUntil:n,holdBack:o,partHoldBack:h}=t;if(n<6*e&&p.h2("The Skip Boundary must be at least six times the EXT-X-TARGETDURATION.",T,972),o<3*e&&p.h2("HOLD-BACK must be at least three times the EXT-X-TARGETDURATION.",T,976),r){void 0===i&&p.h2("EXT-X-PART-INF is required if a Playlist contains one or more EXT-X-PART tags",T,980),void 0===h&&p.h2("EXT-X-PART: PART-HOLD-BACK attribute is mandatory",T,983),h<i&&p.h2("PART-HOLD-BACK must be at least PART-TARGET",T,986);for(const[t,{parts:e}]of s.entries())for(const[t,{duration:s}]of e.entries())void 0!==s&&(s>i&&p.h2("PART-TARGET is the maximum duration of any Partial Segment",T,997),t<e.length-1&&s<.85*i&&p.h2("All Partial Segments except the last part of a segment must have a duration of at least 85% of PART-TARGET",T,1e3))}for(const t of a){const e=s[s.length-1];null!==t.lastMSN&&void 0!==t.lastMSN||(t.lastMSN=e.mediaSequenceNumber),(null===t.lastPart||void 0===t.lastPart)&&e.parts.length>0&&(t.lastPart=e.parts.length-1)}}(i,u),i.duration=i.segments.reduce(((t,e)=>"number"==typeof e.duration?t+e.duration:t),0),i}(t,e),!i.isIFrame&&e.hasMap&&e.compatibleVersion<6&&(e.compatibleVersion=6)),e.compatibleVersion>1&&(!i.version||i.version<e.compatibleVersion)&&p.h2(`EXT-X-VERSION needs to be ${e.compatibleVersion} or higher.`,T,1104),i}function O(t){const e={version:void 0,isMasterPlaylist:void 0,hasMap:!1,targetDuration:0,compatibleVersion:1,isClosedCaptionsNone:!1,hash:{}},i=function(t,e){const i=[];for(const s of t.split("\n")){const t=s.trim();if(t)if(t.startsWith("#")){if(t.startsWith("#EXT")){const s=D(t,e);s&&i.push(s)}}else i.push(t)}return 0!==i.length&&"EXTM3U"===i[0].name||p.h2("The EXTM3U tag MUST be the first line.",T,1086),i}(t,e),s=L(i,e);return s.source=t,s}},64608:(t,e,i)=>{i.d(e,{KT:()=>n,Uz:()=>h,Vd:()=>y,Y4:()=>E,ad:()=>d,h4:()=>A,nw:()=>f,pf:()=>o,qP:()=>l,ru:()=>r,tk:()=>m,ts:()=>T,xC:()=>u});var s=i(134),a=i(86932);class r{constructor({type:t,uri:e,groupId:i,language:a,assocLanguage:r,name:n,isDefault:o,autoselect:h,forced:l,instreamId:d,characteristics:u,channels:c}){(0,s.A)(this,"type",void 0),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"groupId",void 0),(0,s.A)(this,"language",void 0),(0,s.A)(this,"assocLanguage",void 0),(0,s.A)(this,"name",void 0),(0,s.A)(this,"isDefault",void 0),(0,s.A)(this,"autoselect",void 0),(0,s.A)(this,"forced",void 0),(0,s.A)(this,"instreamId",void 0),(0,s.A)(this,"characteristics",void 0),(0,s.A)(this,"channels",void 0),this.type=t,this.uri=e,this.groupId=i,this.language=a,this.assocLanguage=r,this.name=n,this.isDefault=o,this.autoselect=h,this.forced=l,this.instreamId=d,this.characteristics=u,this.channels=c}}class n{constructor({uri:t,isIFrameOnly:e=!1,bandwidth:i,averageBandwidth:a,score:r,codecs:n,resolution:o,frameRate:h,hdcpLevel:l,allowedCpc:d,videoRange:u,stableVariantId:c,programId:p,audio:T=[],video:m=[],subtitles:E=[],closedCaptions:f=[],currentRenditions:y={audio:0,video:0,subtitles:0,closedCaptions:0}}){(0,s.A)(this,"uri",void 0),(0,s.A)(this,"isIFrameOnly",void 0),(0,s.A)(this,"bandwidth",void 0),(0,s.A)(this,"averageBandwidth",void 0),(0,s.A)(this,"score",void 0),(0,s.A)(this,"codecs",void 0),(0,s.A)(this,"resolution",void 0),(0,s.A)(this,"frameRate",void 0),(0,s.A)(this,"hdcpLevel",void 0),(0,s.A)(this,"allowedCpc",void 0),(0,s.A)(this,"videoRange",void 0),(0,s.A)(this,"stableVariantId",void 0),(0,s.A)(this,"programId",void 0),(0,s.A)(this,"audio",void 0),(0,s.A)(this,"video",void 0),(0,s.A)(this,"subtitles",void 0),(0,s.A)(this,"closedCaptions",void 0),(0,s.A)(this,"currentRenditions",void 0),this.uri=t,this.isIFrameOnly=e,this.bandwidth=i,this.averageBandwidth=a,this.score=r,this.codecs=n,this.resolution=o,this.frameRate=h,this.hdcpLevel=l,this.allowedCpc=d,this.videoRange=u,this.stableVariantId=c,this.programId=p,this.audio=T,this.video=m,this.subtitles=E,this.closedCaptions=f,this.currentRenditions=y}}class o{constructor({id:t,value:e,uri:i,language:a}){(0,s.A)(this,"id",void 0),(0,s.A)(this,"value",void 0),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"language",void 0),this.id=t,this.value=e,this.uri=i,this.language=a}}class h{constructor({method:t,uri:e,iv:i,format:a,formatVersion:r}){(0,s.A)(this,"method",void 0),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"iv",void 0),(0,s.A)(this,"format",void 0),(0,s.A)(this,"formatVersion",void 0),this.method=t,this.uri=e,this.iv=i,this.format=a,this.formatVersion=r}}class l{constructor({hint:t=!1,uri:e,mimeType:i,byterange:a,key:r}){(0,s.A)(this,"hint",void 0),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"mimeType",void 0),(0,s.A)(this,"byterange",void 0),(0,s.A)(this,"key",void 0),this.hint=t,this.uri=e,this.mimeType=i,this.byterange=a,this.key=r}}class d{constructor({id:t,classId:e,start:i,end:a,duration:r,plannedDuration:n,endOnNext:o,attributes:h={}}){(0,s.A)(this,"id",void 0),(0,s.A)(this,"classId",void 0),(0,s.A)(this,"start",void 0),(0,s.A)(this,"end",void 0),(0,s.A)(this,"duration",void 0),(0,s.A)(this,"plannedDuration",void 0),(0,s.A)(this,"endOnNext",void 0),(0,s.A)(this,"attributes",void 0),this.id=t,this.classId=e,this.start=i,this.end=a,this.duration=r,this.plannedDuration=n,this.endOnNext=o,this.attributes=h}}class u{constructor({type:t,duration:e,tagName:i,value:a}){(0,s.A)(this,"type",void 0),(0,s.A)(this,"duration",void 0),(0,s.A)(this,"tagName",void 0),(0,s.A)(this,"value",void 0),this.type=t,this.duration=e,this.tagName=i,this.value=a}}class c{constructor(t){(0,s.A)(this,"type",void 0),this.type=t}}class p extends c{constructor({isMasterPlaylist:t,uri:e,version:i,independentSegments:a=!1,start:r,source:n}){super("playlist"),(0,s.A)(this,"isMasterPlaylist",void 0),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"version",void 0),(0,s.A)(this,"independentSegments",void 0),(0,s.A)(this,"start",void 0),(0,s.A)(this,"source",void 0),this.isMasterPlaylist=t,this.uri=e,this.version=i,this.independentSegments=a,this.start=r,this.source=n}}class T extends p{constructor(t={}){super({...t,isMasterPlaylist:!0}),(0,s.A)(this,"variants",void 0),(0,s.A)(this,"currentVariant",void 0),(0,s.A)(this,"sessionDataList",void 0),(0,s.A)(this,"sessionKeyList",void 0);const{variants:e=[],currentVariant:i,sessionDataList:a=[],sessionKeyList:r=[]}=t;this.variants=e,this.currentVariant=i,this.sessionDataList=a,this.sessionKeyList=r}}class m extends p{constructor(t={}){super({...t,isMasterPlaylist:!1}),(0,s.A)(this,"targetDuration",void 0),(0,s.A)(this,"mediaSequenceBase",void 0),(0,s.A)(this,"discontinuitySequenceBase",void 0),(0,s.A)(this,"endlist",void 0),(0,s.A)(this,"playlistType",void 0),(0,s.A)(this,"isIFrame",void 0),(0,s.A)(this,"segments",void 0),(0,s.A)(this,"prefetchSegments",void 0),(0,s.A)(this,"lowLatencyCompatibility",void 0),(0,s.A)(this,"partTargetDuration",void 0),(0,s.A)(this,"renditionReports",void 0),(0,s.A)(this,"skip",void 0),(0,s.A)(this,"hash",void 0),(0,s.A)(this,"duration",void 0),(0,s.A)(this,"timestamp",void 0);const{targetDuration:e,mediaSequenceBase:i=0,discontinuitySequenceBase:r=0,endlist:n=!1,playlistType:o,isIFrame:h,segments:l=[],prefetchSegments:d=[],lowLatencyCompatibility:u,partTargetDuration:c,renditionReports:p=[],skip:T=0,hash:m,duration:E=0}=t;this.targetDuration=e,this.mediaSequenceBase=i,this.discontinuitySequenceBase=r,this.endlist=n,this.playlistType=o,this.isIFrame=h,this.segments=l,this.prefetchSegments=d,this.lowLatencyCompatibility=u,this.partTargetDuration=c,this.renditionReports=p,this.skip=T,this.hash=m,this.duration=E,this.timestamp=(0,a.A)()}}class E extends c{constructor({uri:t,mimeType:e,data:i,duration:a,title:r,byterange:n,discontinuity:o,mediaSequenceNumber:h=0,discontinuitySequence:l=0,key:d,map:u,programDateTime:c,dateRange:p,markers:T=[],parts:m=[]}){super("segment"),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"mimeType",void 0),(0,s.A)(this,"data",void 0),(0,s.A)(this,"duration",void 0),(0,s.A)(this,"title",void 0),(0,s.A)(this,"byterange",void 0),(0,s.A)(this,"discontinuity",void 0),(0,s.A)(this,"mediaSequenceNumber",void 0),(0,s.A)(this,"discontinuitySequence",void 0),(0,s.A)(this,"key",void 0),(0,s.A)(this,"map",void 0),(0,s.A)(this,"programDateTime",void 0),(0,s.A)(this,"dateRange",void 0),(0,s.A)(this,"markers",void 0),(0,s.A)(this,"parts",void 0),this.uri=t,this.mimeType=e,this.data=i,this.duration=a,this.title=r,this.byterange=n,this.discontinuity=o,this.mediaSequenceNumber=h,this.discontinuitySequence=l,this.key=d,this.map=u,this.programDateTime=c,this.dateRange=p,this.markers=T,this.parts=m}}class f extends c{constructor({hint:t=!1,uri:e,duration:i,independent:a,byterange:r,gap:n}){super("part"),(0,s.A)(this,"hint",void 0),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"duration",void 0),(0,s.A)(this,"independent",void 0),(0,s.A)(this,"byterange",void 0),(0,s.A)(this,"gap",void 0),this.hint=t,this.uri=e,this.duration=i,this.independent=a,this.duration=i,this.byterange=r,this.gap=n}}class y extends c{constructor({uri:t,discontinuity:e,mediaSequenceNumber:i=0,discontinuitySequence:a=0,key:r}){super("prefetch"),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"discontinuity",void 0),(0,s.A)(this,"mediaSequenceNumber",void 0),(0,s.A)(this,"discontinuitySequence",void 0),(0,s.A)(this,"key",void 0),this.uri=t,this.discontinuity=e,this.mediaSequenceNumber=i,this.discontinuitySequence=a,this.key=r}}class A{constructor({uri:t,lastMSN:e,lastPart:i}){(0,s.A)(this,"uri",void 0),(0,s.A)(this,"lastMSN",void 0),(0,s.A)(this,"lastPart",void 0),this.uri=t,this.lastMSN=e,this.lastPart=i}}},67756:(t,e,i)=>{i.d(e,{Bq:()=>c,HG:()=>p,Ro:()=>l,Th:()=>T,gI:()=>u,m2:()=>d});var s=i(99704),a=i.n(s),r=i(17735),n=i.n(r),o=i(7210),h=i.n(o);function l(t,e=10){if("number"==typeof t)return t;const i=10===e?a()(t):n()(t,e);return h()(i)?0:i}function d(t){(t.startsWith("0x")||t.startsWith("0X"))&&(t=t.slice(2));const e=[];for(let i=0;i<t.length;i+=2)e.push(l(t.slice(i,i+2),16));return new Uint8Array(e)}function u(t,e,i=0){let s=-1;for(let a=0,r=0;a<t.length;a++)if(t[a]===e){if(r++===i)return[t.slice(0,a),t.slice(a+1)];s=a}return-1!==s?[t.slice(0,s),t.slice(s+1)]:[t]}function c(t,e=" "){return t?(t=t.trim()," "===e||(t.startsWith(e)&&(t=t.slice(1)),t.endsWith(e)&&(t=t.slice(0,-1))),t):t}function p(t){const e=[];let i=!0,s=0;const a=[];for(let r=0;r<t.length;r++){const n=t[r];i&&","===n?(e.push(t.slice(s,r).trim()),s=r+1):'"'!==n&&"'"!==n||(i?(a.push(n),i=!1):n===a[a.length-1]?(a.pop(),i=!0):a.push(n))}return e.push(t.slice(s).trim()),e}function T(t){const e=[];let i=!1;for(const s of t)"-"!==s&&"_"!==s?i?(e.push(s.toUpperCase()),i=!1):e.push(s.toLowerCase()):i=!0;return e.join("")}},62751:(t,e,i)=>{i.d(e,{$$:()=>r,Eh:()=>T,HR:()=>a,IY:()=>y,Ki:()=>f,Mb:()=>E,Sz:()=>d,Xp:()=>h,_R:()=>n,_m:()=>p,d8:()=>m,iW:()=>u,mX:()=>c,n1:()=>o,os:()=>s,qO:()=>l});const s={86017:"mp3",86018:"mp4a.40",86021:"vorbis",86028:"flac",86076:"opus",65542:"ulaw",65543:"alaw",86019:"ac-3",86056:"ec-3",86020:"dtsc",225:"av01",27:"avc1",173:"hev1",196:"vvc1",139:"vp8",167:"vp09",12:"mp4v"},a={flv:0,mp4:1,m4s:1,mov:1,ts:2,mts:2,m2ts:2,ivf:5,opus:4,oggs:4,ogg:4,m3u8:2,m3u:2,mpd:1,mp3:14,mkv:8,mka:8,webm:9,aac:15,flac:17,wav:16,srt:19,vtt:18,ssa:20,ass:20,xml:21,ttml:21,h264:11,264:11,avc:11,h265:12,265:12,hevc:12,h266:13,266:13,vvc:13,mpeg:3,mpg:3,rtsp:6,rtmp:7},r={m3u8:4,m3u:4,mpd:5},n={copy:0,h264:27,avc:27,hevc:173,h265:173,vvc:196,h266:196,av1:225,vp9:167,vp8:139,mpeg4:12,theora:30,mpeg2video:2},o={copy:0,aac:86018,ac3:86019,eac3:86056,dts:86020,mp3:86017,opus:86076,flac:86028,speex:86051,vorbis:86021,pcm_alaw:65543,pcm_mulaw:65542},h={webvtt:94226,subrip:94225,ass:94230,ttml:94232,mov_text:94213,hdmv_pgs:94214,hdmv_text:94231,dvd:94208,dvb:94209,eia_608:94218},l={yuv420p:0,yuv422p:4,yuv444p:5,yuva420p:33,yuva422p:78,yuva444p:79,yuvj420p:12,yuvj422p:13,yuvj444p:14,yuv420p10le:62,yuv422p10le:64,yuv444p10le:68,yuva420p10le:87,yuva422p10le:89,yuva444p10le:91,yuv420p10be:61,yuv422p10be:63,yuv444p10be:67,yuva420p10be:86,yuva422p10be:88,yuva444p10be:90},d={u8:0,"u8-planar":5,s16:1,"s16-planar":6,s32:2,"s32-planar":7,s64:10,"s64-planar":11,float:3,"float-planar":8,double:4,"double-planar":9},u={flv:0,mp4:1,mov:1,ts:2,mpegts:2,mpeg:3,ivf:5,ogg:4,opus:4,m3u8:2,m3u:2,mpd:1,mp3:14,mkv:8,matroska:8,mka:8,webm:9,aac:15,flac:17,wav:16,raw_h264:11,raw_h265:12,raw_vvc:13,rtsp:6,rtmp:7},c={tv:1,pc:2},p={bt709:1,fcc:4,bt470bg:5,smpte170m:6,smpte240m:7,ycgco:8,gbr:0,bt2020nc:9},T={bt709:1,bt470m:4,bt470bg:5,smpte170m:6,smpte240m:7,smpte428:10,film:8,smpte431:11,smpte432:12,bt2020:9,"jedec-p22":22,ebu3213:22},m={bt709:1,gamma22:4,gamma28:5,smpte170m:6,smpte240m:7,srgb:13,xvycc:11,"bt2020-10":14,"bt2020-12":15,smpte2084:16,"arib-std-b67":18},E={Audio:1,Video:0,Subtitle:3,Attachment:4,Data:2},f={default:1,dub:2,original:4,comment:8,lyrics:16,karaoke:32,forced:64,"hearing impaired":128,"visual impaired":256,"clean effects":512,"attached pic":1024,"timed thumbnails":2048,captions:65536,descriptions:131072,metadata:262144,dependent:524288,"still image":1048576},y={mono:4,stereo:3,2.1:11,"3.0":7,"3.0(back)":259,"4.0":263,quad:51,"quad(side)":1539,3.1:15,"5.0":55,"5.0(side)":1543,4.1:271,5.1:63,"5.1(side)":1551,"6.0":1799,"6.0(front)":1731,"3.1.2":20495,hexagonal:311,6.1:1807,"6.1(back)":319,"6.1(front)":1739,"7.0":1591,"7.0(front)":1735,7.1:1599,"7.1(wide)":255,"7.1(wide-side)":1743,"5.1.2":20543,octagonal:1847,cube:184371,"5.1.4":184383,"7.1.2":22079,"7.1.4":185919,"7.2.3":34359825983,"9.1.4":186111,hexadecagonal:6442710839,downmix:1610612736,22.2:2164663779327}},13258:(t,e,i)=>{i.d(e,{A:()=>a});var s=i(134);class a{constructor(t=0){(0,s.A)(this,"rcon",[0,1,2,4,8,16,32,64,128,27,54]),(0,s.A)(this,"subMix",[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)]),(0,s.A)(this,"invSubMix",[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)]),(0,s.A)(this,"sBox",new Uint32Array(256)),(0,s.A)(this,"invSBox",new Uint32Array(256)),(0,s.A)(this,"key",new Uint32Array(0)),(0,s.A)(this,"ksRows",0),(0,s.A)(this,"keySize",0),(0,s.A)(this,"keySchedule",void 0),(0,s.A)(this,"invKeySchedule",void 0),this.initTable()}uint8ArrayToUint32Array_(t){const e=new DataView(t),i=new Uint32Array(4);for(let t=0;t<4;t++)i[t]=e.getUint32(4*t);return i}initTable(){const t=this.sBox,e=this.invSBox,i=this.subMix,s=i[0],a=i[1],r=i[2],n=i[3],o=this.invSubMix,h=o[0],l=o[1],d=o[2],u=o[3],c=new Uint32Array(256);let p=0,T=0,m=0;for(m=0;m<256;m++)c[m]=m<128?m<<1:m<<1^283;for(m=0;m<256;m++){let i=T^T<<1^T<<2^T<<3^T<<4;i=i>>>8^255&i^99,t[p]=i,e[i]=p;const o=c[p],m=c[o],E=c[m];let f=257*c[i]^16843008*i;s[p]=f<<24|f>>>8,a[p]=f<<16|f>>>16,r[p]=f<<8|f>>>24,n[p]=f,f=16843009*E^65537*m^257*o^16843008*p,h[i]=f<<24|f>>>8,l[i]=f<<16|f>>>16,d[i]=f<<8|f>>>24,u[i]=f,p?(p=o^c[c[c[E^o]]],T^=c[c[T]]):p=T=1}}async expandKey(t){const e=this.uint8ArrayToUint32Array_(t);if(this.key){let t=!0,i=0;for(;i<e.length&&t;)t=e[i]===this.key[i],i++;if(t)return}this.key=e;const i=this.keySize=this.key.length;if(4!==i&&6!==i&&8!==i)throw new Error("Invalid aes key size="+i);const s=this.ksRows=4*(i+6+1);let a,r;const n=this.keySchedule=new Uint32Array(s),o=this.invKeySchedule=new Uint32Array(s),h=this.sBox,l=this.rcon,d=this.invSubMix,u=d[0],c=d[1],p=d[2],T=d[3];let m,E;for(a=0;a<s;a++)a<i?m=n[a]=e[a]:(E=m,a%i==0?(E=E<<8|E>>>24,E=h[E>>>24]<<24|h[E>>>16&255]<<16|h[E>>>8&255]<<8|h[255&E],E^=l[a/i|0]<<24):i>6&&a%i==4&&(E=h[E>>>24]<<24|h[E>>>16&255]<<16|h[E>>>8&255]<<8|h[255&E]),n[a]=m=(n[a-i]^E)>>>0);for(r=0;r<s;r++)a=s-r,E=3&r?n[a]:n[a-4],o[r]=r<4||a<=4?E:u[h[E>>>24]]^c[h[E>>>16&255]]^p[h[E>>>8&255]]^T[h[255&E]],o[r]=o[r]>>>0}networkToHostOrderSwap(t){return t<<24|(65280&t)<<8|(16711680&t)>>8|t>>>24}async decrypt(t,e){const i=this.keySize+6,s=this.invKeySchedule,a=this.invSBox,r=this.invSubMix,n=r[0],o=r[1],h=r[2],l=r[3],d=this.uint8ArrayToUint32Array_(e);let u=d[0],c=d[1],p=d[2],T=d[3];const m=new Int32Array(t.buffer).subarray(t.byteOffset>>>2,(t.byteOffset>>>2)+(t.length>>>2)),E=new Int32Array(m.length);let f,y,A,g,v,I,S,X,b,N,R,P,D,L;const O=this.networkToHostOrderSwap;let w=0;for(;w<m.length;){for(b=O(m[w]),N=O(m[w+1]),R=O(m[w+2]),P=O(m[w+3]),v=b^s[0],I=P^s[1],S=R^s[2],X=N^s[3],D=4,L=1;L<i;L++)f=n[v>>>24]^o[I>>16&255]^h[S>>8&255]^l[255&X]^s[D],y=n[I>>>24]^o[S>>16&255]^h[X>>8&255]^l[255&v]^s[D+1],A=n[S>>>24]^o[X>>16&255]^h[v>>8&255]^l[255&I]^s[D+2],g=n[X>>>24]^o[v>>16&255]^h[I>>8&255]^l[255&S]^s[D+3],v=f,I=y,S=A,X=g,D+=4;f=a[v>>>24]<<24^a[I>>16&255]<<16^a[S>>8&255]<<8^a[255&X]^s[D],y=a[I>>>24]<<24^a[S>>16&255]<<16^a[X>>8&255]<<8^a[255&v]^s[D+1],A=a[S>>>24]<<24^a[X>>16&255]<<16^a[v>>8&255]<<8^a[255&I]^s[D+2],g=a[X>>>24]<<24^a[v>>16&255]<<16^a[I>>8&255]<<8^a[255&S]^s[D+3],E[w]=O(f^u),E[w+1]=O(g^c),E[w+2]=O(A^p),E[w+3]=O(y^T),u=b,c=N,p=R,T=P,w+=4}return E.buffer}}},51678:(t,e,i)=>{i.d(e,{A:()=>a});var s=i(134);class a{constructor(t=0){(0,s.A)(this,"subtle",void 0),(0,s.A)(this,"key",void 0),(0,s.A)(this,"mode",void 0),(0,s.A)(this,"keyBuffer",void 0),this.mode=t,this.subtle=crypto.subtle||crypto.webkitSubtle}getSubtleAlgoName(){switch(this.mode){case 0:return"AES-CBC";case 1:return"AES-CTR"}}async expandKey(t){let e=new Uint8Array(t);if(this.keyBuffer){let t=!0,i=0;for(;i<e.length&&t;)t=e[i]===this.keyBuffer[i],i++;if(t)return}this.keyBuffer=e,this.key=await this.subtle.importKey("raw",t,{name:this.getSubtleAlgoName()},!1,["encrypt","decrypt"])}async encryptPadding(t,e){return new Uint8Array(await crypto.subtle.encrypt({name:"AES-CBC",iv:e},this.key,t))}async decrypt(t,e){switch(this.mode){case 0:return this.subtle.decrypt({name:"AES-CBC",iv:e},this.key,t);case 1:return this.subtle.decrypt({name:"AES-CTR",counter:e,length:64},this.key,t)}}static isSupport(){return"object"==typeof(crypto.subtle||crypto.webkitSubtle)}}},6498:(t,e,i)=>{i(67672),i(72739)},8507:(t,e,i)=>{function s(t){const e=t,i=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],s=/:\/\/([^\/@]*@?)\[(\S+)\]/;let a="";s.test(t)&&(t=t.replace(s,((t,e,i)=>(a=i,`://${e||""}a.b`))));const r={},n=/^(?:(?![^:@\/]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@\/]*)(?::([^:@\/]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(t);let o=14;for(;o--;){var h;r[i[o]]=null!==(h=n[o])&&void 0!==h?h:""}return a&&(r.host=a,r.source=e,r.authority=a+(r.port?":"+r.port:"")),{protocol:r.protocol,file:r.file,host:r.host,port:r.port,user:r.user,password:r.password,origin:`${r.protocol}://${r.authority}`,pathname:r.path,search:`?${r.query}`,hash:r.anchor?`#${r.anchor}`:""}}i.d(e,{ll:()=>u,qg:()=>s}),i(73146),i(67672),i(6498),i(72739),i(95335);const a=/(?:\/|^)\.(?=\/)/g,r=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,n=/^(?=([^\/?#]*))\1([^]*)$/,o=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/;function h(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}function l(t){const e=o.exec(t);return e?{scheme:e[1]||"",netLoc:e[2]||"",path:e[3]||"",params:e[4]||"",query:e[5]||"",fragment:e[6]||""}:null}function d(t){for(t=t.split("").reverse().join("").replace(a,"");t.length!==(t=t.replace(r,"")).length;);return t.split("").reverse().join("")}function u(t,e,i){if(i=i||{},t=t.trim(),!(e=e.trim())){if(!i.alwaysNormalize)return t;let e=l(t);if(!e)throw new Error("Error trying to parse base URL.");return e.path=d(e.path),h(e)}let s=l(e);if(!s)throw new Error("Error trying to parse relative URL.");if(s.scheme)return i.alwaysNormalize?(s.path=d(s.path),h(s)):e;let a=l(t);if(!a)throw new Error("Error trying to parse base URL.");if(!a.netLoc&&a.path&&"/"!==a.path[0]){let t=n.exec(a.path);a.netLoc=t[1],a.path=t[2]}a.netLoc&&!a.path&&(a.path="/");const r={scheme:a.scheme,netLoc:s.netLoc,path:null,params:s.params,query:s.query,fragment:s.fragment};if(!s.netLoc&&(r.netLoc=a.netLoc,"/"!==s.path[0]))if(s.path){let t=a.path,e=t.substring(0,t.lastIndexOf("/")+1)+s.path;r.path=d(e)}else r.path=a.path,s.params||(r.params=a.params,s.query||(r.query=a.query));return null===r.path&&(r.path=i.alwaysNormalize?d(s.path):s.path),h(r)}},85079:(t,e,i)=>{var s=i(46438),a=s.JSON||(s.JSON={stringify:JSON.stringify});t.exports=function(t){return a.stringify.apply(a,arguments)}},63342:(t,e,i)=>{i(5882),t.exports=i(46438).Number.isInteger},11837:(t,e,i)=>{i(21489),t.exports=i(46438).Number.isNaN},19737:(t,e,i)=>{i(56477),t.exports=i(46438).Number.parseFloat},58886:(t,e,i)=>{i(15706),t.exports=i(46438).Number.parseInt},25194:(t,e,i)=>{var s=i(24401),a=Math.floor;t.exports=function(t){return!s(t)&&isFinite(t)&&a(t)===t}},5882:(t,e,i)=>{var s=i(88535);s(s.S,"Number",{isInteger:i(25194)})},21489:(t,e,i)=>{var s=i(88535);s(s.S,"Number",{isNaN:function(t){return t!=t}})},56477:(t,e,i)=>{var s=i(88535),a=i(49709);s(s.S+s.F*(Number.parseFloat!=a),"Number",{parseFloat:a})},15706:(t,e,i)=>{var s=i(88535),a=i(15722);s(s.S+s.F*(Number.parseInt!=a),"Number",{parseInt:a})},73146:(t,e,i)=>{t.exports=i(85079)},43929:(t,e,i)=>{t.exports=i(63342)},7210:(t,e,i)=>{t.exports=i(11837)},99704:(t,e,i)=>{t.exports=i(19737)},17735:(t,e,i)=>{t.exports=i(58886)}}]);
1
+ (self.webpackChunklibmedia=self.webpackChunklibmedia||[]).push([[433],{70509:(t,e,i)=>{i.d(e,{A:()=>a});var s=i(134);class a{constructor(){(0,s.A)(this,"onFlush",void 0)}}},97801:(t,e,i)=>{i.d(e,{A:()=>p});var s=i(134),a=i(70509),r=i(13258),n=i(51678),o=i(13724),h=i(4624);const l="src/avnetwork/bsp/aes/AESDecryptPipe.ts",d=16;let u=!0;const c=new Uint8Array(d).fill(d);class p extends a.A{constructor(t=0,e=1048576){super(),(0,s.A)(this,"buffer",void 0),(0,s.A)(this,"aesSoftDecryptor",void 0),(0,s.A)(this,"aesWebDecryptor",void 0),(0,s.A)(this,"aesTargetDecryptor",void 0),(0,s.A)(this,"pointer",void 0),(0,s.A)(this,"endPointer",void 0),(0,s.A)(this,"size",void 0),(0,s.A)(this,"ended",void 0),(0,s.A)(this,"iv",void 0),(0,s.A)(this,"key",void 0),(0,s.A)(this,"mode",void 0),(0,s.A)(this,"pos",void 0),this.mode=t,this.size=e,this.pointer=0,this.endPointer=0,this.pos=0,this.ended=!1,this.buffer=new Uint8Array(e),this.aesSoftDecryptor=new r.A(t),n.A.isSupport()&&u&&(this.aesWebDecryptor=new n.A(t)),this.aesTargetDecryptor=this.aesWebDecryptor||this.aesSoftDecryptor}remainingLength(){return this.endPointer-this.pointer}async expandKey(t,e){this.key=t,this.iv=e,this.aesWebDecryptor&&await this.aesWebDecryptor.expandKey(t),t.byteLength<=8&&this.aesSoftDecryptor.expandKey(t)}async flush_(t){for(;;){const e=await this.onFlush(t);if(-1048575!==e)return e;await new o.A(0)}}async flush(){if(this.size-this.remainingLength()<=0)return;this.pointer<this.endPointer?this.pointer&&(this.buffer.set(this.buffer.subarray(this.pointer,this.endPointer),0),this.endPointer=this.endPointer-this.pointer):this.endPointer=0,this.pointer=0;const t=await this.flush_(this.buffer.subarray(this.endPointer));if(t<0){if(-1048576===t)return void(this.ended=!0);h.h2(`AESPipe error, flush failed, ret: ${t}`,l,128)}this.endPointer+=t}removePadding(t){const e=t.length,i=e&&new DataView(t.buffer).getUint8(e-1);return i?t.subarray(0,e-i):t}async decryptCBC(t){let e,i=0;this.aesTargetDecryptor!==this.aesWebDecryptor||this.ended||(e=this.buffer.subarray(this.pointer+t,this.pointer+t+d).slice(),this.buffer.set((await this.aesWebDecryptor.encryptPadding(c,this.buffer.subarray(this.pointer+t-d,this.pointer+t))).subarray(0,d),this.pointer+t),i=d);try{const s=this.buffer.subarray(this.pointer,this.pointer+t+i),a=await this.aesTargetDecryptor.decrypt(s,this.iv);return this.iv=s.slice(s.length-d-i,s.length-i).buffer,e&&this.buffer.set(e,this.pointer+t),this.pointer+=t,this.pos+=t,new Uint8Array(a)}catch(i){if(this.aesTargetDecryptor===this.aesWebDecryptor&&this.key.byteLength<=8)return h.R8("web aes decrypt failed, try to use soft decryptor",l,178),e&&this.buffer.set(e,this.pointer+t),this.aesTargetDecryptor=this.aesSoftDecryptor,u=!1,this.decryptCBC(t);h.h2("aes decrypt failed",l,188)}}getCTRIv(){const t=new Uint8Array(this.iv).slice();let e=Math.floor(this.pos/d);for(let i=15;i>=0&&e>0;i--){const s=t[i]+(255&e);t[i]=255&s,e=(e>>>8)+(s>>8)}return t.buffer}async decryptCTR(t){try{const e=this.buffer.subarray(this.pointer,this.pointer+t),i=await this.aesTargetDecryptor.decrypt(e,this.getCTRIv());return this.pointer+=t,this.pos+=t,new Uint8Array(i)}catch(e){if(this.aesTargetDecryptor===this.aesWebDecryptor&&this.key.byteLength<=8)return h.R8("web aes decrypt failed, try to use soft decryptor",l,214),this.aesTargetDecryptor=this.aesSoftDecryptor,u=!1,this.decryptCTR(t);h.h2("aes decrypt failed",l,220)}}async read(t){for(;!this.ended&&this.remainingLength()<48;)await this.flush();if(0===this.remainingLength())return-1048576;if(0===this.mode){const e=Math.min(Math.floor((this.remainingLength()-(this.ended?0:32))/d)*d,t.length);let i=await this.decryptCBC(e);return this.ended&&this.aesTargetDecryptor===this.aesSoftDecryptor&&(i=this.removePadding(i)),t.set(i),i.length}{const e=this.ended?this.remainingLength():Math.min(Math.floor(this.remainingLength()/d)*d,t.length);let i=await this.decryptCTR(e);return t.set(i),i.length}}}},15433:(t,e,i)=>{i.r(e),i.d(e,{default:()=>b});var s=i(134),a=i(54001),r=i.n(a),n=i(80662),o=i.n(n),h=i(13724),l=i(82800),d=i(95335),u=i(8507),c=i(48182),p=i(77580),T=i(86932),m=i(4624),E=i(97801),f=i(67672),y=i(9705),A=i(51678),g=i(62751);const v="src/avnetwork/ioLoader/HlsIOLoader.ts";function I(t,e="GET"){var i,s,a;const r={method:"GET",headers:{},mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};return null!==(i=t.httpOptions)&&void 0!==i&&i.headers&&d.__(t.httpOptions.headers,((t,e)=>{r.headers[e]=t})),null!==(s=t.httpOptions)&&void 0!==s&&s.credentials&&(r.credentials=t.httpOptions.credentials),null!==(a=t.httpOptions)&&void 0!==a&&a.referrerPolicy&&(r.referrerPolicy=t.httpOptions.referrerPolicy),r}async function S(t,e,i,s){return new(r())(((a,r)=>{let n=0;!async function o(){try{const r=await fetch(t,{...I(e),signal:s}),d=await r.text(),u=(0,c.A)(d);if(i.isLive&&(!u.segments||u.segments.length<2)){var l;let t=5;null!==(l=u.segments)&&void 0!==l&&l.length&&(t=u.segments[0].duration*(2-u.segments.length)),m.R8(`wait for min buffer time, now segments: ${u.segments.length}`,v,92),await new h.A(t),n=0,o()}a(u)}catch(t){if("AbortError"===(null==t?void 0:t.name))return void a(null);if(n<i.retryCount)return n++,m.z3(`failed fetch m3u8 file, retry(${n}/3)`,v,106),await new h.A(i.retryInterval),o();m.z3("HLSLoader: exception, fetch slice error",v,111),r()}}()}))}class X{constructor(t,e,i,a){(0,s.A)(this,"options",void 0),(0,s.A)(this,"info",void 0),(0,s.A)(this,"mediaPlayList",void 0),(0,s.A)(this,"fetchedMap",void 0),(0,s.A)(this,"fetchedHistoryList",void 0),(0,s.A)(this,"mediaListUrl",void 0),(0,s.A)(this,"segmentIndex",void 0),(0,s.A)(this,"currentUri",void 0),(0,s.A)(this,"loader",void 0),(0,s.A)(this,"keyMap",void 0),(0,s.A)(this,"currentIV",void 0),(0,s.A)(this,"currentKey",void 0),(0,s.A)(this,"aesDecryptPipe",void 0),(0,s.A)(this,"initLoaded",void 0),(0,s.A)(this,"isInitLoader",void 0),(0,s.A)(this,"minBuffer",void 0),(0,s.A)(this,"pendingBuffer",void 0),(0,s.A)(this,"magicAdded",void 0),(0,s.A)(this,"sleep",void 0),(0,s.A)(this,"aborted",void 0),(0,s.A)(this,"signal",void 0),this.options=t,this.info=e,this.segmentIndex=0,this.fetchedMap=new(o()),this.fetchedHistoryList=[],this.keyMap=new(o()),this.aborted=!1,i&&a&&this.setMediaPlayList(i,a)}setMediaPlayList(t,e){if(this.options.isLive){this.fetchedMap.clear(),this.fetchedHistoryList.length=0,this.segmentIndex=0;const t=e.segments.find((t=>t.uri===this.currentUri));if(t)for(e.segments.forEach(((e,i)=>{e.mediaSequenceNumber===t.mediaSequenceNumber+1?this.segmentIndex=i:e.mediaSequenceNumber<=t.mediaSequenceNumber&&(this.fetchedMap.set(e.uri,!0),this.fetchedHistoryList.push(e.uri))}));this.fetchedHistoryList.length>=10;)this.fetchedMap.delete(this.fetchedHistoryList.shift())}if(this.mediaListUrl=t,this.mediaPlayList=e,this.minBuffer=this.mediaPlayList.duration||0,this.mediaPlayList.endlist&&(this.options.isLive=!1),this.initLoaded=!0,this.mediaPlayList.segments.length&&this.mediaPlayList.segments[0].map&&(this.initLoaded=!1),this.mediaPlayList.lowLatencyCompatibility){const t=this.mediaPlayList.lowLatencyCompatibility.partHoldBack||this.mediaPlayList.lowLatencyCompatibility.holdBack||this.minBuffer;let e=0,s=!1,a=0;for(let r=this.mediaPlayList.segments.length-1;r>=0;r--){var i;const n=this.mediaPlayList.segments[r];if(null!==(i=n.parts)&&void 0!==i&&i.length){if(!n.uri)continue;for(let i=n.parts.length-1;i>=0;i--){const o=n.parts[i];if(!o.hint&&(e+=o.duration,o.independent&&(s=!0),e>=t&&s)){a=r;break}}if(e>=t&&s)break}else if(e+=n.duration,s=!0,e>=t&&s){a=r;break}}this.fetchedMap.clear(),this.fetchedHistoryList.length=0;for(let t=0;t<a;t++){const e=this.mediaPlayList.segments[t];this.fetchedMap.set(e.uri,!0),this.fetchedHistoryList.push(e.uri)}for(;this.fetchedHistoryList.length>=10;)this.fetchedMap.delete(this.fetchedHistoryList.shift());this.segmentIndex=a,this.minBuffer=e}}getMediaListUrl(){return this.mediaListUrl}async checkNeedDecrypt(t,e,i){if(!t)return void(this.aesDecryptPipe=null);if("aes-128"!==t.method.toLocaleLowerCase()&&"aes-128-ctr"!==t.method.toLocaleLowerCase()&&("aes-256"!==t.method.toLocaleLowerCase()&&"aes-256-ctr"!==t.method.toLocaleLowerCase()||!A.A.isSupport())){if("mp4"===e.split(".").pop())return void(this.aesDecryptPipe=null);m.h2(`m3u8 ts not support EXT-X-KEY METHOD ${t.method}`,v,284)}const s=t.uri;if(this.keyMap.has(s)?this.currentKey=this.keyMap.get(s):(this.currentKey=await(await fetch((0,u.ll)(this.mediaListUrl,s),I(this.info))).arrayBuffer(),this.keyMap.set(s,this.currentKey)),t.iv)this.currentIV=t.iv.buffer;else{const t=new Uint8Array(16);new DataView(t.buffer).setUint32(12,i,!1),this.currentIV=t.buffer}this.aesDecryptPipe=new E.A(t.method.toLocaleLowerCase().indexOf("ctr")>0?1:0),this.aesDecryptPipe.onFlush=async t=>this.loader.read(t),await this.aesDecryptPipe.expandKey(this.currentKey,this.currentIV)}handleSlice(t,e){const i=this.loader.getUrl().split(".").pop();if("mp3"!==i&&!this.magicAdded&&73===e[0]&&68===e[1]&&51===e[2]){var s;const a=null!==(s=g.HR[i])&&void 0!==s?s:-1;return-1===a?t:(t+6>e.length&&(this.pendingBuffer=e.slice(t-6)),e.set(e.slice(0,t-6),6),e[0]=76,e[1]=73,e[2]=77,e[3]=65,e[4]=a>>>8&255,e[5]=255&a,this.magicAdded=!0,this.pendingBuffer?t:t+6)}return t}async read(t){if(this.pendingBuffer){let e=this.pendingBuffer.length;return t.set(this.pendingBuffer),this.pendingBuffer=null,e}let e=0;if(this.loader){if(e=this.aesDecryptPipe?await this.aesDecryptPipe.read(t):await this.loader.read(t),-1048576!==e||this.aborted)return e;if(this.isInitLoader)this.initLoaded=!0;else if(this.options.isLive)this.fetchedMap.set(this.currentUri,!0),10===this.fetchedHistoryList.length&&this.fetchedMap.delete(this.fetchedHistoryList.shift()),this.fetchedHistoryList.push(this.currentUri),this.segmentIndex++;else if(this.segmentIndex++,this.segmentIndex>=this.mediaPlayList.segments.length)return-1048576;this.loader=null}if(this.options.isLive){var i,s;const e=this.mediaPlayList.segments.filter((t=>t.uri&&!this.fetchedMap.get(t.uri)));if(!e.length){var a;if(this.mediaPlayList.endlist)return-1048576;const e=(this.minBuffer-((0,T.A)()-this.mediaPlayList.timestamp)/1e3)/2;return e>0&&(this.sleep=new h.A(e),await this.sleep,this.sleep=null,this.aborted)?-1048576:("function"==typeof AbortController&&(this.signal=new AbortController),this.mediaPlayList=await S(this.mediaListUrl,this.info,this.options,null===(a=this.signal)||void 0===a?void 0:a.signal),this.signal=null,this.aborted?-1048576:this.read(t))}this.isInitLoader=!(null===(i=e[0].map)||void 0===i||!i.uri||this.initLoaded),this.currentUri=e[0].uri,this.isInitLoader?null!==(s=e[0].map)&&void 0!==s&&s.key&&await this.checkNeedDecrypt(e[0].map.key,e[0].map.uri,this.segmentIndex+(this.mediaPlayList.mediaSequenceBase||0)):await this.checkNeedDecrypt(e[0].key,this.currentUri,this.segmentIndex+(this.mediaPlayList.mediaSequenceBase||0)),this.loader=new p.A(d.X$({},this.options,{disableSegment:!0,loop:!1}));const r=(0,u.ll)(this.mediaListUrl,this.isInitLoader?e[0].map.uri:this.currentUri),n={from:0,to:-1},o=this.isInitLoader?e[0].map.byterange:e[0].byterange;o&&(n.from=o.offset,n.to=o.offset+o.length),await this.loader.open(d.X$({},this.info,{url:r}),n);const l=await(this.aesDecryptPipe?this.aesDecryptPipe.read(t):this.loader.read(t));return l>10?this.handleSlice(l,t):l}{var r,n;this.loader=new p.A(d.X$({},this.options,{disableSegment:!0,loop:!1}));let e=this.mediaPlayList.segments[this.segmentIndex];for(;e&&!e.uri;)e=this.mediaPlayList.segments[++this.segmentIndex];this.isInitLoader=!(null===(r=e.map)||void 0===r||!r.uri||this.initLoaded),this.isInitLoader?null!==(n=e.map)&&void 0!==n&&n.key&&await this.checkNeedDecrypt(e.map.key,e.map.uri,this.segmentIndex+(this.mediaPlayList.mediaSequenceBase||0)):await this.checkNeedDecrypt(e.key,e.uri,this.segmentIndex+(this.mediaPlayList.mediaSequenceBase||0));const i=(0,u.ll)(this.mediaListUrl,this.isInitLoader?e.map.uri:e.uri),s={from:0,to:-1},a=this.isInitLoader?e.map.byterange:e.byterange;a&&(s.from=a.offset,s.to=a.offset+a.length),await this.loader.open(d.X$({},this.info,{url:i}),s);const o=await(this.aesDecryptPipe?this.aesDecryptPipe.read(t):this.loader.read(t));return o>10?this.handleSlice(o,t):o}}async seek(t){this.loader&&(await this.loader.abort(),this.loader=null);let e=0,i=Number(t),s=-1;for(let t=0;t<this.mediaPlayList.segments.length;t++)if(f.ai(this.mediaPlayList.segments[t].duration)&&(e+=this.mediaPlayList.segments[t].duration,1e3*e>=i)){s=t;break}return-1===s&&(s=this.mediaPlayList.segments.length-1),this.segmentIndex=s,this.aborted=!1,0}abortSleep(){this.aborted=!0,this.loader&&this.loader.abortSleep(),this.sleep&&(this.sleep.stop(),this.sleep=null)}async abort(){this.abortSleep(),this.signal&&(this.signal.abort(),this.signal=null),this.loader&&(await this.loader.abort(),this.loader=null)}getMinBuffer(){return this.minBuffer}getDuration(){return this.mediaPlayList.duration}}class b extends l.A{constructor(...t){super(...t),(0,s.A)(this,"info",void 0),(0,s.A)(this,"masterPlaylist",void 0),(0,s.A)(this,"mediaPlayListIndex",void 0),(0,s.A)(this,"mainLoader",void 0),(0,s.A)(this,"loaders",void 0),(0,s.A)(this,"audioSelectedIndex",void 0),(0,s.A)(this,"subtitleSelectedIndex",void 0),(0,s.A)(this,"sleep",void 0),(0,s.A)(this,"aborted",void 0)}async fetchMasterPlayList(){try{const e=await fetch(this.info.url,I(this.info)),i=await e.text(),s=(0,c.A)(i);if(s.isMasterPlaylist)this.masterPlaylist=s;else{const e=s;if(this.options.isLive&&(!e.segments||e.segments.length<2)){var t;let i=5;return null!==(t=e.segments)&&void 0!==t&&t.length&&(i=e.segments[0].duration*(2-e.segments.length)),m.R8(`wait for min buffer time, now segments: ${e.segments.length}`,v,582),await new h.A(i),this.fetchMasterPlayList()}this.mainLoader=new X(this.options,this.info,this.info.url,e),this.loaders.set(0,this.mainLoader)}return s}catch(t){if(this.retryCount<this.options.retryCount)return this.retryCount++,m.z3(`failed fetch m3u8 file, retry(${this.retryCount}/3)`,v,599),this.sleep=new h.A(3),await this.sleep,this.sleep=null,this.aborted&&m.h2("HLSLoader: exception, fetch abort",v,604),this.fetchMasterPlayList();this.status=3,m.h2("HLSLoader: exception, fetch slice error",v,610)}}buildUrl(t){return/^https?/.test(t)||(t=u.ll(this.info.url,t)),t}async createLoader(){if(this.masterPlaylist){const t=this.masterPlaylist.variants[this.mediaPlayListIndex];if(t||m.h2("no media playlist",v,626),t.audio.length){const e=this.buildUrl(t.audio[this.audioSelectedIndex].uri);this.loaders.set(1,new X(this.options,this.info,e,await S(e,this.info,this.options)))}if(t.subtitles.length){const e=this.buildUrl(t.subtitles[this.subtitleSelectedIndex].uri);this.loaders.set(3,new X(this.options,this.info,e,await S(e,this.info,this.options)))}const e=this.buildUrl(t.uri);this.mainLoader=new X(this.options,this.info,e,await S(e,this.info,this.options)),this.loaders.set(0,this.mainLoader)}}async open(t){return 2===this.status?0:0!==this.status?y.lh:(this.info=t,this.mediaPlayListIndex=0,this.audioSelectedIndex=0,this.subtitleSelectedIndex=0,this.loaders=new(o()),this.status=1,this.retryCount=0,this.aborted=!1,await this.fetchMasterPlayList(),!this.loaders.size&&this.masterPlaylist&&await this.createLoader(),this.status=2,0)}async read(t,e){if(!e)return y.UY;const i=await this.loaders.get(e.mediaType).read(t);return i<0&&-1048575!==i&&(this.status=-1048576===i?4:3),i}async seek(t,e){return e?(await this.loaders.get(e.mediaType).seek(t),4===this.status&&(this.status=2),0):y.UY}async size(){return BigInt(0)}async abort(){for(let t of this.loaders)await t[1].abort();this.aborted=!0,this.sleep&&(this.sleep.stop(),this.sleep=null)}async stop(){await this.abort(),this.status=0}getDuration(){var t,e;return null!==(t=null===(e=this.mainLoader)||void 0===e?void 0:e.getDuration())&&void 0!==t?t:0}hasVideo(){return this.masterPlaylist?this.masterPlaylist.variants.length>0:!!this.mainLoader}hasAudio(){if(this.masterPlaylist)return this.masterPlaylist.variants[this.mediaPlayListIndex].audio.length>0}hasSubtitle(){if(this.masterPlaylist)return this.masterPlaylist.variants[this.mediaPlayListIndex].subtitles.length>0}getVideoList(){var t,e;return{list:null!==(t=null===(e=this.masterPlaylist)||void 0===e?void 0:e.variants.map((t=>{var e,i,s,a,r;return{width:null!==(e=null===(i=t.resolution)||void 0===i?void 0:i.width)&&void 0!==e?e:0,height:null!==(s=null===(a=t.resolution)||void 0===a?void 0:a.height)&&void 0!==s?s:0,frameRate:null!==(r=t.frameRate)&&void 0!==r?r:0,codec:t.codecs,bandwidth:t.bandwidth}})))&&void 0!==t?t:[],selectedIndex:this.mediaPlayListIndex||0}}getAudioList(){return this.masterPlaylist&&this.hasAudio()?{list:this.masterPlaylist.variants[this.mediaPlayListIndex].audio.map((t=>({lang:t.language,codec:t.name}))),selectedIndex:this.audioSelectedIndex}:{list:[],selectedIndex:0}}getSubtitleList(){return this.masterPlaylist&&this.hasSubtitle()?{list:this.masterPlaylist.variants[this.mediaPlayListIndex].subtitles.map((t=>({lang:t.language,codec:t.name}))),selectedIndex:this.subtitleSelectedIndex}:{list:[],selectedIndex:0}}selectVideo(t){if(this.masterPlaylist){const e=this.masterPlaylist.variants[t];if(e){const i=this.buildUrl(e.uri);if(S(i,this.info,this.options).then((e=>{this.loaders.get(0).setMediaPlayList(i,e),this.mediaPlayListIndex=t})),1===e.audio.length&&this.loaders.has(1)&&this.buildUrl(e.audio[0].uri)!==this.loaders.get(1).getMediaListUrl()){const t=this.buildUrl(e.audio[0].uri);S(t,this.info,this.options).then((e=>{this.loaders.get(1).setMediaPlayList(t,e)}))}if(1===e.subtitles.length&&this.loaders.has(3)&&this.buildUrl(e.subtitles[0].uri)!==this.loaders.get(3).getMediaListUrl()){const t=this.buildUrl(e.subtitles[0].uri);S(t,this.info,this.options).then((e=>{this.loaders.get(3).setMediaPlayList(t,e)}))}}}}selectAudio(t){if(this.masterPlaylist){const e=this.masterPlaylist.variants[this.mediaPlayListIndex];if(null!=e&&e.audio[t]){const i=this.buildUrl(e.audio[t].uri);S(i,this.info,this.options).then((e=>{this.loaders.get(1).setMediaPlayList(i,e),this.audioSelectedIndex=t}))}}}selectSubtitle(t){if(this.masterPlaylist){const e=this.masterPlaylist.variants[this.mediaPlayListIndex];if(null!=e&&e.subtitles[t]){const i=this.buildUrl(e.subtitles[t].uri);S(i,this.info,this.options).then((e=>{this.loaders.get(3).setMediaPlayList(i,e),this.subtitleSelectedIndex=t}))}}}getMinBuffer(){var t,e;return null!==(t=null===(e=this.mainLoader)||void 0===e?void 0:e.getMinBuffer())&&void 0!==t?t:0}}},48182:(t,e,i)=>{i.d(e,{A:()=>w});var s=i(7210),a=i.n(s),r=i(43929),n=i.n(r),o=i(69736),h=i.n(o),l=i(80662),d=i.n(l),u=i(67756),c=i(64608),p=i(4624);const T="src/avprotocol/m3u8/parser.ts";function m(t){return u.Bq(t,'"')}function E(t){const e=u.gI(t,",");return{duration:u.Ro(e[0]),title:decodeURIComponent(escape(e[1]))}}function f(t){const e=u.gI(t,"@");return{length:u.Ro(e[0]),offset:e[1]?u.Ro(e[1]):-1}}function y(t){const e=u.gI(t,"x");return{width:u.Ro(e[0]),height:u.Ro(e[1])}}function A(t){const e="ALLOWED-CPC: Each entry must consit of KEYFORMAT and Content Protection Configuration",i=t.split(",");0===i.length&&p.z3(e,T,102);const s=[];for(const t of i){const[i,a]=u.gI(t,":");i&&a?s.push({format:i,cpcList:a.split("/")}):p.z3(e,T,108)}return s}function g(t){const e=u.m2(t);return 16!==e.length&&p.z3("IV must be a 128-bit unsigned integer",T,119),e}function v(t,e){e.IV&&t.compatibleVersion<2&&(t.compatibleVersion=2),(e.KEYFORMAT||e.KEYFORMATVERSIONS)&&t.compatibleVersion<5&&(t.compatibleVersion=5)}function I(t){const e={};for(const s of u.HG(t)){const[t,a]=u.gI(s,"="),r=m(a);switch(t){case"URI":e[t]=r;break;case"START-DATE":case"END-DATE":e[t]=new Date(r);break;case"IV":e[t]=g(r);break;case"BYTERANGE":e[t]=f(r);break;case"RESOLUTION":e[t]=y(r);break;case"ALLOWED-CPC":e[t]=A(r);break;case"END-ON-NEXT":case"DEFAULT":case"AUTOSELECT":case"FORCED":case"PRECISE":case"CAN-BLOCK-RELOAD":case"INDEPENDENT":case"GAP":e[t]="YES"===r;break;case"DURATION":case"PLANNED-DURATION":case"BANDWIDTH":case"AVERAGE-BANDWIDTH":case"FRAME-RATE":case"TIME-OFFSET":case"CAN-SKIP-UNTIL":case"HOLD-BACK":case"PART-HOLD-BACK":case"PART-TARGET":case"BYTERANGE-START":case"BYTERANGE-LENGTH":case"LAST-MSN":case"LAST-PART":case"SKIPPED-SEGMENTS":case"SCORE":case"PROGRAM-ID":e[t]=u.Ro(r);break;default:t.startsWith("SCTE35-")?e[t]=u.m2(r):t.startsWith("X-")?e[t]=(i=a).startsWith('"')?m(i):i.startsWith("0x")||i.startsWith("0X")?u.m2(i):u.Ro(i):("VIDEO-RANGE"===t&&"SDR"!==r&&"HLG"!==r&&"PQ"!==r&&p.h2(`VIDEO-RANGE: unknown value "${r}"`,T,206),e[t]=r)}}var i;return e}function S(t,e,i){const s=function({attributes:t}){return new c.ru({type:t.TYPE,uri:t.URI,groupId:t["GROUP-ID"],language:t.LANGUAGE,assocLanguage:t["ASSOC-LANGUAGE"],name:t.NAME,isDefault:t.DEFAULT,autoselect:t.AUTOSELECT,forced:t.FORCED,instreamId:t["INSTREAM-ID"],characteristics:t.CHARACTERISTICS,channels:t.CHANNELS})}(e),a=t[u.Th(i)],r=function(t,e){let i=!1;for(const s of t){if(s.name===e.name)return"All EXT-X-MEDIA tags in the same Group MUST have different NAME attributes.";s.isDefault&&(i=!0)}return i&&e.isDefault?"EXT-X-MEDIA A Group MUST NOT have more than one member with a DEFAULT attribute of YES.":""}(a,s);r&&p.h2(r,T,315),a.push(s),s.isDefault&&(t.currentRenditions[u.Th(i)]=a.length-1)}function X(t,e,i,s,a){const r=new c.KT({uri:i,bandwidth:e.BANDWIDTH,averageBandwidth:e["AVERAGE-BANDWIDTH"],score:e.SCORE,codecs:e.CODECS,resolution:e.RESOLUTION,frameRate:e["FRAME-RATE"],hdcpLevel:e["HDCP-LEVEL"],allowedCpc:e["ALLOWED-CPC"],videoRange:e["VIDEO-RANGE"],stableVariantId:e["STABLE-VARIANT-ID"],programId:e["PROGRAM-ID"]});for(const i of t)if("EXT-X-MEDIA"===i.name){const t=i.attributes,s=t.TYPE;if(s&&t["GROUP-ID"]||p.h2("EXT-X-MEDIA TYPE attribute is REQUIRED.",T,355),e[s]===t["GROUP-ID"]&&(S(r,i,s),"CLOSED-CAPTIONS"===s))for(const{instreamId:t}of r.closedCaptions)if(t&&t.startsWith("SERVICE")&&a.compatibleVersion<7){a.compatibleVersion=7;break}}return function(t,e,i){for(const s of["AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS"])"CLOSED-CAPTIONS"===s&&"NONE"===t[s]?(i.isClosedCaptionsNone=!0,e.closedCaptions=[]):t[s]&&!e[u.Th(s)].some((e=>e.groupId===t[s]))&&p.h2(`${s} attribute MUST match the value of the GROUP-ID attribute of an EXT-X-MEDIA tag whose TYPE attribute is ${s}.`,T,330)}(e,r,a),r.isIFrameOnly=s,r}function b(t,e){if(t.method!==e.method)return!1;if(t.uri!==e.uri)return!1;if(t.iv){if(!e.iv)return!1;if(t.iv.length!==e.iv.length)return!1;for(let i=0;i<t.iv.length;i++)if(t.iv[i]!==e.iv[i])return!1}else if(e.iv)return!1;return t.format===e.format&&t.formatVersion===e.formatVersion}function N(t,e,i,s,a,r,o){const l=new c.Y4({uri:e,mediaSequenceNumber:a,discontinuitySequence:r});let d=!1,u=!1;for(let e=i;e<=s;e++){const{name:i,value:s,attributes:a}=t[e];if("EXTINF"===i)!n()(s.duration)&&o.compatibleVersion<3&&(o.compatibleVersion=3),Math.round(s.duration)>o.targetDuration&&p.h2("EXTINF duration, when rounded to the nearest integer, MUST be less than or equal to the target duration",T,517),l.duration=s.duration,l.title=s.title;else if("EXT-X-BYTERANGE"===i)o.compatibleVersion<4&&(o.compatibleVersion=4),l.byterange=s;else if("EXT-X-DISCONTINUITY"===i)l.parts.length>0&&p.h2("EXT-X-DISCONTINUITY must appear before the first EXT-X-PART tag of the Parent Segment.",T,530),l.discontinuity=!0;else if("EXT-X-KEY"===i)l.parts.length>0&&p.h2("EXT-X-KEY must appear before the first EXT-X-PART tag of the Parent Segment.",T,536),"NONE"!==a.METHOD?(v(o,a),l.key=new c.Uz({method:a.METHOD,uri:a.URI,iv:a.IV,format:a.KEYFORMAT,formatVersion:a.KEYFORMATVERSIONS})):l.key=null;else if("EXT-X-MAP"===i)l.parts.length>0&&p.h2("EXT-X-MAP must appear before the first EXT-X-PART tag of the Parent Segment.",T,555),o.compatibleVersion<5&&(o.compatibleVersion=5),o.hasMap=!0,l.map=new c.qP({uri:a.URI,byterange:a.BYTERANGE,key:l.key});else if("EXT-X-PROGRAM-DATE-TIME"===i)l.programDateTime=s;else if("EXT-X-DATERANGE"===i){const t={};for(const e of h()(a))(e.startsWith("SCTE35-")||e.startsWith("X-"))&&(t[e]=a[e]);l.dateRange=new c.ad({id:a.ID,classId:a.CLASS,start:a["START-DATE"],end:a["END-DATE"],duration:a.DURATION,plannedDuration:a["PLANNED-DURATION"],endOnNext:a["END-ON-NEXT"],attributes:t})}else if("EXT-X-CUE-OUT"===i)l.markers.push(new c.xC({type:"OUT",duration:a&&a.DURATION||s}));else if("EXT-X-CUE-IN"===i)l.markers.push(new c.xC({type:"IN"}));else if("EXT-X-CUE-OUT-CONT"===i||"EXT-X-CUE"===i||"EXT-OATCLS-SCTE35"===i||"EXT-X-ASSET"===i||"EXT-X-SCTE35"===i)l.markers.push(new c.xC({type:"RAW",tagName:i,value:s}));else if("EXT-X-PRELOAD-HINT"!==i||a.TYPE)if("EXT-X-PRELOAD-HINT"===i&&"PART"===a.TYPE&&u)p.h2("Servers should not add more than one EXT-X-PRELOAD-HINT tag with the same TYPE attribute to a Playlist.",T,616);else if("EXT-X-PART"!==i&&"EXT-X-PRELOAD-HINT"!==i||a.URI){if("EXT-X-PRELOAD-HINT"===i&&"MAP"===a.TYPE)d&&p.h2("Servers should not add more than one EXT-X-PRELOAD-HINT tag with the same TYPE attribute to a Playlist.",T,623),d=!0,o.hasMap=!0,l.map=new c.qP({hint:!0,uri:a.URI,byterange:{length:a["BYTERANGE-LENGTH"],offset:a["BYTERANGE-START"]||0}});else if("EXT-X-PART"===i||"EXT-X-PRELOAD-HINT"===i&&"PART"===a.TYPE){"EXT-X-PART"!==i||a.DURATION||p.h2("EXT-X-PART: DURATION attribute is mandatory",T,635),"EXT-X-PRELOAD-HINT"===i&&(u=!0);const t=new c.nw({hint:"EXT-X-PRELOAD-HINT"===i,uri:a.URI,byterange:"EXT-X-PART"===i?a.BYTERANGE:{length:a["BYTERANGE-LENGTH"],offset:a["BYTERANGE-START"]||0},duration:a.DURATION,independent:a.INDEPENDENT,gap:a.GAP});l.parts.push(t)}}else p.h2("EXT-X-PART / EXT-X-PRELOAD-HINT: URI attribute is mandatory",T,619);else p.h2("EXT-X-PRELOAD-HINT: TYPE attribute is mandatory",T,613)}return l}function R(t,e,i,s,a,r,n){const o=new c.Vd({uri:e,mediaSequenceNumber:a,discontinuitySequence:r});for(let e=i;e<=s;e++){const{name:i,attributes:s}=t[e];"EXTINF"===i?p.h2("A prefetch segment must not be advertised with an EXTINF tag.",T,667):"EXT-X-DISCONTINUITY"===i?p.h2("A prefetch segment must not be advertised with an EXT-X-DISCONTINUITY tag.",T,670):"EXT-X-PREFETCH-DISCONTINUITY"===i?o.discontinuity=!0:"EXT-X-KEY"===i?"NONE"!==s.METHOD&&(v(n,s),o.key=new c.Uz({method:s.METHOD,uri:s.URI,iv:s.IV,format:s.KEYFORMAT,formatVersion:s.KEYFORMATVERSIONS})):"EXT-X-MAP"===i&&p.h2("Prefetch segments must not be advertised with an EXT-X-MAP tag.",T,688)}return o}function P(t,e,i,s,a){const{discontinuity:r,key:n,map:o,byterange:h,uri:l}=e;if(r&&(e.discontinuitySequence=i+1),n||(e.key=s),o||(e.map=a),h&&-1===h.offset){const{segments:e}=t;if(e.length>0){const t=e[e.length-1];t.byterange&&t.uri===l?h.offset=t.byterange.offset+t.byterange.length:p.h2("If offset of EXT-X-BYTERANGE is not present, a previous Media Segment MUST be a sub-range of the same media resource",T,912)}else p.h2("If offset of EXT-X-BYTERANGE is not present, a previous Media Segment MUST appear in the Playlist file",T,916)}return t.segments.push(e),[e.discontinuitySequence,e.key,e.map]}function D(t,e){const[i,s]=function(t){const e=t.indexOf(":");return-1===e?[t.slice(1).trim(),null]:[t.slice(1,e).trim(),t.slice(e+1).trim()]}(t),r=function(t){switch(t){case"EXTM3U":case"EXT-X-VERSION":return"Basic";case"EXTINF":case"EXT-X-BYTERANGE":case"EXT-X-DISCONTINUITY":case"EXT-X-PREFETCH-DISCONTINUITY":case"EXT-X-KEY":case"EXT-X-MAP":case"EXT-X-PROGRAM-DATE-TIME":case"EXT-X-DATERANGE":case"EXT-X-CUE-OUT":case"EXT-X-CUE-IN":case"EXT-X-CUE-OUT-CONT":case"EXT-X-CUE":case"EXT-OATCLS-SCTE35":case"EXT-X-ASSET":case"EXT-X-SCTE35":case"EXT-X-PART":case"EXT-X-PRELOAD-HINT":return"Segment";case"EXT-X-TARGETDURATION":case"EXT-X-MEDIA-SEQUENCE":case"EXT-X-DISCONTINUITY-SEQUENCE":case"EXT-X-ENDLIST":case"EXT-X-PLAYLIST-TYPE":case"EXT-X-I-FRAMES-ONLY":case"EXT-X-SERVER-CONTROL":case"EXT-X-PART-INF":case"EXT-X-PREFETCH":case"EXT-X-RENDITION-REPORT":case"EXT-X-SKIP":return"MediaPlaylist";case"EXT-X-MEDIA":case"EXT-X-STREAM-INF":case"EXT-X-I-FRAME-STREAM-INF":case"EXT-X-SESSION-DATA":case"EXT-X-SESSION-KEY":return"MasterPlaylist";case"EXT-X-INDEPENDENT-SEGMENTS":case"EXT-X-START":return"MediaorMasterPlaylist";default:return"Unknown"}}(i);if(function(t,e){if("Segment"===t||"MediaPlaylist"===t)return void 0===e.isMasterPlaylist?void(e.isMasterPlaylist=!1):void(e.isMasterPlaylist&&p.h2("The file contains both media and master playlist tags.",T,1023));if("MasterPlaylist"===t){if(void 0===e.isMasterPlaylist)return void(e.isMasterPlaylist=!0);!1===e.isMasterPlaylist&&p.h2("The file contains both media and master playlist tags.",T,1033)}}(r,e),"Unknown"===r)return null;"MediaPlaylist"===r&&"EXT-X-RENDITION-REPORT"!==i&&"EXT-X-PREFETCH"!==i&&(e.hash[i]&&p.h2("There MUST NOT be more than one Media Playlist tag of each type in any Media Playlist",T,1054),e.hash[i]=!0);const[n,o]=function(t,e){switch(t){case"EXTM3U":case"EXT-X-DISCONTINUITY":case"EXT-X-ENDLIST":case"EXT-X-I-FRAMES-ONLY":case"EXT-X-INDEPENDENT-SEGMENTS":case"EXT-X-CUE-IN":return[null,null];case"EXT-X-VERSION":case"EXT-X-TARGETDURATION":case"EXT-X-MEDIA-SEQUENCE":case"EXT-X-DISCONTINUITY-SEQUENCE":return[u.Ro(e),null];case"EXT-X-CUE-OUT":return a()(Number(e))?[null,I(e)]:[u.Ro(e),null];case"EXT-X-KEY":case"EXT-X-MAP":case"EXT-X-DATERANGE":case"EXT-X-MEDIA":case"EXT-X-STREAM-INF":case"EXT-X-I-FRAME-STREAM-INF":case"EXT-X-SESSION-DATA":case"EXT-X-SESSION-KEY":case"EXT-X-START":case"EXT-X-SERVER-CONTROL":case"EXT-X-PART-INF":case"EXT-X-PART":case"EXT-X-PRELOAD-HINT":case"EXT-X-RENDITION-REPORT":case"EXT-X-SKIP":return[null,I(e)];case"EXTINF":return[E(e),null];case"EXT-X-BYTERANGE":return[f(e),null];case"EXT-X-PROGRAM-DATE-TIME":return[new Date(e),null];default:return[e,null]}}(i,s);return{name:i,category:r,value:n,attributes:o}}function L(t,e){let i;return e.isMasterPlaylist?i=function(t,e){const i=new c.ts;let s=!1;for(const[a,{name:r,value:n,attributes:o}]of t.entries())if("EXT-X-VERSION"===r)i.version=n;else if("EXT-X-STREAM-INF"===r){const r=t[a+1];("string"!=typeof r||r.startsWith("#EXT"))&&p.h2("EXT-X-STREAM-INF must be followed by a URI line",T,417);const n=X(t,o,r,!1,e);n&&("number"==typeof n.score&&(s=!0,n.score<0&&p.h2("SCORE attribute on EXT-X-STREAM-INF must be positive decimal-floating-point number.",T,424)),i.variants.push(n))}else if("EXT-X-I-FRAME-STREAM-INF"===r){const s=X(t,o,o.URI,!0,e);s&&i.variants.push(s)}else if("EXT-X-SESSION-DATA"===r){const t=new c.pf({id:o["DATA-ID"],value:o.VALUE,uri:o.URI,language:o.LANGUAGE});i.sessionDataList.some((e=>e.id===t.id&&e.language===t.language))&&p.h2("A Playlist MUST NOT contain more than one EXT-X-SESSION-DATA tag with the same DATA-ID attribute and the same LANGUAGE attribute.",T,444),i.sessionDataList.push(t)}else if("EXT-X-SESSION-KEY"===r){"NONE"===o.METHOD&&p.h2("EXT-X-SESSION-KEY: The value of the METHOD attribute MUST NOT be NONE",T,450);const t=new c.Uz({method:o.METHOD,uri:o.URI,iv:o.IV,format:o.KEYFORMAT,formatVersion:o.KEYFORMATVERSIONS});i.sessionKeyList.some((e=>b(e,t)))&&p.h2("A Master Playlist MUST NOT contain more than one EXT-X-SESSION-KEY tag with the same METHOD, URI, IV, KEYFORMAT, and KEYFORMATVERSIONS attribute values.",T,460),v(e,o),i.sessionKeyList.push(t)}else"EXT-X-INDEPENDENT-SEGMENTS"===r?(i.independentSegments&&p.h2("EXT-X-INDEPENDENT-SEGMENTS tag MUST NOT appear more than once in a Playlist",T,467),i.independentSegments=!0):"EXT-X-START"===r&&(i.start&&p.h2("EXT-X-START tag MUST NOT appear more than once in a Playlist",T,473),"number"!=typeof o["TIME-OFFSET"]&&p.h2("EXT-X-START: TIME-OFFSET attribute is REQUIRED",T,476),i.start={offset:o["TIME-OFFSET"],precise:o.PRECISE||!1});if(s)for(const t of i.variants)"number"!=typeof t.score&&p.h2("If any Variant Stream contains the SCORE attribute, then all Variant Streams in the Master Playlist SHOULD have a SCORE attribute",T,484);if(e.isClosedCaptionsNone)for(const t of i.variants)t.closedCaptions.length>0&&p.h2("If there is a variant with CLOSED-CAPTIONS attribute of NONE, all EXT-X-STREAM-INF tags MUST have this attribute with a value of NONE",T,491);return i}(t,e):(i=function(t,e){const i=new c.tk;let s=-1,a=0,r=!1,n=!1,o=0,h=null,l=null,u=!1;for(const[d,m]of t.entries()){const{name:E,value:f,attributes:y,category:A}=m;if("Segment"!==A){if("EXT-X-VERSION"===E)void 0===i.version?i.version=f:p.h2("A Playlist file MUST NOT contain more than one EXT-X-VERSION tag.",T,720);else if("EXT-X-TARGETDURATION"===E)i.targetDuration=e.targetDuration=f;else if("EXT-X-MEDIA-SEQUENCE"===E)i.segments.length>0&&p.h2("The EXT-X-MEDIA-SEQUENCE tag MUST appear before the first Media Segment in the Playlist.",T,728),i.mediaSequenceBase=a=f;else if("EXT-X-DISCONTINUITY-SEQUENCE"===E)i.segments.length>0&&p.h2("The EXT-X-DISCONTINUITY-SEQUENCE tag MUST appear before the first Media Segment in the Playlist.",T,734),r&&p.h2("The EXT-X-DISCONTINUITY-SEQUENCE tag MUST appear before any EXT-X-DISCONTINUITY tag.",T,737),i.discontinuitySequenceBase=o=f;else if("EXT-X-ENDLIST"===E)i.endlist=!0;else if("EXT-X-PLAYLIST-TYPE"===E)i.playlistType=f;else if("EXT-X-I-FRAMES-ONLY"===E)e.compatibleVersion<4&&(e.compatibleVersion=4),i.isIFrame=!0;else if("EXT-X-INDEPENDENT-SEGMENTS"===E)i.independentSegments&&p.h2("EXT-X-INDEPENDENT-SEGMENTS tag MUST NOT appear more than once in a Playlist",T,755),i.independentSegments=!0;else if("EXT-X-START"===E)i.start&&p.h2("EXT-X-START tag MUST NOT appear more than once in a Playlist",T,761),"number"!=typeof y["TIME-OFFSET"]&&p.h2("EXT-X-START: TIME-OFFSET attribute is REQUIRED",T,764),i.start={offset:y["TIME-OFFSET"],precise:y.PRECISE||!1};else if("EXT-X-SERVER-CONTROL"===E)y["CAN-BLOCK-RELOAD"]||p.h2("EXT-X-SERVER-CONTROL: CAN-BLOCK-RELOAD=YES is mandatory for Low-Latency HLS",T,770),i.lowLatencyCompatibility={canBlockReload:y["CAN-BLOCK-RELOAD"],canSkipUntil:y["CAN-SKIP-UNTIL"],holdBack:y["HOLD-BACK"],partHoldBack:y["PART-HOLD-BACK"]};else if("EXT-X-PART-INF"===E)y["PART-TARGET"]||p.h2("EXT-X-PART-INF: PART-TARGET attribute is mandatory",T,781),i.partTargetDuration=y["PART-TARGET"];else if("EXT-X-RENDITION-REPORT"===E)y.URI||p.h2("EXT-X-RENDITION-REPORT: URI attribute is mandatory",T,787),0===y.URI.search(/^[a-z]+:/)&&p.h2("EXT-X-RENDITION-REPORT: URI must be relative to the playlist uri",T,790),i.renditionReports.push(new c.h4({uri:y.URI,lastMSN:y["LAST-MSN"],lastPart:y["LAST-PART"]}));else if("EXT-X-SKIP"===E)y["SKIPPED-SEGMENTS"]||p.h2("EXT-X-SKIP: SKIPPED-SEGMENTS attribute is mandatory",T,800),e.compatibleVersion<9&&(e.compatibleVersion=9),i.skip=y["SKIPPED-SEGMENTS"],a+=i.skip;else if("EXT-X-PREFETCH"===E){const r=R(t,f,-1===s?d:s,d-1,a++,o,e);r&&(r.discontinuity&&(r.discontinuitySequence++,o=r.discontinuitySequence),r.key?h=r.key:null===r.key?h=void 0:r.key=h,i.prefetchSegments.push(r)),n=!0,s=-1}else if("string"==typeof m){-1===s&&p.h2("A URI line is not preceded by any segment tags",T,840),i.targetDuration||p.h2("The EXT-X-TARGETDURATION tag is REQUIRED",T,843),n&&p.h2("These segments must appear after all complete segments.",T,846);const r=N(t,m,s,d-1,a++,o,e);r&&(null===r.key&&(h=void 0),[o,h,l]=P(i,r,o,h,l),!u&&r.parts.length>0&&(u=!0)),s=-1}}else-1===s&&(s=d),"EXT-X-DISCONTINUITY"===E&&(r=!0)}if(-1!==s){const r=N(t,"",s,t.length-1,a++,o,e);if(r){var m;null===r.key&&(h=void 0);const{parts:t}=r;!(t.length>0)||i.endlist||null!==(m=t[t.length-1])&&void 0!==m&&m.hint||p.h2("If the Playlist contains EXT-X-PART tags and does not contain an EXT-X-ENDLIST tag, the Playlist must contain an EXT-X-PRELOAD-HINT tag with a TYPE=PART attribute",T,869),P(i,r,o,h,l),!u&&r.parts.length>0&&(u=!0)}}return function(t){const e=new(d()),i=new(d());let s=!1,a=!1;for(let r=t.length-1;r>=0;r--){const{programDateTime:n,dateRange:o}=t[r];if(n&&(a=!0),o&&o.start){s=!0,o.endOnNext&&(o.end||o.duration)&&p.h2("An EXT-X-DATERANGE tag with an END-ON-NEXT=YES attribute MUST NOT contain DURATION or END-DATE attributes.",T,936);const t=o.start.getTime(),a=o.duration||0;o.end&&o.duration&&t+1e3*a!==o.end.getTime()&&p.h2("END-DATE MUST be equal to the value of the START-DATE attribute plus the value of the DURATION",T,942),o.endOnNext&&(o.end=e.get(o.classId)),e.set(o.classId,o.start);const r=o.end?o.end.getTime():o.start.getTime()+1e3*(o.duration||0),n=i.get(o.classId);if(n){for(const e of n)(e.start<=t&&e.end>t||e.start>=t&&e.start<r)&&p.h2("DATERANGE tags with the same CLASS should not overlap",T,954);n.push({start:t,end:r})}else o.classId&&i.set(o.classId,[{start:t,end:r}])}}s&&!a&&p.h2("If a Playlist contains an EXT-X-DATERANGE tag, it MUST also contain at least one EXT-X-PROGRAM-DATE-TIME tag.",T,965)}(i.segments),i.lowLatencyCompatibility&&function({lowLatencyCompatibility:t,targetDuration:e,partTargetDuration:i,segments:s,renditionReports:a},r){const{canSkipUntil:n,holdBack:o,partHoldBack:h}=t;if(n<6*e&&p.h2("The Skip Boundary must be at least six times the EXT-X-TARGETDURATION.",T,972),o<3*e&&p.h2("HOLD-BACK must be at least three times the EXT-X-TARGETDURATION.",T,976),r){void 0===i&&p.h2("EXT-X-PART-INF is required if a Playlist contains one or more EXT-X-PART tags",T,980),void 0===h&&p.h2("EXT-X-PART: PART-HOLD-BACK attribute is mandatory",T,983),h<i&&p.h2("PART-HOLD-BACK must be at least PART-TARGET",T,986);for(const[t,{parts:e}]of s.entries())for(const[t,{duration:s}]of e.entries())void 0!==s&&(s>i&&p.h2("PART-TARGET is the maximum duration of any Partial Segment",T,997),t<e.length-1&&s<.85*i&&p.h2("All Partial Segments except the last part of a segment must have a duration of at least 85% of PART-TARGET",T,1e3))}for(const t of a){const e=s[s.length-1];null!==t.lastMSN&&void 0!==t.lastMSN||(t.lastMSN=e.mediaSequenceNumber),(null===t.lastPart||void 0===t.lastPart)&&e.parts.length>0&&(t.lastPart=e.parts.length-1)}}(i,u),i.duration=i.segments.reduce(((t,e)=>"number"==typeof e.duration?t+e.duration:t),0),i}(t,e),!i.isIFrame&&e.hasMap&&e.compatibleVersion<6&&(e.compatibleVersion=6)),e.compatibleVersion>1&&(!i.version||i.version<e.compatibleVersion)&&p.h2(`EXT-X-VERSION needs to be ${e.compatibleVersion} or higher.`,T,1104),i}function w(t){const e={version:void 0,isMasterPlaylist:void 0,hasMap:!1,targetDuration:0,compatibleVersion:1,isClosedCaptionsNone:!1,hash:{}},i=function(t,e){const i=[];for(const s of t.split("\n")){const t=s.trim();if(t)if(t.startsWith("#")){if(t.startsWith("#EXT")){const s=D(t,e);s&&i.push(s)}}else i.push(t)}return 0!==i.length&&"EXTM3U"===i[0].name||p.h2("The EXTM3U tag MUST be the first line.",T,1086),i}(t,e),s=L(i,e);return s.source=t,s}},64608:(t,e,i)=>{i.d(e,{KT:()=>n,Uz:()=>h,Vd:()=>y,Y4:()=>E,ad:()=>d,h4:()=>A,nw:()=>f,pf:()=>o,qP:()=>l,ru:()=>r,tk:()=>m,ts:()=>T,xC:()=>u});var s=i(134),a=i(86932);class r{constructor({type:t,uri:e,groupId:i,language:a,assocLanguage:r,name:n,isDefault:o,autoselect:h,forced:l,instreamId:d,characteristics:u,channels:c}){(0,s.A)(this,"type",void 0),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"groupId",void 0),(0,s.A)(this,"language",void 0),(0,s.A)(this,"assocLanguage",void 0),(0,s.A)(this,"name",void 0),(0,s.A)(this,"isDefault",void 0),(0,s.A)(this,"autoselect",void 0),(0,s.A)(this,"forced",void 0),(0,s.A)(this,"instreamId",void 0),(0,s.A)(this,"characteristics",void 0),(0,s.A)(this,"channels",void 0),this.type=t,this.uri=e,this.groupId=i,this.language=a,this.assocLanguage=r,this.name=n,this.isDefault=o,this.autoselect=h,this.forced=l,this.instreamId=d,this.characteristics=u,this.channels=c}}class n{constructor({uri:t,isIFrameOnly:e=!1,bandwidth:i,averageBandwidth:a,score:r,codecs:n,resolution:o,frameRate:h,hdcpLevel:l,allowedCpc:d,videoRange:u,stableVariantId:c,programId:p,audio:T=[],video:m=[],subtitles:E=[],closedCaptions:f=[],currentRenditions:y={audio:0,video:0,subtitles:0,closedCaptions:0}}){(0,s.A)(this,"uri",void 0),(0,s.A)(this,"isIFrameOnly",void 0),(0,s.A)(this,"bandwidth",void 0),(0,s.A)(this,"averageBandwidth",void 0),(0,s.A)(this,"score",void 0),(0,s.A)(this,"codecs",void 0),(0,s.A)(this,"resolution",void 0),(0,s.A)(this,"frameRate",void 0),(0,s.A)(this,"hdcpLevel",void 0),(0,s.A)(this,"allowedCpc",void 0),(0,s.A)(this,"videoRange",void 0),(0,s.A)(this,"stableVariantId",void 0),(0,s.A)(this,"programId",void 0),(0,s.A)(this,"audio",void 0),(0,s.A)(this,"video",void 0),(0,s.A)(this,"subtitles",void 0),(0,s.A)(this,"closedCaptions",void 0),(0,s.A)(this,"currentRenditions",void 0),this.uri=t,this.isIFrameOnly=e,this.bandwidth=i,this.averageBandwidth=a,this.score=r,this.codecs=n,this.resolution=o,this.frameRate=h,this.hdcpLevel=l,this.allowedCpc=d,this.videoRange=u,this.stableVariantId=c,this.programId=p,this.audio=T,this.video=m,this.subtitles=E,this.closedCaptions=f,this.currentRenditions=y}}class o{constructor({id:t,value:e,uri:i,language:a}){(0,s.A)(this,"id",void 0),(0,s.A)(this,"value",void 0),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"language",void 0),this.id=t,this.value=e,this.uri=i,this.language=a}}class h{constructor({method:t,uri:e,iv:i,format:a,formatVersion:r}){(0,s.A)(this,"method",void 0),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"iv",void 0),(0,s.A)(this,"format",void 0),(0,s.A)(this,"formatVersion",void 0),this.method=t,this.uri=e,this.iv=i,this.format=a,this.formatVersion=r}}class l{constructor({hint:t=!1,uri:e,mimeType:i,byterange:a,key:r}){(0,s.A)(this,"hint",void 0),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"mimeType",void 0),(0,s.A)(this,"byterange",void 0),(0,s.A)(this,"key",void 0),this.hint=t,this.uri=e,this.mimeType=i,this.byterange=a,this.key=r}}class d{constructor({id:t,classId:e,start:i,end:a,duration:r,plannedDuration:n,endOnNext:o,attributes:h={}}){(0,s.A)(this,"id",void 0),(0,s.A)(this,"classId",void 0),(0,s.A)(this,"start",void 0),(0,s.A)(this,"end",void 0),(0,s.A)(this,"duration",void 0),(0,s.A)(this,"plannedDuration",void 0),(0,s.A)(this,"endOnNext",void 0),(0,s.A)(this,"attributes",void 0),this.id=t,this.classId=e,this.start=i,this.end=a,this.duration=r,this.plannedDuration=n,this.endOnNext=o,this.attributes=h}}class u{constructor({type:t,duration:e,tagName:i,value:a}){(0,s.A)(this,"type",void 0),(0,s.A)(this,"duration",void 0),(0,s.A)(this,"tagName",void 0),(0,s.A)(this,"value",void 0),this.type=t,this.duration=e,this.tagName=i,this.value=a}}class c{constructor(t){(0,s.A)(this,"type",void 0),this.type=t}}class p extends c{constructor({isMasterPlaylist:t,uri:e,version:i,independentSegments:a=!1,start:r,source:n}){super("playlist"),(0,s.A)(this,"isMasterPlaylist",void 0),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"version",void 0),(0,s.A)(this,"independentSegments",void 0),(0,s.A)(this,"start",void 0),(0,s.A)(this,"source",void 0),this.isMasterPlaylist=t,this.uri=e,this.version=i,this.independentSegments=a,this.start=r,this.source=n}}class T extends p{constructor(t={}){super({...t,isMasterPlaylist:!0}),(0,s.A)(this,"variants",void 0),(0,s.A)(this,"currentVariant",void 0),(0,s.A)(this,"sessionDataList",void 0),(0,s.A)(this,"sessionKeyList",void 0);const{variants:e=[],currentVariant:i,sessionDataList:a=[],sessionKeyList:r=[]}=t;this.variants=e,this.currentVariant=i,this.sessionDataList=a,this.sessionKeyList=r}}class m extends p{constructor(t={}){super({...t,isMasterPlaylist:!1}),(0,s.A)(this,"targetDuration",void 0),(0,s.A)(this,"mediaSequenceBase",void 0),(0,s.A)(this,"discontinuitySequenceBase",void 0),(0,s.A)(this,"endlist",void 0),(0,s.A)(this,"playlistType",void 0),(0,s.A)(this,"isIFrame",void 0),(0,s.A)(this,"segments",void 0),(0,s.A)(this,"prefetchSegments",void 0),(0,s.A)(this,"lowLatencyCompatibility",void 0),(0,s.A)(this,"partTargetDuration",void 0),(0,s.A)(this,"renditionReports",void 0),(0,s.A)(this,"skip",void 0),(0,s.A)(this,"hash",void 0),(0,s.A)(this,"duration",void 0),(0,s.A)(this,"timestamp",void 0);const{targetDuration:e,mediaSequenceBase:i=0,discontinuitySequenceBase:r=0,endlist:n=!1,playlistType:o,isIFrame:h,segments:l=[],prefetchSegments:d=[],lowLatencyCompatibility:u,partTargetDuration:c,renditionReports:p=[],skip:T=0,hash:m,duration:E=0}=t;this.targetDuration=e,this.mediaSequenceBase=i,this.discontinuitySequenceBase=r,this.endlist=n,this.playlistType=o,this.isIFrame=h,this.segments=l,this.prefetchSegments=d,this.lowLatencyCompatibility=u,this.partTargetDuration=c,this.renditionReports=p,this.skip=T,this.hash=m,this.duration=E,this.timestamp=(0,a.A)()}}class E extends c{constructor({uri:t,mimeType:e,data:i,duration:a,title:r,byterange:n,discontinuity:o,mediaSequenceNumber:h=0,discontinuitySequence:l=0,key:d,map:u,programDateTime:c,dateRange:p,markers:T=[],parts:m=[]}){super("segment"),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"mimeType",void 0),(0,s.A)(this,"data",void 0),(0,s.A)(this,"duration",void 0),(0,s.A)(this,"title",void 0),(0,s.A)(this,"byterange",void 0),(0,s.A)(this,"discontinuity",void 0),(0,s.A)(this,"mediaSequenceNumber",void 0),(0,s.A)(this,"discontinuitySequence",void 0),(0,s.A)(this,"key",void 0),(0,s.A)(this,"map",void 0),(0,s.A)(this,"programDateTime",void 0),(0,s.A)(this,"dateRange",void 0),(0,s.A)(this,"markers",void 0),(0,s.A)(this,"parts",void 0),this.uri=t,this.mimeType=e,this.data=i,this.duration=a,this.title=r,this.byterange=n,this.discontinuity=o,this.mediaSequenceNumber=h,this.discontinuitySequence=l,this.key=d,this.map=u,this.programDateTime=c,this.dateRange=p,this.markers=T,this.parts=m}}class f extends c{constructor({hint:t=!1,uri:e,duration:i,independent:a,byterange:r,gap:n}){super("part"),(0,s.A)(this,"hint",void 0),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"duration",void 0),(0,s.A)(this,"independent",void 0),(0,s.A)(this,"byterange",void 0),(0,s.A)(this,"gap",void 0),this.hint=t,this.uri=e,this.duration=i,this.independent=a,this.duration=i,this.byterange=r,this.gap=n}}class y extends c{constructor({uri:t,discontinuity:e,mediaSequenceNumber:i=0,discontinuitySequence:a=0,key:r}){super("prefetch"),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"discontinuity",void 0),(0,s.A)(this,"mediaSequenceNumber",void 0),(0,s.A)(this,"discontinuitySequence",void 0),(0,s.A)(this,"key",void 0),this.uri=t,this.discontinuity=e,this.mediaSequenceNumber=i,this.discontinuitySequence=a,this.key=r}}class A{constructor({uri:t,lastMSN:e,lastPart:i}){(0,s.A)(this,"uri",void 0),(0,s.A)(this,"lastMSN",void 0),(0,s.A)(this,"lastPart",void 0),this.uri=t,this.lastMSN=e,this.lastPart=i}}},67756:(t,e,i)=>{i.d(e,{Bq:()=>c,HG:()=>p,Ro:()=>l,Th:()=>T,gI:()=>u,m2:()=>d});var s=i(99704),a=i.n(s),r=i(17735),n=i.n(r),o=i(7210),h=i.n(o);function l(t,e=10){if("number"==typeof t)return t;const i=10===e?a()(t):n()(t,e);return h()(i)?0:i}function d(t){(t.startsWith("0x")||t.startsWith("0X"))&&(t=t.slice(2));const e=[];for(let i=0;i<t.length;i+=2)e.push(l(t.slice(i,i+2),16));return new Uint8Array(e)}function u(t,e,i=0){let s=-1;for(let a=0,r=0;a<t.length;a++)if(t[a]===e){if(r++===i)return[t.slice(0,a),t.slice(a+1)];s=a}return-1!==s?[t.slice(0,s),t.slice(s+1)]:[t]}function c(t,e=" "){return t?(t=t.trim()," "===e||(t.startsWith(e)&&(t=t.slice(1)),t.endsWith(e)&&(t=t.slice(0,-1))),t):t}function p(t){const e=[];let i=!0,s=0;const a=[];for(let r=0;r<t.length;r++){const n=t[r];i&&","===n?(e.push(t.slice(s,r).trim()),s=r+1):'"'!==n&&"'"!==n||(i?(a.push(n),i=!1):n===a[a.length-1]?(a.pop(),i=!0):a.push(n))}return e.push(t.slice(s).trim()),e}function T(t){const e=[];let i=!1;for(const s of t)"-"!==s&&"_"!==s?i?(e.push(s.toUpperCase()),i=!1):e.push(s.toLowerCase()):i=!0;return e.join("")}},62751:(t,e,i)=>{i.d(e,{$$:()=>r,Eh:()=>T,HR:()=>a,IY:()=>y,Ki:()=>f,Mb:()=>E,Sz:()=>d,Xp:()=>h,_R:()=>n,_m:()=>p,d8:()=>m,iW:()=>u,mX:()=>c,n1:()=>o,os:()=>s,qO:()=>l});const s={86017:"mp3",86018:"mp4a.40",86021:"vorbis",86028:"flac",86076:"opus",65542:"ulaw",65543:"alaw",86019:"ac-3",86056:"ec-3",86020:"dtsc",225:"av01",27:"avc1",173:"hev1",196:"vvc1",139:"vp8",167:"vp09",12:"mp4v"},a={flv:0,mp4:1,m4s:1,mov:1,ts:2,mts:2,m2ts:2,ivf:5,opus:4,oggs:4,ogg:4,m3u8:2,m3u:2,mpd:1,mp3:14,mkv:8,mka:8,webm:9,aac:15,flac:17,wav:16,srt:19,vtt:18,ssa:20,ass:20,xml:21,ttml:21,h264:11,264:11,avc:11,h265:12,265:12,hevc:12,h266:13,266:13,vvc:13,mpeg:3,mpg:3,rtsp:6,rtmp:7,avi:10},r={m3u8:4,m3u:4,mpd:5},n={copy:0,h264:27,h261:3,h263:4,h263i:20,h263p:19,mjpeg:7,wmv1:17,wmv2:18,wmv3:71,avc:27,hevc:173,h265:173,vvc:196,h266:196,av1:225,vp9:167,vp8:139,mpeg4:12,theora:30,mpeg2video:2,rv10:5,rv20:6,rv30:68,rv40:69},o={copy:0,aac:86018,ac3:86019,eac3:86056,dts:86020,mp3:86017,opus:86076,flac:86028,speex:86051,vorbis:86021,pcm_alaw:65543,pcm_mulaw:65542,wmav1:86023,wmav2:86024,cook:86036,sipr:86057,ralf:86073,pcm_u8:65541,pcm_s16le:65536,pcm_s24le:65548,pcm_s32le:65544,pcm_s64le:65567,pcm_f32le:65557,pcm_f64le:65559},h={webvtt:94226,subrip:94225,ass:94230,ttml:94232,mov_text:94213,hdmv_pgs:94214,hdmv_text:94231,dvd:94208,dvb:94209,eia_608:94218},l={yuv420p:0,yuv422p:4,yuv444p:5,yuva420p:33,yuva422p:78,yuva444p:79,yuvj420p:12,yuvj422p:13,yuvj444p:14,yuv420p10le:62,yuv422p10le:64,yuv444p10le:68,yuva420p10le:87,yuva422p10le:89,yuva444p10le:91,yuv420p10be:61,yuv422p10be:63,yuv444p10be:67,yuva420p10be:86,yuva422p10be:88,yuva444p10be:90},d={u8:0,"u8-planar":5,s16:1,"s16-planar":6,s32:2,"s32-planar":7,s64:10,"s64-planar":11,float:3,"float-planar":8,double:4,"double-planar":9},u={flv:0,mp4:1,mov:1,ts:2,mpegts:2,mpeg:3,ivf:5,ogg:4,opus:4,m3u8:2,m3u:2,mpd:1,mp3:14,mkv:8,matroska:8,mka:8,webm:9,aac:15,flac:17,wav:16,raw_h264:11,raw_h265:12,raw_vvc:13,rtsp:6,rtmp:7,avi:10},c={tv:1,pc:2},p={bt709:1,fcc:4,bt470bg:5,smpte170m:6,smpte240m:7,ycgco:8,gbr:0,bt2020nc:9},T={bt709:1,bt470m:4,bt470bg:5,smpte170m:6,smpte240m:7,smpte428:10,film:8,smpte431:11,smpte432:12,bt2020:9,"jedec-p22":22,ebu3213:22},m={bt709:1,gamma22:4,gamma28:5,smpte170m:6,smpte240m:7,srgb:13,xvycc:11,"bt2020-10":14,"bt2020-12":15,smpte2084:16,"arib-std-b67":18},E={Audio:1,Video:0,Subtitle:3,Attachment:4,Data:2},f={default:1,dub:2,original:4,comment:8,lyrics:16,karaoke:32,forced:64,"hearing impaired":128,"visual impaired":256,"clean effects":512,"attached pic":1024,"timed thumbnails":2048,captions:65536,descriptions:131072,metadata:262144,dependent:524288,"still image":1048576},y={mono:4,stereo:3,2.1:11,"3.0":7,"3.0(back)":259,"4.0":263,quad:51,"quad(side)":1539,3.1:15,"5.0":55,"5.0(side)":1543,4.1:271,5.1:63,"5.1(side)":1551,"6.0":1799,"6.0(front)":1731,"3.1.2":20495,hexagonal:311,6.1:1807,"6.1(back)":319,"6.1(front)":1739,"7.0":1591,"7.0(front)":1735,7.1:1599,"7.1(wide)":255,"7.1(wide-side)":1743,"5.1.2":20543,octagonal:1847,cube:184371,"5.1.4":184383,"7.1.2":22079,"7.1.4":185919,"7.2.3":34359825983,"9.1.4":186111,hexadecagonal:6442710839,downmix:1610612736,22.2:2164663779327}},13258:(t,e,i)=>{i.d(e,{A:()=>a});var s=i(134);class a{constructor(t=0){(0,s.A)(this,"rcon",[0,1,2,4,8,16,32,64,128,27,54]),(0,s.A)(this,"subMix",[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)]),(0,s.A)(this,"invSubMix",[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)]),(0,s.A)(this,"sBox",new Uint32Array(256)),(0,s.A)(this,"invSBox",new Uint32Array(256)),(0,s.A)(this,"key",new Uint32Array(0)),(0,s.A)(this,"ksRows",0),(0,s.A)(this,"keySize",0),(0,s.A)(this,"keySchedule",void 0),(0,s.A)(this,"invKeySchedule",void 0),this.initTable()}uint8ArrayToUint32Array_(t){const e=new DataView(t),i=new Uint32Array(4);for(let t=0;t<4;t++)i[t]=e.getUint32(4*t);return i}initTable(){const t=this.sBox,e=this.invSBox,i=this.subMix,s=i[0],a=i[1],r=i[2],n=i[3],o=this.invSubMix,h=o[0],l=o[1],d=o[2],u=o[3],c=new Uint32Array(256);let p=0,T=0,m=0;for(m=0;m<256;m++)c[m]=m<128?m<<1:m<<1^283;for(m=0;m<256;m++){let i=T^T<<1^T<<2^T<<3^T<<4;i=i>>>8^255&i^99,t[p]=i,e[i]=p;const o=c[p],m=c[o],E=c[m];let f=257*c[i]^16843008*i;s[p]=f<<24|f>>>8,a[p]=f<<16|f>>>16,r[p]=f<<8|f>>>24,n[p]=f,f=16843009*E^65537*m^257*o^16843008*p,h[i]=f<<24|f>>>8,l[i]=f<<16|f>>>16,d[i]=f<<8|f>>>24,u[i]=f,p?(p=o^c[c[c[E^o]]],T^=c[c[T]]):p=T=1}}async expandKey(t){const e=this.uint8ArrayToUint32Array_(t);if(this.key){let t=!0,i=0;for(;i<e.length&&t;)t=e[i]===this.key[i],i++;if(t)return}this.key=e;const i=this.keySize=this.key.length;if(4!==i&&6!==i&&8!==i)throw new Error("Invalid aes key size="+i);const s=this.ksRows=4*(i+6+1);let a,r;const n=this.keySchedule=new Uint32Array(s),o=this.invKeySchedule=new Uint32Array(s),h=this.sBox,l=this.rcon,d=this.invSubMix,u=d[0],c=d[1],p=d[2],T=d[3];let m,E;for(a=0;a<s;a++)a<i?m=n[a]=e[a]:(E=m,a%i==0?(E=E<<8|E>>>24,E=h[E>>>24]<<24|h[E>>>16&255]<<16|h[E>>>8&255]<<8|h[255&E],E^=l[a/i|0]<<24):i>6&&a%i==4&&(E=h[E>>>24]<<24|h[E>>>16&255]<<16|h[E>>>8&255]<<8|h[255&E]),n[a]=m=(n[a-i]^E)>>>0);for(r=0;r<s;r++)a=s-r,E=3&r?n[a]:n[a-4],o[r]=r<4||a<=4?E:u[h[E>>>24]]^c[h[E>>>16&255]]^p[h[E>>>8&255]]^T[h[255&E]],o[r]=o[r]>>>0}networkToHostOrderSwap(t){return t<<24|(65280&t)<<8|(16711680&t)>>8|t>>>24}async decrypt(t,e){const i=this.keySize+6,s=this.invKeySchedule,a=this.invSBox,r=this.invSubMix,n=r[0],o=r[1],h=r[2],l=r[3],d=this.uint8ArrayToUint32Array_(e);let u=d[0],c=d[1],p=d[2],T=d[3];const m=new Int32Array(t.buffer).subarray(t.byteOffset>>>2,(t.byteOffset>>>2)+(t.length>>>2)),E=new Int32Array(m.length);let f,y,A,g,v,I,S,X,b,N,R,P,D,L;const w=this.networkToHostOrderSwap;let O=0;for(;O<m.length;){for(b=w(m[O]),N=w(m[O+1]),R=w(m[O+2]),P=w(m[O+3]),v=b^s[0],I=P^s[1],S=R^s[2],X=N^s[3],D=4,L=1;L<i;L++)f=n[v>>>24]^o[I>>16&255]^h[S>>8&255]^l[255&X]^s[D],y=n[I>>>24]^o[S>>16&255]^h[X>>8&255]^l[255&v]^s[D+1],A=n[S>>>24]^o[X>>16&255]^h[v>>8&255]^l[255&I]^s[D+2],g=n[X>>>24]^o[v>>16&255]^h[I>>8&255]^l[255&S]^s[D+3],v=f,I=y,S=A,X=g,D+=4;f=a[v>>>24]<<24^a[I>>16&255]<<16^a[S>>8&255]<<8^a[255&X]^s[D],y=a[I>>>24]<<24^a[S>>16&255]<<16^a[X>>8&255]<<8^a[255&v]^s[D+1],A=a[S>>>24]<<24^a[X>>16&255]<<16^a[v>>8&255]<<8^a[255&I]^s[D+2],g=a[X>>>24]<<24^a[v>>16&255]<<16^a[I>>8&255]<<8^a[255&S]^s[D+3],E[O]=w(f^u),E[O+1]=w(g^c),E[O+2]=w(A^p),E[O+3]=w(y^T),u=b,c=N,p=R,T=P,O+=4}return E.buffer}}},51678:(t,e,i)=>{i.d(e,{A:()=>a});var s=i(134);class a{constructor(t=0){(0,s.A)(this,"subtle",void 0),(0,s.A)(this,"key",void 0),(0,s.A)(this,"mode",void 0),(0,s.A)(this,"keyBuffer",void 0),this.mode=t,this.subtle=crypto.subtle||crypto.webkitSubtle}getSubtleAlgoName(){switch(this.mode){case 0:return"AES-CBC";case 1:return"AES-CTR"}}async expandKey(t){let e=new Uint8Array(t);if(this.keyBuffer){let t=!0,i=0;for(;i<e.length&&t;)t=e[i]===this.keyBuffer[i],i++;if(t)return}this.keyBuffer=e,this.key=await this.subtle.importKey("raw",t,{name:this.getSubtleAlgoName()},!1,["encrypt","decrypt"])}async encryptPadding(t,e){return new Uint8Array(await crypto.subtle.encrypt({name:"AES-CBC",iv:e},this.key,t))}async decrypt(t,e){switch(this.mode){case 0:return this.subtle.decrypt({name:"AES-CBC",iv:e},this.key,t);case 1:return this.subtle.decrypt({name:"AES-CTR",counter:e,length:64},this.key,t)}}static isSupport(){return"object"==typeof(crypto.subtle||crypto.webkitSubtle)}}},6498:(t,e,i)=>{i(67672),i(72739)},8507:(t,e,i)=>{function s(t){const e=t,i=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],s=/:\/\/([^\/@]*@?)\[(\S+)\]/;let a="";s.test(t)&&(t=t.replace(s,((t,e,i)=>(a=i,`://${e||""}a.b`))));const r={},n=/^(?:(?![^:@\/]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@\/]*)(?::([^:@\/]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(t);let o=14;for(;o--;){var h;r[i[o]]=null!==(h=n[o])&&void 0!==h?h:""}return a&&(r.host=a,r.source=e,r.authority=a+(r.port?":"+r.port:"")),{protocol:r.protocol,file:r.file,host:r.host,port:r.port,user:r.user,password:r.password,origin:`${r.protocol}://${r.authority}`,pathname:r.path,search:`?${r.query}`,hash:r.anchor?`#${r.anchor}`:""}}i.d(e,{ll:()=>u,qg:()=>s}),i(73146),i(67672),i(6498),i(72739),i(95335);const a=/(?:\/|^)\.(?=\/)/g,r=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,n=/^(?=([^\/?#]*))\1([^]*)$/,o=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/;function h(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}function l(t){const e=o.exec(t);return e?{scheme:e[1]||"",netLoc:e[2]||"",path:e[3]||"",params:e[4]||"",query:e[5]||"",fragment:e[6]||""}:null}function d(t){for(t=t.split("").reverse().join("").replace(a,"");t.length!==(t=t.replace(r,"")).length;);return t.split("").reverse().join("")}function u(t,e,i){if(i=i||{},t=t.trim(),!(e=e.trim())){if(!i.alwaysNormalize)return t;let e=l(t);if(!e)throw new Error("Error trying to parse base URL.");return e.path=d(e.path),h(e)}let s=l(e);if(!s)throw new Error("Error trying to parse relative URL.");if(s.scheme)return i.alwaysNormalize?(s.path=d(s.path),h(s)):e;let a=l(t);if(!a)throw new Error("Error trying to parse base URL.");if(!a.netLoc&&a.path&&"/"!==a.path[0]){let t=n.exec(a.path);a.netLoc=t[1],a.path=t[2]}a.netLoc&&!a.path&&(a.path="/");const r={scheme:a.scheme,netLoc:s.netLoc,path:null,params:s.params,query:s.query,fragment:s.fragment};if(!s.netLoc&&(r.netLoc=a.netLoc,"/"!==s.path[0]))if(s.path){let t=a.path,e=t.substring(0,t.lastIndexOf("/")+1)+s.path;r.path=d(e)}else r.path=a.path,s.params||(r.params=a.params,s.query||(r.query=a.query));return null===r.path&&(r.path=i.alwaysNormalize?d(s.path):s.path),h(r)}},85079:(t,e,i)=>{var s=i(46438),a=s.JSON||(s.JSON={stringify:JSON.stringify});t.exports=function(t){return a.stringify.apply(a,arguments)}},63342:(t,e,i)=>{i(5882),t.exports=i(46438).Number.isInteger},11837:(t,e,i)=>{i(21489),t.exports=i(46438).Number.isNaN},19737:(t,e,i)=>{i(56477),t.exports=i(46438).Number.parseFloat},58886:(t,e,i)=>{i(15706),t.exports=i(46438).Number.parseInt},25194:(t,e,i)=>{var s=i(24401),a=Math.floor;t.exports=function(t){return!s(t)&&isFinite(t)&&a(t)===t}},5882:(t,e,i)=>{var s=i(88535);s(s.S,"Number",{isInteger:i(25194)})},21489:(t,e,i)=>{var s=i(88535);s(s.S,"Number",{isNaN:function(t){return t!=t}})},56477:(t,e,i)=>{var s=i(88535),a=i(49709);s(s.S+s.F*(Number.parseFloat!=a),"Number",{parseFloat:a})},15706:(t,e,i)=>{var s=i(88535),a=i(15722);s(s.S+s.F*(Number.parseInt!=a),"Number",{parseInt:a})},73146:(t,e,i)=>{t.exports=i(85079)},43929:(t,e,i)=>{t.exports=i(63342)},7210:(t,e,i)=>{t.exports=i(11837)},99704:(t,e,i)=>{t.exports=i(19737)},17735:(t,e,i)=>{t.exports=i(58886)}}]);
@@ -1 +1 @@
1
- (self.webpackChunklibmedia=self.webpackChunklibmedia||[]).push([[453],{18453:(e,t,i)=>{i.r(t),i.d(t,{default:()=>S});var a=i(134),r=i(63939),s=i(50932),n=i(4624),o=i(9705),c=i(85947),h=i(14686),d=i(37837),m=i(71517),f=i(91375),l=i(37246),u=i(92647),p=i(77231),g=i(52071),w=i(72739),x=i(44328),R=i(87400);const B="src/avformat/formats/IFlacFormat.ts",b=1024;class S extends c.A{constructor(){super(),(0,a.A)(this,"type",17),(0,a.A)(this,"context",void 0)}init(e){e.ioReader.setEndian(!0),this.context={streamInfo:{minimumBlockSize:0,maximumBlockSize:0,minimumFrameSize:0,maximumFrameSize:0,sampleRate:0,channels:0,bitPerSample:0,samples:BigInt(0),md5:""},frameInfo:{sampleRate:0,channels:0,bps:0,blocksize:0,chMode:0,frameOrSampleNum:BigInt(0),isVarSize:0},seekPoints:[],cueSheet:{catalogNumber:"",leadInSamples:BigInt(0),compactDisc:!1,tracks:[]},picture:{type:0,mimeType:"",description:"",width:0,height:0,colorDepth:0,indexedColor:0,data:null},cacheBuffer:null,cachePos:BigInt(0),bitReader:new l.A(16),fileSize:BigInt(0),firstFramePos:BigInt(0),isVarSize:-1}}async readHeader(e){if("fLaC"!==await e.ioReader.readString(4))return n.z3("the file format is not flac",B,118),o.LR;this.context.fileSize=await e.ioReader.fileSize();const t=e.createStream();for(t.codecpar.codecType=1,t.codecpar.codecId=86028;;){const i=await e.ioReader.readUint8(),a=await e.ioReader.readUint24(),r=-129&i;if(0===r){t.codecpar.extradata=(0,d.sY)(a),t.codecpar.extradataSize=a,(0,h.lW)(t.codecpar.extradata,a,await e.ioReader.peekBuffer(a)),this.context.streamInfo.minimumBlockSize=await e.ioReader.readUint16(),this.context.streamInfo.maximumBlockSize=await e.ioReader.readUint16(),this.context.streamInfo.minimumFrameSize=await e.ioReader.readUint24(),this.context.streamInfo.maximumFrameSize=await e.ioReader.readUint24();const i=await e.ioReader.readUint24();t.codecpar.sampleRate=i>>4,t.codecpar.chLayout.nbChannels=1+((15&i)>>>1),this.context.streamInfo.sampleRate=t.codecpar.sampleRate,this.context.streamInfo.channels=t.codecpar.chLayout.nbChannels;const r=await e.ioReader.readUint8();t.codecpar.bitsPerRawSample=1+((1&i)<<4|(240&r)>>>4),this.context.streamInfo.bitPerSample=t.codecpar.bitsPerRawSample;const s=await e.ioReader.readUint32(),n=BigInt(Math.floor(15&r))<<BigInt(32)|BigInt(Math.floor(s));this.context.streamInfo.samples=n,t.timeBase.den=t.codecpar.sampleRate,t.timeBase.num=1,t.duration=n,t.startTime=BigInt(0),this.context.streamInfo.md5=await e.ioReader.readString(16)}else if(2===r){const t=e.createStream();t.codecpar.codecType=2,t.codecpar.codecTag=await e.ioReader.readUint32(),t.codecpar.extradata=(0,d.sY)(a-4),t.codecpar.extradataSize=a-4,await e.ioReader.readBuffer(a-4,(0,h.JW)(t.codecpar.extradata,t.codecpar.extradataSize))}else if(3===r)for(let t=0;t<a/18;t++){const t=await e.ioReader.readUint64(),i=await e.ioReader.readUint64(),a=await e.ioReader.readUint16();this.context.seekPoints.push({pts:t,pos:i,samples:a})}else if(4===r){e.ioReader.setEndian(!1);const i=await e.ioReader.readUint32(),a=await e.ioReader.readString(i),r=await e.ioReader.readUint32(),s=[];for(let t=0;t<r;t++){const t=await e.ioReader.readUint32();s.push(await e.ioReader.readString(t))}t.metadata.vendor=a,(0,R.ol)(s,t.metadata),e.ioReader.setEndian(!0)}else if(5===r){this.context.cueSheet.catalogNumber=await e.ioReader.readString(128),this.context.cueSheet.leadInSamples=await e.ioReader.readUint64(),this.context.cueSheet.compactDisc=!!(await e.ioReader.readUint8()>>>7),await e.ioReader.skip(258);const t=await e.ioReader.readUint8();for(let i=0;i<t;i++){const t=await e.ioReader.readUint64(),i=await e.ioReader.readUint8(),a=await e.ioReader.readBuffer(12),r=await e.ioReader.readUint8();await e.ioReader.skip(13);const s=await e.ioReader.readUint8(),n=[];for(let t=0;t<s;t++)n.push({offset:await e.ioReader.readUint64(),point:await e.ioReader.readUint8()}),await e.ioReader.skip(3);this.context.cueSheet.tracks.push({offset:t,number:i,isrc:a,type:r>>>7,preEmphasisFlag:r>>>6&1,points:n})}}else if(6===r){this.context.picture.type=await e.ioReader.readUint32();let t=await e.ioReader.readUint32();this.context.picture.mimeType=await e.ioReader.readString(t),t=await e.ioReader.readUint32(),this.context.picture.description=await e.ioReader.readString(t),this.context.picture.width=await e.ioReader.readUint32(),this.context.picture.height=await e.ioReader.readUint32(),this.context.picture.colorDepth=await e.ioReader.readUint32(),this.context.picture.indexedColor=await e.ioReader.readUint32(),t=await e.ioReader.readUint32(),this.context.picture.data=await e.ioReader.readBuffer(t)}else await e.ioReader.skip(a);if(128&i)break}return this.context.firstFramePos=e.ioReader.getPos(),t.privData=this.context,0}async getNextFrame(e){const t=[];for(;;){if(e.ioReader.getPos()===this.context.fileSize){this.context.cacheBuffer&&(t.push(this.context.cacheBuffer),this.context.cacheBuffer=null);break}this.context.cacheBuffer?this.context.cacheBuffer.length<17&&(this.context.cacheBuffer=(0,u.A)(Uint8Array,[this.context.cacheBuffer,await e.ioReader.readBuffer(Math.min(b,Number(BigInt.asIntN(32,this.context.fileSize-e.ioReader.getPos()))))])):(this.context.cachePos=e.ioReader.getPos(),this.context.cacheBuffer=await e.ioReader.readBuffer(Math.min(b,Number(BigInt.asIntN(32,this.context.fileSize-e.ioReader.getPos())))));let i=t.length?0:2;const a=this.context.isVarSize<0?[248,249]:this.context.isVarSize?[249]:[248],r=this.context.cacheBuffer.length-2;for(;i<r;i++)if(255===this.context.cacheBuffer[i]&&w.zy(a,this.context.cacheBuffer[i+1])){i&&(t.push(this.context.cacheBuffer.subarray(0,i)),this.context.cacheBuffer=this.context.cacheBuffer.subarray(i),this.context.cachePos+=BigInt(Math.floor(i)));break}if(i===r){e.ioReader.getPos()===this.context.fileSize?(t.push(this.context.cacheBuffer),this.context.cachePos+=BigInt(Math.floor(this.context.cacheBuffer.length)),this.context.cacheBuffer=null):(t.push(this.context.cacheBuffer.subarray(0,i)),this.context.cachePos+=BigInt(Math.floor(i)),this.context.cacheBuffer=this.context.cacheBuffer.subarray(i));continue}this.context.cacheBuffer.length<16&&(this.context.cacheBuffer=(0,u.A)(Uint8Array,[this.context.cacheBuffer,await e.ioReader.readBuffer(Math.min(b,Number(BigInt.asIntN(32,this.context.fileSize-e.ioReader.getPos()))))])),this.context.bitReader.reset(),this.context.bitReader.appendBuffer(this.context.cacheBuffer.subarray(0,16));const s={};if(!((0,f.x)(this.context.bitReader,s,!0)<0||s.frameOrSampleNum-this.context.frameInfo.frameOrSampleNum!==BigInt(0|this.context.frameInfo.blocksize)&&s.frameOrSampleNum!==this.context.frameInfo.frameOrSampleNum+BigInt(1)))break;t.push(this.context.cacheBuffer.subarray(0,2)),this.context.cachePos+=BigInt(2),this.context.cacheBuffer=this.context.cacheBuffer.subarray(2)}return 1===t.length?t[0]:(0,u.A)(Uint8Array,t)}async readAVPacket(e,t){const i=e.streams.find((e=>e.codecpar.codecType=1));try{let a=e.ioReader.getPos();if(a===this.context.fileSize)return-1048576;if(this.context.bitReader.reset(),this.context.cacheBuffer?(a=this.context.cachePos,this.context.cacheBuffer.length<16&&(this.context.cacheBuffer=(0,u.A)(Uint8Array,[this.context.cacheBuffer,await e.ioReader.readBuffer(Math.min(b,Number(BigInt.asIntN(32,this.context.fileSize-e.ioReader.getPos()))))])),this.context.bitReader.appendBuffer(this.context.cacheBuffer.subarray(0,16))):this.context.bitReader.appendBuffer(await e.ioReader.peekBuffer(16)),(0,f.x)(this.context.bitReader,this.context.frameInfo)<0)return o.LR;const n=await this.getNextFrame(e),c=(0,d.sY)(n.length);return(0,h.lW)(c,n.length,n),(0,m.NX)(t,c,n.length),s.M[17](t+56,a),s.M[15](t+32,i.index),s.M[15](t+76,i.timeBase.den),s.M[15](t+72,i.timeBase.num),s.M[15](t+36,1|r.f[15](t+36)),s.M[17](t+16,this.context.frameInfo.isVarSize?this.context.frameInfo.frameOrSampleNum:this.context.frameInfo.frameOrSampleNum*BigInt(0|this.context.frameInfo.blocksize)),s.M[17](t+8,this.context.frameInfo.isVarSize?this.context.frameInfo.frameOrSampleNum:this.context.frameInfo.frameOrSampleNum*BigInt(0|this.context.frameInfo.blocksize)),this.context.isVarSize<0&&(this.context.isVarSize=this.context.frameInfo.isVarSize),0}catch(t){return-1048576!==e.ioReader.error&&-1048572!==e.ioReader.error?(n.z3(`read packet error, ${t}`,B,418),o.LR):e.ioReader.error}}async syncFrame(e){let t=p.Dh;for(;;)try{const i=await e.ioReader.peekUint16();if((65529===i||65528===i)&&(t=e.ioReader.getPos(),this.context.bitReader.reset(),this.context.bitReader.appendBuffer(await e.ioReader.peekBuffer(16)),!(0,f.x)(this.context.bitReader,{},!0)))break;await e.ioReader.skip(1)}catch(e){break}t!==p.Dh&&await e.ioReader.seek(t)}async seek(e,t,i,a){const r=e.ioReader.getPos(),s=t.privData;if(2&a){const t=await e.ioReader.fileSize();return t<=BigInt(0)?BigInt(o.E$):(i<BigInt(0)?i=BigInt(0):i>t&&(i=t),await e.ioReader.seek(i),4&a||await this.syncFrame(e),r)}if(t&&t.sampleIndexes.length){let a=w.El(t.sampleIndexes,(e=>e.pts>i?-1:1));if(a>0&&(0,x.k)(i-t.sampleIndexes[a-1].pts,t.timeBase,p.i0)<BigInt(5e3))return n.Yz(`seek in sampleIndexes, found index: ${a}, pts: ${t.sampleIndexes[a-1].pts}, pos: ${t.sampleIndexes[a-1].pos}`,B,485),await e.ioReader.seek(t.sampleIndexes[a-1].pos),s.cacheBuffer=null,r}if(s.seekPoints.length){let t=0;for(let e=0;e<s.seekPoints.length;e++){if(s.seekPoints[e].pts===i){t=e;break}if(s.seekPoints[e].pts>i){t=Math.max(e-1,0);break}}const a=s.seekPoints[t];return n.Yz(`seek in seekPoints, found index: ${t}, pts: ${a.pts}, pos: ${a.pos+s.firstFramePos}`,B,505),await e.ioReader.seek(a.pos+s.firstFramePos),s.cacheBuffer=null,r}n.Yz("not found any keyframe index, try to seek in bytes",B,511);const c=await(0,g.A)(e,t,i,s.firstFramePos,this.readAVPacket.bind(this),this.syncFrame.bind(this));return c>0&&(s.cacheBuffer=null),c}getAnalyzeStreamsCount(){return 1}}},85947:(e,t,i)=>{i.d(t,{A:()=>r});var a=i(134);class r{constructor(){(0,a.A)(this,"type",-1),(0,a.A)(this,"onStreamAdd",void 0)}async destroy(e){}}},91375:(e,t,i)=>{i.d(t,{x:()=>c});var a=i(9705),r=i(4624),s=i(14769),n=i(13188);const o="src/avformat/formats/flac/iflac.ts";function c(e,t,i=!1){const c=e.getPointer();if(32764!=(32767&e.readU(15)))return!i&&r.z3("invalid sync code",o,57),a.LR;t.isVarSize=e.readU1();const h=e.readU(4),d=e.readU(4);if(t.chMode=e.readU(4),t.chMode<s.jA)t.channels=t.chMode+1,t.chMode=0;else{if(!(t.chMode<s.jA+3))return!i&&r.z3(`invalid channel mode: ${t.chMode}`,o,76),a.LR;t.channels=2,t.chMode-=s.jA-1}const m=e.readU(3);if(3===m)return!i&&r.z3(`invalid sample size code: ${m}`,o,82),a.LR;if(t.bps=s.oe[m],e.readU1())return!i&&r.z3("broken stream, invalid padding",o,88),a.LR;if(t.frameOrSampleNum=function(e){let t=BigInt(Math.floor(e.readU(8))),i=(t&BigInt(128))>>BigInt(1);if((t&BigInt(192))===BigInt(128)||t>=BigInt(254))return-BigInt(1);for(;t&i;){const a=BigInt(Math.floor(e.readU(8)))-BigInt(128);if(a>>BigInt(6))return-BigInt(1);t=(t<<BigInt(6))+a,i<<=BigInt(5)}return t&=(i<<BigInt(1))-BigInt(1),t}(e),t.frameOrSampleNum<0)return!i&&r.z3("sample/frame number invalid",o,95),a.LR;if(0===h)return!i&&r.z3("reserved blocksize code: 0",o,100),a.LR;if(t.blocksize=6===h?e.readU(8)+1:7===h?e.readU(16)+1:s.Xr[h],d<12)t.sampleRate=s.DK[d];else if(12===d)t.sampleRate=1e3*e.readU(8);else if(13===d)t.sampleRate=e.readU(16);else{if(14!==d)return!i&&r.z3(`illegal sample rate code ${d}`,o,126),a.LR;t.sampleRate=10*e.readU(16)}return(0,n.A)(e.getBuffer().subarray(c,e.getPointer()))!==e.readU(8)?(!i&&r.z3("header crc mismatch",o,133),a.LR):0}},38743:(e,t,i)=>{i.d(t,{B:()=>o,h:()=>c});var a=i(134),r=i(77231),s=i(50011);class n{constructor(){(0,a.A)(this,"list",void 0),this.list=[]}read(e,t){for(let i=0;i<t;i++){const t=e.readUint32();this.list.push(e.readString(t))}}write(e){for(let t=0;t<this.list.length;t++){const i=s.encode(this.list[t]);e.writeUint32(i.length),e.writeBuffer(i)}}addComment(e){this.list.push(e)}}class o{constructor(){(0,a.A)(this,"capturePattern",void 0),(0,a.A)(this,"streamStructureVersion",void 0),(0,a.A)(this,"headerTypeFlag",void 0),(0,a.A)(this,"granulePosition",void 0),(0,a.A)(this,"serialNumber",void 0),(0,a.A)(this,"pageSequenceNumber",void 0),(0,a.A)(this,"crcCheckSum",void 0),(0,a.A)(this,"numberPageSegments",void 0),(0,a.A)(this,"segmentTable",void 0),(0,a.A)(this,"payload",void 0),(0,a.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(e){this.pos=e.getPos(),await this.readPageHeader(e);const t=this.segmentTable.reduce(((e,t)=>e+t),0);t&&(this.payload=await e.readBuffer(t))}async readPageHeader(e){if(this.capturePattern=await e.readString(4),this.streamStructureVersion=await e.readUint8(),this.headerTypeFlag=await e.readUint8(),this.granulePosition=await e.readUint64(),this.serialNumber=await e.readUint32(),this.pageSequenceNumber=await e.readUint32(),this.crcCheckSum=await e.readUint32(),this.numberPageSegments=await e.readUint8(),this.numberPageSegments)for(let t=0;t<this.numberPageSegments;t++){const t=await e.readUint8();this.segmentTable.push(t)}}write(e){if(this.pos=e.getPos(),e.writeString(this.capturePattern),e.writeUint8(this.streamStructureVersion),e.writeUint8(this.headerTypeFlag),e.writeUint64(this.granulePosition),e.writeUint32(this.serialNumber),e.writeUint32(this.pageSequenceNumber),e.writeUint32(this.crcCheckSum),this.payload){this.numberPageSegments=Math.floor(this.payload.length/255)+1;const t=this.payload.length%255;e.writeUint8(this.numberPageSegments);for(let t=0;t<this.numberPageSegments-1;t++)e.writeUint8(255);e.writeUint8(t),e.writeBuffer(this.payload)}else e.writeUint8(0)}}class c{constructor(){(0,a.A)(this,"streamIndex",void 0),(0,a.A)(this,"signature",void 0),(0,a.A)(this,"vendorStringLength",void 0),(0,a.A)(this,"vendorString",void 0),(0,a.A)(this,"userCommentListLength",void 0),(0,a.A)(this,"comments",void 0),this.vendorString="v0.9.0",this.vendorStringLength=this.vendorString.length,this.userCommentListLength=0,this.comments=new n}read(e){this.vendorStringLength=e.readUint32(),this.vendorString=e.readString(this.vendorStringLength),this.userCommentListLength=e.readUint32(),this.userCommentListLength&&this.comments.read(e,this.userCommentListLength)}write(e){const t=s.encode(this.vendorString);e.writeUint32(t.length),e.writeBuffer(t),e.writeUint32(this.comments.list.length),this.comments.write(e)}addComment(e){this.comments.addComment(e)}setCodec(e){}}},87400:(e,t,i)=>{i.d(t,{GM:()=>c,mS:()=>o,ol:()=>n});var a=i(134),r=i(38743);i(95335),i(34677);const s={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(e,t){e&&e.forEach((e=>{const i=e.split("=");if(2===i.length){const e=i[0].trim().toLowerCase(),a=i[1].trim();s[e]?t[s[e]]=a:t[e.toLowerCase()]=a}}))}class o{constructor(e="vorbis"){(0,a.A)(this,"streamIndex",void 0),(0,a.A)(this,"packetType",void 0),(0,a.A)(this,"signature",void 0),(0,a.A)(this,"version",void 0),(0,a.A)(this,"channels",void 0),(0,a.A)(this,"sampleRate",void 0),(0,a.A)(this,"bitrateMaximum",void 0),(0,a.A)(this,"bitrateNominal",void 0),(0,a.A)(this,"bitrateMinimum",void 0),(0,a.A)(this,"blocksize0",void 0),(0,a.A)(this,"blocksize1",void 0),(0,a.A)(this,"framingFlag",void 0),this.signature=e,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(e){this.packetType=e.readUint8(),this.signature=e.readString(6),this.version=e.readUint32(),this.channels=e.readUint8(),this.sampleRate=e.readInt32(),this.bitrateMaximum=e.readInt32(),this.bitrateNominal=e.readInt32(),this.bitrateMinimum=e.readInt32();const t=255&e.readUint8();this.blocksize0=Math.pow(2,t>>>4),this.blocksize1=Math.pow(2,15&t),this.framingFlag=e.readUint8()}write(e){e.writeUint8(1),e.writeString(this.signature),e.writeUint32(this.version),e.writeUint8(this.channels),e.writeInt32(this.sampleRate),e.writeInt32(this.bitrateMaximum),e.writeInt32(this.bitrateNominal),e.writeInt32(this.bitrateMinimum),e.writeUint8(Math.log2(this.blocksize0)<<4|Math.log2(this.blocksize1)),e.writeUint8(1)}setCodec(e){this.sampleRate=e.sampleRate,this.channels=e.chLayout.nbChannels}}class c extends r.h{constructor(e="vorbis"){super(),(0,a.A)(this,"packetType",void 0),(0,a.A)(this,"framingFlag",void 0),this.signature=e,this.packetType=1,this.framingFlag=1}read(e){this.packetType=e.readUint8(),this.signature=e.readString(6),super.read(e),"vorbis"===this.signature&&(this.framingFlag=e.readUint8())}write(e){e.writeUint8(this.packetType),e.writeString(this.signature),super.write(e),"vorbis"===this.signature&&e.writeUint8(this.framingFlag)}addComment(e){this.comments.addComment(e)}setCodec(e){}}},2187:(e,t,i)=>{i.d(t,{d:()=>n});var a=i(72739),r=i(44328),s=i(77231);function n(e,t,i){let n=BigInt(0);return a.__(e,(e=>{n+=e.codecpar.bitrate*(0,r.k)(t,i,s.i0)/BigInt(8e3)})),n}},52071:(e,t,i)=>{i.d(t,{A:()=>m});var a=i(63939),r=(i(9599),i(77231)),s=i(44328),n=i(2187),o=i(71517),c=i(9705),h=i(4624);const d="src/avformat/function/seekInBytes.ts";async function m(e,t,i,m,f,l){const u=e.ioReader.getPos(),p=await e.ioReader.fileSize();let g=r.Dh,w=i;t.startTime!==r.Dh?w-=t.startTime:w-=t.firstDTS;const x=(0,s.k)(i,t.timeBase,r.i0);if(x<BigInt(1e4))return h.Yz(`seek pts is earlier then 10s, seek to first packet pos(${m}) directly`,d,62),await e.ioReader.seek(m),u;let R=(0,n.d)(e.streams,w,t.timeBase);const B=p-(0,n.d)(e.streams,BigInt(1e4),r.i0),b=(0,n.d)(e.streams,BigInt(1e4),r.i0);if(R>B&&(R=B),R<m)return await e.ioReader.seek(m),u;const S=(0,o._5)();let I=p,k=BigInt(0);for(;;){if(I-k<b){g=k;break}if(await e.ioReader.seek(R),await l(e),8&e.ioReader.flags)break;const t=e.ioReader.getPos();if(!(await f(e,S)>=0)){g=r.Dh;break}{const e=(0,s.Mr)(a.f[17](S+8),S+72,r.i0),i=e-x;if(h.Yz(`try to seek to pos: ${R}, got packet pts: ${a.f[17](S+8)}(${e}ms), diff: ${i}ms`,d,100),i<=BigInt(0)&&-i<BigInt(1e4)){g=t;break}i>BigInt(0)?(I=R,R=k+I>>BigInt(1)):(k=R,R=k+I>>BigInt(1))}if(8&e.ioReader.flags)break}return(0,o.Qe)(S),g!==r.Dh?(h.Yz(`finally seek to pos ${g}`,d,131),await e.ioReader.seek(g),await l(e),u):(await e.ioReader.seek(u),8&e.ioReader.flags?BigInt(c.LT):BigInt(c.E$))}},14769:(e,t,i)=>{i.d(t,{DK:()=>o,XC:()=>h,Xr:()=>c,jA:()=>s,ob:()=>r,oe:()=>n});var a=i(31865);const r=34,s=8,n=[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],c=[0,192,576,1152,2304,4608,0,0,256,512,1024,2048,4096,8192,16384,32768];function h(e,t){if(!t&&e.sideData[1]&&(t=e.sideData[1]),t&&t.length===r){const{bitsPerRawSample:i,sampleRate:r,channels:s}=function(e){const t=new a.A(e);t.skip(10);const i=t.readUint24();return{sampleRate:i>>4,channels:1+((15&i)>>>1),bitsPerRawSample:1+((1&i)<<4|(240&t.readUint8())>>>4)}}(t);e.codecpar.bitsPerRawSample=i,e.codecpar.sampleRate=r,e.codecpar.chLayout.nbChannels=s}}},13188:(e,t,i)=>{function a(e,t=0){for(let i=0;i<e.length;i++){t^=e[i];for(let e=0;e<8;e++)128&t?t=t<<1^7:t<<=1}return 255&t}i.d(t,{A:()=>a})}}]);
1
+ (self.webpackChunklibmedia=self.webpackChunklibmedia||[]).push([[453],{18453:(e,t,i)=>{i.r(t),i.d(t,{default:()=>S});var a=i(134),r=i(63939),s=i(50932),n=i(4624),o=i(9705),c=i(85947),h=i(14686),d=i(37837),m=i(71517),f=i(91375),l=i(37246),u=i(92647),p=i(77231),g=i(52071),w=i(72739),x=i(44328),R=i(87400);const B="src/avformat/formats/IFlacFormat.ts",b=1024;class S extends c.A{constructor(){super(),(0,a.A)(this,"type",17),(0,a.A)(this,"context",void 0)}init(e){e.ioReader.setEndian(!0),this.context={streamInfo:{minimumBlockSize:0,maximumBlockSize:0,minimumFrameSize:0,maximumFrameSize:0,sampleRate:0,channels:0,bitPerSample:0,samples:BigInt(0),md5:""},frameInfo:{sampleRate:0,channels:0,bps:0,blocksize:0,chMode:0,frameOrSampleNum:BigInt(0),isVarSize:0},seekPoints:[],cueSheet:{catalogNumber:"",leadInSamples:BigInt(0),compactDisc:!1,tracks:[]},picture:{type:0,mimeType:"",description:"",width:0,height:0,colorDepth:0,indexedColor:0,data:null},cacheBuffer:null,cachePos:BigInt(0),bitReader:new l.A(16),fileSize:BigInt(0),firstFramePos:BigInt(0),isVarSize:-1}}async readHeader(e){if("fLaC"!==await e.ioReader.readString(4))return n.z3("the file format is not flac",B,118),o.LR;this.context.fileSize=await e.ioReader.fileSize();const t=e.createStream();for(t.codecpar.codecType=1,t.codecpar.codecId=86028;;){const i=await e.ioReader.readUint8(),a=await e.ioReader.readUint24(),r=-129&i;if(0===r){t.codecpar.extradata=(0,d.sY)(a),t.codecpar.extradataSize=a,(0,h.lW)(t.codecpar.extradata,a,await e.ioReader.peekBuffer(a)),this.context.streamInfo.minimumBlockSize=await e.ioReader.readUint16(),this.context.streamInfo.maximumBlockSize=await e.ioReader.readUint16(),this.context.streamInfo.minimumFrameSize=await e.ioReader.readUint24(),this.context.streamInfo.maximumFrameSize=await e.ioReader.readUint24();const i=await e.ioReader.readUint24();t.codecpar.sampleRate=i>>4,t.codecpar.chLayout.nbChannels=1+((15&i)>>>1),this.context.streamInfo.sampleRate=t.codecpar.sampleRate,this.context.streamInfo.channels=t.codecpar.chLayout.nbChannels;const r=await e.ioReader.readUint8();t.codecpar.bitsPerRawSample=1+((1&i)<<4|(240&r)>>>4),this.context.streamInfo.bitPerSample=t.codecpar.bitsPerRawSample;const s=await e.ioReader.readUint32(),n=BigInt(Math.floor(15&r))<<BigInt(32)|BigInt(Math.floor(s));this.context.streamInfo.samples=n,t.timeBase.den=t.codecpar.sampleRate,t.timeBase.num=1,t.duration=n,t.startTime=BigInt(0),this.context.streamInfo.md5=await e.ioReader.readString(16)}else if(2===r){const t=e.createStream();t.codecpar.codecType=2,t.codecpar.codecTag=await e.ioReader.readUint32(),t.codecpar.extradata=(0,d.sY)(a-4),t.codecpar.extradataSize=a-4,await e.ioReader.readBuffer(a-4,(0,h.JW)(t.codecpar.extradata,t.codecpar.extradataSize))}else if(3===r)for(let t=0;t<a/18;t++){const t=await e.ioReader.readUint64(),i=await e.ioReader.readUint64(),a=await e.ioReader.readUint16();this.context.seekPoints.push({pts:t,pos:i,samples:a})}else if(4===r){e.ioReader.setEndian(!1);const i=await e.ioReader.readUint32(),a=await e.ioReader.readString(i),r=await e.ioReader.readUint32(),s=[];for(let t=0;t<r;t++){const t=await e.ioReader.readUint32();s.push(await e.ioReader.readString(t))}t.metadata.vendor=a,(0,R.ol)(s,t.metadata),e.ioReader.setEndian(!0)}else if(5===r){this.context.cueSheet.catalogNumber=await e.ioReader.readString(128),this.context.cueSheet.leadInSamples=await e.ioReader.readUint64(),this.context.cueSheet.compactDisc=!!(await e.ioReader.readUint8()>>>7),await e.ioReader.skip(258);const t=await e.ioReader.readUint8();for(let i=0;i<t;i++){const t=await e.ioReader.readUint64(),i=await e.ioReader.readUint8(),a=await e.ioReader.readBuffer(12),r=await e.ioReader.readUint8();await e.ioReader.skip(13);const s=await e.ioReader.readUint8(),n=[];for(let t=0;t<s;t++)n.push({offset:await e.ioReader.readUint64(),point:await e.ioReader.readUint8()}),await e.ioReader.skip(3);this.context.cueSheet.tracks.push({offset:t,number:i,isrc:a,type:r>>>7,preEmphasisFlag:r>>>6&1,points:n})}}else if(6===r){this.context.picture.type=await e.ioReader.readUint32();let t=await e.ioReader.readUint32();this.context.picture.mimeType=await e.ioReader.readString(t),t=await e.ioReader.readUint32(),this.context.picture.description=await e.ioReader.readString(t),this.context.picture.width=await e.ioReader.readUint32(),this.context.picture.height=await e.ioReader.readUint32(),this.context.picture.colorDepth=await e.ioReader.readUint32(),this.context.picture.indexedColor=await e.ioReader.readUint32(),t=await e.ioReader.readUint32(),this.context.picture.data=await e.ioReader.readBuffer(t)}else await e.ioReader.skip(a);if(128&i)break}return this.context.firstFramePos=e.ioReader.getPos(),t.privData=this.context,0}async getNextFrame(e){const t=[];for(;;){if(e.ioReader.getPos()===this.context.fileSize){this.context.cacheBuffer&&(t.push(this.context.cacheBuffer),this.context.cacheBuffer=null);break}this.context.cacheBuffer?this.context.cacheBuffer.length<17&&(this.context.cacheBuffer=(0,u.A)(Uint8Array,[this.context.cacheBuffer,await e.ioReader.readBuffer(Math.min(b,Number(BigInt.asIntN(32,this.context.fileSize-e.ioReader.getPos()))))])):(this.context.cachePos=e.ioReader.getPos(),this.context.cacheBuffer=await e.ioReader.readBuffer(Math.min(b,Number(BigInt.asIntN(32,this.context.fileSize-e.ioReader.getPos())))));let i=t.length?0:2;const a=this.context.isVarSize<0?[248,249]:this.context.isVarSize?[249]:[248],r=this.context.cacheBuffer.length-2;for(;i<r;i++)if(255===this.context.cacheBuffer[i]&&w.zy(a,this.context.cacheBuffer[i+1])){i&&(t.push(this.context.cacheBuffer.subarray(0,i)),this.context.cacheBuffer=this.context.cacheBuffer.subarray(i),this.context.cachePos+=BigInt(Math.floor(i)));break}if(i===r){e.ioReader.getPos()===this.context.fileSize?(t.push(this.context.cacheBuffer),this.context.cachePos+=BigInt(Math.floor(this.context.cacheBuffer.length)),this.context.cacheBuffer=null):(t.push(this.context.cacheBuffer.subarray(0,i)),this.context.cachePos+=BigInt(Math.floor(i)),this.context.cacheBuffer=this.context.cacheBuffer.subarray(i));continue}this.context.cacheBuffer.length<16&&(this.context.cacheBuffer=(0,u.A)(Uint8Array,[this.context.cacheBuffer,await e.ioReader.readBuffer(Math.min(b,Number(BigInt.asIntN(32,this.context.fileSize-e.ioReader.getPos()))))])),this.context.bitReader.reset(),this.context.bitReader.appendBuffer(this.context.cacheBuffer.subarray(0,16));const s={};if(!((0,f.x)(this.context.bitReader,s,!0)<0||s.frameOrSampleNum-this.context.frameInfo.frameOrSampleNum!==BigInt(0|this.context.frameInfo.blocksize)&&s.frameOrSampleNum!==this.context.frameInfo.frameOrSampleNum+BigInt(1)))break;t.push(this.context.cacheBuffer.subarray(0,2)),this.context.cachePos+=BigInt(2),this.context.cacheBuffer=this.context.cacheBuffer.subarray(2)}return 1===t.length?t[0]:(0,u.A)(Uint8Array,t)}async readAVPacket(e,t){const i=e.streams.find((e=>e.codecpar.codecType=1));try{let a=e.ioReader.getPos();if(a===this.context.fileSize)return-1048576;if(this.context.bitReader.reset(),this.context.cacheBuffer?(a=this.context.cachePos,this.context.cacheBuffer.length<16&&(this.context.cacheBuffer=(0,u.A)(Uint8Array,[this.context.cacheBuffer,await e.ioReader.readBuffer(Math.min(b,Number(BigInt.asIntN(32,this.context.fileSize-e.ioReader.getPos()))))])),this.context.bitReader.appendBuffer(this.context.cacheBuffer.subarray(0,16))):this.context.bitReader.appendBuffer(await e.ioReader.peekBuffer(16)),(0,f.x)(this.context.bitReader,this.context.frameInfo)<0)return o.LR;const n=await this.getNextFrame(e),c=(0,d.sY)(n.length);return(0,h.lW)(c,n.length,n),(0,m.NX)(t,c,n.length),s.M[17](t+56,a),s.M[15](t+32,i.index),s.M[15](t+76,i.timeBase.den),s.M[15](t+72,i.timeBase.num),s.M[15](t+36,1|r.f[15](t+36)),s.M[17](t+16,this.context.frameInfo.isVarSize?this.context.frameInfo.frameOrSampleNum:this.context.frameInfo.frameOrSampleNum*BigInt(0|this.context.frameInfo.blocksize)),s.M[17](t+8,this.context.frameInfo.isVarSize?this.context.frameInfo.frameOrSampleNum:this.context.frameInfo.frameOrSampleNum*BigInt(0|this.context.frameInfo.blocksize)),this.context.isVarSize<0&&(this.context.isVarSize=this.context.frameInfo.isVarSize),0}catch(t){return-1048576!==e.ioReader.error&&-1048572!==e.ioReader.error?(n.z3(`read packet error, ${t}`,B,418),o.LR):e.ioReader.error}}async syncFrame(e){let t=p.Dh;for(;;)try{const i=await e.ioReader.peekUint16();if((65529===i||65528===i)&&(t=e.ioReader.getPos(),this.context.bitReader.reset(),this.context.bitReader.appendBuffer(await e.ioReader.peekBuffer(16)),!(0,f.x)(this.context.bitReader,{},!0)))break;await e.ioReader.skip(1)}catch(e){break}t!==p.Dh&&await e.ioReader.seek(t)}async seek(e,t,i,a){const r=e.ioReader.getPos(),s=t.privData;if(2&a){const t=await e.ioReader.fileSize();return t<=BigInt(0)?BigInt(o.E$):(i<BigInt(0)?i=BigInt(0):i>t&&(i=t),await e.ioReader.seek(i),4&a||await this.syncFrame(e),r)}if(t&&t.sampleIndexes.length){let a=w.El(t.sampleIndexes,(e=>e.pts>i?-1:1));if(a>0&&(0,x.k)(i-t.sampleIndexes[a-1].pts,t.timeBase,p.i0)<BigInt(5e3))return n.Yz(`seek in sampleIndexes, found index: ${a}, pts: ${t.sampleIndexes[a-1].pts}, pos: ${t.sampleIndexes[a-1].pos}`,B,485),await e.ioReader.seek(t.sampleIndexes[a-1].pos),s.cacheBuffer=null,r}if(s.seekPoints.length){let t=0;for(let e=0;e<s.seekPoints.length;e++){if(s.seekPoints[e].pts===i){t=e;break}if(s.seekPoints[e].pts>i){t=Math.max(e-1,0);break}}const a=s.seekPoints[t];return n.Yz(`seek in seekPoints, found index: ${t}, pts: ${a.pts}, pos: ${a.pos+s.firstFramePos}`,B,505),await e.ioReader.seek(a.pos+s.firstFramePos),s.cacheBuffer=null,r}n.Yz("not found any keyframe index, try to seek in bytes",B,511);const c=await(0,g.A)(e,t,i,s.firstFramePos,this.readAVPacket.bind(this),this.syncFrame.bind(this));return c>0&&(s.cacheBuffer=null),c}getAnalyzeStreamsCount(){return 1}}},85947:(e,t,i)=>{i.d(t,{A:()=>r});var a=i(134);class r{constructor(){(0,a.A)(this,"type",-1),(0,a.A)(this,"onStreamAdd",void 0)}async destroy(e){}}},91375:(e,t,i)=>{i.d(t,{x:()=>c});var a=i(9705),r=i(4624),s=i(14769),n=i(13188);const o="src/avformat/formats/flac/iflac.ts";function c(e,t,i=!1){const c=e.getPointer();if(32764!=(32767&e.readU(15)))return!i&&r.z3("invalid sync code",o,57),a.LR;t.isVarSize=e.readU1();const h=e.readU(4),d=e.readU(4);if(t.chMode=e.readU(4),t.chMode<s.jA)t.channels=t.chMode+1,t.chMode=0;else{if(!(t.chMode<s.jA+3))return!i&&r.z3(`invalid channel mode: ${t.chMode}`,o,76),a.LR;t.channels=2,t.chMode-=s.jA-1}const m=e.readU(3);if(3===m)return!i&&r.z3(`invalid sample size code: ${m}`,o,82),a.LR;if(t.bps=s.oe[m],e.readU1())return!i&&r.z3("broken stream, invalid padding",o,88),a.LR;if(t.frameOrSampleNum=function(e){let t=BigInt(Math.floor(e.readU(8))),i=(t&BigInt(128))>>BigInt(1);if((t&BigInt(192))===BigInt(128)||t>=BigInt(254))return-BigInt(1);for(;t&i;){const a=BigInt(Math.floor(e.readU(8)))-BigInt(128);if(a>>BigInt(6))return-BigInt(1);t=(t<<BigInt(6))+a,i<<=BigInt(5)}return t&=(i<<BigInt(1))-BigInt(1),t}(e),t.frameOrSampleNum<0)return!i&&r.z3("sample/frame number invalid",o,95),a.LR;if(0===h)return!i&&r.z3("reserved blocksize code: 0",o,100),a.LR;if(t.blocksize=6===h?e.readU(8)+1:7===h?e.readU(16)+1:s.Xr[h],d<12)t.sampleRate=s.DK[d];else if(12===d)t.sampleRate=1e3*e.readU(8);else if(13===d)t.sampleRate=e.readU(16);else{if(14!==d)return!i&&r.z3(`illegal sample rate code ${d}`,o,126),a.LR;t.sampleRate=10*e.readU(16)}return(0,n.A)(e.getBuffer().subarray(c,e.getPointer()))!==e.readU(8)?(!i&&r.z3("header crc mismatch",o,133),a.LR):0}},38743:(e,t,i)=>{i.d(t,{B:()=>o,h:()=>c});var a=i(134),r=i(77231),s=i(50011);class n{constructor(){(0,a.A)(this,"list",void 0),this.list=[]}read(e,t){for(let i=0;i<t;i++){const t=e.readUint32();this.list.push(e.readString(t))}}write(e){for(let t=0;t<this.list.length;t++){const i=s.encode(this.list[t]);e.writeUint32(i.length),e.writeBuffer(i)}}addComment(e){this.list.push(e)}}class o{constructor(){(0,a.A)(this,"capturePattern",void 0),(0,a.A)(this,"streamStructureVersion",void 0),(0,a.A)(this,"headerTypeFlag",void 0),(0,a.A)(this,"granulePosition",void 0),(0,a.A)(this,"serialNumber",void 0),(0,a.A)(this,"pageSequenceNumber",void 0),(0,a.A)(this,"crcCheckSum",void 0),(0,a.A)(this,"numberPageSegments",void 0),(0,a.A)(this,"segmentTable",void 0),(0,a.A)(this,"payload",void 0),(0,a.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(e){this.pos=e.getPos(),await this.readPageHeader(e);const t=this.segmentTable.reduce(((e,t)=>e+t),0);t&&(this.payload=await e.readBuffer(t))}async readPageHeader(e){if(this.capturePattern=await e.readString(4),this.streamStructureVersion=await e.readUint8(),this.headerTypeFlag=await e.readUint8(),this.granulePosition=await e.readUint64(),this.serialNumber=await e.readUint32(),this.pageSequenceNumber=await e.readUint32(),this.crcCheckSum=await e.readUint32(),this.numberPageSegments=await e.readUint8(),this.numberPageSegments)for(let t=0;t<this.numberPageSegments;t++){const t=await e.readUint8();this.segmentTable.push(t)}}write(e){if(this.pos=e.getPos(),e.writeString(this.capturePattern),e.writeUint8(this.streamStructureVersion),e.writeUint8(this.headerTypeFlag),e.writeUint64(this.granulePosition),e.writeUint32(this.serialNumber),e.writeUint32(this.pageSequenceNumber),e.writeUint32(this.crcCheckSum),this.payload){this.numberPageSegments=Math.floor(this.payload.length/255)+1;const t=this.payload.length%255;e.writeUint8(this.numberPageSegments);for(let t=0;t<this.numberPageSegments-1;t++)e.writeUint8(255);e.writeUint8(t),e.writeBuffer(this.payload)}else e.writeUint8(0)}}class c{constructor(){(0,a.A)(this,"streamIndex",void 0),(0,a.A)(this,"signature",void 0),(0,a.A)(this,"vendorStringLength",void 0),(0,a.A)(this,"vendorString",void 0),(0,a.A)(this,"userCommentListLength",void 0),(0,a.A)(this,"comments",void 0),this.vendorString="v0.10.0",this.vendorStringLength=this.vendorString.length,this.userCommentListLength=0,this.comments=new n}read(e){this.vendorStringLength=e.readUint32(),this.vendorString=e.readString(this.vendorStringLength),this.userCommentListLength=e.readUint32(),this.userCommentListLength&&this.comments.read(e,this.userCommentListLength)}write(e){const t=s.encode(this.vendorString);e.writeUint32(t.length),e.writeBuffer(t),e.writeUint32(this.comments.list.length),this.comments.write(e)}addComment(e){this.comments.addComment(e)}setCodec(e){}}},87400:(e,t,i)=>{i.d(t,{GM:()=>c,mS:()=>o,ol:()=>n});var a=i(134),r=i(38743);i(95335),i(34677);const s={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(e,t){e&&e.forEach((e=>{const i=e.split("=");if(2===i.length){const e=i[0].trim().toLowerCase(),a=i[1].trim();s[e]?t[s[e]]=a:t[e.toLowerCase()]=a}}))}class o{constructor(e="vorbis"){(0,a.A)(this,"streamIndex",void 0),(0,a.A)(this,"packetType",void 0),(0,a.A)(this,"signature",void 0),(0,a.A)(this,"version",void 0),(0,a.A)(this,"channels",void 0),(0,a.A)(this,"sampleRate",void 0),(0,a.A)(this,"bitrateMaximum",void 0),(0,a.A)(this,"bitrateNominal",void 0),(0,a.A)(this,"bitrateMinimum",void 0),(0,a.A)(this,"blocksize0",void 0),(0,a.A)(this,"blocksize1",void 0),(0,a.A)(this,"framingFlag",void 0),this.signature=e,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(e){this.packetType=e.readUint8(),this.signature=e.readString(6),this.version=e.readUint32(),this.channels=e.readUint8(),this.sampleRate=e.readInt32(),this.bitrateMaximum=e.readInt32(),this.bitrateNominal=e.readInt32(),this.bitrateMinimum=e.readInt32();const t=255&e.readUint8();this.blocksize0=Math.pow(2,t>>>4),this.blocksize1=Math.pow(2,15&t),this.framingFlag=e.readUint8()}write(e){e.writeUint8(1),e.writeString(this.signature),e.writeUint32(this.version),e.writeUint8(this.channels),e.writeInt32(this.sampleRate),e.writeInt32(this.bitrateMaximum),e.writeInt32(this.bitrateNominal),e.writeInt32(this.bitrateMinimum),e.writeUint8(Math.log2(this.blocksize0)<<4|Math.log2(this.blocksize1)),e.writeUint8(1)}setCodec(e){this.sampleRate=e.sampleRate,this.channels=e.chLayout.nbChannels}}class c extends r.h{constructor(e="vorbis"){super(),(0,a.A)(this,"packetType",void 0),(0,a.A)(this,"framingFlag",void 0),this.signature=e,this.packetType=1,this.framingFlag=1}read(e){this.packetType=e.readUint8(),this.signature=e.readString(6),super.read(e),"vorbis"===this.signature&&(this.framingFlag=e.readUint8())}write(e){e.writeUint8(this.packetType),e.writeString(this.signature),super.write(e),"vorbis"===this.signature&&e.writeUint8(this.framingFlag)}addComment(e){this.comments.addComment(e)}setCodec(e){}}},2187:(e,t,i)=>{i.d(t,{d:()=>n});var a=i(72739),r=i(44328),s=i(77231);function n(e,t,i){let n=BigInt(0);return a.__(e,(e=>{n+=e.codecpar.bitrate*(0,r.k)(t,i,s.i0)/BigInt(8e3)})),n}},52071:(e,t,i)=>{i.d(t,{A:()=>m});var a=i(63939),r=(i(9599),i(77231)),s=i(44328),n=i(2187),o=i(71517),c=i(9705),h=i(4624);const d="src/avformat/function/seekInBytes.ts";async function m(e,t,i,m,f,l){const u=e.ioReader.getPos(),p=await e.ioReader.fileSize();let g=r.Dh,w=i;t.startTime!==r.Dh?w-=t.startTime:w-=t.firstDTS;const x=(0,s.k)(i,t.timeBase,r.i0);if(x<BigInt(1e4))return h.Yz(`seek pts is earlier then 10s, seek to first packet pos(${m}) directly`,d,63),await e.ioReader.seek(m),u;let R=(0,n.d)(e.streams,w,t.timeBase);const B=p-(0,n.d)(e.streams,BigInt(1e4),r.i0),b=(0,n.d)(e.streams,BigInt(1e4),r.i0);if(R>B&&(R=B),R<m)return await e.ioReader.seek(m),u;const S=(0,o._5)();let I=p,k=BigInt(0);e:for(;I-k<b&&(R=k),await e.ioReader.seek(R),await l(e),!(8&e.ioReader.flags);){let i=await f(e,S),n=a.f[17](S+56);if(!(i>=0)){g=r.Dh;break}{const c=(0,s.Mr)(a.f[17](S+8),S+72,r.i0);let m=c-x;if(h.Yz(`try to seek to pos: ${R}, got packet pts: ${a.f[17](S+8)}(${c}ms), diff: ${m}ms`,d,100),m<=BigInt(0)&&-m<BigInt(1e4)||I-k<b){const c=[n];for(;m<=0;){if(a.f[15](S+32)===t.index&&1&a.f[15](S+36)&&c.push(n),(0,o.Up)(S),i=await f(e,S),i<0){if(-1048576===i)break;if(-1048575===i)continue;g=r.Dh;break e}n=a.f[17](S+56),m=(0,s.Mr)(a.f[17](S+8),S+72,r.i0)-x}g=c.pop();break}m>BigInt(0)?(I=R,R=k+I>>BigInt(1)):(k=R,R=k+I>>BigInt(1))}if(8&e.ioReader.flags)break}return(0,o.Qe)(S),g!==r.Dh?(h.Yz(`finally seek to pos ${g}`,d,155),await e.ioReader.seek(g),await l(e),u):(await e.ioReader.seek(u),8&e.ioReader.flags?BigInt(c.LT):BigInt(c.E$))}},14769:(e,t,i)=>{i.d(t,{DK:()=>o,XC:()=>h,Xr:()=>c,jA:()=>s,ob:()=>r,oe:()=>n});var a=i(31865);const r=34,s=8,n=[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],c=[0,192,576,1152,2304,4608,0,0,256,512,1024,2048,4096,8192,16384,32768];function h(e,t){if(!t&&e.sideData[1]&&(t=e.sideData[1]),t&&t.length===r){const{bitsPerRawSample:i,sampleRate:r,channels:s}=function(e){const t=new a.A(e);t.skip(10);const i=t.readUint24();return{sampleRate:i>>4,channels:1+((15&i)>>>1),bitsPerRawSample:1+((1&i)<<4|(240&t.readUint8())>>>4)}}(t);e.codecpar.bitsPerRawSample=i,e.codecpar.sampleRate=r,e.codecpar.chLayout.nbChannels=s}}},13188:(e,t,i)=>{function a(e,t=0){for(let i=0;i<e.length;i++){t^=e[i];for(let e=0;e<8;e++)128&t?t=t<<1^7:t<<=1}return 255&t}i.d(t,{A:()=>a})}}]);
@@ -1 +1 @@
1
- (self.webpackChunklibmedia=self.webpackChunklibmedia||[]).push([[487],{85947:(t,e,s)=>{s.d(e,{A:()=>h});var i=s(134);class h{constructor(){(0,i.A)(this,"type",-1),(0,i.A)(this,"onStreamAdd",void 0)}async destroy(t){}}},85487:(t,e,s)=>{s.r(e),s.d(e,{default:()=>v});var i=s(134),h=s(63939),r=s(50932),a=s(9705),n=s(85947),o=s(14686),u=s(37837),d=s(71517),c=s(95335),p=s(92647),l=s(67659),f=s(77231),g=s(37246),b=s(23991),A=s(37805);const y={framerate:{num:30,den:1}};class v extends n.A{constructor(t={}){super(),(0,i.A)(this,"type",12),(0,i.A)(this,"options",void 0),(0,i.A)(this,"currentDts",void 0),(0,i.A)(this,"currentPts",void 0),(0,i.A)(this,"step",void 0),(0,i.A)(this,"slices",void 0),(0,i.A)(this,"naluPos",void 0),(0,i.A)(this,"queue",void 0),(0,i.A)(this,"bitReader",void 0),(0,i.A)(this,"sliceType",void 0),(0,i.A)(this,"poc",void 0),(0,i.A)(this,"pocTid0",void 0),(0,i.A)(this,"sps",void 0),(0,i.A)(this,"pps",void 0),(0,i.A)(this,"naluReader",void 0),this.options=c.X$({},y,t)}init(t){t.ioReader&&t.ioReader.setEndian(!1),this.slices=[],this.queue=[],this.bitReader=new g.A(50),this.naluReader=new A.A}async destroy(t){if(this.queue.length){for(let t=0;t<this.queue.length;t++)(0,d.Qe)(this.queue[t].avpacket);this.queue.length=0}}isFrameNalu(t){return(t[1===t[2]?3:4]>>>1&63)<32}async readNaluFrame(t){let e=!1;const s=this.slices;for(this.slices=[],s.length&&(e=this.isFrameNalu(s[0]));;){const i=await this.naluReader.read(t.ioReader);if(!i)return s;const h=i[1===i[2]?3:4]>>>1&63;if(this.isFrameNalu(i))if(e){if(i[1===i[2]?5:6]>>>7)return this.slices.push(i),s;s.push(i)}else s.push(i),e=!0;else{if(e&&(35===h||33===h||34===h||32===h))return this.slices.push(i),s;s.push(i)}}}async readHeader(t){const e=t.createStream();for(e.codecpar.codecType=0,e.codecpar.codecId=173,e.timeBase.den=f.SF,e.timeBase.num=1,e.codecpar.bitFormat=2,this.currentDts=BigInt(0),this.currentPts=BigInt(0),this.naluPos=BigInt(0),this.poc=0,this.pocTid0=0,this.step=BigInt(Math.floor(f.SF/this.options.framerate.num*this.options.framerate.den));;){const s=await this.readNaluFrame(t);if(!s.length)return-1048576;const i=(0,p.A)(Uint8Array,s),a=l.sL(i);if(a){e.codecpar.extradata=(0,u.sY)(a.length),(0,o.lW)(e.codecpar.extradata,a.length,a),e.codecpar.extradataSize=a.length,l.XC(e,a);const n=s.find((t=>33==(t[1===t[2]?3:4]>>>1&63))),c=s.find((t=>34==(t[1===t[2]?3:4]>>>1&63)));this.sps=l.wf(n),this.pps=l.ZU(c);const p=(0,d._5)(),f=(0,u.sY)(i.length);(0,o.lW)(f,i.length,i),(0,d.NX)(p,f,i.length),r.M[17](p+56,this.naluPos),this.naluPos+=BigInt(Math.floor(i.length)),r.M[17](p+16,this.currentDts),this.currentDts+=this.step,r.M[17](p+8,this.currentPts),this.currentPts+=this.step,r.M[15](p+32,e.index),r.M[15](p+36,1|h.f[15](p+36)),r.M[15](p+72,e.timeBase.num),r.M[15](p+76,e.timeBase.den),r.M[15](p+80,2),t.interval.packetBuffer.push(p);break}this.naluPos+=BigInt(Math.floor(i.length))}return 0}async readAVPacket_(t,e){const s=t.getStreamByMediaType(0),i=await this.readNaluFrame(t);if(!i.length)return-1048576;this.sliceType=-1;let a=!1,n=!0;i.forEach((t=>{const e=(1===t[2]?t[3]:t[4])>>>1&63,s=7&(1===t[2]?t[4]:t[5]);if(33===e&&(this.sps=l.wf(t)),34===e&&(this.pps=l.ZU(t)),19!==e&&20!==e||(a=!0),e<32&&n){n=!1,this.bitReader.reset(),this.bitReader.appendBuffer(t.subarray(1===t[2]?5:6,50));const i=this.bitReader.readU1();if(e>=16&&e<=23&&(a=!0,this.bitReader.readU1()),b.xb(this.bitReader),!i){this.pps.dependent_slice_segment_flag&&this.bitReader.readU1();const t=Math.ceil(Math.log2(this.sps.ctb_width*this.sps.ctb_height));this.bitReader.readU(t)}for(let t=0;t<this.pps.num_extra_slice_header_bits;t++)this.bitReader.readU1();if(this.sliceType=b.xb(this.bitReader),this.pps.output_flag_present_flag&&this.bitReader.readU1(),this.sps.separate_colour_plane_flag&&this.bitReader.readU(2),19===e||20===e)this.poc=0;else{const t=this.bitReader.readU(this.sps.log2_max_poc_lsb);let s=1<<this.sps.log2_max_poc_lsb,i=this.pocTid0%s,h=this.pocTid0-i,r=0;r=t<i&&i-t>=s/2?h+s:t>i&&t-i>s/2?h-s:h,16!=e&&17!=e&&18!=e||(r=0),this.poc=r+t}0==s&&0!=e&&2!=e&&4!=e&&6!=e&&8!=e&&7!=e&&9!=e&&(this.pocTid0=this.poc)}}));const c=(0,p.A)(Uint8Array,i),f=(0,u.sY)(c.length);return(0,o.lW)(f,c.length,c),(0,d.NX)(e,f,c.length),r.M[17](e+56,this.naluPos),this.naluPos+=BigInt(Math.floor(c.length)),r.M[17](e+16,this.currentDts),this.currentDts+=this.step,r.M[15](e+32,s.index),r.M[15](e+72,s.timeBase.num),r.M[15](e+76,s.timeBase.den),r.M[15](e+80,2),a&&r.M[15](e+36,1|h.f[15](e+36)),0}async readAVPacket(t,e){let s=this.queue.length;const i=()=>{this.queue.length>1&&this.queue.sort(((t,e)=>t.poc-e.poc>0?1:-1));for(let t=0;t<this.queue.length;t++)r.M[17](this.queue[t].avpacket+8,this.currentPts),this.currentPts+=this.step;this.queue.length>1&&this.queue.sort(((t,e)=>h.f[17](t.avpacket+16)-h.f[17](e.avpacket+16)>BigInt(0)?1:-1)),this.queue.length&&((0,d.rN)(e,this.queue[0].avpacket),(0,d.Qe)(this.queue[0].avpacket));for(let e=1;e<this.queue.length;e++)t.interval.packetBuffer.push(this.queue[e].avpacket);this.queue.length=0};for(;;){const e=(0,d._5)();let r=await this.readAVPacket_(t,e);if(r<0)return(0,d.Qe)(e),this.queue.length?(i(),0):r;if(1&h.f[15](e+36)||1===this.sliceType||2===this.sliceType){if(1===s||1&h.f[15](e+36)&&this.queue.length)return i(),this.queue.push({avpacket:e,poc:this.poc}),0;this.queue.push({avpacket:e,poc:this.poc}),s++}else this.queue.push({avpacket:e,poc:this.poc})}}async seek(t,e,s,i){return BigInt(a.E$)}getAnalyzeStreamsCount(){return 1}}},37805:(t,e,s)=>{s.d(e,{A:()=>a});var i=s(134),h=s(60264),r=s(92647);class a{constructor(){(0,i.A)(this,"buffer",void 0),(0,i.A)(this,"pos",void 0),(0,i.A)(this,"end",void 0),(0,i.A)(this,"ended",void 0),this.buffer=new Uint8Array(102400),this.pos=0,this.end=0,this.ended=!1}async read(t){if(this.ended&&this.pos>=this.end)return;const e=[];if(this.pos<this.end-4){let t=h.Ky(this.buffer.subarray(this.pos,this.end-4),3);if(t.offset>-1){const e=this.buffer.slice(this.pos,this.pos+t.offset);return this.pos+=t.offset,e}e.push(this.buffer.slice(this.pos,this.end-4)),this.buffer.copyWithin(0,this.end-4,this.end),this.pos=0,this.end=4}for(;;){if(!this.ended&&this.end<this.buffer.length)try{const e=await t.readToBuffer(this.buffer.length-this.end,this.buffer.subarray(this.end));this.end+=e}catch(t){if(this.ended=!0,this.pos>=this.end)return e.length?(0,r.A)(Uint8Array,e):null}let s=h.Ky(this.buffer.subarray(this.pos,this.end-4),e.length?0:3);if(s.offset>-1)return e.push(this.buffer.slice(this.pos,this.pos+s.offset)),this.pos+=s.offset,(0,r.A)(Uint8Array,e);if(this.ended)return e.push(this.buffer.slice(this.pos,this.end)),this.pos=this.end=0,(0,r.A)(Uint8Array,e);e.push(this.buffer.slice(this.pos,this.end-4)),this.buffer.copyWithin(0,this.end-4,this.end),this.pos=0,this.end=4}}reset(){this.pos=0,this.end=0,this.ended=!1}}}}]);
1
+ (self.webpackChunklibmedia=self.webpackChunklibmedia||[]).push([[487],{85947:(t,e,s)=>{s.d(e,{A:()=>h});var i=s(134);class h{constructor(){(0,i.A)(this,"type",-1),(0,i.A)(this,"onStreamAdd",void 0)}async destroy(t){}}},85487:(t,e,s)=>{s.r(e),s.d(e,{default:()=>v});var i=s(134),h=s(63939),r=s(50932),a=s(9705),n=s(85947),o=s(14686),u=s(37837),d=s(71517),c=s(95335),p=s(92647),l=s(67659),f=s(77231),g=s(37246),b=s(23991),A=s(37805);const y={framerate:{num:30,den:1}};class v extends n.A{constructor(t={}){super(),(0,i.A)(this,"type",12),(0,i.A)(this,"options",void 0),(0,i.A)(this,"currentDts",void 0),(0,i.A)(this,"currentPts",void 0),(0,i.A)(this,"step",void 0),(0,i.A)(this,"slices",void 0),(0,i.A)(this,"naluPos",void 0),(0,i.A)(this,"queue",void 0),(0,i.A)(this,"bitReader",void 0),(0,i.A)(this,"sliceType",void 0),(0,i.A)(this,"poc",void 0),(0,i.A)(this,"pocTid0",void 0),(0,i.A)(this,"sps",void 0),(0,i.A)(this,"pps",void 0),(0,i.A)(this,"naluReader",void 0),this.options=c.X$({},y,t)}init(t){t.ioReader&&t.ioReader.setEndian(!1),this.slices=[],this.queue=[],this.bitReader=new g.A(50),this.naluReader=new A.A}async destroy(t){if(this.queue.length){for(let t=0;t<this.queue.length;t++)(0,d.Qe)(this.queue[t].avpacket);this.queue.length=0}}isFrameNalu(t){return(t[1===t[2]?3:4]>>>1&63)<32}async readNaluFrame(t){let e=!1;const s=this.slices;for(this.slices=[],s.length&&(e=this.isFrameNalu(s[0]));;){const i=await this.naluReader.read(t.ioReader);if(!i)return s;const h=i[1===i[2]?3:4]>>>1&63;if(this.isFrameNalu(i))if(e){if(i[1===i[2]?5:6]>>>7)return this.slices.push(i),s;s.push(i)}else s.push(i),e=!0;else{if(e&&(35===h||33===h||34===h||32===h))return this.slices.push(i),s;s.push(i)}}}async readHeader(t){const e=t.createStream();for(e.codecpar.codecType=0,e.codecpar.codecId=173,e.timeBase.den=f.SF,e.timeBase.num=1,e.codecpar.flags|=1,this.currentDts=BigInt(0),this.currentPts=BigInt(0),this.naluPos=BigInt(0),this.poc=0,this.pocTid0=0,this.step=BigInt(Math.floor(f.SF/this.options.framerate.num*this.options.framerate.den));;){const s=await this.readNaluFrame(t);if(!s.length)return-1048576;const i=(0,p.A)(Uint8Array,s),a=l.sL(i);if(a){e.codecpar.extradata=(0,u.sY)(a.length),(0,o.lW)(e.codecpar.extradata,a.length,a),e.codecpar.extradataSize=a.length,l.XC(e,a);const n=s.find((t=>33==(t[1===t[2]?3:4]>>>1&63))),c=s.find((t=>34==(t[1===t[2]?3:4]>>>1&63)));this.sps=l.wf(n),this.pps=l.ZU(c);const p=(0,d._5)(),f=(0,u.sY)(i.length);(0,o.lW)(f,i.length,i),(0,d.NX)(p,f,i.length),r.M[17](p+56,this.naluPos),this.naluPos+=BigInt(Math.floor(i.length)),r.M[17](p+16,this.currentDts),this.currentDts+=this.step,r.M[17](p+8,this.currentPts),this.currentPts+=this.step,r.M[15](p+32,e.index),r.M[15](p+36,1|h.f[15](p+36)),r.M[15](p+72,e.timeBase.num),r.M[15](p+76,e.timeBase.den),r.M[15](p+36,64|h.f[15](p+36)),t.interval.packetBuffer.push(p);break}this.naluPos+=BigInt(Math.floor(i.length))}return 0}async readAVPacket_(t,e){const s=t.getStreamByMediaType(0),i=await this.readNaluFrame(t);if(!i.length)return-1048576;this.sliceType=-1;let a=!1,n=!0;i.forEach((t=>{const e=(1===t[2]?t[3]:t[4])>>>1&63,s=7&(1===t[2]?t[4]:t[5]);if(33===e&&(this.sps=l.wf(t)),34===e&&(this.pps=l.ZU(t)),19!==e&&20!==e||(a=!0),e<32&&n){n=!1,this.bitReader.reset(),this.bitReader.appendBuffer(t.subarray(1===t[2]?5:6,50));const i=this.bitReader.readU1();if(e>=16&&e<=23&&(a=!0,this.bitReader.readU1()),b.xb(this.bitReader),!i){this.pps.dependent_slice_segment_flag&&this.bitReader.readU1();const t=Math.ceil(Math.log2(this.sps.ctb_width*this.sps.ctb_height));this.bitReader.readU(t)}for(let t=0;t<this.pps.num_extra_slice_header_bits;t++)this.bitReader.readU1();if(this.sliceType=b.xb(this.bitReader),this.pps.output_flag_present_flag&&this.bitReader.readU1(),this.sps.separate_colour_plane_flag&&this.bitReader.readU(2),19===e||20===e)this.poc=0;else{const t=this.bitReader.readU(this.sps.log2_max_poc_lsb);let s=1<<this.sps.log2_max_poc_lsb,i=this.pocTid0%s,h=this.pocTid0-i,r=0;r=t<i&&i-t>=s/2?h+s:t>i&&t-i>s/2?h-s:h,16!=e&&17!=e&&18!=e||(r=0),this.poc=r+t}0==s&&0!=e&&2!=e&&4!=e&&6!=e&&8!=e&&7!=e&&9!=e&&(this.pocTid0=this.poc)}}));const c=(0,p.A)(Uint8Array,i),f=(0,u.sY)(c.length);return(0,o.lW)(f,c.length,c),(0,d.NX)(e,f,c.length),r.M[17](e+56,this.naluPos),this.naluPos+=BigInt(Math.floor(c.length)),r.M[17](e+16,this.currentDts),this.currentDts+=this.step,r.M[15](e+32,s.index),r.M[15](e+72,s.timeBase.num),r.M[15](e+76,s.timeBase.den),r.M[15](e+36,64|h.f[15](e+36)),a&&r.M[15](e+36,1|h.f[15](e+36)),0}async readAVPacket(t,e){let s=this.queue.length;const i=()=>{this.queue.length>1&&this.queue.sort(((t,e)=>t.poc-e.poc>0?1:-1));for(let t=0;t<this.queue.length;t++)r.M[17](this.queue[t].avpacket+8,this.currentPts),this.currentPts+=this.step;this.queue.length>1&&this.queue.sort(((t,e)=>h.f[17](t.avpacket+16)-h.f[17](e.avpacket+16)>BigInt(0)?1:-1)),this.queue.length&&((0,d.rN)(e,this.queue[0].avpacket),(0,d.Qe)(this.queue[0].avpacket));for(let e=1;e<this.queue.length;e++)t.interval.packetBuffer.push(this.queue[e].avpacket);this.queue.length=0};for(;;){const e=(0,d._5)();let r=await this.readAVPacket_(t,e);if(r<0)return(0,d.Qe)(e),this.queue.length?(i(),0):r;if(1&h.f[15](e+36)||1===this.sliceType||2===this.sliceType){if(1===s||1&h.f[15](e+36)&&this.queue.length)return i(),this.queue.push({avpacket:e,poc:this.poc}),0;this.queue.push({avpacket:e,poc:this.poc}),s++}else this.queue.push({avpacket:e,poc:this.poc})}}async seek(t,e,s,i){const h=t.ioReader.getPos();return 2&i?(await t.ioReader.seek(s),h):BigInt(a.E$)}getAnalyzeStreamsCount(){return 1}}},37805:(t,e,s)=>{s.d(e,{A:()=>a});var i=s(134),h=s(60264),r=s(92647);class a{constructor(){(0,i.A)(this,"buffer",void 0),(0,i.A)(this,"pos",void 0),(0,i.A)(this,"end",void 0),(0,i.A)(this,"ended",void 0),this.buffer=new Uint8Array(102400),this.pos=0,this.end=0,this.ended=!1}async read(t){if(this.ended&&this.pos>=this.end)return;const e=[];if(this.pos<this.end-4){let t=h.Ky(this.buffer.subarray(this.pos,this.end-4),3);if(t.offset>-1){const e=this.buffer.slice(this.pos,this.pos+t.offset);return this.pos+=t.offset,e}e.push(this.buffer.slice(this.pos,this.end-4)),this.buffer.copyWithin(0,this.end-4,this.end),this.pos=0,this.end=4}for(;;){if(!this.ended&&this.end<this.buffer.length)try{const e=await t.readToBuffer(this.buffer.length-this.end,this.buffer.subarray(this.end));this.end+=e}catch(t){if(this.ended=!0,this.pos>=this.end)return e.length?(0,r.A)(Uint8Array,e):null}let s=h.Ky(this.buffer.subarray(this.pos,this.end-4),e.length?0:3);if(s.offset>-1)return e.push(this.buffer.slice(this.pos,this.pos+s.offset)),this.pos+=s.offset,(0,r.A)(Uint8Array,e);if(this.ended)return e.push(this.buffer.slice(this.pos,this.end)),this.pos=this.end=0,(0,r.A)(Uint8Array,e);e.push(this.buffer.slice(this.pos,this.end-4)),this.buffer.copyWithin(0,this.end-4,this.end),this.pos=0,this.end=4}}reset(){this.pos=0,this.end=0,this.ended=!1}}}}]);