@openlist-frontend/openlist-frontend 4.1.3 → 4.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/VERSION +1 -1
- package/dist/assets/2fa-DnO7OW8r.js +1 -0
- package/dist/assets/2fa-legacy-CW-gE4u7.js +1 -0
- package/dist/{lite/assets/About-DC8lOADj.js → assets/About-DbBVzhe0.js} +1 -1
- package/dist/{lite/assets/About-legacy-BBURv-NS.js → assets/About-legacy-DenzJhZP.js} +1 -1
- package/dist/assets/{AddOrEdit-DXB5q5QW.js → AddOrEdit-26ruvLmM.js} +1 -1
- package/dist/assets/AddOrEdit-74laTJ2-.js +1 -0
- package/dist/assets/AddOrEdit-BDKD_Z4F.js +1 -0
- package/dist/assets/{AddOrEdit-CWzJ9FmZ.js → AddOrEdit-BXKVJ8uY.js} +1 -1
- package/dist/assets/AddOrEdit-legacy-D6h5RN8T.js +1 -0
- package/dist/assets/{AddOrEdit-legacy-Dz3jSAvS.js → AddOrEdit-legacy-DO3xzVrb.js} +1 -1
- package/dist/assets/{AddOrEdit-legacy-Bqz9cUu6.js → AddOrEdit-legacy-DQ2LG7sl.js} +1 -1
- package/dist/assets/AddOrEdit-legacy-DxDq8HJ6.js +1 -0
- package/dist/assets/Common-legacy-CWb8wL9W.js +1 -0
- package/dist/assets/Common-mJXEpduw.js +1 -0
- package/dist/assets/{Copy-TNx1OuVO.js → Copy-CO7Z8yWm.js} +1 -1
- package/dist/assets/{Copy-legacy-OI3BodRq.js → Copy-legacy-Dj2lhlcL.js} +1 -1
- package/dist/assets/Decompress-BEkrwzIu.js +1 -0
- package/dist/assets/{Decompress-legacy-bxXixx4s.js → Decompress-legacy-DvzgUTRr.js} +1 -1
- package/dist/assets/{DeletePopover-BuNX49KG.js → DeletePopover-CAP4EK2m.js} +1 -1
- package/dist/assets/{DeletePopover-legacy-VN9zzbeh.js → DeletePopover-legacy-CD4d4LSF.js} +1 -1
- package/dist/assets/File-DUSRp2wv.js +2 -0
- package/dist/assets/{File-legacy-BI0ttA9l.js → File-legacy-C2mqSJAb.js} +1 -1
- package/dist/assets/{Folder-Cbrh1YqP.js → Folder-CTz3fIPw.js} +3 -3
- package/dist/{lite/assets/Folder-legacy-CdnSa-xd.js → assets/Folder-legacy-BEVN1MLr.js} +2 -2
- package/dist/assets/{FolderTree-CINIB__M.js → FolderTree-B-JVhW12.js} +1 -1
- package/dist/assets/{FolderTree-legacy-DuvgfbAr.js → FolderTree-legacy-Buo0bWMI.js} +1 -1
- package/dist/assets/Grid-CZuK8hT5.js +1 -0
- package/dist/assets/Grid-legacy-D59EQdlr.js +1 -0
- package/dist/assets/{GridItem-BajQFf7o.js → GridItem-BTuMpend.js} +1 -1
- package/dist/assets/{GridItem-legacy-Bhf2pnJl.js → GridItem-legacy-JihU9ieU.js} +1 -1
- package/dist/assets/{ImageWithError-BPBjZ-uy.js → ImageWithError-CVjfpGck.js} +1 -1
- package/dist/assets/{ImageWithError-legacy-RTfSLkrQ.js → ImageWithError-legacy-BeC68avU.js} +1 -1
- package/dist/{lite/assets/Images-CnEV0E-X.js → assets/Images-DK4UYmZg.js} +1 -1
- package/dist/{lite/assets/Images-legacy-By18EwBs.js → assets/Images-legacy-D5Ne1SS5.js} +1 -1
- package/dist/assets/Layout-B1rGA3nZ.js +6 -0
- package/dist/assets/Layout-legacy-C0kGGd08.js +6 -0
- package/dist/assets/List-Coh-6NJA.js +1 -0
- package/dist/assets/List-legacy-CSkvZQ4q.js +1 -0
- package/dist/assets/Messenger-CnV47Bze.js +1 -0
- package/dist/assets/Messenger-legacy-DFlWZQR1.js +1 -0
- package/dist/assets/{Metas-BaHPe9Ju.js → Metas-DE61Jy7q.js} +1 -1
- package/dist/assets/{Metas-legacy-BMQ38nt3.js → Metas-legacy-BoOLwhTp.js} +1 -1
- package/dist/assets/{Move-UJoZX5yh.js → Move-DtTvDViD.js} +1 -1
- package/dist/assets/{Move-legacy-m_IT2nLW.js → Move-legacy-CaSSrfNz.js} +1 -1
- package/dist/assets/Other-CLxXY7Yv.js +1 -0
- package/dist/assets/Other-legacy-2aFOBKcP.js +1 -0
- package/dist/{lite/assets/PackageDownload-D9a1i7HG.js → assets/PackageDownload-DoqlhmWi.js} +1 -1
- package/dist/{lite/assets/PackageDownload-legacy-BpFYsmOC.js → assets/PackageDownload-legacy-C-DmBp0b.js} +1 -1
- package/dist/assets/{Paginator-DlbMSJt2.js → Paginator-CcvouZsH.js} +1 -1
- package/dist/assets/{Paginator-legacy-DxGKPO7E.js → Paginator-legacy-Dl1wmpdf.js} +1 -1
- package/dist/assets/{Password-CBvtVSWQ.js → Password-BJH0O-Ee.js} +1 -1
- package/dist/assets/{Password-legacy-BkgQ4-9q.js → Password-legacy-aLr5CPaC.js} +1 -1
- package/dist/assets/Profile-A8BTUzP1.js +1 -0
- package/dist/assets/{Profile-legacy-CHgF31ln.js → Profile-legacy-DlLHgHcg.js} +1 -1
- package/dist/assets/{PublicKeys-Bmh37XmH.js → PublicKeys-GmxW9slb.js} +1 -1
- package/dist/{lite/assets/PublicKeys-legacy-BDVRnCVU.js → assets/PublicKeys-legacy-Dpy2OKO7.js} +1 -1
- package/dist/assets/ResponsiveGrid-B-Gtx7hU.js +1 -0
- package/dist/assets/{ResponsiveGrid-legacy-qfZ_0KLP.js → ResponsiveGrid-legacy-C98rjzv4.js} +1 -1
- package/dist/assets/{S3-Y_DV35HZ.js → S3-B2QEPRxz.js} +1 -1
- package/dist/{lite/assets/S3-legacy-Clh47jH4.js → assets/S3-legacy-D0oGQXX7.js} +1 -1
- package/dist/assets/{SettingItem-C6CU6cRH.js → SettingItem-BKq_8Tgg.js} +1 -1
- package/dist/{lite/assets/SettingItem-legacy-CKSh0dJo.js → assets/SettingItem-legacy-B-daHqNK.js} +1 -1
- package/dist/assets/Shares-CIpBRvjh.js +1 -0
- package/dist/assets/Shares-legacy-Czt75hUx.js +1 -0
- package/dist/{lite/assets/Storages-DN5G_Myk.js → assets/Storages-3NxbdTsR.js} +1 -1
- package/dist/assets/{Storages-legacy-DxDw7XAb.js → Storages-legacy--XB7c9Lu.js} +1 -1
- package/dist/assets/{Upload-CseQ8phI.js → Upload-BrafIJK3.js} +2 -2
- package/dist/assets/{Upload-BDnRTRao.js → Upload-CAJUVnYz.js} +1 -1
- package/dist/assets/{Upload-legacy-CFpY0UA2.js → Upload-legacy-CqzGbhWy.js} +1 -1
- package/dist/assets/Upload-legacy-DonEbWL7.js +6 -0
- package/dist/assets/{Users-BJ6Mg5jK.js → Users-Dov8BVlG.js} +1 -1
- package/dist/assets/Users-legacy-BvP21aaZ.js +1 -0
- package/dist/assets/{Wether-BrBCeLPY.js → Wether-DnkqeggH.js} +1 -1
- package/dist/assets/{Wether-legacy-BY6L8rYv.js → Wether-legacy-CAaj_TCP.js} +1 -1
- package/dist/assets/aliyun_video-BUZEYb1M.js +1 -0
- package/dist/assets/aliyun_video-legacy-CZCG3ZE7.js +1 -0
- package/dist/{lite/assets/archive-jWus6q-p.js → assets/archive-Wwf_kxPh.js} +1 -1
- package/dist/assets/archive-legacy-BRdlrV0m.js +1 -0
- package/dist/assets/artplayer-Du7zVVz_.css +1 -0
- package/dist/assets/artplayer-Dx_o8qbL.js +6 -0
- package/dist/assets/artplayer-legacy-qu5LeyCY.js +1 -0
- package/dist/assets/{asciinema-BofNEn4g.js → asciinema-gyesvthN.js} +1 -1
- package/dist/{lite/assets/asciinema-legacy-BQ7RS1U8.js → assets/asciinema-legacy-BcfykwUM.js} +1 -1
- package/dist/assets/{audio-CE7OCTzy.js → audio-CkAeZoI5.js} +1 -1
- package/dist/assets/{audio-legacy-DXaLGnl4.js → audio-legacy-CqodcquN.js} +1 -1
- package/dist/{lite/assets/backup-restore-BsJBSefl.js → assets/backup-restore-DSurV-LF.js} +1 -1
- package/dist/{lite/assets/backup-restore-legacy-CmNwS_QY.js → assets/backup-restore-legacy-Bul7Mx1E.js} +1 -1
- package/dist/assets/entry-CVdmt6wo.js +1 -0
- package/dist/assets/entry-legacy-Bwsa0639.js +1 -0
- package/dist/assets/entry-legacy-CEj-WSrU.js +1 -0
- package/dist/assets/entry-u0ydTOPw.js +1 -0
- package/dist/assets/flash-BujtDaR2.js +1 -0
- package/dist/assets/flash-legacy-TufwamJ4.js +1 -0
- package/dist/assets/heic-YcL882lE.js +1 -0
- package/dist/assets/heic-legacy-C9V8QWlr.js +1 -0
- package/dist/{lite/assets/helper-Dl9Ufp3q.js → assets/helper-CK1xm1ZU.js} +1 -1
- package/dist/assets/helper-D19WhGE8.js +1 -0
- package/dist/assets/helper-legacy-D5fWMl8g.js +1 -0
- package/dist/{lite/assets/helper-legacy-BfBKKLyx.js → assets/helper-legacy-DnsNXh5c.js} +1 -1
- package/dist/assets/{html-legacy-oUqPI3JI.js → html-legacy-ZLUETlal.js} +1 -1
- package/dist/assets/{html-DBsD0Vf8.js → html-zAnEIQrt.js} +1 -1
- package/dist/assets/icon-1UxJ_z4h.js +1 -0
- package/dist/assets/icon-legacy-ae4Og5ve.js +1 -0
- package/dist/assets/{image-mSxdrD8s.js → image-D8Y9vFpL.js} +1 -1
- package/dist/assets/{image-legacy-HvFVd3Fc.js → image-legacy-BeKvZVUJ.js} +1 -1
- package/dist/{lite/assets/index-BtZVxFW3.js → assets/index-BMdLk_D8.js} +1 -1
- package/dist/{lite/assets/index-DgFxiGS1.js → assets/index-Bm6_Y9sI.js} +6 -6
- package/dist/{lite/assets/index-DwM6hnGr.js → assets/index-C4xpIx4V.js} +2 -2
- package/dist/{lite/assets/index-D8VrAP1D.js → assets/index-C7ZV98_F.js} +1 -1
- package/dist/assets/{index-DFgk5DLi.js → index-CCprj32B.js} +1 -1
- package/dist/assets/{index-gxiOhmHK.js → index-CKG1ZNQZ.js} +2 -2
- package/dist/assets/index-CTnHW0Hg.js +1 -0
- package/dist/assets/{index-CinOmCOR.js → index-Djf5AcBv.js} +1 -1
- package/dist/assets/{index-D2lxPcyS.js → index-eLRQQlhw.js} +1 -1
- package/dist/{lite/assets/index-legacy-Be_E5yrL.js → assets/index-legacy-8kNL0jTf.js} +1 -1
- package/dist/assets/index-legacy-BnW9yB9Z.js +28 -0
- package/dist/assets/{index-legacy-Xi622lIw.js → index-legacy-C7KH6YWX.js} +1 -1
- package/dist/assets/{index-legacy-BoULPS20.js → index-legacy-CKgx1aTJ.js} +1 -1
- package/dist/assets/{index-legacy-B9XrTrN5.js → index-legacy-CYPFt7al.js} +1 -1
- package/dist/assets/{index-legacy-BjkvhKBt.js → index-legacy-Cqf4u7Tk.js} +1 -1
- package/dist/assets/index-legacy-DHebV9rT.js +1 -0
- package/dist/assets/{index-legacy-DDkguF-O.js → index-legacy-MsXPuGSt.js} +1 -1
- package/dist/assets/index-legacy-QzbBOX-x.js +18 -0
- package/dist/{lite/assets/index-legacy-BfcfgGKx.js → assets/index-legacy-WntVcU0W.js} +1 -1
- package/dist/{lite/assets/index-DxYB-nt2.js → assets/index-vDZfREFO.js} +1 -1
- package/dist/assets/{indexes-w1aTyf-q.js → indexes-4GSYOl-x.js} +1 -1
- package/dist/assets/{indexes-legacy-BTfGF496.js → indexes-legacy-D5AvV5rv.js} +1 -1
- package/dist/assets/{ipa-BdrF57Uf.js → ipa-D4SZWz_c.js} +1 -1
- package/dist/assets/{ipa-legacy-CX-KZW9S.js → ipa-legacy-Cmz2KaOW.js} +1 -1
- package/dist/assets/{markdown-jAsJc4fK.js → markdown-BViStt17.js} +1 -1
- package/dist/assets/markdown-legacy-D-o2A_ax.js +1 -0
- package/dist/assets/{markdown_with_word_wrap-wGBIpwmm.js → markdown_with_word_wrap-acH_y5MB.js} +1 -1
- package/dist/assets/markdown_with_word_wrap-legacy-D49mE1wT.js +1 -0
- package/dist/assets/offline_download-Fbk9MS4a.js +1 -0
- package/dist/assets/{offline_download-legacy-vH-tm0Di.js → offline_download-legacy-Bw24ZKyO.js} +1 -1
- package/dist/assets/{pdf-B1PprfC2.js → pdf-CI1MrVa4.js} +1 -1
- package/dist/assets/{pdf-legacy-Cn2v_ady.js → pdf-legacy-DZbYLbtj.js} +2 -2
- package/dist/assets/plist-FjwosD2N.js +1 -0
- package/dist/assets/{plist-legacy-Dx42TsRY.js → plist-legacy-FwdYdIRS.js} +1 -1
- package/dist/assets/{share-agdFoXKt.js → share-Dr-UV3DI.js} +1 -1
- package/dist/assets/{share-legacy-hUybwYO6.js → share-legacy-BeIGs_Ll.js} +1 -1
- package/dist/assets/{storage-Ln5bQ9Jj.js → storage-D_MY-bv8.js} +1 -1
- package/dist/assets/{storage-legacy-D0-cTYAq.js → storage-legacy-Dj_KTUH1.js} +1 -1
- package/dist/assets/{style-DjjbeCex.js → style-BGlJarg-.js} +1 -1
- package/dist/{lite/assets/style-legacy-BfMuJm2_.js → assets/style-legacy-BjKlv_jM.js} +1 -1
- package/dist/assets/{text-editor-SbktMI1I.js → text-editor-D8z8lZYG.js} +1 -1
- package/dist/{lite/assets/text-editor-legacy-lLgU1caD.js → assets/text-editor-legacy-wswMIqoG.js} +1 -1
- package/dist/assets/{url-D6cS6jtV.js → url-D1DZG2PN.js} +1 -1
- package/dist/assets/{url-legacy-Bt4XFE_Y.js → url-legacy-CO37P29p.js} +1 -1
- package/dist/assets/{useTitle-DB_Uj-GZ.js → useTitle-Bvvany__.js} +1 -1
- package/dist/assets/{useTitle-legacy-CN0HWZOF.js → useTitle-legacy-Dz_oGTmz.js} +1 -1
- package/dist/assets/video-Bswyf4az.js +7 -0
- package/dist/assets/video-legacy-Bmvq5B8Q.js +9 -0
- package/dist/{lite/assets/video360-C7O7n4u6.js → assets/video360-DpnUmoag.js} +2 -2
- package/dist/assets/{video360-legacy-K8_p-sBq.js → video360-legacy-Dl3uFXTd.js} +2 -2
- package/dist/assets/video_box-legacy-BC8nOfW8.js +1 -0
- package/dist/assets/video_box-uTixsfAb.js +6 -0
- package/dist/i18n.tar.gz +0 -0
- package/dist/index.html +2 -2
- package/dist/lite/VERSION +1 -1
- package/dist/lite/assets/2fa-Cp8GV6f2.js +1 -0
- package/dist/lite/assets/2fa-legacy-CDlu5-tX.js +1 -0
- package/dist/{assets/About-DRXSKBfh.js → lite/assets/About-BiIG6v0o.js} +1 -1
- package/dist/{assets/About-legacy-HnDcUSTc.js → lite/assets/About-legacy-Nom7wMbp.js} +1 -1
- package/dist/lite/assets/{AddOrEdit-kxwtaa4m.js → AddOrEdit-BL1BeyoJ.js} +1 -1
- package/dist/lite/assets/{AddOrEdit-CdXVTJ9c.js → AddOrEdit-DDTliQC9.js} +1 -1
- package/dist/lite/assets/AddOrEdit-DUSORWWH.js +1 -0
- package/dist/lite/assets/AddOrEdit-P9_440Uh.js +1 -0
- package/dist/lite/assets/{AddOrEdit-legacy-DNvzTdWh.js → AddOrEdit-legacy-64dp_VVE.js} +1 -1
- package/dist/lite/assets/AddOrEdit-legacy-CU0tx0-k.js +1 -0
- package/dist/lite/assets/{AddOrEdit-legacy-Rqv219Y6.js → AddOrEdit-legacy-CYqNrxMH.js} +1 -1
- package/dist/lite/assets/AddOrEdit-legacy-Cxs3ZD9l.js +1 -0
- package/dist/lite/assets/Common-DUYM0qhl.js +1 -0
- package/dist/lite/assets/Common-legacy-Bykd7dpj.js +1 -0
- package/dist/lite/assets/{Copy-BnLZydCJ.js → Copy-CSUzrb-x.js} +1 -1
- package/dist/lite/assets/{Copy-legacy-CccB5S71.js → Copy-legacy-e0bet9IK.js} +1 -1
- package/dist/lite/assets/Decompress-D0dRPg6l.js +1 -0
- package/dist/lite/assets/{Decompress-legacy-WrdK96xb.js → Decompress-legacy-DKQqLfdo.js} +1 -1
- package/dist/lite/assets/{DeletePopover-CIhnzIg1.js → DeletePopover-LagDx2W3.js} +1 -1
- package/dist/lite/assets/{DeletePopover-legacy-B3JQBuli.js → DeletePopover-legacy-B-ceofN8.js} +1 -1
- package/dist/lite/assets/File-BWWtKrhV.js +2 -0
- package/dist/lite/assets/{File-legacy-B1SaBxxh.js → File-legacy-DiivbtlC.js} +1 -1
- package/dist/lite/assets/{Folder-CSDsLaTD.js → Folder-LDL2MQIm.js} +3 -3
- package/dist/{assets/Folder-legacy-BjJaEYhG.js → lite/assets/Folder-legacy-COJG8Q2p.js} +2 -2
- package/dist/lite/assets/{FolderTree-D63old4t.js → FolderTree-B_M4MmTX.js} +1 -1
- package/dist/lite/assets/{FolderTree-legacy-CBxiI_hU.js → FolderTree-legacy-BoxZZ-Bl.js} +1 -1
- package/dist/lite/assets/Grid-legacy-CHqUQbNG.js +1 -0
- package/dist/lite/assets/Grid-t0zQLjKi.js +1 -0
- package/dist/lite/assets/{GridItem-CbZobLSv.js → GridItem-VL-h_0bJ.js} +1 -1
- package/dist/lite/assets/{GridItem-legacy-7puWlG97.js → GridItem-legacy-Dub6K9FE.js} +1 -1
- package/dist/lite/assets/{ImageWithError-a3ABP7Da.js → ImageWithError-DCqtD_dx.js} +1 -1
- package/dist/lite/assets/{ImageWithError-legacy-S3VHJvoR.js → ImageWithError-legacy-Dr3Dnm7P.js} +1 -1
- package/dist/{assets/Images-CtsWnQPO.js → lite/assets/Images-MD_JglgI.js} +1 -1
- package/dist/{assets/Images-legacy-x-UK3uNL.js → lite/assets/Images-legacy-B8gsymQh.js} +1 -1
- package/dist/lite/assets/Layout-CHsCOBH4.js +6 -0
- package/dist/lite/assets/Layout-legacy-7VJRCJRu.js +6 -0
- package/dist/lite/assets/List-PPAUqQL3.js +1 -0
- package/dist/lite/assets/List-legacy-jZhqGE6J.js +1 -0
- package/dist/lite/assets/Messenger-CI3Fj4WR.js +1 -0
- package/dist/lite/assets/Messenger-legacy-DBaggPFZ.js +1 -0
- package/dist/lite/assets/{Metas-KhspbyAu.js → Metas-CnKzOOqI.js} +1 -1
- package/dist/lite/assets/{Metas-legacy-CusFfxbn.js → Metas-legacy-DiWc9jH2.js} +1 -1
- package/dist/lite/assets/{Move-C5DrzjZK.js → Move-DR4A37IE.js} +1 -1
- package/dist/lite/assets/{Move-legacy-D7B59QHE.js → Move-legacy-Dq4vhjoq.js} +1 -1
- package/dist/lite/assets/Other-C10g6L1D.js +1 -0
- package/dist/lite/assets/Other-legacy-BhvWSmNK.js +1 -0
- package/dist/{assets/PackageDownload-DfaaNeIO.js → lite/assets/PackageDownload-Sb8Gf-bN.js} +1 -1
- package/dist/{assets/PackageDownload-legacy-CFioC5Qr.js → lite/assets/PackageDownload-legacy-_LSavf1q.js} +1 -1
- package/dist/lite/assets/{Paginator-CXOC5uLq.js → Paginator-Bk9q62IB.js} +1 -1
- package/dist/lite/assets/{Paginator-legacy-Bi9-Cav5.js → Paginator-legacy-TGxD05Bb.js} +1 -1
- package/dist/lite/assets/{Password-BZrRUCVO.js → Password-gfBOG-Vm.js} +1 -1
- package/dist/lite/assets/{Password-legacy-fYQaSh45.js → Password-legacy-BhjtN2vr.js} +1 -1
- package/dist/lite/assets/Profile-BnHDknJp.js +1 -0
- package/dist/lite/assets/{Profile-legacy-CmELDc8I.js → Profile-legacy-Ck3FIwT0.js} +1 -1
- package/dist/lite/assets/{PublicKeys-BwFJGnGK.js → PublicKeys-CJnfquth.js} +1 -1
- package/dist/{assets/PublicKeys-legacy-aGSqyMDc.js → lite/assets/PublicKeys-legacy-DPeF0ipr.js} +1 -1
- package/dist/lite/assets/ResponsiveGrid-BSvFaM_t.js +1 -0
- package/dist/lite/assets/{ResponsiveGrid-legacy-D1975Fgk.js → ResponsiveGrid-legacy-Cvd5QSxb.js} +1 -1
- package/dist/lite/assets/{S3-zdVrcvMQ.js → S3-C4v6mepu.js} +1 -1
- package/dist/{assets/S3-legacy-IbfEiIs1.js → lite/assets/S3-legacy-Ddi1mULM.js} +1 -1
- package/dist/lite/assets/{SettingItem-CEsLk31e.js → SettingItem-DfDTdGVz.js} +1 -1
- package/dist/{assets/SettingItem-legacy-Aohf_J_D.js → lite/assets/SettingItem-legacy-X-mebGDm.js} +1 -1
- package/dist/lite/assets/Shares-eOXygW7q.js +1 -0
- package/dist/lite/assets/Shares-legacy-A-yOhTjr.js +1 -0
- package/dist/{assets/Storages-QPQm-MWw.js → lite/assets/Storages-DPJKHeYT.js} +1 -1
- package/dist/lite/assets/{Storages-legacy-OnslPQ3L.js → Storages-legacy-B1hawBl6.js} +1 -1
- package/dist/lite/assets/{Upload-CWTuegkI.js → Upload-BgCWW1ZP.js} +1 -1
- package/dist/lite/assets/{Upload-BEShq3aL.js → Upload-Dn9Zt2ir.js} +2 -2
- package/dist/lite/assets/{Upload-legacy-BMDLPvqf.js → Upload-legacy-BNsTSvqL.js} +1 -1
- package/dist/lite/assets/Upload-legacy-BjZkHgze.js +6 -0
- package/dist/lite/assets/{Users-zGBlk4q_.js → Users-CRwlRJki.js} +1 -1
- package/dist/lite/assets/Users-legacy-tSqLQ1MC.js +1 -0
- package/dist/lite/assets/{Wether-BjSG14wG.js → Wether-DIIDvqtz.js} +1 -1
- package/dist/lite/assets/{Wether-legacy-8SD_eYpL.js → Wether-legacy-DnY7xir2.js} +1 -1
- package/dist/lite/assets/aliyun_video-Dcfhim5l.js +1 -0
- package/dist/lite/assets/aliyun_video-legacy-fKInvsIp.js +1 -0
- package/dist/{assets/archive-CM-zGADV.js → lite/assets/archive-BmYGyL-D.js} +1 -1
- package/dist/lite/assets/archive-legacy-13D70yLk.js +1 -0
- package/dist/lite/assets/artplayer-CPzgtlP-.js +6 -0
- package/dist/lite/assets/artplayer-Du7zVVz_.css +1 -0
- package/dist/lite/assets/artplayer-legacy-D7Kq1v6U.js +1 -0
- package/dist/lite/assets/{asciinema-CA_qtko5.js → asciinema-CnVNqzQ3.js} +1 -1
- package/dist/{assets/asciinema-legacy-DCRR9N7J.js → lite/assets/asciinema-legacy-CR_8G7YK.js} +1 -1
- package/dist/lite/assets/{audio-BnIZi2lE.js → audio-BzrVqsI7.js} +1 -1
- package/dist/lite/assets/{audio-legacy-DcDbftcj.js → audio-legacy-C9duowev.js} +1 -1
- package/dist/{assets/backup-restore-Ba3_yqXQ.js → lite/assets/backup-restore-DzEeR52o.js} +1 -1
- package/dist/{assets/backup-restore-legacy-bf9g4tv4.js → lite/assets/backup-restore-legacy-Bca-CDdx.js} +1 -1
- package/dist/lite/assets/entry-BTx4NjL7.js +1 -0
- package/dist/lite/assets/entry-BoTU0nG3.js +1 -0
- package/dist/lite/assets/entry-legacy-DqV9qT0k.js +1 -0
- package/dist/lite/assets/entry-legacy-nMsdLwMv.js +1 -0
- package/dist/lite/assets/flash-legacy-CcDa5_zU.js +1 -0
- package/dist/lite/assets/flash-n-Uerf3G.js +1 -0
- package/dist/lite/assets/heic-DJsGgSth.js +1 -0
- package/dist/lite/assets/heic-legacy-5E4avPOJ.js +1 -0
- package/dist/{assets/helper-CvwzuJRv.js → lite/assets/helper-BRT5m-UO.js} +1 -1
- package/dist/lite/assets/helper-Y6Ih7bVv.js +1 -0
- package/dist/lite/assets/helper-legacy-CupJzs18.js +1 -0
- package/dist/{assets/helper-legacy-BdBHsZDj.js → lite/assets/helper-legacy-DGYPOWF1.js} +1 -1
- package/dist/lite/assets/{html-Ces8gMsz.js → html-B_RN4qHU.js} +1 -1
- package/dist/lite/assets/{html-legacy-0IEekoCE.js → html-legacy-CTmoSLMG.js} +1 -1
- package/dist/lite/assets/icon-99T2NcXn.js +1 -0
- package/dist/lite/assets/icon-legacy--imLLEN3.js +1 -0
- package/dist/lite/assets/{image-Dewa76sq.js → image-D7ssBu4O.js} +1 -1
- package/dist/lite/assets/{image-legacy-B4M5pk24.js → image-legacy-B7RjwG2e.js} +1 -1
- package/dist/lite/assets/{index-Cuci44XH.js → index-B3PN_rL5.js} +1 -1
- package/dist/lite/assets/{index-DyCGLVyV.js → index-B7j55Lx_.js} +2 -2
- package/dist/{assets/index-yRqGUhvz.js → lite/assets/index-BN93XOUQ.js} +1 -1
- package/dist/{assets/index-DSZyhv1D.js → lite/assets/index-CE2qbwV4.js} +1 -1
- package/dist/{assets/index-D9i2fsQo.js → lite/assets/index-CHbFa2Qi.js} +1 -1
- package/dist/lite/assets/{index-YrLVu2US.js → index-DGG3tImp.js} +1 -1
- package/dist/{assets/index-Bpj9HV4J.js → lite/assets/index-DVeSrIjH.js} +6 -6
- package/dist/lite/assets/{index-Dd2j_kdw.js → index-DfK_oJ0a.js} +1 -1
- package/dist/{assets/index-rRcWdKjE.js → lite/assets/index-DiQ5fKYa.js} +2 -2
- package/dist/lite/assets/index-DmEGoYU0.js +1 -0
- package/dist/lite/assets/{index-legacy-ZKup1Jkn.js → index-legacy-AYHOnsIL.js} +5 -5
- package/dist/lite/assets/{index-legacy-B-N9ZseE.js → index-legacy-B18blw0h.js} +1 -1
- package/dist/lite/assets/{index-legacy-TlIcIvVH.js → index-legacy-BQG1O82M.js} +1 -1
- package/dist/lite/assets/{index-legacy-BqUCtjfV.js → index-legacy-Bv1gPy8D.js} +1 -1
- package/dist/lite/assets/{index-legacy-BSp_jupB.js → index-legacy-DFmoAcdO.js} +1 -1
- package/dist/{assets/index-legacy-DS1TXPDt.js → lite/assets/index-legacy-DIGekq4N.js} +1 -1
- package/dist/lite/assets/index-legacy-DKh3ofD4.js +1 -0
- package/dist/{assets/index-legacy-KltvJBM4.js → lite/assets/index-legacy-_1Jar6t1.js} +1 -1
- package/dist/lite/assets/{index-legacy-Bu7DMRmv.js → index-legacy-kM70Lk7B.js} +1 -1
- package/dist/lite/assets/index-legacy-t_wcdI0_.js +18 -0
- package/dist/lite/assets/{indexes-B3J0F8jv.js → indexes-B_xpZUtC.js} +1 -1
- package/dist/lite/assets/{indexes-legacy-k3Llr6LB.js → indexes-legacy-C4cOsGQP.js} +1 -1
- package/dist/lite/assets/{ipa-DP-KYhse.js → ipa-DnoFGq1x.js} +1 -1
- package/dist/lite/assets/{ipa-legacy-BhzoyUFI.js → ipa-legacy-CIXCx8B2.js} +1 -1
- package/dist/lite/assets/{markdown-dEC3QCQ2.js → markdown-TJH7xmNb.js} +1 -1
- package/dist/lite/assets/markdown-legacy-c4Ay76yC.js +1 -0
- package/dist/lite/assets/{markdown_with_word_wrap-DH8eHI3P.js → markdown_with_word_wrap-D2xfCDFO.js} +1 -1
- package/dist/lite/assets/markdown_with_word_wrap-legacy-l4PIXAK-.js +1 -0
- package/dist/lite/assets/offline_download-CmjIF9vB.js +1 -0
- package/dist/lite/assets/{offline_download-legacy-p_DCiSw1.js → offline_download-legacy-C475ejHE.js} +1 -1
- package/dist/lite/assets/{pdf-Drdn5-wv.js → pdf-DTj5WiGP.js} +1 -1
- package/dist/lite/assets/{pdf-legacy-C4XkxLN7.js → pdf-legacy-1NJiUq5K.js} +2 -2
- package/dist/lite/assets/plist-CPm1wlhL.js +1 -0
- package/dist/lite/assets/{plist-legacy-DwWyqdzY.js → plist-legacy-BvRa_WzA.js} +1 -1
- package/dist/lite/assets/{share-WVCIuMZr.js → share-BhTXOLp-.js} +1 -1
- package/dist/lite/assets/{share-legacy-BVad6nZ0.js → share-legacy-DhBXeLhn.js} +1 -1
- package/dist/lite/assets/{storage-Ln5bQ9Jj.js → storage-D_MY-bv8.js} +1 -1
- package/dist/lite/assets/{storage-legacy-D0-cTYAq.js → storage-legacy-Dj_KTUH1.js} +1 -1
- package/dist/lite/assets/{style-rlSvx9zK.js → style-D8eAFLLT.js} +1 -1
- package/dist/{assets/style-legacy-dOJIKPIk.js → lite/assets/style-legacy-DZQRbjrI.js} +1 -1
- package/dist/lite/assets/{text-editor-D7UFabmu.js → text-editor-CN5RpNem.js} +1 -1
- package/dist/{assets/text-editor-legacy-xsXJ3Ia3.js → lite/assets/text-editor-legacy-BNyX3UlY.js} +1 -1
- package/dist/lite/assets/{url-DUHdU0yR.js → url-Cqo_0H5O.js} +1 -1
- package/dist/lite/assets/{url-legacy-DHeGylTK.js → url-legacy--KYBfjIe.js} +1 -1
- package/dist/lite/assets/{useTitle-Dh-Pxw36.js → useTitle-Du1KlcYm.js} +1 -1
- package/dist/lite/assets/{useTitle-legacy-C1HWSdYr.js → useTitle-legacy-Be3LvOiw.js} +1 -1
- package/dist/lite/assets/video-BBuQ14R0.js +7 -0
- package/dist/lite/assets/video-legacy-B7NepIr7.js +9 -0
- package/dist/{assets/video360-CV5b8UFP.js → lite/assets/video360-CSrjtpy_.js} +2 -2
- package/dist/lite/assets/{video360-legacy-qc4Lesqq.js → video360-legacy-COCOSzJK.js} +2 -2
- package/dist/lite/assets/video_box-DLwxRedp.js +6 -0
- package/dist/lite/assets/video_box-legacy-BdtBVjqO.js +1 -0
- package/dist/lite/i18n.tar.gz +0 -0
- package/dist/lite/index.html +2 -2
- package/package.json +1 -1
- package/dist/assets/2fa-CT-NYgA3.js +0 -1
- package/dist/assets/2fa-legacy-CyEV0yMi.js +0 -1
- package/dist/assets/AddOrEdit-D5IdC9IZ.js +0 -1
- package/dist/assets/AddOrEdit-DotYixB5.js +0 -1
- package/dist/assets/AddOrEdit-legacy-hKzQmG6z.js +0 -1
- package/dist/assets/AddOrEdit-legacy-pqhGDkjt.js +0 -1
- package/dist/assets/Common-DyTR23zx.js +0 -1
- package/dist/assets/Common-legacy-Bu4A0EQs.js +0 -1
- package/dist/assets/Decompress-D6J5mZmX.js +0 -1
- package/dist/assets/File-HMt4p1bt.js +0 -2
- package/dist/assets/Grid-D4kpsoUh.js +0 -1
- package/dist/assets/Grid-legacy-DyUKe7bQ.js +0 -1
- package/dist/assets/Layout-DJMWDycc.js +0 -6
- package/dist/assets/Layout-legacy-CjghOd32.js +0 -6
- package/dist/assets/List-CTOk2d4m.js +0 -1
- package/dist/assets/List-legacy-IzZZFROW.js +0 -1
- package/dist/assets/Messenger-BQkbQG7l.js +0 -1
- package/dist/assets/Messenger-legacy-BCyOwLup.js +0 -1
- package/dist/assets/Other-DJeb2jK0.js +0 -1
- package/dist/assets/Other-legacy-y8AH6kL4.js +0 -1
- package/dist/assets/Profile-ns9_ZyF2.js +0 -1
- package/dist/assets/ResponsiveGrid-C0UulUty.js +0 -1
- package/dist/assets/Shares-WdL8c7Sh.js +0 -1
- package/dist/assets/Shares-legacy-DT0u0YdD.js +0 -1
- package/dist/assets/Upload-legacy-BnwNk2QJ.js +0 -6
- package/dist/assets/Users-legacy-Con5HL4g.js +0 -1
- package/dist/assets/aliyun_video-BAez-Nd0.js +0 -1
- package/dist/assets/aliyun_video-legacy-RehDwg_I.js +0 -1
- package/dist/assets/archive-legacy-BCzx1MZN.js +0 -1
- package/dist/assets/entry-Bmz-OIH1.js +0 -1
- package/dist/assets/entry-C3niDQ6e.js +0 -1
- package/dist/assets/entry-legacy-C9EzaIT_.js +0 -1
- package/dist/assets/entry-legacy-Dy6hZkgE.js +0 -1
- package/dist/assets/flash-CGj5o-qp.js +0 -1
- package/dist/assets/flash-legacy-eQcFQFG-.js +0 -1
- package/dist/assets/heic-CW4cDVSF.js +0 -1
- package/dist/assets/heic-legacy-CxJkUUcv.js +0 -1
- package/dist/assets/helper-aw8_TacA.js +0 -1
- package/dist/assets/helper-legacy-CK8yvLIc.js +0 -1
- package/dist/assets/hls-BieG3Go3.js +0 -6
- package/dist/assets/hls-legacy-D8-R03Q8.js +0 -8
- package/dist/assets/icon-BHLI6ipM.js +0 -1
- package/dist/assets/icon-legacy-CgGKXaZ7.js +0 -1
- package/dist/assets/index-jlq2Eprg.js +0 -1
- package/dist/assets/index-legacy-COsLKAT0.js +0 -18
- package/dist/assets/index-legacy-CdAmiIpI.js +0 -28
- package/dist/assets/index-legacy-DSLZNPxK.js +0 -1
- package/dist/assets/markdown-legacy-BFkS1Ot_.js +0 -1
- package/dist/assets/markdown_with_word_wrap-legacy-BY6HsH_h.js +0 -1
- package/dist/assets/offline_download-9S_MVKlk.js +0 -1
- package/dist/assets/plist-BfuLrOaV.js +0 -1
- package/dist/assets/video-Bm4wQYfw.js +0 -7
- package/dist/assets/video-legacy-nheuTH-v.js +0 -9
- package/dist/assets/video_box-ClNgqs0q.js +0 -6
- package/dist/assets/video_box-legacy-Dmg8R6zj.js +0 -8
- package/dist/lite/assets/2fa-D4svCGak.js +0 -1
- package/dist/lite/assets/2fa-legacy-D-GD6Sq7.js +0 -1
- package/dist/lite/assets/AddOrEdit-DeUG7ANk.js +0 -1
- package/dist/lite/assets/AddOrEdit-dMaKietS.js +0 -1
- package/dist/lite/assets/AddOrEdit-legacy-BHPkdTBL.js +0 -1
- package/dist/lite/assets/AddOrEdit-legacy-DlLjr4Yf.js +0 -1
- package/dist/lite/assets/Common-legacy-5VxLmGN5.js +0 -1
- package/dist/lite/assets/Common-pfO8swNL.js +0 -1
- package/dist/lite/assets/Decompress-XJrFmeXJ.js +0 -1
- package/dist/lite/assets/File-RwdxpokM.js +0 -2
- package/dist/lite/assets/Grid-10iut_Dk.js +0 -1
- package/dist/lite/assets/Grid-legacy-BGn9FMmp.js +0 -1
- package/dist/lite/assets/Layout-DX_q_tAO.js +0 -6
- package/dist/lite/assets/Layout-legacy-BC1cObb-.js +0 -6
- package/dist/lite/assets/List-Cv17z0Po.js +0 -1
- package/dist/lite/assets/List-legacy-D_AlmgGo.js +0 -1
- package/dist/lite/assets/Messenger-EqvlvEKQ.js +0 -1
- package/dist/lite/assets/Messenger-legacy-CxQz7sq_.js +0 -1
- package/dist/lite/assets/Other-aObNVBF9.js +0 -1
- package/dist/lite/assets/Other-legacy-CSY7ynnm.js +0 -1
- package/dist/lite/assets/Profile-Bxu3nsRH.js +0 -1
- package/dist/lite/assets/ResponsiveGrid-DvSjRnFS.js +0 -1
- package/dist/lite/assets/Shares-ChIImU5T.js +0 -1
- package/dist/lite/assets/Shares-legacy-CgozQl5Q.js +0 -1
- package/dist/lite/assets/Upload-legacy-BTZQZHvI.js +0 -6
- package/dist/lite/assets/Users-legacy-BZmUfLl-.js +0 -1
- package/dist/lite/assets/aliyun_video-CV1o5aGc.js +0 -1
- package/dist/lite/assets/aliyun_video-legacy-C5O8pgpw.js +0 -1
- package/dist/lite/assets/archive-legacy-Q6ptvr-p.js +0 -1
- package/dist/lite/assets/entry-CzDPoMEK.js +0 -1
- package/dist/lite/assets/entry-EPg9s4dA.js +0 -1
- package/dist/lite/assets/entry-legacy-B221uB01.js +0 -1
- package/dist/lite/assets/entry-legacy-DyDgH5jW.js +0 -1
- package/dist/lite/assets/flash-Y36ji-YR.js +0 -1
- package/dist/lite/assets/flash-legacy-ByoTYr7C.js +0 -1
- package/dist/lite/assets/heic-CAYMmZ5H.js +0 -1
- package/dist/lite/assets/heic-legacy-jzdsuYPe.js +0 -1
- package/dist/lite/assets/helper-legacy-CQI2LgPF.js +0 -1
- package/dist/lite/assets/helper-rYV8G9tK.js +0 -1
- package/dist/lite/assets/hls-BxpkA6ke.js +0 -6
- package/dist/lite/assets/hls-legacy-CRV7qw99.js +0 -8
- package/dist/lite/assets/icon-C_-dl6ym.js +0 -1
- package/dist/lite/assets/icon-legacy-B1zSbPkT.js +0 -1
- package/dist/lite/assets/index-CPeT-wnS.js +0 -1
- package/dist/lite/assets/index-legacy-Coo__kNa.js +0 -1
- package/dist/lite/assets/index-legacy-DfmxoxQC.js +0 -18
- package/dist/lite/assets/markdown-legacy-Boenmgl3.js +0 -1
- package/dist/lite/assets/markdown_with_word_wrap-legacy-BvejNkI3.js +0 -1
- package/dist/lite/assets/offline_download-D2uEZvl1.js +0 -1
- package/dist/lite/assets/plist-Dj7rEOZ6.js +0 -1
- package/dist/lite/assets/video-DzAfazMX.js +0 -7
- package/dist/lite/assets/video-legacy-Cg3m1FD_.js +0 -9
- package/dist/lite/assets/video_box-CZdpB5uX.js +0 -6
- package/dist/lite/assets/video_box-legacy-D4DvGejv.js +0 -8
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{dF as ji,cJ as gn,e5 as Ya}from"./index-Bpj9HV4J.js";import{a as zi}from"./index-gxiOhmHK.js";var Dt={exports:{}};Dt.exports;var Xi;function qa(){return Xi||(Xi=1,(function(a,e){/*!
|
|
2
|
-
* artplayer-plugin-danmuku.js v5.1.8
|
|
3
|
-
* Github: https://github.com/zhw2590582/ArtPlayer
|
|
4
|
-
* (c) 2017-2025 Harvey Zack
|
|
5
|
-
* Released under the MIT License.
|
|
6
|
-
*/(function(t,s,i,r,n,o,d,l){var c=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof ji<"u"?ji:{},u=typeof c[r]=="function"&&c[r],h=u.i||{},f=u.cache||{},g=typeof zi=="function"&&zi.bind(a);function m(E,T){if(!f[E]){if(!t[E]){if(n[E])return n[E];var S=typeof c[r]=="function"&&c[r];if(!T&&S)return S(E,!0);if(u)return u(E,!0);if(g&&typeof E=="string")return g(E);var x=Error("Cannot find module '"+E+"'");throw x.code="MODULE_NOT_FOUND",x}A.resolve=function(I){var R=t[E][1][I];return R!=null?R:I},A.cache={};var b=f[E]=new m.Module(E);t[E][0].call(b.exports,A,b,b.exports,c)}return f[E].exports;function A(I){var R=A.resolve(I);return R===!1?{}:m(R)}}m.isParcelRequire=!0,m.Module=function(E){this.id=E,this.bundle=m,this.require=g,this.exports={}},m.modules=t,m.cache=f,m.parent=u,m.distDir=void 0,m.publicUrl=void 0,m.devServer=void 0,m.i=h,m.register=function(E,T){t[E]=[function(S,x){x.exports=T},{}]},Object.defineProperty(m,"root",{get:function(){return c[r]}}),c[r]=m;for(var p=0;p<s.length;p++)m(s[p]);{var v=m(i);a.exports=v}})({jz4E5:[function(t,s,i,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(i),n.export(i,"default",()=>f);var o=t("./danmuku"),d=n.interopDefault(o),l=t("./setting"),c=n.interopDefault(l),u=t("./heatmap"),h=n.interopDefault(u);function f(g){return m=>{let p=new d.default(m,g),v=new c.default(m,p);return p.option.heatmap&&(0,h.default)(m,p,p.option.heatmap),{name:"artplayerPluginDanmuku",emit:p.emit.bind(p),load:p.load.bind(p),config:p.config.bind(p),hide:p.hide.bind(p),show:p.show.bind(p),reset:p.reset.bind(p),mount:v.mount.bind(v),get option(){return p.option},get isHide(){return p.isHide},get isStop(){return p.isStop}}}}f.icons=c.default.icons,typeof window<"u"&&(window.artplayerPluginDanmuku=f)},{"./danmuku":"3oV1P","./setting":"ddE7h","./heatmap":"falVu","@parcel/transformer-js/src/esmodule-helpers.js":"7o2zS"}],"3oV1P":[function(t,s,i,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(i);var o=t("./bilibili"),d=t("bundle-text:./worker"),l=n.interopDefault(d);class c{constructor(h,f){let{constructor:g,template:m}=h;this.utils=g.utils,this.validator=g.validator,this.$danmuku=m.$danmuku,this.$player=m.$player,this.art=h,this.queue=[],this.$refs=[],this.isStop=!1,this.isHide=!1,this.timer=null,this.index=0,this.option=c.option,this.states={wait:[],ready:[],emit:[],stop:[]},this.config(f,!0);let p=new Blob([l.default.replace("export{e as default};","")],{type:"application/javascript"});this.worker=new Worker(URL.createObjectURL(p)),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this.reset=this.reset.bind(this),this.resize=this.resize.bind(this),this.destroy=this.destroy.bind(this),h.on("video:play",this.start),h.on("video:playing",this.start),h.on("video:pause",this.stop),h.on("video:waiting",this.stop),h.on("destroy",this.destroy),h.on("resize",this.resize),this.load()}static get option(){return{danmuku:[],speed:5,margin:[10,"25%"],opacity:1,color:"#FFFFFF",mode:0,modes:[0,1,2],fontSize:25,antiOverlap:!0,synchronousPlayback:!1,mount:void 0,heatmap:!1,width:512,points:[],filter:()=>!0,beforeEmit:()=>!0,beforeVisible:()=>!0,visible:!0,emitter:!0,maxLength:200,lockTime:5,theme:"dark",OPACITY:{},FONT_SIZE:{},MARGIN:{},SPEED:{},COLOR:[]}}static get scheme(){return{danmuku:"array|function|string",speed:"number",margin:"array",opacity:"number",color:"string",mode:"number",modes:"array",fontSize:"number|string",antiOverlap:"boolean",synchronousPlayback:"boolean",mount:"?htmldivelement|string",heatmap:"object|boolean",width:"number",points:"array",filter:"function",beforeEmit:"function",beforeVisible:"function",visible:"boolean",emitter:"boolean",maxLength:"number",lockTime:"number",theme:"string",OPACITY:"object",FONT_SIZE:"object",MARGIN:"object",SPEED:"object",COLOR:"array"}}static get cssText(){return' user-select: none; position: absolute; white-space: pre; pointer-events: none; perspective: 500px; display: inline-block; will-change: transform; font-weight: normal; line-height: 1.125; visibility: hidden; font-family: SimHei, "Microsoft JhengHei", Arial, Helvetica, sans-serif; text-shadow: rgb(0, 0, 0) 1px 0px 1px, rgb(0, 0, 0) 0px 1px 1px, rgb(0, 0, 0) 0px -1px 1px, rgb(0, 0, 0) -1px 0px 1px; '}get isRotate(){var h,f;return(f=(h=this.art.plugins)==null?void 0:h.autoOrientation)==null?void 0:f.state}get marginTop(){let{clamp:h}=this.utils,f=this.option.margin[0],{clientHeight:g}=this.$player;return typeof f=="number"?h(f,0,g):typeof f=="string"&&f.endsWith("%")?h(g*(parseFloat(f)/100),0,g):c.option.margin[0]}get marginBottom(){let{clamp:h}=this.utils,f=this.option.margin[1],{clientHeight:g}=this.$player;return typeof f=="number"?h(f,0,g):typeof f=="string"&&f.endsWith("%")?h(g*(parseFloat(f)/100),0,g):c.option.margin[1]}get fontSize(){let{clamp:h}=this.utils,{clientHeight:f}=this.$player,g=this.option.fontSize;return typeof g=="number"?Math.round(h(g,12,f)):typeof g=="string"&&g.endsWith("%")?Math.round(h(f*(parseFloat(g)/100),12,f)):c.option.fontSize}get $ref(){let h=this.$refs.pop()||document.createElement("div");return h.style.cssText=c.cssText,h.dataset.mode="",h.className="",h}get readys(){let{currentTime:h}=this.art,f=[];return this.filter("ready",g=>f.push(g)),this.filter("wait",g=>{h+.1>=g.time&&g.time>=h-.1&&f.push(g)}),f}get visibles(){let h=[],{clientWidth:f}=this.$player,g=this.getLeft(this.$player);return this.filter("emit",m=>{let p=m.$ref.offsetTop,v=this.getLeft(m.$ref)-g,E=m.$ref.clientHeight,T=m.$ref.clientWidth,S=v+T,x=S/m.$restTime,b={};b.top=p,b.left=v,b.height=E,b.width=T,b.right=f-S,b.speed=x,b.distance=S,b.time=m.$restTime,b.mode=m.mode,h.push(b)}),h}get speed(){return this.option.synchronousPlayback&&this.art.playbackRate?this.option.speed/Number(this.art.playbackRate):this.option.speed}async load(h){let{errorHandle:f}=this.utils,g=[],m=h||this.option.danmuku;try{typeof m=="function"?g=await m():m instanceof Promise?g=await m:typeof m=="string"?g=await(0,o.bilibiliDanmuParseFromUrl)(m):Array.isArray(m)&&(g=m),f(Array.isArray(g),"Danmuku need return an array as result"),h===void 0&&(this.reset(),this.queue=[],this.states={wait:[],ready:[],emit:[],stop:[]},this.$refs=[],this.$danmuku.innerText="");for(let p=0;p<g.length;p++){let v=g[p];await this.emit(v)}this.art.emit("artplayerPluginDanmuku:loaded",this.queue)}catch(p){throw this.art.emit("artplayerPluginDanmuku:error",p),p}return this}async emit(h){let{clamp:f}=this.utils;if(this.validator(h,{text:"string",mode:"?number",color:"?string",time:"?number",border:"?boolean",style:"?object"}),!h.text.trim()||(h.time?h.time=f(h.time,0,1/0):h.time=this.art.currentTime+.5,h.mode===void 0&&(h.mode=this.option.mode),h.style===void 0&&(h.style={}),h.color===void 0&&(h.color=this.option.color),![0,1,2].includes(h.mode)||!this.option.filter(h)))return this;let g={...h,$state:"wait",$id:this.index++,$ref:null,$restTime:0,$lastStartTime:0};return this.setState(g,"wait"),this.queue.push(g),this}config(h,f=!1){let{clamp:g}=this.utils,{$controlsCenter:m}=this.art.template;return(Object.keys(h).some(p=>JSON.stringify(this.option[p])!==JSON.stringify(h[p]))||f)&&(this.option=Object.assign({},c.option,this.option,h),this.validator(this.option,c.scheme),this.option.mode=g(this.option.mode,0,2),this.option.speed=g(this.option.speed,1,10),this.option.opacity=g(this.option.opacity,0,1),this.option.lockTime=g(this.option.lockTime,1,60),this.option.maxLength=g(this.option.maxLength,1,1e3),this.option.mount=this.option.mount||m,h.fontSize&&this.reset(),this.option.visible?this.show():this.hide(),this.art.emit("artplayerPluginDanmuku:config",this.option)),this}getLeft(h){let f=h.getBoundingClientRect();return this.isRotate?f.top:f.left}postMessage(h={}){return new Promise(f=>{h.id=Date.now(),this.worker.postMessage(h),this.worker.onmessage=g=>{let{data:m}=g;m.id===h.id&&f(m)}})}filter(h,f){let g=this.states[h]||[];for(let m=0;m<g.length;m++)f(g[m]);return g}setState(h,f){this.states[h.$state]=this.states[h.$state].filter(g=>g!==h),h.$state=f,h.$ref&&(h.$ref.dataset.state=f),this.states[f].push(h)}makeWait(h){this.setState(h,"wait"),h.$ref&&(h.$ref.style.cssText=c.cssText,h.$ref.style.visibility="hidden",h.$ref.style.marginLeft="0px",h.$ref.style.transform="translateX(0px)",h.$ref.style.transition="transform 0s linear 0s",this.$refs.push(h.$ref),h.$ref=null)}update(){let{setStyles:h}=this.utils;return this.timer=window.requestAnimationFrame(async()=>{if(this.art.playing&&!this.isHide){this.filter("emit",g=>{let m=(Date.now()-g.$lastStartTime)/1e3;g.$restTime-=m,g.$lastStartTime=Date.now(),g.$restTime<=0&&this.makeWait(g)});let f=this.readys;for(let g=0;g<f.length;g++){let m=f[g];if(await this.option.beforeVisible(m)){let{clientWidth:p,clientHeight:v}=this.$player;m.$ref=this.$ref,m.$ref.innerText=m.text,this.$danmuku.appendChild(m.$ref),m.$ref.style.opacity=this.option.opacity,m.$ref.style.fontSize="".concat(this.fontSize,"px"),m.$ref.style.color=m.color,m.$ref.style.border=m.border?"1px solid ".concat(m.color):null,m.$ref.style.backgroundColor=m.border?"rgb(0 0 0 / 50%)":null,h(m.$ref,m.style),m.$lastStartTime=Date.now(),m.$restTime=this.speed;let E=p+m.$ref.clientWidth,{result:T}=await this.postMessage({type:"getDanmuTop",target:{mode:m.mode,height:m.$ref.clientHeight,speed:E/m.$restTime},visibles:this.visibles,antiOverlap:this.option.antiOverlap,clientWidth:p,clientHeight:v,marginBottom:this.marginBottom,marginTop:this.marginTop});if(m.$ref)if(this.isStop||T===void 0)this.setState(m,"ready"),this.$refs.push(m.$ref),m.$ref=null;else{switch(this.setState(m,"emit"),m.$ref.style.top="".concat(T,"px"),m.$ref.style.visibility="visible",m.$ref.dataset.mode=m.mode,m.mode){case 0:m.$ref.style.left="".concat(p,"px"),m.$ref.style.marginLeft="0px",m.$ref.style.transform="translateX(".concat(-E,"px)"),m.$ref.style.transition="transform ".concat(m.$restTime,"s linear 0s");break;case 1:case 2:m.$ref.style.left="50%",m.$ref.style.marginLeft="-".concat(m.$ref.clientWidth/2,"px")}this.art.emit("artplayerPluginDanmuku:visible",m)}}}}this.isStop||this.update()}),this}resize(){let{clientWidth:h}=this.$player;this.filter("stop",f=>{f.mode===0&&(f.$ref.style.left="".concat(h,"px"))}),this.filter("emit",f=>{if(f.$lastStartTime=Date.now(),f.mode===0){let g=h+f.$ref.clientWidth;f.$ref.style.left="".concat(h,"px"),f.$ref.style.transform="translateX(".concat(-g,"px)"),f.$ref.style.transition="transform ".concat(f.$restTime,"s linear 0s")}})}continue(){let{clientWidth:h}=this.$player;return this.filter("stop",f=>{if(this.setState(f,"emit"),f.$lastStartTime=Date.now(),f.mode===0){let g=h+f.$ref.clientWidth;f.$ref.style.transform="translateX(".concat(-g,"px)"),f.$ref.style.transition="transform ".concat(f.$restTime,"s linear 0s")}}),this}suspend(){let{clientWidth:h}=this.$player;return this.filter("emit",f=>{if(this.setState(f,"stop"),f.mode===0){let g=h-(this.getLeft(f.$ref)-this.getLeft(this.$player));f.$ref.style.transform="translateX(".concat(-g,"px)"),f.$ref.style.transition="transform 0s linear 0s"}}),this}stop(){return this.isStop=!0,this.suspend(),window.cancelAnimationFrame(this.timer),this.art.emit("artplayerPluginDanmuku:stop"),this}start(){return this.isStop=!1,this.continue(),this.update(),this.art.emit("artplayerPluginDanmuku:start"),this}reset(){return this.queue.forEach(h=>this.makeWait(h)),this.art.emit("artplayerPluginDanmuku:reset"),this}show(){return this.isHide=!1,this.$danmuku.style.opacity=1,this.option.visible=!0,this.art.emit("artplayerPluginDanmuku:show"),this}hide(){return this.isHide=!0,this.$danmuku.style.opacity=0,this.option.visible=!1,this.art.emit("artplayerPluginDanmuku:hide"),this}destroy(){this.stop(),this.worker.terminate(),this.art.off("video:play",this.start),this.art.off("video:playing",this.start),this.art.off("video:pause",this.stop),this.art.off("video:waiting",this.stop),this.art.off("resize",this.reset),this.art.off("destroy",this.destroy),this.art.emit("artplayerPluginDanmuku:destroy")}}i.default=c},{"./bilibili":"4KZjR","bundle-text:./worker":"4Jmn3","@parcel/transformer-js/src/esmodule-helpers.js":"7o2zS"}],"4KZjR":[function(t,s,i,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");function o(u){switch(u){case 1:case 2:case 3:default:return 0;case 4:return 2;case 5:return 1}}function d(u){if(typeof u!="string")return[];let h=new RegExp(new RegExp('<d (?:.*? )??p="(?<p>.+?)"(?: .*?)?>(?<text>.+?)<\\/d>',"gs"));return Array.from(u.matchAll(h)).map(f=>{let g=f.groups.p.split(",");return g.length>=8?{text:f.groups.text.trim().replaceAll(""",'"').replaceAll("'","'").replaceAll("<","<").replaceAll(">",">").replaceAll("&","&"),time:Number(g[0]),mode:o(Number(g[1])),fontSize:Number(g[2]),color:"#".concat(Number(g[3]).toString(16)),timestamp:Number(g[4]),pool:Number(g[5]),userID:g[6],rowID:Number(g[7])}:null}).filter(Boolean)}function l({data:u}){let{xml:h,id:f}=u;if(!f||!h)return;let g=d(h);self.postMessage({danmus:g,id:f})}function c(u){return new Promise(async h=>{let f=await fetch(u),g=await f.text();try{let m=(function(){let p=new Blob([" ".concat(o.toString()," ").concat(d.toString()," onmessage = ").concat(l.toString()," ")],{type:"application/javascript"});return new Worker(URL.createObjectURL(p))})();m.onmessage=p=>{let{danmus:v,id:E}=p.data;E&&v&&(h(v),m.terminate())},m.postMessage({xml:g,id:Date.now()})}catch(m){h(d(g))}})}n.defineInteropFlag(i),n.export(i,"bilibiliDanmuParseFromUrl",()=>c)},{"@parcel/transformer-js/src/esmodule-helpers.js":"7o2zS"}],"7o2zS":[function(t,s,i,r){i.interopDefault=function(n){return n&&n.__esModule?n:{default:n}},i.defineInteropFlag=function(n){Object.defineProperty(n,"__esModule",{value:!0})},i.exportAll=function(n,o){return Object.keys(n).forEach(function(d){d==="default"||d==="__esModule"||Object.prototype.hasOwnProperty.call(o,d)||Object.defineProperty(o,d,{enumerable:!0,get:function(){return n[d]}})}),o},i.export=function(n,o,d){Object.defineProperty(n,o,{enumerable:!0,get:d})}},{}],"4Jmn3":[function(t,s,i,r){s.exports='!function(e,t,i,o,n,r,f,l){var d="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},u="function"==typeof d[o]&&d[o],h=u.i||{},p=u.cache||{},s="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function a(t,i){if(!p[t]){if(!e[t]){if(n[t])return n[t];var r="function"==typeof d[o]&&d[o];if(!i&&r)return r(t,!0);if(u)return u(t,!0);if(s&&"string"==typeof t)return s(t);var f=Error("Cannot find module \'"+t+"\'");throw f.code="MODULE_NOT_FOUND",f}h.resolve=function(i){var o=e[t][1][i];return null!=o?o:i},h.cache={};var l=p[t]=new a.Module(t);e[t][0].call(l.exports,h,l,l.exports,d)}return p[t].exports;function h(e){var t=h.resolve(e);return!1===t?{}:a(t)}}a.isParcelRequire=!0,a.Module=function(e){this.id=e,this.bundle=a,this.require=s,this.exports={}},a.modules=e,a.cache=p,a.parent=u,a.distDir=void 0,a.publicUrl=void 0,a.devServer=void 0,a.i=h,a.register=function(t,i){e[t]=[function(e,t){t.exports=i},{}]},Object.defineProperty(a,"root",{get:function(){return d[o]}}),d[o]=a;for(var c=0;c<t.length;c++)a(t[c]);if(i){var g=a(i);"object"==typeof exports&&"undefined"!=typeof module?module.exports=g:"function"==typeof define&&define.amd&&define(function(){return g})}}({"3DCG7":[function(e,t,i,o){function n({target:e,visibles:t,clientWidth:i,clientHeight:o,marginBottom:n,marginTop:r,antiOverlap:f}){let l=o-n,d=t.filter(t=>t.mode===e.mode&&t.top<=l).sort((e,t)=>e.top-t.top);if(0===d.length)if(2===e.mode)return l-e.height;else return r;if(d.unshift({type:"top",top:0,left:0,right:0,height:r,width:i,speed:0,distance:i}),d.push({type:"bottom",top:l,left:0,right:0,height:n,width:i,speed:0,distance:i}),2===e.mode)for(let t=d.length-2;t>=0;t-=1){let i=d[t],o=d[t+1],n=i.top+i.height;if(o.top-n>=e.height)return o.top-e.height}else for(let t=1;t<d.length;t+=1){let i=d[t],o=d[t-1],n=o.top+o.height;if(i.top-n>=e.height)return n}let u=[];for(let e=1;e<d.length-1;e+=1){let t=d[e];if(u.length){let e=u[u.length-1];e[0].top===t.top?e.push(t):u.push([t])}else u.push([t])}if(f)switch(e.mode){case 0:{let t=u.find(t=>t.every(t=>!(i<t.distance)&&(!!(e.speed<t.speed)||!!(t.right/(e.speed-t.speed)>t.time))));return t&&t[0]?t[0].top:void 0}case 1:case 2:return}else{switch(e.mode){case 0:u.sort((e,t)=>{let i=Math.min(...t.map(e=>e.right)),o=Math.min(...e.map(e=>e.right));return i*t.length-o*e.length});break;case 1:case 2:u.sort((e,t)=>{let i=Math.max(...t.map(e=>e.width));return Math.max(...e.map(e=>e.width))*e.length-i*t.length})}return u[0][0].top}}onmessage=e=>{let{data:t}=e;if(!t.id||!t.type)return;let i=(0,({getDanmuTop:n})[t.type])(t);self.postMessage({result:i,id:t.id})}},{}]},["3DCG7"],"3DCG7","parcelRequire93cf",{});'},{}],ddE7h:[function(t,s,i,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(i);var o=t("bundle-text:./style.less"),d=n.interopDefault(o),l=t("bundle-text:./img/on.svg"),c=n.interopDefault(l),u=t("bundle-text:./img/off.svg"),h=n.interopDefault(u),f=t("bundle-text:./img/config.svg"),g=n.interopDefault(f),m=t("bundle-text:./img/style.svg"),p=n.interopDefault(m),v=t("bundle-text:./img/mode_0_off.svg"),E=n.interopDefault(v),T=t("bundle-text:./img/mode_0_on.svg"),S=n.interopDefault(T),x=t("bundle-text:./img/mode_1_off.svg"),b=n.interopDefault(x),A=t("bundle-text:./img/mode_1_on.svg"),I=n.interopDefault(A),R=t("bundle-text:./img/mode_2_off.svg"),L=n.interopDefault(R),w=t("bundle-text:./img/mode_2_on.svg"),U=n.interopDefault(w),V=t("bundle-text:./img/check_on.svg"),B=n.interopDefault(V),N=t("bundle-text:./img/check_off.svg"),M=n.interopDefault(N);if(i.default=class{constructor(C,k){this.art=C,this.danmuku=k,this.utils=C.constructor.utils;let{setStyle:O}=this.utils,{$controlsCenter:G}=C.template;O(G,"display","flex"),this.template={$controlsCenter:G,$mount:G,$danmuku:null,$toggle:null,$config:null,$configPanel:null,$configModes:null,$style:null,$stylePanel:null,$styleModes:null,$colors:null,$opacitySlider:null,$opacityValue:null,$marginSlider:null,$marginValue:null,$fontSizeSlider:null,$fontSizeValue:null,$speedSlider:null,$speedValue:null,$input:null,$send:null},this.slider={opacity:null,margin:null,fontSize:null,speed:null},this.emitting=!1,this.isLock=!1,this.timer=null,this.createTemplate(),this.createSliders(),this.createEvents(),this.mount(this.option.mount),C.on("resize",()=>this.resize()),C.on("fullscreen",F=>this.onFullscreen(F)),C.on("fullscreenWeb",F=>this.onFullscreen(F)),C.proxy(this.template.$config,"mouseenter",()=>{this.onMouseEnter({$control:this.template.$config,$panel:this.template.$configPanel})}),C.proxy(this.template.$style,"mouseenter",()=>{this.onMouseEnter({$control:this.template.$style,$panel:this.template.$stylePanel})})}static get icons(){return{$on:c.default,$off:h.default,$config:g.default,$style:p.default,$mode_0_off:E.default,$mode_0_on:S.default,$mode_1_off:b.default,$mode_1_on:I.default,$mode_2_off:L.default,$mode_2_on:U.default,$check_on:B.default,$check_off:M.default}}get option(){return this.danmuku.option}get outside(){return this.template.$mount!==this.template.$controlsCenter}get TEMPLATE(){let{option:C}=this;return'<div class="apd-toggle">'.concat(c.default).concat(h.default,'</div><div class="apd-config">').concat(g.default,'<div class="apd-config-panel"><div class="apd-config-panel-inner"><div class="apd-config-mode">按类型屏蔽<div class="apd-modes"><div data-mode="0" class="apd-mode">').concat(E.default).concat(S.default,'<div>滚动</div></div><div data-mode="1" class="apd-mode">').concat(b.default).concat(I.default,'<div>顶部</div></div><div data-mode="2" class="apd-mode">').concat(L.default).concat(U.default,'<div>底部</div></div></div></div><div class="apd-config-other"><div class="apd-other apd-anti-overlap">').concat(B.default).concat(M.default,' 防止弹幕重叠</div><div class="apd-other apd-sync-video">').concat(B.default).concat(M.default,' 同步视频速度</div></div><div class="apd-config-slider apd-config-opacity">不透明度<div class="apd-slider"></div><div class="apd-value">未知</div></div><div class="apd-config-slider apd-config-margin">显示区域<div class="apd-slider"></div><div class="apd-value">未知</div></div><div class="apd-config-slider apd-config-fontSize">弹幕字号<div class="apd-slider"></div><div class="apd-value">未知</div></div><div class="apd-config-slider apd-config-speed">弹幕速度<div class="apd-slider"></div><div class="apd-value">未知</div></div></div></div></div><div class="apd-emitter"><div class="apd-style">').concat(p.default,'<div class="apd-style-panel"><div class="apd-style-panel-inner"><div class="apd-style-mode">模式<div class="apd-modes"><div data-mode="0" class="apd-mode">').concat(S.default,'<div>滚动</div></div><div data-mode="1" class="apd-mode">').concat(I.default,'<div>顶部</div></div><div data-mode="2" class="apd-mode">').concat(U.default,'<div>底部</div></div></div></div><div class="apd-style-color">颜色<div class="apd-colors">').concat(this.COLOR.map(k=>'<div data-color="'.concat(k,'" class="apd-color" style="background-color: ').concat(k,'"></div>')).join(""),'</div></div></div></div></div><input class="apd-input" placeholder="发个友善的弹幕见证当下" autocomplete="off" maxLength="').concat(C.maxLength,'" /><div class="apd-send">发送</div></div>')}get OPACITY(){return{min:0,max:100,steps:[],...this.option.OPACITY}}get FONT_SIZE(){return{min:12,max:120,steps:[],...this.option.FONT_SIZE}}get MARGIN(){return{min:0,max:3,steps:[{name:"1/4",value:[10,"75%"]},{name:"半屏",value:[10,"50%"]},{name:"3/4",value:[10,"25%"]},{name:"满屏",value:[10,10]}],...this.option.MARGIN}}get SPEED(){return{min:0,max:4,steps:[{name:"极慢",value:10},{name:"较慢",value:7.5,hide:!0},{name:"适中",value:5},{name:"较快",value:2.5,hide:!0},{name:"极快",value:1}],...this.option.SPEED}}get COLOR(){return this.option.COLOR.length?this.option.COLOR:["#FE0302","#FF7204","#FFAA02","#FFD302","#FFFF00","#A0EE00","#00CD00","#019899","#4266BE","#89D5FF","#CC0273","#222222","#9B9B9B","#FFFFFF"]}query(C){let{query:k}=this.utils,{$danmuku:O}=this.template;return k(C,O)}append(C,k){let{append:O}=this.utils;[...C.children].some(G=>G===k)||O(C,k)}setData(C,k){let{$player:O}=this.art.template,{$mount:G}=this.template;O.dataset[C]=k,this.outside&&(G.dataset[C]=k)}createTemplate(){let{createElement:C,tooltip:k}=this.utils,O=C("div");O.className="artplayer-plugin-danmuku",O.innerHTML=this.TEMPLATE,this.template.$danmuku=O,this.template.$toggle=this.query(".apd-toggle"),this.template.$config=this.query(".apd-config"),this.template.$configPanel=this.query(".apd-config-panel"),this.template.$configModes=this.query(".apd-config-mode .apd-modes"),this.template.$style=this.query(".apd-style"),this.template.$stylePanel=this.query(".apd-style-panel"),this.template.$styleModes=this.query(".apd-style-mode .apd-modes"),this.template.$colors=this.query(".apd-colors"),this.template.$antiOverlap=this.query(".apd-anti-overlap"),this.template.$syncVideo=this.query(".apd-sync-video"),this.template.$opacitySlider=this.query(".apd-config-opacity .apd-slider"),this.template.$opacityValue=this.query(".apd-config-opacity .apd-value"),this.template.$marginSlider=this.query(".apd-config-margin .apd-slider"),this.template.$marginValue=this.query(".apd-config-margin .apd-value"),this.template.$fontSizeSlider=this.query(".apd-config-fontSize .apd-slider"),this.template.$fontSizeValue=this.query(".apd-config-fontSize .apd-value"),this.template.$speedSlider=this.query(".apd-config-speed .apd-slider"),this.template.$speedValue=this.query(".apd-config-speed .apd-value"),this.template.$input=this.query(".apd-input"),this.template.$send=this.query(".apd-send");let{$toggle:G}=this.template;this.art.on("artplayerPluginDanmuku:show",()=>{k(G,"关闭弹幕")}),this.art.on("artplayerPluginDanmuku:hide",()=>{k(G,"打开弹幕")})}createEvents(){let{$toggle:C,$configModes:k,$styleModes:O,$colors:G,$antiOverlap:F,$syncVideo:$,$send:q,$input:Z}=this.template;this.art.proxy(C,"click",()=>{this.danmuku.config({visible:!this.option.visible}),this.reset()}),this.art.proxy(k,"click",Y=>{let j=Y.target.closest(".apd-mode");if(!j)return;let oe=Number(j.dataset.mode);this.option.modes.includes(oe)?this.danmuku.config({modes:this.option.modes.filter(le=>le!==oe)}):this.danmuku.config({modes:[...this.option.modes,oe]}),this.reset()}),this.art.proxy(F,"click",()=>{this.danmuku.config({antiOverlap:!this.option.antiOverlap}),this.reset()}),this.art.proxy($,"click",()=>{this.danmuku.config({synchronousPlayback:!this.option.synchronousPlayback}),this.reset()}),this.art.proxy(O,"click",Y=>{let j=Y.target.closest(".apd-mode");if(!j)return;let oe=Number(j.dataset.mode);this.danmuku.config({mode:oe}),this.reset()}),this.art.proxy(G,"click",Y=>{let j=Y.target.closest(".apd-color");j&&(this.danmuku.config({color:j.dataset.color}),this.reset())}),this.art.proxy(q,"click",()=>this.emit()),this.art.proxy(Z,"keypress",Y=>{Y.key==="Enter"&&(Y.preventDefault(),this.emit())})}createSliders(){this.slider.opacity=this.createSlider({...this.OPACITY,container:this.template.$opacitySlider,findIndex:()=>Math.round(100*this.option.opacity),onChange:C=>{let{$opacityValue:k}=this.template;k.textContent="".concat(C,"%"),this.danmuku.config({opacity:C/100})}}),this.slider.margin=this.createSlider({...this.MARGIN,container:this.template.$marginSlider,findIndex:()=>this.MARGIN.steps.findIndex(C=>C.value[0]===this.option.margin[0]&&C.value[1]===this.option.margin[1]),onChange:C=>{let k=this.MARGIN.steps[C];if(!k)return;let{$marginValue:O}=this.template;O.textContent=k.name,this.danmuku.config({margin:k.value})}}),this.slider.fontSize=this.createSlider({...this.FONT_SIZE,container:this.template.$fontSizeSlider,findIndex:()=>this.danmuku.fontSize,onChange:C=>{let{$fontSizeValue:k}=this.template;k.textContent="".concat(C,"px"),C!==this.danmuku.fontSize&&this.danmuku.config({fontSize:C})}}),this.slider.speed=this.createSlider({...this.SPEED,container:this.template.$speedSlider,findIndex:()=>this.SPEED.steps.findIndex(C=>C.value===this.option.speed),onChange:C=>{let k=this.SPEED.steps[C];if(!k)return;let{$speedValue:O}=this.template;O.textContent=k.name,this.danmuku.config({speed:k.value})}})}createSlider({min:C,max:k,container:O,findIndex:G,onChange:F,steps:$=[]}){let{query:q,clamp:Z,setStyle:Y}=this.utils;Y(O,"touch-action","none"),O.innerHTML='<div class="apd-slider-line"><div class="apd-slider-points">'.concat($.map(()=>'<div class="apd-slider-point"></div>').join(""),'</div><div class="apd-slider-progress"></div></div><div class="apd-slider-dot"></div><div class="apd-slider-steps">').concat($.map(ae=>ae.hide?"":'<div class="apd-slider-step">'.concat(ae.name,"</div>")).join(""),"</div>");let j=q(".apd-slider-dot",O),oe=q(".apd-slider-progress",O),le=!1;function ye(ae=G()){if(ae<C||ae>k)return;let At=(ae-C)/(k-C);j.style.left="".concat(100*At,"%"),$.length===0&&(oe.style.width=j.style.left),F(ae)}function Se(ae){let{top:At,height:dt,left:Lt,width:Gt}=O.getBoundingClientRect();this.art.isRotate?ye(Math.round(Z(ae.clientY-At,0,dt)/dt*(k-C)+C)):ye(Math.round(Z(ae.clientX-Lt,0,Gt)/Gt*(k-C)+C))}return this.art.proxy(O,"click",ae=>{Se.call(this,ae)}),this.art.proxy(O,"pointerdown",ae=>{le=ae.button===0}),this.art.proxy(document,"pointermove",ae=>{le&&Se.call(this,ae)}),this.art.proxy(document,"pointerup",ae=>{le&&(le=!1,Se.call(this,ae))}),{reset:ye}}onFullscreen(C){let{$danmuku:k,$controlsCenter:O,$mount:G}=this.template;this.outside?C?this.append(O,k):this.append(G,k):this.append(O,k)}onMouseEnter({$control:C,$panel:k}){let{$player:O}=this.art.template,G=C.getBoundingClientRect(),F=k.getBoundingClientRect(),$=O.getBoundingClientRect(),q=F.width/2-G.width/2,Z=$.left-(G.left-q),Y=G.right+q-$.right;Z>0?k.style.left="".concat(-q+Z,"px"):Y>0?k.style.left="".concat(-q-Y,"px"):k.style.left="".concat(-q,"px")}async emit(){let{$input:C}=this.template,k=C.value.trim();if(!k.length||this.isLock||this.emitting)return;let O={text:k,mode:this.option.mode,color:this.option.color,time:this.art.currentTime};try{this.emitting=!0;let G=await this.option.beforeEmit(O);if(this.emitting=!1,G!==!0)return;O.border=!0,delete O.time,this.danmuku.emit(O),C.value="",this.lock()}catch(G){this.emitting=!1}}lock(){let{addClass:C}=this.utils,{$send:k}=this.template;this.isLock=!0;let O=this.option.lockTime;k.innerText=O,C(k,"apd-lock");let G=()=>{this.timer=setTimeout(()=>{O===0?this.unlock():(k.innerText=O-=1,G())},1e3)};G()}unlock(){let{removeClass:C}=this.utils,{$send:k}=this.template;clearTimeout(this.timer),this.isLock=!1,k.innerText="发送",C(k,"apd-lock")}resize(){if(this.outside||this.art.fullscreen||this.art.fullscreenWeb)return;let{$player:C,$controlsCenter:k}=this.art.template,{$danmuku:O}=this.template;this.art.width<this.option.width?this.append(C,O):this.append(k,O)}reset(){let{inverseClass:C,tooltip:k}=this.utils,{$toggle:O,$colors:G}=this.template;this.slider.opacity.reset(),this.slider.margin.reset(),this.slider.fontSize.reset(),this.slider.speed.reset(),this.setData("danmukuVisible",this.option.visible),this.setData("danmukuMode",this.option.mode),this.setData("danmukuColor",this.option.color),this.setData("danmukuMode0",this.option.modes.includes(0)),this.setData("danmukuMode1",this.option.modes.includes(1)),this.setData("danmukuMode2",this.option.modes.includes(2)),this.setData("danmukuAntiOverlap",this.option.antiOverlap),this.setData("danmukuSyncVideo",this.option.synchronousPlayback),this.setData("danmukuTheme",this.option.theme),this.setData("danmukuEmitter",this.option.emitter);let F=Array.from(G.children).find($=>$.dataset.color===this.option.color.toUpperCase());F&&C(F,"apd-active"),k(O,this.option.visible?"关闭弹幕":"打开弹幕"),this.resize()}mount(C){let{errorHandle:k}=this.utils,O=typeof C=="string"?document.querySelector(C):C;k(O,"Can not find the mount point: ".concat(C)),this.append(O,this.template.$danmuku),this.template.$mount=O,this.reset()}},typeof document<"u"){let C="artplayer-plugin-danmuku",k=document.getElementById(C);k||((k=document.createElement("style")).id=C,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{document.head.appendChild(k)}):(document.head||document.documentElement).appendChild(k)),k.textContent=d.default}},{"bundle-text:./style.less":"jaQAo","bundle-text:./img/on.svg":"86CEd","bundle-text:./img/off.svg":"3FcnK","bundle-text:./img/config.svg":"j1vhO","bundle-text:./img/style.svg":"jmfTi","bundle-text:./img/mode_0_off.svg":"ffHqV","bundle-text:./img/mode_0_on.svg":"eGfex","bundle-text:./img/mode_1_off.svg":"77326","bundle-text:./img/mode_1_on.svg":"6P4nN","bundle-text:./img/mode_2_off.svg":"cBcwx","bundle-text:./img/mode_2_on.svg":"i6KC4","bundle-text:./img/check_on.svg":"2H4K5","bundle-text:./img/check_off.svg":"4JI0m","@parcel/transformer-js/src/esmodule-helpers.js":"7o2zS"}],jaQAo:[function(t,s,i,r){s.exports='.artplayer-plugin-danmuku{z-index:99;color:#fff;flex-shrink:0;justify-content:center;align-items:center;gap:10px;width:100%;height:32px;font-size:12px;font-weight:300;display:flex;position:relative}.artplayer-plugin-danmuku .apd-icon{cursor:pointer;opacity:.75;fill:#fff;transition:all .2s}.artplayer-plugin-danmuku .apd-icon:hover{opacity:1}.artplayer-plugin-danmuku .apd-config{display:flex;position:relative}.artplayer-plugin-danmuku .apd-config .apd-config-panel{opacity:0;pointer-events:none;width:320px;padding:10px;position:absolute;bottom:24px;left:0}.artplayer-plugin-danmuku .apd-config .apd-config-panel .apd-config-panel-inner{background-color:#000000d9;border-radius:3px;width:100%;padding:10px}.artplayer-plugin-danmuku .apd-config:hover .apd-config-panel{opacity:100;pointer-events:all}.artplayer-plugin-danmuku .apd-config-mode,.artplayer-plugin-danmuku .apd-config-slider,.artplayer-plugin-danmuku .apd-config-other,.artplayer-plugin-danmuku .apd-style-mode{margin-bottom:15px}.artplayer-plugin-danmuku .apd-modes{align-items:center;gap:20px;margin-top:5px;display:flex}.artplayer-plugin-danmuku .apd-modes .apd-mode{cursor:pointer;text-align:center}.artplayer-plugin-danmuku .apd-modes .apd-mode:hover{color:#00a1d6}.artplayer-plugin-danmuku .apd-config-slider{align-items:center;gap:12px;display:flex}.artplayer-plugin-danmuku .apd-config-slider .apd-value{text-align:right;width:32px}.artplayer-plugin-danmuku .apd-slider{cursor:pointer;flex:1;justify-content:center;align-items:center;height:20px;display:flex;position:relative}.artplayer-plugin-danmuku .apd-slider .apd-slider-line{background-color:#ffffff40;border-radius:3px;width:100%;height:2px;position:relative;overflow:hidden}.artplayer-plugin-danmuku .apd-slider .apd-slider-points{justify-content:space-between;align-items:center;display:flex;position:absolute;inset:0}.artplayer-plugin-danmuku .apd-slider .apd-slider-points .apd-slider-point{background-color:#ffffff80;border-radius:50%;width:2px;height:2px}.artplayer-plugin-danmuku .apd-slider .apd-slider-progress{background-color:#00a1d6;width:0%;height:100%}.artplayer-plugin-danmuku .apd-slider .apd-slider-dot{background-color:#00a1d6;border-radius:50%;width:12px;height:12px;position:absolute;left:0%;transform:translate(-6px)}.artplayer-plugin-danmuku .apd-slider .apd-slider-steps{color:#777;justify-content:space-between;align-items:center;width:calc(100% + 32px);display:flex;position:absolute;bottom:-12px}.artplayer-plugin-danmuku .apd-slider .apd-slider-steps .apd-slider-step{text-align:center;flex-shrink:0;width:36px;scale:.95}.artplayer-plugin-danmuku .apd-config-other{align-items:center;gap:20px;display:flex}.artplayer-plugin-danmuku .apd-config-other .apd-check-off,.artplayer-plugin-danmuku .apd-config-other .apd-check-on{width:16px;height:16px}.artplayer-plugin-danmuku .apd-config-other .apd-other{cursor:pointer;align-items:center;gap:2px;display:flex}.artplayer-plugin-danmuku .apd-config-other .apd-other:hover{color:#00a1d6}.artplayer-plugin-danmuku .apd-emitter{background-color:#ffffff40;border-radius:5px;flex:1;align-items:center;height:100%;display:flex}.artplayer-plugin-danmuku .apd-style{justify-content:center;align-items:center;display:flex;position:relative}.artplayer-plugin-danmuku .apd-style .apd-style-panel{opacity:0;pointer-events:none;width:200px;padding:10px;position:absolute;bottom:24px;left:0}.artplayer-plugin-danmuku .apd-style .apd-style-panel .apd-style-panel-inner{background-color:#000000d9;border-radius:3px;width:100%;padding:10px}.artplayer-plugin-danmuku .apd-style:hover .apd-style-panel{opacity:100;pointer-events:all}.artplayer-plugin-danmuku .apd-colors{flex-wrap:wrap;gap:8px;margin-top:5px;display:flex}.artplayer-plugin-danmuku .apd-colors .apd-color{cursor:pointer;border-radius:2px;width:16px;height:16px}.artplayer-plugin-danmuku .apd-colors .apd-color.apd-active{border:1px solid #000;box-shadow:0 0 0 1px #fff}.artplayer-plugin-danmuku .apd-input{color:#fff;background-color:#0000;border:none;outline:none;flex:1;width:auto;min-width:0;height:100%;line-height:1}.artplayer-plugin-danmuku .apd-input::placeholder{color:#ffffff80}.artplayer-plugin-danmuku .apd-send{cursor:pointer;width:60px;height:100%;text-shadow:none;background-color:#00a1d6;border-top-right-radius:5px;border-bottom-right-radius:5px;flex-shrink:0;justify-content:center;align-items:center;display:flex}.artplayer-plugin-danmuku .apd-send.apd-lock{cursor:not-allowed;color:#666;background-color:#e7e7e7}.art-controls-center .apd-emitter{flex:none;width:260px}.art-fullscreen .artplayer-plugin-danmuku,.art-fullscreen-web .artplayer-plugin-danmuku{gap:16px;height:38px}.art-fullscreen .artplayer-plugin-danmuku .apd-config-icon,.art-fullscreen-web .artplayer-plugin-danmuku .apd-config-icon,.art-fullscreen .artplayer-plugin-danmuku .apd-toggle-off,.art-fullscreen-web .artplayer-plugin-danmuku .apd-toggle-off,.art-fullscreen .artplayer-plugin-danmuku .apd-toggle-on,.art-fullscreen-web .artplayer-plugin-danmuku .apd-toggle-on{width:28px;height:28px}.art-fullscreen .artplayer-plugin-danmuku .apd-emitter,.art-fullscreen-web .artplayer-plugin-danmuku .apd-emitter{flex:none;width:400px}.art-video-player>.artplayer-plugin-danmuku{padding:0 10px;position:absolute;bottom:-40px;left:0;right:0}.art-video-player:has(>.artplayer-plugin-danmuku){margin-bottom:40px}[data-danmuku-emitter=false] .apd-emitter{display:none!important}[data-danmuku-emitter=false] .art-controls-center .artplayer-plugin-danmuku{justify-content:flex-end;gap:18px}[data-danmuku-emitter=false].art-fullscreen .art-controls-center .artplayer-plugin-danmuku,[data-danmuku-emitter=false].art-fullscreen-web .art-controls-center .artplayer-plugin-danmuku{gap:24px}[data-danmuku-theme=light]>.artplayer-plugin-danmuku .apd-icon{fill:#333}[data-danmuku-theme=light]>.artplayer-plugin-danmuku .apd-emitter{background-color:#f1f2f3}[data-danmuku-theme=light]>.artplayer-plugin-danmuku .apd-input{color:#000}[data-danmuku-theme=light]>.artplayer-plugin-danmuku .apd-input::placeholder{color:#0000004d}[data-danmuku-visible=false] .apd-toggle-off{display:block}[data-danmuku-visible=false] .apd-toggle-on,[data-danmuku-visible=true] .apd-toggle-off{display:none}[data-danmuku-visible=true] .apd-toggle-on{display:block}[data-danmuku-anti-overlap=false] .apd-anti-overlap .apd-check-on{display:none}[data-danmuku-anti-overlap=false] .apd-anti-overlap .apd-check-off,[data-danmuku-anti-overlap=true] .apd-anti-overlap .apd-check-on{display:block}[data-danmuku-anti-overlap=true] .apd-anti-overlap .apd-check-off,[data-danmuku-sync-video=false] .apd-sync-video .apd-check-on{display:none}[data-danmuku-sync-video=false] .apd-sync-video .apd-check-off,[data-danmuku-sync-video=true] .apd-sync-video .apd-check-on{display:block}[data-danmuku-sync-video=true] .apd-sync-video .apd-check-off{display:none}[data-danmuku-mode0=false] .apd-config-mode .apd-mode-0-off{display:block}[data-danmuku-mode0=false] .apd-config-mode .apd-mode-0-on{display:none}[data-danmuku-mode0=false] .art-danmuku [data-mode="0"]{opacity:0!important}[data-danmuku-mode0=true] .apd-config-mode .apd-mode-0-off{display:none}[data-danmuku-mode0=true] .apd-config-mode .apd-mode-0-on{display:block}[data-danmuku-mode="0"] .apd-style-mode [data-mode="0"]{color:#00a1d6}[data-danmuku-mode="0"] .apd-style-mode [data-mode="0"] path{fill:#00a1d6}[data-danmuku-mode1=false] .apd-config-mode .apd-mode-1-off{display:block}[data-danmuku-mode1=false] .apd-config-mode .apd-mode-1-on{display:none}[data-danmuku-mode1=false] .art-danmuku [data-mode="1"]{opacity:0!important}[data-danmuku-mode1=true] .apd-config-mode .apd-mode-1-off{display:none}[data-danmuku-mode1=true] .apd-config-mode .apd-mode-1-on{display:block}[data-danmuku-mode="1"] .apd-style-mode [data-mode="1"]{color:#00a1d6}[data-danmuku-mode="1"] .apd-style-mode [data-mode="1"] path{fill:#00a1d6}[data-danmuku-mode2=false] .apd-config-mode .apd-mode-2-off{display:block}[data-danmuku-mode2=false] .apd-config-mode .apd-mode-2-on{display:none}[data-danmuku-mode2=false] .art-danmuku [data-mode="2"]{opacity:0!important}[data-danmuku-mode2=true] .apd-config-mode .apd-mode-2-off{display:none}[data-danmuku-mode2=true] .apd-config-mode .apd-mode-2-on{display:block}[data-danmuku-mode="2"] .apd-style-mode [data-mode="2"]{color:#00a1d6}[data-danmuku-mode="2"] .apd-style-mode [data-mode="2"] path{fill:#00a1d6}'},{}],"86CEd":[function(t,s,i,r){s.exports='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" class="apd-icon apd-toggle-on" data-pointer="none"><path fill-rule="evenodd" d="M11.989 4.828q-.705 0-1.515.012l-1.71-2.566a1.008 1.008 0 0 0-1.678 1.118l.999 1.5q-1.022.027-2.164.068a4.01 4.01 0 0 0-3.83 3.44q-.246 1.725-.245 4.185-.001 2.947.35 5.116a4.01 4.01 0 0 0 3.763 3.363l.906.046c1.205.063 1.808.095 3.607.095a.988.988 0 0 0 0-1.975c-1.758 0-2.339-.03-3.501-.092l-.915-.047a2.04 2.04 0 0 1-1.91-1.708q-.325-1.987-.325-4.798 0-2.344.225-3.904c.14-.977.96-1.713 1.945-1.747q3.666-.13 6.063-.131 2.398 0 6.064.13c.96.034 1.71.81 1.855 1.814.075.524.113 1.962.141 3.065v.002c.01.342.017.65.025.88a.987.987 0 1 0 1.974-.068c-.008-.226-.016-.523-.025-.856v-.027c-.03-1.118-.073-2.663-.16-3.276-.273-1.906-1.783-3.438-3.74-3.507q-1.35-.048-2.531-.078l1.05-1.46a1.008 1.008 0 0 0-1.638-1.177l-1.862 2.59q-.571-.006-1.088-.007zm.521 4.775h-1.32v4.631h2.222v.847h-2.618v1.078h2.618l.003.678c.36.026.714.163 1.01.407h.11v-1.085h2.694v-1.078h-2.695v-.847H16.8v-4.63h-1.276a8.6 8.6 0 0 0 .748-1.42L15.183 7.8a14 14 0 0 1-.814 1.804h-1.518l.693-.308a9 9 0 0 0-.814-1.408l-1.045.352c.297.396.572.847.825 1.364Zm-4.18 3.564.154-1.485h1.98V8.294h-3.2v.98H9.33v1.43H7.472l-.308 3.453h2.277c0 1.166-.044 1.925-.12 2.277-.078.352-.386.528-.936.528-.308 0-.616-.022-.902-.055l.297 1.067.062.005c.285.02.551.04.818.04 1.001-.067 1.562-.419 1.694-1.057.11-.638.176-1.903.176-3.795zm7.458.11v-.858h-1.254v.858zm-2.376-.858v.858h-1.199v-.858h1.2Zm-1.199-.946h1.2v-.902h-1.2zm2.321 0v-.902h1.254v.902z" clip-rule="evenodd"/><path fill="#00AEEC" fill-rule="evenodd" d="M22.846 14.627a1 1 0 0 0-1.412.075l-5.091 5.703-2.216-2.275-.097-.086-.008-.005a1 1 0 0 0-1.322 1.493l2.963 3.041.093.083.007.005a1 1 0 0 0 1.354-.124l5.81-6.505.08-.102.005-.008a1 1 0 0 0-.166-1.295" clip-rule="evenodd"/></svg>'},{}],"3FcnK":[function(t,s,i,r){s.exports='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" class="apd-icon apd-toggle-off" data-pointer="none"><path fill-rule="evenodd" d="m8.085 4.891-.999-1.499a1.008 1.008 0 0 1 1.679-1.118l1.709 2.566q.81-.012 1.515-.012h.13q.517 0 1.088.007l1.862-2.59a1.008 1.008 0 0 1 1.637 1.177l-1.049 1.46q1.182.03 2.53.078c1.958.069 3.468 1.6 3.74 3.507.088.613.13 2.158.16 3.276l.001.027c.01.333.017.63.025.856a.987.987 0 0 1-1.974.069c-.008-.23-.016-.539-.025-.881v-.002c-.028-1.103-.066-2.541-.142-3.065-.143-1.004-.895-1.78-1.854-1.813a179 179 0 0 0-6.064-.131q-2.397 0-6.063.13a2.04 2.04 0 0 0-1.945 1.748q-.225 1.56-.225 3.904.001 2.811.325 4.798c.154.949.95 1.66 1.91 1.708a98 98 0 0 0 5.416.139.988.988 0 0 1 0 1.975 100 100 0 0 1-5.513-.141A4.01 4.01 0 0 1 2.197 17.7q-.353-2.169-.351-5.116-.001-2.46.245-4.184A4.01 4.01 0 0 1 5.92 4.96q1.142-.04 2.164-.069Zm4.436 4.707h-1.32v4.63h2.222v.848h-2.618v1.078h2.431a5.01 5.01 0 0 1 3.575-3.115V9.598h-1.276a8.6 8.6 0 0 0 .748-1.42l-1.089-.384a14 14 0 0 1-.814 1.804h-1.518l.693-.308a9 9 0 0 0-.814-1.408l-1.045.352c.297.396.572.847.825 1.364m-4.18 3.564.154-1.485h1.98V8.289h-3.2v.979h2.067v1.43H7.483l-.308 3.454h2.277c0 1.166-.044 1.925-.12 2.277-.078.352-.386.528-.936.528-.308 0-.616-.022-.902-.055l.297 1.067.062.004c.285.02.551.04.818.04 1.001-.066 1.562-.418 1.694-1.056.11-.638.176-1.903.176-3.795zm7.458.11v-.858h-1.254v.858H15.8Zm-2.376-.858v.858h-1.199v-.858h1.2Zm-1.199-.946h1.2v-.902h-1.2zm2.321 0v-.902H15.8v.902h-1.254Zm3.517 10.594a4 4 0 1 0 0-8 4 4 0 0 0 0 8m-.002-1.502a2.5 2.5 0 0 1-2.217-3.657l3.326 3.398a2.5 2.5 0 0 1-1.109.259m2.5-2.5c0 .42-.103.815-.286 1.162l-3.328-3.401a2.5 2.5 0 0 1 3.614 2.239" clip-rule="evenodd"/></svg>'},{}],j1vhO:[function(t,s,i,r){s.exports='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" class="apd-icon apd-config-icon" data-pointer="none"><path fill-rule="evenodd" d="m15.645 4.881 1.06-1.473a.998.998 0 1 0-1.622-1.166L13.22 4.835a111 111 0 0 0-1.1-.007h-.131q-.705 0-1.515.012L8.783 2.3A.998.998 0 0 0 7.12 3.408l.988 1.484q-1.033.028-2.188.069a4.01 4.01 0 0 0-3.83 3.44q-.246 1.725-.245 4.185-.001 2.947.35 5.116a4.01 4.01 0 0 0 3.763 3.363 100 100 0 0 0 5.513.141.988.988 0 0 0 0-1.975 98 98 0 0 1-5.416-.139 2.04 2.04 0 0 1-1.91-1.708q-.325-1.986-.325-4.798 0-2.344.225-3.904c.14-.977.96-1.713 1.945-1.747q3.666-.13 6.063-.131 2.398 0 6.064.13c.96.034 1.71.81 1.855 1.814.075.524.113 1.962.141 3.065v.002c.005.183.01.07.014-.038.004-.096.008-.189.011-.081a.987.987 0 1 0 1.974-.069c-.004-.105-.007-.009-.011.09a2 2 0 0 1-.007.135l-.002.01a1 1 0 0 1-.005-.091v-.027c-.03-1.118-.073-2.663-.16-3.276-.273-1.906-1.783-3.438-3.74-3.507q-1.357-.048-2.543-.079Zm-3.113 4.703h-1.307v4.643h2.2v.04l.651-1.234c.113-.215.281-.389.482-.509v-.11h.235q.207-.074.433-.074h1.553V9.584h-1.264a8.5 8.5 0 0 0 .741-1.405l-1.078-.381c-.24.631-.501 1.23-.806 1.786h-1.503l.686-.305a8.6 8.6 0 0 0-.806-1.394l-1.034.348c.294.392.566.839.817 1.35Zm-1.7 5.502h2.16l-.564 1.068h-1.595zm-2.498-1.863.152-1.561h1.96V8.289H7.277v.969h2.048v1.435h-1.84l-.306 3.51h2.254c0 1.155-.043 1.906-.12 2.255-.076.348-.38.523-.925.523-.305 0-.61-.022-.893-.055l.294 1.056.061.005c.282.02.546.039.81.039.991-.065 1.547-.414 1.677-1.046.11-.631.175-1.883.175-3.757zm5.09-.8v.85h-1.188v-.85h1.187Zm-1.188-.955h1.187v-.893h-1.187zm2.322.007v-.893h1.241v.893zm.528 2.757a1.26 1.26 0 0 1 1.087-.627l4.003-.009a1.26 1.26 0 0 1 1.094.63l1.721 2.982c.226.39.225.872-.001 1.263l-1.743 3a1.26 1.26 0 0 1-1.086.628l-4.003.009a1.26 1.26 0 0 1-1.094-.63l-1.722-2.982a1.26 1.26 0 0 1 .002-1.263zm1.967.858a1.26 1.26 0 0 0-1.08.614l-.903 1.513a1.26 1.26 0 0 0-.002 1.289l.885 1.492c.227.384.64.62 1.086.618l2.192-.005a1.26 1.26 0 0 0 1.08-.615l.904-1.518a1.26 1.26 0 0 0 .001-1.288l-.884-1.489a1.26 1.26 0 0 0-1.086-.616zm2.517 2.76a1.4 1.4 0 1 1-2.8 0 1.4 1.4 0 0 1 2.8 0" clip-rule="evenodd"/></svg>'},{}],jmfTi:[function(t,s,i,r){s.exports='<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="36" height="24" class="apd-icon apd-style-icon" data-pointer="none" viewBox="0 0 22 22"><path d="M17 16H5c-.55 0-1 .45-1 1s.45 1 1 1h12c.55 0 1-.45 1-1s-.45-1-1-1M6.96 15c.39 0 .74-.24.89-.6l.65-1.6h5l.66 1.6c.15.36.5.6.89.6.69 0 1.15-.71.88-1.34l-3.88-8.97C11.87 4.27 11.46 4 11 4s-.87.27-1.05.69l-3.88 8.97c-.27.63.2 1.34.89 1.34M11 5.98 12.87 11H9.13z"/></svg>'},{}],ffHqV:[function(t,s,i,r){s.exports='<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="28" height="28" class="apd-icon apd-mode-0-off" data-pointer="none"><path fill="#00AEEC" d="M23 15c1.487 0 2.866.464 4 1.255V7a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v14a4 4 0 0 0 4 4h11.674A7 7 0 0 1 23 15M11 9h6a1 1 0 0 1 0 2h-6a1 1 0 0 1 0-2m-3 2H6V9h2zm4 4h-2v-2h2zm2-1a1 1 0 0 1 1-1h1a1 1 0 0 1 0 2h-1a1 1 0 0 1-1-1"/><path fill="#00AEEC" d="M26.536 18.464a5 5 0 0 0-7.071 0 5 5 0 0 0 0 7.071 5 5 0 1 0 7.071-7.071m-5.657 5.657a3 3 0 0 1-.586-3.415l4.001 4.001a3 3 0 0 1-3.415-.586m4.829-.827-4.001-4.001a3.002 3.002 0 0 1 4.001 4.001"/></svg>'},{}],eGfex:[function(t,s,i,r){s.exports='<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="28" height="28" class="apd-icon apd-mode-0-on" data-pointer="none"><path fill="#FFF" d="M23 3H5a4 4 0 0 0-4 4v14a4 4 0 0 0 4 4h18a4 4 0 0 0 4-4V7a4 4 0 0 0-4-4M11 9h6a1 1 0 0 1 0 2h-6a1 1 0 0 1 0-2m-3 2H6V9h2zm4 4h-2v-2h2zm9 0h-6a1 1 0 0 1 0-2h6a1 1 0 0 1 0 2"/></svg>'},{}],77326:[function(t,s,i,r){s.exports='<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="28" height="28" class="apd-icon apd-mode-1-off" data-pointer="none"><path fill="#00AEEC" d="M23 15c1.487 0 2.866.464 4 1.255V7a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v14a4 4 0 0 0 4 4h11.674A7 7 0 0 1 23 15m-4-8h2v2h-2zM9 9H7V7h2zm4 0h-2V7h2zm2-2h2v2h-2z"/><path fill="#00AEEC" d="M26.536 18.464a5 5 0 0 0-7.071 0 5 5 0 0 0 0 7.071 5 5 0 1 0 7.071-7.071m-5.657 5.657a3 3 0 0 1-.586-3.415l4.001 4.001a3 3 0 0 1-3.415-.586m4.829-.827-4.001-4.001a3.002 3.002 0 0 1 4.001 4.001"/></svg>'},{}],"6P4nN":[function(t,s,i,r){s.exports='<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="28" height="28" class="apd-icon apd-mode-1-on" data-pointer="none"><path fill="#FFF" d="M23 3H5a4 4 0 0 0-4 4v14a4 4 0 0 0 4 4h18a4 4 0 0 0 4-4V7a4 4 0 0 0-4-4M9 9H7V7h2zm4 0h-2V7h2zm4 0h-2V7h2zm4 0h-2V7h2z"/></svg>'},{}],cBcwx:[function(t,s,i,r){s.exports='<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="28" height="28" class="apd-icon apd-mode-2-off" data-pointer="none"><path fill="#00AEEC" d="M23 15c1.487 0 2.866.464 4 1.255V7a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v14a4 4 0 0 0 4 4h11.674A7 7 0 0 1 23 15M9 21H7v-2h2zm4 0h-2v-2h2z"/><path fill="#00AEEC" d="M26.536 18.464a5 5 0 0 0-7.071 0 5 5 0 0 0 0 7.071 5 5 0 1 0 7.071-7.071m-5.657 5.657a3 3 0 0 1-.586-3.415l4.001 4.001a3 3 0 0 1-3.415-.586m4.829-.827-4.001-4.001a3.002 3.002 0 0 1 4.001 4.001"/></svg>'},{}],i6KC4:[function(t,s,i,r){s.exports='<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="28" height="28" class="apd-icon apd-mode-2-on" data-pointer="none"><path fill="#FFF" d="M23 3H5a4 4 0 0 0-4 4v14a4 4 0 0 0 4 4h18a4 4 0 0 0 4-4V7a4 4 0 0 0-4-4M9 21H7v-2h2zm4 0h-2v-2h2zm4 0h-2v-2h2zm4 0h-2v-2h2z"/></svg>'},{}],"2H4K5":[function(t,s,i,r){s.exports='<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" class="apd-icon apd-check-on" data-pointer="none"><path fill="#00AEEC" d="m13 18.25-1.8-1.8c-.6-.6-1.65-.6-2.25 0s-.6 1.5 0 2.25l2.85 2.85c.318.318.762.468 1.2.448.438.02.882-.13 1.2-.448l8.85-8.85c.6-.6.6-1.65 0-2.25s-1.65-.6-2.25 0zM8 4h16c2.21 0 4 1.79 4 4v16c0 2.21-1.79 4-4 4H8c-2.21 0-4-1.79-4-4V8c0-2.21 1.79-4 4-4"/></svg>'},{}],"4JI0m":[function(t,s,i,r){s.exports='<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" class="apd-icon apd-check-off" data-pointer="none"><path fill="#FFF" d="M8 6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2zm0-2h16c2.21 0 4 1.79 4 4v16c0 2.21-1.79 4-4 4H8c-2.21 0-4-1.79-4-4V8c0-2.21 1.79-4 4-4"/></svg>'},{}],falVu:[function(t,s,i,r){var n=t("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(i),n.export(i,"default",()=>l);let o={map:(c,u,h,f,g)=>(c-u)*(g-f)/(h-u)+f,range(c,u,h){let f=Math.round(c/h)*h;return Array.from({length:Math.floor((u-c)/h)},(g,m)=>m*h+f)}},d=(c,u)=>{let h=u[0]-c[0],f=u[1]-c[1];return{length:Math.sqrt(Math.pow(h,2)+Math.pow(f,2)),angle:Math.atan2(f,h)}};function l(c,u,h){let{query:f}=c.constructor.utils;c.controls.add({name:"heatmap",position:"top",html:"",style:{position:"absolute",top:"-100px",left:"0px",right:"0px",height:"100px",width:"100%",pointerEvents:"none"},mounted(g){let m=null,p=null;function v(E=[]){if(m=null,p=null,g.innerHTML="",!c.duration||c.option.isLive)return;let T={w:g.offsetWidth,h:g.offsetHeight},S={xMin:0,xMax:T.w,yMin:0,yMax:128,scale:.25,opacity:.2,minHeight:Math.floor(.05*T.h),sampling:Math.floor(T.w/100),smoothing:.2,flattening:.2};typeof h=="object"&&Object.assign(S,h);let x=[];if(Array.isArray(E)&&E.length)x=[...E];else{let B=c.duration/T.w;for(let N=0;N<=T.w;N+=S.sampling){let M=u.queue.filter(({time:C})=>C>N*B&&C<=(N+S.sampling)*B).length;x.push([N,M])}}if(x.length===0)return;let b=x[x.length-1],A=b[0],I=b[1];A!==T.w&&x.push([T.w,I]);let R=x.map(B=>B[1]),L=(Math.min(...R)+Math.max(...R))/2;for(let B=0;B<x.length;B++){let N=x[B],M=N[1];N[1]=M*(M>L?1+S.scale:1-S.scale)+S.minHeight}let w=(B,N,M,C)=>{let k=d(N||B,M||B),O=o.map(Math.cos(k.angle)*S.flattening,0,1,1,0),G=k.angle*O+(C?Math.PI:0),F=k.length*S.smoothing;return[B[0]+Math.cos(G)*F,B[1]+Math.sin(G)*F]},U=(B,N,M)=>{let C=w(M[N-1],M[N-2],B),k=w(B,M[N-1],M[N+1],!0),O=N===M.length-1?" z":"";return"C ".concat(C[0],",").concat(C[1]," ").concat(k[0],",").concat(k[1]," ").concat(B[0],",").concat(B[1]).concat(O)},V=x.map(B=>[o.map(B[0],S.xMin,S.xMax,0,T.w),o.map(B[1],S.yMin,S.yMax,T.h,0)]).reduce((B,N,M,C)=>M===0?"M ".concat(C[C.length-1][0],",").concat(T.h," L ").concat(N[0],",").concat(T.h," L ").concat(N[0],",").concat(N[1]):"".concat(B," ").concat(U(N,M,C)),"");g.innerHTML='<svg viewBox="0 0 '.concat(T.w," ").concat(T.h,'"><defs><linearGradient id="heatmap-solids" x1="0%" y1="0%" x2="100%" y2="0%"><stop offset="0%" style="stop-color:var(--art-theme);stop-opacity:').concat(S.opacity,'" /><stop offset="0%" style="stop-color:var(--art-theme);stop-opacity:').concat(S.opacity,'" id="heatmap-start" /><stop offset="0%" style="stop-color:var(--art-progress-color);stop-opacity:1" id="heatmap-stop" /><stop offset="100%" style="stop-color:var(--art-progress-color);stop-opacity:1" /></linearGradient></defs><path fill="url(#heatmap-solids)" d="').concat(V,'"></path></svg>'),m=f("#heatmap-start",g),p=f("#heatmap-stop",g),m.setAttribute("offset","".concat(100*c.played,"%")),p.setAttribute("offset","".concat(100*c.played,"%"))}c.on("video:timeupdate",()=>{m&&p&&(m.setAttribute("offset","".concat(100*c.played,"%")),p.setAttribute("offset","".concat(100*c.played,"%")))}),c.on("setBar",(E,T)=>{m&&p&&E==="played"&&(m.setAttribute("offset","".concat(100*T,"%")),p.setAttribute("offset","".concat(100*T,"%")))}),c.on("ready",()=>v()),c.on("resize",()=>v()),c.on("artplayerPluginDanmuku:loaded",()=>v()),c.on("artplayerPluginDanmuku:points",E=>v(E))}})}},{"@parcel/transformer-js/src/esmodule-helpers.js":"7o2zS"}]},["jz4E5"],"jz4E5","parcelRequire93cf",{})})(Dt,Dt.exports)),Dt.exports}var ja=qa();const ch=gn(ja);var Rs={exports:{}},Qi;function za(){return Qi||(Qi=1,(function(a,e){var t=function(s){var i=!1;try{if(typeof WebAssembly=="object"&&typeof WebAssembly.instantiate=="function"){const v=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));v instanceof WebAssembly.Module&&(i=new WebAssembly.Instance(v)instanceof WebAssembly.Instance)}}catch(v){}console.log("WebAssembly support detected: "+(i?"yes":"no"));var r=this;r.canvas=s.canvas,r.renderMode=s.renderMode||(s.lossyRender?"lossy":"wasm-blend"),r.libassMemoryLimit=s.libassMemoryLimit||0,r.libassGlyphLimit=s.libassGlyphLimit||0,r.targetFps=s.targetFps||24,r.prescaleFactor=s.prescaleFactor||1,r.prescaleHeightLimit=s.prescaleHeightLimit||1080,r.maxRenderHeight=s.maxRenderHeight||0,r.dropAllAnimations=s.dropAllAnimations||!1,r.isOurCanvas=!1,r.video=s.video,r.canvasParent=null,r.fonts=s.fonts||[],r.availableFonts=s.availableFonts||[],r.fallbackFont=s.fallbackFont||"default.woff2",r.lazyFileLoading=s.lazyFileLoading||!1,r.onReadyEvent=s.onReady,i?r.workerUrl=s.workerUrl||"subtitles-octopus-worker.js":r.workerUrl=s.legacyWorkerUrl||"subtitles-octopus-worker-legacy.js",r.subUrl=s.subUrl,r.subContent=s.subContent||null,r.onErrorEvent=s.onError,r.debug=s.debug||!1,r.lastRenderTime=0,r.pixelRatio=window.devicePixelRatio||1,r.timeOffset=s.timeOffset||0,r.hasAlphaBug=!1,(function(){if(typeof ImageData.prototype.constructor=="function")try{new window.ImageData(new Uint8ClampedArray([0,0,0,0]),1,1);return}catch(T){console.log("detected that ImageData is not constructable despite browser saying so")}var v=document.createElement("canvas"),E=v.getContext("2d");window.ImageData=function(){var T=0;if(arguments[0]instanceof Uint8ClampedArray)var S=arguments[T++];var x=arguments[T++],b=arguments[T],A=E.createImageData(x,b);return S&&A.data.set(S),A}})(),r.workerError=function(v){if(console.error("Worker error: ",v),r.onErrorEvent&&r.onErrorEvent(v),!r.debug)throw r.dispose(),new Error("Worker error: "+v)},r.init=function(){if(!window.Worker){r.workerError("worker not supported");return}r.worker||(r.worker=new Worker(r.workerUrl),r.worker.addEventListener("message",r.onWorkerMessage),r.worker.addEventListener("error",r.workerError)),r.workerActive=!1,r.createCanvas(),r.setVideo(s.video),r.setSubUrl(s.subUrl),r.worker.postMessage({target:"worker-init",width:r.canvas.width,height:r.canvas.height,URL:document.URL,currentScript:r.workerUrl,preMain:!0,renderMode:r.renderMode,subUrl:r.subUrl,subContent:r.subContent,fonts:r.fonts,availableFonts:r.availableFonts,fallbackFont:r.fallbackFont,lazyFileLoading:r.lazyFileLoading,debug:r.debug,targetFps:r.targetFps,libassMemoryLimit:r.libassMemoryLimit,libassGlyphLimit:r.libassGlyphLimit,dropAllAnimations:r.dropAllAnimations})},r.createCanvas=function(){r.canvas||(r.video?(r.isOurCanvas=!0,r.canvas=document.createElement("canvas"),r.canvas.className="libassjs-canvas",r.canvas.style.display="none",r.canvasParent=document.createElement("div"),r.canvasParent.className="libassjs-canvas-parent",r.canvasParent.appendChild(r.canvas),r.video.nextSibling?r.video.parentNode.insertBefore(r.canvasParent,r.video.nextSibling):r.video.parentNode.appendChild(r.canvasParent)):r.canvas||r.workerError("Don't know where to render: you should give video or canvas in options.")),r.ctx=r.canvas.getContext("2d"),r.bufferCanvas=document.createElement("canvas"),r.bufferCanvasCtx=r.bufferCanvas.getContext("2d"),r.bufferCanvas.width=1,r.bufferCanvas.height=1;var v=new Uint8ClampedArray([0,255,0,0]),E=new ImageData(v,1,1);r.bufferCanvasCtx.clearRect(0,0,1,1),r.ctx.clearRect(0,0,1,1);var T=r.ctx.getImageData(0,0,1,1).data;r.bufferCanvasCtx.putImageData(E,0,0),r.ctx.drawImage(r.bufferCanvas,0,0);var S=r.ctx.getImageData(0,0,1,1).data;r.hasAlphaBug=T[1]!=S[1],r.hasAlphaBug&&console.log("Detected a browser having issue with transparent pixels, applying workaround")};function n(){r.setCurrentTime(r.video.currentTime+r.timeOffset)}function o(){r.setIsPaused(!1,r.video.currentTime+r.timeOffset)}function d(){r.setIsPaused(!0,r.video.currentTime+r.timeOffset)}function l(){r.video.removeEventListener("timeupdate",n,!1)}function c(){r.video.addEventListener("timeupdate",n,!1);var v=r.video.currentTime+r.timeOffset;r.setCurrentTime(v)}function u(){r.setRate(r.video.playbackRate)}function h(){r.setIsPaused(!0,r.video.currentTime+r.timeOffset)}function f(v){v.target.removeEventListener(v.type,f,!1),r.resize()}r.setVideo=function(v){r.video=v,r.video&&(r.video.addEventListener("timeupdate",n,!1),r.video.addEventListener("playing",o,!1),r.video.addEventListener("pause",d,!1),r.video.addEventListener("seeking",l,!1),r.video.addEventListener("seeked",c,!1),r.video.addEventListener("ratechange",u,!1),r.video.addEventListener("waiting",h,!1),document.addEventListener("fullscreenchange",r.resizeWithTimeout,!1),document.addEventListener("mozfullscreenchange",r.resizeWithTimeout,!1),document.addEventListener("webkitfullscreenchange",r.resizeWithTimeout,!1),document.addEventListener("msfullscreenchange",r.resizeWithTimeout,!1),window.addEventListener("resize",r.resizeWithTimeout,!1),typeof ResizeObserver<"u"&&(r.ro=new ResizeObserver(r.resizeWithTimeout),r.ro.observe(r.video)),r.video.videoWidth>0?r.resize():r.video.addEventListener("loadedmetadata",f,!1))},r.getVideoPosition=function(){var v=r.video.videoWidth/r.video.videoHeight,E=r.video.offsetWidth,T=r.video.offsetHeight,S=E/T,x=E,b=T;S>v?x=Math.floor(T*v):b=Math.floor(E/v);var A=(E-x)/2,I=(T-b)/2;return{width:x,height:b,x:A,y:I}},r.setSubUrl=function(v){r.subUrl=v},r.renderFrameData=null;function g(){var v=r.renderFramesData,E=performance.now();r.ctx.clearRect(0,0,r.canvas.width,r.canvas.height);for(var T=0;T<v.canvases.length;T++){var S=v.canvases[T];r.bufferCanvas.width=S.w,r.bufferCanvas.height=S.h;var x=new Uint8ClampedArray(S.buffer);if(r.hasAlphaBug)for(var b=3;b<x.length;b=b+4)x[b]=x[b]>=1?x[b]:1;var A=new ImageData(x,S.w,S.h);r.bufferCanvasCtx.putImageData(A,0,0),r.ctx.drawImage(r.bufferCanvas,S.x,S.y)}if(r.debug){var I=Math.round(performance.now()-E),R=v.blendTime;console.log(typeof R<"u"?"render: "+Math.round(v.spentTime-R)+" ms, blend: "+Math.round(R)+" ms, draw: "+I+" ms; TOTAL="+Math.round(v.spentTime+I)+" ms":Math.round(v.spentTime)+" ms (+ "+I+" ms draw)"),r.renderStart=performance.now()}}function m(){var v=r.renderFramesData,E=performance.now();r.ctx.clearRect(0,0,r.canvas.width,r.canvas.height);for(var T=0;T<v.bitmaps.length;T++){var S=v.bitmaps[T];r.ctx.drawImage(S.bitmap,S.x,S.y)}if(r.debug){var x=Math.round(performance.now()-E);console.log(v.bitmaps.length+" bitmaps, libass: "+Math.round(v.libassTime)+"ms, decode: "+Math.round(v.decodeTime)+"ms, draw: "+x+"ms"),r.renderStart=performance.now()}}r.workerActive=!1,r.frameId=0,r.onWorkerMessage=function(v){r.workerActive||(r.workerActive=!0,r.onReadyEvent&&r.onReadyEvent());var E=v.data;switch(E.target){case"stdout":{console.log(E.content);break}case"console-log":{console.log.apply(console,JSON.parse(E.content));break}case"console-debug":{console.debug.apply(console,JSON.parse(E.content));break}case"console-info":{console.info.apply(console,JSON.parse(E.content));break}case"console-warn":{console.warn.apply(console,JSON.parse(E.content));break}case"console-error":{console.error.apply(console,JSON.parse(E.content));break}case"stderr":{console.error(E.content);break}case"window":{window[E.method]();break}case"canvas":{switch(E.op){case"getContext":{r.ctx=r.canvas.getContext(E.type,E.attributes);break}case"resize":{r.resize(E.width,E.height);break}case"renderCanvas":{r.lastRenderTime<E.time&&(r.lastRenderTime=E.time,r.renderFramesData=E,window.requestAnimationFrame(g));break}case"renderFastCanvas":{r.lastRenderTime<E.time&&(r.lastRenderTime=E.time,r.renderFramesData=E,window.requestAnimationFrame(m));break}case"setObjectProperty":{r.canvas[E.object][E.property]=E.value;break}default:throw"eh?"}break}case"tick":{r.frameId=E.id,r.worker.postMessage({target:"tock",id:r.frameId});break}case"custom":{if(r.onCustomMessage)r.onCustomMessage(v);else throw"Custom message received but client onCustomMessage not implemented.";break}case"setimmediate":{r.worker.postMessage({target:"setimmediate"});break}case"get-events":break;case"get-styles":break;case"ready":break;default:throw"what? "+E.target}};function p(v,E){var T=r.prescaleFactor<=0?1:r.prescaleFactor;if(E<=0||v<=0)v=0,E=0;else{var S=T<1?-1:1,x=E;S*x*T<=S*r.prescaleHeightLimit?x*=T:S*x<S*r.prescaleHeightLimit&&(x=r.prescaleHeightLimit),r.maxRenderHeight>0&&x>r.maxRenderHeight&&(x=r.maxRenderHeight),v*=x/E,E=x}return{width:v,height:E}}r.resize=function(v,E,T,S){var x=null;if(T=T||0,S=S||0,(!v||!E)&&r.video){x=r.getVideoPosition();var b=p(x.width*r.pixelRatio,x.height*r.pixelRatio);v=b.width,E=b.height;var A=r.canvasParent.getBoundingClientRect().top-r.video.getBoundingClientRect().top;T=x.y-A,S=x.x}if(!v||!E){r.video||console.error("width or height is 0. You should specify width & height for resize.");return}(r.canvas.width!=v||r.canvas.height!=E||r.canvas.style.top!=T||r.canvas.style.left!=S)&&(r.canvas.width=v,r.canvas.height=E,x!=null&&(r.canvasParent.style.position="relative",r.canvas.style.display="block",r.canvas.style.position="absolute",r.canvas.style.width=x.width+"px",r.canvas.style.height=x.height+"px",r.canvas.style.top=T+"px",r.canvas.style.left=S+"px",r.canvas.style.pointerEvents="none"),r.worker.postMessage({target:"canvas",width:r.canvas.width,height:r.canvas.height}))},r.resizeWithTimeout=function(){r.resize(),setTimeout(r.resize,100)},r.runBenchmark=function(){r.worker.postMessage({target:"runBenchmark"})},r.customMessage=function(v,E){E=E||{},r.worker.postMessage({target:"custom",userData:v,preMain:E.preMain})},r.setCurrentTime=function(v){r.worker.postMessage({target:"video",currentTime:v})},r.setTrackByUrl=function(v){r.worker.postMessage({target:"set-track-by-url",url:v})},r.setTrack=function(v){r.worker.postMessage({target:"set-track",content:v})},r.freeTrack=function(v){r.worker.postMessage({target:"free-track"})},r.render=r.setCurrentTime,r.setIsPaused=function(v,E){r.worker.postMessage({target:"video",isPaused:v,currentTime:E})},r.setRate=function(v){r.worker.postMessage({target:"video",rate:v})},r.dispose=function(){r.worker.postMessage({target:"destroy"}),r.worker.terminate(),r.worker.removeEventListener("message",r.onWorkerMessage),r.worker.removeEventListener("error",r.workerError),r.workerActive=!1,r.worker=null,r.video&&(r.video.removeEventListener("timeupdate",n,!1),r.video.removeEventListener("playing",o,!1),r.video.removeEventListener("pause",d,!1),r.video.removeEventListener("seeking",l,!1),r.video.removeEventListener("seeked",c,!1),r.video.removeEventListener("ratechange",u,!1),r.video.removeEventListener("waiting",h,!1),r.video.removeEventListener("loadedmetadata",f,!1),document.removeEventListener("fullscreenchange",r.resizeWithTimeout,!1),document.removeEventListener("mozfullscreenchange",r.resizeWithTimeout,!1),document.removeEventListener("webkitfullscreenchange",r.resizeWithTimeout,!1),document.removeEventListener("msfullscreenchange",r.resizeWithTimeout,!1),window.removeEventListener("resize",r.resizeWithTimeout,!1),r.video.parentNode.removeChild(r.canvasParent),r.video=null),r.ro&&(r.ro.disconnect(),r.ro=null),r.onCustomMessage=null,r.onErrorEvent=null,r.onReadyEvent=null},r.fetchFromWorker=function(v,E,T){try{var S=v.target,x=setTimeout(function(){A(Error("Error: Timeout while try to fetch "+S))},5e3),b=function(I){I.data.target==S&&(E(I.data),r.worker.removeEventListener("message",b),r.worker.removeEventListener("error",A),clearTimeout(x))},A=function(I){T(I),r.worker.removeEventListener("message",b),r.worker.removeEventListener("error",A),clearTimeout(x)};r.worker.addEventListener("message",b),r.worker.addEventListener("error",A),r.worker.postMessage(v)}catch(I){T(I)}},r.createEvent=function(v){r.worker.postMessage({target:"create-event",event:v})},r.getEvents=function(v,E){r.fetchFromWorker({target:"get-events"},function(T){v(T.events)},E)},r.setEvent=function(v,E){r.worker.postMessage({target:"set-event",event:v,index:E})},r.removeEvent=function(v){r.worker.postMessage({target:"remove-event",index:v})},r.createStyle=function(v){r.worker.postMessage({target:"create-style",style:v})},r.getStyles=function(v,E){r.fetchFromWorker({target:"get-styles"},function(T){v(T.styles)},E)},r.setStyle=function(v,E){r.worker.postMessage({target:"set-style",style:v,index:E})},r.removeStyle=function(v){r.worker.postMessage({target:"remove-style",index:v})},r.init()};typeof SubtitlesOctopusOnLoad=="function"&&SubtitlesOctopusOnLoad(),a.exports&&(a.exports=t)})(Rs)),Rs.exports}var Xa=za();const Qa=gn(Xa),{fontsPath:mn,libAssPath:pn}=Ya(),Za="".concat(pn(),"/subtitles-octopus-worker.js"),Ja="".concat(pn(),"/subtitles-octopus-worker.wasm"),eo="".concat(mn(),"/TimesNewRoman.ttf"),to="".concat(mn(),"/SourceHanSansCN-Bold.woff2");let Ne=null;function so(a){return/^https?:\/\//.test(a)}function fs(a){return so(a)?a:new URL(a,document.baseURI).toString()}function io({workerUrl:a,wasmUrl:e}){return new Promise(t=>{fetch(a).then(s=>s.text()).then(s=>{let i=s;i=i.replace(/wasmBinaryFile\s*=\s*"(subtitles-octopus-worker\.wasm)"/g,(n,o)=>(e?e=fs(e):e=new URL(o,fs(a)).toString(),'wasmBinaryFile = "'.concat(e,'"')));const r=new Blob([i],{type:"text/javascript"});t(URL.createObjectURL(r))})})}function Ds(a){Ne.canvasParent&&(Ne.canvasParent.style.display=a?"block":"none")}function uh(a){return async e=>(Ne=new Qa({availableFonts:{"times new roman":fs(eo)},workerUrl:await io({workerUrl:Za,wasmUrl:Ja}),fallbackFont:fs(to),video:e.template.$video,...a}),Ne.canvasParent.className="artplayer-plugin-ass",Ne.canvasParent.style.cssText="\n position: absolute;\n width: 100%;\n height: 100%;\n user-select: none;\n pointer-events: none;\n z-index: 20;\n ",e.on("artplayer-plugin-ass:switch",t=>{Ne.freeTrack(),Ne.setTrackByUrl(t),Ds(!0)}),e.on("subtitle",t=>Ds(t)),e.on("artplayer-plugin-ass:visible",t=>Ds(t)),e.on("subtitleOffset",t=>Ne.timeOffset=t),e.on("destroy",()=>Ne.dispose()),{name:"artplayerPluginAss",instance:Ne})}const K=Number.isFinite||function(a){return typeof a=="number"&&isFinite(a)},ro=Number.isSafeInteger||function(a){return typeof a=="number"&&Math.abs(a)<=no},no=Number.MAX_SAFE_INTEGER||9007199254740991;let W=(function(a){return a.NETWORK_ERROR="networkError",a.MEDIA_ERROR="mediaError",a.KEY_SYSTEM_ERROR="keySystemError",a.MUX_ERROR="muxError",a.OTHER_ERROR="otherError",a})({}),_=(function(a){return a.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",a.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",a.KEY_SYSTEM_NO_SESSION="keySystemNoSession",a.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",a.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",a.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",a.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",a.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",a.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",a.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",a.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",a.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",a.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",a.MANIFEST_LOAD_ERROR="manifestLoadError",a.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",a.MANIFEST_PARSING_ERROR="manifestParsingError",a.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",a.LEVEL_EMPTY_ERROR="levelEmptyError",a.LEVEL_LOAD_ERROR="levelLoadError",a.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",a.LEVEL_PARSING_ERROR="levelParsingError",a.LEVEL_SWITCH_ERROR="levelSwitchError",a.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",a.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",a.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",a.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",a.FRAG_LOAD_ERROR="fragLoadError",a.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",a.FRAG_DECRYPT_ERROR="fragDecryptError",a.FRAG_PARSING_ERROR="fragParsingError",a.FRAG_GAP="fragGap",a.REMUX_ALLOC_ERROR="remuxAllocError",a.KEY_LOAD_ERROR="keyLoadError",a.KEY_LOAD_TIMEOUT="keyLoadTimeOut",a.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",a.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",a.BUFFER_APPEND_ERROR="bufferAppendError",a.BUFFER_APPENDING_ERROR="bufferAppendingError",a.BUFFER_STALLED_ERROR="bufferStalledError",a.BUFFER_FULL_ERROR="bufferFullError",a.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",a.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",a.ASSET_LIST_LOAD_ERROR="assetListLoadError",a.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",a.ASSET_LIST_PARSING_ERROR="assetListParsingError",a.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",a.INTERNAL_EXCEPTION="internalException",a.INTERNAL_ABORTED="aborted",a.ATTACH_MEDIA_ERROR="attachMediaError",a.UNKNOWN="unknown",a})({}),y=(function(a){return a.MEDIA_ATTACHING="hlsMediaAttaching",a.MEDIA_ATTACHED="hlsMediaAttached",a.MEDIA_DETACHING="hlsMediaDetaching",a.MEDIA_DETACHED="hlsMediaDetached",a.MEDIA_ENDED="hlsMediaEnded",a.STALL_RESOLVED="hlsStallResolved",a.BUFFER_RESET="hlsBufferReset",a.BUFFER_CODECS="hlsBufferCodecs",a.BUFFER_CREATED="hlsBufferCreated",a.BUFFER_APPENDING="hlsBufferAppending",a.BUFFER_APPENDED="hlsBufferAppended",a.BUFFER_EOS="hlsBufferEos",a.BUFFERED_TO_END="hlsBufferedToEnd",a.BUFFER_FLUSHING="hlsBufferFlushing",a.BUFFER_FLUSHED="hlsBufferFlushed",a.MANIFEST_LOADING="hlsManifestLoading",a.MANIFEST_LOADED="hlsManifestLoaded",a.MANIFEST_PARSED="hlsManifestParsed",a.LEVEL_SWITCHING="hlsLevelSwitching",a.LEVEL_SWITCHED="hlsLevelSwitched",a.LEVEL_LOADING="hlsLevelLoading",a.LEVEL_LOADED="hlsLevelLoaded",a.LEVEL_UPDATED="hlsLevelUpdated",a.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",a.LEVELS_UPDATED="hlsLevelsUpdated",a.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",a.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",a.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",a.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",a.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",a.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",a.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",a.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",a.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",a.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",a.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",a.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",a.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",a.CUES_PARSED="hlsCuesParsed",a.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",a.INIT_PTS_FOUND="hlsInitPtsFound",a.FRAG_LOADING="hlsFragLoading",a.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",a.FRAG_LOADED="hlsFragLoaded",a.FRAG_DECRYPTED="hlsFragDecrypted",a.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",a.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",a.FRAG_PARSING_METADATA="hlsFragParsingMetadata",a.FRAG_PARSED="hlsFragParsed",a.FRAG_BUFFERED="hlsFragBuffered",a.FRAG_CHANGED="hlsFragChanged",a.FPS_DROP="hlsFpsDrop",a.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",a.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",a.ERROR="hlsError",a.DESTROYING="hlsDestroying",a.KEY_LOADING="hlsKeyLoading",a.KEY_LOADED="hlsKeyLoaded",a.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",a.BACK_BUFFER_REACHED="hlsBackBufferReached",a.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",a.ASSET_LIST_LOADING="hlsAssetListLoading",a.ASSET_LIST_LOADED="hlsAssetListLoaded",a.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",a.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",a.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",a.INTERSTITIAL_STARTED="hlsInterstitialStarted",a.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",a.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",a.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",a.INTERSTITIAL_ENDED="hlsInterstitialEnded",a.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",a.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",a.EVENT_CUE_ENTER="hlsEventCueEnter",a})({});var J={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},H={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};class ut{constructor(e,t=0,s=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=s}sample(e,t){const s=Math.pow(this.alpha_,e);this.estimate_=t*(1-s)+s*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class ao{constructor(e,t,s,i=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=s,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new ut(e),this.fast_=new ut(t),this.defaultTTFB_=i,this.ttfb_=new ut(e)}update(e,t){const{slow_:s,fast_:i,ttfb_:r}=this;s.halfLife!==e&&(this.slow_=new ut(e,s.getEstimate(),s.getTotalWeight())),i.halfLife!==t&&(this.fast_=new ut(t,i.getEstimate(),i.getTotalWeight())),r.halfLife!==e&&(this.ttfb_=new ut(e,r.getEstimate(),r.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);const s=8*t,i=e/1e3,r=s/i;this.fast_.sample(i,r),this.slow_.sample(i,r)}sampleTTFB(e){const t=e/1e3,s=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(s,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}get defaultEstimate(){return this.defaultEstimate_}destroy(){}}function oo(a,e,t){return(e=co(e))in a?Object.defineProperty(a,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):a[e]=t,a}function ie(){return ie=Object.assign?Object.assign.bind():function(a){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var s in t)({}).hasOwnProperty.call(t,s)&&(a[s]=t[s])}return a},ie.apply(null,arguments)}function Zi(a,e){var t=Object.keys(a);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(a);e&&(s=s.filter(function(i){return Object.getOwnPropertyDescriptor(a,i).enumerable})),t.push.apply(t,s)}return t}function te(a){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Zi(Object(t),!0).forEach(function(s){oo(a,s,t[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(t)):Zi(Object(t)).forEach(function(s){Object.defineProperty(a,s,Object.getOwnPropertyDescriptor(t,s))})}return a}function lo(a,e){if(typeof a!="object"||!a)return a;var t=a[Symbol.toPrimitive];if(t!==void 0){var s=t.call(a,e);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(a)}function co(a){var e=lo(a,"string");return typeof e=="symbol"?e:e+""}class Pe{constructor(e,t){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;const s="[".concat(e,"]:");this.trace=Qe,this.debug=t.debug.bind(null,s),this.log=t.log.bind(null,s),this.warn=t.warn.bind(null,s),this.info=t.info.bind(null,s),this.error=t.error.bind(null,s)}}const Qe=function(){},uo={trace:Qe,debug:Qe,log:Qe,warn:Qe,info:Qe,error:Qe};function Js(){return ie({},uo)}function ho(a,e){const t=self.console[a];return t?t.bind(self.console,"".concat(e?"["+e+"] ":"","[").concat(a,"] >")):Qe}function Ji(a,e,t){return e[a]?e[a].bind(e):ho(a,t)}const ei=Js();function fo(a,e,t){const s=Js();if(typeof console=="object"&&a===!0||typeof a=="object"){const i=["debug","log","info","warn","error"];i.forEach(r=>{s[r]=Ji(r,a,t)});try{s.log('Debug logs enabled for "'.concat(e,'" in hls.js version 1.6.12'))}catch(r){return Js()}i.forEach(r=>{ei[r]=Ji(r,a)})}else ie(ei,s);return s}const se=ei;function Je(a=!0){return typeof self>"u"?void 0:(a||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function go(a){return typeof self<"u"&&a===self.ManagedMediaSource}function yn(a,e){const t=Object.keys(a),s=Object.keys(e),i=t.length,r=s.length;return!i||!r||i===r&&!t.some(n=>s.indexOf(n)===-1)}function De(a,e=!1){if(typeof TextDecoder<"u"){const l=new TextDecoder("utf-8").decode(a);if(e){const c=l.indexOf("\0");return c!==-1?l.substring(0,c):l}return l.replace(/\0/g,"")}const t=a.length;let s,i,r,n="",o=0;for(;o<t;){if(s=a[o++],s===0&&e)return n;if(s===0||s===3)continue;switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:n+=String.fromCharCode(s);break;case 12:case 13:i=a[o++],n+=String.fromCharCode((s&31)<<6|i&63);break;case 14:i=a[o++],r=a[o++],n+=String.fromCharCode((s&15)<<12|(i&63)<<6|(r&63)<<0);break}}return n}function Ae(a){let e="";for(let t=0;t<a.length;t++){let s=a[t].toString(16);s.length<2&&(s="0"+s),e+=s}return e}function vn(a){return Uint8Array.from(a.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function mo(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var _s={exports:{}},er;function po(){return er||(er=1,(function(a,e){(function(t){var s=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,i=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,n=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(d,l,c){if(c=c||{},d=d.trim(),l=l.trim(),!l){if(!c.alwaysNormalize)return d;var u=o.parseURL(d);if(!u)throw new Error("Error trying to parse base URL.");return u.path=o.normalizePath(u.path),o.buildURLFromParts(u)}var h=o.parseURL(l);if(!h)throw new Error("Error trying to parse relative URL.");if(h.scheme)return c.alwaysNormalize?(h.path=o.normalizePath(h.path),o.buildURLFromParts(h)):l;var f=o.parseURL(d);if(!f)throw new Error("Error trying to parse base URL.");if(!f.netLoc&&f.path&&f.path[0]!=="/"){var g=i.exec(f.path);f.netLoc=g[1],f.path=g[2]}f.netLoc&&!f.path&&(f.path="/");var m={scheme:f.scheme,netLoc:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(m.netLoc=f.netLoc,h.path[0]!=="/"))if(!h.path)m.path=f.path,h.params||(m.params=f.params,h.query||(m.query=f.query));else{var p=f.path,v=p.substring(0,p.lastIndexOf("/")+1)+h.path;m.path=o.normalizePath(v)}return m.path===null&&(m.path=c.alwaysNormalize?o.normalizePath(h.path):h.path),o.buildURLFromParts(m)},parseURL:function(d){var l=s.exec(d);return l?{scheme:l[1]||"",netLoc:l[2]||"",path:l[3]||"",params:l[4]||"",query:l[5]||"",fragment:l[6]||""}:null},normalizePath:function(d){for(d=d.split("").reverse().join("").replace(r,"");d.length!==(d=d.replace(n,"")).length;);return d.split("").reverse().join("")},buildURLFromParts:function(d){return d.scheme+d.netLoc+d.path+d.params+d.query+d.fragment}};a.exports=o})()})(_s)),_s.exports}var vi=po();class Ei{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}}var re={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class En{constructor(e){this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,typeof e=="string"&&(e={url:e}),this.base=e,vo(this,"stats")}setByteRange(e,t){const s=e.split("@",2);let i;s.length===1?i=(t==null?void 0:t.byteRangeEndOffset)||0:i=parseInt(s[1]),this._byteRange=[i,parseInt(s[0])+i]}get baseurl(){return this.base.url}get byteRange(){return this._byteRange===null?[]:this._byteRange}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get elementaryStreams(){return this._streams===null&&(this._streams={[re.AUDIO]:null,[re.VIDEO]:null,[re.AUDIOVIDEO]:null}),this._streams}set elementaryStreams(e){this._streams=e}get hasStats(){return this._stats!==null}get hasStreams(){return this._streams!==null}get stats(){return this._stats===null&&(this._stats=new Ei),this._stats}set stats(e){this._stats=e}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=vi.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[re.AUDIO]=null,e[re.VIDEO]=null,e[re.AUDIOVIDEO]=null}}function he(a){return a.sn!=="initSegment"}class ks extends En{constructor(e,t){super(t),this._decryptdata=null,this._programDateTime=null,this._ref=null,this._bitrate=void 0,this.rawProgramDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.playlistOffset=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e}get byteLength(){if(this.hasStats){const e=this.stats.total;if(e)return e}if(this.byteRange.length){const e=this.byteRange[0],t=this.byteRange[1];if(K(e)&&K(t))return t-e}return null}get bitrate(){return this.byteLength?this.byteLength*8/this.duration:this._bitrate?this._bitrate:null}set bitrate(e){this._bitrate=e}get decryptdata(){const{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{const s=Object.keys(this.levelkeys);if(s.length===1){const i=this._decryptdata=this.levelkeys[s[0]]||null;if(i)return i.getDecryptData(this.sn)}}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null)return null;const e=K(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){var t;const s=Object.keys(this.levelkeys),i=s.length;if(i>1||i===1&&(t=this.levelkeys[s[0]])!=null&&t.encrypted)return!0}return!1}get programDateTime(){return this._programDateTime===null&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime}set programDateTime(e){if(!K(e)){this._programDateTime=this.rawProgramDateTime=null;return}this._programDateTime=e}get ref(){return he(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}addStart(e){this.setStart(this.start+e)}setStart(e){this.start=e,this._ref&&(this._ref.start=e)}setDuration(e){this.duration=e,this._ref&&(this._ref.duration=e)}setKeyFormat(e){if(this.levelkeys){const t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort()}setElementaryStreamInfo(e,t,s,i,r,n=!1){const{elementaryStreams:o}=this,d=o[e];if(!d){o[e]={startPTS:t,endPTS:s,startDTS:i,endDTS:r,partial:n};return}d.startPTS=Math.min(d.startPTS,t),d.endPTS=Math.max(d.endPTS,s),d.startDTS=Math.min(d.startDTS,i),d.endDTS=Math.max(d.endDTS,r)}}class yo extends En{constructor(e,t,s,i,r){super(s),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=i;const n=e.enumeratedString("BYTERANGE");n&&this.setByteRange(n,r),r&&(this.fragOffset=r.fragOffset+r.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}}function Tn(a,e){const t=Object.getPrototypeOf(a);if(t){const s=Object.getOwnPropertyDescriptor(t,e);return s||Tn(t,e)}}function vo(a,e){const t=Tn(a,e);t&&(t.enumerable=!0,Object.defineProperty(a,e,t))}const tr=Math.pow(2,32)-1,Eo=[].push,Sn={video:1,audio:2,id3:3,text:4};function fe(a){return String.fromCharCode.apply(null,a)}function xn(a,e){const t=a[e]<<8|a[e+1];return t<0?65536+t:t}function z(a,e){const t=An(a,e);return t<0?4294967296+t:t}function sr(a,e){let t=z(a,e);return t*=Math.pow(2,32),t+=z(a,e+4),t}function An(a,e){return a[e]<<24|a[e+1]<<16|a[e+2]<<8|a[e+3]}function To(a){const e=a.byteLength;for(let t=0;t<e;){const s=z(a,t);if(s>8&&a[t+4]===109&&a[t+5]===111&&a[t+6]===111&&a[t+7]===102)return!0;t=s>1?t+s:e}return!1}function Q(a,e){const t=[];if(!e.length)return t;const s=a.byteLength;for(let i=0;i<s;){const r=z(a,i),n=fe(a.subarray(i+4,i+8)),o=r>1?i+r:s;if(n===e[0])if(e.length===1)t.push(a.subarray(i+8,o));else{const d=Q(a.subarray(i+8,o),e.slice(1));d.length&&Eo.apply(t,d)}i=o}return t}function So(a){const e=[],t=a[0];let s=8;const i=z(a,s);s+=4;let r=0,n=0;t===0?(r=z(a,s),n=z(a,s+4),s+=8):(r=sr(a,s),n=sr(a,s+8),s+=16),s+=2;let o=a.length+n;const d=xn(a,s);s+=2;for(let l=0;l<d;l++){let c=s;const u=z(a,c);c+=4;const h=u&2147483647;if((u&2147483648)>>>31===1)return se.warn("SIDX has hierarchical references (not supported)"),null;const g=z(a,c);c+=4,e.push({referenceSize:h,subsegmentDuration:g,info:{duration:g/i,start:o,end:o+h-1}}),o+=h,c+=4,s=c}return{earliestPresentationTime:r,timescale:i,version:t,referencesCount:d,references:e}}function Ln(a){const e=[],t=Q(a,["moov","trak"]);for(let i=0;i<t.length;i++){const r=t[i],n=Q(r,["tkhd"])[0];if(n){let o=n[0];const d=z(n,o===0?12:20),l=Q(r,["mdia","mdhd"])[0];if(l){o=l[0];const c=z(l,o===0?12:20),u=Q(r,["mdia","hdlr"])[0];if(u){const h=fe(u.subarray(8,12)),f={soun:re.AUDIO,vide:re.VIDEO}[h],g=Q(r,["mdia","minf","stbl","stsd"])[0],m=xo(g);f?(e[d]={timescale:c,type:f,stsd:m},e[f]=te({timescale:c,id:d},m)):e[d]={timescale:c,type:h,stsd:m}}}}}return Q(a,["moov","mvex","trex"]).forEach(i=>{const r=z(i,4),n=e[r];n&&(n.default={duration:z(i,12),flags:z(i,20)})}),e}function xo(a){const e=a.subarray(8),t=e.subarray(86),s=fe(e.subarray(4,8));let i=s,r;const n=s==="enca"||s==="encv";if(n){const l=Q(e,[s])[0].subarray(s==="enca"?28:78);Q(l,["sinf"]).forEach(u=>{const h=Q(u,["schm"])[0];if(h){const f=fe(h.subarray(4,8));if(f==="cbcs"||f==="cenc"){const g=Q(u,["frma"])[0];g&&(i=fe(g))}}})}const o=i;switch(i){case"avc1":case"avc2":case"avc3":case"avc4":{const d=Q(t,["avcC"])[0];d&&d.length>3&&(i+="."+Ht(d[1])+Ht(d[2])+Ht(d[3]),r=Vt(o==="avc1"?"dva1":"dvav",t));break}case"mp4a":{const d=Q(e,[s])[0],l=Q(d.subarray(28),["esds"])[0];if(l&&l.length>7){let c=4;if(l[c++]!==3)break;c=Cs(l,c),c+=2;const u=l[c++];if(u&128&&(c+=2),u&64&&(c+=l[c++]),l[c++]!==4)break;c=Cs(l,c);const h=l[c++];if(h===64)i+="."+Ht(h);else break;if(c+=12,l[c++]!==5)break;c=Cs(l,c);const f=l[c++];let g=(f&248)>>3;g===31&&(g+=1+((f&7)<<3)+((l[c]&224)>>5)),i+="."+g}break}case"hvc1":case"hev1":{const d=Q(t,["hvcC"])[0];if(d&&d.length>12){const l=d[1],c=["","A","B","C"][l>>6],u=l&31,h=z(d,2),f=(l&32)>>5?"H":"L",g=d[12],m=d.subarray(6,12);i+="."+c+u,i+="."+Ao(h).toString(16).toUpperCase(),i+="."+f+g;let p="";for(let v=m.length;v--;){const E=m[v];(E||p)&&(p="."+E.toString(16).toUpperCase()+p)}i+=p}r=Vt(o=="hev1"?"dvhe":"dvh1",t);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":{i=Vt(i,t)||i;break}case"vp09":{const d=Q(t,["vpcC"])[0];if(d&&d.length>6){const l=d[4],c=d[5],u=d[6]>>4&15;i+="."+Be(l)+"."+Be(c)+"."+Be(u)}break}case"av01":{const d=Q(t,["av1C"])[0];if(d&&d.length>2){const l=d[1]>>>5,c=d[1]&31,u=d[2]>>>7?"H":"M",h=(d[2]&64)>>6,f=(d[2]&32)>>5,g=l===2&&h?f?12:10:h?10:8,m=(d[2]&16)>>4,p=(d[2]&8)>>3,v=(d[2]&4)>>2,E=d[2]&3;i+="."+l+"."+Be(c)+u+"."+Be(g)+"."+m+"."+p+v+E+"."+Be(1)+"."+Be(1)+"."+Be(1)+"."+0,r=Vt("dav1",t)}break}}return{codec:i,encrypted:n,supplemental:r}}function Vt(a,e){const t=Q(e,["dvvC"]),s=t.length?t[0]:Q(e,["dvcC"])[0];if(s){const i=s[2]>>1&127,r=s[2]<<5&32|s[3]>>3&31;return a+"."+Be(i)+"."+Be(r)}}function Ao(a){let e=0;for(let t=0;t<32;t++)e|=(a>>t&1)<<31-t;return e>>>0}function Cs(a,e){const t=e+5;for(;a[e++]&128&&e<t;);return e}function Ht(a){return("0"+a.toString(16).toUpperCase()).slice(-2)}function Be(a){return(a<10?"0":"")+a}function Lo(a,e){if(!a||!e)return;const t=e.keyId;t&&e.isCommonEncryption&&Q(a,["moov","trak"]).forEach(i=>{const n=Q(i,["mdia","minf","stbl","stsd"])[0].subarray(8);let o=Q(n,["enca"]);const d=o.length>0;d||(o=Q(n,["encv"])),o.forEach(l=>{const c=d?l.subarray(28):l.subarray(78);Q(c,["sinf"]).forEach(h=>{const f=In(h);if(f){const g=f.subarray(8,24);g.some(m=>m!==0)||(se.log("[eme] Patching keyId in 'enc".concat(d?"a":"v",">sinf>>tenc' box: ").concat(Ae(g)," -> ").concat(Ae(t))),f.set(t,8))}})})})}function In(a){const e=Q(a,["schm"])[0];if(e){const t=fe(e.subarray(4,8));if(t==="cbcs"||t==="cenc")return Q(a,["schi","tenc"])[0]}return null}function Io(a,e,t){const s={},i=Q(a,["moof","traf"]);for(let r=0;r<i.length;r++){const n=i[r],o=Q(n,["tfhd"])[0],d=z(o,4),l=e[d];if(!l)continue;s[d]||(s[d]={start:NaN,duration:0,sampleCount:0,timescale:l.timescale,type:l.type});const c=s[d],u=Q(n,["tfdt"])[0];if(u){const T=u[0];let S=z(u,4);T===1&&(S===tr?t.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(S*=tr+1,S+=z(u,8))),K(S)&&(!K(c.start)||S<c.start)&&(c.start=S)}const h=l.default,f=z(o,0)|(h==null?void 0:h.flags);let g=(h==null?void 0:h.duration)||0;f&8&&(f&2?g=z(o,12):g=z(o,8));const m=Q(n,["trun"]);let p=c.start||0,v=0,E=g;for(let T=0;T<m.length;T++){const S=m[T],x=z(S,4),b=c.sampleCount;c.sampleCount+=x;const A=S[3]&1,I=S[3]&4,R=S[2]&1,L=S[2]&2,w=S[2]&4,U=S[2]&8;let V=8,B=x;for(A&&(V+=4),I&&x&&(!(S[V+1]&1)&&c.keyFrameIndex===void 0&&(c.keyFrameIndex=b),V+=4,R?(E=z(S,V),V+=4):E=g,L&&(V+=4),U&&(V+=4),p+=E,v+=E,B--);B--;)R?(E=z(S,V),V+=4):E=g,L&&(V+=4),w&&(S[V+1]&1||c.keyFrameIndex===void 0&&(c.keyFrameIndex=c.sampleCount-(B+1),c.keyFrameStart=p),V+=4),U&&(V+=4),p+=E,v+=E;!v&&g&&(v+=g*x)}c.duration+=v}if(!Object.keys(s).some(r=>s[r].duration)){let r=1/0,n=0;const o=Q(a,["sidx"]);for(let d=0;d<o.length;d++){const l=So(o[d]);if(l!=null&&l.references){r=Math.min(r,l.earliestPresentationTime/l.timescale);const c=l.references.reduce((u,h)=>u+h.info.duration||0,0);n=Math.max(n,c+l.earliestPresentationTime/l.timescale)}}n&&K(n)&&Object.keys(s).forEach(d=>{s[d].duration||(s[d].duration=n*s[d].timescale-s[d].start)})}return s}function bo(a){const e={valid:null,remainder:null},t=Q(a,["moof"]);if(t.length<2)return e.remainder=a,e;const s=t[t.length-1];return e.valid=a.slice(0,s.byteOffset-8),e.remainder=a.slice(s.byteOffset-8),e}function Ce(a,e){const t=new Uint8Array(a.length+e.length);return t.set(a),t.set(e,a.length),t}function ir(a,e){const t=[],s=e.samples,i=e.timescale,r=e.id;let n=!1;return Q(s,["moof"]).map(d=>{const l=d.byteOffset-8;Q(d,["traf"]).map(u=>{const h=Q(u,["tfdt"]).map(f=>{const g=f[0];let m=z(f,4);return g===1&&(m*=Math.pow(2,32),m+=z(f,8)),m/i})[0];return h!==void 0&&(a=h),Q(u,["tfhd"]).map(f=>{const g=z(f,4),m=z(f,0)&16777215,p=(m&1)!==0,v=(m&2)!==0,E=(m&8)!==0;let T=0;const S=(m&16)!==0;let x=0;const b=(m&32)!==0;let A=8;g===r&&(p&&(A+=8),v&&(A+=4),E&&(T=z(f,A),A+=4),S&&(x=z(f,A),A+=4),b&&(A+=4),e.type==="video"&&(n=Ls(e.codec)),Q(u,["trun"]).map(I=>{const R=I[0],L=z(I,0)&16777215,w=(L&1)!==0;let U=0;const V=(L&4)!==0,B=(L&256)!==0;let N=0;const M=(L&512)!==0;let C=0;const k=(L&1024)!==0,O=(L&2048)!==0;let G=0;const F=z(I,4);let $=8;w&&(U=z(I,$),$+=4),V&&($+=4);let q=U+l;for(let Z=0;Z<F;Z++){if(B?(N=z(I,$),$+=4):N=T,M?(C=z(I,$),$+=4):C=x,k&&($+=4),O&&(R===0?G=z(I,$):G=An(I,$),$+=4),e.type===re.VIDEO){let Y=0;for(;Y<C;){const j=z(s,q);if(q+=4,Ro(n,s[q])){const oe=s.subarray(q,q+j);Ti(oe,n?2:1,a+G/i,t)}q+=j,Y+=j+4}}a+=N/i}}))})})}),t}function Ls(a){if(!a)return!1;const e=a.substring(0,4);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function Ro(a,e){if(a){const t=e>>1&63;return t===39||t===40}else return(e&31)===6}function Ti(a,e,t,s){const i=bn(a);let r=0;r+=e;let n=0,o=0,d=0;for(;r<i.length;){n=0;do{if(r>=i.length)break;d=i[r++],n+=d}while(d===255);o=0;do{if(r>=i.length)break;d=i[r++],o+=d}while(d===255);const l=i.length-r;let c=r;if(o<l)r+=o;else if(o>l){se.error("Malformed SEI payload. ".concat(o," is too small, only ").concat(l," bytes left to parse."));break}if(n===4){if(i[c++]===181){const h=xn(i,c);if(c+=2,h===49){const f=z(i,c);if(c+=4,f===1195456820){const g=i[c++];if(g===3){const m=i[c++],p=31&m,v=64&m,E=v?2+p*3:0,T=new Uint8Array(E);if(v){T[0]=m;for(let S=1;S<E;S++)T[S]=i[c++]}s.push({type:g,payloadType:n,pts:t,bytes:T})}}}}}else if(n===5&&o>16){const u=[];for(let g=0;g<16;g++){const m=i[c++].toString(16);u.push(m.length==1?"0"+m:m),(g===3||g===5||g===7||g===9)&&u.push("-")}const h=o-16,f=new Uint8Array(h);for(let g=0;g<h;g++)f[g]=i[c++];s.push({payloadType:n,pts:t,uuid:u.join(""),userData:De(f),userDataBytes:f})}}}function bn(a){const e=a.byteLength,t=[];let s=1;for(;s<e-2;)a[s]===0&&a[s+1]===0&&a[s+2]===3?(t.push(s+2),s+=2):s++;if(t.length===0)return a;const i=e-t.length,r=new Uint8Array(i);let n=0;for(s=0;s<i;n++,s++)n===t[0]&&(n++,t.shift()),r[s]=a[n];return r}function Do(a){const e=a[0];let t="",s="",i=0,r=0,n=0,o=0,d=0,l=0;if(e===0){for(;fe(a.subarray(l,l+1))!=="\0";)t+=fe(a.subarray(l,l+1)),l+=1;for(t+=fe(a.subarray(l,l+1)),l+=1;fe(a.subarray(l,l+1))!=="\0";)s+=fe(a.subarray(l,l+1)),l+=1;s+=fe(a.subarray(l,l+1)),l+=1,i=z(a,12),r=z(a,16),o=z(a,20),d=z(a,24),l=28}else if(e===1){l+=4,i=z(a,l),l+=4;const u=z(a,l);l+=4;const h=z(a,l);for(l+=4,n=2**32*u+h,ro(n)||(n=Number.MAX_SAFE_INTEGER,se.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=z(a,l),l+=4,d=z(a,l),l+=4;fe(a.subarray(l,l+1))!=="\0";)t+=fe(a.subarray(l,l+1)),l+=1;for(t+=fe(a.subarray(l,l+1)),l+=1;fe(a.subarray(l,l+1))!=="\0";)s+=fe(a.subarray(l,l+1)),l+=1;s+=fe(a.subarray(l,l+1)),l+=1}const c=a.subarray(l,a.byteLength);return{schemeIdUri:t,value:s,timeScale:i,presentationTime:n,presentationTimeDelta:r,eventDuration:o,id:d,payload:c}}function _o(a,...e){const t=e.length;let s=8,i=t;for(;i--;)s+=e[i].byteLength;const r=new Uint8Array(s);for(r[0]=s>>24&255,r[1]=s>>16&255,r[2]=s>>8&255,r[3]=s&255,r.set(a,4),i=0,s=8;i<t;i++)r.set(e[i],s),s+=e[i].byteLength;return r}function ko(a,e,t){if(a.byteLength!==16)throw new RangeError("Invalid system id");let s,i;s=0,i=new Uint8Array;let r;s>0?(r=new Uint8Array(4),e.length>0&&new DataView(r.buffer).setUint32(0,e.length,!1)):r=new Uint8Array;const n=new Uint8Array(4);return t.byteLength>0&&new DataView(n.buffer).setUint32(0,t.byteLength,!1),_o([112,115,115,104],new Uint8Array([s,0,0,0]),a,r,i,n,t)}function Co(a){const e=[];if(a instanceof ArrayBuffer){const t=a.byteLength;let s=0;for(;s+32<t;){const i=new DataView(a,s),r=Po(i);e.push(r),s+=r.size}}return e}function Po(a){const e=a.getUint32(0),t=a.byteOffset,s=a.byteLength;if(s<e)return{offset:t,size:s};if(a.getUint32(4)!==1886614376)return{offset:t,size:e};const r=a.getUint32(8)>>>24;if(r!==0&&r!==1)return{offset:t,size:e};const n=a.buffer,o=Ae(new Uint8Array(n,t+12,16));let d=null,l=null,c=0;if(r===0)c=28;else{const h=a.getUint32(28);if(!h||s<32+h*16)return{offset:t,size:e};d=[];for(let f=0;f<h;f++)d.push(new Uint8Array(n,t+32+f*16,16));c=32+h*16}if(!c)return{offset:t,size:e};const u=a.getUint32(c);return e-32<u?{offset:t,size:e}:(l=new Uint8Array(n,t+c+4,u),{version:r,systemId:o,kids:d,data:l,offset:t,size:e})}const Rn=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),St={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,dav1:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function Si(a,e){const t=St[e];return!!t&&!!t[a.slice(0,4)]}function wt(a,e,t=!0){return!a.split(",").some(s=>!xi(s,e,t))}function xi(a,e,t=!0){var s;const i=Je(t);return(s=i==null?void 0:i.isTypeSupported(Ot(a,e)))!=null?s:!1}function Ot(a,e){return"".concat(e,"/mp4;codecs=").concat(a)}function rr(a){if(a){const e=a.substring(0,4);return St.video[e]}return 2}function gs(a){const e=Rn();return a.split(",").reduce((t,s)=>{const r=e&&Ls(s)?9:St.video[s];return r?(r*2+t)/(t?3:2):(St.audio[s]+t)/(t?2:1)},0)}const Ps={};function wo(a,e=!0){if(Ps[a])return Ps[a];const t={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[a];for(let i=0;i<t.length;i++){var s;if(xi(t[i],"audio",e))return Ps[a]=t[i],t[i];if(t[i]==="mp3"&&(s=Je(e))!=null&&s.isTypeSupported("audio/mpeg"))return""}return a}const Oo=/flac|opus|mp4a\.40\.34/i;function ms(a,e=!0){return a.replace(Oo,t=>wo(t.toLowerCase(),e))}function Mo(a,e){const t=[];if(a){const s=a.split(",");for(let i=0;i<s.length;i++)Si(s[i],"video")||t.push(s[i])}return e&&t.push(e),t.join(",")}function ns(a,e){if(a&&(a.length>4||["ac-3","ec-3","alac","fLaC","Opus"].indexOf(a)!==-1)&&(nr(a,"audio")||nr(a,"video")))return a;if(e){const t=e.split(",");if(t.length>1){if(a){for(let s=t.length;s--;)if(t[s].substring(0,4)===a.substring(0,4))return t[s]}return t[0]}}return e||a}function nr(a,e){return Si(a,e)&&xi(a,e)}function Fo(a){const e=a.split(",");for(let t=0;t<e.length;t++){const s=e[t].split(".");s.length>2&&s[0]==="avc1"&&(e[t]="avc1.".concat(parseInt(s[1]).toString(16)).concat(("000"+parseInt(s[2]).toString(16)).slice(-4)))}return e.join(",")}function $o(a){if(a.startsWith("av01.")){const e=a.split("."),t=["0","111","01","01","01","0"];for(let s=e.length;s>4&&s<10;s++)e[s]=t[s-4];return e.join(".")}return a}function ar(a){const e=Je(a)||{isTypeSupported:()=>!1};return{mpeg:e.isTypeSupported("audio/mpeg"),mp3:e.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:e.isTypeSupported('audio/mp4; codecs="ac-3"')}}function ti(a){return a.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}const No={supported:!0,powerEfficient:!0,smooth:!0},Bo={supported:!1,smooth:!1,powerEfficient:!1},Dn={supported:!0,configurations:[],decodingInfoResults:[No]};function _n(a,e){return{supported:!1,configurations:e,decodingInfoResults:[Bo],error:a}}function Uo(a,e,t,s,i,r){const n=a.videoCodec,o=a.audioCodec?a.audioGroups:null,d=r==null?void 0:r.audioCodec,l=r==null?void 0:r.channels,c=l?parseInt(l):d?1/0:2;let u=null;if(o!=null&&o.length)try{o.length===1&&o[0]?u=e.groups[o[0]].channels:u=o.reduce((h,f)=>{if(f){const g=e.groups[f];if(!g)throw new Error("Audio track group ".concat(f," not found"));Object.keys(g.channels).forEach(m=>{h[m]=(h[m]||0)+g.channels[m]})}return h},{2:0})}catch(h){return!0}return n!==void 0&&(n.split(",").some(h=>Ls(h))||a.width>1920&&a.height>1088||a.height>1920&&a.width>1088||a.frameRate>Math.max(s,30)||a.videoRange!=="SDR"&&a.videoRange!==t||a.bitrate>Math.max(i,8e6))||!!u&&K(c)&&Object.keys(u).some(h=>parseInt(h)>c)}function kn(a,e,t,s={}){const i=a.videoCodec;if(!i&&!a.audioCodec||!t)return Promise.resolve(Dn);const r=[],n=Go(a),o=n.length,d=Ko(a,e,o>0),l=d.length;for(let c=o||1*l||1;c--;){const u={type:"media-source"};if(o&&(u.video=n[c%o]),l){u.audio=d[c%l];const h=u.audio.bitrate;u.video&&h&&(u.video.bitrate-=h)}r.push(u)}if(i){const c=navigator.userAgent;if(i.split(",").some(u=>Ls(u))&&Rn())return Promise.resolve(_n(new Error("Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (".concat(c,")")),r))}return Promise.all(r.map(c=>{const u=Ho(c);return s[u]||(s[u]=t.decodingInfo(c))})).then(c=>({supported:!c.some(u=>!u.supported),configurations:r,decodingInfoResults:c})).catch(c=>({supported:!1,configurations:r,decodingInfoResults:[],error:c}))}function Go(a){var e;const t=(e=a.videoCodec)==null?void 0:e.split(","),s=Cn(a),i=a.width||640,r=a.height||480,n=a.frameRate||30,o=a.videoRange.toLowerCase();return t?t.map(d=>{const l={contentType:Ot($o(d),"video"),width:i,height:r,bitrate:s,framerate:n};return o!=="sdr"&&(l.transferFunction=o),l}):[]}function Ko(a,e,t){var s;const i=(s=a.audioCodec)==null?void 0:s.split(","),r=Cn(a);return i&&a.audioGroups?a.audioGroups.reduce((n,o)=>{var d;const l=o?(d=e.groups[o])==null?void 0:d.tracks:null;return l?l.reduce((c,u)=>{if(u.groupId===o){const h=parseFloat(u.channels||"");i.forEach(f=>{const g={contentType:Ot(f,"audio"),bitrate:t?Vo(f,r):r};h&&(g.channels=""+h),c.push(g)})}return c},n):n},[]):[]}function Vo(a,e){if(e<=1)return 1;let t=128e3;return a==="ec-3"?t=768e3:a==="ac-3"&&(t=64e4),Math.min(e/2,t)}function Cn(a){return Math.ceil(Math.max(a.bitrate*.9,a.averageBitrate)/1e3)*1e3||1}function Ho(a){let e="";const{audio:t,video:s}=a;if(s){const i=ti(s.contentType);e+="".concat(i,"_r").concat(s.height,"x").concat(s.width,"f").concat(Math.ceil(s.framerate)).concat(s.transferFunction||"sd","_").concat(Math.ceil(s.bitrate/1e5))}if(t){const i=ti(t.contentType);e+="".concat(s?"_":"").concat(i,"_c").concat(t.channels)}return e}const si=["NONE","TYPE-0","TYPE-1",null];function Wo(a){return si.indexOf(a)>-1}const ps=["SDR","PQ","HLG"];function Yo(a){return!!a&&ps.indexOf(a)>-1}var as={No:"",Yes:"YES",v2:"v2"};function or(a){const{canSkipUntil:e,canSkipDateRanges:t,age:s}=a,i=s<e/2;return e&&i?t?as.v2:as.Yes:as.No}class lr{constructor(e,t,s){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=s}addDirectives(e){const t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}class Mt{constructor(e){if(this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.supplemental=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(s=>!!s).map(s=>s.substring(0,4)).join(","),"supplemental"in e){var t;this.supplemental=e.supplemental;const s=(t=e.supplemental)==null?void 0:t.videoCodec;s&&s!==e.videoCodec&&(this.codecSet+=",".concat(s.substring(0,4)))}this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return dr(this._audioGroups,e)}hasSubtitleGroup(e){return dr(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t){if(e==="audio"){let s=this._audioGroups;s||(s=this._audioGroups=[]),s.indexOf(t)===-1&&s.push(t)}else if(e==="text"){let s=this._subtitleGroups;s||(s=this._subtitleGroups=[]),s.indexOf(t)===-1&&s.push(t)}}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return(e=this.audioGroups)==null?void 0:e[0]}get textGroupId(){var e;return(e=this.subtitleGroups)==null?void 0:e[0]}addFallback(){}}function dr(a,e){return!e||!a?!1:a.indexOf(e)!==-1}function qo(){if(typeof matchMedia=="function"){const a=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(a.media!==e.media)return a.matches===!0}return!1}function jo(a,e){let t=!1,s=[];if(a&&(t=a!=="SDR",s=[a]),e){s=e.allowedVideoRanges||ps.slice(0);const i=s.join("")!=="SDR"&&!e.videoCodec;t=e.preferHDR!==void 0?e.preferHDR:i&&qo(),t||(s=["SDR"])}return{preferHDR:t,allowedVideoRanges:s}}const zo=a=>{const e=new WeakSet;return(t,s)=>{if(a&&(s=a(t,s)),typeof s=="object"&&s!==null){if(e.has(s))return;e.add(s)}return s}},ne=(a,e)=>JSON.stringify(a,zo(e));function Xo(a,e,t,s,i){const r=Object.keys(a),n=s==null?void 0:s.channels,o=s==null?void 0:s.audioCodec,d=i==null?void 0:i.videoCodec,l=n&&parseInt(n)===2;let c=!1,u=!1,h=1/0,f=1/0,g=1/0,m=1/0,p=0,v=[];const{preferHDR:E,allowedVideoRanges:T}=jo(e,i);for(let I=r.length;I--;){const R=a[r[I]];c||(c=R.channels[2]>0),h=Math.min(h,R.minHeight),f=Math.min(f,R.minFramerate),g=Math.min(g,R.minBitrate),T.filter(w=>R.videoRanges[w]>0).length>0&&(u=!0)}h=K(h)?h:0,f=K(f)?f:0;const S=Math.max(1080,h),x=Math.max(30,f);g=K(g)?g:t,t=Math.max(g,t),u||(e=void 0);const b=r.length>1;return{codecSet:r.reduce((I,R)=>{const L=a[R];if(R===I)return I;if(v=u?T.filter(w=>L.videoRanges[w]>0):[],b){if(L.minBitrate>t)return Fe(R,"min bitrate of ".concat(L.minBitrate," > current estimate of ").concat(t)),I;if(!L.hasDefaultAudio)return Fe(R,"no renditions with default or auto-select sound found"),I;if(o&&R.indexOf(o.substring(0,4))%5!==0)return Fe(R,'audio codec preference "'.concat(o,'" not found')),I;if(n&&!l){if(!L.channels[n])return Fe(R,"no renditions with ".concat(n," channel sound found (channels options: ").concat(Object.keys(L.channels),")")),I}else if((!o||l)&&c&&L.channels[2]===0)return Fe(R,"no renditions with stereo sound found"),I;if(L.minHeight>S)return Fe(R,"min resolution of ".concat(L.minHeight," > maximum of ").concat(S)),I;if(L.minFramerate>x)return Fe(R,"min framerate of ".concat(L.minFramerate," > maximum of ").concat(x)),I;if(!v.some(w=>L.videoRanges[w]>0))return Fe(R,"no variants with VIDEO-RANGE of ".concat(ne(v)," found")),I;if(d&&R.indexOf(d.substring(0,4))%5!==0)return Fe(R,'video codec preference "'.concat(d,'" not found')),I;if(L.maxScore<p)return Fe(R,"max score of ".concat(L.maxScore," < selected max of ").concat(p)),I}return I&&(gs(R)>=gs(I)||L.fragmentError>a[I].fragmentError)?I:(m=L.minIndex,p=L.maxScore,R)},void 0),videoRanges:v,preferHDR:E,minFramerate:f,minBitrate:g,minIndex:m}}function Fe(a,e){se.log('[abr] start candidates with "'.concat(a,'" ignored because ').concat(e))}function Pn(a){return a.reduce((e,t)=>{let s=e.groups[t.groupId];s||(s=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),s.tracks.push(t);const i=t.channels||"2";return s.channels[i]=(s.channels[i]||0)+1,s.hasDefault=s.hasDefault||t.default,s.hasAutoSelect=s.hasAutoSelect||t.autoselect,s.hasDefault&&(e.hasDefaultAudio=!0),s.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function Qo(a,e,t,s){return a.slice(t,s+1).reduce((i,r,n)=>{if(!r.codecSet)return i;const o=r.audioGroups;let d=i[r.codecSet];d||(i[r.codecSet]=d={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:n,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!o,fragmentError:0}),d.minBitrate=Math.min(d.minBitrate,r.bitrate);const l=Math.min(r.height,r.width);return d.minHeight=Math.min(d.minHeight,l),d.minFramerate=Math.min(d.minFramerate,r.frameRate),d.minIndex=Math.min(d.minIndex,n),d.maxScore=Math.max(d.maxScore,r.score),d.fragmentError+=r.fragmentError,d.videoRanges[r.videoRange]=(d.videoRanges[r.videoRange]||0)+1,o&&o.forEach(c=>{if(!c)return;const u=e.groups[c];u&&(d.hasDefaultAudio=d.hasDefaultAudio||e.hasDefaultAudio?u.hasDefault:u.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(u.channels).forEach(h=>{d.channels[h]=(d.channels[h]||0)+u.channels[h]}))}),i},{})}function cr(a){if(!a)return a;const{lang:e,assocLang:t,characteristics:s,channels:i,audioCodec:r}=a;return{lang:e,assocLang:t,characteristics:s,channels:i,audioCodec:r}}function Ge(a,e,t){if("attrs"in a){const s=e.indexOf(a);if(s!==-1)return s}for(let s=0;s<e.length;s++){const i=e[s];if(ot(a,i,t))return s}return-1}function ot(a,e,t){const{groupId:s,name:i,lang:r,assocLang:n,default:o}=a,d=a.forced;return(s===void 0||e.groupId===s)&&(i===void 0||e.name===i)&&(r===void 0||Zo(r,e.lang))&&(r===void 0||e.assocLang===n)&&(o===void 0||e.default===o)&&(d===void 0||e.forced===d)&&(!("characteristics"in a)||Jo(a.characteristics||"",e.characteristics))&&(t===void 0||t(a,e))}function Zo(a,e="--"){return a.length===e.length?a===e:a.startsWith(e)||e.startsWith(a)}function Jo(a,e=""){const t=a.split(","),s=e.split(",");return t.length===s.length&&!t.some(i=>s.indexOf(i)===-1)}function nt(a,e){const{audioCodec:t,channels:s}=a;return(t===void 0||(e.audioCodec||"").substring(0,4)===t.substring(0,4))&&(s===void 0||s===(e.channels||"2"))}function el(a,e,t,s,i){const r=e[s],o=e.reduce((h,f,g)=>{const m=f.uri;return(h[m]||(h[m]=[])).push(g),h},{})[r.uri];o.length>1&&(s=Math.max.apply(Math,o));const d=r.videoRange,l=r.frameRate,c=r.codecSet.substring(0,4),u=ur(e,s,h=>{if(h.videoRange!==d||h.frameRate!==l||h.codecSet.substring(0,4)!==c)return!1;const f=h.audioGroups,g=t.filter(m=>!f||f.indexOf(m.groupId)!==-1);return Ge(a,g,i)>-1});return u>-1?u:ur(e,s,h=>{const f=h.audioGroups,g=t.filter(m=>!f||f.indexOf(m.groupId)!==-1);return Ge(a,g,i)>-1})}function ur(a,e,t){for(let s=e;s>-1;s--)if(t(a[s]))return s;for(let s=e+1;s<a.length;s++)if(t(a[s]))return s;return-1}function ys(a,e){var t;return!!a&&a!==((t=e.loadLevelObj)==null?void 0:t.uri)}class tl extends Pe{constructor(e){super("abr",e.logger),this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.rebufferNotice=-1,this.supportedCache={},this.bwEstimator=void 0,this._abandonRulesCheck=t=>{var s;const{fragCurrent:i,partCurrent:r,hls:n}=this,{autoLevelEnabled:o,media:d}=n;if(!i||!d)return;const l=performance.now(),c=r?r.stats:i.stats,u=r?r.duration:i.duration,h=l-c.loading.start,f=n.minAutoLevel,g=i.level,m=this._nextAutoLevel;if(c.aborted||c.loaded&&c.loaded===c.total||g<=f){this.clearTimer(),this._nextAutoLevel=-1;return}if(!o)return;const p=m>-1&&m!==g,v=!!t||p;if(!v&&(d.paused||!d.playbackRate||!d.readyState))return;const E=n.mainForwardBufferInfo;if(!v&&E===null)return;const T=this.bwEstimator.getEstimateTTFB(),S=Math.abs(d.playbackRate);if(h<=Math.max(T,1e3*(u/(S*2))))return;const x=E?E.len/S:0,b=c.loading.first?c.loading.first-c.loading.start:-1,A=c.loaded&&b>-1,I=this.getBwEstimate(),R=n.levels,L=R[g],w=Math.max(c.loaded,Math.round(u*(i.bitrate||L.averageBitrate)/8));let U=A?h-b:h;U<1&&A&&(U=Math.min(h,c.loaded*8/I));const V=A?c.loaded*1e3/U:0,B=T/1e3,N=V?(w-c.loaded)/V:w*8/I+B;if(N<=x)return;const M=V?V*8:I,C=((s=(t==null?void 0:t.details)||this.hls.latestLevelDetails)==null?void 0:s.live)===!0,k=this.hls.config.abrBandWidthUpFactor;let O=Number.POSITIVE_INFINITY,G;for(G=g-1;G>f;G--){const Z=R[G].maxBitrate,Y=!R[G].details||C;if(O=this.getTimeToLoadFrag(B,M,u*Z,Y),O<Math.min(x,u+B))break}if(O>=N||O>u*10)return;A?this.bwEstimator.sample(h-Math.min(T,b),c.loaded):this.bwEstimator.sampleTTFB(h);const F=R[G].maxBitrate;this.getBwEstimate()*k>F&&this.resetEstimator(F);const $=this.findBestLevel(F,f,G,0,x,1,1);$>-1&&(G=$),this.warn("Fragment ".concat(i.sn).concat(r?" part "+r.index:""," of level ").concat(g," is loading too slowly;\n Fragment duration: ").concat(i.duration.toFixed(3),"\n Time to underbuffer: ").concat(x.toFixed(3)," s\n Estimated load time for current fragment: ").concat(N.toFixed(3)," s\n Estimated load time for down switch fragment: ").concat(O.toFixed(3)," s\n TTFB estimate: ").concat(b|0," ms\n Current BW estimate: ").concat(K(I)?I|0:"Unknown"," bps\n New BW estimate: ").concat(this.getBwEstimate()|0," bps\n Switching to level ").concat(G," @ ").concat(F|0," bps")),n.nextLoadLevel=n.nextAutoLevel=G,this.clearTimer();const q=()=>{if(this.clearTimer(),this.fragCurrent===i&&this.hls.loadLevel===G&&G>0){const Z=this.getStarvationDelay();if(this.warn("Aborting inflight request ".concat(G>0?"and switching down":"","\n Fragment duration: ").concat(i.duration.toFixed(3)," s\n Time to underbuffer: ").concat(Z.toFixed(3)," s")),i.abortRequests(),this.fragCurrent=this.partCurrent=null,G>f){let Y=this.findBestLevel(this.hls.levels[f].bitrate,f,G,0,Z,1,1);Y===-1&&(Y=f),this.hls.nextLoadLevel=this.hls.nextAutoLevel=Y,this.resetEstimator(this.hls.levels[Y].bitrate)}}};p||N>O*2?q():this.timer=self.setInterval(q,O*1e3),n.trigger(y.FRAG_LOAD_EMERGENCY_ABORTED,{frag:i,part:r,stats:c})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){e&&(this.log("setting initial bwe to ".concat(e)),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){const e=this.hls.config;return new ao(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.FRAG_LOADING,this.onFragLoading,this),e.on(y.FRAG_LOADED,this.onFragLoaded,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this),e.on(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(y.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(y.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.FRAG_LOADING,this.onFragLoading,this),e.off(y.FRAG_LOADED,this.onFragLoaded,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this),e.off(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(y.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(y.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=this.supportedCache=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.supportedCache={},this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(e,t){const s=t.frag;if(!this.ignoreFragment(s)){if(!s.bitrateTest){var i;this.fragCurrent=s,this.partCurrent=(i=t.part)!=null?i:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}onLevelSwitching(e,t){this.clearTimer()}onError(e,t){if(!t.fatal)switch(t.details){case _.BUFFER_ADD_CODEC_ERROR:case _.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case _.FRAG_LOAD_TIMEOUT:{const s=t.frag,{fragCurrent:i,partCurrent:r}=this;if(s&&i&&s.sn===i.sn&&s.level===i.level){const n=performance.now(),o=r?r.stats:s.stats,d=n-o.loading.start,l=o.loading.first?o.loading.first-o.loading.start:-1;if(o.loaded&&l>-1){const u=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(d-Math.min(u,l),o.loaded)}else this.bwEstimator.sampleTTFB(d)}break}}}getTimeToLoadFrag(e,t,s,i){const r=e+s/t,n=i?e+this.lastLevelLoadSec:0;return r+n}onLevelLoaded(e,t){const s=this.hls.config,{loading:i}=t.stats,r=i.end-i.first;K(r)&&(this.lastLevelLoadSec=r/1e3),t.details.live?this.bwEstimator.update(s.abrEwmaSlowLive,s.abrEwmaFastLive):this.bwEstimator.update(s.abrEwmaSlowVoD,s.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(t.levelInfo)}onFragLoaded(e,{frag:t,part:s}){const i=s?s.stats:t.stats;if(t.type===H.MAIN&&this.bwEstimator.sampleTTFB(i.loading.first-i.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){const r=s?s.duration:t.duration,n=this.hls.levels[t.level],o=(n.loaded?n.loaded.bytes:0)+i.loaded,d=(n.loaded?n.loaded.duration:0)+r;n.loaded={bytes:o,duration:d},n.realBitrate=Math.round(8*o/d)}if(t.bitrateTest){const r={stats:i,frag:t,part:s,id:t.type};this.onFragBuffered(y.FRAG_BUFFERED,r),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFragBuffered(e,t){const{frag:s,part:i}=t,r=i!=null&&i.stats.loaded?i.stats:s.stats;if(r.aborted||this.ignoreFragment(s))return;const n=r.parsing.end-r.loading.start-Math.min(r.loading.first-r.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(n,r.loaded),r.bwEstimate=this.getBwEstimate(),s.bitrateTest?this.bitrateTestDelay=n/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==H.MAIN||e.sn==="initSegment"}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){const{maxAutoLevel:e,minAutoLevel:t}=this.hls,s=this.getBwEstimate(),i=this.hls.config.maxStarvationDelay,r=this.findBestLevel(s,t,e,0,i,1,1);if(r>-1)return r;const n=this.hls.firstLevel,o=Math.min(Math.max(n,t),e);return this.warn("Could not find best starting auto level. Defaulting to first in playlist ".concat(n," clamped to ").concat(o)),o}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){const e=this.forcedAutoLevel,s=this.bwEstimator.canEstimate(),i=this.lastLoadedFragLevel>-1;if(e!==-1&&(!s||!i||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;const r=s&&i?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){const n=this.hls.levels;if(n.length>Math.max(e,r)&&n[e].loadError<=n[r].loadError)return e}return this._nextAutoLevel=r,this.nextAutoLevelKey=this.getAutoLevelKey(),r}getAutoLevelKey(){return"".concat(this.getBwEstimate(),"_").concat(this.getStarvationDelay().toFixed(2))}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:t,hls:s}=this;if(s.levels.length<=1)return s.loadLevel;const{maxAutoLevel:i,config:r,minAutoLevel:n}=s,o=t?t.duration:e?e.duration:0,d=this.getBwEstimate(),l=this.getStarvationDelay();let c=r.abrBandWidthFactor,u=r.abrBandWidthUpFactor;if(l){const p=this.findBestLevel(d,n,i,l,0,c,u);if(p>=0)return this.rebufferNotice=-1,p}let h=o?Math.min(o,r.maxStarvationDelay):r.maxStarvationDelay;if(!l){const p=this.bitrateTestDelay;p&&(h=(o?Math.min(o,r.maxLoadingDelay):r.maxLoadingDelay)-p,this.info("bitrate test took ".concat(Math.round(1e3*p),"ms, set first fragment max fetchDuration to ").concat(Math.round(1e3*h)," ms")),c=u=1)}const f=this.findBestLevel(d,n,i,l,h,c,u);if(this.rebufferNotice!==f&&(this.rebufferNotice=f,this.info("".concat(l?"rebuffering expected":"buffer is empty",", optimal quality level ").concat(f))),f>-1)return f;const g=s.levels[n],m=s.loadLevelObj;return m&&(g==null?void 0:g.bitrate)<m.bitrate?n:s.loadLevel}getStarvationDelay(){const e=this.hls,t=e.media;if(!t)return 1/0;const s=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,i=e.mainForwardBufferInfo;return(i?i.len:0)/s}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,s,i,r,n,o){var d;const l=i+r,c=this.lastLoadedFragLevel,u=c===-1?this.hls.firstLevel:c,{fragCurrent:h,partCurrent:f}=this,{levels:g,allAudioTracks:m,loadLevel:p,config:v}=this.hls;if(g.length===1)return 0;const E=g[u],T=!!((d=this.hls.latestLevelDetails)!=null&&d.live),S=p===-1||c===-1;let x,b="SDR",A=(E==null?void 0:E.frameRate)||0;const{audioPreference:I,videoPreference:R}=v,L=this.audioTracksByGroup||(this.audioTracksByGroup=Pn(m));let w=-1;if(S){if(this.firstSelection!==-1)return this.firstSelection;const M=this.codecTiers||(this.codecTiers=Qo(g,L,t,s)),C=Xo(M,b,e,I,R),{codecSet:k,videoRanges:O,minFramerate:G,minBitrate:F,minIndex:$,preferHDR:q}=C;w=$,x=k,b=q?O[O.length-1]:O[0],A=G,e=Math.max(e,F),this.log("picked start tier ".concat(ne(C)))}else x=E==null?void 0:E.codecSet,b=E==null?void 0:E.videoRange;const U=f?f.duration:h?h.duration:0,V=this.bwEstimator.getEstimateTTFB()/1e3,B=[];for(let M=s;M>=t;M--){var N;const C=g[M],k=M>u;if(!C)continue;if(v.useMediaCapabilities&&!C.supportedResult&&!C.supportedPromise){const Y=navigator.mediaCapabilities;typeof(Y==null?void 0:Y.decodingInfo)=="function"&&Uo(C,L,b,A,e,I)?(C.supportedPromise=kn(C,L,Y,this.supportedCache),C.supportedPromise.then(j=>{if(!this.hls)return;C.supportedResult=j;const oe=this.hls.levels,le=oe.indexOf(C);j.error?this.warn('MediaCapabilities decodingInfo error: "'.concat(j.error,'" for level ').concat(le," ").concat(ne(j))):j.supported?j.decodingInfoResults.some(ye=>ye.smooth===!1||ye.powerEfficient===!1)&&this.log("MediaCapabilities decodingInfo for level ".concat(le," not smooth or powerEfficient: ").concat(ne(j))):(this.warn("Unsupported MediaCapabilities decodingInfo result for level ".concat(le," ").concat(ne(j))),le>-1&&oe.length>1&&(this.log("Removing unsupported level ".concat(le)),this.hls.removeLevel(le),this.hls.loadLevel===-1&&(this.hls.nextLoadLevel=0)))}).catch(j=>{this.warn("Error handling MediaCapabilities decodingInfo: ".concat(j))})):C.supportedResult=Dn}if((x&&C.codecSet!==x||b&&C.videoRange!==b||k&&A>C.frameRate||!k&&A>0&&A<C.frameRate||(N=C.supportedResult)!=null&&(N=N.decodingInfoResults)!=null&&N.some(Y=>Y.smooth===!1))&&(!S||M!==w)){B.push(M);continue}const O=C.details,G=(f?O==null?void 0:O.partTarget:O==null?void 0:O.averagetargetduration)||U;let F;k?F=o*e:F=n*e;const $=U&&i>=U*2&&r===0?C.averageBitrate:C.maxBitrate,q=this.getTimeToLoadFrag(V,F,$*G,O===void 0);if(F>=$&&(M===c||C.loadError===0&&C.fragmentError===0)&&(q<=V||!K(q)||T&&!this.bitrateTestDelay||q<l)){const Y=this.forcedAutoLevel;return M!==p&&(Y===-1||Y!==p)&&(B.length&&this.trace("Skipped level(s) ".concat(B.join(",")," of ").concat(s,' max with CODECS and VIDEO-RANGE:"').concat(g[B[0]].codecs,'" ').concat(g[B[0]].videoRange,'; not compatible with "').concat(x,'" ').concat(b)),this.info("switch candidate:".concat(u,"->").concat(M," adjustedbw(").concat(Math.round(F),")-bitrate=").concat(Math.round(F-$)," ttfb:").concat(V.toFixed(1)," avgDuration:").concat(G.toFixed(1)," maxFetchDuration:").concat(l.toFixed(1)," fetchDuration:").concat(q.toFixed(1)," firstSelection:").concat(S," codecSet:").concat(C.codecSet," videoRange:").concat(C.videoRange," hls.loadLevel:").concat(p))),S&&(this.firstSelection=M),M}}return-1}set nextAutoLevel(e){const t=this.deriveNextAutoLevel(e);this._nextAutoLevel!==t&&(this.nextAutoLevelKey="",this._nextAutoLevel=t)}deriveNextAutoLevel(e){const{maxAutoLevel:t,minAutoLevel:s}=this.hls;return Math.min(Math.max(e,s),t)}}const wn={search:function(a,e){let t=0,s=a.length-1,i=null,r=null;for(;t<=s;){i=(t+s)/2|0,r=a[i];const n=e(r);if(n>0)t=i+1;else if(n<0)s=i-1;else return r}return null}};function sl(a,e,t){if(e===null||!Array.isArray(a)||!a.length||!K(e))return null;const s=a[0].programDateTime;if(e<(s||0))return null;const i=a[a.length-1].endProgramDateTime;if(e>=(i||0))return null;for(let r=0;r<a.length;++r){const n=a[r];if(rl(e,t,n))return n}return null}function lt(a,e,t=0,s=0,i=.005){let r=null;if(a){r=e[1+a.sn-e[0].sn]||null;const o=a.endDTS-t;o>0&&o<15e-7&&(t+=15e-7),r&&a.level!==r.level&&r.end<=a.end&&(r=e[2+a.sn-e[0].sn]||null)}else t===0&&e[0].start===0&&(r=e[0]);if(r&&((!a||a.level===r.level)&&hr(t,s,r)===0||il(r,a,Math.min(i,s))))return r;const n=wn.search(e,hr.bind(null,t,s));return n&&(n!==a||!r)?n:r}function il(a,e,t){if(e&&e.start===0&&e.level<a.level&&(e.endPTS||0)>0){const s=e.tagList.reduce((i,r)=>(r[0]==="INF"&&(i+=parseFloat(r[1])),i),t);return a.start<=s}return!1}function hr(a=0,e=0,t){if(t.start<=a&&t.start+t.duration>a)return 0;const s=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-s<=a?1:t.start-s>a&&t.start?-1:0}function rl(a,e,t){const s=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-s>a}function On(a,e,t){if(a&&a.startCC<=e&&a.endCC>=e){let s=a.fragments;const{fragmentHint:i}=a;i&&(s=s.concat(i));let r;return wn.search(s,n=>n.cc<e?1:n.cc>e?-1:(r=n,n.end<=t?1:n.start>t?-1:0)),r||null}return null}function vs(a){switch(a.details){case _.FRAG_LOAD_TIMEOUT:case _.KEY_LOAD_TIMEOUT:case _.LEVEL_LOAD_TIMEOUT:case _.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Mn(a){return a.details.startsWith("key")}function Fn(a){return Mn(a)&&!!a.frag&&!a.frag.decryptdata}function fr(a,e){const t=vs(e);return a.default["".concat(t?"timeout":"error","Retry")]}function Ai(a,e){const t=a.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*a.retryDelayMs,a.maxRetryDelayMs)}function gr(a){return te(te({},a),{errorRetry:null,timeoutRetry:null})}function Es(a,e,t,s){if(!a)return!1;const i=s==null?void 0:s.code,r=e<a.maxNumRetry&&(nl(i)||!!t);return a.shouldRetry?a.shouldRetry(a,e,t,s,r):r}function nl(a){return ii(a)||!!a&&(a<400||a>499)}function ii(a){return a===0&&navigator.onLine===!1}var pe={DoNothing:0,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,RetryRequest:5},be={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,MoveAllAlternatesMatchingKey:4};class al extends Pe{constructor(e){super("error-controller",e.logger),this.hls=void 0,this.playlistError=0,this.hls=e,this.registerListeners()}registerListeners(){const e=this.hls;e.on(y.ERROR,this.onError,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(y.ERROR,this.onError,this),e.off(y.ERROR,this.onErrorOut,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return(e==null?void 0:e.type)===H.MAIN?e.level:this.getVariantIndex()}getVariantIndex(){var e;const t=this.hls,s=t.currentLevel;return(e=t.loadLevelObj)!=null&&e.details||s===-1?t.loadLevel:s}variantHasKey(e,t){if(e){var s;if((s=e.details)!=null&&s.hasKey(t))return!0;const i=e.audioGroups;if(i)return this.hls.allAudioTracks.filter(n=>i.indexOf(n.groupId)>=0).some(n=>{var o;return(o=n.details)==null?void 0:o.hasKey(t)})}return!1}onManifestLoading(){this.playlistError=0}onLevelUpdated(){this.playlistError=0}onError(e,t){var s;if(t.fatal)return;const i=this.hls,r=t.context;switch(t.details){case _.FRAG_LOAD_ERROR:case _.FRAG_LOAD_TIMEOUT:case _.KEY_LOAD_ERROR:case _.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case _.FRAG_PARSING_ERROR:if((s=t.frag)!=null&&s.gap){t.errorAction=yt();return}case _.FRAG_GAP:case _.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=pe.SendAlternateToPenaltyBox;return}case _.LEVEL_EMPTY_ERROR:case _.LEVEL_PARSING_ERROR:{var n;const d=t.parent===H.MAIN?t.level:i.loadLevel;t.details===_.LEVEL_EMPTY_ERROR&&((n=t.context)!=null&&(n=n.levelDetails)!=null&&n.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,d):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,d))}return;case _.LEVEL_LOAD_ERROR:case _.LEVEL_LOAD_TIMEOUT:typeof(r==null?void 0:r.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,r.level));return;case _.AUDIO_TRACK_LOAD_ERROR:case _.AUDIO_TRACK_LOAD_TIMEOUT:case _.SUBTITLE_LOAD_ERROR:case _.SUBTITLE_TRACK_LOAD_TIMEOUT:if(r){const d=i.loadLevelObj;if(d&&(r.type===J.AUDIO_TRACK&&d.hasAudioGroup(r.groupId)||r.type===J.SUBTITLE_TRACK&&d.hasSubtitleGroup(r.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.loadLevel),t.errorAction.action=pe.SendAlternateToPenaltyBox,t.errorAction.flags=be.MoveAllAlternatesMatchingHost;return}}return;case _.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:t.errorAction={action:pe.SendAlternateToPenaltyBox,flags:be.MoveAllAlternatesMatchingHDCP};return;case _.KEY_SYSTEM_SESSION_UPDATE_FAILED:case _.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case _.KEY_SYSTEM_NO_SESSION:t.errorAction={action:pe.SendAlternateToPenaltyBox,flags:be.MoveAllAlternatesMatchingKey};return;case _.BUFFER_ADD_CODEC_ERROR:case _.REMUX_ALLOC_ERROR:case _.BUFFER_APPEND_ERROR:if(!t.errorAction){var o;t.errorAction=this.getLevelSwitchAction(t,(o=t.level)!=null?o:i.loadLevel)}return;case _.INTERNAL_EXCEPTION:case _.BUFFER_APPENDING_ERROR:case _.BUFFER_FULL_ERROR:case _.LEVEL_SWITCH_ERROR:case _.BUFFER_STALLED_ERROR:case _.BUFFER_SEEK_OVER_HOLE:case _.BUFFER_NUDGE_ON_STALL:t.errorAction=yt();return}t.type===W.KEY_SYSTEM_ERROR&&(t.levelRetry=!1,t.errorAction=yt())}getPlaylistRetryOrSwitchAction(e,t){const s=this.hls,i=fr(s.config.playlistLoadPolicy,e),r=this.playlistError++;if(Es(i,r,vs(e),e.response))return{action:pe.RetryRequest,flags:be.None,retryConfig:i,retryCount:r};const o=this.getLevelSwitchAction(e,t);return i&&(o.retryConfig=i,o.retryCount=r),o}getFragRetryOrSwitchAction(e){const t=this.hls,s=this.getVariantLevelIndex(e.frag),i=t.levels[s],{fragLoadPolicy:r,keyLoadPolicy:n}=t.config,o=fr(Mn(e)?n:r,e),d=t.levels.reduce((c,u)=>c+u.fragmentError,0);if(i&&(e.details!==_.FRAG_GAP&&i.fragmentError++,!Fn(e)&&Es(o,d,vs(e),e.response)))return{action:pe.RetryRequest,flags:be.None,retryConfig:o,retryCount:d};const l=this.getLevelSwitchAction(e,s);return o&&(l.retryConfig=o,l.retryCount=d),l}getLevelSwitchAction(e,t){const s=this.hls;t==null&&(t=s.loadLevel);const i=this.hls.levels[t];if(i){var r,n;const l=e.details;i.loadError++,l===_.BUFFER_APPEND_ERROR&&i.fragmentError++;let c=-1;const{levels:u,loadLevel:h,minAutoLevel:f,maxAutoLevel:g}=s;!s.autoLevelEnabled&&!s.config.preserveManualLevelOnError&&(s.loadLevel=-1);const m=(r=e.frag)==null?void 0:r.type,v=(m===H.AUDIO&&l===_.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(l===_.BUFFER_ADD_CODEC_ERROR||l===_.BUFFER_APPEND_ERROR))&&u.some(({audioCodec:b})=>i.audioCodec!==b),T=e.sourceBufferName==="video"&&(l===_.BUFFER_ADD_CODEC_ERROR||l===_.BUFFER_APPEND_ERROR)&&u.some(({codecSet:b,audioCodec:A})=>i.codecSet!==b&&i.audioCodec===A),{type:S,groupId:x}=(n=e.context)!=null?n:{};for(let b=u.length;b--;){const A=(b+h)%u.length;if(A!==h&&A>=f&&A<=g&&u[A].loadError===0){var o,d;const I=u[A];if(l===_.FRAG_GAP&&m===H.MAIN&&e.frag){const R=u[A].details;if(R){const L=lt(e.frag,R.fragments,e.frag.start);if(L!=null&&L.gap)continue}}else{if(S===J.AUDIO_TRACK&&I.hasAudioGroup(x)||S===J.SUBTITLE_TRACK&&I.hasSubtitleGroup(x))continue;if(m===H.AUDIO&&(o=i.audioGroups)!=null&&o.some(R=>I.hasAudioGroup(R))||m===H.SUBTITLE&&(d=i.subtitleGroups)!=null&&d.some(R=>I.hasSubtitleGroup(R))||v&&i.audioCodec===I.audioCodec||T&&i.codecSet===I.codecSet||!v&&i.codecSet!==I.codecSet)continue}c=A;break}}if(c>-1&&s.loadLevel!==c)return e.levelRetry=!0,this.playlistError=0,{action:pe.SendAlternateToPenaltyBox,flags:be.None,nextAutoLevel:c}}return{action:pe.SendAlternateToPenaltyBox,flags:be.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var s;switch((s=t.errorAction)==null?void 0:s.action){case pe.DoNothing:break;case pe.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==_.FRAG_GAP?t.fatal=!0:/MediaSource readyState: ended/.test(t.error.message)&&(this.warn('MediaSource ended after "'.concat(t.sourceBufferName,'" sourceBuffer append error. Attempting to recover from media error.')),this.hls.recoverMediaError());break}if(t.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){const t=this.hls,s=e.errorAction;if(!s)return;const{flags:i}=s,r=s.nextAutoLevel;switch(i){case be.None:this.switchLevel(e,r);break;case be.MoveAllAlternatesMatchingHDCP:{const d=this.getVariantLevelIndex(e.frag),l=t.levels[d],c=l==null?void 0:l.attrs["HDCP-LEVEL"];if(s.hdcpLevel=c,c==="NONE")this.warn("HDCP policy resticted output with HDCP-LEVEL=NONE");else if(c){t.maxHdcpLevel=si[si.indexOf(c)-1],s.resolved=!0,this.warn('Restricting playback to HDCP-LEVEL of "'.concat(t.maxHdcpLevel,'" or lower'));break}}case be.MoveAllAlternatesMatchingKey:{const d=e.decryptdata;if(d){const l=this.hls.levels,c=l.length;for(let h=c;h--;)if(this.variantHasKey(l[h],d)){var n,o;this.log("Banned key found in level ".concat(h," (").concat(l[h].bitrate,'bps) or audio group "').concat((n=l[h].audioGroups)==null?void 0:n.join(","),'" (').concat((o=e.frag)==null?void 0:o.type," fragment) ").concat(Ae(d.keyId||[]))),l[h].fragmentError++,l[h].loadError++,this.log("Removing level ".concat(h," with key error (").concat(e.error,")")),this.hls.removeLevel(h)}const u=e.frag;if(this.hls.levels.length<c)s.resolved=!0;else if(u&&u.type!==H.MAIN){const h=u.decryptdata;h&&!d.matches(h)&&(s.resolved=!0)}}break}}s.resolved||this.switchLevel(e,r)}switchLevel(e,t){if(t!==void 0&&e.errorAction&&(this.warn("switching to level ".concat(t," after ").concat(e.details)),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel,e.details===_.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&e.sourceBufferName!=="audiovideo")){const s=ti(e.mimeType),i=this.hls.levels;for(let r=i.length;r--;)i[r]["".concat(e.sourceBufferName,"Codec")]===s&&(this.log("Removing level ".concat(r," for ").concat(e.details,' ("').concat(s,'" not supported)')),this.hls.removeLevel(r))}}}function yt(a){const e={action:pe.DoNothing,flags:be.None};return a&&(e.resolved=!0),e}var ge={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class ol{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){const{hls:e}=this;e&&(e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.BUFFER_APPENDED,this.onBufferAppended,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this),e.on(y.FRAG_LOADED,this.onFragLoaded,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.BUFFER_APPENDED,this.onBufferAppended,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this),e.off(y.FRAG_LOADED,this.onFragLoaded,this))}destroy(){this._unregisterListeners(),this.hls=this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){const s=this.activePartLists[t];if(s)for(let i=s.length;i--;){const r=s[i];if(!r)break;if(r.start<=e&&e<=r.end&&r.loaded)return r}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){return this.getFragAtPos(e,t,!0)}getFragAtPos(e,t,s){const{fragments:i}=this,r=Object.keys(i);for(let n=r.length;n--;){const o=i[r[n]];if((o==null?void 0:o.body.type)===t&&(!s||o.buffered)){const d=o.body;if(d.start<=e&&e<=d.end)return d}}return null}detectEvictedFragments(e,t,s,i,r){this.timeRanges&&(this.timeRanges[e]=t);const n=(i==null?void 0:i.fragment.sn)||-1;Object.keys(this.fragments).forEach(o=>{const d=this.fragments[o];if(!d||n>=d.body.sn)return;if(!d.buffered&&(!d.loaded||r)){d.body.type===s&&this.removeFragment(d.body);return}const l=d.range[e];if(l){if(l.time.length===0){this.removeFragment(d.body);return}l.time.some(c=>{const u=!this.isTimeBuffered(c.startPTS,c.endPTS,t);return u&&this.removeFragment(d.body),u})}})}detectPartialFragments(e){const t=this.timeRanges;if(!t||e.frag.sn==="initSegment")return;const s=e.frag,i=ht(s),r=this.fragments[i];if(!r||r.buffered&&s.gap)return;const n=!s.relurl;Object.keys(t).forEach(o=>{const d=s.elementaryStreams[o];if(!d)return;const l=t[o],c=n||d.partial===!0;r.range[o]=this.getBufferedTimes(s,e.part,c,l)}),r.loaded=null,Object.keys(r.range).length?(r.buffered=!0,(r.body.endList=s.endList||r.body.endList)&&(this.endListFragments[r.body.type]=r),Wt(r)||this.removeParts(s.sn-1,s.type)):this.removeFragment(r.body)}removeParts(e,t){const s=this.activePartLists[t];s&&(this.activePartLists[t]=mr(s,i=>i.fragment.sn>=e))}fragBuffered(e,t){const s=ht(e);let i=this.fragments[s];!i&&t&&(i=this.fragments[s]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,i.buffered=!0)}getBufferedTimes(e,t,s,i){const r={time:[],partial:s},n=e.start,o=e.end,d=e.minEndPTS||o,l=e.maxStartPTS||n;for(let c=0;c<i.length;c++){const u=i.start(c)-this.bufferPadding,h=i.end(c)+this.bufferPadding;if(l>=u&&d<=h){r.time.push({startPTS:Math.max(n,i.start(c)),endPTS:Math.min(o,i.end(c))});break}else if(n<h&&o>u){const f=Math.max(n,i.start(c)),g=Math.min(o,i.end(c));g>f&&(r.partial=!0,r.time.push({startPTS:f,endPTS:g}))}else if(o<=u)break}return r}getPartialFragment(e){let t=null,s,i,r,n=0;const{bufferPadding:o,fragments:d}=this;return Object.keys(d).forEach(l=>{const c=d[l];c&&Wt(c)&&(i=c.body.start-o,r=c.body.end+o,e>=i&&e<=r&&(s=Math.min(e-i,r-e),n<=s&&(t=c.body,n=s)))}),t}isEndListAppended(e){const t=this.endListFragments[e];return t!==void 0&&(t.buffered||Wt(t))}getState(e){const t=ht(e),s=this.fragments[t];return s?s.buffered?Wt(s)?ge.PARTIAL:ge.OK:ge.APPENDING:ge.NOT_LOADED}isTimeBuffered(e,t,s){let i,r;for(let n=0;n<s.length;n++){if(i=s.start(n)-this.bufferPadding,r=s.end(n)+this.bufferPadding,e>=i&&t<=r)return!0;if(t<=i)return!1}return!1}onManifestLoading(){this.removeAllFragments()}onFragLoaded(e,t){if(t.frag.sn==="initSegment"||t.frag.bitrateTest)return;const s=t.frag,i=t.part?null:t,r=ht(s);this.fragments[r]={body:s,appendedPTS:null,loaded:i,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:s,part:i,timeRanges:r,type:n}=t;if(s.sn==="initSegment")return;const o=s.type;if(i){let l=this.activePartLists[o];l||(this.activePartLists[o]=l=[]),l.push(i)}this.timeRanges=r;const d=r[n];this.detectEvictedFragments(n,d,o,i)}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=ht(e);return!!this.fragments[t]}hasFragments(e){const{fragments:t}=this,s=Object.keys(t);if(!e)return s.length>0;for(let i=s.length;i--;){const r=t[s[i]];if((r==null?void 0:r.body.type)===e)return!0}return!1}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,s,i,r){i&&!this.hasGaps||Object.keys(this.fragments).forEach(n=>{const o=this.fragments[n];if(!o)return;const d=o.body;d.type!==s||i&&!d.gap||d.start<t&&d.end>e&&(o.buffered||r)&&this.removeFragment(d)})}removeFragment(e){const t=ht(e);e.clearElementaryStreamInfo();const s=this.activePartLists[e.type];if(s){const i=e.sn;this.activePartLists[e.type]=mr(s,r=>r.fragment.sn!==i)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){var e;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;const t=(e=this.hls)==null||(e=e.latestLevelDetails)==null?void 0:e.partList;t&&t.forEach(s=>s.clearElementaryStreamInfo())}}function Wt(a){var e,t,s;return a.buffered&&!!(a.body.gap||(e=a.range.video)!=null&&e.partial||(t=a.range.audio)!=null&&t.partial||(s=a.range.audiovideo)!=null&&s.partial)}function ht(a){return"".concat(a.type,"_").concat(a.level,"_").concat(a.sn)}function mr(a,e){return a.filter(t=>{const s=e(t);return s||t.clearElementaryStreamInfo(),s})}var et={cbc:0,ctr:1};class ll{constructor(e,t,s){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=e,this.aesIV=t,this.aesMode=s}decrypt(e,t){switch(this.aesMode){case et.cbc:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case et.ctr:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error("[AESCrypto] invalid aes mode ".concat(this.aesMode))}}}function dl(a){const e=a.byteLength,t=e&&new DataView(a.buffer).getUint8(e-1);return t?a.slice(0,e-t):a}class cl{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(e){const t=new DataView(e),s=new Uint32Array(4);for(let i=0;i<4;i++)s[i]=t.getUint32(i*4);return s}initTable(){const e=this.sBox,t=this.invSBox,s=this.subMix,i=s[0],r=s[1],n=s[2],o=s[3],d=this.invSubMix,l=d[0],c=d[1],u=d[2],h=d[3],f=new Uint32Array(256);let g=0,m=0,p=0;for(p=0;p<256;p++)p<128?f[p]=p<<1:f[p]=p<<1^283;for(p=0;p<256;p++){let v=m^m<<1^m<<2^m<<3^m<<4;v=v>>>8^v&255^99,e[g]=v,t[v]=g;const E=f[g],T=f[E],S=f[T];let x=f[v]*257^v*16843008;i[g]=x<<24|x>>>8,r[g]=x<<16|x>>>16,n[g]=x<<8|x>>>24,o[g]=x,x=S*16843009^T*65537^E*257^g*16843008,l[v]=x<<24|x>>>8,c[v]=x<<16|x>>>16,u[v]=x<<8|x>>>24,h[v]=x,g?(g=E^f[f[f[S^E]]],m^=f[f[m]]):g=m=1}}expandKey(e){const t=this.uint8ArrayToUint32Array_(e);let s=!0,i=0;for(;i<t.length&&s;)s=t[i]===this.key[i],i++;if(s)return;this.key=t;const r=this.keySize=t.length;if(r!==4&&r!==6&&r!==8)throw new Error("Invalid aes key size="+r);const n=this.ksRows=(r+6+1)*4;let o,d;const l=this.keySchedule=new Uint32Array(n),c=this.invKeySchedule=new Uint32Array(n),u=this.sBox,h=this.rcon,f=this.invSubMix,g=f[0],m=f[1],p=f[2],v=f[3];let E,T;for(o=0;o<n;o++){if(o<r){E=l[o]=t[o];continue}T=E,o%r===0?(T=T<<8|T>>>24,T=u[T>>>24]<<24|u[T>>>16&255]<<16|u[T>>>8&255]<<8|u[T&255],T^=h[o/r|0]<<24):r>6&&o%r===4&&(T=u[T>>>24]<<24|u[T>>>16&255]<<16|u[T>>>8&255]<<8|u[T&255]),l[o]=E=(l[o-r]^T)>>>0}for(d=0;d<n;d++)o=n-d,d&3?T=l[o]:T=l[o-4],d<4||o<=4?c[d]=T:c[d]=g[u[T>>>24]]^m[u[T>>>16&255]]^p[u[T>>>8&255]]^v[u[T&255]],c[d]=c[d]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,s){const i=this.keySize+6,r=this.invKeySchedule,n=this.invSBox,o=this.invSubMix,d=o[0],l=o[1],c=o[2],u=o[3],h=this.uint8ArrayToUint32Array_(s);let f=h[0],g=h[1],m=h[2],p=h[3];const v=new Int32Array(e),E=new Int32Array(v.length);let T,S,x,b,A,I,R,L,w,U,V,B,N,M;const C=this.networkToHostOrderSwap;for(;t<v.length;){for(w=C(v[t]),U=C(v[t+1]),V=C(v[t+2]),B=C(v[t+3]),A=w^r[0],I=B^r[1],R=V^r[2],L=U^r[3],N=4,M=1;M<i;M++)T=d[A>>>24]^l[I>>16&255]^c[R>>8&255]^u[L&255]^r[N],S=d[I>>>24]^l[R>>16&255]^c[L>>8&255]^u[A&255]^r[N+1],x=d[R>>>24]^l[L>>16&255]^c[A>>8&255]^u[I&255]^r[N+2],b=d[L>>>24]^l[A>>16&255]^c[I>>8&255]^u[R&255]^r[N+3],A=T,I=S,R=x,L=b,N=N+4;T=n[A>>>24]<<24^n[I>>16&255]<<16^n[R>>8&255]<<8^n[L&255]^r[N],S=n[I>>>24]<<24^n[R>>16&255]<<16^n[L>>8&255]<<8^n[A&255]^r[N+1],x=n[R>>>24]<<24^n[L>>16&255]<<16^n[A>>8&255]<<8^n[I&255]^r[N+2],b=n[L>>>24]<<24^n[A>>16&255]<<16^n[I>>8&255]<<8^n[R&255]^r[N+3],E[t]=C(T^f),E[t+1]=C(b^g),E[t+2]=C(x^m),E[t+3]=C(S^p),f=w,g=U,m=V,p=B,t=t+4}return E.buffer}}class ul{constructor(e,t,s){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=e,this.key=t,this.aesMode=s}expandKey(){const e=hl(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}}function hl(a){switch(a){case et.cbc:return"AES-CBC";case et.ctr:return"AES-CTR";default:throw new Error("[FastAESKey] invalid aes mode ".concat(a))}}const fl=16;class Li{constructor(e,{removePKCS7Padding:t=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.enableSoftwareAES=void 0,this.enableSoftwareAES=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{const s=self.crypto;s&&(this.subtle=s.subtle||s.webkitSubtle)}catch(s){}this.useSoftware=!this.subtle}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){const{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;const s=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?dl(s):s}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,s,i){return this.useSoftware?new Promise((r,n)=>{const o=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.softwareDecrypt(o,t,s,i);const d=this.flush();d?r(d.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,s,i)}softwareDecrypt(e,t,s,i){const{currentIV:r,currentResult:n,remainderData:o}=this;if(i!==et.cbc||t.byteLength!==16)return se.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),o&&(e=Ce(o,e),this.remainderData=null);const d=this.getValidChunk(e);if(!d.length)return null;r&&(s=r);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new cl),l.expandKey(t);const c=n;return this.currentResult=l.decrypt(d.buffer,0,s),this.currentIV=d.slice(-16).buffer,c||null}webCryptoDecrypt(e,t,s,i){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,s,i));this.key=t,this.fastAesKey=new ul(this.subtle,t,i)}return this.fastAesKey.expandKey().then(r=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new ll(this.subtle,new Uint8Array(s),i).decrypt(e.buffer,r)):Promise.reject(new Error("web crypto not initialized"))).catch(r=>(se.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, ".concat(r.name,": ").concat(r.message)),this.onWebCryptoError(e,t,s,i)))}onWebCryptoError(e,t,s,i){const r=this.enableSoftwareAES;if(r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,s,i);const n=this.flush();if(n)return n.buffer}throw new Error("WebCrypto"+(r?" and softwareDecrypt":"")+": failed to decrypt data")}getValidChunk(e){let t=e;const s=e.length-e.length%fl;return s!==e.length&&(t=e.slice(0,s),this.remainderData=e.slice(s)),t}logOnce(e){this.logEnabled&&(se.log("[decrypter]: ".concat(e)),this.logEnabled=!1)}}const pr=Math.pow(2,17);class gl{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){const s=e.url;if(!s)return Promise.reject(new qe({type:W.NETWORK_ERROR,details:_.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a ".concat(s?"part list":"url")),networkDetails:null}));this.abort();const i=this.config,r=i.fLoader,n=i.loader;return new Promise((o,d)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(g=>g[0]==="GAP")){d(vr(e));return}else e.gap=!1;const l=this.loader=r?new r(i):new n(i),c=yr(e);e.loader=l;const u=gr(i.fragLoadPolicy.default),h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:pr};e.stats=l.stats;const f={onSuccess:(g,m,p,v)=>{this.resetLoader(e,l);let E=g.data;p.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(E.slice(0,16)),E=E.slice(16)),o({frag:e,part:null,payload:E,networkDetails:v})},onError:(g,m,p,v)=>{this.resetLoader(e,l),d(new qe({type:W.NETWORK_ERROR,details:_.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:te({url:s,data:void 0},g),error:new Error("HTTP Error ".concat(g.code," ").concat(g.text)),networkDetails:p,stats:v}))},onAbort:(g,m,p)=>{this.resetLoader(e,l),d(new qe({type:W.NETWORK_ERROR,details:_.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:p,stats:g}))},onTimeout:(g,m,p)=>{this.resetLoader(e,l),d(new qe({type:W.NETWORK_ERROR,details:_.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error("Timeout after ".concat(h.timeout,"ms")),networkDetails:p,stats:g}))}};t&&(f.onProgress=(g,m,p,v)=>t({frag:e,part:null,payload:p,networkDetails:v})),l.load(c,h,f)})}loadPart(e,t,s){this.abort();const i=this.config,r=i.fLoader,n=i.loader;return new Promise((o,d)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){d(vr(e,t));return}const l=this.loader=r?new r(i):new n(i),c=yr(e,t);e.loader=l;const u=gr(i.fragLoadPolicy.default),h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:pr};t.stats=l.stats,l.load(c,h,{onSuccess:(f,g,m,p)=>{this.resetLoader(e,l),this.updateStatsFromPart(e,t);const v={frag:e,part:t,payload:f.data,networkDetails:p};s(v),o(v)},onError:(f,g,m,p)=>{this.resetLoader(e,l),d(new qe({type:W.NETWORK_ERROR,details:_.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:te({url:c.url,data:void 0},f),error:new Error("HTTP Error ".concat(f.code," ").concat(f.text)),networkDetails:m,stats:p}))},onAbort:(f,g,m)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,l),d(new qe({type:W.NETWORK_ERROR,details:_.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:m,stats:f}))},onTimeout:(f,g,m)=>{this.resetLoader(e,l),d(new qe({type:W.NETWORK_ERROR,details:_.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error("Timeout after ".concat(h.timeout,"ms")),networkDetails:m,stats:f}))}})})}updateStatsFromPart(e,t){const s=e.stats,i=t.stats,r=i.total;if(s.loaded+=i.loaded,r){const d=Math.round(e.duration/t.duration),l=Math.min(Math.round(s.loaded/r),d),u=(d-l)*Math.round(s.loaded/l);s.total=s.loaded+u}else s.total=Math.max(s.loaded,s.total);const n=s.loading,o=i.loading;n.start?n.first+=o.first-o.start:(n.start=o.start,n.first=o.first),n.end=o.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function yr(a,e=null){const t=e||a,s={frag:a,part:e,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},i=t.byteRangeStartOffset,r=t.byteRangeEndOffset;if(K(i)&&K(r)){var n;let o=i,d=r;if(a.sn==="initSegment"&&ml((n=a.decryptdata)==null?void 0:n.method)){const l=r-i;l%16&&(d=r+(16-l%16)),i!==0&&(s.resetIV=!0,o=i-16)}s.rangeStart=o,s.rangeEnd=d}return s}function vr(a,e){const t=new Error("GAP ".concat(a.gap?"tag":"attribute"," found")),s={type:W.MEDIA_ERROR,details:_.FRAG_GAP,fatal:!1,frag:a,error:t,networkDetails:null};return e&&(s.part=e),(e||a).stats.aborted=!0,new qe(s)}function ml(a){return a==="AES-128"||a==="AES-256"}class qe extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class $n extends Pe{constructor(e,t){super(e,t),this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}class Ii{constructor(e,t,s,i=0,r=-1,n=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=Yt(),this.buffering={audio:Yt(),video:Yt(),audiovideo:Yt()},this.level=e,this.sn=t,this.id=s,this.size=i,this.part=r,this.partial=n}}function Yt(){return{start:0,executeStart:0,executeEnd:0,end:0}}const Er={length:0,start:()=>0,end:()=>0};class X{static isBuffered(e,t){if(e){const s=X.getBuffered(e);for(let i=s.length;i--;)if(t>=s.start(i)&&t<=s.end(i))return!0}return!1}static bufferedRanges(e){if(e){const t=X.getBuffered(e);return X.timeRangesToArray(t)}return[]}static timeRangesToArray(e){const t=[];for(let s=0;s<e.length;s++)t.push({start:e.start(s),end:e.end(s)});return t}static bufferInfo(e,t,s){if(e){const i=X.bufferedRanges(e);if(i.length)return X.bufferedInfo(i,t,s)}return{len:0,start:t,end:t,bufferedIndex:-1}}static bufferedInfo(e,t,s){t=Math.max(0,t),e.length>1&&e.sort((c,u)=>c.start-u.start||u.end-c.end);let i=-1,r=[];if(s)for(let c=0;c<e.length;c++){t>=e[c].start&&t<=e[c].end&&(i=c);const u=r.length;if(u){const h=r[u-1].end;e[c].start-h<s?e[c].end>h&&(r[u-1].end=e[c].end):r.push(e[c])}else r.push(e[c])}else r=e;let n=0,o,d=t,l=t;for(let c=0;c<r.length;c++){const u=r[c].start,h=r[c].end;if(i===-1&&t>=u&&t<=h&&(i=c),t+s>=u&&t<h)d=u,l=h,n=l-t;else if(t+s<u){o=u;break}}return{len:n,start:d||0,end:l||0,nextStart:o,buffered:e,bufferedIndex:i}}static getBuffered(e){try{return e.buffered||Er}catch(t){return se.log("failed to get media.buffered",t),Er}}}const Nn=/\{\$([a-zA-Z0-9-_]+)\}/g;function Tr(a){return Nn.test(a)}function ri(a,e){if(a.variableList!==null||a.hasVariableRefs){const t=a.variableList;return e.replace(Nn,s=>{const i=s.substring(2,s.length-1),r=t==null?void 0:t[i];return r===void 0?(a.playlistParsingError||(a.playlistParsingError=new Error('Missing preceding EXT-X-DEFINE tag for Variable Reference: "'.concat(i,'"'))),s):r})}return e}function Sr(a,e,t){let s=a.variableList;s||(a.variableList=s={});let i,r;if("QUERYPARAM"in e){i=e.QUERYPARAM;try{const n=new self.URL(t).searchParams;if(n.has(i))r=n.get(i);else throw new Error('"'.concat(i,'" does not match any query parameter in URI: "').concat(t,'"'))}catch(n){a.playlistParsingError||(a.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: ".concat(n.message)))}}else i=e.NAME,r=e.VALUE;i in s?a.playlistParsingError||(a.playlistParsingError=new Error('EXT-X-DEFINE duplicate Variable Name declarations: "'.concat(i,'"'))):s[i]=r||""}function pl(a,e,t){const s=e.IMPORT;if(t&&s in t){let i=a.variableList;i||(a.variableList=i={}),i[s]=t[s]}else a.playlistParsingError||(a.playlistParsingError=new Error('EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "'.concat(s,'"')))}const yl=/^(\d+)x(\d+)$/,xr=/(.+?)=(".*?"|.*?)(?:,|$)/g;class de{constructor(e,t){typeof e=="string"&&(e=de.parseAttrList(e,t)),ie(this,e)}get clientAttrs(){return Object.keys(this).filter(e=>e.substring(0,2)==="X-")}decimalInteger(e){const t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;const s=new Uint8Array(t.length/2);for(let i=0;i<t.length/2;i++)s[i]=parseInt(t.slice(i*2,i*2+2),16);return s}return null}hexadecimalIntegerAsNumber(e){const t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){const s=this[e];return s?parseFloat(s):t}enumeratedString(e){return this[e]}enumeratedStringList(e,t){const s=this[e];return(s?s.split(/[ ,]+/):[]).reduce((i,r)=>(i[r.toLowerCase()]=!0,i),t)}bool(e){return this[e]==="YES"}decimalResolution(e){const t=yl.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e,t){let s;const i={};for(xr.lastIndex=0;(s=xr.exec(e))!==null;){const n=s[1].trim();let o=s[2];const d=o.indexOf('"')===0&&o.lastIndexOf('"')===o.length-1;let l=!1;if(d)o=o.slice(1,-1);else switch(n){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":l=!0}if(t&&(d||l))o=ri(t,o);else if(!l&&!d)switch(n){case"CLOSED-CAPTIONS":if(o==="NONE")break;case"ALLOWED-CPC":case"CLASS":case"ASSOC-LANGUAGE":case"AUDIO":case"BYTERANGE":case"CHANNELS":case"CHARACTERISTICS":case"CODECS":case"DATA-ID":case"END-DATE":case"GROUP-ID":case"ID":case"IMPORT":case"INSTREAM-ID":case"KEYFORMAT":case"KEYFORMATVERSIONS":case"LANGUAGE":case"NAME":case"PATHWAY-ID":case"QUERYPARAM":case"RECENTLY-REMOVED-DATERANGES":case"SERVER-URI":case"STABLE-RENDITION-ID":case"STABLE-VARIANT-ID":case"START-DATE":case"SUBTITLES":case"SUPPLEMENTAL-CODECS":case"URI":case"VALUE":case"VIDEO":case"X-ASSET-LIST":case"X-ASSET-URI":se.warn("".concat(e,": attribute ").concat(n," is missing quotes"))}i[n]=o}return i}}const vl="com.apple.hls.interstitial";function El(a){return a!=="ID"&&a!=="CLASS"&&a!=="CUE"&&a!=="START-DATE"&&a!=="DURATION"&&a!=="END-DATE"&&a!=="END-ON-NEXT"}function Tl(a){return a==="SCTE35-OUT"||a==="SCTE35-IN"||a==="SCTE35-CMD"}class Bn{constructor(e,t,s=0){var i;if(this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=(t==null?void 0:t.tagAnchor)||null,this.tagOrder=(i=t==null?void 0:t.tagOrder)!=null?i:s,t){const r=t.attr;for(const n in r)if(Object.prototype.hasOwnProperty.call(e,n)&&e[n]!==r[n]){se.warn('DATERANGE tag attribute: "'.concat(n,'" does not match for tags with ID: "').concat(e.ID,'"')),this._badValueForSameId=n;break}e=ie(new de({}),r,e)}if(this.attr=e,t?(this._startDate=t._startDate,this._cue=t._cue,this._endDate=t._endDate,this._dateAtEnd=t._dateAtEnd):this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const r=(t==null?void 0:t.endDate)||new Date(this.attr["END-DATE"]);K(r.getTime())&&(this._endDate=r)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get cue(){const e=this._cue;return e===void 0?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):e}get startTime(){const{tagAnchor:e}=this;return e===null||e.programDateTime===null?(se.warn('Expected tagAnchor Fragment with PDT set for DateRange "'.concat(this.id,'": ').concat(e)),NaN):e.start+(this.startDate.getTime()-e.programDateTime)/1e3}get startDate(){return this._startDate}get endDate(){const e=this._endDate||this._dateAtEnd;if(e)return e;const t=this.duration;return t!==null?this._dateAtEnd=new Date(this._startDate.getTime()+t*1e3):null}get duration(){if("DURATION"in this.attr){const e=this.attr.decimalFloatingPoint("DURATION");if(K(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isInterstitial(){return this.class===vl}get isValid(){return!!this.id&&!this._badValueForSameId&&K(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)&&(!this.attr.CUE||!this.cue.pre&&!this.cue.post||this.cue.pre!==this.cue.post)&&(!this.isInterstitial||"X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)}}const Sl=10;class xl{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.dateRangeTagCount=0,this.live=!0,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}const t=this.lastPartSn-e.lastPartSn,s=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!s||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&s>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1}hasKey(e){return this.encryptedFragments.some(t=>{let s=t.decryptdata;return s||(t.setKeyFormat(e.keyFormat),s=t.decryptdata),!!s&&e.matches(s)})}get hasProgramDateTime(){return this.fragments.length?K(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||Sl}get drift(){const e=this.driftEndTime-this.driftStartTime;return e>0?(this.driftEnd-this.driftStart)*1e3/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){return this.fragments.length?this.fragments[this.fragments.length-1].end:0}get fragmentStart(){return this.fragments.length?this.fragments[0].start:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}get maxPartIndex(){const e=this.partList;if(e){const t=this.lastPartIndex;if(t!==-1){for(let s=e.length;s--;)if(e[s].index>t)return e[s].index;return t}}return 0}get lastPartSn(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}get expired(){if(this.live&&this.age&&this.misses<3){const e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return!1}}function bi(a,e){return a.length===e.length?!a.some((t,s)=>t!==e[s]):!1}function Ar(a,e){return!a&&!e?!0:!a||!e?!1:bi(a,e)}function vt(a){return a==="AES-128"||a==="AES-256"||a==="AES-256-CTR"}function Ri(a){switch(a){case"AES-128":case"AES-256":return et.cbc;case"AES-256-CTR":return et.ctr;default:throw new Error("invalid full segment method ".concat(a))}}function Di(a){return Uint8Array.from(atob(a),e=>e.charCodeAt(0))}function ni(a){return Uint8Array.from(unescape(encodeURIComponent(a)),e=>e.charCodeAt(0))}function Al(a){const e=ni(a).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function Un(a){const e=function(s,i,r){const n=s[i];s[i]=s[r],s[r]=n};e(a,0,3),e(a,1,2),e(a,4,5),e(a,6,7)}function Ll(a){const e=a.split(":");let t=null;if(e[0]==="data"&&e.length===2){const s=e[1].split(";"),i=s[s.length-1].split(",");if(i.length===2){const r=i[0]==="base64",n=i[1];r?(s.splice(-1,1),t=Di(n)):t=Al(n)}}return t}const Ts=typeof self<"u"?self:void 0;var ce={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Ee={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function os(a){switch(a){case Ee.FAIRPLAY:return ce.FAIRPLAY;case Ee.PLAYREADY:return ce.PLAYREADY;case Ee.WIDEVINE:return ce.WIDEVINE;case Ee.CLEARKEY:return ce.CLEARKEY}}function ws(a){switch(a){case ce.FAIRPLAY:return Ee.FAIRPLAY;case ce.PLAYREADY:return Ee.PLAYREADY;case ce.WIDEVINE:return Ee.WIDEVINE;case ce.CLEARKEY:return Ee.CLEARKEY}}function _t(a){const{drmSystems:e,widevineLicenseUrl:t}=a,s=e?[ce.FAIRPLAY,ce.WIDEVINE,ce.PLAYREADY,ce.CLEARKEY].filter(i=>!!e[i]):[];return!s[ce.WIDEVINE]&&t&&s.push(ce.WIDEVINE),s}const Gn=(function(a){return Ts!=null&&(a=Ts.navigator)!=null&&a.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null})();function Il(a,e,t,s){let i;switch(a){case ce.FAIRPLAY:i=["cenc","sinf"];break;case ce.WIDEVINE:case ce.PLAYREADY:i=["cenc"];break;case ce.CLEARKEY:i=["cenc","keyids"];break;default:throw new Error("Unknown key-system: ".concat(a))}return bl(i,e,t,s)}function bl(a,e,t,s){return[{initDataTypes:a,persistentState:s.persistentState||"optional",distinctiveIdentifier:s.distinctiveIdentifier||"optional",sessionTypes:s.sessionTypes||[s.sessionType||"temporary"],audioCapabilities:e.map(r=>({contentType:"audio/mp4; codecs=".concat(r),robustness:s.audioRobustness||"",encryptionScheme:s.audioEncryptionScheme||null})),videoCapabilities:t.map(r=>({contentType:"video/mp4; codecs=".concat(r),robustness:s.videoRobustness||"",encryptionScheme:s.videoEncryptionScheme||null}))}]}function Rl(a){var e;return!!a&&(a.sessionType==="persistent-license"||!!((e=a.sessionTypes)!=null&&e.some(t=>t==="persistent-license")))}function Dl(a){const e=new Uint16Array(a.buffer,a.byteOffset,a.byteLength/2),t=String.fromCharCode.apply(null,Array.from(e)),s=t.substring(t.indexOf("<"),t.length),n=new DOMParser().parseFromString(s,"text/xml").getElementsByTagName("KID")[0];if(n){const o=n.childNodes[0]?n.childNodes[0].nodeValue:n.getAttribute("VALUE");if(o){const d=Di(o).subarray(0,16);return Un(d),d}}return null}let qt={};class Ft{static clearKeyUriToKeyIdMap(){qt={}}static setKeyIdForUri(e,t){qt[e]=t}constructor(e,t,s,i=[1],r=null,n){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=s,this.keyFormatVersions=i,this.iv=r,this.encrypted=e?e!=="NONE":!1,this.isCommonEncryption=this.encrypted&&!vt(e),n!=null&&n.startsWith("0x")&&(this.keyId=new Uint8Array(vn(n)))}matches(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&bi(e.keyFormatVersions,this.keyFormatVersions)&&Ar(e.iv,this.iv)&&Ar(e.keyId,this.keyId)}isSupported(){if(this.method){if(vt(this.method)||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case Ee.FAIRPLAY:case Ee.WIDEVINE:case Ee.PLAYREADY:case Ee.CLEARKEY:return["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if(vt(this.method)){let i=this.iv;return i||(typeof e!="number"&&(se.warn('missing IV for initialization segment with method="'.concat(this.method,'" - compliance issue')),e=0),i=_l(e)),new Ft(this.method,this.uri,"identity",this.keyFormatVersions,i)}if(this.pssh&&this.keyId)return this;const t=Ll(this.uri);if(t)switch(this.keyFormat){case Ee.WIDEVINE:if(this.pssh=t,!this.keyId){const i=Co(t.buffer);if(i.length){var s;const r=i[0];this.keyId=(s=r.kids)!=null&&s.length?r.kids[0]:null}}if(!this.keyId){const i=t.length-22;this.keyId=t.subarray(i,i+16)}break;case Ee.PLAYREADY:{const i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=ko(i,null,t),this.keyId=Dl(t);break}default:{let i=t.subarray(0,16);if(i.length!==16){const r=new Uint8Array(16);r.set(i,16-i.length),i=r}this.keyId=i;break}}if(!this.keyId||this.keyId.byteLength!==16){let i=qt[this.uri];if(!i){const r=Object.keys(qt).length%Number.MAX_SAFE_INTEGER;i=new Uint8Array(16),new DataView(i.buffer,12,4).setUint32(0,r),Ft.setKeyIdForUri(this.uri,i)}this.keyId=i}return this}}function _l(a){const e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=a>>8*(15-t)&255;return e}const Lr=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,Ir=/#EXT-X-MEDIA:(.*)/g,kl=/^#EXT(?:INF|-X-TARGETDURATION):/m,Os=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),Cl=new RegExp([/#EXT-X-(PROGRAM-DATE-TIME|BYTERANGE|DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class Ke{static findGroup(e,t){for(let s=0;s<e.length;s++){const i=e[s];if(i.id===t)return i}}static resolve(e,t){return vi.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return kl.test(e)}static parseMasterPlaylist(e,t){const s=Tr(e),i={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:s},r=[];if(Lr.lastIndex=0,!e.startsWith("#EXTM3U"))return i.playlistParsingError=new Error("no EXTM3U delimiter"),i;let n;for(;(n=Lr.exec(e))!=null;)if(n[1]){var o;const l=new de(n[1],i),c=ri(i,n[2]),u={attrs:l,bitrate:l.decimalInteger("BANDWIDTH")||l.decimalInteger("AVERAGE-BANDWIDTH"),name:l.NAME,url:Ke.resolve(c,t)},h=l.decimalResolution("RESOLUTION");h&&(u.width=h.width,u.height=h.height),Dr(l.CODECS,u);const f=l["SUPPLEMENTAL-CODECS"];f&&(u.supplemental={},Dr(f,u.supplemental)),(o=u.unknownCodecs)!=null&&o.length||r.push(u),i.levels.push(u)}else if(n[3]){const l=n[3],c=n[4];switch(l){case"SESSION-DATA":{const u=new de(c,i),h=u["DATA-ID"];h&&(i.sessionData===null&&(i.sessionData={}),i.sessionData[h]=u);break}case"SESSION-KEY":{const u=br(c,t,i);u.encrypted&&u.isSupported()?(i.sessionKeys===null&&(i.sessionKeys=[]),i.sessionKeys.push(u)):se.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'.concat(c,'"'));break}case"DEFINE":{{const u=new de(c,i);Sr(i,u,t)}break}case"CONTENT-STEERING":{const u=new de(c,i);i.contentSteering={uri:Ke.resolve(u["SERVER-URI"],t),pathwayId:u["PATHWAY-ID"]||"."};break}case"START":{i.startTimeOffset=Rr(c);break}}}const d=r.length>0&&r.length<i.levels.length;return i.levels=d?r:i.levels,i.levels.length===0&&(i.playlistParsingError=new Error("no levels found in manifest")),i}static parseMasterPlaylistMedia(e,t,s){let i;const r={},n=s.levels,o={AUDIO:n.map(l=>({id:l.attrs.AUDIO,audioCodec:l.audioCodec})),SUBTITLES:n.map(l=>({id:l.attrs.SUBTITLES,textCodec:l.textCodec})),"CLOSED-CAPTIONS":[]};let d=0;for(Ir.lastIndex=0;(i=Ir.exec(e))!==null;){const l=new de(i[1],s),c=l.TYPE;if(c){const u=o[c],h=r[c]||[];r[c]=h;const f=l.LANGUAGE,g=l["ASSOC-LANGUAGE"],m=l.CHANNELS,p=l.CHARACTERISTICS,v=l["INSTREAM-ID"],E={attrs:l,bitrate:0,id:d++,groupId:l["GROUP-ID"]||"",name:l.NAME||f||"",type:c,default:l.bool("DEFAULT"),autoselect:l.bool("AUTOSELECT"),forced:l.bool("FORCED"),lang:f,url:l.URI?Ke.resolve(l.URI,t):""};if(g&&(E.assocLang=g),m&&(E.channels=m),p&&(E.characteristics=p),v&&(E.instreamId=v),u!=null&&u.length){const T=Ke.findGroup(u,E.groupId)||u[0];_r(E,T,"audioCodec"),_r(E,T,"textCodec")}h.push(E)}}return r}static parseLevelPlaylist(e,t,s,i,r,n){var o;const d={url:t},l=new xl(t),c=l.fragments,u=[];let h=null,f=0,g=0,m=0,p=0,v=0,E=null,T=new ks(i,d),S,x,b,A=-1,I=!1,R=null,L;if(Os.lastIndex=0,l.m3u8=e,l.hasVariableRefs=Tr(e),((o=Os.exec(e))==null?void 0:o[0])!=="#EXTM3U")return l.playlistParsingError=new Error("Missing format identifier #EXTM3U"),l;for(;(S=Os.exec(e))!==null;){I&&(I=!1,T=new ks(i,d),T.playlistOffset=m,T.setStart(m),T.sn=f,T.cc=p,v&&(T.bitrate=v),T.level=s,h&&(T.initSegment=h,h.rawProgramDateTime&&(T.rawProgramDateTime=h.rawProgramDateTime,h.rawProgramDateTime=null),R&&(T.setByteRange(R),R=null)));const B=S[1];if(B){T.duration=parseFloat(B);const N=(" "+S[2]).slice(1);T.title=N||null,T.tagList.push(N?["INF",B,N]:["INF",B])}else if(S[3]){if(K(T.duration)){T.playlistOffset=m,T.setStart(m),b&&Cr(T,b,l),T.sn=f,T.level=s,T.cc=p,c.push(T);const N=(" "+S[3]).slice(1);T.relurl=ri(l,N),ai(T,E,u),E=T,m+=T.duration,f++,g=0,I=!0}}else{if(S=S[0].match(Cl),!S){se.warn("No matches on slow regex match for level playlist!");continue}for(x=1;x<S.length&&S[x]===void 0;x++);const N=(" "+S[x]).slice(1),M=(" "+S[x+1]).slice(1),C=S[x+2]?(" "+S[x+2]).slice(1):null;switch(N){case"BYTERANGE":E?T.setByteRange(M,E):T.setByteRange(M);break;case"PROGRAM-DATE-TIME":T.rawProgramDateTime=M,T.tagList.push(["PROGRAM-DATE-TIME",M]),A===-1&&(A=c.length);break;case"PLAYLIST-TYPE":l.type&&We(l,N,S),l.type=M.toUpperCase();break;case"MEDIA-SEQUENCE":l.startSN!==0?We(l,N,S):c.length>0&&Pr(l,N,S),f=l.startSN=parseInt(M);break;case"SKIP":{l.skippedSegments&&We(l,N,S);const k=new de(M,l),O=k.decimalInteger("SKIPPED-SEGMENTS");if(K(O)){l.skippedSegments+=O;for(let F=O;F--;)c.push(null);f+=O}const G=k.enumeratedString("RECENTLY-REMOVED-DATERANGES");G&&(l.recentlyRemovedDateranges=(l.recentlyRemovedDateranges||[]).concat(G.split(" ")));break}case"TARGETDURATION":l.targetduration!==0&&We(l,N,S),l.targetduration=Math.max(parseInt(M),1);break;case"VERSION":l.version!==null&&We(l,N,S),l.version=parseInt(M);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":l.live||We(l,N,S),l.live=!1;break;case"#":(M||C)&&T.tagList.push(C?[M,C]:[M]);break;case"DISCONTINUITY":p++,T.tagList.push(["DIS"]);break;case"GAP":T.gap=!0,T.tagList.push([N]);break;case"BITRATE":T.tagList.push([N,M]),v=parseInt(M)*1e3,K(v)?T.bitrate=v:v=0;break;case"DATERANGE":{const k=new de(M,l),O=new Bn(k,l.dateRanges[k.ID],l.dateRangeTagCount);l.dateRangeTagCount++,O.isValid||l.skippedSegments?l.dateRanges[O.id]=O:se.warn('Ignoring invalid DATERANGE tag: "'.concat(M,'"')),T.tagList.push(["EXT-X-DATERANGE",M]);break}case"DEFINE":{{const k=new de(M,l);"IMPORT"in k?pl(l,k,n):Sr(l,k,t)}break}case"DISCONTINUITY-SEQUENCE":l.startCC!==0?We(l,N,S):c.length>0&&Pr(l,N,S),l.startCC=p=parseInt(M);break;case"KEY":{const k=br(M,t,l);if(k.isSupported()){if(k.method==="NONE"){b=void 0;break}b||(b={});const O=b[k.keyFormat];O!=null&&O.matches(k)||(O&&(b=ie({},b)),b[k.keyFormat]=k)}else se.warn('[Keys] Ignoring unsupported EXT-X-KEY tag: "'.concat(M,'"'));break}case"START":l.startTimeOffset=Rr(M);break;case"MAP":{const k=new de(M,l);if(T.duration){const O=new ks(i,d);kr(O,k,s,b),h=O,T.initSegment=h,h.rawProgramDateTime&&!T.rawProgramDateTime&&(T.rawProgramDateTime=h.rawProgramDateTime)}else{const O=T.byteRangeEndOffset;if(O){const G=T.byteRangeStartOffset;R="".concat(O-G,"@").concat(G)}else R=null;kr(T,k,s,b),h=T,I=!0}h.cc=p;break}case"SERVER-CONTROL":{L&&We(l,N,S),L=new de(M),l.canBlockReload=L.bool("CAN-BLOCK-RELOAD"),l.canSkipUntil=L.optionalFloat("CAN-SKIP-UNTIL",0),l.canSkipDateRanges=l.canSkipUntil>0&&L.bool("CAN-SKIP-DATERANGES"),l.partHoldBack=L.optionalFloat("PART-HOLD-BACK",0),l.holdBack=L.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{l.partTarget&&We(l,N,S);const k=new de(M);l.partTarget=k.decimalFloatingPoint("PART-TARGET");break}case"PART":{let k=l.partList;k||(k=l.partList=[]);const O=g>0?k[k.length-1]:void 0,G=g++,F=new de(M,l),$=new yo(F,T,d,G,O);k.push($),T.duration+=$.duration;break}case"PRELOAD-HINT":{const k=new de(M,l);l.preloadHint=k;break}case"RENDITION-REPORT":{const k=new de(M,l);l.renditionReports=l.renditionReports||[],l.renditionReports.push(k);break}default:se.warn("line parsed but not handled: ".concat(S));break}}}E&&!E.relurl?(c.pop(),m-=E.duration,l.partList&&(l.fragmentHint=E)):l.partList&&(ai(T,E,u),T.cc=p,l.fragmentHint=T,b&&Cr(T,b,l)),l.targetduration||(l.playlistParsingError=new Error("Missing Target Duration"));const w=c.length,U=c[0],V=c[w-1];if(m+=l.skippedSegments*l.targetduration,m>0&&w&&V){l.averagetargetduration=m/w;const B=V.sn;l.endSN=B!=="initSegment"?B:0,l.live||(V.endList=!0),A>0&&(wl(c,A),U&&u.unshift(U))}return l.fragmentHint&&(m+=l.fragmentHint.duration),l.totalduration=m,u.length&&l.dateRangeTagCount&&U&&Kn(u,l),l.endCC=p,l}}function Kn(a,e){let t=a.length;if(!t)if(e.hasProgramDateTime){const o=e.fragments[e.fragments.length-1];a.push(o),t++}else return;const s=a[t-1],i=e.live?1/0:e.totalduration,r=Object.keys(e.dateRanges);for(let o=r.length;o--;){const d=e.dateRanges[r[o]],l=d.startDate.getTime();d.tagAnchor=s.ref;for(let c=t;c--;){var n;if(((n=a[c])==null?void 0:n.sn)<e.startSN)break;const u=Pl(e,l,a,c,i);if(u!==-1){d.tagAnchor=e.fragments[u].ref;break}}}}function Pl(a,e,t,s,i){const r=t[s];if(r){const o=r.programDateTime;if(e>=o||s===0){var n;const d=(((n=t[s+1])==null?void 0:n.start)||i)-r.start;if(e<=o+d*1e3){const l=t[s].sn-a.startSN;if(l<0)return-1;const c=a.fragments;if(c.length>t.length){const h=(t[s+1]||c[c.length-1]).sn-a.startSN;for(let f=h;f>l;f--){const g=c[f].programDateTime;if(e>=g&&e<g+c[f].duration*1e3)return f}}return l}}}return-1}function br(a,e,t){var s,i;const r=new de(a,t),n=(s=r.METHOD)!=null?s:"",o=r.URI,d=r.hexadecimalInteger("IV"),l=r.KEYFORMATVERSIONS,c=(i=r.KEYFORMAT)!=null?i:"identity";o&&r.IV&&!d&&se.error("Invalid IV: ".concat(r.IV));const u=o?Ke.resolve(o,e):"",h=(l||"1").split("/").map(Number).filter(Number.isFinite);return new Ft(n,u,c,h,d,r.KEYID)}function Rr(a){const t=new de(a).decimalFloatingPoint("TIME-OFFSET");return K(t)?t:null}function Dr(a,e){let t=(a||"").split(/[ ,]+/).filter(s=>s);["video","audio","text"].forEach(s=>{const i=t.filter(r=>Si(r,s));i.length&&(e["".concat(s,"Codec")]=i.map(r=>r.split("/")[0]).join(","),t=t.filter(r=>i.indexOf(r)===-1))}),e.unknownCodecs=t}function _r(a,e,t){const s=e[t];s&&(a[t]=s)}function wl(a,e){let t=a[e];for(let s=e;s--;){const i=a[s];if(!i)return;i.programDateTime=t.programDateTime-i.duration*1e3,t=i}}function ai(a,e,t){a.rawProgramDateTime?t.push(a):e!=null&&e.programDateTime&&(a.programDateTime=e.endProgramDateTime)}function kr(a,e,t,s){a.relurl=e.URI,e.BYTERANGE&&a.setByteRange(e.BYTERANGE),a.level=t,a.sn="initSegment",s&&(a.levelkeys=s),a.initSegment=null}function Cr(a,e,t){a.levelkeys=e;const{encryptedFragments:s}=t;(!s.length||s[s.length-1].levelkeys!==e)&&Object.keys(e).some(i=>e[i].isCommonEncryption)&&s.push(a)}function We(a,e,t){a.playlistParsingError=new Error("#EXT-X-".concat(e," must not appear more than once (").concat(t[0],")"))}function Pr(a,e,t){a.playlistParsingError=new Error("#EXT-X-".concat(e," must appear before the first Media Segment (").concat(t[0],")"))}function Ms(a,e){const t=e.startPTS;if(K(t)){let s=0,i;e.sn>a.sn?(s=t-a.start,i=a):(s=a.start-t,i=e),i.duration!==s&&i.setDuration(s)}else e.sn>a.sn?a.cc===e.cc&&a.minEndPTS?e.setStart(a.start+(a.minEndPTS-a.start)):e.setStart(a.start+a.duration):e.setStart(Math.max(a.start-e.duration,0))}function Vn(a,e,t,s,i,r,n){s-t<=0&&(n.warn("Fragment should have a positive duration",e),s=t+e.duration,r=i+e.duration);let d=t,l=s;const c=e.startPTS,u=e.endPTS;if(K(c)){const v=Math.abs(c-t);a&&v>a.totalduration?n.warn("media timestamps and playlist times differ by ".concat(v,"s for level ").concat(e.level," ").concat(a.url)):K(e.deltaPTS)?e.deltaPTS=Math.max(v,e.deltaPTS):e.deltaPTS=v,d=Math.max(t,c),t=Math.min(t,c),i=e.startDTS!==void 0?Math.min(i,e.startDTS):i,l=Math.min(s,u),s=Math.max(s,u),r=e.endDTS!==void 0?Math.max(r,e.endDTS):r}const h=t-e.start;e.start!==0&&e.setStart(t),e.setDuration(s-e.start),e.startPTS=t,e.maxStartPTS=d,e.startDTS=i,e.endPTS=s,e.minEndPTS=l,e.endDTS=r;const f=e.sn;if(!a||f<a.startSN||f>a.endSN)return 0;let g;const m=f-a.startSN,p=a.fragments;for(p[m]=e,g=m;g>0;g--)Ms(p[g],p[g-1]);for(g=m;g<p.length-1;g++)Ms(p[g],p[g+1]);return a.fragmentHint&&Ms(p[p.length-1],a.fragmentHint),a.PTSKnown=a.alignedSliding=!0,h}function Ol(a,e,t){if(a===e)return;let s=null;const i=a.fragments;for(let c=i.length-1;c>=0;c--){const u=i[c].initSegment;if(u){s=u;break}}a.fragmentHint&&delete a.fragmentHint.endPTS;let r;$l(a,e,(c,u,h,f)=>{if((!e.startCC||e.skippedSegments)&&u.cc!==c.cc){const g=c.cc-u.cc;for(let m=h;m<f.length;m++)f[m].cc+=g;e.endCC=f[f.length-1].cc}K(c.startPTS)&&K(c.endPTS)&&(u.setStart(u.startPTS=c.startPTS),u.startDTS=c.startDTS,u.maxStartPTS=c.maxStartPTS,u.endPTS=c.endPTS,u.endDTS=c.endDTS,u.minEndPTS=c.minEndPTS,u.setDuration(c.endPTS-c.startPTS),u.duration&&(r=u),e.PTSKnown=e.alignedSliding=!0),c.hasStreams&&(u.elementaryStreams=c.elementaryStreams),u.loader=c.loader,c.hasStats&&(u.stats=c.stats),c.initSegment&&(u.initSegment=c.initSegment,s=c.initSegment)});const n=e.fragments,o=e.fragmentHint?n.concat(e.fragmentHint):n;if(s&&o.forEach(c=>{var u;c&&(!c.initSegment||c.initSegment.relurl===((u=s)==null?void 0:u.relurl))&&(c.initSegment=s)}),e.skippedSegments){if(e.deltaUpdateFailed=n.some(c=>!c),e.deltaUpdateFailed){t.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let c=e.skippedSegments;c--;)n.shift();e.startSN=n[0].sn}else{e.canSkipDateRanges&&(e.dateRanges=Ml(a.dateRanges,e,t));const c=a.fragments.filter(u=>u.rawProgramDateTime);if(a.hasProgramDateTime&&!e.hasProgramDateTime)for(let u=1;u<o.length;u++)o[u].programDateTime===null&&ai(o[u],o[u-1],c);Kn(c,e)}e.endCC=n[n.length-1].cc}if(!e.startCC){var d;const c=Yn(a,e.startSN-1);e.startCC=(d=c==null?void 0:c.cc)!=null?d:n[0].cc}Fl(a.partList,e.partList,(c,u)=>{u.elementaryStreams=c.elementaryStreams,u.stats=c.stats}),r?Vn(e,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS,t):Hn(a,e),n.length&&(e.totalduration=e.edge-n[0].start),e.driftStartTime=a.driftStartTime,e.driftStart=a.driftStart;const l=e.advancedDateTime;if(e.advanced&&l){const c=e.edge;e.driftStart||(e.driftStartTime=l,e.driftStart=c),e.driftEndTime=l,e.driftEnd=c}else e.driftEndTime=a.driftEndTime,e.driftEnd=a.driftEnd,e.advancedDateTime=a.advancedDateTime;e.requestScheduled===-1&&(e.requestScheduled=a.requestScheduled)}function Ml(a,e,t){const{dateRanges:s,recentlyRemovedDateranges:i}=e,r=ie({},a);i&&i.forEach(d=>{delete r[d]});const o=Object.keys(r).length;return o?(Object.keys(s).forEach(d=>{const l=r[d],c=new Bn(s[d].attr,l);c.isValid?(r[d]=c,l||(c.tagOrder+=o)):t.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'.concat(ne(s[d].attr),'"'))}),r):s}function Fl(a,e,t){if(a&&e){let s=0;for(let i=0,r=a.length;i<=r;i++){const n=a[i],o=e[i+s];n&&o&&n.index===o.index&&n.fragment.sn===o.fragment.sn?t(n,o):s--}}}function $l(a,e,t){const s=e.skippedSegments,i=Math.max(a.startSN,e.startSN)-e.startSN,r=(a.fragmentHint?1:0)+(s?e.endSN:Math.min(a.endSN,e.endSN))-e.startSN,n=e.startSN-a.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,d=a.fragmentHint?a.fragments.concat(a.fragmentHint):a.fragments;for(let l=i;l<=r;l++){const c=d[n+l];let u=o[l];if(s&&!u&&c&&(u=e.fragments[l]=c),c&&u){t(c,u,l,o);const h=c.relurl,f=u.relurl;if(h&&Nl(h,f)){e.playlistParsingError=wr("media sequence mismatch ".concat(u.sn,":"),a,e,c,u);return}else if(c.cc!==u.cc){e.playlistParsingError=wr("discontinuity sequence mismatch (".concat(c.cc,"!=").concat(u.cc,")"),a,e,c,u);return}}}}function wr(a,e,t,s,i){return new Error("".concat(a," ").concat(i.url,"\nPlaylist starting @").concat(e.startSN,"\n").concat(e.m3u8,"\n\nPlaylist starting @").concat(t.startSN,"\n").concat(t.m3u8))}function Hn(a,e,t=!0){const s=e.startSN+e.skippedSegments-a.startSN,i=a.fragments,r=s>=0;let n=0;if(r&&s<i.length)n=i[s].start;else if(r&&e.startSN===a.endSN+1)n=a.fragmentEnd;else if(r&&t)n=a.fragmentStart+s*e.levelTargetDuration;else if(!e.skippedSegments&&e.fragmentStart===0)n=a.fragmentStart;else return;oi(e,n)}function oi(a,e){if(e){const t=a.fragments;for(let s=a.skippedSegments;s<t.length;s++)t[s].addStart(e);a.fragmentHint&&a.fragmentHint.addStart(e)}}function Wn(a,e=1/0){let t=1e3*a.targetduration;if(a.updated){const s=a.fragments;if(s.length&&t*4>e){const r=s[s.length-1].duration*1e3;r<t&&(t=r)}}else t/=2;return Math.round(t)}function Yn(a,e,t){if(!a)return null;let s=a.fragments[e-a.startSN];return s||(s=a.fragmentHint,s&&s.sn===e)?s:e<a.startSN&&t&&t.sn===e?t:null}function Or(a,e,t){return a?qn(a.partList,e,t):null}function qn(a,e,t){if(a)for(let s=a.length;s--;){const i=a[s];if(i.index===t&&i.fragment.sn===e)return i}return null}function jn(a){a.forEach((e,t)=>{var s;(s=e.details)==null||s.fragments.forEach(i=>{i.level=t,i.initSegment&&(i.initSegment.level=t)})})}function Nl(a,e){return a!==e&&e?Mr(a)!==Mr(e):!1}function Mr(a){return a.replace(/\?[^?]*$/,"")}function kt(a,e){for(let s=0,i=a.length;s<i;s++){var t;if(((t=a[s])==null?void 0:t.cc)===e)return a[s]}return null}function Bl(a,e){return!!(a&&e.startCC<a.endCC&&e.endCC>a.startCC)}function Fr(a,e){const t=a.start+e;a.startPTS=t,a.setStart(t),a.endPTS=t+a.duration}function zn(a,e){const t=e.fragments;for(let s=0,i=t.length;s<i;s++)Fr(t[s],a);e.fragmentHint&&Fr(e.fragmentHint,a),e.alignedSliding=!0}function Ul(a,e){a&&(Xn(e,a),e.alignedSliding||Ss(e,a),!e.alignedSliding&&!e.skippedSegments&&Hn(a,e,!1))}function Xn(a,e){if(!Bl(e,a))return;const t=Math.min(e.endCC,a.endCC),s=kt(e.fragments,t),i=kt(a.fragments,t);if(!s||!i)return;se.log("Aligning playlist at start of dicontinuity sequence ".concat(t));const r=s.start-i.start;zn(r,a)}function Ss(a,e){if(!a.hasProgramDateTime||!e.hasProgramDateTime)return;const t=a.fragments,s=e.fragments;if(!t.length||!s.length)return;let i,r;const n=Math.min(e.endCC,a.endCC);e.startCC<n&&a.startCC<n&&(i=kt(s,n),r=kt(t,n)),(!i||!r)&&(i=s[Math.floor(s.length/2)],r=kt(t,i.cc)||t[Math.floor(t.length/2)]);const o=i.programDateTime,d=r.programDateTime;if(!o||!d)return;const l=(d-o)/1e3-(r.start-i.start);zn(l,a)}function Te(a,e,t){Le(a,e,t),a.addEventListener(e,t)}function Le(a,e,t){a.removeEventListener(e,t)}const Gl={toString:function(a){let e="";const t=a.length;for(let s=0;s<t;s++)e+="[".concat(a.start(s).toFixed(3),"-").concat(a.end(s).toFixed(3),"]");return e}},P={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"};class _i extends $n{constructor(e,t,s,i,r){super(i,e.logger),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=P.STOPPED,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.buffering=!0,this.loadingParts=!1,this.loopSn=void 0,this.onMediaSeeking=()=>{const{config:n,fragCurrent:o,media:d,mediaBuffer:l,state:c}=this,u=d?d.currentTime:0,h=X.bufferInfo(l||d,u,n.maxBufferHole),f=!h.len;if(this.log("Media seeking to ".concat(K(u)?u.toFixed(3):u,", state: ").concat(c,", ").concat(f?"out of":"in"," buffer")),this.state===P.ENDED)this.resetLoadingState();else if(o){const g=n.maxFragLookUpTolerance,m=o.start-g,p=o.start+o.duration+g;if(f||p<h.start||m>h.end){const v=u>p;(u<m||v)&&(v&&o.loader&&(this.log("Cancelling fragment load for seek (sn: ".concat(o.sn,")")),o.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}if(d){this.fragmentTracker.removeFragmentsInRange(u,1/0,this.playlistType,!0);const g=this.lastCurrentTime;if(u>g&&(this.lastCurrentTime=u),!this.loadingParts){const m=Math.max(h.end,u),p=this.shouldLoadParts(this.getLevelDetails(),m);p&&(this.log("LL-Part loading ON after seeking to ".concat(u.toFixed(2)," with buffer @").concat(m.toFixed(2))),this.loadingParts=p)}}this.hls.hasEnoughToStart||(this.log("Setting ".concat(f?"startPosition":"nextLoadPosition"," to ").concat(u," for seek without enough to start")),this.nextLoadPosition=u,f&&(this.startPosition=u)),f&&this.state===P.IDLE&&this.tickImmediate()},this.onMediaEnded=()=>{this.log("setting startPosition to 0 because media ended"),this.startPosition=this.lastCurrentTime=0},this.playlistType=r,this.hls=e,this.fragmentLoader=new gl(e.config),this.keyLoader=s,this.fragmentTracker=t,this.config=e.config,this.decrypter=new Li(e.config)}registerListeners(){const{hls:e}=this;e.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(y.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(y.ERROR,this.onError,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){if(this.state===P.STOPPED)return;this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=P.STOPPED}get startPositionValue(){const{nextLoadPosition:e,startPosition:t}=this;return t===-1&&e?e:t}get bufferingEnabled(){return this.buffering}pauseBuffering(){this.buffering=!1}resumeBuffering(){this.buffering=!0}get inFlightFrag(){return{frag:this.fragCurrent,state:this.state}}_streamEnded(e,t){if(t.live||!this.media)return!1;const s=e.end||0,i=this.config.timelineOffset||0;if(s<=i)return!1;const r=e.buffered;this.config.maxBufferHole&&r&&r.length>1&&(e=X.bufferedInfo(r,e.start,0));const n=e.nextStart;if(n&&n>i&&n<t.edge||this.media.currentTime<e.start)return!1;const d=t.partList;if(d!=null&&d.length){const c=d[d.length-1];return X.isBuffered(this.media,c.start+c.duration/2)}const l=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(l)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null)return this.levelLastLoaded.details}get timelineOffset(){const e=this.config.timelineOffset;if(e){var t;return((t=this.getLevelDetails())==null?void 0:t.appliedTimelineOffset)||e}return 0}onMediaAttached(e,t){const s=this.media=this.mediaBuffer=t.media;Te(s,"seeking",this.onMediaSeeking),Te(s,"ended",this.onMediaEnded);const i=this.config;this.levels&&i.autoStartLoad&&this.state===P.STOPPED&&this.startLoad(i.startPosition)}onMediaDetaching(e,t){const s=!!t.transferMedia,i=this.media;if(i!==null){if(i.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),Le(i,"seeking",this.onMediaSeeking),Le(i,"ended",this.onMediaEnded),this.keyLoader&&!s&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,s){this.resetLoadingState(),this.resetTransmuxer();return}this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}}onManifestLoading(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1}onError(e,t){}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset}onHandlerDestroying(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),super.onHandlerDestroying(),this.hls=this.onMediaSeeking=this.onMediaEnded=null}onHandlerDestroyed(){this.state=P.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,s){this.startFragRequested=!0,this._loadFragForPlayback(e,t,s)}_loadFragForPlayback(e,t,s){const i=r=>{const n=r.frag;if(this.fragContextChanged(n)){this.warn("".concat(n.type," sn: ").concat(n.sn).concat(r.part?" part: "+r.part.index:""," of ").concat(this.fragInfo(n,!1,r.part),") was dropped during download.")),this.fragmentTracker.removeFragment(n);return}n.stats.chunkCount++,this._handleFragmentLoadProgress(r)};this._doFragLoad(e,t,s,i).then(r=>{if(!r)return;const n=this.state,o=r.frag;if(this.fragContextChanged(o)){(n===P.FRAG_LOADING||!this.fragCurrent&&n===P.PARSING)&&(this.fragmentTracker.removeFragment(o),this.state=P.IDLE);return}"payload"in r&&(this.log("Loaded ".concat(o.type," sn: ").concat(o.sn," of ").concat(this.playlistLabel()," ").concat(o.level)),this.hls.trigger(y.FRAG_LOADED,r)),this._handleFragmentLoadComplete(r)}).catch(r=>{this.state===P.STOPPED||this.state===P.ERROR||(this.warn("Frag error: ".concat((r==null?void 0:r.message)||r)),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;const{fragmentTracker:s}=this;if(s.getState(e)===ge.APPENDING){const r=e.type,n=this.getFwdBufferInfo(this.mediaBuffer,r),o=Math.max(e.duration,n?n.len:this.config.maxBufferLength),d=this.backtrackFragment;((d?e.sn-d.sn:0)===1||this.reduceMaxBufferLength(o,e.duration))&&s.removeFragment(e)}else((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?s.removeAllFragments():s.hasParts(e.type)&&(s.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),s.getState(e)===ge.PARTIAL&&s.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){const t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}waitForLive(e){const t=e.details;return(t==null?void 0:t.live)&&t.type!=="EVENT"&&(this.levelLastLoaded!==e||t.expired)}flushMainBuffer(e,t,s=null){if(!(e-t))return;const i={startOffset:e,endOffset:t,type:s};this.hls.trigger(y.BUFFER_FLUSHING,i)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(s=>{const i=s==null?void 0:s.frag;if(!i||this.fragContextChanged(i)||!this.levels)throw new Error("init load aborted");return s}).then(s=>{const{hls:i}=this,{frag:r,payload:n}=s,o=r.decryptdata;if(n&&n.byteLength>0&&o!=null&&o.key&&o.iv&&vt(o.method)){const d=self.performance.now();return this.decrypter.decrypt(new Uint8Array(n),o.key.buffer,o.iv.buffer,Ri(o.method)).catch(l=>{throw i.trigger(y.ERROR,{type:W.MEDIA_ERROR,details:_.FRAG_DECRYPT_ERROR,fatal:!1,error:l,reason:l.message,frag:r}),l}).then(l=>{const c=self.performance.now();return i.trigger(y.FRAG_DECRYPTED,{frag:r,payload:l,stats:{tstart:d,tdecrypt:c}}),s.payload=l,this.completeInitSegmentLoad(s)})}return this.completeInitSegmentLoad(s)}).catch(s=>{this.state===P.STOPPED||this.state===P.ERROR||(this.warn(s),this.resetFragmentLoading(e))})}completeInitSegmentLoad(e){const{levels:t}=this;if(!t)throw new Error("init load aborted, missing levels");const s=e.frag.stats;this.state!==P.STOPPED&&(this.state=P.IDLE),e.frag.data=new Uint8Array(e.payload),s.parsing.start=s.buffering.start=self.performance.now(),s.parsing.end=s.buffering.end=self.performance.now(),this.tick()}unhandledEncryptionError(e,t){var s,i;const r=e.tracks;if(r&&!t.encrypted&&((s=r.audio)!=null&&s.encrypted||(i=r.video)!=null&&i.encrypted)&&(!this.config.emeEnabled||!this.keyLoader.emeController)){const n=this.media,o=new Error("Encrypted track with no key in ".concat(this.fragInfo(t)," (media ").concat(n?"attached mediaKeys: "+n.mediaKeys:"detached",")"));return this.warn(o.message),!n||n.mediaKeys?!1:(this.hls.trigger(y.ERROR,{type:W.KEY_SYSTEM_ERROR,details:_.KEY_SYSTEM_NO_KEYS,fatal:!1,error:o,frag:t}),this.resetTransmuxer(),!0)}return!1}fragContextChanged(e){const{fragCurrent:t}=this;return!e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){const s=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log("Buffered ".concat(e.type," sn: ").concat(e.sn).concat(t?" part: "+t.index:""," of ").concat(this.fragInfo(e,!1,t)," > buffer:").concat(s?Gl.toString(X.getBuffered(s)):"(detached)",")")),he(e)){var i;if(e.type!==H.SUBTITLE){const n=e.elementaryStreams;if(!Object.keys(n).some(o=>!!n[o])){this.state=P.IDLE;return}}const r=(i=this.levels)==null?void 0:i[e.level];r!=null&&r.fragmentError&&(this.log("Resetting level fragment error count of ".concat(r.fragmentError," on frag buffered")),r.fragmentError=0)}this.state=P.IDLE}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const{frag:s,part:i,partsLoaded:r}=e,n=!r||r.length===0||r.some(d=>!d),o=new Ii(s.level,s.sn,s.stats.chunkCount+1,0,i?i.index:-1,!n);t.flush(o)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,s=null,i){var r;this.fragCurrent=e;const n=t.details;if(!this.levels||!n)throw new Error("frag load aborted, missing level".concat(n?"":" detail","s"));let o=null;if(e.encrypted&&!((r=e.decryptdata)!=null&&r.key)){if(this.log("Loading key for ".concat(e.sn," of [").concat(n.startSN,"-").concat(n.endSN,"], ").concat(this.playlistLabel()," ").concat(e.level)),this.state=P.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then(h=>{if(!this.fragContextChanged(h.frag))return this.hls.trigger(y.KEY_LOADED,h),this.state===P.KEY_LOADING&&(this.state=P.IDLE),h}),this.hls.trigger(y.KEY_LOADING,{frag:e}),this.fragCurrent===null)return this.log("context changed in KEY_LOADING"),Promise.resolve(null)}else e.encrypted||(o=this.keyLoader.loadClear(e,n.encryptedFragments,this.startFragRequested),o&&this.log("[eme] blocking frag load until media-keys acquired"));const d=this.fragPrevious;if(he(e)&&(!d||e.sn!==d.sn)){const h=this.shouldLoadParts(t.details,e.end);h!==this.loadingParts&&(this.log("LL-Part loading ".concat(h?"ON":"OFF"," loading sn ").concat(d==null?void 0:d.sn,"->").concat(e.sn)),this.loadingParts=h)}if(s=Math.max(e.start,s||0),this.loadingParts&&he(e)){const h=n.partList;if(h&&i){s>n.fragmentEnd&&n.fragmentHint&&(e=n.fragmentHint);const f=this.getNextPart(h,e,s);if(f>-1){const g=h[f];e=this.fragCurrent=g.fragment,this.log("Loading ".concat(e.type," sn: ").concat(e.sn," part: ").concat(g.index," (").concat(f,"/").concat(h.length-1,") of ").concat(this.fragInfo(e,!1,g),") cc: ").concat(e.cc," [").concat(n.startSN,"-").concat(n.endSN,"], target: ").concat(parseFloat(s.toFixed(3)))),this.nextLoadPosition=g.start+g.duration,this.state=P.FRAG_LOADING;let m;return o?m=o.then(p=>!p||this.fragContextChanged(p.frag)?null:this.doFragPartsLoad(e,g,t,i)).catch(p=>this.handleFragLoadError(p)):m=this.doFragPartsLoad(e,g,t,i).catch(p=>this.handleFragLoadError(p)),this.hls.trigger(y.FRAG_LOADING,{frag:e,part:g,targetBufferTime:s}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):m}else if(!e.url||this.loadedEndOfParts(h,s))return Promise.resolve(null)}}if(he(e)&&this.loadingParts){var l;this.log("LL-Part loading OFF after next part miss @".concat(s.toFixed(2)," Check buffer at sn: ").concat(e.sn," loaded parts: ").concat((l=n.partList)==null?void 0:l.filter(h=>h.loaded).map(h=>"[".concat(h.start,"-").concat(h.end,"]")))),this.loadingParts=!1}else if(!e.url)return Promise.resolve(null);this.log("Loading ".concat(e.type," sn: ").concat(e.sn," of ").concat(this.fragInfo(e,!1),") cc: ").concat(e.cc," ").concat("["+n.startSN+"-"+n.endSN+"]",", target: ").concat(parseFloat(s.toFixed(3)))),K(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=P.FRAG_LOADING;const c=this.config.progressive;let u;return c&&o?u=o.then(h=>!h||this.fragContextChanged(h.frag)?null:this.fragmentLoader.load(e,i)).catch(h=>this.handleFragLoadError(h)):u=Promise.all([this.fragmentLoader.load(e,c?i:void 0),o]).then(([h])=>(!c&&i&&i(h),h)).catch(h=>this.handleFragLoadError(h)),this.hls.trigger(y.FRAG_LOADING,{frag:e,targetBufferTime:s}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):u}doFragPartsLoad(e,t,s,i){return new Promise((r,n)=>{var o;const d=[],l=(o=s.details)==null?void 0:o.partList,c=u=>{this.fragmentLoader.loadPart(e,u,i).then(h=>{d[u.index]=h;const f=h.part;this.hls.trigger(y.FRAG_LOADED,h);const g=Or(s.details,e.sn,u.index+1)||qn(l,e.sn,u.index+1);if(g)c(g);else return r({frag:e,part:f,partsLoaded:d})}).catch(n)};c(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;t.frag&&t.details===_.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===W.KEY_SYSTEM_ERROR?(t.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(t.frag)):this.hls.trigger(y.ERROR,t)}else this.hls.trigger(y.ERROR,{type:W.OTHER_ERROR,details:_.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==P.PARSING){!this.fragCurrent&&this.state!==P.STOPPED&&this.state!==P.ERROR&&(this.state=P.IDLE);return}const{frag:s,part:i,level:r}=t,n=self.performance.now();s.stats.parsing.end=n,i&&(i.stats.parsing.end=n);const o=this.getLevelDetails(),l=o&&s.sn>o.endSN||this.shouldLoadParts(o,s.end);l!==this.loadingParts&&(this.log("LL-Part loading ".concat(l?"ON":"OFF"," after parsing segment ending @").concat(s.end.toFixed(2))),this.loadingParts=l),this.updateLevelTiming(s,i,r,e.partial)}shouldLoadParts(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e.partList){var s;const r=e.partList[0];if(r.fragment.type===H.SUBTITLE)return!1;const n=r.end+(((s=e.fragmentHint)==null?void 0:s.duration)||0);if(t>=n){var i;if((this.hls.hasEnoughToStart?((i=this.media)==null?void 0:i.currentTime)||this.lastCurrentTime:this.getLoadPosition())>r.start-r.fragment.duration)return!0}}}return!1}getCurrentContext(e){const{levels:t,fragCurrent:s}=this,{level:i,sn:r,part:n}=e;if(!(t!=null&&t[i]))return this.warn("Levels object was unset while buffering fragment ".concat(r," of ").concat(this.playlistLabel()," ").concat(i,". The current chunk will not be buffered.")),null;const o=t[i],d=o.details,l=n>-1?Or(d,r,n):null,c=l?l.fragment:Yn(d,r,s);return c?(s&&s!==c&&(c.stats=s.stats),{frag:c,part:l,level:o}):null}bufferFragmentData(e,t,s,i,r){if(this.state!==P.PARSING)return;const{data1:n,data2:o}=e;let d=n;if(o&&(d=Ce(n,o)),!d.length)return;const l=this.initPTS[t.cc],c=l?-l.baseTime/l.timescale:void 0,u={type:e.type,frag:t,part:s,chunkMeta:i,offset:c,parent:t.type,data:d};if(this.hls.trigger(y.BUFFER_APPENDING,u),e.dropped&&e.independent&&!s){if(r)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!X.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}const s=t.currentTime,i=X.bufferInfo(t,s,0),r=e.duration,n=Math.min(this.config.maxFragLookUpTolerance*2,r*.25),o=Math.max(Math.min(e.start-n,i.end-n),s+n);e.start-o>n&&this.flushMainBuffer(o,e.start)}getFwdBufferInfo(e,t){var s;const i=this.getLoadPosition();if(!K(i))return null;const n=this.lastCurrentTime>i||(s=this.media)!=null&&s.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,i,t,n)}getFwdBufferInfoAtPos(e,t,s,i){const r=X.bufferInfo(e,t,i);if(r.len===0&&r.nextStart!==void 0){const n=this.fragmentTracker.getBufferedFrag(t,s);if(n&&(r.nextStart<=n.end||n.gap)){const o=Math.max(Math.min(r.nextStart,n.end)-t,i);return X.bufferInfo(e,t,o)}}return r}getMaxBufferLength(e){const{config:t}=this;let s;return e?s=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):s=t.maxBufferLength,Math.min(s,t.maxMaxBufferLength)}reduceMaxBufferLength(e,t){const s=this.config,i=Math.max(Math.min(e-t,s.maxBufferLength),t),r=Math.max(e-t*3,s.maxMaxBufferLength/2,i);return r>=i?(s.maxMaxBufferLength=r,this.warn("Reduce max buffer length to ".concat(r,"s")),!0):!1}getAppendedFrag(e,t=H.MAIN){const s=this.fragmentTracker?this.fragmentTracker.getAppendedFrag(e,t):null;return s&&"fragment"in s?s.fragment:s}getNextFragment(e,t){const s=t.fragments,i=s.length;if(!i)return null;const{config:r}=this,n=s[0].start,o=r.lowLatencyMode&&!!t.partList;let d=null;if(t.live){const u=r.initialLiveManifestSize;if(i<u)return this.warn("Not enough fragments to start playback (have: ".concat(i,", need: ").concat(u,")")),null;if(!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<n){var l;o&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),d=this.getInitialLiveFragment(t);const h=this.hls.startPosition,f=this.hls.liveSyncPosition,g=d?(h!==-1&&h>=n?h:f)||d.start:e;this.log("Setting startPosition to ".concat(g," to match start frag at live edge. mainStart: ").concat(h," liveSyncPosition: ").concat(f," frag.start: ").concat((l=d)==null?void 0:l.start)),this.startPosition=this.nextLoadPosition=g}}else e<=n&&(d=s[0]);if(!d){const u=this.loadingParts?t.partEnd:t.fragmentEnd;d=this.getFragmentAtPosition(e,u,t)}let c=this.filterReplacedPrimary(d,t);if(!c&&d){const u=d.sn-t.startSN;c=this.filterReplacedPrimary(s[u+1]||null,t)}return this.mapToInitFragWhenRequired(c)}isLoopLoading(e,t){const s=this.fragmentTracker.getState(e);return(s===ge.OK||s===ge.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,s,i,r){let n=null;if(e.gap&&(n=this.getNextFragment(this.nextLoadPosition,t),n&&!n.gap&&s.nextStart)){const o=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,s.nextStart,i,0);if(o!==null&&s.len+o.len>=r){const d=n.sn;return this.loopSn!==d&&(this.log('buffer full after gaps in "'.concat(i,'" playlist starting at sn: ').concat(d)),this.loopSn=d),null}}return this.loopSn=void 0,n}get primaryPrefetch(){if($r(this.config)){var e;if((e=this.hls.interstitialsManager)==null||(e=e.playingItem)==null?void 0:e.event)return!0}return!1}filterReplacedPrimary(e,t){if(!e)return e;if($r(this.config)&&e.type!==H.SUBTITLE){const s=this.hls.interstitialsManager,i=s==null?void 0:s.bufferingItem;if(i){const n=i.event;if(n){if(n.appendInPlace||Math.abs(e.start-i.start)>1||i.start===0)return null}else if(e.end<=i.start&&(t==null?void 0:t.live)===!1||e.start>i.end&&i.nextEvent&&(i.nextEvent.appendInPlace||e.start-i.end>1))return null}const r=s==null?void 0:s.playerQueue;if(r)for(let n=r.length;n--;){const o=r[n].interstitial;if(o.appendInPlace&&e.start>=o.startTime&&e.end<=o.resumeTime)return null}}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!e.initSegment.data&&!this.bitrateTest?e.initSegment:e}getNextPart(e,t,s){let i=-1,r=!1,n=!0;for(let o=0,d=e.length;o<d;o++){const l=e[o];if(n=n&&!l.independent,i>-1&&s<l.start)break;const c=l.loaded;c?i=-1:(r||(l.independent||n)&&l.fragment===t)&&(l.fragment!==t&&this.warn("Need buffer at ".concat(s," but next unloaded part starts at ").concat(l.start)),i=o),r=c}return i}loadedEndOfParts(e,t){let s;for(let i=e.length;i--;){if(s=e[i],!s.loaded)return!1;if(t>s.start)return!0}return!1}getInitialLiveFragment(e){const t=e.fragments,s=this.fragPrevious;let i=null;if(s){if(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: ".concat(s.programDateTime)),i=sl(t,s.endProgramDateTime,this.config.maxFragLookUpTolerance)),!i){const r=s.sn+1;if(r>=e.startSN&&r<=e.endSN){const n=t[r-e.startSN];s.cc===n.cc&&(i=n,this.log("Live playlist, switching playlist, load frag with next SN: ".concat(i.sn)))}i||(i=On(e,s.cc,s.end),i&&this.log("Live playlist, switching playlist, load frag with same CC: ".concat(i.sn)))}}else{const r=this.hls.liveSyncPosition;r!==null&&(i=this.getFragmentAtPosition(r,this.bitrateTest?e.fragmentEnd:e.edge,e))}return i}getFragmentAtPosition(e,t,s){const{config:i}=this;let{fragPrevious:r}=this,{fragments:n,endSN:o}=s;const{fragmentHint:d}=s,{maxFragLookUpTolerance:l}=i,c=s.partList,u=!!(this.loadingParts&&c!=null&&c.length&&d);u&&!this.bitrateTest&&c[c.length-1].fragment.sn===d.sn&&(n=n.concat(d),o=d.sn);let h;if(e<t){var f;const m=e<this.lastCurrentTime||e>t-l||(f=this.media)!=null&&f.paused||!this.startFragRequested?0:l;h=lt(r,n,e,m)}else h=n[n.length-1];if(h){const g=h.sn-s.startSN,m=this.fragmentTracker.getState(h);if((m===ge.OK||m===ge.PARTIAL&&h.gap)&&(r=h),r&&h.sn===r.sn&&(!u||c[0].fragment.sn>h.sn||!s.live)&&h.level===r.level){const v=n[g+1];h.sn<o&&this.fragmentTracker.getState(v)!==ge.OK?h=v:h=null}}return h}alignPlaylists(e,t,s){const i=e.fragments.length;if(!i)return this.warn("No fragments in live playlist"),0;const r=e.fragmentStart,n=!t,o=e.alignedSliding&&K(r);if(n||!o&&!r){Ul(s,e);const d=e.fragmentStart;return this.log("Live playlist sliding: ".concat(d.toFixed(2)," start-sn: ").concat(t?t.startSN:"na","->").concat(e.startSN," fragments: ").concat(i)),d}return r}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,t){let s=this.startPosition;s<t&&(s=-1);const i=this.timelineOffset;if(s===-1){const r=this.startTimeOffset!==null,n=r?this.startTimeOffset:e.startTimeOffset;n!==null&&K(n)?(s=t+n,n<0&&(s+=e.edge),s=Math.min(Math.max(t,s),t+e.totalduration),this.log("Setting startPosition to ".concat(s," for start time offset ").concat(n," found in ").concat(r?"multivariant":"media"," playlist")),this.startPosition=s):e.live?(s=this.hls.liveSyncPosition||t,this.log("Setting startPosition to -1 to start at live edge ".concat(s)),this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=s=0),this.lastCurrentTime=s+i}this.nextLoadPosition=s+i}getLoadPosition(){var e;const{media:t}=this;let s=0;return(e=this.hls)!=null&&e.hasEnoughToStart&&t?s=t.currentTime:this.nextLoadPosition>=0&&(s=this.nextLoadPosition),s}handleFragLoadAborted(e,t){this.transmuxer&&e.type===this.playlistType&&he(e)&&e.stats.aborted&&(this.log("Fragment ".concat(e.sn).concat(t?" part "+t.index:""," of ").concat(this.playlistLabel()," ").concat(e.level," was aborted")),this.resetFragmentLoading(e))}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==P.FRAG_LOADING_WAITING_RETRY)&&(this.state=P.IDLE)}onFragmentOrKeyLoadError(e,t){var s;if(t.chunkMeta&&!t.frag){const v=this.getCurrentContext(t.chunkMeta);v&&(t.frag=v.frag)}const i=t.frag;if(!i||i.type!==e||!this.levels)return;if(this.fragContextChanged(i)){var r;this.warn("Frag load error must match current frag to retry ".concat(i.url," > ").concat((r=this.fragCurrent)==null?void 0:r.url));return}const n=t.details===_.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(i,!0);const o=t.errorAction;if(!o){this.state=P.ERROR;return}const{action:d,flags:l,retryCount:c=0,retryConfig:u}=o,h=!!u,f=h&&d===pe.RetryRequest,g=h&&!o.resolved&&l===be.MoveAllAlternatesMatchingHost,m=(s=this.hls.latestLevelDetails)==null?void 0:s.live;if(!f&&g&&he(i)&&!i.endList&&m&&!Fn(t))this.resetFragmentErrors(e),this.treatAsGap(i),o.resolved=!0;else if((f||g)&&c<u.maxNumRetry){var p;const v=ii((p=t.response)==null?void 0:p.code),E=Ai(u,c);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+E,this.state=P.FRAG_LOADING_WAITING_RETRY,o.resolved=!0,v){this.log("Waiting for connection (offline)"),this.retryDate=1/0,t.reason="offline";return}this.warn("Fragment ".concat(i.sn," of ").concat(e," ").concat(i.level," errored with ").concat(t.details,", retrying loading ").concat(c+1,"/").concat(u.maxNumRetry," in ").concat(E,"ms"))}else if(u)if(this.resetFragmentErrors(e),c<u.maxNumRetry)!n&&d!==pe.RemoveAlternatePermanently&&(o.resolved=!0);else{this.warn("".concat(t.details," reached or exceeded max retry (").concat(c,")"));return}else d===pe.SendAlternateToPenaltyBox?this.state=P.WAITING_LEVEL:this.state=P.ERROR;this.tickImmediate()}checkRetryDate(){const e=self.performance.now(),t=this.retryDate,s=t===1/0;(!t||e>=t||s&&!ii(0))&&(s&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=P.IDLE)}reduceLengthAndFlushBuffer(e){if(this.state===P.PARSING||this.state===P.PARSED){const t=e.frag,s=e.parent,i=this.getFwdBufferInfo(this.mediaBuffer,s),r=i&&i.len>.5;r&&this.reduceMaxBufferLength(i.len,(t==null?void 0:t.duration)||10);const n=!r;return n&&this.warn("Buffer full error while media.currentTime (".concat(this.getLoadPosition(),") is not buffered, flush ").concat(s," buffer")),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),n}return!1}resetFragmentErrors(e){e===H.AUDIO&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==P.STOPPED&&(this.state=P.IDLE)}afterBufferFlushed(e,t,s){if(!e)return;const i=X.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,s),this.state===P.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==P.STOPPED&&(this.state=P.IDLE)}resetStartWhenNotLoaded(){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;const e=this.levelLastLoaded,t=e?e.details:null;t!=null&&t.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(t,t.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.log("Loading context changed while buffering sn ".concat(e.sn," of ").concat(this.playlistLabel()," ").concat(e.level===-1?"<removed>":e.level,". This chunk will not be buffered.")),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,s,i){const r=s.details;if(!r){this.warn("level.details undefined");return}if(!Object.keys(e.elementaryStreams).reduce((d,l)=>{const c=e.elementaryStreams[l];if(c){const u=c.endPTS-c.startPTS;if(u<=0)return this.warn("Could not parse fragment ".concat(e.sn," ").concat(l," duration reliably (").concat(u,")")),d||!1;const h=i?0:Vn(r,e,c.startPTS,c.endPTS,c.startDTS,c.endDTS,this);return this.hls.trigger(y.LEVEL_PTS_UPDATED,{details:r,level:s,drift:h,type:l,frag:e,start:c.startPTS,end:c.endPTS}),!0}return d},!1)){var o;if(s.fragmentError===0&&this.treatAsGap(e,s),((o=this.transmuxer)==null?void 0:o.error)===null){const d=new Error("Found no media in fragment ".concat(e.sn," of ").concat(this.playlistLabel()," ").concat(e.level," resetting transmuxer to fallback to playlist timing"));if(this.warn(d.message),this.hls.trigger(y.ERROR,{type:W.MEDIA_ERROR,details:_.FRAG_PARSING_ERROR,fatal:!1,error:d,frag:e,reason:"Found no media in msn ".concat(e.sn," of ").concat(this.playlistLabel(),' "').concat(s.url,'"')}),!this.hls)return;this.resetTransmuxer()}}this.state=P.PARSED,this.log("Parsed ".concat(e.type," sn: ").concat(e.sn).concat(t?" part: "+t.index:""," of ").concat(this.fragInfo(e,!1,t),")")),this.hls.trigger(y.FRAG_PARSED,{frag:e,part:t})}playlistLabel(){return this.playlistType===H.MAIN?"level":"track"}fragInfo(e,t=!0,s){var i,r;return"".concat(this.playlistLabel()," ").concat(e.level," (").concat(s?"part":"frag",":[").concat(((i=t&&!s?e.startPTS:(s||e).start)!=null?i:NaN).toFixed(3),"-").concat(((r=t&&!s?e.endPTS:(s||e).end)!=null?r:NaN).toFixed(3),"]").concat(s&&e.type==="main"?"INDEPENDENT="+(s.independent?"YES":"NO"):"")}treatAsGap(e,t){t&&t.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)}resetTransmuxer(){var e;(e=this.transmuxer)==null||e.reset()}recoverWorkerError(e){e.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(),this.resetLoadingState())}set state(e){const t=this._state;t!==e&&(this._state=e,this.log("".concat(t,"->").concat(e)))}get state(){return this._state}}function $r(a){return!!a.interstitialsController&&a.enableInterstitialPlayback!==!1}class Qn{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){const{chunks:e,dataLength:t}=this;let s;if(e.length)e.length===1?s=e[0]:s=Kl(e,t);else return new Uint8Array(0);return this.reset(),s}reset(){this.chunks.length=0,this.dataLength=0}}function Kl(a,e){const t=new Uint8Array(e);let s=0;for(let i=0;i<a.length;i++){const r=a[i];t.set(r,s),s+=r.length}return t}var Fs={exports:{}},Nr;function Vl(){return Nr||(Nr=1,(function(a){var e=Object.prototype.hasOwnProperty,t="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(t=!1));function i(d,l,c){this.fn=d,this.context=l,this.once=c||!1}function r(d,l,c,u,h){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new i(c,u||d,h),g=t?t+l:l;return d._events[g]?d._events[g].fn?d._events[g]=[d._events[g],f]:d._events[g].push(f):(d._events[g]=f,d._eventsCount++),d}function n(d,l){--d._eventsCount===0?d._events=new s:delete d._events[l]}function o(){this._events=new s,this._eventsCount=0}o.prototype.eventNames=function(){var l=[],c,u;if(this._eventsCount===0)return l;for(u in c=this._events)e.call(c,u)&&l.push(t?u.slice(1):u);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(c)):l},o.prototype.listeners=function(l){var c=t?t+l:l,u=this._events[c];if(!u)return[];if(u.fn)return[u.fn];for(var h=0,f=u.length,g=new Array(f);h<f;h++)g[h]=u[h].fn;return g},o.prototype.listenerCount=function(l){var c=t?t+l:l,u=this._events[c];return u?u.fn?1:u.length:0},o.prototype.emit=function(l,c,u,h,f,g){var m=t?t+l:l;if(!this._events[m])return!1;var p=this._events[m],v=arguments.length,E,T;if(p.fn){switch(p.once&&this.removeListener(l,p.fn,void 0,!0),v){case 1:return p.fn.call(p.context),!0;case 2:return p.fn.call(p.context,c),!0;case 3:return p.fn.call(p.context,c,u),!0;case 4:return p.fn.call(p.context,c,u,h),!0;case 5:return p.fn.call(p.context,c,u,h,f),!0;case 6:return p.fn.call(p.context,c,u,h,f,g),!0}for(T=1,E=new Array(v-1);T<v;T++)E[T-1]=arguments[T];p.fn.apply(p.context,E)}else{var S=p.length,x;for(T=0;T<S;T++)switch(p[T].once&&this.removeListener(l,p[T].fn,void 0,!0),v){case 1:p[T].fn.call(p[T].context);break;case 2:p[T].fn.call(p[T].context,c);break;case 3:p[T].fn.call(p[T].context,c,u);break;case 4:p[T].fn.call(p[T].context,c,u,h);break;default:if(!E)for(x=1,E=new Array(v-1);x<v;x++)E[x-1]=arguments[x];p[T].fn.apply(p[T].context,E)}}return!0},o.prototype.on=function(l,c,u){return r(this,l,c,u,!1)},o.prototype.once=function(l,c,u){return r(this,l,c,u,!0)},o.prototype.removeListener=function(l,c,u,h){var f=t?t+l:l;if(!this._events[f])return this;if(!c)return n(this,f),this;var g=this._events[f];if(g.fn)g.fn===c&&(!h||g.once)&&(!u||g.context===u)&&n(this,f);else{for(var m=0,p=[],v=g.length;m<v;m++)(g[m].fn!==c||h&&!g[m].once||u&&g[m].context!==u)&&p.push(g[m]);p.length?this._events[f]=p.length===1?p[0]:p:n(this,f)}return this},o.prototype.removeAllListeners=function(l){var c;return l?(c=t?t+l:l,this._events[c]&&n(this,c)):(this._events=new s,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,a.exports=o})(Fs)),Fs.exports}var Hl=Vl(),ki=mo(Hl);const $t="1.6.12",xt={};function Wl(){return typeof __HLS_WORKER_BUNDLE__=="function"}function Yl(){const a=xt[$t];if(a)return a.clientCount++,a;const e=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(".concat(__HLS_WORKER_BUNDLE__.toString(),")(true);")],{type:"text/javascript"}),t=self.URL.createObjectURL(e),i={worker:new self.Worker(t),objectURL:t,clientCount:1};return xt[$t]=i,i}function ql(a){const e=xt[a];if(e)return e.clientCount++,e;const t=new self.URL(a,self.location.href).href,i={worker:new self.Worker(t),scriptURL:t,clientCount:1};return xt[a]=i,i}function jl(a){const e=xt[a||$t];if(e&&e.clientCount--===1){const{worker:s,objectURL:i}=e;delete xt[a||$t],i&&self.URL.revokeObjectURL(i),s.terminate()}}function Zn(a,e){return e+10<=a.length&&a[e]===51&&a[e+1]===68&&a[e+2]===73&&a[e+3]<255&&a[e+4]<255&&a[e+6]<128&&a[e+7]<128&&a[e+8]<128&&a[e+9]<128}function Ci(a,e){return e+10<=a.length&&a[e]===73&&a[e+1]===68&&a[e+2]===51&&a[e+3]<255&&a[e+4]<255&&a[e+6]<128&&a[e+7]<128&&a[e+8]<128&&a[e+9]<128}function Is(a,e){let t=0;return t=(a[e]&127)<<21,t|=(a[e+1]&127)<<14,t|=(a[e+2]&127)<<7,t|=a[e+3]&127,t}function Nt(a,e){const t=e;let s=0;for(;Ci(a,e);){s+=10;const i=Is(a,e+6);s+=i,Zn(a,e+10)&&(s+=10),e+=s}if(s>0)return a.subarray(t,t+s)}function zl(a,e,t,s){const i=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],r=e[t+2],n=r>>2&15;if(n>12){const f=new Error("invalid ADTS sampling index:".concat(n));a.emit(y.ERROR,y.ERROR,{type:W.MEDIA_ERROR,details:_.FRAG_PARSING_ERROR,fatal:!0,error:f,reason:f.message});return}const o=(r>>6&3)+1,d=e[t+3]>>6&3|(r&1)<<2,l="mp4a.40."+o,c=i[n];let u=n;(o===5||o===29)&&(u-=3);const h=[o<<3|(u&14)>>1,(u&1)<<7|d<<3];return se.log("manifest codec:".concat(s,", parsed codec:").concat(l,", channels:").concat(d,", rate:").concat(c," (ADTS object type:").concat(o," sampling index:").concat(n,")")),{config:h,samplerate:c,channelCount:d,codec:l,parsedCodec:l,manifestCodec:s}}function Jn(a,e){return a[e]===255&&(a[e+1]&246)===240}function ea(a,e){return a[e+1]&1?7:9}function Pi(a,e){return(a[e+3]&3)<<11|a[e+4]<<3|(a[e+5]&224)>>>5}function Xl(a,e){return e+5<a.length}function xs(a,e){return e+1<a.length&&Jn(a,e)}function Ql(a,e){return Xl(a,e)&&Jn(a,e)&&Pi(a,e)<=a.length-e}function Zl(a,e){if(xs(a,e)){const t=ea(a,e);if(e+t>=a.length)return!1;const s=Pi(a,e);if(s<=t)return!1;const i=e+s;return i===a.length||xs(a,i)}return!1}function ta(a,e,t,s,i){if(!a.samplerate){const r=zl(e,t,s,i);if(!r)return;ie(a,r)}}function sa(a){return 1024*9e4/a}function Jl(a,e){const t=ea(a,e);if(e+t<=a.length){const s=Pi(a,e)-t;if(s>0)return{headerLength:t,frameLength:s}}}function ia(a,e,t,s,i){const r=sa(a.samplerate),n=s+i*r,o=Jl(e,t);let d;if(o){const{frameLength:u,headerLength:h}=o,f=h+u,g=Math.max(0,t+f-e.length);g?(d=new Uint8Array(f-h),d.set(e.subarray(t+h,e.length),0)):d=e.subarray(t+h,t+f);const m={unit:d,pts:n};return g||a.samples.push(m),{sample:m,length:f,missing:g}}const l=e.length-t;return d=new Uint8Array(l),d.set(e.subarray(t,e.length),0),{sample:{unit:d,pts:n},length:l,missing:-1}}function ed(a,e){return Ci(a,e)&&Is(a,e+6)+10<=a.length-e}function td(a){return a instanceof ArrayBuffer?a:a.byteOffset==0&&a.byteLength==a.buffer.byteLength?a.buffer:new Uint8Array(a).buffer}function $s(a,e=0,t=1/0){return sd(a,e,t,Uint8Array)}function sd(a,e,t,s){const i=id(a);let r=1;"BYTES_PER_ELEMENT"in s&&(r=s.BYTES_PER_ELEMENT);const n=rd(a)?a.byteOffset:0,o=(n+a.byteLength)/r,d=(n+e)/r,l=Math.floor(Math.max(0,Math.min(d,o))),c=Math.floor(Math.min(l+Math.max(t,0),o));return new s(i,l,c-l)}function id(a){return a instanceof ArrayBuffer?a:a.buffer}function rd(a){return a&&a.buffer instanceof ArrayBuffer&&a.byteLength!==void 0&&a.byteOffset!==void 0}function nd(a){const e={key:a.type,description:"",data:"",mimeType:null,pictureType:null},t=3;if(a.size<2)return;if(a.data[0]!==t){console.log("Ignore frame with unrecognized character encoding");return}const s=a.data.subarray(1).indexOf(0);if(s===-1)return;const i=De($s(a.data,1,s)),r=a.data[2+s],n=a.data.subarray(3+s).indexOf(0);if(n===-1)return;const o=De($s(a.data,3+s,n));let d;return i==="-->"?d=De($s(a.data,4+s+n)):d=td(a.data.subarray(4+s+n)),e.mimeType=i,e.pictureType=r,e.description=o,e.data=d,e}function ad(a){if(a.size<2)return;const e=De(a.data,!0),t=new Uint8Array(a.data.subarray(e.length+1));return{key:a.type,info:e,data:t.buffer}}function od(a){if(a.size<2)return;if(a.type==="TXXX"){let t=1;const s=De(a.data.subarray(t),!0);t+=s.length+1;const i=De(a.data.subarray(t));return{key:a.type,info:s,data:i}}const e=De(a.data.subarray(1));return{key:a.type,info:"",data:e}}function ld(a){if(a.type==="WXXX"){if(a.size<2)return;let t=1;const s=De(a.data.subarray(t),!0);t+=s.length+1;const i=De(a.data.subarray(t));return{key:a.type,info:s,data:i}}const e=De(a.data);return{key:a.type,info:"",data:e}}function dd(a){return a.type==="PRIV"?ad(a):a.type[0]==="W"?ld(a):a.type==="APIC"?nd(a):od(a)}function cd(a){const e=String.fromCharCode(a[0],a[1],a[2],a[3]),t=Is(a,4),s=10;return{type:e,size:t,data:a.subarray(s,s+t)}}const jt=10,ud=10;function ra(a){let e=0;const t=[];for(;Ci(a,e);){const s=Is(a,e+6);a[e+5]>>6&1&&(e+=jt),e+=jt;const i=e+s;for(;e+ud<i;){const r=cd(a.subarray(e)),n=dd(r);n&&t.push(n),e+=r.size+jt}Zn(a,e)&&(e+=jt)}return t}function na(a){return a&&a.key==="PRIV"&&a.info==="com.apple.streaming.transportStreamTimestamp"}function hd(a){if(a.data.byteLength===8){const e=new Uint8Array(a.data),t=e[3]&1;let s=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return s/=45,t&&(s+=4772185884e-2),Math.round(s)}}function wi(a){const e=ra(a);for(let t=0;t<e.length;t++){const s=e[t];if(na(s))return hd(s)}}let Re=(function(a){return a.audioId3="org.id3",a.dateRange="com.apple.quicktime.HLS",a.emsg="https://aomedia.org/emsg/ID3",a.misbklv="urn:misb:KLV:bin:1910.1",a})({});function Ue(a="",e=9e4){return{type:a,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class Oi{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,s,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,s){}demux(e,t){this.cachedData&&(e=Ce(this.cachedData,e),this.cachedData=null);let s=Nt(e,0),i=s?s.length:0,r;const n=this._audioTrack,o=this._id3Track,d=s?wi(s):void 0,l=e.length;for((this.basePTS===null||this.frameIndex===0&&K(d))&&(this.basePTS=fd(d,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),s&&s.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:s,type:Re.audioId3,duration:Number.POSITIVE_INFINITY});i<l;){if(this.canParse(e,i)){const c=this.appendFrame(n,e,i);c?(this.frameIndex++,this.lastPTS=c.sample.pts,i+=c.length,r=i):i=l}else ed(e,i)?(s=Nt(e,i),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:s,type:Re.audioId3,duration:Number.POSITIVE_INFINITY}),i+=s.length,r=i):i++;if(i===l&&r!==l){const c=e.slice(r);this.cachedData?this.cachedData=Ce(this.cachedData,c):this.cachedData=c}}return{audioTrack:n,videoTrack:Ue(),id3Track:o,textTrack:Ue()}}demuxSampleAes(e,t,s){return Promise.reject(new Error("[".concat(this,"] This demuxer does not support Sample-AES decryption")))}flush(e){const t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:Ue(),id3Track:this._id3Track,textTrack:Ue()}}destroy(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}const fd=(a,e,t)=>{if(K(a))return a*90;const s=t?t.baseTime*9e4/t.timescale:0;return e*9e4+s};let zt=null;const gd=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],md=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],pd=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],yd=[0,1,1,4];function aa(a,e,t,s,i){if(t+24>e.length)return;const r=oa(e,t);if(r&&t+r.frameLength<=e.length){const n=r.samplesPerFrame*9e4/r.sampleRate,o=s+i*n,d={unit:e.subarray(t,t+r.frameLength),pts:o,dts:o};return a.config=[],a.channelCount=r.channelCount,a.samplerate=r.sampleRate,a.samples.push(d),{sample:d,length:r.frameLength,missing:0}}}function oa(a,e){const t=a[e+1]>>3&3,s=a[e+1]>>1&3,i=a[e+2]>>4&15,r=a[e+2]>>2&3;if(t!==1&&i!==0&&i!==15&&r!==3){const n=a[e+2]>>1&1,o=a[e+3]>>6,d=t===3?3-s:s===3?3:4,l=gd[d*14+i-1]*1e3,u=md[(t===3?0:t===2?1:2)*3+r],h=o===3?1:2,f=pd[t][s],g=yd[s],m=f*8*g,p=Math.floor(f*l/u+n)*g;if(zt===null){const T=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);zt=T?parseInt(T[1]):0}return!!zt&&zt<=87&&s===2&&l>=224e3&&o===0&&(a[e+3]=a[e+3]|128),{sampleRate:u,channelCount:h,frameLength:p,samplesPerFrame:m}}}function Mi(a,e){return a[e]===255&&(a[e+1]&224)===224&&(a[e+1]&6)!==0}function la(a,e){return e+1<a.length&&Mi(a,e)}function vd(a,e){return Mi(a,e)&&4<=a.length-e}function da(a,e){if(e+1<a.length&&Mi(a,e)){const s=oa(a,e);let i=4;s!=null&&s.frameLength&&(i=s.frameLength);const r=e+i;return r===a.length||la(a,r)}return!1}class Ed extends Oi{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,s,i){super.resetInitSegment(e,t,s,i),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}static probe(e,t){if(!e)return!1;const s=Nt(e,0);let i=(s==null?void 0:s.length)||0;if(da(e,i))return!1;for(let r=e.length;i<r;i++)if(Zl(e,i))return t.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return Ql(e,t)}appendFrame(e,t,s){ta(e,this.observer,t,s,e.manifestCodec);const i=ia(e,t,s,this.basePTS,this.frameIndex);if(i&&i.missing===0)return i}}const ca=(a,e)=>{let t=0,s=5;e+=s;const i=new Uint32Array(1),r=new Uint32Array(1),n=new Uint8Array(1);for(;s>0;){n[0]=a[e];const o=Math.min(s,8),d=8-o;r[0]=4278190080>>>24+d<<d,i[0]=(n[0]&r[0])>>d,t=t?t<<o|i[0]:i[0],e+=1,s-=o}return t};class Td extends Oi{constructor(e){super(),this.observer=void 0,this.observer=e}resetInitSegment(e,t,s,i){super.resetInitSegment(e,t,s,i),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,s){const i=ua(e,t,s,this.basePTS,this.frameIndex);if(i!==-1)return{sample:e.samples[e.samples.length-1],length:i,missing:0}}static probe(e){if(!e)return!1;const t=Nt(e,0);if(!t)return!1;const s=t.length;return e[s]===11&&e[s+1]===119&&wi(t)!==void 0&&ca(e,s)<16}}function ua(a,e,t,s,i){if(t+8>e.length||e[t]!==11||e[t+1]!==119)return-1;const r=e[t+4]>>6;if(r>=3)return-1;const o=[48e3,44100,32e3][r],d=e[t+4]&63,c=[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][d*3+r]*2;if(t+c>e.length)return-1;const u=e[t+6]>>5;let h=0;u===2?h+=2:(u&1&&u!==1&&(h+=2),u&4&&(h+=2));const f=(e[t+6]<<8|e[t+7])>>12-h&1,m=[2,1,2,3,3,4,4,5][u]+f,p=e[t+5]>>3,v=e[t+5]&7,E=new Uint8Array([r<<6|p<<1|v>>2,(v&3)<<6|u<<3|f<<2|d>>4,d<<4&224]),T=1536/o*9e4,S=s+i*T,x=e.subarray(t,t+c);return a.config=E,a.channelCount=m,a.samplerate=o,a.samples.push({unit:x,pts:S}),c}class Sd extends Oi{resetInitSegment(e,t,s,i){super.resetInitSegment(e,t,s,i),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=Nt(e,0);let s=(t==null?void 0:t.length)||0;if(t&&e[s]===11&&e[s+1]===119&&wi(t)!==void 0&&ca(e,s)<=16)return!1;for(let i=e.length;s<i;s++)if(da(e,s))return se.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return vd(e,t)}appendFrame(e,t,s){if(this.basePTS!==null)return aa(e,t,s,this.basePTS,this.frameIndex)}}const xd=/\/emsg[-/]ID3/i;class Ad{constructor(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}resetTimeStamp(){}resetInitSegment(e,t,s,i){const r=this.videoTrack=Ue("video",1),n=this.audioTrack=Ue("audio",1),o=this.txtTrack=Ue("text",1);if(this.id3Track=Ue("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;const d=Ln(e);if(d.video){const{id:l,timescale:c,codec:u,supplemental:h}=d.video;r.id=l,r.timescale=o.timescale=c,r.codec=u,r.supplemental=h}if(d.audio){const{id:l,timescale:c,codec:u}=d.audio;n.id=l,n.timescale=c,n.codec=u}o.id=Sn.text,r.sampleDuration=0,r.duration=n.duration=i}resetContiguity(){this.remainderData=null}static probe(e){return To(e)}demux(e,t){this.timeOffset=t;let s=e;const i=this.videoTrack,r=this.txtTrack;if(this.config.progressive){this.remainderData&&(s=Ce(this.remainderData,e));const o=bo(s);this.remainderData=o.remainder,i.samples=o.valid||new Uint8Array}else i.samples=s;const n=this.extractID3Track(i,t);return r.samples=ir(t,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:n,textTrack:this.txtTrack}}flush(){const e=this.timeOffset,t=this.videoTrack,s=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;const i=this.extractID3Track(t,this.timeOffset);return s.samples=ir(e,t),{videoTrack:t,audioTrack:Ue(),id3Track:i,textTrack:Ue()}}extractID3Track(e,t){const s=this.id3Track;if(e.samples.length){const i=Q(e.samples,["emsg"]);i&&i.forEach(r=>{const n=Do(r);if(xd.test(n.schemeIdUri)){const o=Br(n,t);let d=n.eventDuration===4294967295?Number.POSITIVE_INFINITY:n.eventDuration/n.timeScale;d<=.001&&(d=Number.POSITIVE_INFINITY);const l=n.payload;s.samples.push({data:l,len:l.byteLength,dts:o,pts:o,type:Re.emsg,duration:d})}else if(this.config.enableEmsgKLVMetadata&&n.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){const o=Br(n,t);s.samples.push({data:n.payload,len:n.payload.byteLength,dts:o,pts:o,type:Re.misbklv,duration:Number.POSITIVE_INFINITY})}})}return s}demuxSampleAes(e,t,s){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0}}function Br(a,e){return K(a.presentationTime)?a.presentationTime/a.timeScale:e+a.presentationTimeDelta/a.timeScale}class Ld{constructor(e,t,s){this.keyData=void 0,this.decrypter=void 0,this.keyData=s,this.decrypter=new Li(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,et.cbc)}decryptAacSample(e,t,s){const i=e[t].unit;if(i.length<=16)return;const r=i.subarray(16,i.length-i.length%16),n=r.buffer.slice(r.byteOffset,r.byteOffset+r.length);this.decryptBuffer(n).then(o=>{const d=new Uint8Array(o);i.set(d,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,s)}).catch(s)}decryptAacSamples(e,t,s){for(;;t++){if(t>=e.length){s();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,s),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){const t=Math.floor((e.length-48)/160)*16+16,s=new Int8Array(t);let i=0;for(let r=32;r<e.length-16;r+=160,i+=16)s.set(e.subarray(r,r+16),i);return s}getAvcDecryptedUnit(e,t){const s=new Uint8Array(t);let i=0;for(let r=32;r<e.length-16;r+=160,i+=16)e.set(s.subarray(i,i+16),r);return e}decryptAvcSample(e,t,s,i,r){const n=bn(r.data),o=this.getAvcEncryptedData(n);this.decryptBuffer(o.buffer).then(d=>{r.data=this.getAvcDecryptedUnit(n,d),this.decrypter.isSync()||this.decryptAvcSamples(e,t,s+1,i)}).catch(i)}decryptAvcSamples(e,t,s,i){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,s=0){if(t>=e.length){i();return}const r=e[t].units;for(;!(s>=r.length);s++){const n=r[s];if(!(n.data.length<=48||n.type!==1&&n.type!==5)&&(this.decryptAvcSample(e,t,s,i,n),!this.decrypter.isSync()))return}}}}class ha{constructor(){this.VideoSample=null}createVideoSample(e,t,s){return{key:e,frame:!1,pts:t,dts:s,units:[],length:0}}getLastNalUnit(e){var t;let s=this.VideoSample,i;if((!s||s.units.length===0)&&(s=e[e.length-1]),(t=s)!=null&&t.units){const r=s.units;i=r[r.length-1]}return i}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){const s=t.samples,i=s.length;if(i){const r=s[i-1];e.pts=r.pts,e.dts=r.dts}else{t.dropped++;return}}t.samples.push(e)}}parseNALu(e,t,s){const i=t.byteLength;let r=e.naluState||0;const n=r,o=[];let d=0,l,c,u,h=-1,f=0;for(r===-1&&(h=0,f=this.getNALuType(t,0),r=0,d=1);d<i;){if(l=t[d++],!r){r=l?0:1;continue}if(r===1){r=l?0:2;continue}if(!l)r=3;else if(l===1){if(c=d-r-1,h>=0){const g={data:t.subarray(h,c),type:f};o.push(g)}else{const g=this.getLastNalUnit(e.samples);g&&(n&&d<=4-n&&g.state&&(g.data=g.data.subarray(0,g.data.byteLength-n)),c>0&&(g.data=Ce(g.data,t.subarray(0,c)),g.state=0))}d<i?(u=this.getNALuType(t,d),h=d,f=u,r=0):r=-1}else r=0}if(h>=0&&r>=0){const g={data:t.subarray(h,i),type:f,state:r};o.push(g)}if(o.length===0){const g=this.getLastNalUnit(e.samples);g&&(g.data=Ce(g.data,t))}return e.naluState=r,o}}class Ct{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const e=this.data,t=this.bytesAvailable,s=e.byteLength-t,i=new Uint8Array(4),r=Math.min(4,t);if(r===0)throw new Error("no bytes available");i.set(e.subarray(s,s+r)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=r*8,this.bytesAvailable-=r}skipBits(e){let t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e);const s=this.word>>>32-t;if(e>32&&se.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?s<<t|this.readBits(t):s}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if((this.word&2147483648>>>e)!==0)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const e=this.skipLZ();return this.readBits(e+1)-1}readEG(){const e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}}class Id extends ha{parsePES(e,t,s,i){const r=this.parseNALu(e,s.data,i);let n=this.VideoSample,o,d=!1;s.data=null,n&&r.length&&!e.audFound&&(this.pushAccessUnit(n,e),n=this.VideoSample=this.createVideoSample(!1,s.pts,s.dts)),r.forEach(l=>{var c,u;switch(l.type){case 1:{let m=!1;o=!0;const p=l.data;if(d&&p.length>4){const v=this.readSliceType(p);(v===2||v===4||v===7||v===9)&&(m=!0)}if(m){var h;(h=n)!=null&&h.frame&&!n.key&&(this.pushAccessUnit(n,e),n=this.VideoSample=null)}n||(n=this.VideoSample=this.createVideoSample(!0,s.pts,s.dts)),n.frame=!0,n.key=m;break}case 5:o=!0,(c=n)!=null&&c.frame&&!n.key&&(this.pushAccessUnit(n,e),n=this.VideoSample=null),n||(n=this.VideoSample=this.createVideoSample(!0,s.pts,s.dts)),n.key=!0,n.frame=!0;break;case 6:{o=!0,Ti(l.data,1,s.pts,t.samples);break}case 7:{var f,g;o=!0,d=!0;const m=l.data,p=this.readSPS(m);if(!e.sps||e.width!==p.width||e.height!==p.height||((f=e.pixelRatio)==null?void 0:f[0])!==p.pixelRatio[0]||((g=e.pixelRatio)==null?void 0:g[1])!==p.pixelRatio[1]){e.width=p.width,e.height=p.height,e.pixelRatio=p.pixelRatio,e.sps=[m];const v=m.subarray(1,4);let E="avc1.";for(let T=0;T<3;T++){let S=v[T].toString(16);S.length<2&&(S="0"+S),E+=S}e.codec=E}break}case 8:o=!0,e.pps=[l.data];break;case 9:o=!0,e.audFound=!0,(u=n)!=null&&u.frame&&(this.pushAccessUnit(n,e),n=null),n||(n=this.VideoSample=this.createVideoSample(!1,s.pts,s.dts));break;case 12:o=!0;break;default:o=!1;break}n&&o&&n.units.push(l)}),i&&n&&(this.pushAccessUnit(n,e),this.VideoSample=null)}getNALuType(e,t){return e[t]&31}readSliceType(e){const t=new Ct(e);return t.readUByte(),t.readUEG(),t.readUEG()}skipScalingList(e,t){let s=8,i=8,r;for(let n=0;n<e;n++)i!==0&&(r=t.readEG(),i=(s+r+256)%256),s=i===0?s:i}readSPS(e){const t=new Ct(e);let s=0,i=0,r=0,n=0,o,d,l;const c=t.readUByte.bind(t),u=t.readBits.bind(t),h=t.readUEG.bind(t),f=t.readBoolean.bind(t),g=t.skipBits.bind(t),m=t.skipEG.bind(t),p=t.skipUEG.bind(t),v=this.skipScalingList.bind(this);c();const E=c();if(u(5),g(3),c(),p(),E===100||E===110||E===122||E===244||E===44||E===83||E===86||E===118||E===128){const I=h();if(I===3&&g(1),p(),p(),g(1),f())for(d=I!==3?8:12,l=0;l<d;l++)f()&&(l<6?v(16,t):v(64,t))}p();const T=h();if(T===0)h();else if(T===1)for(g(1),m(),m(),o=h(),l=0;l<o;l++)m();p(),g(1);const S=h(),x=h(),b=u(1);b===0&&g(1),g(1),f()&&(s=h(),i=h(),r=h(),n=h());let A=[1,1];if(f()&&f())switch(c()){case 1:A=[1,1];break;case 2:A=[12,11];break;case 3:A=[10,11];break;case 4:A=[16,11];break;case 5:A=[40,33];break;case 6:A=[24,11];break;case 7:A=[20,11];break;case 8:A=[32,11];break;case 9:A=[80,33];break;case 10:A=[18,11];break;case 11:A=[15,11];break;case 12:A=[64,33];break;case 13:A=[160,99];break;case 14:A=[4,3];break;case 15:A=[3,2];break;case 16:A=[2,1];break;case 255:{A=[c()<<8|c(),c()<<8|c()];break}}return{width:Math.ceil((S+1)*16-s*2-i*2),height:(2-b)*(x+1)*16-(b?2:4)*(r+n),pixelRatio:A}}}class bd extends ha{constructor(...e){super(...e),this.initVPS=null}parsePES(e,t,s,i){const r=this.parseNALu(e,s.data,i);let n=this.VideoSample,o,d=!1;s.data=null,n&&r.length&&!e.audFound&&(this.pushAccessUnit(n,e),n=this.VideoSample=this.createVideoSample(!1,s.pts,s.dts)),r.forEach(l=>{var c,u;switch(l.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:n||(n=this.VideoSample=this.createVideoSample(!1,s.pts,s.dts)),n.frame=!0,o=!0;break;case 16:case 17:case 18:case 21:if(o=!0,d){var h;(h=n)!=null&&h.frame&&!n.key&&(this.pushAccessUnit(n,e),n=this.VideoSample=null)}n||(n=this.VideoSample=this.createVideoSample(!0,s.pts,s.dts)),n.key=!0,n.frame=!0;break;case 19:case 20:o=!0,(c=n)!=null&&c.frame&&!n.key&&(this.pushAccessUnit(n,e),n=this.VideoSample=null),n||(n=this.VideoSample=this.createVideoSample(!0,s.pts,s.dts)),n.key=!0,n.frame=!0;break;case 39:o=!0,Ti(l.data,2,s.pts,t.samples);break;case 32:o=!0,e.vps||(typeof e.params!="object"&&(e.params={}),e.params=ie(e.params,this.readVPS(l.data)),this.initVPS=l.data),e.vps=[l.data];break;case 33:if(o=!0,d=!0,e.vps!==void 0&&e.vps[0]!==this.initVPS&&e.sps!==void 0&&!this.matchSPS(e.sps[0],l.data)&&(this.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){const f=this.readSPS(l.data);e.width=f.width,e.height=f.height,e.pixelRatio=f.pixelRatio,e.codec=f.codecString,e.sps=[],typeof e.params!="object"&&(e.params={});for(const g in f.params)e.params[g]=f.params[g]}this.pushParameterSet(e.sps,l.data,e.vps),n||(n=this.VideoSample=this.createVideoSample(!0,s.pts,s.dts)),n.key=!0;break;case 34:if(o=!0,typeof e.params=="object"){if(!e.pps){e.pps=[];const f=this.readPPS(l.data);for(const g in f)e.params[g]=f[g]}this.pushParameterSet(e.pps,l.data,e.vps)}break;case 35:o=!0,e.audFound=!0,(u=n)!=null&&u.frame&&(this.pushAccessUnit(n,e),n=null),n||(n=this.VideoSample=this.createVideoSample(!1,s.pts,s.dts));break;default:o=!1;break}n&&o&&n.units.push(l)}),i&&n&&(this.pushAccessUnit(n,e),this.VideoSample=null)}pushParameterSet(e,t,s){(s&&s[0]===this.initVPS||!s&&!e.length)&&e.push(t)}getNALuType(e,t){return(e[t]&126)>>>1}ebsp2rbsp(e){const t=new Uint8Array(e.byteLength);let s=0;for(let i=0;i<e.byteLength;i++)i>=2&&e[i]===3&&e[i-1]===0&&e[i-2]===0||(t[s]=e[i],s++);return new Uint8Array(t.buffer,0,s)}pushAccessUnit(e,t){super.pushAccessUnit(e,t),this.initVPS&&(this.initVPS=null)}readVPS(e){const t=new Ct(e);t.readUByte(),t.readUByte(),t.readBits(4),t.skipBits(2),t.readBits(6);const s=t.readBits(3),i=t.readBoolean();return{numTemporalLayers:s+1,temporalIdNested:i}}readSPS(e){const t=new Ct(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);const s=t.readBits(3);t.readBoolean();const i=t.readBits(2),r=t.readBoolean(),n=t.readBits(5),o=t.readUByte(),d=t.readUByte(),l=t.readUByte(),c=t.readUByte(),u=t.readUByte(),h=t.readUByte(),f=t.readUByte(),g=t.readUByte(),m=t.readUByte(),p=t.readUByte(),v=t.readUByte(),E=[],T=[];for(let ee=0;ee<s;ee++)E.push(t.readBoolean()),T.push(t.readBoolean());if(s>0)for(let ee=s;ee<8;ee++)t.readBits(2);for(let ee=0;ee<s;ee++)E[ee]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),T[ee]&&t.readUByte();t.readUEG();const S=t.readUEG();S==3&&t.skipBits(1);const x=t.readUEG(),b=t.readUEG(),A=t.readBoolean();let I=0,R=0,L=0,w=0;A&&(I+=t.readUEG(),R+=t.readUEG(),L+=t.readUEG(),w+=t.readUEG());const U=t.readUEG(),V=t.readUEG(),B=t.readUEG(),N=t.readBoolean();for(let ee=N?0:s;ee<=s;ee++)t.skipUEG(),t.skipUEG(),t.skipUEG();if(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.readBoolean()&&t.readBoolean())for(let ve=0;ve<4;ve++)for(let _e=0;_e<(ve===3?2:6);_e++)if(!t.readBoolean())t.readUEG();else{const we=Math.min(64,1<<4+(ve<<1));ve>1&&t.readEG();for(let ct=0;ct<we;ct++)t.readEG()}t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());const k=t.readUEG();let O=0;for(let ee=0;ee<k;ee++){let ve=!1;if(ee!==0&&(ve=t.readBoolean()),ve){ee===k&&t.readUEG(),t.readBoolean(),t.readUEG();let _e=0;for(let tt=0;tt<=O;tt++){const we=t.readBoolean();let ct=!1;we||(ct=t.readBoolean()),(we||ct)&&_e++}O=_e}else{const _e=t.readUEG(),tt=t.readUEG();O=_e+tt;for(let we=0;we<_e;we++)t.readUEG(),t.readBoolean();for(let we=0;we<tt;we++)t.readUEG(),t.readBoolean()}}if(t.readBoolean()){const ee=t.readUEG();for(let ve=0;ve<ee;ve++){for(let _e=0;_e<B+4;_e++)t.readBits(1);t.readBits(1)}}let F=0,$=1,q=1,Z=!0,Y=1,j=0;t.readBoolean(),t.readBoolean();let oe=!1;if(t.readBoolean()){if(t.readBoolean()){const st=t.readUByte(),Vi=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],Kt=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];st>0&&st<16?($=Vi[st-1],q=Kt[st-1]):st===255&&($=t.readBits(16),q=t.readBits(16))}if(t.readBoolean()&&t.readBoolean(),t.readBoolean()&&(t.readBits(3),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.readUByte(),t.readUByte())),t.readBoolean()&&(t.readUEG(),t.readUEG()),t.readBoolean(),t.readBoolean(),t.readBoolean(),oe=t.readBoolean(),oe&&(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG()),t.readBoolean()&&(Y=t.readBits(32),j=t.readBits(32),t.readBoolean()&&t.readUEG(),t.readBoolean())){const Kt=t.readBoolean(),Hi=t.readBoolean();let It=!1;(Kt||Hi)&&(It=t.readBoolean(),It&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),It&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(let Wi=0;Wi<=s;Wi++){Z=t.readBoolean();const Wa=Z||t.readBoolean();let Yi=!1;Wa?t.readEG():Yi=t.readBoolean();const qi=Yi?1:t.readUEG()+1;if(Kt)for(let bt=0;bt<qi;bt++)t.readUEG(),t.readUEG(),It&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(Hi)for(let bt=0;bt<qi;bt++)t.readUEG(),t.readUEG(),It&&(t.readUEG(),t.readUEG()),t.skipBits(1)}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),F=t.readUEG())}let ye=x,Se=b;if(A){let ee=1,ve=1;S===1?ee=ve=2:S==2&&(ee=2),ye=x-ee*R-ee*I,Se=b-ve*w-ve*L}const ae=i?["A","B","C"][i]:"",At=o<<24|d<<16|l<<8|c;let dt=0;for(let ee=0;ee<32;ee++)dt=(dt|(At>>ee&1)<<31-ee)>>>0;let Lt=dt.toString(16);n===1&&Lt==="2"&&(Lt="6");const Gt=r?"H":"L";return{codecString:"hvc1.".concat(ae).concat(n,".").concat(Lt,".").concat(Gt).concat(v,".B0"),params:{general_tier_flag:r,general_profile_idc:n,general_profile_space:i,general_profile_compatibility_flags:[o,d,l,c],general_constraint_indicator_flags:[u,h,f,g,m,p],general_level_idc:v,bit_depth:U+8,bit_depth_luma_minus8:U,bit_depth_chroma_minus8:V,min_spatial_segmentation_idc:F,chroma_format_idc:S,frame_rate:{fixed:Z,fps:j/Y}},width:ye,height:Se,pixelRatio:[$,q]}}readPPS(e){const t=new Ct(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.skipUEG(),t.skipUEG(),t.skipBits(2),t.skipBits(3),t.skipBits(2),t.skipUEG(),t.skipUEG(),t.skipEG(),t.skipBits(2),t.readBoolean()&&t.skipUEG(),t.skipEG(),t.skipEG(),t.skipBits(4);const i=t.readBoolean(),r=t.readBoolean();let n=1;return r&&i?n=0:r?n=3:i&&(n=2),{parallelismType:n}}matchSPS(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}}const me=188;class Ze{constructor(e,t,s,i){this.logger=void 0,this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=t,this.typeSupported=s,this.logger=i,this.videoParser=null}static probe(e,t){const s=Ze.syncOffset(e);return s>0&&t.warn("MPEG2-TS detected but first sync word found @ offset ".concat(s)),s!==-1}static syncOffset(e){const t=e.length;let s=Math.min(me*5,t-me)+1,i=0;for(;i<s;){let r=!1,n=-1,o=0;for(let d=i;d<t;d+=me)if(e[d]===71&&(t-d===me||e[d+me]===71)){if(o++,n===-1&&(n=d,n!==0&&(s=Math.min(n+me*99,e.length-me)+1)),r||(r=li(e,d)===0),r&&o>1&&(n===0&&o>2||d+me>s))return n}else{if(o)return-1;break}i++}return-1}static createTrack(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:Sn[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,s,i){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=Ze.createTrack("video"),this._videoTrack.duration=i,this._audioTrack=Ze.createTrack("audio",i),this._id3Track=Ze.createTrack("id3"),this._txtTrack=Ze.createTrack("text"),this._audioTrack.segmentCodec="aac",this.videoParser=null,this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=s}resetTimeStamp(){}resetContiguity(){const{_audioTrack:e,_videoTrack:t,_id3Track:s}=this;e&&(e.pesData=null),t&&(t.pesData=null),s&&(s.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t,s=!1,i=!1){s||(this.sampleAes=null);let r;const n=this._videoTrack,o=this._audioTrack,d=this._id3Track,l=this._txtTrack;let c=n.pid,u=n.pesData,h=o.pid,f=d.pid,g=o.pesData,m=d.pesData,p=null,v=this.pmtParsed,E=this._pmtId,T=e.length;if(this.remainderData&&(e=Ce(this.remainderData,e),T=e.length,this.remainderData=null),T<me&&!i)return this.remainderData=e,{audioTrack:o,videoTrack:n,id3Track:d,textTrack:l};const S=Math.max(0,Ze.syncOffset(e));T-=(T-S)%me,T<e.byteLength&&!i&&(this.remainderData=new Uint8Array(e.buffer,T,e.buffer.byteLength-T));let x=0;for(let A=S;A<T;A+=me)if(e[A]===71){const I=!!(e[A+1]&64),R=li(e,A),L=(e[A+3]&48)>>4;let w;if(L>1){if(w=A+5+e[A+4],w===A+me)continue}else w=A+4;switch(R){case c:I&&(u&&(r=ft(u,this.logger))&&(this.readyVideoParser(n.segmentCodec),this.videoParser!==null&&this.videoParser.parsePES(n,l,r,!1)),u={data:[],size:0}),u&&(u.data.push(e.subarray(w,A+me)),u.size+=A+me-w);break;case h:if(I){if(g&&(r=ft(g,this.logger)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,r);break;case"mp3":this.parseMPEGPES(o,r);break;case"ac3":this.parseAC3PES(o,r);break}g={data:[],size:0}}g&&(g.data.push(e.subarray(w,A+me)),g.size+=A+me-w);break;case f:I&&(m&&(r=ft(m,this.logger))&&this.parseID3PES(d,r),m={data:[],size:0}),m&&(m.data.push(e.subarray(w,A+me)),m.size+=A+me-w);break;case 0:I&&(w+=e[w]+1),E=this._pmtId=Rd(e,w);break;case E:{I&&(w+=e[w]+1);const U=Dd(e,w,this.typeSupported,s,this.observer,this.logger);c=U.videoPid,c>0&&(n.pid=c,n.segmentCodec=U.segmentVideoCodec),h=U.audioPid,h>0&&(o.pid=h,o.segmentCodec=U.segmentAudioCodec),f=U.id3Pid,f>0&&(d.pid=f),p!==null&&!v&&(this.logger.warn("MPEG-TS PMT found at ".concat(A," after unknown PID '").concat(p,"'. Backtracking to sync byte @").concat(S," to parse all TS packets.")),p=null,A=S-188),v=this.pmtParsed=!0;break}case 17:case 8191:break;default:p=R;break}}else x++;x>0&&di(this.observer,new Error("Found ".concat(x," TS packet/s that do not start with 0x47")),void 0,this.logger),n.pesData=u,o.pesData=g,d.pesData=m;const b={audioTrack:o,videoTrack:n,id3Track:d,textTrack:l};return i&&this.extractRemainingSamples(b),b}flush(){const{remainderData:e}=this;this.remainderData=null;let t;return e?t=this.demux(e,-1,!1,!0):t={videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){const{audioTrack:t,videoTrack:s,id3Track:i,textTrack:r}=e,n=s.pesData,o=t.pesData,d=i.pesData;let l;if(n&&(l=ft(n,this.logger))?(this.readyVideoParser(s.segmentCodec),this.videoParser!==null&&(this.videoParser.parsePES(s,r,l,!0),s.pesData=null)):s.pesData=n,o&&(l=ft(o,this.logger))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,l);break;case"mp3":this.parseMPEGPES(t,l);break;case"ac3":this.parseAC3PES(t,l);break}t.pesData=null}else o!=null&&o.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=o;d&&(l=ft(d,this.logger))?(this.parseID3PES(i,l),i.pesData=null):i.pesData=d}demuxSampleAes(e,t,s){const i=this.demux(e,s,!0,!this.config.progressive),r=this.sampleAes=new Ld(this.observer,this.config,t);return this.decrypt(i,r)}readyVideoParser(e){this.videoParser===null&&(e==="avc"?this.videoParser=new Id:e==="hevc"&&(this.videoParser=new bd))}decrypt(e,t){return new Promise(s=>{const{audioTrack:i,videoTrack:r}=e;i.samples&&i.segmentCodec==="aac"?t.decryptAacSamples(i.samples,0,()=>{r.samples?t.decryptAvcSamples(r.samples,0,0,()=>{s(e)}):s(e)}):r.samples&&t.decryptAvcSamples(r.samples,0,0,()=>{s(e)})})}destroy(){this.observer&&this.observer.removeAllListeners(),this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0}parseAACPES(e,t){let s=0;const i=this.aacOverFlow;let r=t.data;if(i){this.aacOverFlow=null;const u=i.missing,h=i.sample.unit.byteLength;if(u===-1)r=Ce(i.sample.unit,r);else{const f=h-u;i.sample.unit.set(r.subarray(0,u),f),e.samples.push(i.sample),s=i.missing}}let n,o;for(n=s,o=r.length;n<o-1&&!xs(r,n);n++);if(n!==s){let u;const h=n<o-1;if(h?u="AAC PES did not start with ADTS header,offset:".concat(n):u="No ADTS header found in AAC PES",di(this.observer,new Error(u),h,this.logger),!h)return}ta(e,this.observer,r,n,this.audioCodec);let d;if(t.pts!==void 0)d=t.pts;else if(i){const u=sa(e.samplerate);d=i.sample.pts+u}else{this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}let l=0,c;for(;n<o;)if(c=ia(e,r,n,d,l),n+=c.length,c.missing){this.aacOverFlow=c;break}else for(l++;n<o-1&&!xs(r,n);n++);}parseMPEGPES(e,t){const s=t.data,i=s.length;let r=0,n=0;const o=t.pts;if(o===void 0){this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;n<i;)if(la(s,n)){const d=aa(e,s,n,o,r);if(d)n+=d.length,r++;else break}else n++}parseAC3PES(e,t){{const s=t.data,i=t.pts;if(i===void 0){this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS");return}const r=s.length;let n=0,o=0,d;for(;o<r&&(d=ua(e,s,o,i,n++))>0;)o+=d}}parseID3PES(e,t){if(t.pts===void 0){this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const s=ie({},t,{type:this._videoTrack?Re.emsg:Re.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(s)}}function li(a,e){return((a[e+1]&31)<<8)+a[e+2]}function Rd(a,e){return(a[e+10]&31)<<8|a[e+11]}function Dd(a,e,t,s,i,r){const n={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},o=(a[e+1]&15)<<8|a[e+2],d=e+3+o-4,l=(a[e+10]&15)<<8|a[e+11];for(e+=12+l;e<d;){const c=li(a,e),u=(a[e+3]&15)<<8|a[e+4];switch(a[e]){case 207:if(!s){Ns("ADTS AAC",r);break}case 15:n.audioPid===-1&&(n.audioPid=c);break;case 21:n.id3Pid===-1&&(n.id3Pid=c);break;case 219:if(!s){Ns("H.264",r);break}case 27:n.videoPid===-1&&(n.videoPid=c);break;case 3:case 4:!t.mpeg&&!t.mp3?r.log("MPEG audio found, not supported in this browser"):n.audioPid===-1&&(n.audioPid=c,n.segmentAudioCodec="mp3");break;case 193:if(!s){Ns("AC-3",r);break}case 129:t.ac3?n.audioPid===-1&&(n.audioPid=c,n.segmentAudioCodec="ac3"):r.log("AC-3 audio found, not supported in this browser");break;case 6:if(n.audioPid===-1&&u>0){let h=e+5,f=u;for(;f>2;){switch(a[h]){case 106:t.ac3!==!0?r.log("AC-3 audio found, not supported in this browser for now"):(n.audioPid=c,n.segmentAudioCodec="ac3");break}const m=a[h+1]+2;h+=m,f-=m}}break;case 194:case 135:return di(i,new Error("Unsupported EC-3 in M2TS found"),void 0,r),n;case 36:n.videoPid===-1&&(n.videoPid=c,n.segmentVideoCodec="hevc",r.log("HEVC in M2TS found"));break}e+=u+5}return n}function di(a,e,t,s){s.warn("parsing error: ".concat(e.message)),a.emit(y.ERROR,y.ERROR,{type:W.MEDIA_ERROR,details:_.FRAG_PARSING_ERROR,fatal:!1,levelRetry:t,error:e,reason:e.message})}function Ns(a,e){e.log("".concat(a," with AES-128-CBC encryption found in unencrypted stream"))}function ft(a,e){let t=0,s,i,r,n,o;const d=a.data;if(!a||a.size===0)return null;for(;d[0].length<19&&d.length>1;)d[0]=Ce(d[0],d[1]),d.splice(1,1);if(s=d[0],(s[0]<<16)+(s[1]<<8)+s[2]===1){if(i=(s[4]<<8)+s[5],i&&i>a.size-6)return null;const c=s[7];c&192&&(n=(s[9]&14)*536870912+(s[10]&255)*4194304+(s[11]&254)*16384+(s[12]&255)*128+(s[13]&254)/2,c&64?(o=(s[14]&14)*536870912+(s[15]&255)*4194304+(s[16]&254)*16384+(s[17]&255)*128+(s[18]&254)/2,n-o>60*9e4&&(e.warn("".concat(Math.round((n-o)/9e4),"s delta between PTS and DTS, align them")),n=o)):o=n),r=s[8];let u=r+9;if(a.size<=u)return null;a.size-=u;const h=new Uint8Array(a.size);for(let f=0,g=d.length;f<g;f++){s=d[f];let m=s.byteLength;if(u)if(u>m){u-=m;continue}else s=s.subarray(u),m-=u,u=0;h.set(s,t),t+=m}return i&&(i-=r+3),{data:h,pts:n,dts:o,len:i}}return null}class _d{static getSilentFrame(e,t){switch(e){case"mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(t===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(t===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}}const ze=Math.pow(2,32)-1;class D{static init(){D.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};let e;for(e in D.types)D.types.hasOwnProperty(e)&&(D.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);const t=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),s=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);D.HDLR_TYPES={video:t,audio:s};const i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),r=new Uint8Array([0,0,0,0,0,0,0,0]);D.STTS=D.STSC=D.STCO=r,D.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),D.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),D.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),D.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const n=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),d=new Uint8Array([0,0,0,1]);D.FTYP=D.box(D.types.ftyp,n,d,n,o),D.DINF=D.box(D.types.dinf,D.box(D.types.dref,i))}static box(e,...t){let s=8,i=t.length;const r=i;for(;i--;)s+=t[i].byteLength;const n=new Uint8Array(s);for(n[0]=s>>24&255,n[1]=s>>16&255,n[2]=s>>8&255,n[3]=s&255,n.set(e,4),i=0,s=8;i<r;i++)n.set(t[i],s),s+=t[i].byteLength;return n}static hdlr(e){return D.box(D.types.hdlr,D.HDLR_TYPES[e])}static mdat(e){return D.box(D.types.mdat,e)}static mdhd(e,t){t*=e;const s=Math.floor(t/(ze+1)),i=Math.floor(t%(ze+1));return D.box(D.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,s>>24,s>>16&255,s>>8&255,s&255,i>>24,i>>16&255,i>>8&255,i&255,85,196,0,0]))}static mdia(e){return D.box(D.types.mdia,D.mdhd(e.timescale||0,e.duration||0),D.hdlr(e.type),D.minf(e))}static mfhd(e){return D.box(D.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}static minf(e){return e.type==="audio"?D.box(D.types.minf,D.box(D.types.smhd,D.SMHD),D.DINF,D.stbl(e)):D.box(D.types.minf,D.box(D.types.vmhd,D.VMHD),D.DINF,D.stbl(e))}static moof(e,t,s){return D.box(D.types.moof,D.mfhd(e),D.traf(s,t))}static moov(e){let t=e.length;const s=[];for(;t--;)s[t]=D.trak(e[t]);return D.box.apply(null,[D.types.moov,D.mvhd(e[0].timescale||0,e[0].duration||0)].concat(s).concat(D.mvex(e)))}static mvex(e){let t=e.length;const s=[];for(;t--;)s[t]=D.trex(e[t]);return D.box.apply(null,[D.types.mvex,...s])}static mvhd(e,t){t*=e;const s=Math.floor(t/(ze+1)),i=Math.floor(t%(ze+1)),r=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,s>>24,s>>16&255,s>>8&255,s&255,i>>24,i>>16&255,i>>8&255,i&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return D.box(D.types.mvhd,r)}static sdtp(e){const t=e.samples||[],s=new Uint8Array(4+t.length);let i,r;for(i=0;i<t.length;i++)r=t[i].flags,s[i+4]=r.dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy;return D.box(D.types.sdtp,s)}static stbl(e){return D.box(D.types.stbl,D.stsd(e),D.box(D.types.stts,D.STTS),D.box(D.types.stsc,D.STSC),D.box(D.types.stsz,D.STSZ),D.box(D.types.stco,D.STCO))}static avc1(e){let t=[],s=[],i,r,n;for(i=0;i<e.sps.length;i++)r=e.sps[i],n=r.byteLength,t.push(n>>>8&255),t.push(n&255),t=t.concat(Array.prototype.slice.call(r));for(i=0;i<e.pps.length;i++)r=e.pps[i],n=r.byteLength,s.push(n>>>8&255),s.push(n&255),s=s.concat(Array.prototype.slice.call(r));const o=D.box(D.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(s))),d=e.width,l=e.height,c=e.pixelRatio[0],u=e.pixelRatio[1];return D.box(D.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,d>>8&255,d&255,l>>8&255,l&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,D.box(D.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),D.box(D.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,c&255,u>>24,u>>16&255,u>>8&255,u&255])))}static esds(e){const t=e.config;return new Uint8Array([0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2,...t,6,1,2])}static audioStsd(e){const t=e.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount||0,0,16,0,0,0,0,t>>8&255,t&255,0,0])}static mp4a(e){return D.box(D.types.mp4a,D.audioStsd(e),D.box(D.types.esds,D.esds(e)))}static mp3(e){return D.box(D.types[".mp3"],D.audioStsd(e))}static ac3(e){return D.box(D.types["ac-3"],D.audioStsd(e),D.box(D.types.dac3,e.config))}static stsd(e){const{segmentCodec:t}=e;if(e.type==="audio"){if(t==="aac")return D.box(D.types.stsd,D.STSD,D.mp4a(e));if(t==="ac3"&&e.config)return D.box(D.types.stsd,D.STSD,D.ac3(e));if(t==="mp3"&&e.codec==="mp3")return D.box(D.types.stsd,D.STSD,D.mp3(e))}else if(e.pps&&e.sps){if(t==="avc")return D.box(D.types.stsd,D.STSD,D.avc1(e));if(t==="hevc"&&e.vps)return D.box(D.types.stsd,D.STSD,D.hvc1(e))}else throw new Error("video track missing pps or sps");throw new Error("unsupported ".concat(e.type," segment codec (").concat(t,"/").concat(e.codec,")"))}static tkhd(e){const t=e.id,s=(e.duration||0)*(e.timescale||0),i=e.width||0,r=e.height||0,n=Math.floor(s/(ze+1)),o=Math.floor(s%(ze+1));return D.box(D.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,o>>24,o>>16&255,o>>8&255,o&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,i>>8&255,i&255,0,0,r>>8&255,r&255,0,0]))}static traf(e,t){const s=D.sdtp(e),i=e.id,r=Math.floor(t/(ze+1)),n=Math.floor(t%(ze+1));return D.box(D.types.traf,D.box(D.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,i&255])),D.box(D.types.tfdt,new Uint8Array([1,0,0,0,r>>24,r>>16&255,r>>8&255,r&255,n>>24,n>>16&255,n>>8&255,n&255])),D.trun(e,s.length+16+20+8+16+8+8),s)}static trak(e){return e.duration=e.duration||4294967295,D.box(D.types.trak,D.tkhd(e),D.mdia(e))}static trex(e){const t=e.id;return D.box(D.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){const s=e.samples||[],i=s.length,r=12+16*i,n=new Uint8Array(r);let o,d,l,c,u,h;for(t+=8+r,n.set([e.type==="video"?1:0,0,15,1,i>>>24&255,i>>>16&255,i>>>8&255,i&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),o=0;o<i;o++)d=s[o],l=d.duration,c=d.size,u=d.flags,h=d.cts,n.set([l>>>24&255,l>>>16&255,l>>>8&255,l&255,c>>>24&255,c>>>16&255,c>>>8&255,c&255,u.isLeading<<2|u.dependsOn,u.isDependedOn<<6|u.hasRedundancy<<4|u.paddingValue<<1|u.isNonSync,u.degradPrio&61440,u.degradPrio&15,h>>>24&255,h>>>16&255,h>>>8&255,h&255],12+16*o);return D.box(D.types.trun,n)}static initSegment(e){D.types||D.init();const t=D.moov(e);return Ce(D.FTYP,t)}static hvc1(e){const t=e.params,s=[e.vps,e.sps,e.pps],i=4,r=new Uint8Array([1,t.general_profile_space<<6|(t.general_tier_flag?32:0)|t.general_profile_idc,t.general_profile_compatibility_flags[0],t.general_profile_compatibility_flags[1],t.general_profile_compatibility_flags[2],t.general_profile_compatibility_flags[3],t.general_constraint_indicator_flags[0],t.general_constraint_indicator_flags[1],t.general_constraint_indicator_flags[2],t.general_constraint_indicator_flags[3],t.general_constraint_indicator_flags[4],t.general_constraint_indicator_flags[5],t.general_level_idc,240|t.min_spatial_segmentation_idc>>8,255&t.min_spatial_segmentation_idc,252|t.parallelismType,252|t.chroma_format_idc,248|t.bit_depth_luma_minus8,248|t.bit_depth_chroma_minus8,0,parseInt(t.frame_rate.fps),i-1|t.temporal_id_nested<<2|t.num_temporal_layers<<3|(t.frame_rate.fixed?64:0),s.length]);let n=r.length;for(let g=0;g<s.length;g+=1){n+=3;for(let m=0;m<s[g].length;m+=1)n+=2+s[g][m].length}const o=new Uint8Array(n);o.set(r,0),n=r.length;const d=s.length-1;for(let g=0;g<s.length;g+=1){o.set(new Uint8Array([32+g|(g===d?128:0),0,s[g].length]),n),n+=3;for(let m=0;m<s[g].length;m+=1)o.set(new Uint8Array([s[g][m].length>>8,s[g][m].length&255]),n),n+=2,o.set(s[g][m],n),n+=s[g][m].length}const l=D.box(D.types.hvcC,o),c=e.width,u=e.height,h=e.pixelRatio[0],f=e.pixelRatio[1];return D.box(D.types.hvc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c>>8&255,c&255,u>>8&255,u&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),l,D.box(D.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),D.box(D.types.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,h&255,f>>24,f>>16&255,f>>8&255,f&255])))}}D.types=void 0;D.HDLR_TYPES=void 0;D.STTS=void 0;D.STSC=void 0;D.STCO=void 0;D.STSZ=void 0;D.VMHD=void 0;D.SMHD=void 0;D.STSD=void 0;D.FTYP=void 0;D.DINF=void 0;const fa=9e4;function Fi(a,e,t=1,s=!1){const i=a*e*t;return s?Math.round(i):i}function kd(a,e,t=1,s=!1){return Fi(a,e,1/t,s)}function Rt(a,e=!1){return Fi(a,1e3,1/fa,e)}function Cd(a,e=1){return Fi(a,fa,1/e)}const Pd=10*1e3,wd=1024,Od=1152,Md=1536;let gt=null,Bs=null;function Ur(a,e,t,s){return{duration:e,size:t,cts:s,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:a?2:1,isNonSync:a?0:1}}}class ls extends Pe{constructor(e,t,s,i){if(super("mp4-remuxer",i),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextVideoTs=null,this.nextAudioTs=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=s,this.ISGenerated=!1,gt===null){const n=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);gt=n?parseInt(n[1]):0}if(Bs===null){const r=navigator.userAgent.match(/Safari\/(\d+)/i);Bs=r?parseInt(r[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){this.log("initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){this.log("reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){this.log("ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1;const s=e[0].pts,i=e.reduce((r,n)=>{let o=n.pts,d=o-r;return d<-4294967296&&(t=!0,o=ke(o,s),d=o-r),d>0?r:o},s);return t&&this.debug("PTS rollover detected"),i}remux(e,t,s,i,r,n,o,d){let l,c,u,h,f,g,m=r,p=r;const v=e.pid>-1,E=t.pid>-1,T=t.samples.length,S=e.samples.length>0,x=o&&T>0||T>1;if((!v||S)&&(!E||x)||this.ISGenerated||o){if(this.ISGenerated){var A,I,R,L;const B=this.videoTrackConfig;(B&&(t.width!==B.width||t.height!==B.height||((A=t.pixelRatio)==null?void 0:A[0])!==((I=B.pixelRatio)==null?void 0:I[0])||((R=t.pixelRatio)==null?void 0:R[1])!==((L=B.pixelRatio)==null?void 0:L[1]))||!B&&x||this.nextAudioTs===null&&S)&&this.resetInitSegment()}this.ISGenerated||(u=this.generateIS(e,t,r,n));const w=this.isVideoContiguous;let U=-1,V;if(x&&(U=Fd(t.samples),!w&&this.config.forceKeyFrameOnDiscontinuity))if(g=!0,U>0){this.warn("Dropped ".concat(U," out of ").concat(T," video samples due to a missing keyframe"));const B=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(U),t.dropped+=U,p+=(t.samples[0].pts-B)/t.inputTimeScale,V=p}else U===-1&&(this.warn("No keyframe found out of ".concat(T," video samples")),g=!1);if(this.ISGenerated){if(S&&x){const B=this.getVideoStartPts(t.samples),M=(ke(e.samples[0].pts,B)-B)/t.inputTimeScale;m+=Math.max(0,M),p+=Math.max(0,-M)}if(S){if(e.samplerate||(this.warn("regenerate InitSegment as audio detected"),u=this.generateIS(e,t,r,n)),c=this.remuxAudio(e,m,this.isAudioContiguous,n,E||x||d===H.AUDIO?p:void 0),x){const B=c?c.endPTS-c.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),u=this.generateIS(e,t,r,n)),l=this.remuxVideo(t,p,w,B)}}else x&&(l=this.remuxVideo(t,p,w,0));l&&(l.firstKeyFrame=U,l.independent=U!==-1,l.firstKeyFramePTS=V)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(s.samples.length&&(f=ga(s,r,this._initPTS,this._initDTS)),i.samples.length&&(h=ma(i,r,this._initPTS))),{audio:c,video:l,initSegment:u,independent:g,text:h,id3:f}}generateIS(e,t,s,i){const r=e.samples,n=t.samples,o=this.typeSupported,d={},l=this._initPTS;let c=!l||i,u="audio/mp4",h,f,g,m=-1;if(c&&(h=f=1/0),e.config&&r.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":o.mpeg?(u="audio/mpeg",e.codec=""):o.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3";break}d.audio={id:"audio",container:u,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&o.mpeg?new Uint8Array(0):D.initSegment([e]),metadata:{channelCount:e.channelCount}},c&&(m=e.id,g=e.inputTimeScale,!l||g!==l.timescale?h=f=r[0].pts-Math.round(g*s):c=!1)}if(t.sps&&t.pps&&n.length){if(t.timescale=t.inputTimeScale,d.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:D.initSegment([t]),metadata:{width:t.width,height:t.height}},c)if(m=t.id,g=t.inputTimeScale,!l||g!==l.timescale){const p=this.getVideoStartPts(n),v=Math.round(g*s);f=Math.min(f,ke(n[0].dts,p)-v),h=Math.min(h,p-v)}else c=!1;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(d).length)return this.ISGenerated=!0,c?(l&&this.warn("Timestamps at playlist time: ".concat(i?"":"~").concat(s," ").concat(h/g," != initPTS: ").concat(l.baseTime/l.timescale," (").concat(l.baseTime,"/").concat(l.timescale,") trackId: ").concat(l.trackId)),this.log("Found initPTS at playlist time: ".concat(s," offset: ").concat(h/g," (").concat(h,"/").concat(g,") trackId: ").concat(m)),this._initPTS={baseTime:h,timescale:g,trackId:m},this._initDTS={baseTime:f,timescale:g,trackId:m}):h=g=void 0,{tracks:d,initPTS:h,timescale:g,trackId:m}}remuxVideo(e,t,s,i){const r=e.inputTimeScale,n=e.samples,o=[],d=n.length,l=this._initPTS,c=l.baseTime*r/l.timescale;let u=this.nextVideoTs,h=8,f=this.videoSampleDuration,g,m,p=Number.POSITIVE_INFINITY,v=Number.NEGATIVE_INFINITY,E=!1;if(!s||u===null){const F=c+t*r,$=n[0].pts-ke(n[0].dts,n[0].pts);gt&&u!==null&&Math.abs(F-$-(u+c))<15e3?s=!0:u=F-$-c}const T=u+c;for(let F=0;F<d;F++){const $=n[F];$.pts=ke($.pts,T),$.dts=ke($.dts,T),$.dts<n[F>0?F-1:F].dts&&(E=!0)}E&&n.sort(function(F,$){const q=F.dts-$.dts,Z=F.pts-$.pts;return q||Z}),g=n[0].dts,m=n[n.length-1].dts;const S=m-g,x=S?Math.round(S/(d-1)):f||e.inputTimeScale/30;if(s){const F=g-T,$=F>x,q=F<-1;if(($||q)&&($?this.warn("".concat((e.segmentCodec||"").toUpperCase(),": ").concat(Rt(F,!0)," ms (").concat(F,"dts) hole between fragments detected at ").concat(t.toFixed(3))):this.warn("".concat((e.segmentCodec||"").toUpperCase(),": ").concat(Rt(-F,!0)," ms (").concat(F,"dts) overlapping between fragments detected at ").concat(t.toFixed(3))),!q||T>=n[0].pts||gt)){g=T;const Z=n[0].pts-F;if($)n[0].dts=g,n[0].pts=Z;else{let Y=!0;for(let j=0;j<n.length&&!(n[j].dts>Z&&Y);j++){const oe=n[j].pts;if(n[j].dts-=F,n[j].pts-=F,j<n.length-1){const le=n[j+1].pts,ye=n[j].pts,Se=le<=ye,ae=le<=oe;Y=Se==ae}}}this.log("Video: Initial PTS/DTS adjusted: ".concat(Rt(Z,!0),"/").concat(Rt(g,!0),", delta: ").concat(Rt(F,!0)," ms"))}}g=Math.max(0,g);let b=0,A=0,I=g;for(let F=0;F<d;F++){const $=n[F],q=$.units,Z=q.length;let Y=0;for(let j=0;j<Z;j++)Y+=q[j].data.length;A+=Y,b+=Z,$.length=Y,$.dts<I?($.dts=I,I+=x/4|0||1):I=$.dts,p=Math.min($.pts,p),v=Math.max($.pts,v)}m=n[d-1].dts;const R=A+4*b+8;let L;try{L=new Uint8Array(R)}catch(F){this.observer.emit(y.ERROR,y.ERROR,{type:W.MUX_ERROR,details:_.REMUX_ALLOC_ERROR,fatal:!1,error:F,bytes:R,reason:"fail allocating video mdat ".concat(R)});return}const w=new DataView(L.buffer);w.setUint32(0,R),L.set(D.types.mdat,4);let U=!1,V=Number.POSITIVE_INFINITY,B=Number.POSITIVE_INFINITY,N=Number.NEGATIVE_INFINITY,M=Number.NEGATIVE_INFINITY;for(let F=0;F<d;F++){const $=n[F],q=$.units;let Z=0;for(let oe=0,le=q.length;oe<le;oe++){const ye=q[oe],Se=ye.data,ae=ye.data.byteLength;w.setUint32(h,ae),h+=4,L.set(Se,h),h+=ae,Z+=4+ae}let Y;if(F<d-1)f=n[F+1].dts-$.dts,Y=n[F+1].pts-$.pts;else{const oe=this.config,le=F>0?$.dts-n[F-1].dts:x;if(Y=F>0?$.pts-n[F-1].pts:x,oe.stretchShortVideoTrack&&this.nextAudioTs!==null){const ye=Math.floor(oe.maxBufferHole*r),Se=(i?p+i*r:this.nextAudioTs+c)-$.pts;Se>ye?(f=Se-le,f<0?f=le:U=!0,this.log("It is approximately ".concat(Se/90," ms to the next segment; using duration ").concat(f/90," ms for the last video frame."))):f=le}else f=le}const j=Math.round($.pts-$.dts);V=Math.min(V,f),N=Math.max(N,f),B=Math.min(B,Y),M=Math.max(M,Y),o.push(Ur($.key,f,Z,j))}if(o.length){if(gt){if(gt<70){const F=o[0].flags;F.dependsOn=2,F.isNonSync=0}}else if(Bs&&M-B<N-V&&x/N<.025&&o[0].cts===0){this.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let F=g;for(let $=0,q=o.length;$<q;$++){const Z=F+o[$].duration,Y=F+o[$].cts;if($<q-1){const j=Z+o[$+1].cts;o[$].duration=j-Y}else o[$].duration=$?o[$-1].duration:x;o[$].cts=0,F=Z}}}f=U||!f?x:f;const C=m+f;this.nextVideoTs=u=C-c,this.videoSampleDuration=f,this.isVideoContiguous=!0;const G={data1:D.moof(e.sequenceNumber++,g,ie(e,{samples:o})),data2:L,startPTS:(p-c)/r,endPTS:(v+f-c)/r,startDTS:(g-c)/r,endDTS:u/r,type:"video",hasAudio:!1,hasVideo:!0,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,G}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return Od;case"ac3":return Md;default:return wd}}remuxAudio(e,t,s,i,r){const n=e.inputTimeScale,o=e.samplerate?e.samplerate:n,d=n/o,l=this.getSamplesPerFrame(e),c=l*d,u=this._initPTS,h=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,f=[],g=r!==void 0;let m=e.samples,p=h?0:8,v=this.nextAudioTs||-1;const E=u.baseTime*n/u.timescale,T=E+t*n;if(this.isAudioContiguous=s=s||m.length&&v>0&&(i&&Math.abs(T-(v+E))<9e3||Math.abs(ke(m[0].pts,T)-(v+E))<20*c),m.forEach(function(M){M.pts=ke(M.pts,T)}),!s||v<0){if(m=m.filter(M=>M.pts>=0),!m.length)return;r===0?v=0:i&&!g?v=Math.max(0,T-E):v=m[0].pts-E}if(e.segmentCodec==="aac"){const M=this.config.maxAudioFramesDrift;for(let C=0,k=v+E;C<m.length;C++){const O=m[C],G=O.pts,F=G-k,$=Math.abs(1e3*F/n);if(F<=-M*c&&g)C===0&&(this.warn("Audio frame @ ".concat((G/n).toFixed(3),"s overlaps marker by ").concat(Math.round(1e3*F/n)," ms.")),this.nextAudioTs=v=G-E,k=G);else if(F>=M*c&&$<Pd&&g){let q=Math.round(F/c);for(k=G-q*c;k<0&&q&&c;)q--,k+=c;C===0&&(this.nextAudioTs=v=k-E),this.warn("Injecting ".concat(q," audio frames @ ").concat(((k-E)/n).toFixed(3),"s due to ").concat(Math.round(1e3*F/n)," ms gap."));for(let Z=0;Z<q;Z++){let Y=_d.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);Y||(this.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),Y=O.unit.subarray()),m.splice(C,0,{unit:Y,pts:k}),k+=c,C++}}O.pts=k,k+=c}}let S=null,x=null,b,A=0,I=m.length;for(;I--;)A+=m[I].unit.byteLength;for(let M=0,C=m.length;M<C;M++){const k=m[M],O=k.unit;let G=k.pts;if(x!==null){const $=f[M-1];$.duration=Math.round((G-x)/d)}else if(s&&e.segmentCodec==="aac"&&(G=v+E),S=G,A>0){A+=p;try{b=new Uint8Array(A)}catch($){this.observer.emit(y.ERROR,y.ERROR,{type:W.MUX_ERROR,details:_.REMUX_ALLOC_ERROR,fatal:!1,error:$,bytes:A,reason:"fail allocating audio mdat ".concat(A)});return}h||(new DataView(b.buffer).setUint32(0,A),b.set(D.types.mdat,4))}else return;b.set(O,p);const F=O.byteLength;p+=F,f.push(Ur(!0,l,F,0)),x=G}const R=f.length;if(!R)return;const L=f[f.length-1];v=x-E,this.nextAudioTs=v+d*L.duration;const w=h?new Uint8Array(0):D.moof(e.sequenceNumber++,S/d,ie({},e,{samples:f}));e.samples=[];const U=(S-E)/n,V=v/n,N={data1:w,data2:b,startPTS:U,endPTS:V,startDTS:U,endDTS:V,type:"audio",hasAudio:!0,hasVideo:!1,nb:R};return this.isAudioContiguous=!0,N}}function ke(a,e){let t;if(e===null)return a;for(e<a?t=-8589934592:t=8589934592;Math.abs(a-e)>4294967296;)a+=t;return a}function Fd(a){for(let e=0;e<a.length;e++)if(a[e].key)return e;return-1}function ga(a,e,t,s){const i=a.samples.length;if(!i)return;const r=a.inputTimeScale;for(let o=0;o<i;o++){const d=a.samples[o];d.pts=ke(d.pts-t.baseTime*r/t.timescale,e*r)/r,d.dts=ke(d.dts-s.baseTime*r/s.timescale,e*r)/r}const n=a.samples;return a.samples=[],{samples:n}}function ma(a,e,t){const s=a.samples.length;if(!s)return;const i=a.inputTimeScale;for(let n=0;n<s;n++){const o=a.samples[n];o.pts=ke(o.pts-t.baseTime*i/t.timescale,e*i)/i}a.samples.sort((n,o)=>n.pts-o.pts);const r=a.samples;return a.samples=[],{samples:r}}class $d extends Pe{constructor(e,t,s,i){super("passthrough-remuxer",i),this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null,this.isVideoContiguous=!1}destroy(){}resetTimeStamp(e){this.lastEndTime=null;const t=this.initPTS;t&&e&&t.baseTime===e.baseTime&&t.timescale===e.timescale||(this.initPTS=e)}resetNextTimestamp(){this.isVideoContiguous=!1,this.lastEndTime=null}resetInitSegment(e,t,s,i){this.audioCodec=t,this.videoCodec=s,this.generateInitSegment(e,i),this.emitInitSegment=!0}generateInitSegment(e,t){let{audioCodec:s,videoCodec:i}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}const{audio:r,video:n}=this.initData=Ln(e);if(t)Lo(e,t);else{const d=r||n;d!=null&&d.encrypted&&this.warn('Init segment with encrypted track with has no key ("'.concat(d.codec,'")!'))}r&&(s=Gr(r,re.AUDIO,this)),n&&(i=Gr(n,re.VIDEO,this));const o={};r&&n?o.audiovideo={container:"video/mp4",codec:s+","+i,supplemental:n.supplemental,encrypted:n.encrypted,initSegment:e,id:"main"}:r?o.audio={container:"audio/mp4",codec:s,encrypted:r.encrypted,initSegment:e,id:"audio"}:n?o.video={container:"video/mp4",codec:i,supplemental:n.supplemental,encrypted:n.encrypted,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=o}remux(e,t,s,i,r,n){var o,d;let{initPTS:l,lastEndTime:c}=this;const u={audio:void 0,video:void 0,text:i,id3:s,initSegment:void 0};K(c)||(c=this.lastEndTime=r||0);const h=t.samples;if(!h.length)return u;const f={initPTS:void 0,timescale:void 0,trackId:void 0};let g=this.initData;if((o=g)!=null&&o.length||(this.generateInitSegment(h),g=this.initData),!((d=g)!=null&&d.length))return this.warn("Failed to generate initSegment."),u;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);const m=Io(h,g,this),p=g.audio?m[g.audio.id]:null,v=g.video?m[g.video.id]:null,E=Xt(v,1/0),T=Xt(p,1/0),S=Xt(v,0,!0),x=Xt(p,0,!0);let b=r,A=0;const I=p&&(!v||!l&&T<E||l&&l.trackId===g.audio.id),R=I?p:v;if(R){const k=R.timescale,O=R.start-r*k,G=I?g.audio.id:g.video.id;b=R.start/k,A=I?x-T:S-E,(n||!l)&&(Nd(l,b,r,A)||k!==l.timescale)&&(l&&this.warn("Timestamps at playlist time: ".concat(n?"":"~").concat(r," ").concat(O/k," != initPTS: ").concat(l.baseTime/l.timescale," (").concat(l.baseTime,"/").concat(l.timescale,") trackId: ").concat(l.trackId)),this.log("Found initPTS at playlist time: ".concat(r," offset: ").concat(b-r," (").concat(O,"/").concat(k,") trackId: ").concat(G)),l=null,f.initPTS=O,f.timescale=k,f.trackId=G)}else this.warn("No audio or video samples found for initPTS at playlist time: ".concat(r));l?(f.initPTS=l.baseTime,f.timescale=l.timescale,f.trackId=l.trackId):((!f.timescale||f.trackId===void 0||f.initPTS===void 0)&&(this.warn("Could not set initPTS"),f.initPTS=b,f.timescale=1,f.trackId=-1),this.initPTS=l={baseTime:f.initPTS,timescale:f.timescale,trackId:f.trackId});const L=b-l.baseTime/l.timescale,w=L+A;A>0?this.lastEndTime=w:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const U=!!g.audio,V=!!g.video;let B="";U&&(B+="audio"),V&&(B+="video");const N=(g.audio?g.audio.encrypted:!1)||(g.video?g.video.encrypted:!1),M={data1:h,startPTS:L,startDTS:L,endPTS:w,endDTS:w,type:B,hasAudio:U,hasVideo:V,nb:1,dropped:0,encrypted:N};u.audio=U&&!V?M:void 0,u.video=V?M:void 0;const C=v==null?void 0:v.sampleCount;if(C){const k=v.keyFrameIndex,O=k!==-1;M.nb=C,M.dropped=k===0||this.isVideoContiguous?0:O?k:C,M.independent=O,M.firstKeyFrame=k,O&&v.keyFrameStart&&(M.firstKeyFramePTS=(v.keyFrameStart-l.baseTime)/l.timescale),this.isVideoContiguous||(u.independent=O),this.isVideoContiguous||(this.isVideoContiguous=O),M.dropped&&this.warn("fmp4 does not start with IDR: firstIDR ".concat(k,"/").concat(C," dropped: ").concat(M.dropped," start: ").concat(M.firstKeyFramePTS||"NA"))}return u.initSegment=f,u.id3=ga(s,r,l,l),i.samples.length&&(u.text=ma(i,r,l)),u}}function Xt(a,e,t=!1){return(a==null?void 0:a.start)!==void 0?(a.start+(t?a.duration:0))/a.timescale:e}function Nd(a,e,t,s){if(a===null)return!0;const i=Math.max(s,1),r=e-a.baseTime/a.timescale;return Math.abs(r-t)>i}function Gr(a,e,t){const s=a.codec;return s&&s.length>4?s:e===re.AUDIO?s==="ec-3"||s==="ac-3"||s==="alac"?s:s==="fLaC"||s==="Opus"?ms(s,!1):(t.warn('Unhandled audio codec "'.concat(s,'" in mp4 MAP')),s||"mp4a"):(t.warn('Unhandled video codec "'.concat(s,'" in mp4 MAP')),s||"avc1")}let je;try{je=self.performance.now.bind(self.performance)}catch(a){je=Date.now}const ds=[{demux:Ad,remux:$d},{demux:Ze,remux:ls},{demux:Ed,remux:ls},{demux:Sd,remux:ls}];ds.splice(2,0,{demux:Td,remux:ls});class Kr{constructor(e,t,s,i,r,n){this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=s,this.id=r,this.logger=n}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,s,i){const r=s.transmuxing;r.executeStart=je();let n=new Uint8Array(e);const{currentTransmuxState:o,transmuxConfig:d}=this;i&&(this.currentTransmuxState=i);const{contiguous:l,discontinuity:c,trackSwitch:u,accurateTimeOffset:h,timeOffset:f,initSegmentChange:g}=i||o,{audioCodec:m,videoCodec:p,defaultInitPts:v,duration:E,initSegmentData:T}=d,S=Bd(n,t);if(S&&vt(S.method)){const I=this.getDecrypter(),R=Ri(S.method);if(I.isSync()){let L=I.softwareDecrypt(n,S.key.buffer,S.iv.buffer,R);if(s.part>-1){const U=I.flush();L=U&&U.buffer}if(!L)return r.executeEnd=je(),Us(s);n=new Uint8Array(L)}else return this.asyncResult=!0,this.decryptionPromise=I.webCryptoDecrypt(n,S.key.buffer,S.iv.buffer,R).then(L=>{const w=this.push(L,null,s);return this.decryptionPromise=null,w}),this.decryptionPromise}const x=this.needsProbing(c,u);if(x){const I=this.configureTransmuxer(n);if(I)return this.logger.warn("[transmuxer] ".concat(I.message)),this.observer.emit(y.ERROR,y.ERROR,{type:W.MEDIA_ERROR,details:_.FRAG_PARSING_ERROR,fatal:!1,error:I,reason:I.message}),r.executeEnd=je(),Us(s)}(c||u||g||x)&&this.resetInitSegment(T,m,p,E,t),(c||g||x)&&this.resetInitialTimestamp(v),l||this.resetContiguity();const b=this.transmux(n,S,f,h,s);this.asyncResult=Bt(b);const A=this.currentTransmuxState;return A.contiguous=!0,A.discontinuity=!1,A.trackSwitch=!1,r.executeEnd=je(),b}flush(e){const t=e.transmuxing;t.executeStart=je();const{decrypter:s,currentTransmuxState:i,decryptionPromise:r}=this;if(r)return this.asyncResult=!0,r.then(()=>this.flush(e));const n=[],{timeOffset:o}=i;if(s){const u=s.flush();u&&n.push(this.push(u.buffer,null,e))}const{demuxer:d,remuxer:l}=this;if(!d||!l){t.executeEnd=je();const u=[Us(e)];return this.asyncResult?Promise.resolve(u):u}const c=d.flush(o);return Bt(c)?(this.asyncResult=!0,c.then(u=>(this.flushRemux(n,u,e),n))):(this.flushRemux(n,c,e),this.asyncResult?Promise.resolve(n):n)}flushRemux(e,t,s){const{audioTrack:i,videoTrack:r,id3Track:n,textTrack:o}=t,{accurateTimeOffset:d,timeOffset:l}=this.currentTransmuxState;this.logger.log("[transmuxer.ts]: Flushed ".concat(this.id," sn: ").concat(s.sn).concat(s.part>-1?" part: "+s.part:""," of ").concat(this.id===H.MAIN?"level":"track"," ").concat(s.level));const c=this.remuxer.remux(i,r,n,o,l,d,!0,this.id);e.push({remuxResult:c,chunkMeta:s}),s.transmuxing.executeEnd=je()}resetInitialTimestamp(e){const{demuxer:t,remuxer:s}=this;!t||!s||(t.resetTimeStamp(e),s.resetTimeStamp(e))}resetContiguity(){const{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,s,i,r){const{demuxer:n,remuxer:o}=this;!n||!o||(n.resetInitSegment(e,t,s,i),o.resetInitSegment(e,t,s,r))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,s,i,r){let n;return t&&t.method==="SAMPLE-AES"?n=this.transmuxSampleAes(e,t,s,i,r):n=this.transmuxUnencrypted(e,s,i,r),n}transmuxUnencrypted(e,t,s,i){const{audioTrack:r,videoTrack:n,id3Track:o,textTrack:d}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(r,n,o,d,t,s,!1,this.id),chunkMeta:i}}transmuxSampleAes(e,t,s,i,r){return this.demuxer.demuxSampleAes(e,t,s).then(n=>({remuxResult:this.remuxer.remux(n.audioTrack,n.videoTrack,n.id3Track,n.textTrack,s,i,!1,this.id),chunkMeta:r}))}configureTransmuxer(e){const{config:t,observer:s,typeSupported:i}=this;let r;for(let u=0,h=ds.length;u<h;u++){var n;if((n=ds[u].demux)!=null&&n.probe(e,this.logger)){r=ds[u];break}}if(!r)return new Error("Failed to find demuxer by probing fragment data");const o=this.demuxer,d=this.remuxer,l=r.remux,c=r.demux;(!d||!(d instanceof l))&&(this.remuxer=new l(s,t,i,this.logger)),(!o||!(o instanceof c))&&(this.demuxer=new c(s,t,i,this.logger),this.probe=c.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new Li(this.config)),e}}function Bd(a,e){let t=null;return a.byteLength>0&&(e==null?void 0:e.key)!=null&&e.iv!==null&&e.method!=null&&(t=e),t}const Us=a=>({remuxResult:{},chunkMeta:a});function Bt(a){return"then"in a&&a.then instanceof Function}class Ud{constructor(e,t,s,i,r){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=s,this.duration=i,this.defaultInitPts=r||null}}class Gd{constructor(e,t,s,i,r,n){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=s,this.trackSwitch=i,this.timeOffset=r,this.initSegmentChange=n}}let Vr=0;class pa{constructor(e,t,s,i){this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=Vr++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=d=>{const l=d.data,c=this.hls;if(!(!c||!(l!=null&&l.event)||l.instanceNo!==this.instanceNo))switch(l.event){case"init":{var u;const h=(u=this.workerContext)==null?void 0:u.objectURL;h&&self.URL.revokeObjectURL(h);break}case"transmuxComplete":{this.handleTransmuxComplete(l.data);break}case"flush":{this.onFlush(l.data);break}case"workerLog":{c.logger[l.data.logType]&&c.logger[l.data.logType](l.data.message);break}default:{l.data=l.data||{},l.data.frag=this.frag,l.data.part=this.part,l.data.id=this.id,c.trigger(l.event,l.data);break}}},this.onWorkerError=d=>{if(!this.hls)return;const l=new Error("".concat(d.message," (").concat(d.filename,":").concat(d.lineno,")"));this.hls.config.enableWorker=!1,this.hls.logger.warn('Error in "'.concat(this.id,'" Web Worker, fallback to inline')),this.hls.trigger(y.ERROR,{type:W.OTHER_ERROR,details:_.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:l})};const r=e.config;this.hls=e,this.id=t,this.useWorker=!!r.enableWorker,this.onTransmuxComplete=s,this.onFlush=i;const n=(d,l)=>{l=l||{},l.frag=this.frag||void 0,d===y.ERROR&&(l=l,l.parent=this.id,l.part=this.part,this.error=l.error),this.hls.trigger(d,l)};this.observer=new ki,this.observer.on(y.FRAG_DECRYPTED,n),this.observer.on(y.ERROR,n);const o=ar(r.preferManagedMediaSource);if(this.useWorker&&typeof Worker<"u"){const d=this.hls.logger;if(r.workerPath||Wl()){try{r.workerPath?(d.log("loading Web Worker ".concat(r.workerPath,' for "').concat(t,'"')),this.workerContext=ql(r.workerPath)):(d.log('injecting Web Worker for "'.concat(t,'"')),this.workerContext=Yl());const{worker:c}=this.workerContext;c.addEventListener("message",this.onWorkerMessage),c.addEventListener("error",this.onWorkerError),c.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:o,id:t,config:ne(r)})}catch(c){d.warn('Error setting up "'.concat(t,'" Web Worker, fallback to inline'),c),this.terminateWorker(),this.error=null,this.transmuxer=new Kr(this.observer,o,r,"",t,e.logger)}return}}this.transmuxer=new Kr(this.observer,o,r,"",t,e.logger)}reset(){if(this.frag=null,this.part=null,this.workerContext){const e=this.instanceNo;this.instanceNo=Vr++;const t=this.hls.config,s=ar(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:s,id:this.id,config:ne(t)})}}terminateWorker(){if(this.workerContext){const{worker:e}=this.workerContext;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),jl(this.hls.config.workerPath)}}destroy(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{const t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}const e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null}push(e,t,s,i,r,n,o,d,l,c){var u,h;l.transmuxing.start=self.performance.now();const{instanceNo:f,transmuxer:g}=this,m=n?n.start:r.start,p=r.decryptdata,v=this.frag,E=!(v&&r.cc===v.cc),T=!(v&&l.level===v.level),S=v?l.sn-v.sn:-1,x=this.part?l.part-this.part.index:-1,b=S===0&&l.id>1&&l.id===(v==null?void 0:v.stats.chunkCount),A=!T&&(S===1||S===0&&(x===1||b&&x<=0)),I=self.performance.now();(T||S||r.stats.parsing.start===0)&&(r.stats.parsing.start=I),n&&(x||!A)&&(n.stats.parsing.start=I);const R=!(v&&((u=r.initSegment)==null?void 0:u.url)===((h=v.initSegment)==null?void 0:h.url)),L=new Gd(E,A,d,T,m,R);if(!A||E||R){this.hls.logger.log("[transmuxer-interface]: Starting new transmux session for ".concat(r.type," sn: ").concat(l.sn).concat(l.part>-1?" part: "+l.part:""," ").concat(this.id===H.MAIN?"level":"track",": ").concat(l.level," id: ").concat(l.id,"\n discontinuity: ").concat(E,"\n trackSwitch: ").concat(T,"\n contiguous: ").concat(A,"\n accurateTimeOffset: ").concat(d,"\n timeOffset: ").concat(m,"\n initSegmentChange: ").concat(R));const w=new Ud(s,i,t,o,c);this.configureTransmuxer(w)}if(this.frag=r,this.part=n,this.workerContext)this.workerContext.worker.postMessage({instanceNo:f,cmd:"demux",data:e,decryptdata:p,chunkMeta:l,state:L},e instanceof ArrayBuffer?[e]:[]);else if(g){const w=g.push(e,p,l,L);Bt(w)?w.then(U=>{this.handleTransmuxComplete(U)}).catch(U=>{this.transmuxerError(U,l,"transmuxer-interface push error")}):this.handleTransmuxComplete(w)}}flush(e){e.transmuxing.start=self.performance.now();const{instanceNo:t,transmuxer:s}=this;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:t,cmd:"flush",chunkMeta:e});else if(s){const i=s.flush(e);Bt(i)?i.then(r=>{this.handleFlushResult(r,e)}).catch(r=>{this.transmuxerError(r,e,"transmuxer-interface flush error")}):this.handleFlushResult(i,e)}}transmuxerError(e,t,s){this.hls&&(this.error=e,this.hls.trigger(y.ERROR,{type:W.MEDIA_ERROR,details:_.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:e,err:e,reason:s}))}handleFlushResult(e,t){e.forEach(s=>{this.handleTransmuxComplete(s)}),this.onFlush(t)}configureTransmuxer(e){const{instanceNo:t,transmuxer:s}=this;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):s&&s.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}const Hr=100;class Kd extends _i{constructor(e,t,s){super(e,t,s,"audio-stream-controller",H.AUDIO),this.mainAnchor=null,this.mainFragLoading=null,this.audioOnly=!1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=!1,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.resetItem()}resetItem(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(y.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(y.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(y.BUFFER_RESET,this.onBufferReset,this),e.on(y.BUFFER_CREATED,this.onBufferCreated,this),e.on(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(y.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(y.FRAG_LOADING,this.onFragLoading,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){const{hls:e}=this;e&&(super.unregisterListeners(),e.off(y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(y.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(y.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(y.BUFFER_RESET,this.onBufferReset,this),e.off(y.BUFFER_CREATED,this.onBufferCreated,this),e.off(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(y.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(y.FRAG_LOADING,this.onFragLoading,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this))}onInitPtsFound(e,{frag:t,id:s,initPTS:i,timescale:r,trackId:n}){if(s===H.MAIN){const o=t.cc,d=this.fragCurrent;if(this.initPTS[o]={baseTime:i,timescale:r,trackId:n},this.log("InitPTS for cc: ".concat(o," found from main: ").concat(i/r," (").concat(i,"/").concat(r,") trackId: ").concat(n)),this.mainAnchor=t,this.state===P.WAITING_INIT_PTS){const l=this.waitingData;(!l&&!this.loadingParts||l&&l.frag.cc!==o)&&this.syncWithAnchor(t,l==null?void 0:l.frag)}else!this.hls.hasEnoughToStart&&d&&d.cc!==o?(d.abortRequests(),this.syncWithAnchor(t,d)):this.state===P.IDLE&&this.tick()}}getLoadPosition(){return!this.startFragRequested&&this.nextLoadPosition>=0?this.nextLoadPosition:super.getLoadPosition()}syncWithAnchor(e,t){var s;const i=((s=this.mainFragLoading)==null?void 0:s.frag)||null;if(t&&(i==null?void 0:i.cc)===t.cc)return;const r=(i||e).cc,n=this.getLevelDetails(),o=this.getLoadPosition(),d=On(n,r,o);d&&(this.log("Syncing with main frag at ".concat(d.start," cc ").concat(d.cc)),this.startFragRequested=!1,this.nextLoadPosition=d.start,this.resetLoadingState(),this.state===P.IDLE&&this.doTickIdle())}startLoad(e,t){if(!this.levels){this.startPosition=e,this.state=P.STOPPED;return}const s=this.lastCurrentTime;this.stopLoad(),this.setInterval(Hr),s>0&&e===-1?(this.log("Override startPosition with lastCurrentTime @".concat(s.toFixed(3))),e=s,this.state=P.IDLE):this.state=P.WAITING_TRACK,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}doTick(){switch(this.state){case P.IDLE:this.doTickIdle();break;case P.WAITING_TRACK:{const{levels:e,trackId:t}=this,s=e==null?void 0:e[t],i=s==null?void 0:s.details;if(i&&!this.waitForLive(s)){if(this.waitForCdnTuneIn(i))break;this.state=P.WAITING_INIT_PTS}break}case P.FRAG_LOADING_WAITING_RETRY:{this.checkRetryDate();break}case P.WAITING_INIT_PTS:{const e=this.waitingData;if(e){const{frag:t,part:s,cache:i,complete:r}=e,n=this.mainAnchor;if(this.initPTS[t.cc]!==void 0){this.waitingData=null,this.state=P.FRAG_LOADING;const o=i.flush().buffer,d={frag:t,part:s,payload:o,networkDetails:null};this._handleFragmentLoadProgress(d),r&&super._handleFragmentLoadComplete(d)}else n&&n.cc!==e.frag.cc&&this.syncWithAnchor(n,e.frag)}else this.state=P.IDLE}}this.onTickEnd()}resetLoadingState(){const e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null),super.resetLoadingState()}onTickEnd(){const{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){var e;const{hls:t,levels:s,media:i,trackId:r}=this,n=t.config;if(!this.buffering||!i&&!this.primaryPrefetch&&(this.startFragRequested||!n.startFragPrefetch)||!(s!=null&&s[r]))return;const o=s[r],d=o.details;if(!d||this.waitForLive(o)||this.waitForCdnTuneIn(d)){this.state=P.WAITING_TRACK,this.startFragRequested=!1;return}const l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,re.AUDIO,H.AUDIO));const c=this.getFwdBufferInfo(l,H.AUDIO);if(c===null)return;if(!this.switchingTrack&&this._streamEnded(c,d)){t.trigger(y.BUFFER_EOS,{type:"audio"}),this.state=P.ENDED;return}const u=c.len,h=t.maxBufferLength,f=d.fragments,g=f[0].start,m=this.getLoadPosition(),p=this.flushing?m:c.end;if(this.switchingTrack&&i){const T=m;d.PTSKnown&&T<g&&(c.end>g||c.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=g+.05)}if(u>=h&&!this.switchingTrack&&p<f[f.length-1].start)return;let v=this.getNextFragment(p,d);if(v&&this.isLoopLoading(v,p)&&(v=this.getNextFragmentLoopLoading(v,d,c,H.MAIN,h)),!v){this.bufferFlushed=!0;return}let E=((e=this.mainFragLoading)==null?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&E&&he(v)&&!v.endList&&(!d.live||!this.loadingParts&&p<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(E)===ge.OK&&(this.mainFragLoading=E=null),E&&he(E))){if(v.start>E.end){const S=this.fragmentTracker.getFragAtPos(p,H.MAIN);S&&S.end>E.end&&(E=S,this.mainFragLoading={frag:S,targetBufferTime:null})}if(v.start>E.end)return}this.loadFragment(v,o,p)}onMediaDetaching(e,t){this.bufferFlushed=this.flushing=!1,super.onMediaDetaching(e,t)}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(s=>new Mt(s))}onAudioTrackSwitching(e,t){const s=!!t.url;this.trackId=t.id;const{fragCurrent:i}=this;i&&(i.abortRequests(),this.removeUnbufferedFrags(i.start)),this.resetLoadingState(),s?(this.switchingTrack=t,this.flushAudioIfNeeded(t),this.state!==P.STOPPED&&(this.setInterval(Hr),this.state=P.IDLE,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval())}onManifestLoading(){super.onManifestLoading(),this.bufferFlushed=this.flushing=this.audioOnly=!1,this.resetItem(),this.trackId=-1}onLevelLoaded(e,t){this.mainDetails=t.details;const s=this.cachedTrackLoadedData;s&&(this.cachedTrackLoadedData=null,this.onAudioTrackLoaded(y.AUDIO_TRACK_LOADED,s))}onAudioTrackLoaded(e,t){var s;const{levels:i}=this,{details:r,id:n,groupId:o,track:d}=t;if(!i){this.warn("Audio tracks reset while loading track ".concat(n,' "').concat(d.name,'" of "').concat(o,'"'));return}const l=this.mainDetails;if(!l||r.endCC>l.endCC||l.expired){this.cachedTrackLoadedData=t,this.state!==P.STOPPED&&(this.state=P.WAITING_TRACK);return}this.cachedTrackLoadedData=null,this.log("Audio track ".concat(n,' "').concat(d.name,'" of "').concat(o,'" loaded [').concat(r.startSN,",").concat(r.endSN,"]").concat(r.lastPartSn?"[part-".concat(r.lastPartSn,"-").concat(r.lastPartIndex,"]"):"",",duration:").concat(r.totalduration));const c=i[n];let u=0;if(r.live||(s=c.details)!=null&&s.live){if(this.checkLiveUpdate(r),r.deltaUpdateFailed)return;if(c.details){var h;u=this.alignPlaylists(r,c.details,(h=this.levelLastLoaded)==null?void 0:h.details)}r.alignedSliding||(Xn(r,l),r.alignedSliding||Ss(r,l),u=r.fragmentStart)}c.details=r,this.levelLastLoaded=c,this.startFragRequested||this.setStartPosition(l,u),this.hls.trigger(y.AUDIO_TRACK_UPDATED,{details:r,id:n,groupId:t.groupId}),this.state===P.WAITING_TRACK&&!this.waitForCdnTuneIn(r)&&(this.state=P.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;const s=e.frag,{part:i,payload:r}=e,{config:n,trackId:o,levels:d}=this;if(!d){this.warn("Audio tracks were reset while fragment load was in progress. Fragment ".concat(s.sn," of level ").concat(s.level," will not be buffered"));return}const l=d[o];if(!l){this.warn("Audio track is undefined on fragment load progress");return}const c=l.details;if(!c){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(s.start);return}const u=n.defaultAudioCodec||l.audioCodec||"mp4a.40.2";let h=this.transmuxer;h||(h=this.transmuxer=new pa(this.hls,H.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const f=this.initPTS[s.cc],g=(t=s.initSegment)==null?void 0:t.data;if(f!==void 0){const p=i?i.index:-1,v=p!==-1,E=new Ii(s.level,s.sn,s.stats.chunkCount,r.byteLength,p,v);h.push(r,g,u,"",s,i,c.totalduration,!1,E,f)}else{this.log("Unknown video PTS for cc ".concat(s.cc,", waiting for video PTS before demuxing audio frag ").concat(s.sn," of [").concat(c.startSN," ,").concat(c.endSN,"],track ").concat(o));const{cache:m}=this.waitingData=this.waitingData||{frag:s,part:i,cache:new Qn,complete:!1};m.push(new Uint8Array(r)),this.state!==P.STOPPED&&(this.state=P.WAITING_INIT_PTS)}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=null}onBufferCreated(e,t){this.bufferFlushed=this.flushing=!1;const s=t.tracks.audio;s&&(this.mediaBuffer=s.buffer||null)}onFragLoading(e,t){!this.audioOnly&&t.frag.type===H.MAIN&&he(t.frag)&&(this.mainFragLoading=t,this.state===P.IDLE&&this.tick())}onFragBuffered(e,t){const{frag:s,part:i}=t;if(s.type!==H.AUDIO){!this.audioOnly&&s.type===H.MAIN&&!s.elementaryStreams.video&&!s.elementaryStreams.audiovideo&&(this.audioOnly=!0,this.mainFragLoading=null);return}if(this.fragContextChanged(s)){this.warn("Fragment ".concat(s.sn).concat(i?" p: "+i.index:""," of level ").concat(s.level," finished buffering, but was aborted. state: ").concat(this.state,", audioSwitch: ").concat(this.switchingTrack?this.switchingTrack.name:"false"));return}if(he(s)){this.fragPrevious=s;const r=this.switchingTrack;r&&(this.bufferedTrack=r,this.switchingTrack=null,this.hls.trigger(y.AUDIO_TRACK_SWITCHED,te({},r)))}this.fragBufferedComplete(s,i),this.media&&this.tick()}onError(e,t){var s;if(t.fatal){this.state=P.ERROR;return}switch(t.details){case _.FRAG_GAP:case _.FRAG_PARSING_ERROR:case _.FRAG_DECRYPT_ERROR:case _.FRAG_LOAD_ERROR:case _.FRAG_LOAD_TIMEOUT:case _.KEY_LOAD_ERROR:case _.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(H.AUDIO,t);break;case _.AUDIO_TRACK_LOAD_ERROR:case _.AUDIO_TRACK_LOAD_TIMEOUT:case _.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===P.WAITING_TRACK&&((s=t.context)==null?void 0:s.type)===J.AUDIO_TRACK&&(this.state=P.IDLE);break;case _.BUFFER_ADD_CODEC_ERROR:case _.BUFFER_APPEND_ERROR:if(t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)||this.resetLoadingState();break;case _.BUFFER_FULL_ERROR:if(t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case _.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushing(e,{type:t}){t!==re.VIDEO&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==re.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===P.ENDED&&(this.state=P.IDLE);const s=this.mediaBuffer||this.media;s&&(this.afterBufferFlushed(s,t,H.AUDIO),this.tick())}}_handleTransmuxComplete(e){var t;const s="audio",{hls:i}=this,{remuxResult:r,chunkMeta:n}=e,o=this.getCurrentContext(n);if(!o){this.resetWhenMissingContext(n);return}const{frag:d,part:l,level:c}=o,{details:u}=c,{audio:h,text:f,id3:g,initSegment:m}=r;if(this.fragContextChanged(d)||!u){this.fragmentTracker.removeFragment(d);return}if(this.state=P.PARSING,this.switchingTrack&&h&&this.completeAudioSwitch(this.switchingTrack),m!=null&&m.tracks){const p=d.initSegment||d;if(this.unhandledEncryptionError(m,d))return;this._bufferInitSegment(c,m.tracks,p,n),i.trigger(y.FRAG_PARSING_INIT_SEGMENT,{frag:p,id:s,tracks:m.tracks})}if(h){const{startPTS:p,endPTS:v,startDTS:E,endDTS:T}=h;l&&(l.elementaryStreams[re.AUDIO]={startPTS:p,endPTS:v,startDTS:E,endDTS:T}),d.setElementaryStreamInfo(re.AUDIO,p,v,E,T),this.bufferFragmentData(h,d,l,n)}if(g!=null&&(t=g.samples)!=null&&t.length){const p=ie({id:s,frag:d,details:u},g);i.trigger(y.FRAG_PARSING_METADATA,p)}if(f){const p=ie({id:s,frag:d,details:u},f);i.trigger(y.FRAG_PARSING_USERDATA,p)}}_bufferInitSegment(e,t,s,i){if(this.state!==P.PARSING||(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,!t.audio))return;const r=t.audio;r.id=H.AUDIO;const n=e.audioCodec;this.log("Init audio buffer, container:".concat(r.container,", codecs[level/parsed]=[").concat(n,"/").concat(r.codec,"]")),n&&n.split(",").length===1&&(r.levelCodec=n),this.hls.trigger(y.BUFFER_CODECS,t);const o=r.initSegment;if(o!=null&&o.byteLength){const d={type:"audio",frag:s,part:null,chunkMeta:i,parent:s.type,data:o};this.hls.trigger(y.BUFFER_APPENDING,d)}this.tickImmediate()}loadFragment(e,t,s){const i=this.fragmentTracker.getState(e);if(this.switchingTrack||i===ge.NOT_LOADED||i===ge.PARTIAL){var r;if(!he(e))this._loadInitSegment(e,t);else if((r=t.details)!=null&&r.live&&!this.initPTS[e.cc]){this.log("Waiting for video PTS in continuity counter ".concat(e.cc," of live stream before loading audio fragment ").concat(e.sn," of level ").concat(this.trackId)),this.state=P.WAITING_INIT_PTS;const n=this.mainDetails;n&&n.fragmentStart!==t.details.fragmentStart&&Ss(t.details,n)}else super.loadFragment(e,t,s)}else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){if(this.media&&this.bufferedTrack){const{name:t,lang:s,assocLang:i,characteristics:r,audioCodec:n,channels:o}=this.bufferedTrack;ot({name:t,lang:s,assocLang:i,characteristics:r,audioCodec:n,channels:o},e,nt)||(ys(e.url,this.hls)?(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null):this.bufferedTrack=e)}}completeAudioSwitch(e){const{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(y.AUDIO_TRACK_SWITCHED,te({},e))}}class $i extends Pe{constructor(e,t){super(t,e.logger),this.hls=void 0,this.canLoad=!1,this.timer=-1,this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t,s){const i=t==null?void 0:t.renditionReports;if(i){let r=-1;for(let n=0;n<i.length;n++){const o=i[n];let d;try{d=new self.URL(o.URI,t.url).href}catch(l){this.warn("Could not construct new URL for Rendition Report: ".concat(l)),d=o.URI||""}if(d===e){r=n;break}else d===e.substring(0,d.length)&&(r=n)}if(r!==-1){const n=i[r],o=parseInt(n["LAST-MSN"])||t.lastPartSn;let d=parseInt(n["LAST-PART"])||t.lastPartIndex;if(this.hls.config.lowLatencyMode){const c=Math.min(t.age-t.partTarget,t.targetduration);d>=0&&c>t.partTarget&&(d+=1)}const l=s&&or(s);return new lr(o,d>=0?d:void 0,l)}}}loadPlaylist(e){this.clearTimer()}loadingPlaylist(e,t){this.clearTimer()}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}getUrlWithDirectives(e,t){if(t)try{return t.addDirectives(e)}catch(s){this.warn("Could not construct new URL with HLS Delivery Directives: ".concat(s))}return e}playlistLoaded(e,t,s){const{details:i,stats:r}=t,n=self.performance.now(),o=r.loading.first?Math.max(0,n-r.loading.first):0;i.advancedDateTime=Date.now()-o;const d=this.hls.config.timelineOffset;if(d!==i.appliedTimelineOffset){const c=Math.max(d||0,0);i.appliedTimelineOffset=c,i.fragments.forEach(u=>{u.setStart(u.playlistOffset+c)})}if(i.live||s!=null&&s.live){const c="levelInfo"in t?t.levelInfo:t.track;if(i.reloaded(s),s&&i.fragments.length>0){Ol(s,i,this);const E=i.playlistParsingError;if(E){this.warn(E);const T=this.hls;if(!T.config.ignorePlaylistParsingErrors){var l;const{networkDetails:S}=t;T.trigger(y.ERROR,{type:W.NETWORK_ERROR,details:_.LEVEL_PARSING_ERROR,fatal:!1,url:i.url,error:E,reason:E.message,level:t.level||void 0,parent:(l=i.fragments[0])==null?void 0:l.type,networkDetails:S,stats:r});return}i.playlistParsingError=null}}i.requestScheduled===-1&&(i.requestScheduled=r.loading.start);const u=this.hls.mainForwardBufferInfo,h=u?u.end-u.len:0,f=(i.edge-h)*1e3,g=Wn(i,f);if(i.requestScheduled+g<n?i.requestScheduled=n:i.requestScheduled+=g,this.log("live playlist ".concat(e," ").concat(i.advanced?"REFRESHED "+i.lastPartSn+"-"+i.lastPartIndex:i.updated?"UPDATED":"MISSED")),!this.canLoad||!i.live)return;let m,p,v;if(i.canBlockReload&&i.endSN&&i.advanced){const E=this.hls.config.lowLatencyMode,T=i.lastPartSn,S=i.endSN,x=i.lastPartIndex,b=x!==-1,A=T===S;b?A?(p=S+1,v=E?0:x):(p=T,v=E?x+1:i.maxPartIndex):p=S+1;const I=i.age,R=I+i.ageHeader;let L=Math.min(R-i.partTarget,i.targetduration*1.5);if(L>0){if(R>i.targetduration*3)this.log("Playlist last advanced ".concat(I.toFixed(2),"s ago. Omitting segment and part directives.")),p=void 0,v=void 0;else if(s!=null&&s.tuneInGoal&&R-i.partTarget>s.tuneInGoal)this.warn("CDN Tune-in goal increased from: ".concat(s.tuneInGoal," to: ").concat(L," with playlist age: ").concat(i.age)),L=0;else{const w=Math.floor(L/i.targetduration);if(p+=w,v!==void 0){const U=Math.round(L%i.targetduration/i.partTarget);v+=U}this.log("CDN Tune-in age: ".concat(i.ageHeader,"s last advanced ").concat(I.toFixed(2),"s goal: ").concat(L," skip sn ").concat(w," to part ").concat(v))}i.tuneInGoal=L}if(m=this.getDeliveryDirectives(i,t.deliveryDirectives,p,v),E||!A){i.requestScheduled=n,this.loadingPlaylist(c,m);return}}else(i.canBlockReload||i.canSkipUntil)&&(m=this.getDeliveryDirectives(i,t.deliveryDirectives,p,v));m&&p!==void 0&&i.canBlockReload&&(i.requestScheduled=r.loading.first+Math.max(g-o*2,g/2)),this.scheduleLoading(c,m,i)}else this.clearTimer()}scheduleLoading(e,t,s){const i=s||e.details;if(!i){this.loadingPlaylist(e,t);return}const r=self.performance.now(),n=i.requestScheduled;if(r>=n){this.loadingPlaylist(e,t);return}const o=n-r;this.log("reload live playlist ".concat(e.name||e.bitrate+"bps"," in ").concat(Math.round(o)," ms")),this.clearTimer(),this.timer=self.setTimeout(()=>this.loadingPlaylist(e,t),o)}getDeliveryDirectives(e,t,s,i){let r=or(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(s=t.msn,i=t.part,r=as.No),new lr(s,i,r)}checkRetry(e){const t=e.details,s=vs(e),i=e.errorAction,{action:r,retryCount:n=0,retryConfig:o}=i||{},d=!!i&&!!o&&(r===pe.RetryRequest||!i.resolved&&r===pe.SendAlternateToPenaltyBox);if(d){var l;if(n>=o.maxNumRetry)return!1;if(s&&(l=e.context)!=null&&l.deliveryDirectives)this.warn("Retrying playlist loading ".concat(n+1,"/").concat(o.maxNumRetry,' after "').concat(t,'" without delivery-directives')),this.loadPlaylist();else{const c=Ai(o,n);this.clearTimer(),this.timer=self.setTimeout(()=>this.loadPlaylist(),c),this.warn("Retrying playlist loading ".concat(n+1,"/").concat(o.maxNumRetry,' after "').concat(t,'" in ').concat(c,"ms"))}e.levelRetry=!0,i.resolved=!0}return d}}function ya(a,e){if(a.length!==e.length)return!1;for(let t=0;t<a.length;t++)if(!Ut(a[t].attrs,e[t].attrs))return!1;return!0}function Ut(a,e,t){const s=a["STABLE-RENDITION-ID"];return s&&!t?s===e["STABLE-RENDITION-ID"]:!(t||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(i=>a[i]!==e[i])}function ci(a,e){return e.label.toLowerCase()===a.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(a.lang||"").toLowerCase())}class Vd extends $i{constructor(e){super(e,"audio-track-controller"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:e}=this;e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.LEVEL_LOADING,this.onLevelLoading,this),e.on(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(y.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(y.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.LEVEL_LOADING,this.onLevelLoading,this),e.off(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(y.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(y.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){const{id:s,groupId:i,details:r}=t,n=this.tracksInGroup[s];if(!n||n.groupId!==i){this.warn("Audio track with id:".concat(s," and group:").concat(i," not found in active group ").concat(n==null?void 0:n.groupId));return}const o=n.details;n.details=t.details,this.log("Audio track ".concat(s,' "').concat(n.name,'" lang:').concat(n.lang," group:").concat(i," loaded [").concat(r.startSN,"-").concat(r.endSN,"]")),s===this.trackId&&this.playlistLoaded(s,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const s=t.audioGroups||null,i=this.groupIds;let r=this.currentTrack;if(!s||(i==null?void 0:i.length)!==(s==null?void 0:s.length)||s!=null&&s.some(o=>(i==null?void 0:i.indexOf(o))===-1)){this.groupIds=s,this.trackId=-1,this.currentTrack=null;const o=this.tracks.filter(h=>!s||s.indexOf(h.groupId)!==-1);if(o.length)this.selectDefaultTrack&&!o.some(h=>h.default)&&(this.selectDefaultTrack=!1),o.forEach((h,f)=>{h.id=f});else if(!r&&!this.tracksInGroup.length)return;this.tracksInGroup=o;const d=this.hls.config.audioPreference;if(!r&&d){const h=Ge(d,o,nt);if(h>-1)r=o[h];else{const f=Ge(d,this.tracks);r=this.tracks[f]}}let l=this.findTrackId(r);l===-1&&r&&(l=this.findTrackId(null));const c={audioTracks:o};this.log("Updating audio tracks, ".concat(o.length," track(s) found in group(s): ").concat(s==null?void 0:s.join(","))),this.hls.trigger(y.AUDIO_TRACKS_UPDATED,c);const u=this.trackId;if(l!==-1&&u===-1)this.setAudioTrack(l);else if(o.length&&u===-1){var n;const h=new Error("No audio track selected for current audio group-ID(s): ".concat((n=this.groupIds)==null?void 0:n.join(",")," track count: ").concat(o.length));this.warn(h.message),this.hls.trigger(y.ERROR,{type:W.MEDIA_ERROR,details:_.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:h})}}}onError(e,t){t.fatal||!t.context||t.context.type===J.AUDIO_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&this.checkRetry(t)}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioOption(e){const t=this.hls;if(t.config.audioPreference=e,e){const s=this.allAudioTracks;if(this.selectDefaultTrack=!1,s.length){const i=this.currentTrack;if(i&&ot(e,i,nt))return i;const r=Ge(e,this.tracksInGroup,nt);if(r>-1){const n=this.tracksInGroup[r];return this.setAudioTrack(r),n}else if(i){let n=t.loadLevel;n===-1&&(n=t.firstAutoLevel);const o=el(e,t.levels,s,n,nt);if(o===-1)return null;t.nextLoadLevel=o}if(e.channels||e.audioCodec){const n=Ge(e,s);if(n>-1)return s[n]}}}return null}setAudioTrack(e){const t=this.tracksInGroup;if(e<0||e>=t.length){this.warn("Invalid audio track id: ".concat(e));return}this.selectDefaultTrack=!1;const s=this.currentTrack,i=t[e],r=i.details&&!i.details.live;if(e===this.trackId&&i===s&&r||(this.log("Switching to audio-track ".concat(e,' "').concat(i.name,'" lang:').concat(i.lang," group:").concat(i.groupId," channels:").concat(i.channels)),this.trackId=e,this.currentTrack=i,this.hls.trigger(y.AUDIO_TRACK_SWITCHING,te({},i)),r))return;const n=this.switchParams(i.url,s==null?void 0:s.details,i.details);this.loadPlaylist(n)}findTrackId(e){const t=this.tracksInGroup;for(let s=0;s<t.length;s++){const i=t[s];if(!(this.selectDefaultTrack&&!i.default)&&(!e||ot(e,i,nt)))return s}if(e){const{name:s,lang:i,assocLang:r,characteristics:n,audioCodec:o,channels:d}=e;for(let l=0;l<t.length;l++){const c=t[l];if(ot({name:s,lang:i,assocLang:r,characteristics:n,audioCodec:o,channels:d},c,nt))return l}for(let l=0;l<t.length;l++){const c=t[l];if(Ut(e.attrs,c.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return l}for(let l=0;l<t.length;l++){const c=t[l];if(Ut(e.attrs,c.attrs,["LANGUAGE"]))return l}}return-1}loadPlaylist(e){super.loadPlaylist();const t=this.currentTrack;this.shouldLoadPlaylist(t)&&ys(t.url,this.hls)&&this.scheduleLoading(t,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const s=e.id,i=e.groupId,r=this.getUrlWithDirectives(e.url,t),n=e.details,o=n==null?void 0:n.age;this.log("Loading audio-track ".concat(s,' "').concat(e.name,'" lang:').concat(e.lang," group:").concat(i).concat((t==null?void 0:t.msn)!==void 0?" at sn "+t.msn+" part "+t.part:"").concat(o&&n.live?" age "+o.toFixed(1)+(n.type&&" "+n.type||""):""," ").concat(r)),this.hls.trigger(y.AUDIO_TRACK_LOADING,{url:r,id:s,groupId:i,deliveryDirectives:t||null,track:e})}}class Hd{constructor(e){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=e}destroy(){this.tracks=this.queues=null}append(e,t,s){if(this.queues===null||this.tracks===null)return;const i=this.queues[t];i.push(e),i.length===1&&!s&&this.executeNext(t)}appendBlocker(e){return new Promise(t=>{const s={label:"async-blocker",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.append(s,e)})}prependBlocker(e){return new Promise(t=>{if(this.queues){const s={label:"async-blocker-prepend",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.queues[e].unshift(s)}})}removeBlockers(){this.queues!==null&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(e=>{var t;const s=(t=e[0])==null?void 0:t.label;(s==="async-blocker"||s==="async-blocker-prepend")&&(e[0].execute(),e.splice(0,1))})}unblockAudio(e){if(this.queues===null)return;this.queues.audio[0]===e&&this.shiftAndExecuteNext("audio")}executeNext(e){if(this.queues===null||this.tracks===null)return;const t=this.queues[e];if(t.length){const i=t[0];try{i.execute()}catch(r){var s;if(i.onError(r),this.queues===null||this.tracks===null)return;const n=(s=this.tracks[e])==null?void 0:s.buffer;n!=null&&n.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){this.queues!==null&&(this.queues[e].shift(),this.executeNext(e))}current(e){var t;return((t=this.queues)==null?void 0:t[e][0])||null}toString(){const{queues:e,tracks:t}=this;return e===null||t===null?"<destroyed>":"\n".concat(this.list("video"),"\n").concat(this.list("audio"),"\n").concat(this.list("audiovideo"),"}")}list(e){var t,s;return(t=this.queues)!=null&&t[e]||(s=this.tracks)!=null&&s[e]?"".concat(e,": (").concat(this.listSbInfo(e),") ").concat(this.listOps(e)):""}listSbInfo(e){var t;const s=(t=this.tracks)==null?void 0:t[e],i=s==null?void 0:s.buffer;return i?"SourceBuffer".concat(i.updating?" updating":"").concat(s.ended?" ended":"").concat(s.ending?" ending":""):"none"}listOps(e){var t;return((t=this.queues)==null?void 0:t[e].map(s=>s.label).join(", "))||""}}const Wr=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,va="HlsJsTrackRemovedError";class Wd extends Error{constructor(e){super(e),this.name=va}}class Yd extends Pe{constructor(e,t){super("buffer-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.details=null,this._objectUrl=null,this.operationQueue=null,this.bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.blockedAudioAppend=null,this.lastVideoAppendEnd=0,this.appendSource=void 0,this.transferData=void 0,this.overrides=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.sourceBuffers=[[null,null],[null,null]],this._onEndStreaming=s=>{var i;this.hls&&((i=this.mediaSource)==null?void 0:i.readyState)==="open"&&this.hls.pauseBuffering()},this._onStartStreaming=s=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=s=>{const{media:i,mediaSource:r}=this;s&&this.log("Media source opened"),!(!i||!r)&&(r.removeEventListener("sourceopen",this._onMediaSourceOpen),i.removeEventListener("emptied",this._onMediaEmptied),this.updateDuration(),this.hls.trigger(y.MEDIA_ATTACHED,{media:i,mediaSource:r}),this.mediaSource!==null&&this.checkPendingTracks())},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{const{mediaSrc:s,_objectUrl:i}=this;s!==i&&this.error("Media element src was set while attaching MediaSource (".concat(i," > ").concat(s,")"))},this.hls=e,this.fragmentTracker=t,this.appendSource=go(Je(e.config.preferManagedMediaSource)),this.initTracks(),this.registerListeners()}hasSourceTypes(){return Object.keys(this.tracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.transferData=this.overrides=void 0,this.operationQueue&&(this.operationQueue.destroy(),this.operationQueue=null),this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null}registerListeners(){const{hls:e}=this;e.on(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.BUFFER_RESET,this.onBufferReset,this),e.on(y.BUFFER_APPENDING,this.onBufferAppending,this),e.on(y.BUFFER_CODECS,this.onBufferCodecs,this),e.on(y.BUFFER_EOS,this.onBufferEos,this),e.on(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(y.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(y.FRAG_PARSED,this.onFragParsed,this),e.on(y.FRAG_CHANGED,this.onFragChanged,this),e.on(y.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.BUFFER_RESET,this.onBufferReset,this),e.off(y.BUFFER_APPENDING,this.onBufferAppending,this),e.off(y.BUFFER_CODECS,this.onBufferCodecs,this),e.off(y.BUFFER_EOS,this.onBufferEos,this),e.off(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(y.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(y.FRAG_PARSED,this.onFragParsed,this),e.off(y.FRAG_CHANGED,this.onFragChanged,this),e.off(y.ERROR,this.onError,this)}transferMedia(){const{media:e,mediaSource:t}=this;if(!e)return null;const s={};if(this.operationQueue){const r=this.isUpdating();r||this.operationQueue.removeBlockers();const n=this.isQueued();(r||n)&&this.warn("Transfering MediaSource with".concat(n?" operations in queue":"").concat(r?" updating SourceBuffer(s)":""," ").concat(this.operationQueue)),this.operationQueue.destroy()}const i=this.transferData;return!this.sourceBufferCount&&i&&i.mediaSource===t?ie(s,i.tracks):this.sourceBuffers.forEach(r=>{const[n]=r;n&&(s[n]=ie({},this.tracks[n]),this.removeBuffer(n)),r[0]=r[1]=null}),{media:e,mediaSource:t,tracks:s}}initTracks(){const e={};this.sourceBuffers=[[null,null],[null,null]],this.tracks=e,this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0}onManifestLoading(){this.bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){var s;let i=2;(t.audio&&!t.video||!t.altAudio)&&(i=1),this.bufferCodecEventsTotal=i,this.log("".concat(i," bufferCodec event(s) expected.")),(s=this.transferData)!=null&&s.mediaSource&&this.sourceBufferCount&&i&&this.bufferCreated()}onMediaAttaching(e,t){const s=this.media=t.media;this.transferData=this.overrides=void 0;const i=Je(this.appendSource);if(i){const r=!!t.mediaSource;(r||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);const n=this.mediaSource=t.mediaSource||new i;if(this.assignMediaSource(n),r)this._objectUrl=s.src,this.attachTransferred();else{const o=this._objectUrl=self.URL.createObjectURL(n);if(this.appendSource)try{s.removeAttribute("src");const d=self.ManagedMediaSource;s.disableRemotePlayback=s.disableRemotePlayback||d&&n instanceof d,Yr(s),qd(s,o),s.load()}catch(d){s.src=o}else s.src=o}s.addEventListener("emptied",this._onMediaEmptied)}}assignMediaSource(e){var t,s;this.log("".concat(((t=this.transferData)==null?void 0:t.mediaSource)===e?"transferred":"created"," media source: ").concat((s=e.constructor)==null?void 0:s.name)),e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.addEventListener("startstreaming",this._onStartStreaming),e.addEventListener("endstreaming",this._onEndStreaming))}attachTransferred(){const e=this.media,t=this.transferData;if(!t||!e)return;const s=this.tracks,i=t.tracks,r=i?Object.keys(i):null,n=r?r.length:0,o=()=>{Promise.resolve().then(()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen()})};if(i&&r&&n){if(!this.tracksReady){this.hls.config.startFragPrefetch=!0,this.log("attachTransferred: waiting for SourceBuffer track info");return}if(this.log("attachTransferred: (bufferCodecEventsTotal ".concat(this.bufferCodecEventsTotal,")\nrequired tracks: ").concat(ne(s,(d,l)=>d==="initSegment"?void 0:l),";\ntransfer tracks: ").concat(ne(i,(d,l)=>d==="initSegment"?void 0:l),"}")),!yn(i,s)){t.mediaSource=null,t.tracks=void 0;const d=e.currentTime,l=this.details,c=Math.max(d,(l==null?void 0:l.fragments[0].start)||0);if(c-d>1){this.log("attachTransferred: waiting for playback to reach new tracks start time ".concat(d," -> ").concat(c));return}this.warn('attachTransferred: resetting MediaSource for incompatible tracks ("'.concat(Object.keys(i),'"->"').concat(Object.keys(s),'") start time: ').concat(c," currentTime: ").concat(d)),this.onMediaDetaching(y.MEDIA_DETACHING,{}),this.onMediaAttaching(y.MEDIA_ATTACHING,t),e.currentTime=c;return}this.transferData=void 0,r.forEach(d=>{const l=d,c=i[l];if(c){const u=c.buffer;if(u){const h=this.fragmentTracker,f=c.id;if(h.hasFragments(f)||h.hasParts(f)){const p=X.getBuffered(u);h.detectEvictedFragments(l,p,f,null,!0)}const g=Gs(l),m=[l,u];this.sourceBuffers[g]=m,u.updating&&this.operationQueue&&this.operationQueue.prependBlocker(l),this.trackSourceBuffer(l,c)}}}),o(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),o()}get mediaSourceOpenOrEnded(){var e;const t=(e=this.mediaSource)==null?void 0:e.readyState;return t==="open"||t==="ended"}onMediaDetaching(e,t){const s=!!t.transferMedia;this.transferData=this.overrides=void 0;const{media:i,mediaSource:r,_objectUrl:n}=this;if(r){if(this.log("media source ".concat(s?"transferring":"detaching")),s)this.sourceBuffers.forEach(([o])=>{o&&this.removeBuffer(o)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){const o=r.readyState==="open";try{const d=r.sourceBuffers;for(let l=d.length;l--;)o&&d[l].abort(),r.removeSourceBuffer(d[l]);o&&r.endOfStream()}catch(d){this.warn("onMediaDetaching: ".concat(d.message," while calling endOfStream"))}}this.sourceBufferCount&&this.onBufferReset()}r.removeEventListener("sourceopen",this._onMediaSourceOpen),r.removeEventListener("sourceended",this._onMediaSourceEnded),r.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(r.removeEventListener("startstreaming",this._onStartStreaming),r.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}i&&(i.removeEventListener("emptied",this._onMediaEmptied),s||(n&&self.URL.revokeObjectURL(n),this.mediaSrc===n?(i.removeAttribute("src"),this.appendSource&&Yr(i),i.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(y.MEDIA_DETACHED,t)}onBufferReset(){this.sourceBuffers.forEach(([e])=>{e&&this.resetBuffer(e)}),this.initTracks()}resetBuffer(e){var t;const s=(t=this.tracks[e])==null?void 0:t.buffer;if(this.removeBuffer(e),s)try{var i;(i=this.mediaSource)!=null&&i.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(s)}catch(r){this.warn("onBufferReset ".concat(e),r)}delete this.tracks[e]}removeBuffer(e){this.removeBufferListeners(e),this.sourceBuffers[Gs(e)]=[null,null];const t=this.tracks[e];t&&(t.buffer=void 0)}resetQueue(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new Hd(this.tracks)}onBufferCodecs(e,t){var s;const i=this.tracks,r=Object.keys(t);this.log('BUFFER_CODECS: "'.concat(r,'" (current SB count ').concat(this.sourceBufferCount,")"));const n="audiovideo"in t&&(i.audio||i.video)||i.audiovideo&&("audio"in t||"video"in t),o=!n&&this.sourceBufferCount&&this.media&&r.some(d=>!i[d]);if(n||o){this.warn('Unsupported transition between "'.concat(Object.keys(i),'" and "').concat(r,'" SourceBuffers'));return}r.forEach(d=>{var l,c;const u=t[d],{id:h,codec:f,levelCodec:g,container:m,metadata:p,supplemental:v}=u;let E=i[d];const T=(l=this.transferData)==null||(l=l.tracks)==null?void 0:l[d],S=T!=null&&T.buffer?T:E,x=(S==null?void 0:S.pendingCodec)||(S==null?void 0:S.codec),b=S==null?void 0:S.levelCodec;E||(E=i[d]={buffer:void 0,listeners:[],codec:f,supplemental:v,container:m,levelCodec:g,metadata:p,id:h});const A=ns(x,b),I=A==null?void 0:A.replace(Wr,"$1");let R=ns(f,g);const L=(c=R)==null?void 0:c.replace(Wr,"$1");R&&A&&I!==L&&(d.slice(0,5)==="audio"&&(R=ms(R,this.appendSource)),this.log("switching codec ".concat(x," to ").concat(R)),R!==(E.pendingCodec||E.codec)&&(E.pendingCodec=R),E.container=m,this.appendChangeType(d,m,R))}),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),!this.sourceBufferCount&&(this.bufferCodecEventsTotal>1&&!this.tracks.video&&!t.video&&((s=t.audio)==null?void 0:s.id)==="main"&&(this.log("Main audio-only"),this.bufferCodecEventsTotal=1),this.mediaSourceOpenOrEnded&&this.checkPendingTracks())}get sourceBufferTracks(){return Object.keys(this.tracks).reduce((e,t)=>{const s=this.tracks[t];return e[t]={id:s.id,container:s.container,codec:s.codec,levelCodec:s.levelCodec},e},{})}appendChangeType(e,t,s){const i="".concat(t,";codecs=").concat(s),r={label:"change-type=".concat(i),execute:()=>{const n=this.tracks[e];if(n){const o=n.buffer;o!=null&&o.changeType&&(this.log("changing ".concat(e," sourceBuffer type to ").concat(i)),o.changeType(i),n.codec=s,n.container=t)}this.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:n=>{this.warn("Failed to change ".concat(e," SourceBuffer type"),n)}};this.append(r,e,this.isPending(this.tracks[e]))}blockAudio(e){var t;const s=e.start,i=s+e.duration*.05;if(((t=this.fragmentTracker.getAppendedFrag(s,H.MAIN))==null?void 0:t.gap)===!0)return;const n={label:"block-audio",execute:()=>{var o;const d=this.tracks.video;(this.lastVideoAppendEnd>i||d!=null&&d.buffer&&X.isBuffered(d.buffer,i)||((o=this.fragmentTracker.getAppendedFrag(i,H.MAIN))==null?void 0:o.gap)===!0)&&(this.blockedAudioAppend=null,this.shiftAndExecuteNext("audio"))},onStart:()=>{},onComplete:()=>{},onError:o=>{this.warn("Error executing block-audio operation",o)}};this.blockedAudioAppend={op:n,frag:e},this.append(n,"audio",!0)}unblockAudio(){const{blockedAudioAppend:e,operationQueue:t}=this;e&&t&&(this.blockedAudioAppend=null,t.unblockAudio(e.op))}onBufferAppending(e,t){const{tracks:s}=this,{data:i,type:r,parent:n,frag:o,part:d,chunkMeta:l,offset:c}=t,u=l.buffering[r],{sn:h,cc:f}=o,g=self.performance.now();u.start=g;const m=o.stats.buffering,p=d?d.stats.buffering:null;m.start===0&&(m.start=g),p&&p.start===0&&(p.start=g);const v=s.audio;let E=!1;r==="audio"&&(v==null?void 0:v.container)==="audio/mpeg"&&(E=!this.lastMpegAudioChunk||l.id===1||this.lastMpegAudioChunk.sn!==l.sn,this.lastMpegAudioChunk=l);const T=s.video,S=T==null?void 0:T.buffer;if(S&&h!=="initSegment"){const A=d||o,I=this.blockedAudioAppend;if(r==="audio"&&n!=="main"&&!this.blockedAudioAppend&&!(T.ending||T.ended)){const L=A.start+A.duration*.05,w=S.buffered,U=this.currentOp("video");!w.length&&!U?this.blockAudio(A):!U&&!X.isBuffered(S,L)&&this.lastVideoAppendEnd<L&&this.blockAudio(A)}else if(r==="video"){const R=A.end;if(I){const L=I.frag.start;(R>L||R<this.lastVideoAppendEnd||X.isBuffered(S,L))&&this.unblockAudio()}this.lastVideoAppendEnd=R}}const x=(d||o).start,b={label:"append-".concat(r),execute:()=>{var A;u.executeStart=self.performance.now();const I=(A=this.tracks[r])==null?void 0:A.buffer;I&&(E?this.updateTimestampOffset(I,x,.1,r,h,f):c!==void 0&&K(c)&&this.updateTimestampOffset(I,c,1e-6,r,h,f)),this.appendExecutor(i,r)},onStart:()=>{},onComplete:()=>{const A=self.performance.now();u.executeEnd=u.end=A,m.first===0&&(m.first=A),p&&p.first===0&&(p.first=A);const I={};this.sourceBuffers.forEach(([R,L])=>{R&&(I[R]=X.getBuffered(L))}),this.appendErrors[r]=0,r==="audio"||r==="video"?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(y.BUFFER_APPENDED,{type:r,frag:o,part:d,chunkMeta:l,parent:o.type,timeRanges:I})},onError:A=>{var I;const R={type:W.MEDIA_ERROR,parent:o.type,details:_.BUFFER_APPEND_ERROR,sourceBufferName:r,frag:o,part:d,chunkMeta:l,error:A,err:A,fatal:!1},L=(I=this.media)==null?void 0:I.error;if(A.code===DOMException.QUOTA_EXCEEDED_ERR||A.name=="QuotaExceededError"||"quota"in A)R.details=_.BUFFER_FULL_ERROR;else if(A.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!L)R.errorAction=yt(!0);else if(A.name===va&&this.sourceBufferCount===0)R.errorAction=yt(!0);else{const w=++this.appendErrors[r];this.warn("Failed ".concat(w,"/").concat(this.hls.config.appendErrorMaxRetry,' times to append segment in "').concat(r,'" sourceBuffer (').concat(L||"no media error",")")),(w>=this.hls.config.appendErrorMaxRetry||L)&&(R.fatal=!0)}this.hls.trigger(y.ERROR,R)}};this.log('queuing "'.concat(r,'" append sn: ').concat(h).concat(d?" p: "+d.index:""," of ").concat(o.type===H.MAIN?"level":"track"," ").concat(o.level," cc: ").concat(f)),this.append(b,r,this.isPending(this.tracks[r]))}getFlushOp(e,t,s){return this.log('queuing "'.concat(e,'" remove ').concat(t,"-").concat(s)),{label:"remove",execute:()=>{this.removeExecutor(e,t,s)},onStart:()=>{},onComplete:()=>{this.hls.trigger(y.BUFFER_FLUSHED,{type:e})},onError:i=>{this.warn("Failed to remove ".concat(t,"-").concat(s,' from "').concat(e,'" SourceBuffer'),i)}}}onBufferFlushing(e,t){const{type:s,startOffset:i,endOffset:r}=t;s?this.append(this.getFlushOp(s,i,r),s):this.sourceBuffers.forEach(([n])=>{n&&this.append(this.getFlushOp(n,i,r),n)})}onFragParsed(e,t){const{frag:s,part:i}=t,r=[],n=i?i.elementaryStreams:s.elementaryStreams;n[re.AUDIOVIDEO]?r.push("audiovideo"):(n[re.AUDIO]&&r.push("audio"),n[re.VIDEO]&&r.push("video"));const o=()=>{const d=self.performance.now();s.stats.buffering.end=d,i&&(i.stats.buffering.end=d);const l=i?i.stats:s.stats;this.hls.trigger(y.FRAG_BUFFERED,{frag:s,part:i,stats:l,id:s.type})};r.length===0&&this.warn("Fragments must have at least one ElementaryStreamType set. type: ".concat(s.type," level: ").concat(s.level," sn: ").concat(s.sn)),this.blockBuffers(o,r).catch(d=>{this.warn("Fragment buffered callback ".concat(d)),this.stepOperationQueue(this.sourceBufferTypes)})}onFragChanged(e,t){this.trimBuffers()}get bufferedToEnd(){return this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{if(e){const t=this.tracks[e];if(t)return!t.ended||t.ending}return!1})}onBufferEos(e,t){var s;this.sourceBuffers.forEach(([n])=>{if(n){const o=this.tracks[n];(!t.type||t.type===n)&&(o.ending=!0,o.ended||(o.ended=!0,this.log("".concat(n," buffer reached EOS"))))}});const i=((s=this.overrides)==null?void 0:s.endOfStream)!==!1;this.sourceBufferCount>0&&!this.sourceBuffers.some(([n])=>{var o;return n&&!((o=this.tracks[n])!=null&&o.ended)})?i?(this.log("Queueing EOS"),this.blockUntilOpen(()=>{this.tracksEnded();const{mediaSource:n}=this;if(!n||n.readyState!=="open"){n&&this.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: ".concat(n.readyState));return}this.log("Calling mediaSource.endOfStream()"),n.endOfStream(),this.hls.trigger(y.BUFFERED_TO_END,void 0)})):(this.tracksEnded(),this.hls.trigger(y.BUFFERED_TO_END,void 0)):t.type==="video"&&this.unblockAudio()}tracksEnded(){this.sourceBuffers.forEach(([e])=>{if(e!==null){const t=this.tracks[e];t&&(t.ending=!1)}})}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.updateDuration())}updateDuration(){this.blockUntilOpen(()=>{const e=this.getDurationAndRange();e&&this.updateMediaSource(e)})}onError(e,t){if(t.details===_.BUFFER_APPEND_ERROR&&t.frag){var s;const i=(s=t.errorAction)==null?void 0:s.nextAutoLevel;K(i)&&i!==t.frag.level&&this.resetAppendErrors()}}resetAppendErrors(){this.appendErrors={audio:0,video:0,audiovideo:0}}trimBuffers(){const{hls:e,details:t,media:s}=this;if(!s||t===null||!this.sourceBufferCount)return;const i=e.config,r=s.currentTime,n=t.levelTargetDuration,o=t.live&&i.liveBackBufferLength!==null?i.liveBackBufferLength:i.backBufferLength;if(K(o)&&o>=0){const l=Math.max(o,n),c=Math.floor(r/n)*n-l;this.flushBackBuffer(r,n,c)}const d=i.frontBufferFlushThreshold;if(K(d)&&d>0){const l=Math.max(i.maxBufferLength,d),c=Math.max(l,n),u=Math.floor(r/n)*n+c;this.flushFrontBuffer(r,n,u)}}flushBackBuffer(e,t,s){this.sourceBuffers.forEach(([i,r])=>{if(r){const o=X.getBuffered(r);if(o.length>0&&s>o.start(0)){var n;this.hls.trigger(y.BACK_BUFFER_REACHED,{bufferEnd:s});const d=this.tracks[i];if((n=this.details)!=null&&n.live)this.hls.trigger(y.LIVE_BACK_BUFFER_REACHED,{bufferEnd:s});else if(d!=null&&d.ended){this.log("Cannot flush ".concat(i," back buffer while SourceBuffer is in ended state"));return}this.hls.trigger(y.BUFFER_FLUSHING,{startOffset:0,endOffset:s,type:i})}}})}flushFrontBuffer(e,t,s){this.sourceBuffers.forEach(([i,r])=>{if(r){const n=X.getBuffered(r),o=n.length;if(o<2)return;const d=n.start(o-1),l=n.end(o-1);if(s>d||e>=d&&e<=l)return;this.hls.trigger(y.BUFFER_FLUSHING,{startOffset:d,endOffset:1/0,type:i})}})}getDurationAndRange(){var e;const{details:t,mediaSource:s}=this;if(!t||!this.media||(s==null?void 0:s.readyState)!=="open")return null;const i=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(t.fragments.length&&s.setLiveSeekableRange){const l=Math.max(0,t.fragmentStart),c=Math.max(l,i);return{duration:1/0,start:l,end:c}}return{duration:1/0}}const r=(e=this.overrides)==null?void 0:e.duration;if(r)return K(r)?{duration:r}:null;const n=this.media.duration,o=K(s.duration)?s.duration:0;return i>o&&i>n||!K(n)?{duration:i}:null}updateMediaSource({duration:e,start:t,end:s}){const i=this.mediaSource;!this.media||!i||i.readyState!=="open"||(i.duration!==e&&(K(e)&&this.log("Updating MediaSource duration to ".concat(e.toFixed(3))),i.duration=e),t!==void 0&&s!==void 0&&(this.log("MediaSource duration is set to ".concat(i.duration,". Setting seekable range to ").concat(t,"-").concat(s,".")),i.setLiveSeekableRange(t,s)))}get tracksReady(){const e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}checkPendingTracks(){const{bufferCodecEventsTotal:e,pendingTrackCount:t,tracks:s}=this;if(this.log("checkPendingTracks (pending: ".concat(t," codec events expected: ").concat(e,") ").concat(ne(s))),this.tracksReady){var i;const r=(i=this.transferData)==null?void 0:i.tracks;r&&Object.keys(r).length?this.attachTransferred():this.createSourceBuffers()}}bufferCreated(){if(this.sourceBufferCount){const e={};this.sourceBuffers.forEach(([t,s])=>{if(t){const i=this.tracks[t];e[t]={buffer:s,container:i.container,codec:i.codec,supplemental:i.supplemental,levelCodec:i.levelCodec,id:i.id,metadata:i.metadata}}}),this.hls.trigger(y.BUFFER_CREATED,{tracks:e}),this.log("SourceBuffers created. Running queue: ".concat(this.operationQueue)),this.sourceBuffers.forEach(([t])=>{this.executeNext(t)})}else{const e=new Error("could not create source buffer for media codec(s)");this.hls.trigger(y.ERROR,{type:W.MEDIA_ERROR,details:_.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:e,reason:e.message})}}createSourceBuffers(){const{tracks:e,sourceBuffers:t,mediaSource:s}=this;if(!s)throw new Error("createSourceBuffers called when mediaSource was null");for(const r in e){const n=r,o=e[n];if(this.isPending(o)){const d=this.getTrackCodec(o,n),l="".concat(o.container,";codecs=").concat(d);o.codec=d,this.log("creating sourceBuffer(".concat(l,")").concat(this.currentOp(n)?" Queued":""," ").concat(ne(o)));try{const c=s.addSourceBuffer(l),u=Gs(n),h=[n,c];t[u]=h,o.buffer=c}catch(c){var i;this.error("error while trying to add sourceBuffer: ".concat(c.message)),this.shiftAndExecuteNext(n),(i=this.operationQueue)==null||i.removeBlockers(),delete this.tracks[n],this.hls.trigger(y.ERROR,{type:W.MEDIA_ERROR,details:_.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:c,sourceBufferName:n,mimeType:l,parent:o.id});return}this.trackSourceBuffer(n,o)}}this.bufferCreated()}getTrackCodec(e,t){const s=e.supplemental;let i=e.codec;s&&(t==="video"||t==="audiovideo")&&wt(s,"video")&&(i=Mo(i,s));const r=ns(i,e.levelCodec);return r?t.slice(0,5)==="audio"?ms(r,this.appendSource):r:""}trackSourceBuffer(e,t){const s=t.buffer;if(!s)return;const i=this.getTrackCodec(t,e);this.tracks[e]={buffer:s,codec:i,container:t.container,levelCodec:t.levelCodec,supplemental:t.supplemental,metadata:t.metadata,id:t.id,listeners:[]},this.removeBufferListeners(e),this.addBufferListener(e,"updatestart",this.onSBUpdateStart),this.addBufferListener(e,"updateend",this.onSBUpdateEnd),this.addBufferListener(e,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(e,"bufferedchange",(r,n)=>{const o=n.removedRanges;o!=null&&o.length&&this.hls.trigger(y.BUFFER_FLUSHED,{type:r})})}get mediaSrc(){var e,t;const s=((e=this.media)==null||(t=e.querySelector)==null?void 0:t.call(e,"source"))||this.media;return s==null?void 0:s.src}onSBUpdateStart(e){const t=this.currentOp(e);t&&t.onStart()}onSBUpdateEnd(e){var t;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}const s=this.currentOp(e);s&&(s.onComplete(),this.shiftAndExecuteNext(e))}onSBUpdateError(e,t){var s;const i=new Error("".concat(e," SourceBuffer error. MediaSource readyState: ").concat((s=this.mediaSource)==null?void 0:s.readyState));this.error("".concat(i),t),this.hls.trigger(y.ERROR,{type:W.MEDIA_ERROR,details:_.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:i,fatal:!1});const r=this.currentOp(e);r&&r.onError(i)}updateTimestampOffset(e,t,s,i,r,n){const o=t-e.timestampOffset;Math.abs(o)>=s&&(this.log("Updating ".concat(i," SourceBuffer timestampOffset to ").concat(t," (sn: ").concat(r," cc: ").concat(n,")")),e.timestampOffset=t)}removeExecutor(e,t,s){const{media:i,mediaSource:r}=this,n=this.tracks[e],o=n==null?void 0:n.buffer;if(!i||!r||!o){this.warn("Attempting to remove from the ".concat(e," SourceBuffer, but it does not exist")),this.shiftAndExecuteNext(e);return}const d=K(i.duration)?i.duration:1/0,l=K(r.duration)?r.duration:1/0,c=Math.max(0,t),u=Math.min(s,d,l);u>c&&(!n.ending||n.ended)?(n.ended=!1,this.log("Removing [".concat(c,",").concat(u,"] from the ").concat(e," SourceBuffer")),o.remove(c,u)):this.shiftAndExecuteNext(e)}appendExecutor(e,t){const s=this.tracks[t],i=s==null?void 0:s.buffer;if(!i)throw new Wd("Attempting to append to the ".concat(t," SourceBuffer, but it does not exist"));s.ending=!1,s.ended=!1,i.appendBuffer(e)}blockUntilOpen(e){if(this.isUpdating()||this.isQueued())this.blockBuffers(e).catch(t=>{this.warn("SourceBuffer blocked callback ".concat(t)),this.stepOperationQueue(this.sourceBufferTypes)});else try{e()}catch(t){this.warn("Callback run without blocking ".concat(this.operationQueue," ").concat(t))}}isUpdating(){return this.sourceBuffers.some(([e,t])=>e&&t.updating)}isQueued(){return this.sourceBuffers.some(([e])=>e&&!!this.currentOp(e))}isPending(e){return!!e&&!e.buffer}blockBuffers(e,t=this.sourceBufferTypes){if(!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);const{operationQueue:s}=this,i=t.map(n=>this.appendBlocker(n));return t.length>1&&!!this.blockedAudioAppend&&this.unblockAudio(),Promise.all(i).then(n=>{s===this.operationQueue&&(e(),this.stepOperationQueue(this.sourceBufferTypes))})}stepOperationQueue(e){e.forEach(t=>{var s;const i=(s=this.tracks[t])==null?void 0:s.buffer;!i||i.updating||this.shiftAndExecuteNext(t)})}append(e,t,s){this.operationQueue&&this.operationQueue.append(e,t,s)}appendBlocker(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)}currentOp(e){return this.operationQueue?this.operationQueue.current(e):null}executeNext(e){e&&this.operationQueue&&this.operationQueue.executeNext(e)}shiftAndExecuteNext(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e)}get pendingTrackCount(){return Object.keys(this.tracks).reduce((e,t)=>e+(this.isPending(this.tracks[t])?1:0),0)}get sourceBufferCount(){return this.sourceBuffers.reduce((e,[t])=>e+(t?1:0),0)}get sourceBufferTypes(){return this.sourceBuffers.map(([e])=>e).filter(e=>!!e)}addBufferListener(e,t,s){const i=this.tracks[e];if(!i)return;const r=i.buffer;if(!r)return;const n=s.bind(this,e);i.listeners.push({event:t,listener:n}),r.addEventListener(t,n)}removeBufferListeners(e){const t=this.tracks[e];if(!t)return;const s=t.buffer;s&&(t.listeners.forEach(i=>{s.removeEventListener(i.event,i.listener)}),t.listeners.length=0)}}function Yr(a){const e=a.querySelectorAll("source");[].slice.call(e).forEach(t=>{a.removeChild(t)})}function qd(a,e){const t=self.document.createElement("source");t.type="video/mp4",t.src=e,a.appendChild(t)}function Gs(a){return a==="audio"?1:0}class Ni{constructor(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:e}=this;e.on(y.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(y.BUFFER_CODECS,this.onBufferCodecs,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(y.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(y.BUFFER_CODECS,this.onBufferCodecs,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){const s=this.hls.levels[t.droppedLevel];this.isLevelAllowed(s)&&this.restrictedLevels.push({bitrate:s.bitrate,height:s.height,width:s.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(e,t){const s=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,s.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onLevelsUpdated(e,t){this.timer&&K(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping(),this.media=null}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}const e=this.hls.levels;if(e.length){const t=this.hls,s=this.getMaxLevel(e.length-1);s!==this.autoLevelCapping&&t.logger.log("Setting autoLevelCapping to ".concat(s,": ").concat(e[s].height,"p@").concat(e[s].bitrate," for media ").concat(this.mediaWidth,"x").concat(this.mediaHeight)),t.autoLevelCapping=s,t.autoLevelEnabled&&t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){const t=this.hls.levels;if(!t.length)return-1;const s=t.filter((i,r)=>this.isLevelAllowed(i)&&r<=e);return this.clientRect=null,Ni.getMaxLevelByMediaSize(s,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;const e=this.media,t={width:0,height:0};if(e){const s=e.getBoundingClientRect();t.width=s.width,t.height=s.height,!t.width&&!t.height&&(t.width=s.right-s.left||e.width||0,t.height=s.bottom-s.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(t){}return Math.min(e,this.hls.config.maxDevicePixelRatio)}isLevelAllowed(e){return!this.restrictedLevels.some(s=>e.bitrate===s.bitrate&&e.width===s.width&&e.height===s.height)}static getMaxLevelByMediaSize(e,t,s){if(!(e!=null&&e.length))return-1;const i=(o,d)=>d?o.width!==d.width||o.height!==d.height:!0;let r=e.length-1;const n=Math.max(t,s);for(let o=0;o<e.length;o+=1){const d=e[o];if((d.width>=n||d.height>=n)&&i(d,e[o+1])){r=o;break}}return r}}const jd={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},xe=jd,zd={HLS:"h"},Xd=zd;class Ve{constructor(e,t){Array.isArray(e)&&(e=e.map(s=>s instanceof Ve?s:new Ve(s))),this.value=e,this.params=t}}const Qd="Dict";function Zd(a){return Array.isArray(a)?JSON.stringify(a):a instanceof Map?"Map{}":a instanceof Set?"Set{}":typeof a=="object"?JSON.stringify(a):String(a)}function Jd(a,e,t,s){return new Error("failed to ".concat(a,' "').concat(Zd(e),'" as ').concat(t),{cause:s})}function He(a,e,t){return Jd("serialize",a,e,t)}class Ea{constructor(e){this.description=e}}const qr="Bare Item",ec="Boolean";function tc(a){if(typeof a!="boolean")throw He(a,ec);return a?"?1":"?0"}function sc(a){return btoa(String.fromCharCode(...a))}const ic="Byte Sequence";function rc(a){if(ArrayBuffer.isView(a)===!1)throw He(a,ic);return":".concat(sc(a),":")}const nc="Integer";function ac(a){return a<-999999999999999||999999999999999<a}function Ta(a){if(ac(a))throw He(a,nc);return a.toString()}function oc(a){return"@".concat(Ta(a.getTime()/1e3))}function Sa(a,e){if(a<0)return-Sa(-a,e);const t=Math.pow(10,e);if(Math.abs(a*t%1-.5)<Number.EPSILON){const i=Math.floor(a*t);return(i%2===0?i:i+1)/t}else return Math.round(a*t)/t}const lc="Decimal";function dc(a){const e=Sa(a,3);if(Math.floor(Math.abs(e)).toString().length>12)throw He(a,lc);const t=e.toString();return t.includes(".")?t:"".concat(t,".0")}const cc="String",uc=/[\x00-\x1f\x7f]+/;function hc(a){if(uc.test(a))throw He(a,cc);return'"'.concat(a.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),'"')}function fc(a){return a.description||a.toString().slice(7,-1)}const gc="Token";function jr(a){const e=fc(a);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===!1)throw He(e,gc);return e}function ui(a){switch(typeof a){case"number":if(!K(a))throw He(a,qr);return Number.isInteger(a)?Ta(a):dc(a);case"string":return hc(a);case"symbol":return jr(a);case"boolean":return tc(a);case"object":if(a instanceof Date)return oc(a);if(a instanceof Uint8Array)return rc(a);if(a instanceof Ea)return jr(a);default:throw He(a,qr)}}const mc="Key";function hi(a){if(/^[a-z*][a-z0-9\-_.*]*$/.test(a)===!1)throw He(a,mc);return a}function Bi(a){return a==null?"":Object.entries(a).map(([e,t])=>t===!0?";".concat(hi(e)):";".concat(hi(e),"=").concat(ui(t))).join("")}function xa(a){return a instanceof Ve?"".concat(ui(a.value)).concat(Bi(a.params)):ui(a)}function pc(a){return"(".concat(a.value.map(xa).join(" "),")").concat(Bi(a.params))}function yc(a,e={whitespace:!0}){if(typeof a!="object"||a==null)throw He(a,Qd);const t=a instanceof Map?a.entries():Object.entries(a),s=e!=null&&e.whitespace?" ":"";return Array.from(t).map(([i,r])=>{r instanceof Ve||(r=new Ve(r));let n=hi(i);return r.value===!0?n+=Bi(r.params):(n+="=",Array.isArray(r.value)?n+=pc(r):n+=xa(r)),n}).join(",".concat(s))}function Aa(a,e){return yc(a,e)}const $e="CMCD-Object",ue="CMCD-Request",it="CMCD-Session",Xe="CMCD-Status",vc={br:$e,ab:$e,d:$e,ot:$e,tb:$e,tpb:$e,lb:$e,tab:$e,lab:$e,url:$e,pb:ue,bl:ue,tbl:ue,dl:ue,ltc:ue,mtp:ue,nor:ue,nrr:ue,rc:ue,sn:ue,sta:ue,su:ue,ttfb:ue,ttfbb:ue,ttlb:ue,cmsdd:ue,cmsds:ue,smrt:ue,df:ue,cs:ue,ts:ue,cid:it,pr:it,sf:it,sid:it,st:it,v:it,msd:it,bs:Xe,bsd:Xe,cdn:Xe,rtp:Xe,bg:Xe,pt:Xe,ec:Xe,e:Xe},Ec={REQUEST:ue};function Tc(a){return Object.keys(a).reduce((e,t)=>{var s;return(s=a[t])===null||s===void 0||s.forEach(i=>e[i]=t),e},{})}function Sc(a,e){const t={};if(!a)return t;const s=Object.keys(a),i=e?Tc(e):{};return s.reduce((r,n)=>{var o;const d=vc[n]||i[n]||Ec.REQUEST,l=(o=r[d])!==null&&o!==void 0?o:r[d]={};return l[n]=a[n],r},t)}function xc(a){return["ot","sf","st","e","sta"].includes(a)}function Ac(a){return typeof a=="number"?K(a):a!=null&&a!==""&&a!==!1}const La="event";function Lc(a,e){const t=new URL(a),s=new URL(e);if(t.origin!==s.origin)return a;const i=t.pathname.split("/").slice(1),r=s.pathname.split("/").slice(1,-1);for(;i[0]===r[0];)i.shift(),r.shift();for(;r.length;)r.shift(),i.unshift("..");return i.join("/")+t.search+t.hash}const cs=a=>Math.round(a),fi=(a,e)=>Array.isArray(a)?a.map(t=>fi(t,e)):a instanceof Ve&&typeof a.value=="string"?new Ve(fi(a.value,e),a.params):(e.baseUrl&&(a=Lc(a,e.baseUrl)),e.version===1?encodeURIComponent(a):a),Qt=a=>cs(a/100)*100,Ic=(a,e)=>{let t=a;return e.version>=2&&(a instanceof Ve&&typeof a.value=="string"?t=new Ve([a]):typeof a=="string"&&(t=[a])),fi(t,e)},bc={br:cs,d:cs,bl:Qt,dl:Qt,mtp:Qt,nor:Ic,rtp:Qt,tb:cs},Ia="request",ba="response",Ui=["ab","bg","bl","br","bs","bsd","cdn","cid","cs","df","ec","lab","lb","ltc","msd","mtp","pb","pr","pt","sf","sid","sn","st","sta","tab","tb","tbl","tpb","ts","v"],Rc=["e"],Dc=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function bs(a){return Dc.test(a)}function _c(a){return Ui.includes(a)||Rc.includes(a)||bs(a)}const Ra=["d","dl","nor","ot","rtp","su"];function kc(a){return Ui.includes(a)||Ra.includes(a)||bs(a)}const Cc=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"];function Pc(a){return Ui.includes(a)||Ra.includes(a)||Cc.includes(a)||bs(a)}const wc=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"];function Oc(a){return wc.includes(a)||bs(a)}const Mc={[ba]:Pc,[La]:_c,[Ia]:kc};function Da(a,e={}){const t={};if(a==null||typeof a!="object")return t;const s=e.version||a.v||1,i=e.reportingMode||Ia,r=s===1?Oc:Mc[i];let n=Object.keys(a).filter(r);const o=e.filter;typeof o=="function"&&(n=n.filter(o));const d=i===ba||i===La;d&&!n.includes("ts")&&n.push("ts"),s>1&&!n.includes("v")&&n.push("v");const l=ie({},bc,e.formatters),c={version:s,reportingMode:i,baseUrl:e.baseUrl};return n.sort().forEach(u=>{let h=a[u];const f=l[u];if(typeof f=="function"&&(h=f(h,c)),u==="v"){if(s===1)return;h=s}u=="pr"&&h===1||(d&&u==="ts"&&!K(h)&&(h=Date.now()),Ac(h)&&(xc(u)&&typeof h=="string"&&(h=new Ea(h)),t[u]=h))}),t}function Fc(a,e={}){const t={};if(!a)return t;const s=Da(a,e),i=Sc(s,e==null?void 0:e.customHeaderMap);return Object.entries(i).reduce((r,[n,o])=>{const d=Aa(o,{whitespace:!1});return d&&(r[n]=d),r},t)}function $c(a,e,t){return ie(a,Fc(e,t))}const Nc="CMCD";function Bc(a,e={}){return a?Aa(Da(a,e),{whitespace:!1}):""}function Uc(a,e={}){if(!a)return"";const t=Bc(a,e);return encodeURIComponent(t)}function Gc(a,e={}){if(!a)return"";const t=Uc(a,e);return"".concat(Nc,"=").concat(t)}const zr=/CMCD=[^&#]+/;function Kc(a,e,t){const s=Gc(e,t);if(!s)return a;if(zr.test(a))return a.replace(zr,s);const i=a.includes("?")?"&":"?";return"".concat(a).concat(i).concat(s)}class Vc{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=i=>{try{this.apply(i,{ot:xe.MANIFEST,su:!this.initialized})}catch(r){this.hls.logger.warn("Could not generate manifest CMCD data.",r)}},this.applyFragmentData=i=>{try{const{frag:r,part:n}=i,o=this.hls.levels[r.level],d=this.getObjectType(r),l={d:(n||r).duration*1e3,ot:d};(d===xe.VIDEO||d===xe.AUDIO||d==xe.MUXED)&&(l.br=o.bitrate/1e3,l.tb=this.getTopBandwidth(d)/1e3,l.bl=this.getBufferLength(d));const c=n?this.getNextPart(n):this.getNextFrag(r);c!=null&&c.url&&c.url!==r.url&&(l.nor=c.url),this.apply(i,l)}catch(r){this.hls.logger.warn("Could not generate segment CMCD data.",r)}},this.hls=e;const t=this.config=e.config,{cmcd:s}=t;s!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=s.sessionId||e.sessionId,this.cid=s.contentId,this.useHeaders=s.useHeaders===!0,this.includeKeys=s.includeKeys,this.registerListeners())}registerListeners(){const e=this.hls;e.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHED,this.onMediaDetached,this),e.on(y.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHED,this.onMediaDetached,this),e.off(y.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=this.media=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var s,i;this.audioBuffer=(s=t.tracks.audio)==null?void 0:s.buffer,this.videoBuffer=(i=t.tracks.video)==null?void 0:i.buffer}createData(){var e;return{v:1,sf:Xd.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){ie(t,this.createData());const s=t.ot===xe.INIT||t.ot===xe.VIDEO||t.ot===xe.MUXED;this.starved&&s&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering);const{includeKeys:i}=this;i&&(t=Object.keys(t).reduce((n,o)=>(i.includes(o)&&(n[o]=t[o]),n),{}));const r={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),$c(e.headers,t,r)):e.url=Kc(e.url,t,r)}getNextFrag(e){var t;const s=(t=this.hls.levels[e.level])==null?void 0:t.details;if(s){const i=e.sn-s.startSN;return s.fragments[i+1]}}getNextPart(e){var t;const{index:s,fragment:i}=e,r=(t=this.hls.levels[i.level])==null||(t=t.details)==null?void 0:t.partList;if(r){const{sn:n}=i;for(let o=r.length-1;o>=0;o--){const d=r[o];if(d.index===s&&d.fragment.sn===n)return r[o+1]}}}getObjectType(e){const{type:t}=e;if(t==="subtitle")return xe.TIMED_TEXT;if(e.sn==="initSegment")return xe.INIT;if(t==="audio")return xe.AUDIO;if(t==="main")return this.hls.audioTracks.length?xe.VIDEO:xe.MUXED}getTopBandwidth(e){let t=0,s;const i=this.hls;if(e===xe.AUDIO)s=i.audioTracks;else{const r=i.maxAutoLevel,n=r>-1?r+1:i.levels.length;s=i.levels.slice(0,n)}return s.forEach(r=>{r.bitrate>t&&(t=r.bitrate)}),t>0?t:NaN}getBufferLength(e){const t=this.media,s=e===xe.AUDIO?this.audioBuffer:this.videoBuffer;return!s||!t?NaN:X.bufferInfo(s,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){const{pLoader:e}=this.config,t=this.applyPlaylistData,s=e||this.config.loader;return class{constructor(r){this.loader=void 0,this.loader=new s(r)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(r,n,o){t(r),this.loader.load(r,n,o)}}}createFragmentLoader(){const{fLoader:e}=this.config,t=this.applyFragmentData,s=e||this.config.loader;return class{constructor(r){this.loader=void 0,this.loader=new s(r)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(r,n,o){t(r),this.loader.load(r,n,o)}}}}const Hc=3e5;class Wc extends Pe{constructor(e){super("content-steering",e.logger),this.hls=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this._pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.registerListeners()}registerListeners(){const e=this.hls;e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.ERROR,this.onError,this))}pathways(){return(this.levels||[]).reduce((e,t)=>(e.indexOf(t.pathwayId)===-1&&e.push(t.pathwayId),e),[])}get pathwayPriority(){return this._pathwayPriority}set pathwayPriority(e){this.updatePathwayPriority(e)}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){const e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){const t=this.levels;t&&(this.levels=t.filter(s=>s!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){const{contentSteering:s}=t;s!==null&&(this.pathwayId=s.pathwayId,this.uri=s.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){const{errorAction:s}=t;if((s==null?void 0:s.action)===pe.SendAlternateToPenaltyBox&&s.flags===be.MoveAllAlternatesMatchingHost){const i=this.levels;let r=this._pathwayPriority,n=this.pathwayId;if(t.context){const{groupId:o,pathwayId:d,type:l}=t.context;o&&i?n=this.getPathwayForGroupId(o,l,n):d&&(n=d)}n in this.penalizedPathways||(this.penalizedPathways[n]=performance.now()),!r&&i&&(r=this.pathways()),r&&r.length>1&&(this.updatePathwayPriority(r),s.resolved=this.pathwayId!==n),t.details===_.BUFFER_APPEND_ERROR&&!t.fatal?s.resolved=!0:s.resolved||this.warn("Could not resolve ".concat(t.details,' ("').concat(t.error.message,'") with content-steering for Pathway: ').concat(n," levels: ").concat(i&&i.length," priorities: ").concat(ne(r)," penalized: ").concat(ne(this.penalizedPathways)))}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){const s=e[0].pathwayId;this.log("No levels found in Pathway ".concat(this.pathwayId,'. Setting initial Pathway to "').concat(s,'"')),t=this.getLevelsForPathway(s),this.pathwayId=s}return t.length!==e.length&&this.log("Found ".concat(t.length,"/").concat(e.length,' levels in Pathway "').concat(this.pathwayId,'"')),t}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this._pathwayPriority=e;let t;const s=this.penalizedPathways,i=performance.now();Object.keys(s).forEach(r=>{i-s[r]>Hc&&delete s[r]});for(let r=0;r<e.length;r++){const n=e[r];if(n in s)continue;if(n===this.pathwayId)return;const o=this.hls.nextLoadLevel,d=this.hls.levels[o];if(t=this.getLevelsForPathway(n),t.length>0){this.log('Setting Pathway to "'.concat(n,'"')),this.pathwayId=n,jn(t),this.hls.trigger(y.LEVELS_UPDATED,{levels:t});const l=this.hls.levels[o];d&&l&&this.levels&&(l.attrs["STABLE-VARIANT-ID"]!==d.attrs["STABLE-VARIANT-ID"]&&l.bitrate!==d.bitrate&&this.log("Unstable Pathways change from bitrate ".concat(d.bitrate," to ").concat(l.bitrate)),this.hls.nextLoadLevel=o);break}}}getPathwayForGroupId(e,t,s){const i=this.getLevelsForPathway(s).concat(this.levels||[]);for(let r=0;r<i.length;r++)if(t===J.AUDIO_TRACK&&i[r].hasAudioGroup(e)||t===J.SUBTITLE_TRACK&&i[r].hasSubtitleGroup(e))return i[r].pathwayId;return s}clonePathways(e){const t=this.levels;if(!t)return;const s={},i={};e.forEach(r=>{const{ID:n,"BASE-ID":o,"URI-REPLACEMENT":d}=r;if(t.some(c=>c.pathwayId===n))return;const l=this.getLevelsForPathway(o).map(c=>{const u=new de(c.attrs);u["PATHWAY-ID"]=n;const h=u.AUDIO&&"".concat(u.AUDIO,"_clone_").concat(n),f=u.SUBTITLES&&"".concat(u.SUBTITLES,"_clone_").concat(n);h&&(s[u.AUDIO]=h,u.AUDIO=h),f&&(i[u.SUBTITLES]=f,u.SUBTITLES=f);const g=_a(c.uri,u["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",d),m=new Mt({attrs:u,audioCodec:c.audioCodec,bitrate:c.bitrate,height:c.height,name:c.name,url:g,videoCodec:c.videoCodec,width:c.width});if(c.audioGroups)for(let p=1;p<c.audioGroups.length;p++)m.addGroupId("audio","".concat(c.audioGroups[p],"_clone_").concat(n));if(c.subtitleGroups)for(let p=1;p<c.subtitleGroups.length;p++)m.addGroupId("text","".concat(c.subtitleGroups[p],"_clone_").concat(n));return m});t.push(...l),Xr(this.audioTracks,s,d,n),Xr(this.subtitleTracks,i,d,n)})}loadSteeringManifest(e){const t=this.hls.config,s=t.loader;this.loader&&this.loader.destroy(),this.loader=new s(t);let i;try{i=new self.URL(e)}catch(c){this.enabled=!1,this.log("Failed to parse Steering Manifest URI: ".concat(e));return}if(i.protocol!=="data:"){const c=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;i.searchParams.set("_HLS_pathway",this.pathwayId),i.searchParams.set("_HLS_throughput",""+c)}const r={responseType:"json",url:i.href},n=t.steeringManifestLoadPolicy.default,o=n.errorRetry||n.timeoutRetry||{},d={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},l={onSuccess:(c,u,h,f)=>{this.log('Loaded steering manifest: "'.concat(i,'"'));const g=c.data;if((g==null?void 0:g.VERSION)!==1){this.log("Steering VERSION ".concat(g.VERSION," not supported!"));return}this.updated=performance.now(),this.timeToLoad=g.TTL;const{"RELOAD-URI":m,"PATHWAY-CLONES":p,"PATHWAY-PRIORITY":v}=g;if(m)try{this.uri=new self.URL(m,i).href}catch(T){this.enabled=!1,this.log("Failed to parse Steering Manifest RELOAD-URI: ".concat(m));return}this.scheduleRefresh(this.uri||h.url),p&&this.clonePathways(p);const E={steeringManifest:g,url:i.toString()};this.hls.trigger(y.STEERING_MANIFEST_LOADED,E),v&&this.updatePathwayPriority(v)},onError:(c,u,h,f)=>{if(this.log("Error loading steering manifest: ".concat(c.code," ").concat(c.text," (").concat(u.url,")")),this.stopLoad(),c.code===410){this.enabled=!1,this.log("Steering manifest ".concat(u.url," no longer available"));return}let g=this.timeToLoad*1e3;if(c.code===429){const m=this.loader;if(typeof(m==null?void 0:m.getResponseHeader)=="function"){const p=m.getResponseHeader("Retry-After");p&&(g=parseFloat(p)*1e3)}this.log("Steering manifest ".concat(u.url," rate limited"));return}this.scheduleRefresh(this.uri||u.url,g)},onTimeout:(c,u,h)=>{this.log("Timeout loading steering manifest (".concat(u.url,")")),this.scheduleRefresh(this.uri||u.url)}};this.log("Requesting steering manifest: ".concat(i)),this.loader.load(r,d,l)}scheduleRefresh(e,t=this.timeToLoad*1e3){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var s;const i=(s=this.hls)==null?void 0:s.media;if(i&&!i.ended){this.loadSteeringManifest(e);return}this.scheduleRefresh(e,this.timeToLoad*1e3)},t)}}function Xr(a,e,t,s){a&&Object.keys(e).forEach(i=>{const r=a.filter(n=>n.groupId===i).map(n=>{const o=ie({},n);return o.details=void 0,o.attrs=new de(o.attrs),o.url=o.attrs.URI=_a(n.url,n.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[i],o.attrs["PATHWAY-ID"]=s,o});a.push(...r)})}function _a(a,e,t,s){const{HOST:i,PARAMS:r,[t]:n}=s;let o;e&&(o=n==null?void 0:n[e],o&&(a=o));const d=new self.URL(a);return i&&!o&&(d.host=i),r&&Object.keys(r).sort().forEach(l=>{l&&d.searchParams.set(l,r[l])}),d.href}class Et extends Pe{constructor(e){super("eme",e.logger),this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.mediaKeys=null,this.setMediaKeysQueue=Et.CDMCleanupPromise?[Et.CDMCleanupPromise]:[],this.bannedKeyIds={},this.onMediaEncrypted=t=>{const{initDataType:s,initData:i}=t,r='"'.concat(t.type,'" event: init data type: "').concat(s,'"');if(this.debug(r),i!==null){if(!this.keyFormatPromise){let n=Object.keys(this.keySystemAccessPromises);n.length||(n=_t(this.config));const o=n.map(ws).filter(d=>!!d);this.keyFormatPromise=this.getKeyFormatPromise(o)}this.keyFormatPromise.then(n=>{const o=os(n);if(s!=="sinf"||o!==ce.FAIRPLAY){this.log('Ignoring "'.concat(t.type,'" event with init data type: "').concat(s,'" for selected key-system ').concat(o));return}let d;try{const f=fe(new Uint8Array(i)),g=Di(JSON.parse(f).sinf),m=In(g);if(!m)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");d=new Uint8Array(m.subarray(8,24))}catch(f){this.warn("".concat(r," Failed to parse sinf: ").concat(f));return}const l=Ae(d),{keyIdToKeySessionPromise:c,mediaKeySessions:u}=this;let h=c[l];for(let f=0;f<u.length;f++){const g=u[f],m=g.decryptdata;if(!m.keyId)continue;const p=Ae(m.keyId);if(bi(d,m.keyId)||m.uri.replace(/-/g,"").indexOf(l)!==-1){if(h=c[p],!h)continue;if(m.pssh)break;delete c[p],m.pssh=new Uint8Array(i),m.keyId=d,h=c[l]=h.then(()=>this.generateRequestWithPreferredKeySession(g,s,i,"encrypted-event-key-match")),h.catch(v=>this.handleError(v));break}}h||this.handleError(new Error("Key ID ".concat(l," not encountered in playlist. Key-system sessions ").concat(u.length,".")))}).catch(n=>this.handleError(n))}},this.onWaitingForKey=t=>{this.log('"'.concat(t.type,'" event'))},this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.onDestroying(),this.onMediaDetached();const e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.config=this.keyIdToKeySessionPromise=null,this.onMediaEncrypted=this.onWaitingForKey=null}registerListeners(){this.hls.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(y.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(y.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(y.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.on(y.DESTROYING,this.onDestroying,this)}unregisterListeners(){this.hls.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(y.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(y.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(y.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.off(y.DESTROYING,this.onDestroying,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:s}=this.config,i=t==null?void 0:t[e];if(i)return i.licenseUrl;if(e===ce.WIDEVINE&&s)return s}getLicenseServerUrlOrThrow(e){const t=this.getLicenseServerUrl(e);if(t===void 0)throw new Error('no license server URL configured for key-system "'.concat(e,'"'));return t}getServerCertificateUrl(e){const{drmSystems:t}=this.config,s=t==null?void 0:t[e];if(s)return s.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'.concat(e,'"]'))}attemptKeySystemAccess(e){const t=this.hls.levels,s=(n,o,d)=>!!n&&d.indexOf(n)===o,i=t.map(n=>n.audioCodec).filter(s),r=t.map(n=>n.videoCodec).filter(s);return i.length+r.length===0&&r.push("avc1.42e01e"),new Promise((n,o)=>{const d=l=>{const c=l.shift();this.getMediaKeysPromise(c,i,r).then(u=>n({keySystem:c,mediaKeys:u})).catch(u=>{l.length?d(l):u instanceof Ie?o(u):o(new Ie({type:W.KEY_SYSTEM_ERROR,details:_.KEY_SYSTEM_NO_ACCESS,error:u,fatal:!0},u.message))})};d(e)})}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:s}=this.config;if(typeof s!="function"){let i="Configured requestMediaKeySystemAccess is not a function ".concat(s);return Gn===null&&self.location.protocol==="http:"&&(i="navigator.requestMediaKeySystemAccess is not available over insecure protocol ".concat(location.protocol)),Promise.reject(new Error(i))}return s(e,t)}getMediaKeysPromise(e,t,s){var i;const r=Il(e,t,s,this.config.drmSystemOptions||{});let n=this.keySystemAccessPromises[e],o=(i=n)==null?void 0:i.keySystemAccess;if(!o){this.log('Requesting encrypted media "'.concat(e,'" key-system access with config: ').concat(ne(r))),o=this.requestMediaKeySystemAccess(e,r);const d=n=this.keySystemAccessPromises[e]={keySystemAccess:o};return o.catch(l=>{this.log('Failed to obtain access to key-system "'.concat(e,'": ').concat(l))}),o.then(l=>{this.log('Access for key-system "'.concat(l.keySystem,'" obtained'));const c=this.fetchServerCertificate(e);this.log('Create media-keys for "'.concat(e,'"'));const u=d.mediaKeys=l.createMediaKeys().then(h=>(this.log('Media-keys created for "'.concat(e,'"')),d.hasMediaKeys=!0,c.then(f=>f?this.setMediaKeysServerCertificate(h,e,f):h)));return u.catch(h=>{this.error('Failed to create media-keys for "'.concat(e,'"}: ').concat(h))}),u})}return o.then(()=>n.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:s}){this.log('Creating key-system session "'.concat(t,'" keyId: ').concat(Ae(e.keyId||[])," keyUri: ").concat(e.uri));const i=s.createSession(),r={decryptdata:e,keySystem:t,mediaKeys:s,mediaKeysSession:i,keyStatus:"status-pending"};return this.mediaKeySessions.push(r),r}renewKeySession(e){const t=e.decryptdata;if(t.pssh){const s=this.createMediaKeySessionContext(e),i=Zt(t),r="cenc";this.keyIdToKeySessionPromise[i]=this.generateRequestWithPreferredKeySession(s,r,t.pssh.buffer,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}updateKeySession(e,t){const s=e.mediaKeysSession;return this.log('Updating key-session "'.concat(s.sessionId,'" for keyId ').concat(Ae(e.decryptdata.keyId||[]),"\n } (data length: ").concat(t.byteLength,")")),s.update(t)}getSelectedKeySystemFormats(){return Object.keys(this.keySystemAccessPromises).map(e=>({keySystem:e,hasMediaKeys:this.keySystemAccessPromises[e].hasMediaKeys})).filter(({hasMediaKeys:e})=>!!e).map(({keySystem:e})=>ws(e)).filter(e=>!!e)}getKeySystemAccess(e){return this.getKeySystemSelectionPromise(e).then(({keySystem:t,mediaKeys:s})=>this.attemptSetMediaKeys(t,s))}selectKeySystem(e){return new Promise((t,s)=>{this.getKeySystemSelectionPromise(e).then(({keySystem:i})=>{const r=ws(i);r?t(r):s(new Error('Unable to find format for key-system "'.concat(i,'"')))}).catch(s)})}selectKeySystemFormat(e){const t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log("Selecting key-system from fragment (sn: ".concat(e.sn," ").concat(e.type,": ").concat(e.level,") key formats ").concat(t.join(", "))),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){const t=_t(this.config),s=e.map(os).filter(i=>!!i&&t.indexOf(i)!==-1);return this.selectKeySystem(s)}getKeyStatus(e){const{mediaKeySessions:t}=this;for(let s=0;s<t.length;s++){const i=Yc(e,t[s]);if(i)return i}}loadKey(e){const t=e.keyInfo.decryptdata,s=Zt(t),i=this.bannedKeyIds[s];if(i||this.getKeyStatus(t)==="internal-error"){const o=Qr(i||"internal-error",t);return this.handleError(o,e.frag),Promise.reject(o)}const r="(keyId: ".concat(s,' format: "').concat(t.keyFormat,'" method: ').concat(t.method," uri: ").concat(t.uri,")");this.log("Starting session for key ".concat(r));const n=this.keyIdToKeySessionPromise[s];if(!n){const o=this.getKeySystemForKeyPromise(t).then(({keySystem:d,mediaKeys:l})=>(this.throwIfDestroyed(),this.log("Handle encrypted media sn: ".concat(e.frag.sn," ").concat(e.frag.type,": ").concat(e.frag.level," using key ").concat(r)),this.attemptSetMediaKeys(d,l).then(()=>(this.throwIfDestroyed(),this.createMediaKeySessionContext({keySystem:d,mediaKeys:l,decryptdata:t}))))).then(d=>{const l="cenc",c=t.pssh?t.pssh.buffer:null;return this.generateRequestWithPreferredKeySession(d,l,c,"playlist-key")});return o.catch(d=>this.handleError(d,e.frag)),this.keyIdToKeySessionPromise[s]=o,o}return n.catch(o=>{if(o instanceof Ie){const d=te({},o.data);this.getKeyStatus(t)==="internal-error"&&(d.decryptdata=t);const l=new Ie(d,o.message);this.handleError(l,e.frag)}}),n}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e,t){if(this.hls)if(e instanceof Ie){t&&(e.data.frag=t);const s=e.data.decryptdata;this.error("".concat(e.message).concat(s?" (".concat(Ae(s.keyId||[]),")"):"")),this.hls.trigger(y.ERROR,e.data)}else this.error(e.message),this.hls.trigger(y.ERROR,{type:W.KEY_SYSTEM_ERROR,details:_.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0})}getKeySystemForKeyPromise(e){const t=Zt(e),s=this.keyIdToKeySessionPromise[t];if(!s){const i=os(e.keyFormat),r=i?[i]:_t(this.config);return this.attemptKeySystemAccess(r)}return s}getKeySystemSelectionPromise(e){if(e.length||(e=_t(this.config)),e.length===0)throw new Ie({type:W.KEY_SYSTEM_ERROR,details:_.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options ".concat(ne({drmSystems:this.config.drmSystems})));return this.attemptKeySystemAccess(e)}attemptSetMediaKeys(e,t){if(this.mediaKeys===t)return Promise.resolve();const s=this.setMediaKeysQueue.slice();this.log('Setting media-keys for "'.concat(e,'"'));const i=Promise.all(s).then(()=>{if(!this.media)throw this.mediaKeys=null,new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return this.mediaKeys=t,this.setMediaKeysQueue.push(i),i.then(()=>{this.log('Media-keys set for "'.concat(e,'"')),s.push(i),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(r=>s.indexOf(r)===-1)})}generateRequestWithPreferredKeySession(e,t,s,i){var r;const n=(r=this.config.drmSystems)==null||(r=r[e.keySystem])==null?void 0:r.generateRequest;if(n)try{const g=n.call(this.hls,t,s,e);if(!g)throw new Error("Invalid response from configured generateRequest filter");t=g.initDataType,s=g.initData?g.initData:null,e.decryptdata.pssh=s?new Uint8Array(s):null}catch(g){if(this.warn(g.message),this.hls&&this.hls.config.debug)throw g}if(s===null)return this.log('Skipping key-session request for "'.concat(i,'" (no initData)')),Promise.resolve(e);const o=Zt(e.decryptdata),d=e.decryptdata.uri;this.log('Generating key-session request for "'.concat(i,'" keyId: ').concat(o," URI: ").concat(d," (init data type: ").concat(t," length: ").concat(s.byteLength,")"));const l=new ki,c=e._onmessage=g=>{const m=e.mediaKeysSession;if(!m){l.emit("error",new Error("invalid state"));return}const{messageType:p,message:v}=g;this.log('"'.concat(p,'" message event for session "').concat(m.sessionId,'" message size: ').concat(v.byteLength)),p==="license-request"||p==="license-renewal"?this.renewLicense(e,v).catch(E=>{l.eventNames().length?l.emit("error",E):this.handleError(E)}):p==="license-release"?e.keySystem===ce.FAIRPLAY&&this.updateKeySession(e,ni("acknowledged")).then(()=>this.removeSession(e)).catch(E=>this.handleError(E)):this.warn('unhandled media key message type "'.concat(p,'"'))},u=(g,m)=>{m.keyStatus=g;let p;g.startsWith("usable")?l.emit("resolved"):g==="internal-error"||g==="output-restricted"||g==="output-downscaled"?p=Qr(g,m.decryptdata):g==="expired"?p=new Error("key expired (keyId: ".concat(o,")")):g==="released"?p=new Error("key released"):g==="status-pending"||this.warn('unhandled key status change "'.concat(g,'" (keyId: ').concat(o,")")),p&&(l.eventNames().length?l.emit("error",p):this.handleError(p))},h=e._onkeystatuseschange=g=>{if(!e.mediaKeysSession){l.emit("error",new Error("invalid state"));return}const p=this.getKeyStatuses(e);if(!Object.keys(p).some(S=>p[S]!=="status-pending"))return;if(p[o]==="expired"){this.log("Expired key ".concat(ne(p),' in key-session "').concat(e.mediaKeysSession.sessionId,'"')),this.renewKeySession(e);return}let E=p[o];if(E)u(E,e);else{var T;e.keyStatusTimeouts||(e.keyStatusTimeouts={}),(T=e.keyStatusTimeouts)[o]||(T[o]=self.setTimeout(()=>{if(!e.mediaKeysSession||!this.mediaKeys)return;const x=this.getKeyStatus(e.decryptdata);if(x&&x!=="status-pending")return this.log("No status for keyId ".concat(o,' in key-session "').concat(e.mediaKeysSession.sessionId,'". Using session key-status ').concat(x," from other session.")),u(x,e);this.log("key status for ".concat(o,' in key-session "').concat(e.mediaKeysSession.sessionId,'" timed out after 0ms')),E="internal-error",u(E,e)},0)),this.log("No status for keyId ".concat(o," (").concat(ne(p),")."))}};Te(e.mediaKeysSession,"message",c),Te(e.mediaKeysSession,"keystatuseschange",h);const f=new Promise((g,m)=>{l.on("error",m),l.on("resolved",g)});return e.mediaKeysSession.generateRequest(t,s).then(()=>{this.log('Request generated for key-session "'.concat(e.mediaKeysSession.sessionId,'" keyId: ').concat(o," URI: ").concat(d))}).catch(g=>{throw new Ie({type:W.KEY_SYSTEM_ERROR,details:_.KEY_SYSTEM_NO_SESSION,error:g,decryptdata:e.decryptdata,fatal:!1},"Error generating key-session request: ".concat(g))}).then(()=>f).catch(g=>(l.removeAllListeners(),this.removeSession(e).then(()=>{throw g}))).then(()=>(l.removeAllListeners(),e))}getKeyStatuses(e){const t={};return e.mediaKeysSession.keyStatuses.forEach((s,i)=>{if(typeof i=="string"&&typeof s=="object"){const o=i;i=s,s=o}const r="buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i);e.keySystem===ce.PLAYREADY&&r.length===16&&Un(r);const n=Ae(r);s==="internal-error"&&(this.bannedKeyIds[n]=s),this.log('key status change "'.concat(s,'" for keyStatuses keyId: ').concat(n,' key-session "').concat(e.mediaKeysSession.sessionId,'"')),t[n]=s}),t}fetchServerCertificate(e){const t=this.config,s=t.loader,i=new s(t),r=this.getServerCertificateUrl(e);return r?(this.log('Fetching server certificate for "'.concat(e,'"')),new Promise((n,o)=>{const d={responseType:"arraybuffer",url:r},l=t.certLoadPolicy.default,c={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(h,f,g,m)=>{n(h.data)},onError:(h,f,g,m)=>{o(new Ie({type:W.KEY_SYSTEM_ERROR,details:_.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:g,response:te({url:d.url,data:void 0},h)},'"'.concat(e,'" certificate request failed (').concat(r,"). Status: ").concat(h.code," (").concat(h.text,")")))},onTimeout:(h,f,g)=>{o(new Ie({type:W.KEY_SYSTEM_ERROR,details:_.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:g,response:{url:d.url,data:void 0}},'"'.concat(e,'" certificate request timed out (').concat(r,")")))},onAbort:(h,f,g)=>{o(new Error("aborted"))}};i.load(d,c,u)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,s){return new Promise((i,r)=>{e.setServerCertificate(s).then(n=>{this.log("setServerCertificate ".concat(n?"success":"not supported by CDM"," (").concat(s.byteLength,') on "').concat(t,'"')),i(e)}).catch(n=>{r(new Ie({type:W.KEY_SYSTEM_ERROR,details:_.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:n,fatal:!0},n.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(s=>this.updateKeySession(e,new Uint8Array(s)).catch(i=>{throw new Ie({type:W.KEY_SYSTEM_ERROR,details:_.KEY_SYSTEM_SESSION_UPDATE_FAILED,decryptdata:e.decryptdata,error:i,fatal:!1},i.message)}))}unpackPlayReadyKeyMessage(e,t){const s=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!s.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;const i=new DOMParser().parseFromString(s,"application/xml"),r=i.querySelectorAll("HttpHeader");if(r.length>0){let c;for(let u=0,h=r.length;u<h;u++){var n,o;c=r[u];const f=(n=c.querySelector("name"))==null?void 0:n.textContent,g=(o=c.querySelector("value"))==null?void 0:o.textContent;f&&g&&e.setRequestHeader(f,g)}}const d=i.querySelector("Challenge"),l=d==null?void 0:d.textContent;if(!l)throw new Error("Cannot find <Challenge> in key message");return ni(atob(l))}setupLicenseXHR(e,t,s,i){const r=this.config.licenseXhrSetup;return r?Promise.resolve().then(()=>{if(!s.decryptdata)throw new Error("Key removed");return r.call(this.hls,e,t,s,i)}).catch(n=>{if(!s.decryptdata)throw n;return e.open("POST",t,!0),r.call(this.hls,e,t,s,i)}).then(n=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:n||i})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:i}))}requestLicense(e,t){const s=this.config.keyLoadPolicy.default;return new Promise((i,r)=>{const n=this.getLicenseServerUrlOrThrow(e.keySystem);this.log("Sending license request to URL: ".concat(n));const o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return r(new Error("invalid state"));if(o.readyState===4)if(o.status===200){this._requestLicenseFailureCount=0;let d=o.response;this.log("License received ".concat(d instanceof ArrayBuffer?d.byteLength:d));const l=this.config.licenseResponseCallback;if(l)try{d=l.call(this.hls,o,n,e)}catch(c){this.error(c)}i(d)}else{const d=s.errorRetry,l=d?d.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>l||o.status>=400&&o.status<500)r(new Ie({type:W.KEY_SYSTEM_ERROR,details:_.KEY_SYSTEM_LICENSE_REQUEST_FAILED,decryptdata:e.decryptdata,fatal:!0,networkDetails:o,response:{url:n,data:void 0,code:o.status,text:o.statusText}},"License Request XHR failed (".concat(n,"). Status: ").concat(o.status," (").concat(o.statusText,")")));else{const c=l-this._requestLicenseFailureCount+1;this.warn("Retrying license request, ".concat(c," attempts left")),this.requestLicense(e,t).then(i,r)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,n,e,t).then(({xhr:d,licenseChallenge:l})=>{e.keySystem==ce.PLAYREADY&&(l=this.unpackPlayReadyKeyMessage(d,l)),d.send(l)}).catch(r)})}onDestroying(){this.unregisterListeners(),this._clear()}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const s=t.media;this.media=s,Te(s,"encrypted",this.onMediaEncrypted),Te(s,"waitingforkey",this.onWaitingForKey)}onMediaDetached(){const e=this.media;e&&(Le(e,"encrypted",this.onMediaEncrypted),Le(e,"waitingforkey",this.onWaitingForKey),this.media=null,this.mediaKeys=null)}_clear(){var e;if(this._requestLicenseFailureCount=0,this.keyIdToKeySessionPromise={},this.bannedKeyIds={},!this.mediaKeys&&!this.mediaKeySessions.length)return;const t=this.media,s=this.mediaKeySessions.slice();this.mediaKeySessions=[],this.mediaKeys=null,Ft.clearKeyUriToKeyIdMap();const i=s.length;Et.CDMCleanupPromise=Promise.all(s.map(r=>this.removeSession(r)).concat((t==null||(e=t.setMediaKeys(null))==null?void 0:e.catch(r=>{this.log("Could not clear media keys: ".concat(r)),this.hls&&this.hls.trigger(y.ERROR,{type:W.OTHER_ERROR,details:_.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error("Could not clear media keys: ".concat(r))})}))||Promise.resolve())).catch(r=>{this.log("Could not close sessions and clear media keys: ".concat(r)),this.hls&&this.hls.trigger(y.ERROR,{type:W.OTHER_ERROR,details:_.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error("Could not close sessions and clear media keys: ".concat(r))})}).then(()=>{i&&this.log("finished closing key sessions and clearing media keys")})}onManifestLoading(){this.keyFormatPromise=null,this.bannedKeyIds={}}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){const s=t.reduce((i,r)=>(i.indexOf(r.keyFormat)===-1&&i.push(r.keyFormat),i),[]);this.log("Selecting key-system from session-keys ".concat(s.join(", "))),this.keyFormatPromise=this.getKeyFormatPromise(s)}}removeSession(e){const{mediaKeysSession:t,licenseXhr:s,decryptdata:i}=e;if(t){this.log('Remove licenses and keys and close session "'.concat(t.sessionId,'" keyId: ').concat(Ae((i==null?void 0:i.keyId)||[]))),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),s&&s.readyState!==XMLHttpRequest.DONE&&s.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;const r=this.mediaKeySessions.indexOf(e);r>-1&&this.mediaKeySessions.splice(r,1);const{keyStatusTimeouts:n}=e;n&&Object.keys(n).forEach(l=>self.clearTimeout(n[l]));const{drmSystemOptions:o}=this.config;return(Rl(o)?new Promise((l,c)=>{self.setTimeout(()=>c(new Error("MediaKeySession.remove() timeout")),8e3),t.remove().then(l).catch(c)}):Promise.resolve()).catch(l=>{this.log("Could not remove session: ".concat(l)),this.hls&&this.hls.trigger(y.ERROR,{type:W.OTHER_ERROR,details:_.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error:new Error("Could not remove session: ".concat(l))})}).then(()=>t.close()).catch(l=>{this.log("Could not close session: ".concat(l)),this.hls&&this.hls.trigger(y.ERROR,{type:W.OTHER_ERROR,details:_.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error("Could not close session: ".concat(l))})})}return Promise.resolve()}}Et.CDMCleanupPromise=void 0;function Zt(a){if(!a)throw new Error("Could not read keyId of undefined decryptdata");if(a.keyId===null)throw new Error("keyId is null");return Ae(a.keyId)}function Yc(a,e){if(a.keyId&&e.mediaKeysSession.keyStatuses.has(a.keyId))return e.mediaKeysSession.keyStatuses.get(a.keyId);if(a.matches(e.decryptdata))return e.keyStatus}class Ie extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}}function Qr(a,e){const t=a==="output-restricted",s=t?_.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:_.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new Ie({type:W.KEY_SYSTEM_ERROR,details:s,fatal:!1,decryptdata:e},t?"HDCP level output restricted":'key status changed to "'.concat(a,'"'))}class qc{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(y.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(y.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListeners(){this.hls.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(y.MEDIA_DETACHING,this.onMediaDetaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){const s=this.hls.config;if(s.capLevelOnFPSDrop){const i=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=i,i&&typeof i.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),s.fpsDroppedMonitoringPeriod)}}onMediaDetaching(){this.media=null}checkFPS(e,t,s){const i=performance.now();if(t){if(this.lastTime){const r=i-this.lastTime,n=s-this.lastDroppedFrames,o=t-this.lastDecodedFrames,d=1e3*n/r,l=this.hls;if(l.trigger(y.FPS_DROP,{currentDropped:n,currentDecoded:o,totalDroppedFrames:s}),d>0&&n>l.config.fpsDroppedMonitoringThreshold*o){let c=l.currentLevel;l.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(l.autoLevelCapping===-1||l.autoLevelCapping>=c)&&(c=c-1,l.trigger(y.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:l.currentLevel}),l.autoLevelCapping=c,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=s,this.lastDecodedFrames=t}}checkFPSInterval(){const e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){const t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}function ka(a,e){let t;try{t=new Event("addtrack")}catch(s){t=document.createEvent("Event"),t.initEvent("addtrack",!1,!1)}t.track=a,e.dispatchEvent(t)}function Ca(a,e){const t=a.mode;if(t==="disabled"&&(a.mode="hidden"),a.cues&&!a.cues.getCueById(e.id))try{if(a.addCue(e),!a.cues.getCueById(e.id))throw new Error("addCue is failed for: ".concat(e))}catch(s){se.debug("[texttrack-utils]: ".concat(s));try{const i=new self.TextTrackCue(e.startTime,e.endTime,e.text);i.id=e.id,a.addCue(i)}catch(i){se.debug("[texttrack-utils]: Legacy TextTrackCue fallback failed: ".concat(i))}}t==="disabled"&&(a.mode=t)}function pt(a,e){const t=a.mode;if(t==="disabled"&&(a.mode="hidden"),a.cues)for(let s=a.cues.length;s--;)e&&a.cues[s].removeEventListener("enter",e),a.removeCue(a.cues[s]);t==="disabled"&&(a.mode=t)}function gi(a,e,t,s){const i=a.mode;if(i==="disabled"&&(a.mode="hidden"),a.cues&&a.cues.length>0){const r=zc(a.cues,e,t);for(let n=0;n<r.length;n++)(!s||s(r[n]))&&a.removeCue(r[n])}i==="disabled"&&(a.mode=i)}function jc(a,e){if(e<=a[0].startTime)return 0;const t=a.length-1;if(e>a[t].endTime)return-1;let s=0,i=t,r;for(;s<=i;)if(r=Math.floor((i+s)/2),e<a[r].startTime)i=r-1;else if(e>a[r].startTime&&s<t)s=r+1;else return r;return a[s].startTime-e<e-a[i].startTime?s:i}function zc(a,e,t){const s=[],i=jc(a,e);if(i>-1)for(let r=i,n=a.length;r<n;r++){const o=a[r];if(o.startTime>=e&&o.endTime<=t)s.push(o);else if(o.startTime>t)return s}return s}function us(a){const e=[];for(let t=0;t<a.length;t++){const s=a[t];(s.kind==="subtitles"||s.kind==="captions")&&s.label&&e.push(a[t])}return e}class Xc extends $i{constructor(e){super(e,"subtitle-track-controller"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=null;const s=us(this.media.textTracks);for(let r=0;r<s.length;r++)if(s[r].mode==="hidden")t=s[r];else if(s[r].mode==="showing"){t=s[r];break}const i=this.findTrackForTextTrack(t);this.subtitleTrack!==i&&this.setSubtitleTrack(i)},this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}registerListeners(){const{hls:e}=this;e.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.LEVEL_LOADING,this.onLevelLoading,this),e.on(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(y.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(y.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.LEVEL_LOADING,this.onLevelLoading,this),e.off(y.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(y.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(y.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)}onMediaDetaching(e,t){const s=this.media;if(!s)return;const i=!!t.transferMedia;if(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||s.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),this.subtitleTrack=-1,this.media=null,i)return;us(s.textTracks).forEach(n=>{pt(n)})}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){const{id:s,groupId:i,details:r}=t,n=this.tracksInGroup[s];if(!n||n.groupId!==i){this.warn("Subtitle track with id:".concat(s," and group:").concat(i," not found in active group ").concat(n==null?void 0:n.groupId));return}const o=n.details;n.details=t.details,this.log("Subtitle track ".concat(s,' "').concat(n.name,'" lang:').concat(n.lang," group:").concat(i," loaded [").concat(r.startSN,"-").concat(r.endSN,"]")),s===this.trackId&&this.playlistLoaded(s,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const s=t.subtitleGroups||null,i=this.groupIds;let r=this.currentTrack;if(!s||(i==null?void 0:i.length)!==(s==null?void 0:s.length)||s!=null&&s.some(n=>(i==null?void 0:i.indexOf(n))===-1)){this.groupIds=s,this.trackId=-1,this.currentTrack=null;const n=this.tracks.filter(c=>!s||s.indexOf(c.groupId)!==-1);if(n.length)this.selectDefaultTrack&&!n.some(c=>c.default)&&(this.selectDefaultTrack=!1),n.forEach((c,u)=>{c.id=u});else if(!r&&!this.tracksInGroup.length)return;this.tracksInGroup=n;const o=this.hls.config.subtitlePreference;if(!r&&o){this.selectDefaultTrack=!1;const c=Ge(o,n);if(c>-1)r=n[c];else{const u=Ge(o,this.tracks);r=this.tracks[u]}}let d=this.findTrackId(r);d===-1&&r&&(d=this.findTrackId(null));const l={subtitleTracks:n};this.log("Updating subtitle tracks, ".concat(n.length,' track(s) found in "').concat(s==null?void 0:s.join(","),'" group-id')),this.hls.trigger(y.SUBTITLE_TRACKS_UPDATED,l),d!==-1&&this.trackId===-1&&this.setSubtitleTrack(d)}}findTrackId(e){const t=this.tracksInGroup,s=this.selectDefaultTrack;for(let i=0;i<t.length;i++){const r=t[i];if(!(s&&!r.default||!s&&!e)&&(!e||ot(r,e)))return i}if(e){for(let i=0;i<t.length;i++){const r=t[i];if(Ut(e.attrs,r.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return i}for(let i=0;i<t.length;i++){const r=t[i];if(Ut(e.attrs,r.attrs,["LANGUAGE"]))return i}}return-1}findTrackForTextTrack(e){if(e){const t=this.tracksInGroup;for(let s=0;s<t.length;s++){const i=t[s];if(ci(i,e))return s}}return-1}onError(e,t){t.fatal||!t.context||t.context.type===J.SUBTITLE_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&this.checkRetry(t)}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){if(e.id===-1)return this.setSubtitleTrack(-1),null;const t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){const s=this.currentTrack;if(s&&ot(e,s))return s;const i=Ge(e,this.tracksInGroup);if(i>-1){const r=this.tracksInGroup[i];return this.setSubtitleTrack(i),r}else{if(s)return null;{const r=Ge(e,t);if(r>-1)return t[r]}}}}return null}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const s=e.id,i=e.groupId,r=this.getUrlWithDirectives(e.url,t),n=e.details,o=n==null?void 0:n.age;this.log("Loading subtitle ".concat(s,' "').concat(e.name,'" lang:').concat(e.lang," group:").concat(i).concat((t==null?void 0:t.msn)!==void 0?" at sn "+t.msn+" part "+t.part:"").concat(o&&n.live?" age "+o.toFixed(1)+(n.type&&" "+n.type||""):""," ").concat(r)),this.hls.trigger(y.SUBTITLE_TRACK_LOADING,{url:r,id:s,groupId:i,deliveryDirectives:t||null,track:e})}toggleTrackModes(){const{media:e}=this;if(!e)return;const t=us(e.textTracks),s=this.currentTrack;let i;if(s&&(i=t.filter(r=>ci(s,r))[0],i||this.warn('Unable to find subtitle TextTrack with name "'.concat(s.name,'" and language "').concat(s.lang,'"'))),[].slice.call(t).forEach(r=>{r.mode!=="disabled"&&r!==i&&(r.mode="disabled")}),i){const r=this.subtitleDisplay?"showing":"hidden";i.mode!==r&&(i.mode=r)}}setSubtitleTrack(e){const t=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(e<-1||e>=t.length||!K(e)){this.warn("Invalid subtitle track id: ".concat(e));return}this.selectDefaultTrack=!1;const s=this.currentTrack,i=t[e]||null;if(this.trackId=e,this.currentTrack=i,this.toggleTrackModes(),!i){this.hls.trigger(y.SUBTITLE_TRACK_SWITCH,{id:e});return}const r=!!i.details&&!i.details.live;if(e===this.trackId&&i===s&&r)return;this.log("Switching to subtitle-track ".concat(e)+(i?' "'.concat(i.name,'" lang:').concat(i.lang," group:").concat(i.groupId):""));const{id:n,groupId:o="",name:d,type:l,url:c}=i;this.hls.trigger(y.SUBTITLE_TRACK_SWITCH,{id:n,groupId:o,name:d,type:l,url:c});const u=this.switchParams(i.url,s==null?void 0:s.details,i.details);this.loadPlaylist(u)}}function Qc(){try{return crypto.randomUUID()}catch(a){try{const e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch(e){let t=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{const r=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(i=="x"?r:r&3|8).toString(16)})}}}function Pt(a){let e=5381,t=a.length;for(;t;)e=e*33^a.charCodeAt(--t);return(e>>>0).toString()}const Tt=.025;let As=(function(a){return a[a.Point=0]="Point",a[a.Range=1]="Range",a})({});function Zc(a,e,t){return"".concat(a.identifier,"-").concat(t+1,"-").concat(Pt(e))}class Jc{constructor(e,t){this.base=void 0,this._duration=null,this._timelineStart=null,this.appendInPlaceDisabled=void 0,this.appendInPlaceStarted=void 0,this.dateRange=void 0,this.hasPlayed=!1,this.cumulativeDuration=0,this.resumeOffset=NaN,this.playoutLimit=NaN,this.restrictions={skip:!1,jump:!1},this.snapOptions={out:!1,in:!1},this.assetList=[],this.assetListLoader=void 0,this.assetListResponse=null,this.resumeAnchor=void 0,this.error=void 0,this.resetOnResume=void 0,this.base=t,this.dateRange=e,this.setDateRange(e)}setDateRange(e){this.dateRange=e,this.resumeOffset=e.attr.optionalFloat("X-RESUME-OFFSET",this.resumeOffset),this.playoutLimit=e.attr.optionalFloat("X-PLAYOUT-LIMIT",this.playoutLimit),this.restrictions=e.attr.enumeratedStringList("X-RESTRICT",this.restrictions),this.snapOptions=e.attr.enumeratedStringList("X-SNAP",this.snapOptions)}reset(){var e;this.appendInPlaceStarted=!1,(e=this.assetListLoader)==null||e.destroy(),this.assetListLoader=void 0,this.supplementsPrimary||(this.assetListResponse=null,this.assetList=[],this._duration=null)}isAssetPastPlayoutLimit(e){var t;if(e>0&&e>=this.assetList.length)return!0;const s=this.playoutLimit;return e<=0||isNaN(s)?!1:s===0?!0:(((t=this.assetList[e])==null?void 0:t.startOffset)||0)>s}findAssetIndex(e){return this.assetList.indexOf(e)}get identifier(){return this.dateRange.id}get startDate(){return this.dateRange.startDate}get startTime(){const e=this.dateRange.startTime;if(this.snapOptions.out){const t=this.dateRange.tagAnchor;if(t)return Ks(e,t)}return e}get startOffset(){return this.cue.pre?0:this.startTime}get startIsAligned(){if(this.startTime===0||this.snapOptions.out)return!0;const e=this.dateRange.tagAnchor;if(e){const t=this.dateRange.startTime,s=Ks(t,e);return t-s<.1}return!1}get resumptionOffset(){const e=this.resumeOffset,t=K(e)?e:this.duration;return this.cumulativeDuration+t}get resumeTime(){const e=this.startOffset+this.resumptionOffset;if(this.snapOptions.in){const t=this.resumeAnchor;if(t)return Ks(e,t)}return e}get appendInPlace(){return this.appendInPlaceStarted?!0:this.appendInPlaceDisabled?!1:!!(!this.cue.once&&!this.cue.pre&&this.startIsAligned&&(isNaN(this.playoutLimit)&&isNaN(this.resumeOffset)||this.resumeOffset&&this.duration&&Math.abs(this.resumeOffset-this.duration)<Tt))}set appendInPlace(e){if(this.appendInPlaceStarted){this.resetOnResume=!e;return}this.appendInPlaceDisabled=!e}get timelineStart(){return this._timelineStart!==null?this._timelineStart:this.startTime}set timelineStart(e){this._timelineStart=e}get duration(){const e=this.playoutLimit;let t;return this._duration!==null?t=this._duration:this.dateRange.duration?t=this.dateRange.duration:t=this.dateRange.plannedDuration||0,!isNaN(e)&&e<t&&(t=e),t}set duration(e){this._duration=e}get cue(){return this.dateRange.cue}get timelineOccupancy(){return this.dateRange.attr["X-TIMELINE-OCCUPIES"]==="RANGE"?As.Range:As.Point}get supplementsPrimary(){return this.dateRange.attr["X-TIMELINE-STYLE"]==="PRIMARY"}get contentMayVary(){return this.dateRange.attr["X-CONTENT-MAY-VARY"]!=="NO"}get assetUrl(){return this.dateRange.attr["X-ASSET-URI"]}get assetListUrl(){return this.dateRange.attr["X-ASSET-LIST"]}get baseUrl(){return this.base.url}get assetListLoaded(){return this.assetList.length>0||this.assetListResponse!==null}toString(){return eu(this)}}function Ks(a,e){return a-e.start<e.duration/2&&!(Math.abs(a-(e.start+e.duration))<Tt)?e.start:e.start+e.duration}function Pa(a,e,t){const s=new self.URL(a,t);return s.protocol!=="data:"&&s.searchParams.set("_HLS_primary_id",e),s}function Vs(a,e){for(;(t=a.assetList[++e])!=null&&t.error;)var t;return e}function eu(a){return'["'.concat(a.identifier,'" ').concat(a.cue.pre?"<pre>":a.cue.post?"<post>":"").concat(a.timelineStart.toFixed(2),"-").concat(a.resumeTime.toFixed(2),"]")}function mt(a){const e=a.timelineStart,t=a.duration||0;return'["'.concat(a.identifier,'" ').concat(e.toFixed(2),"-").concat((e+t).toFixed(2),"]")}class tu{constructor(e,t,s,i){this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetails=!1,this.mediaAttached=null,this._currentTime=void 0,this._bufferedEosTime=void 0,this.checkPlayout=()=>{this.reachedPlayout(this.currentTime)&&this.hls&&this.hls.trigger(y.PLAYOUT_LIMIT_REACHED,{})};const r=this.hls=new e(t);this.interstitial=s,this.assetItem=i;const n=()=>{this.hasDetails=!0};r.once(y.LEVEL_LOADED,n),r.once(y.AUDIO_TRACK_LOADED,n),r.once(y.SUBTITLE_TRACK_LOADED,n),r.on(y.MEDIA_ATTACHING,(o,{media:d})=>{this.removeMediaListeners(),this.mediaAttached=d,this.interstitial.playoutLimit&&(d.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&r.on(y.BUFFER_APPENDED,()=>{const c=this.bufferedEnd;this.reachedPlayout(c)&&(this._bufferedEosTime=c,r.trigger(y.BUFFERED_TO_END,void 0))}))})}get appendInPlace(){return this.interstitial.appendInPlace}loadSource(){const e=this.hls;if(e)if(e.url)e.levels.length&&!e.started&&e.startLoad(-1,!0);else{let t=this.assetItem.uri;try{t=Pa(t,e.config.primarySessionId||"").href}catch(s){}e.loadSource(t)}}bufferedInPlaceToEnd(e){var t;if(!this.appendInPlace)return!1;if((t=this.hls)!=null&&t.bufferedToEnd)return!0;if(!e)return!1;const s=Math.min(this._bufferedEosTime||1/0,this.duration),i=this.timelineOffset,r=X.bufferInfo(e,i,0);return this.getAssetTime(r.end)>=s-.02}reachedPlayout(e){const s=this.interstitial.playoutLimit;return this.startOffset+e>=s}get destroyed(){var e;return!((e=this.hls)!=null&&e.userConfig)}get assetId(){return this.assetItem.identifier}get interstitialId(){return this.assetItem.parentIdentifier}get media(){var e;return((e=this.hls)==null?void 0:e.media)||null}get bufferedEnd(){const e=this.media||this.mediaAttached;if(!e)return this._bufferedEosTime?this._bufferedEosTime:this.currentTime;const t=X.bufferInfo(e,e.currentTime,.001);return this.getAssetTime(t.end)}get currentTime(){const e=this.media||this.mediaAttached;return e?this.getAssetTime(e.currentTime):this._currentTime||0}get duration(){const e=this.assetItem.duration;if(!e)return 0;const t=this.interstitial.playoutLimit;if(t){const s=t-this.startOffset;if(s>0&&s<e)return s}return e}get remaining(){const e=this.duration;return e?Math.max(0,e-this.currentTime):0}get startOffset(){return this.assetItem.startOffset}get timelineOffset(){var e;return((e=this.hls)==null?void 0:e.config.timelineOffset)||0}set timelineOffset(e){const t=this.timelineOffset;if(e!==t){const s=e-t;if(Math.abs(s)>1/9e4&&this.hls){if(this.hasDetails)throw new Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=e}}}getAssetTime(e){const t=this.timelineOffset,s=this.duration;return Math.min(Math.max(0,e-t),s)}removeMediaListeners(){const e=this.mediaAttached;e&&(this._currentTime=e.currentTime,this.bufferSnapShot(),e.removeEventListener("timeupdate",this.checkPlayout))}bufferSnapShot(){if(this.mediaAttached){var e;(e=this.hls)!=null&&e.bufferedToEnd&&(this._bufferedEosTime=this.bufferedEnd)}}destroy(){this.removeMediaListeners(),this.hls&&this.hls.destroy(),this.hls=null,this.tracks=this.mediaAttached=this.checkPlayout=null}attachMedia(e){var t;this.loadSource(),(t=this.hls)==null||t.attachMedia(e)}detachMedia(){var e;this.removeMediaListeners(),this.mediaAttached=null,(e=this.hls)==null||e.detachMedia()}resumeBuffering(){var e;(e=this.hls)==null||e.resumeBuffering()}pauseBuffering(){var e;(e=this.hls)==null||e.pauseBuffering()}transferMedia(){var e;return this.bufferSnapShot(),((e=this.hls)==null?void 0:e.transferMedia())||null}resetDetails(){const e=this.hls;if(e&&this.hasDetails){e.stopLoad();const t=s=>delete s.details;e.levels.forEach(t),e.allAudioTracks.forEach(t),e.allSubtitleTracks.forEach(t),this.hasDetails=!1}}on(e,t,s){var i;(i=this.hls)==null||i.on(e,t)}once(e,t,s){var i;(i=this.hls)==null||i.once(e,t)}off(e,t,s){var i;(i=this.hls)==null||i.off(e,t)}toString(){var e;return"HlsAssetPlayer: ".concat(mt(this.assetItem)," ").concat((e=this.hls)==null?void 0:e.sessionId," ").concat(this.appendInPlace?"append-in-place":"")}}const Zr=.033;class su extends Pe{constructor(e,t){super("interstitials-sched",t),this.onScheduleUpdate=void 0,this.eventMap={},this.events=null,this.items=null,this.durations={primary:0,playout:0,integrated:0},this.onScheduleUpdate=e}destroy(){this.reset(),this.onScheduleUpdate=null}reset(){this.eventMap={},this.setDurations(0,0,0),this.events&&this.events.forEach(e=>e.reset()),this.events=this.items=null}resetErrorsInRange(e,t){return this.events?this.events.reduce((s,i)=>e<=i.startOffset&&t>i.startOffset?(delete i.error,s+1):s,0):0}get duration(){const e=this.items;return e?e[e.length-1].end:0}get length(){return this.items?this.items.length:0}getEvent(e){return e&&this.eventMap[e]||null}hasEvent(e){return e in this.eventMap}findItemIndex(e,t){if(e.event)return this.findEventIndex(e.event.identifier);let s=-1;e.nextEvent?s=this.findEventIndex(e.nextEvent.identifier)-1:e.previousEvent&&(s=this.findEventIndex(e.previousEvent.identifier)+1);const i=this.items;if(i)for(i[s]||(t===void 0&&(t=e.start),s=this.findItemIndexAtTime(t));s>=0&&(r=i[s])!=null&&r.event;){var r;s--}return s}findItemIndexAtTime(e,t){const s=this.items;if(s)for(let i=0;i<s.length;i++){let r=s[i];if(t&&t!=="primary"&&(r=r[t]),e===r.start||e>r.start&&e<r.end)return i}return-1}findJumpRestrictedIndex(e,t){const s=this.items;if(s)for(let i=e;i<=t&&s[i];i++){const r=s[i].event;if(r!=null&&r.restrictions.jump&&!r.appendInPlace)return i}return-1}findEventIndex(e){const t=this.items;if(t)for(let i=t.length;i--;){var s;if(((s=t[i].event)==null?void 0:s.identifier)===e)return i}return-1}findAssetIndex(e,t){const s=e.assetList,i=s.length;if(i>1)for(let r=0;r<i;r++){const n=s[r];if(!n.error){const o=n.timelineStart;if(t===o||t>o&&(t<o+(n.duration||0)||r===i-1))return r}}return 0}get assetIdAtEnd(){var e;const t=(e=this.items)==null||(e=e[this.length-1])==null?void 0:e.event;if(t){const s=t.assetList,i=s[s.length-1];if(i)return i.identifier}return null}parseInterstitialDateRanges(e,t){const s=e.main.details,{dateRanges:i}=s,r=this.events,n=this.parseDateRanges(i,{url:s.url},t),o=Object.keys(i),d=r?r.filter(l=>!o.includes(l.identifier)):[];n.length&&n.sort((l,c)=>{const u=l.cue.pre,h=l.cue.post,f=c.cue.pre,g=c.cue.post;if(u&&!f)return-1;if(f&&!u||h&&!g)return 1;if(g&&!h)return-1;if(!u&&!f&&!h&&!g){const m=l.startTime,p=c.startTime;if(m!==p)return m-p}return l.dateRange.tagOrder-c.dateRange.tagOrder}),this.events=n,d.forEach(l=>{this.removeEvent(l)}),this.updateSchedule(e,d)}updateSchedule(e,t=[],s=!1){const i=this.events||[];if(i.length||t.length||this.length<2){const r=this.items,n=this.parseSchedule(i,e);(s||t.length||(r==null?void 0:r.length)!==n.length||n.some((d,l)=>Math.abs(d.playout.start-r[l].playout.start)>.005||Math.abs(d.playout.end-r[l].playout.end)>.005))&&(this.items=n,this.onScheduleUpdate(t,r))}}parseDateRanges(e,t,s){const i=[],r=Object.keys(e);for(let n=0;n<r.length;n++){const o=r[n],d=e[o];if(d.isInterstitial){let l=this.eventMap[o];l?l.setDateRange(d):(l=new Jc(d,t),this.eventMap[o]=l,s===!1&&(l.appendInPlace=s)),i.push(l)}}return i}parseSchedule(e,t){const s=[],i=t.main.details,r=i.live?1/0:i.edge;let n=0;if(e=e.filter(d=>!d.error&&!(d.cue.once&&d.hasPlayed)),e.length){this.resolveOffsets(e,t);let d=0,l=0;if(e.forEach((c,u)=>{const h=c.cue.pre,f=c.cue.post,g=e[u-1]||null,m=c.appendInPlace,p=f?r:c.startOffset,v=c.duration,E=c.timelineOccupancy===As.Range?v:0,T=c.resumptionOffset,S=(g==null?void 0:g.startTime)===p,x=p+c.cumulativeDuration;let b=m?x+v:p+T;if(h||!f&&p<=0){const I=l;l+=E,c.timelineStart=x;const R=n;n+=v,s.push({event:c,start:x,end:b,playout:{start:R,end:n},integrated:{start:I,end:l}})}else if(p<=r){if(!S){const L=p-d;if(L>Zr){const w=d,U=l;l+=L;const V=n;n+=L;const B={previousEvent:e[u-1]||null,nextEvent:c,start:w,end:w+L,playout:{start:V,end:n},integrated:{start:U,end:l}};s.push(B)}else L>0&&g&&(g.cumulativeDuration+=L,s[s.length-1].end=p)}f&&(b=x),c.timelineStart=x;const I=l;l+=E;const R=n;n+=v,s.push({event:c,start:x,end:b,playout:{start:R,end:n},integrated:{start:I,end:l}})}else return;const A=c.resumeTime;f||A>r?d=r:d=A}),d<r){var o;const c=d,u=l,h=r-d;l+=h;const f=n;n+=h,s.push({previousEvent:((o=s[s.length-1])==null?void 0:o.event)||null,nextEvent:null,start:d,end:c+h,playout:{start:f,end:n},integrated:{start:u,end:l}})}this.setDurations(r,n,l)}else s.push({previousEvent:null,nextEvent:null,start:0,end:r,playout:{start:0,end:r},integrated:{start:0,end:r}}),this.setDurations(r,r,r);return s}setDurations(e,t,s){this.durations={primary:e,playout:t,integrated:s}}resolveOffsets(e,t){const s=t.main.details,i=s.live?1/0:s.edge;let r=0,n=-1;e.forEach((o,d)=>{const l=o.cue.pre,c=o.cue.post,u=l?0:c?i:o.startTime;this.updateAssetDurations(o),n===u?o.cumulativeDuration=r:(r=0,n=u),!c&&o.snapOptions.in&&(o.resumeAnchor=lt(null,s.fragments,o.startOffset+o.resumptionOffset,0,0)||void 0),o.appendInPlace&&!o.appendInPlaceStarted&&(this.primaryCanResumeInPlaceAt(o,t)||(o.appendInPlace=!1)),!o.appendInPlace&&d+1<e.length&&e[d+1].startTime-e[d].resumeTime<Zr&&(e[d+1].appendInPlace=!1,e[d+1].appendInPlace&&this.warn("Could not change append strategy for abutting event ".concat(o)));const f=K(o.resumeOffset)?o.resumeOffset:o.duration;r+=f})}primaryCanResumeInPlaceAt(e,t){const s=e.resumeTime,i=e.startTime+e.resumptionOffset;return Math.abs(s-i)>Tt?(this.log('"'.concat(e.identifier,'" resumption ').concat(s," not aligned with estimated timeline end ").concat(i)),!1):!Object.keys(t).some(n=>{const o=t[n].details,d=o.edge;if(s>=d)return this.log('"'.concat(e.identifier,'" resumption ').concat(s," past ").concat(n," playlist end ").concat(d)),!1;const l=lt(null,o.fragments,s);if(!l)return this.log('"'.concat(e.identifier,'" resumption ').concat(s," does not align with any fragments in ").concat(n," playlist (").concat(o.fragStart,"-").concat(o.fragmentEnd,")")),!0;const c=n==="audio"?.175:0;return Math.abs(l.start-s)<Tt+c||Math.abs(l.end-s)<Tt+c?!1:(this.log('"'.concat(e.identifier,'" resumption ').concat(s," not aligned with ").concat(n," fragment bounds (").concat(l.start,"-").concat(l.end," sn: ").concat(l.sn," cc: ").concat(l.cc,")")),!0)})}updateAssetDurations(e){if(!e.assetListLoaded)return;const t=e.timelineStart;let s=0,i=!1,r=!1;for(let n=0;n<e.assetList.length;n++){const o=e.assetList[n],d=t+s;o.startOffset=s,o.timelineStart=d,i||(i=o.duration===null),r||(r=!!o.error);const l=o.error?0:o.duration||0;s+=l}i&&!r?e.duration=Math.max(s,e.duration):e.duration=s}removeEvent(e){e.reset(),delete this.eventMap[e.identifier]}}function Oe(a){return"[".concat(a.event?'"'+a.event.identifier+'"':"primary",": ").concat(a.start.toFixed(2),"-").concat(a.end.toFixed(2),"]")}class iu{constructor(e){this.hls=void 0,this.hls=e}destroy(){this.hls=null}loadAssetList(e,t){const s=e.assetListUrl;let i;try{i=Pa(s,this.hls.sessionId,e.baseUrl)}catch(h){const f=this.assignAssetListError(e,_.ASSET_LIST_LOAD_ERROR,h,s);this.hls.trigger(y.ERROR,f);return}t&&i.protocol!=="data:"&&i.searchParams.set("_HLS_start_offset",""+t);const r=this.hls.config,n=r.loader,o=new n(r),d={responseType:"json",url:i.href},l=r.interstitialAssetListLoadPolicy.default,c={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(h,f,g,m)=>{const p=h.data,v=p==null?void 0:p.ASSETS;if(!Array.isArray(v)){const E=this.assignAssetListError(e,_.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),g.url,f,m);this.hls.trigger(y.ERROR,E);return}e.assetListResponse=p,this.hls.trigger(y.ASSET_LIST_LOADED,{event:e,assetListResponse:p,networkDetails:m})},onError:(h,f,g,m)=>{const p=this.assignAssetListError(e,_.ASSET_LIST_LOAD_ERROR,new Error("Error loading X-ASSET-LIST: HTTP status ".concat(h.code," ").concat(h.text," (").concat(f.url,")")),f.url,m,g);this.hls.trigger(y.ERROR,p)},onTimeout:(h,f,g)=>{const m=this.assignAssetListError(e,_.ASSET_LIST_LOAD_TIMEOUT,new Error("Timeout loading X-ASSET-LIST (".concat(f.url,")")),f.url,h,g);this.hls.trigger(y.ERROR,m)}};return o.load(d,c,u),this.hls.trigger(y.ASSET_LIST_LOADING,{event:e}),o}assignAssetListError(e,t,s,i,r,n){return e.error=s,{type:W.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:i,error:s,networkDetails:n,stats:r}}}function Jr(a){a==null||a.play().catch(()=>{})}function Jt(a,e){return"[".concat(a,"] Advancing timeline position to ").concat(e)}class ru extends Pe{constructor(e,t){super("interstitials",e.logger),this.HlsPlayerClass=void 0,this.hls=void 0,this.assetListLoader=void 0,this.mediaSelection=null,this.altSelection=null,this.media=null,this.detachedData=null,this.requiredTracks=null,this.manager=null,this.playerQueue=[],this.bufferedPos=-1,this.timelinePos=-1,this.schedule=void 0,this.playingItem=null,this.bufferingItem=null,this.waitingItem=null,this.endedItem=null,this.playingAsset=null,this.endedAsset=null,this.bufferingAsset=null,this.shouldPlay=!1,this.onPlay=()=>{this.shouldPlay=!0},this.onPause=()=>{this.shouldPlay=!1},this.onSeeking=()=>{const s=this.currentTime;if(s===void 0||this.playbackDisabled||!this.schedule)return;const i=s-this.timelinePos;if(Math.abs(i)<1/7056e5)return;const n=i<=-.01;this.timelinePos=s,this.bufferedPos=s;const o=this.playingItem;if(!o){this.checkBuffer();return}if(n&&this.schedule.resetErrorsInRange(s,s-i)&&this.updateSchedule(!0),this.checkBuffer(),n&&s<o.start||s>=o.end){var d;const f=this.findItemIndex(o);let g=this.schedule.findItemIndexAtTime(s);if(g===-1&&(g=f+(n?-1:1),this.log("seeked ".concat(n?"back ":"","to position not covered by schedule ").concat(s," (resolving from ").concat(f," to ").concat(g,")"))),!this.isInterstitial(o)&&(d=this.media)!=null&&d.paused&&(this.shouldPlay=!1),!n&&g>f){const m=this.schedule.findJumpRestrictedIndex(f+1,g);if(m>f){this.setSchedulePosition(m);return}}this.setSchedulePosition(g);return}const l=this.playingAsset;if(!l){if(this.playingLastItem&&this.isInterstitial(o)){const f=o.event.assetList[0];f&&(this.endedItem=this.playingItem,this.playingItem=null,this.setScheduleToAssetAtTime(s,f))}return}const c=l.timelineStart,u=l.duration||0;if(n&&s<c||s>=c+u){var h;(h=o.event)!=null&&h.appendInPlace&&(this.clearInterstitial(o.event,o),this.flushFrontBuffer(s)),this.setScheduleToAssetAtTime(s,l)}},this.onTimeupdate=()=>{const s=this.currentTime;if(s===void 0||this.playbackDisabled)return;if(s>this.timelinePos)this.timelinePos=s,s>this.bufferedPos&&this.checkBuffer();else return;const i=this.playingItem;if(!i||this.playingLastItem)return;if(s>=i.end){this.timelinePos=i.end;const o=this.findItemIndex(i);this.setSchedulePosition(o+1)}const r=this.playingAsset;if(!r)return;const n=r.timelineStart+(r.duration||0);s>=n&&this.setScheduleToAssetAtTime(s,r)},this.onScheduleUpdate=(s,i)=>{const r=this.schedule;if(!r)return;const n=this.playingItem,o=r.events||[],d=r.items||[],l=r.durations,c=s.map(m=>m.identifier),u=!!(o.length||c.length);(u||i)&&this.log("INTERSTITIALS_UPDATED (".concat(o.length,"): ").concat(o,"\nSchedule: ").concat(d.map(m=>Oe(m))," pos: ").concat(this.timelinePos)),c.length&&this.log("Removed events ".concat(c));let h=null,f=null;n&&(h=this.updateItem(n,this.timelinePos),this.itemsMatch(n,h)?this.playingItem=h:this.waitingItem=this.endedItem=null),this.waitingItem=this.updateItem(this.waitingItem),this.endedItem=this.updateItem(this.endedItem);const g=this.bufferingItem;if(g&&(f=this.updateItem(g,this.bufferedPos),this.itemsMatch(g,f)?this.bufferingItem=f:g.event&&(this.bufferingItem=this.playingItem,this.clearInterstitial(g.event,null))),s.forEach(m=>{m.assetList.forEach(p=>{this.clearAssetPlayer(p.identifier,null)})}),this.playerQueue.forEach(m=>{if(m.interstitial.appendInPlace){const p=m.assetItem.timelineStart,v=m.timelineOffset-p;if(v)try{m.timelineOffset=p}catch(E){Math.abs(v)>Tt&&this.warn("".concat(E,' ("').concat(m.assetId,'" ').concat(m.timelineOffset,"->").concat(p,")"))}}}),u||i){if(this.hls.trigger(y.INTERSTITIALS_UPDATED,{events:o.slice(0),schedule:d.slice(0),durations:l,removedIds:c}),this.isInterstitial(n)&&c.includes(n.event.identifier)){this.warn('Interstitial "'.concat(n.event.identifier,'" removed while playing')),this.primaryFallback(n.event);return}n&&this.trimInPlace(h,n),g&&f!==h&&this.trimInPlace(f,g),this.checkBuffer()}},this.hls=e,this.HlsPlayerClass=t,this.assetListLoader=new iu(e),this.schedule=new su(this.onScheduleUpdate,e.logger),this.registerListeners()}registerListeners(){const e=this.hls;e&&(e.on(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(y.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(y.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(y.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(y.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(y.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(y.BUFFER_APPENDED,this.onBufferAppended,this),e.on(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(y.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(y.MEDIA_ENDED,this.onMediaEnded,this),e.on(y.ERROR,this.onError,this),e.on(y.DESTROYING,this.onDestroying,this))}unregisterListeners(){const e=this.hls;e&&(e.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(y.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(y.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(y.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(y.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(y.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(y.BUFFER_CODECS,this.onBufferCodecs,this),e.off(y.BUFFER_APPENDED,this.onBufferAppended,this),e.off(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(y.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(y.MEDIA_ENDED,this.onMediaEnded,this),e.off(y.ERROR,this.onError,this),e.off(y.DESTROYING,this.onDestroying,this))}startLoad(){this.resumeBuffering()}stopLoad(){this.pauseBuffering()}resumeBuffering(){var e;(e=this.getBufferingPlayer())==null||e.resumeBuffering()}pauseBuffering(){var e;(e=this.getBufferingPlayer())==null||e.pauseBuffering()}destroy(){this.unregisterListeners(),this.stopLoad(),this.assetListLoader&&this.assetListLoader.destroy(),this.emptyPlayerQueue(),this.clearScheduleState(),this.schedule&&this.schedule.destroy(),this.media=this.detachedData=this.mediaSelection=this.requiredTracks=this.altSelection=this.schedule=this.manager=null,this.hls=this.HlsPlayerClass=this.log=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null}onDestroying(){const e=this.primaryMedia||this.media;e&&this.removeMediaListeners(e)}removeMediaListeners(e){Le(e,"play",this.onPlay),Le(e,"pause",this.onPause),Le(e,"seeking",this.onSeeking),Le(e,"timeupdate",this.onTimeupdate)}onMediaAttaching(e,t){const s=this.media=t.media;Te(s,"seeking",this.onSeeking),Te(s,"timeupdate",this.onTimeupdate),Te(s,"play",this.onPlay),Te(s,"pause",this.onPause)}onMediaAttached(e,t){const s=this.effectivePlayingItem,i=this.detachedData;if(this.detachedData=null,s===null)this.checkStart();else if(!i){this.clearScheduleState();const r=this.findItemIndex(s);this.setSchedulePosition(r)}}clearScheduleState(){this.log("clear schedule state"),this.playingItem=this.bufferingItem=this.waitingItem=this.endedItem=this.playingAsset=this.endedAsset=this.bufferingAsset=null}onMediaDetaching(e,t){const s=!!t.transferMedia,i=this.media;if(this.media=null,!s&&(i&&this.removeMediaListeners(i),this.detachedData)){const r=this.getBufferingPlayer();r&&(this.log("Removing schedule state for detachedData and ".concat(r)),this.playingAsset=this.endedAsset=this.bufferingAsset=this.bufferingItem=this.waitingItem=this.detachedData=null,r.detachMedia()),this.shouldPlay=!1}}get interstitialsManager(){if(!this.hls)return null;if(this.manager)return this.manager;const e=this,t=()=>e.bufferingItem||e.waitingItem,s=u=>u&&e.getAssetPlayer(u.identifier),i=(u,h,f,g,m)=>{if(u){let p=u[h].start;const v=u.event;if(v){if(h==="playout"||v.timelineOccupancy!==As.Point){const E=s(f);(E==null?void 0:E.interstitial)===v&&(p+=E.assetItem.startOffset+E[m])}}else{const E=g==="bufferedPos"?n():e[g];p+=E-u.start}return p}return 0},r=(u,h)=>{var f;if(u!==0&&h!=="primary"&&(f=e.schedule)!=null&&f.length){var g;const m=e.schedule.findItemIndexAtTime(u),p=(g=e.schedule.items)==null?void 0:g[m];if(p){const v=p[h].start-p.start;return u+v}}return u},n=()=>{const u=e.bufferedPos;return u===Number.MAX_VALUE?o("primary"):Math.max(u,0)},o=u=>{var h,f;return(h=e.primaryDetails)!=null&&h.live?e.primaryDetails.edge:((f=e.schedule)==null?void 0:f.durations[u])||0},d=(u,h)=>{var f,g;const m=e.effectivePlayingItem;if(m!=null&&(f=m.event)!=null&&f.restrictions.skip||!e.schedule)return;e.log("seek to ".concat(u,' "').concat(h,'"'));const p=e.effectivePlayingItem,v=e.schedule.findItemIndexAtTime(u,h),E=(g=e.schedule.items)==null?void 0:g[v],T=e.getBufferingPlayer(),S=T==null?void 0:T.interstitial,x=S==null?void 0:S.appendInPlace,b=p&&e.itemsMatch(p,E);if(p&&(x||b)){const A=s(e.playingAsset),I=(A==null?void 0:A.media)||e.primaryMedia;if(I){const R=h==="primary"?I.currentTime:i(p,h,e.playingAsset,"timelinePos","currentTime"),L=u-R,w=(x?R:I.currentTime)+L;if(w>=0&&(!A||x||w<=A.duration)){I.currentTime=w;return}}}if(E){let A=u;if(h!=="primary"){const R=E[h].start,L=u-R;A=E.start+L}const I=!e.isInterstitial(E);if((!e.isInterstitial(p)||p.event.appendInPlace)&&(I||E.event.appendInPlace)){const R=e.media||(x?T==null?void 0:T.media:null);R&&(R.currentTime=A)}else if(p){const R=e.findItemIndex(p);if(v>R){const w=e.schedule.findJumpRestrictedIndex(R+1,v);if(w>R){e.setSchedulePosition(w);return}}let L=0;if(I)e.timelinePos=A,e.checkBuffer();else{const w=E.event.assetList,U=u-(E[h]||E).start;for(let V=w.length;V--;){const B=w[V];if(B.duration&&U>=B.startOffset&&U<B.startOffset+B.duration){L=V;break}}}e.setSchedulePosition(v,L)}}},l=()=>{const u=e.effectivePlayingItem;if(e.isInterstitial(u))return u;const h=t();return e.isInterstitial(h)?h:null},c={get bufferedEnd(){const u=t(),h=e.bufferingItem;if(h&&h===u){var f;return i(h,"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")-h.playout.start||((f=e.bufferingAsset)==null?void 0:f.startOffset)||0}return 0},get currentTime(){const u=l(),h=e.effectivePlayingItem;return h&&h===u?i(h,"playout",e.effectivePlayingAsset,"timelinePos","currentTime")-h.playout.start:0},set currentTime(u){const h=l(),f=e.effectivePlayingItem;f&&f===h&&d(u+f.playout.start,"playout")},get duration(){const u=l();return u?u.playout.end-u.playout.start:0},get assetPlayers(){var u;const h=(u=l())==null?void 0:u.event.assetList;return h?h.map(f=>e.getAssetPlayer(f.identifier)):[]},get playingIndex(){var u;const h=(u=l())==null?void 0:u.event;return h&&e.effectivePlayingAsset?h.findAssetIndex(e.effectivePlayingAsset):-1},get scheduleItem(){return l()}};return this.manager={get events(){var u;return((u=e.schedule)==null||(u=u.events)==null?void 0:u.slice(0))||[]},get schedule(){var u;return((u=e.schedule)==null||(u=u.items)==null?void 0:u.slice(0))||[]},get interstitialPlayer(){return l()?c:null},get playerQueue(){return e.playerQueue.slice(0)},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return t()},get bufferingIndex(){const u=t();return e.findItemIndex(u)},get playingAsset(){return e.effectivePlayingAsset},get playingItem(){return e.effectivePlayingItem},get playingIndex(){const u=e.effectivePlayingItem;return e.findItemIndex(u)},primary:{get bufferedEnd(){return n()},get currentTime(){const u=e.timelinePos;return u>0?u:0},set currentTime(u){d(u,"primary")},get duration(){return o("primary")},get seekableStart(){var u;return((u=e.primaryDetails)==null?void 0:u.fragmentStart)||0}},integrated:{get bufferedEnd(){return i(t(),"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return i(e.effectivePlayingItem,"integrated",e.effectivePlayingAsset,"timelinePos","currentTime")},set currentTime(u){d(u,"integrated")},get duration(){return o("integrated")},get seekableStart(){var u;return r(((u=e.primaryDetails)==null?void 0:u.fragmentStart)||0,"integrated")}},skip:()=>{const u=e.effectivePlayingItem,h=u==null?void 0:u.event;if(h&&!h.restrictions.skip){const f=e.findItemIndex(u);if(h.appendInPlace){const g=u.playout.start+u.event.duration;d(g+.001,"playout")}else e.advanceAfterAssetEnded(h,f,1/0)}}}}get effectivePlayingItem(){return this.waitingItem||this.playingItem||this.endedItem}get effectivePlayingAsset(){return this.playingAsset||this.endedAsset}get playingLastItem(){var e;const t=this.playingItem,s=(e=this.schedule)==null?void 0:e.items;return!this.playbackStarted||!t||!s?!1:this.findItemIndex(t)===s.length-1}get playbackStarted(){return this.effectivePlayingItem!==null}get currentTime(){var e,t;if(this.mediaSelection===null)return;const s=this.waitingItem||this.playingItem;if(this.isInterstitial(s)&&!s.event.appendInPlace)return;let i=this.media;!i&&(e=this.bufferingItem)!=null&&(e=e.event)!=null&&e.appendInPlace&&(i=this.primaryMedia);const r=(t=i)==null?void 0:t.currentTime;if(!(r===void 0||!K(r)))return r}get primaryMedia(){var e;return this.media||((e=this.detachedData)==null?void 0:e.media)||null}isInterstitial(e){return!!(e!=null&&e.event)}retreiveMediaSource(e,t){const s=this.getAssetPlayer(e);s&&this.transferMediaFromPlayer(s,t)}transferMediaFromPlayer(e,t){const s=e.interstitial.appendInPlace,i=e.media;if(s&&i===this.primaryMedia){if(this.bufferingAsset=null,(!t||this.isInterstitial(t)&&!t.event.appendInPlace)&&t&&i){this.detachedData={media:i};return}const r=e.transferMedia();this.log("transfer MediaSource from ".concat(e," ").concat(ne(r))),this.detachedData=r}else t&&i&&(this.shouldPlay||(this.shouldPlay=!i.paused))}transferMediaTo(e,t){var s,i;if(e.media===t)return;let r=null;const n=this.hls,o=e!==n,d=o&&e.interstitial.appendInPlace,l=(s=this.detachedData)==null?void 0:s.mediaSource;let c;if(n.media)d&&(r=n.transferMedia(),this.detachedData=r),c="Primary";else if(l){const g=this.getBufferingPlayer();g?(r=g.transferMedia(),c="".concat(g)):c="detached MediaSource"}else c="detached media";if(!r){if(l)r=this.detachedData,this.log("using detachedData: MediaSource ".concat(ne(r)));else if(!this.detachedData||n.media===t){const g=this.playerQueue;g.length>1&&g.forEach(m=>{if(o&&m.interstitial.appendInPlace!==d){const p=m.interstitial;this.clearInterstitial(m.interstitial,null),p.appendInPlace=!1,p.appendInPlace&&this.warn("Could not change append strategy for queued assets ".concat(p))}}),this.hls.detachMedia(),this.detachedData={media:t}}}const u=r&&"mediaSource"in r&&((i=r.mediaSource)==null?void 0:i.readyState)!=="closed",h=u&&r?r:t;this.log("".concat(u?"transfering MediaSource":"attaching media"," to ").concat(o?e:"Primary"," from ").concat(c," (media.currentTime: ").concat(t.currentTime,")"));const f=this.schedule;if(h===r&&f){const g=o&&e.assetId===f.assetIdAtEnd;h.overrides={duration:f.duration,endOfStream:!o||g,cueRemoval:!o}}e.attachMedia(h)}onInterstitialCueEnter(){this.onTimeupdate()}checkStart(){const e=this.schedule,t=e==null?void 0:e.events;if(!t||this.playbackDisabled||!this.media)return;this.bufferedPos===-1&&(this.bufferedPos=0);const s=this.timelinePos,i=this.effectivePlayingItem;if(s===-1){const r=this.hls.startPosition;if(this.log(Jt("checkStart",r)),this.timelinePos=r,t.length&&t[0].cue.pre){const n=e.findEventIndex(t[0].identifier);this.setSchedulePosition(n)}else if(r>=0||!this.primaryLive){const n=this.timelinePos=r>0?r:0,o=e.findItemIndexAtTime(n);this.setSchedulePosition(o)}}else if(i&&!this.playingItem){const r=e.findItemIndex(i);this.setSchedulePosition(r)}}advanceAssetBuffering(e,t){const s=e.event,i=s.findAssetIndex(t),r=Vs(s,i);if(!s.isAssetPastPlayoutLimit(r))this.bufferedToEvent(e,r);else if(this.schedule){var n;const o=(n=this.schedule.items)==null?void 0:n[this.findItemIndex(e)+1];o&&this.bufferedToItem(o)}}advanceAfterAssetEnded(e,t,s){const i=Vs(e,s);if(e.isAssetPastPlayoutLimit(i)){if(this.schedule){const r=this.schedule.items;if(r){const n=t+1,o=r.length;if(n>=o){this.setSchedulePosition(-1);return}const d=e.resumeTime;this.timelinePos<d&&(this.log(Jt("advanceAfterAssetEnded",d)),this.timelinePos=d,e.appendInPlace&&this.advanceInPlace(d),this.checkBuffer(this.bufferedPos<d)),this.setSchedulePosition(n)}}}else{if(e.appendInPlace){const r=e.assetList[i];r&&this.advanceInPlace(r.timelineStart)}this.setSchedulePosition(t,i)}}setScheduleToAssetAtTime(e,t){const s=this.schedule;if(!s)return;const i=t.parentIdentifier,r=s.getEvent(i);if(r){const n=s.findEventIndex(i),o=s.findAssetIndex(r,e);this.advanceAfterAssetEnded(r,n,o-1)}}setSchedulePosition(e,t){var s;const i=(s=this.schedule)==null?void 0:s.items;if(!i||this.playbackDisabled)return;const r=e>=0?i[e]:null;this.log("setSchedulePosition ".concat(e,", ").concat(t," (").concat(r&&Oe(r),") pos: ").concat(this.timelinePos));const n=this.waitingItem||this.playingItem,o=this.playingLastItem;if(this.isInterstitial(n)){const c=n.event,u=this.playingAsset,h=u==null?void 0:u.identifier,f=h?this.getAssetPlayer(h):null;if(f&&h&&(!this.eventItemsMatch(n,r)||t!==void 0&&h!==c.assetList[t].identifier)){var d;const g=c.findAssetIndex(u);if(this.log("INTERSTITIAL_ASSET_ENDED ".concat(g+1,"/").concat(c.assetList.length," ").concat(mt(u))),this.endedAsset=u,this.playingAsset=null,this.hls.trigger(y.INTERSTITIAL_ASSET_ENDED,{asset:u,assetListIndex:g,event:c,schedule:i.slice(0),scheduleIndex:e,player:f}),n!==this.playingItem){this.itemsMatch(n,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(c,this.findItemIndex(this.playingItem),g);return}this.retreiveMediaSource(h,r),f.media&&!((d=this.detachedData)!=null&&d.mediaSource)&&f.detachMedia()}if(!this.eventItemsMatch(n,r)&&(this.endedItem=n,this.playingItem=null,this.log("INTERSTITIAL_ENDED ".concat(c," ").concat(Oe(n))),c.hasPlayed=!0,this.hls.trigger(y.INTERSTITIAL_ENDED,{event:c,schedule:i.slice(0),scheduleIndex:e}),c.cue.once)){var l;this.updateSchedule();const g=(l=this.schedule)==null?void 0:l.items;if(r&&g){const m=this.findItemIndex(r);this.advanceSchedule(m,g,t,n,o)}return}}this.advanceSchedule(e,i,t,n,o)}advanceSchedule(e,t,s,i,r){const n=this.schedule;if(!n)return;const o=t[e]||null,d=this.primaryMedia,l=this.playerQueue;if(l.length&&l.forEach(c=>{const u=c.interstitial,h=n.findEventIndex(u.identifier);(h<e||h>e+1)&&this.clearInterstitial(u,o)}),this.isInterstitial(o)){this.timelinePos=Math.min(Math.max(this.timelinePos,o.start),o.end);const c=o.event;if(s===void 0){s=n.findAssetIndex(c,this.timelinePos);const g=Vs(c,s-1);if(c.isAssetPastPlayoutLimit(g)||c.appendInPlace&&this.timelinePos===o.end){this.advanceAfterAssetEnded(c,e,s);return}s=g}const u=this.waitingItem;this.assetsBuffered(o,d)||this.setBufferingItem(o);let h=this.preloadAssets(c,s);if(this.eventItemsMatch(o,u||i)||(this.waitingItem=o,this.log("INTERSTITIAL_STARTED ".concat(Oe(o)," ").concat(c.appendInPlace?"append in place":"")),this.hls.trigger(y.INTERSTITIAL_STARTED,{event:c,schedule:t.slice(0),scheduleIndex:e})),!c.assetListLoaded){this.log("Waiting for ASSET-LIST to complete loading ".concat(c));return}if(c.assetListLoader&&(c.assetListLoader.destroy(),c.assetListLoader=void 0),!d){this.log("Waiting for attachMedia to start Interstitial ".concat(c));return}this.waitingItem=this.endedItem=null,this.playingItem=o;const f=c.assetList[s];if(!f){this.advanceAfterAssetEnded(c,e,s||0);return}if(h||(h=this.getAssetPlayer(f.identifier)),h===null||h.destroyed){const g=c.assetList.length;this.warn("asset ".concat(s+1,"/").concat(g," player destroyed ").concat(c)),h=this.createAssetPlayer(c,f,s),h.loadSource()}if(!this.eventItemsMatch(o,this.bufferingItem)&&c.appendInPlace&&this.isAssetBuffered(f))return;this.startAssetPlayer(h,s,t,e,d),this.shouldPlay&&Jr(h.media)}else o?(this.resumePrimary(o,e,i),this.shouldPlay&&Jr(this.hls.media)):r&&this.isInterstitial(i)&&(this.endedItem=null,this.playingItem=i,i.event.appendInPlace||this.attachPrimary(n.durations.primary,null))}get playbackDisabled(){return this.hls.config.enableInterstitialPlayback===!1}get primaryDetails(){var e;return(e=this.mediaSelection)==null?void 0:e.main.details}get primaryLive(){var e;return!!((e=this.primaryDetails)!=null&&e.live)}resumePrimary(e,t,s){var i,r;if(this.playingItem=e,this.playingAsset=this.endedAsset=null,this.waitingItem=this.endedItem=null,this.bufferedToItem(e),this.log("resuming ".concat(Oe(e))),!((i=this.detachedData)!=null&&i.mediaSource)){let o=this.timelinePos;(o<e.start||o>=e.end)&&(o=this.getPrimaryResumption(e,t),this.log(Jt("resumePrimary",o)),this.timelinePos=o),this.attachPrimary(o,e)}if(!s)return;const n=(r=this.schedule)==null?void 0:r.items;n&&(this.log("INTERSTITIALS_PRIMARY_RESUMED ".concat(Oe(e))),this.hls.trigger(y.INTERSTITIALS_PRIMARY_RESUMED,{schedule:n.slice(0),scheduleIndex:t}),this.checkBuffer())}getPrimaryResumption(e,t){const s=e.start;if(this.primaryLive){const i=this.primaryDetails;if(t===0)return this.hls.startPosition;if(i&&(s<i.fragmentStart||s>i.edge))return this.hls.liveSyncPosition||-1}return s}isAssetBuffered(e){const t=this.getAssetPlayer(e.identifier);return t!=null&&t.hls?t.hls.bufferedToEnd:X.bufferInfo(this.primaryMedia,this.timelinePos,0).end+1>=e.timelineStart+(e.duration||0)}attachPrimary(e,t,s){t?this.setBufferingItem(t):this.bufferingItem=this.playingItem,this.bufferingAsset=null;const i=this.primaryMedia;if(!i)return;const r=this.hls;r.media?this.checkBuffer():(this.transferMediaTo(r,i),s&&this.startLoadingPrimaryAt(e,s)),s||(this.log(Jt("attachPrimary",e)),this.timelinePos=e,this.startLoadingPrimaryAt(e,s))}startLoadingPrimaryAt(e,t){var s;const i=this.hls;!i.loadingEnabled||!i.media||Math.abs((((s=i.mainForwardBufferInfo)==null?void 0:s.start)||i.media.currentTime)-e)>.5?i.startLoad(e,t):i.bufferingEnabled||i.resumeBuffering()}onManifestLoading(){var e;this.stopLoad(),(e=this.schedule)==null||e.reset(),this.emptyPlayerQueue(),this.clearScheduleState(),this.shouldPlay=!1,this.bufferedPos=this.timelinePos=-1,this.mediaSelection=this.altSelection=this.manager=this.requiredTracks=null,this.hls.off(y.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(y.BUFFER_CODECS,this.onBufferCodecs,this)}onLevelUpdated(e,t){if(t.level===-1||!this.schedule)return;const s=this.hls.levels[t.level];if(!s.details)return;const i=te(te({},this.mediaSelection||this.altSelection),{},{main:s});this.mediaSelection=i,this.schedule.parseInterstitialDateRanges(i,this.hls.config.interstitialAppendInPlace),!this.effectivePlayingItem&&this.schedule.items&&this.checkStart()}onAudioTrackUpdated(e,t){const s=this.hls.audioTracks[t.id],i=this.mediaSelection;if(!i){this.altSelection=te(te({},this.altSelection),{},{audio:s});return}const r=te(te({},i),{},{audio:s});this.mediaSelection=r}onSubtitleTrackUpdated(e,t){const s=this.hls.subtitleTracks[t.id],i=this.mediaSelection;if(!i){this.altSelection=te(te({},this.altSelection),{},{subtitles:s});return}const r=te(te({},i),{},{subtitles:s});this.mediaSelection=r}onAudioTrackSwitching(e,t){const s=cr(t);this.playerQueue.forEach(({hls:i})=>i&&(i.setAudioOption(t)||i.setAudioOption(s)))}onSubtitleTrackSwitch(e,t){const s=cr(t);this.playerQueue.forEach(({hls:i})=>i&&(i.setSubtitleOption(t)||t.id!==-1&&i.setSubtitleOption(s)))}onBufferCodecs(e,t){const s=t.tracks;s&&(this.requiredTracks=s)}onBufferAppended(e,t){this.checkBuffer()}onBufferFlushed(e,t){const s=this.playingItem;if(s&&!this.itemsMatch(s,this.bufferingItem)&&!this.isInterstitial(s)){const i=this.timelinePos;this.bufferedPos=i,this.checkBuffer()}}onBufferedToEnd(e){if(!this.schedule)return;const t=this.schedule.events;if(this.bufferedPos<Number.MAX_VALUE&&t){for(let i=0;i<t.length;i++){const r=t[i];if(r.cue.post){var s;const n=this.schedule.findEventIndex(r.identifier),o=(s=this.schedule.items)==null?void 0:s[n];this.isInterstitial(o)&&this.eventItemsMatch(o,this.bufferingItem)&&this.bufferedToItem(o,0);break}}this.bufferedPos=Number.MAX_VALUE}}onMediaEnded(e){const t=this.playingItem;if(!this.playingLastItem&&t){const s=this.findItemIndex(t);this.setSchedulePosition(s+1)}else this.shouldPlay=!1}updateItem(e,t){var s;const i=(s=this.schedule)==null?void 0:s.items;if(e&&i){const r=this.findItemIndex(e,t);return i[r]||null}return null}trimInPlace(e,t){if(this.isInterstitial(e)&&e.event.appendInPlace&&t.end-e.end>.25){e.event.assetList.forEach((r,n)=>{e.event.isAssetPastPlayoutLimit(n)&&this.clearAssetPlayer(r.identifier,null)});const s=e.end+.25,i=X.bufferInfo(this.primaryMedia,s,0);(i.end>s||(i.nextStart||0)>s)&&(this.log("trim buffered interstitial ".concat(Oe(e)," (was ").concat(Oe(t),")")),this.attachPrimary(s,null,!0),this.flushFrontBuffer(s))}}itemsMatch(e,t){return!!t&&(e===t||e.event&&t.event&&this.eventItemsMatch(e,t)||!e.event&&!t.event&&this.findItemIndex(e)===this.findItemIndex(t))}eventItemsMatch(e,t){var s;return!!t&&(e===t||e.event.identifier===((s=t.event)==null?void 0:s.identifier))}findItemIndex(e,t){return e&&this.schedule?this.schedule.findItemIndex(e,t):-1}updateSchedule(e=!1){var t;const s=this.mediaSelection;s&&((t=this.schedule)==null||t.updateSchedule(s,[],e))}checkBuffer(e){var t;const s=(t=this.schedule)==null?void 0:t.items;if(!s)return;const i=X.bufferInfo(this.primaryMedia,this.timelinePos,0);e&&(this.bufferedPos=this.timelinePos),e||(e=i.len<1),this.updateBufferedPos(i.end,s,e)}updateBufferedPos(e,t,s){const i=this.schedule,r=this.bufferingItem;if(this.bufferedPos>e||!i)return;if(t.length===1&&this.itemsMatch(t[0],r)){this.bufferedPos=e;return}const n=this.playingItem,o=this.findItemIndex(n);let d=i.findItemIndexAtTime(e);if(this.bufferedPos<e){var l;const c=this.findItemIndex(r),u=Math.min(c+1,t.length-1),h=t[u];if((d===-1&&r&&e>=r.end||(l=h.event)!=null&&l.appendInPlace&&e+.01>=h.start)&&(d=u),this.isInterstitial(r)){const f=r.event;if(u-o>1&&f.appendInPlace===!1||f.assetList.length===0&&f.assetListLoader)return}if(this.bufferedPos=e,d>c&&d>o)this.bufferedToItem(h);else{const f=this.primaryDetails;this.primaryLive&&f&&e>f.edge-f.targetduration&&h.start<f.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(h)&&this.preloadAssets(h.event,0)}}else s&&n&&!this.itemsMatch(n,r)&&(d===o?this.bufferedToItem(n):d===o+1&&this.bufferedToItem(t[d]))}assetsBuffered(e,t){return e.event.assetList.length===0?!1:!e.event.assetList.some(i=>{const r=this.getAssetPlayer(i.identifier);return!(r!=null&&r.bufferedInPlaceToEnd(t))})}setBufferingItem(e){const t=this.bufferingItem,s=this.schedule;if(!this.itemsMatch(e,t)&&s){const{items:i,events:r}=s;if(!i||!r)return t;const n=this.isInterstitial(e),o=this.getBufferingPlayer();this.bufferingItem=e,this.bufferedPos=Math.max(e.start,Math.min(e.end,this.timelinePos));const d=o?o.remaining:t?t.end-this.timelinePos:0;if(this.log("INTERSTITIALS_BUFFERED_TO_BOUNDARY ".concat(Oe(e))+(t?" (".concat(d.toFixed(2)," remaining)"):"")),!this.playbackDisabled)if(n){const l=s.findAssetIndex(e.event,this.bufferedPos);e.event.assetList.forEach((c,u)=>{const h=this.getAssetPlayer(c.identifier);h&&(u===l&&h.loadSource(),h.resumeBuffering())})}else this.hls.resumeBuffering(),this.playerQueue.forEach(l=>l.pauseBuffering());this.hls.trigger(y.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:r.slice(0),schedule:i.slice(0),bufferingIndex:this.findItemIndex(e),playingIndex:this.findItemIndex(this.playingItem)})}else this.bufferingItem!==e&&(this.bufferingItem=e);return t}bufferedToItem(e,t=0){const s=this.setBufferingItem(e);if(!this.playbackDisabled){if(this.isInterstitial(e))this.bufferedToEvent(e,t);else if(s!==null){this.bufferingAsset=null;const i=this.detachedData;i?i.mediaSource?this.attachPrimary(e.start,e,!0):this.preloadPrimary(e):this.preloadPrimary(e)}}}preloadPrimary(e){const t=this.findItemIndex(e),s=this.getPrimaryResumption(e,t);this.startLoadingPrimaryAt(s)}bufferedToEvent(e,t){const s=e.event,i=s.assetList.length===0&&!s.assetListLoader,r=s.cue.once;if(i||!r){const n=this.preloadAssets(s,t);if(n!=null&&n.interstitial.appendInPlace){const o=this.primaryMedia;o&&this.bufferAssetPlayer(n,o)}}}preloadAssets(e,t){const s=e.assetUrl,i=e.assetList.length,r=i===0&&!e.assetListLoader,n=e.cue.once;if(r){const d=e.timelineStart;if(e.appendInPlace){var o;const h=this.playingItem;!this.isInterstitial(h)&&(h==null||(o=h.nextEvent)==null?void 0:o.identifier)===e.identifier&&this.flushFrontBuffer(d+.25)}let l,c=0;if(!this.playingItem&&this.primaryLive&&(c=this.hls.startPosition,c===-1&&(c=this.hls.liveSyncPosition||0)),c&&!(e.cue.pre||e.cue.post)){const h=c-d;h>0&&(l=Math.round(h*1e3)/1e3)}if(this.log("Load interstitial asset ".concat(t+1,"/").concat(s?1:i," ").concat(e).concat(l?" live-start: ".concat(c," start-offset: ").concat(l):"")),s)return this.createAsset(e,0,0,d,e.duration,s);const u=this.assetListLoader.loadAssetList(e,l);u&&(e.assetListLoader=u)}else if(!n&&i){for(let l=t;l<i;l++){const c=e.assetList[l],u=this.getAssetPlayerQueueIndex(c.identifier);(u===-1||this.playerQueue[u].destroyed)&&!c.error&&this.createAssetPlayer(e,c,l)}const d=e.assetList[t];if(d){const l=this.getAssetPlayer(d.identifier);return l&&l.loadSource(),l}}return null}flushFrontBuffer(e){const t=this.requiredTracks;if(!t)return;this.log("Removing front buffer starting at ".concat(e)),Object.keys(t).forEach(i=>{this.hls.trigger(y.BUFFER_FLUSHING,{startOffset:e,endOffset:1/0,type:i})})}getAssetPlayerQueueIndex(e){const t=this.playerQueue;for(let s=0;s<t.length;s++)if(e===t[s].assetId)return s;return-1}getAssetPlayer(e){const t=this.getAssetPlayerQueueIndex(e);return this.playerQueue[t]||null}getBufferingPlayer(){const{playerQueue:e,primaryMedia:t}=this;if(t){for(let s=0;s<e.length;s++)if(e[s].media===t)return e[s]}return null}createAsset(e,t,s,i,r,n){const o={parentIdentifier:e.identifier,identifier:Zc(e,n,t),duration:r,startOffset:s,timelineStart:i,uri:n};return this.createAssetPlayer(e,o,t)}createAssetPlayer(e,t,s){const i=this.hls,r=i.userConfig;let n=r.videoPreference;const o=i.loadLevelObj||i.levels[i.currentLevel];(n||o)&&(n=ie({},n),o.videoCodec&&(n.videoCodec=o.videoCodec),o.videoRange&&(n.allowedVideoRanges=[o.videoRange]));const d=i.audioTracks[i.audioTrack],l=i.subtitleTracks[i.subtitleTrack];let c=0;if(this.primaryLive||e.appendInPlace){const S=this.timelinePos-t.timelineStart;if(S>1){const x=t.duration;x&&S<x&&(c=S)}}const u=t.identifier,h=te(te({},r),{},{maxMaxBufferLength:Math.min(180,i.config.maxMaxBufferLength),autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:i.sessionId,assetPlayerId:u,abrEwmaDefaultEstimate:i.bandwidthEstimate,interstitialsController:void 0,startPosition:c,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:n,audioPreference:d||r.audioPreference,subtitlePreference:l||r.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(h.timelineOffset=t.timelineStart));const f=h.cmcd;f!=null&&f.sessionId&&f.contentId&&(h.cmcd=ie({},f,{contentId:Pt(t.uri)})),this.getAssetPlayer(u)&&this.warn("Duplicate date range identifier ".concat(e," and asset ").concat(u));const g=new tu(this.HlsPlayerClass,h,e,t);this.playerQueue.push(g),e.assetList[s]=t;let m=!0;const p=S=>{if(S.live){var x;const I=new Error("Interstitials MUST be VOD assets ".concat(e)),R={fatal:!0,type:W.OTHER_ERROR,details:_.INTERSTITIAL_ASSET_ITEM_ERROR,error:I},L=((x=this.schedule)==null?void 0:x.findEventIndex(e.identifier))||-1;this.handleAssetItemError(R,e,L,s,I.message);return}const b=S.edge-S.fragmentStart,A=t.duration;(m||A===null||b>A)&&(m=!1,this.log('Interstitial asset "'.concat(u,'" duration change ').concat(A," > ").concat(b)),t.duration=b,this.updateSchedule())};g.on(y.LEVEL_UPDATED,(S,{details:x})=>p(x)),g.on(y.LEVEL_PTS_UPDATED,(S,{details:x})=>p(x)),g.on(y.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());const v=(S,x)=>{const b=this.getAssetPlayer(u);if(b&&x.tracks){b.off(y.BUFFER_CODECS,v),b.tracks=x.tracks;const A=this.primaryMedia;this.bufferingAsset===b.assetItem&&A&&!b.media&&this.bufferAssetPlayer(b,A)}};g.on(y.BUFFER_CODECS,v);const E=()=>{var S;const x=this.getAssetPlayer(u);if(this.log("buffered to end of asset ".concat(x)),!x||!this.schedule)return;const b=this.schedule.findEventIndex(e.identifier),A=(S=this.schedule.items)==null?void 0:S[b];this.isInterstitial(A)&&this.advanceAssetBuffering(A,t)};g.on(y.BUFFERED_TO_END,E);const T=S=>()=>{if(!this.getAssetPlayer(u)||!this.schedule)return;this.shouldPlay=!0;const b=this.schedule.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,b,S)};return g.once(y.MEDIA_ENDED,T(s)),g.once(y.PLAYOUT_LIMIT_REACHED,T(1/0)),g.on(y.ERROR,(S,x)=>{if(!this.schedule)return;const b=this.getAssetPlayer(u);if(x.details===_.BUFFER_STALLED_ERROR){if(b!=null&&b.appendInPlace){this.handleInPlaceStall(e);return}this.onTimeupdate(),this.checkBuffer(!0);return}this.handleAssetItemError(x,e,this.schedule.findEventIndex(e.identifier),s,"Asset player error ".concat(x.error," ").concat(e))}),g.on(y.DESTROYING,()=>{if(!this.getAssetPlayer(u)||!this.schedule)return;const x=new Error("Asset player destroyed unexpectedly ".concat(u)),b={fatal:!0,type:W.OTHER_ERROR,details:_.INTERSTITIAL_ASSET_ITEM_ERROR,error:x};this.handleAssetItemError(b,e,this.schedule.findEventIndex(e.identifier),s,x.message)}),this.log("INTERSTITIAL_ASSET_PLAYER_CREATED ".concat(mt(t))),this.hls.trigger(y.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:s,event:e,player:g}),g}clearInterstitial(e,t){e.assetList.forEach(s=>{this.clearAssetPlayer(s.identifier,t)}),e.reset()}resetAssetPlayer(e){const t=this.getAssetPlayerQueueIndex(e);if(t!==-1){this.log('reset asset player "'.concat(e,'" after error'));const s=this.playerQueue[t];this.transferMediaFromPlayer(s,null),s.resetDetails()}}clearAssetPlayer(e,t){const s=this.getAssetPlayerQueueIndex(e);if(s!==-1){const i=this.playerQueue[s];this.log("clear ".concat(i," toSegment: ").concat(t&&Oe(t))),this.transferMediaFromPlayer(i,t),this.playerQueue.splice(s,1),i.destroy()}}emptyPlayerQueue(){let e;for(;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[]}startAssetPlayer(e,t,s,i,r){const{interstitial:n,assetItem:o,assetId:d}=e,l=n.assetList.length,c=this.playingAsset;this.endedAsset=null,this.playingAsset=o,(!c||c.identifier!==d)&&(c&&(this.clearAssetPlayer(c.identifier,s[i]),delete c.error),this.log("INTERSTITIAL_ASSET_STARTED ".concat(t+1,"/").concat(l," ").concat(mt(o))),this.hls.trigger(y.INTERSTITIAL_ASSET_STARTED,{asset:o,assetListIndex:t,event:n,schedule:s.slice(0),scheduleIndex:i,player:e})),this.bufferAssetPlayer(e,r)}bufferAssetPlayer(e,t){var s,i;if(!this.schedule)return;const{interstitial:r,assetItem:n}=e,o=this.schedule.findEventIndex(r.identifier),d=(s=this.schedule.items)==null?void 0:s[o];if(!d)return;e.loadSource(),this.setBufferingItem(d),this.bufferingAsset=n;const l=this.getBufferingPlayer();if(l===e)return;const c=r.appendInPlace;if(c&&(l==null?void 0:l.interstitial.appendInPlace)===!1)return;const u=(l==null?void 0:l.tracks)||((i=this.detachedData)==null?void 0:i.tracks)||this.requiredTracks;if(c&&n!==this.playingAsset){if(!e.tracks){this.log("Waiting for track info before buffering ".concat(e));return}if(u&&!yn(u,e.tracks)){const h=new Error("Asset ".concat(mt(n)," SourceBuffer tracks ('").concat(Object.keys(e.tracks),"') are not compatible with primary content tracks ('").concat(Object.keys(u),"')")),f={fatal:!0,type:W.OTHER_ERROR,details:_.INTERSTITIAL_ASSET_ITEM_ERROR,error:h},g=r.findAssetIndex(n);this.handleAssetItemError(f,r,o,g,h.message);return}}this.transferMediaTo(e,t)}handleInPlaceStall(e){const t=this.schedule,s=this.primaryMedia;if(!t||!s)return;const i=s.currentTime,r=t.findAssetIndex(e,i),n=e.assetList[r];if(n){const o=this.getAssetPlayer(n.identifier);if(o){const d=o.currentTime||i-n.timelineStart,l=o.duration-d;if(this.warn("Stalled at ".concat(d," of ").concat(d+l," in ").concat(o," ").concat(e," (media.currentTime: ").concat(i,")")),d&&(l/s.playbackRate<.5||o.bufferedInPlaceToEnd(s))&&o.hls){const c=t.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,c,r)}}}}advanceInPlace(e){const t=this.primaryMedia;t&&t.currentTime<e&&(t.currentTime=e)}handleAssetItemError(e,t,s,i,r){if(e.details===_.BUFFER_STALLED_ERROR)return;const n=t.assetList[i]||null;if(this.warn("INTERSTITIAL_ASSET_ERROR ".concat(n&&mt(n)," ").concat(e.error)),!this.schedule)return;const o=(n==null?void 0:n.identifier)||"",d=this.getAssetPlayerQueueIndex(o),l=this.playerQueue[d]||null,c=this.schedule.items,u=ie({},e,{fatal:!1,errorAction:yt(!0),asset:n,assetListIndex:i,event:t,schedule:c,scheduleIndex:s,player:l});if(this.hls.trigger(y.INTERSTITIAL_ASSET_ERROR,u),!e.fatal)return;const h=this.playingAsset,f=this.bufferingAsset,g=new Error(r);if(n&&(this.clearAssetPlayer(o,null),n.error=g),!t.assetList.some(m=>!m.error))t.error=g;else for(let m=i;m<t.assetList.length;m++)this.resetAssetPlayer(t.assetList[m].identifier);this.updateSchedule(!0),t.error?this.primaryFallback(t):h&&h.identifier===o?this.advanceAfterAssetEnded(t,s,i):f&&f.identifier===o&&this.isInterstitial(this.bufferingItem)&&this.advanceAssetBuffering(this.bufferingItem,f)}primaryFallback(e){const t=e.timelineStart,s=this.effectivePlayingItem;if(s){this.log('Fallback to primary from event "'.concat(e.identifier,'" start: ').concat(t," pos: ").concat(this.timelinePos," playing: ").concat(Oe(s)," error: ").concat(e.error));let i=this.timelinePos;i===-1&&(i=this.hls.startPosition);const r=this.updateItem(s,i);if(this.itemsMatch(s,r)&&this.clearInterstitial(e,null),e.appendInPlace&&(this.attachPrimary(t,null),this.flushFrontBuffer(t)),!this.schedule)return;const n=this.schedule.findItemIndexAtTime(i);this.setSchedulePosition(n)}else this.checkStart()}onAssetListLoaded(e,t){var s,i;const r=t.event,n=r.identifier,o=t.assetListResponse.ASSETS;if(!((s=this.schedule)!=null&&s.hasEvent(n)))return;const d=r.timelineStart,l=r.duration;let c=0;o.forEach((m,p)=>{const v=parseFloat(m.DURATION);this.createAsset(r,p,c,d+c,v,m.URI),c+=v}),r.duration=c,this.log("Loaded asset-list with duration: ".concat(c," (was: ").concat(l,") ").concat(r));const u=this.waitingItem,h=(u==null?void 0:u.event.identifier)===n;this.updateSchedule();const f=(i=this.bufferingItem)==null?void 0:i.event;if(h){var g;const m=this.schedule.findEventIndex(n),p=(g=this.schedule.items)==null?void 0:g[m];if(p){if(!this.playingItem&&this.timelinePos>p.end&&this.schedule.findItemIndexAtTime(this.timelinePos)!==m){r.error=new Error("Interstitial no longer within playback range ".concat(this.timelinePos," ").concat(r)),this.updateSchedule(!0),this.primaryFallback(r);return}this.setBufferingItem(p)}this.setSchedulePosition(m)}else if((f==null?void 0:f.identifier)===n){const m=r.assetList[0];if(m){const p=this.getAssetPlayer(m.identifier);if(f.appendInPlace){const v=this.primaryMedia;p&&v&&this.bufferAssetPlayer(p,v)}else p&&p.loadSource()}}}onError(e,t){if(this.schedule)switch(t.details){case _.ASSET_LIST_PARSING_ERROR:case _.ASSET_LIST_LOAD_ERROR:case _.ASSET_LIST_LOAD_TIMEOUT:{const s=t.interstitial;s&&(this.updateSchedule(!0),this.primaryFallback(s));break}case _.BUFFER_STALLED_ERROR:{const s=this.endedItem||this.waitingItem||this.playingItem;if(this.isInterstitial(s)&&s.event.appendInPlace){this.handleInPlaceStall(s.event);return}this.log("Primary player stall @".concat(this.timelinePos," bufferedPos: ").concat(this.bufferedPos)),this.onTimeupdate(),this.checkBuffer(!0);break}}}}const en=500;class nu extends _i{constructor(e,t,s){super(e,t,s,"subtitle-stream-controller",H.SUBTITLE),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(y.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(y.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(y.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(y.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(y.BUFFER_FLUSHING,this.onBufferFlushing,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(y.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(y.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(y.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(y.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(y.BUFFER_FLUSHING,this.onBufferFlushing,this)}startLoad(e,t){this.stopLoad(),this.state=P.IDLE,this.setInterval(en),this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}onManifestLoading(){super.onManifestLoading(),this.mainDetails=null}onMediaDetaching(e,t){this.tracksBuffered=[],super.onMediaDetaching(e,t)}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){const{frag:s,success:i}=t;if(this.fragContextChanged(s)||(he(s)&&(this.fragPrevious=s),this.state=P.IDLE),!i)return;const r=this.tracksBuffered[this.currentTrackId];if(!r)return;let n;const o=s.start;for(let l=0;l<r.length;l++)if(o>=r[l].start&&o<=r[l].end){n=r[l];break}const d=s.start+s.duration;n?n.end=d:(n={start:o,end:d},r.push(n)),this.fragmentTracker.fragBuffered(s),this.fragBufferedComplete(s,null),this.media&&this.tick()}onBufferFlushing(e,t){const{startOffset:s,endOffset:i}=t;if(s===0&&i!==Number.POSITIVE_INFINITY){const r=i-1;if(r<=0)return;t.endOffsetSubtitles=Math.max(0,r),this.tracksBuffered.forEach(n=>{for(let o=0;o<n.length;){if(n[o].end<=r){n.shift();continue}else if(n[o].start<r)n[o].start=r;else break;o++}}),this.fragmentTracker.removeFragmentsInRange(s,r,H.SUBTITLE)}}onError(e,t){const s=t.frag;(s==null?void 0:s.type)===H.SUBTITLE&&(t.details===_.FRAG_GAP&&this.fragmentTracker.fragBuffered(s,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==P.STOPPED&&(this.state=P.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(this.levels&&ya(this.levels,t)){this.levels=t.map(s=>new Mt(s));return}this.tracksBuffered=[],this.levels=t.map(s=>{const i=new Mt(s);return this.tracksBuffered[i.id]=[],i}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,H.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(e,t){var s;if(this.currentTrackId=t.id,!((s=this.levels)!=null&&s.length)||this.currentTrackId===-1){this.clearInterval();return}const i=this.levels[this.currentTrackId];i!=null&&i.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,i&&this.state!==P.STOPPED&&this.setInterval(en)}onSubtitleTrackLoaded(e,t){var s;const{currentTrackId:i,levels:r}=this,{details:n,id:o}=t;if(!r){this.warn("Subtitle tracks were reset while loading level ".concat(o));return}const d=r[o];if(o>=r.length||!d)return;this.log("Subtitle track ".concat(o," loaded [").concat(n.startSN,",").concat(n.endSN,"]").concat(n.lastPartSn?"[part-".concat(n.lastPartSn,"-").concat(n.lastPartIndex,"]"):"",",duration:").concat(n.totalduration)),this.mediaBuffer=this.mediaBufferTimeRanges;let l=0;if(n.live||(s=d.details)!=null&&s.live){if(n.deltaUpdateFailed)return;const u=this.mainDetails;if(!u){this.startFragRequested=!1;return}const h=u.fragments[0];if(!d.details)n.hasProgramDateTime&&u.hasProgramDateTime?(Ss(n,u),l=n.fragmentStart):h&&(l=h.start,oi(n,l));else{var c;l=this.alignPlaylists(n,d.details,(c=this.levelLastLoaded)==null?void 0:c.details),l===0&&h&&(l=h.start,oi(n,l))}u&&!this.startFragRequested&&this.setStartPosition(u,l)}d.details=n,this.levelLastLoaded=d,o===i&&(this.hls.trigger(y.SUBTITLE_TRACK_UPDATED,{details:n,id:o,groupId:t.groupId}),this.tick(),n.live&&!this.fragCurrent&&this.media&&this.state===P.IDLE&&(lt(null,n.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),d.details=void 0)))}_handleFragmentLoadComplete(e){const{frag:t,payload:s}=e,i=t.decryptdata,r=this.hls;if(!this.fragContextChanged(t)&&s&&s.byteLength>0&&i!=null&&i.key&&i.iv&&vt(i.method)){const n=performance.now();this.decrypter.decrypt(new Uint8Array(s),i.key.buffer,i.iv.buffer,Ri(i.method)).catch(o=>{throw r.trigger(y.ERROR,{type:W.MEDIA_ERROR,details:_.FRAG_DECRYPT_ERROR,fatal:!1,error:o,reason:o.message,frag:t}),o}).then(o=>{const d=performance.now();r.trigger(y.FRAG_DECRYPTED,{frag:t,payload:o,stats:{tstart:n,tdecrypt:d}})}).catch(o=>{this.warn("".concat(o.name,": ").concat(o.message)),this.state=P.IDLE})}}doTick(){if(!this.media){this.state=P.IDLE;return}if(this.state===P.IDLE){const{currentTrackId:e,levels:t}=this,s=t==null?void 0:t[e];if(!s||!t.length||!s.details||this.waitForLive(s))return;const{config:i}=this,r=this.getLoadPosition(),n=X.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],r,i.maxBufferHole),{end:o,len:d}=n,l=s.details,c=this.hls.maxBufferLength+l.levelTargetDuration;if(d>c)return;const u=l.fragments,h=u.length,f=l.edge;let g=null;const m=this.fragPrevious;if(o<f){const E=i.maxFragLookUpTolerance,T=o>f-E?0:E;g=lt(m,u,Math.max(u[0].start,o),T),!g&&m&&m.start<u[0].start&&(g=u[0])}else g=u[h-1];if(g=this.filterReplacedPrimary(g,s.details),!g)return;const p=g.sn-l.startSN,v=u[p-1];if(v&&v.cc===g.cc&&this.fragmentTracker.getState(v)===ge.NOT_LOADED&&(g=v),this.fragmentTracker.getState(g)===ge.NOT_LOADED){const E=this.mapToInitFragWhenRequired(g);E&&this.loadFragment(E,s,o)}}}loadFragment(e,t,s){he(e)?super.loadFragment(e,t,s):this._loadInitSegment(e,t)}get mediaBufferTimeRanges(){return new au(this.tracksBuffered[this.currentTrackId]||[])}}class au{constructor(e){this.buffered=void 0;const t=(s,i,r)=>{if(i=i>>>0,i>r-1)throw new DOMException("Failed to execute '".concat(s,"' on 'TimeRanges': The index provided (").concat(i,") is greater than the maximum bound (").concat(r,")"));return e[i][s]};this.buffered={get length(){return e.length},end(s){return t("end",s,e.length)},start(s){return t("start",s,e.length)}}}}const ou={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},wa=a=>String.fromCharCode(ou[a]||a),Me=15,Ye=100,lu={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},du={17:2,18:4,21:6,22:8,23:10,19:13,20:15},cu={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},uu={25:2,26:4,29:6,30:8,31:10,27:13,28:15},hu=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class fu{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const s=typeof t=="function"?t():t;se.log("".concat(this.time," [").concat(e,"] ").concat(s))}}}const rt=function(e){const t=[];for(let s=0;s<e.length;s++)t.push(e[s].toString(16));return t};class Oa{constructor(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){const t=["foreground","underline","italics","background","flash"];for(let s=0;s<t.length;s++){const i=t[s];e.hasOwnProperty(i)&&(this[i]=e[i])}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class gu{constructor(){this.uchar=" ",this.penState=new Oa}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return this.uchar===" "&&this.penState.isDefault()}}class mu{constructor(e){this.chars=[],this.pos=0,this.currPenState=new Oa,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<Ye;t++)this.chars.push(new gu);this.logger=e}equals(e){for(let t=0;t<Ye;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<Ye;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<Ye;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>Ye&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Ye)}moveCursor(e){const t=this.pos+e;if(e>1)for(let s=this.pos+1;s<t+1;s++)this.chars[s].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();const t=wa(e);if(this.pos>=Ye){this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1)}clearFromPos(e){let t;for(t=e;t<Ye;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const e=[];let t=!0;for(let s=0;s<Ye;s++){const i=this.chars[s].uchar;i!==" "&&(t=!1),e.push(i)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}class Hs{constructor(e){this.rows=[],this.currRow=Me-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<Me;t++)this.rows.push(new mu(e));this.logger=e}reset(){for(let e=0;e<Me;e++)this.rows[e].clear();this.currRow=Me-1}equals(e){let t=!0;for(let s=0;s<Me;s++)if(!this.rows[s].equals(e.rows[s])){t=!1;break}return t}copy(e){for(let t=0;t<Me;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<Me;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+ne(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let o=0;o<Me;o++)this.rows[o].clear();const r=this.currRow+1-this.nrRollUpRows,n=this.lastOutputScreen;if(n){const o=n.rows[r].cueStartTime,d=this.logger.time;if(o!==null&&d!==null&&o<d)for(let l=0;l<this.nrRollUpRows;l++)this.rows[t-this.nrRollUpRows+l+1].copy(n.rows[r+l])}}this.currRow=t;const s=this.rows[this.currRow];if(e.indent!==null){const r=e.indent,n=Math.max(r-1,0);s.setCursor(e.indent),e.color=s.chars[n].penState.foreground}const i={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(i)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+ne(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,()=>this.getDisplayText());const e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;const t=[];let s="",i=-1;for(let r=0;r<Me;r++){const n=this.rows[r].getTextString();n&&(i=r+1,e?t.push("Row "+i+": '"+n+"'"):t.push(n.trim()))}return t.length>0&&(e?s="["+t.join(" | ")+"]":s=t.join("\n")),s}getTextAndFormat(){return this.rows}}class tn{constructor(e,t,s){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new Hs(s),this.nonDisplayedMemory=new Hs(s),this.lastOutputScreen=new Hs(s),this.currRollUpRow=this.displayedMemory.rows[Me-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=s}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[Me-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let s=0;s<e.length;s++)this.writeScreen.insertChar(e[s]);const t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){const e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){const t={flash:!1};if(t.underline=e%2===1,t.italics=e>=46,t.italics)t.foreground="white";else{const s=Math.floor(e/2)-16,i=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=i[s]}this.logger.log(2,"MIDROW: "+ne(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){const t=this.logger.time;t!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=t:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t),this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}class sn{constructor(e,t,s){this.channels=void 0,this.currentChannel=0,this.cmdHistory=yu(),this.logger=void 0;const i=this.logger=new fu;this.channels=[null,new tn(e,t,i),new tn(e+1,s,i)]}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){this.logger.time=e;for(let s=0;s<t.length;s+=2){const i=t[s]&127,r=t[s+1]&127;let n=!1,o=null;if(i===0&&r===0)continue;this.logger.log(3,()=>"["+rt([t[s],t[s+1]])+"] -> ("+rt([i,r])+")");const d=this.cmdHistory;if(i>=16&&i<=31){if(pu(i,r,d)){es(null,null,d),this.logger.log(3,()=>"Repeated command ("+rt([i,r])+") is dropped");continue}es(i,r,this.cmdHistory),n=this.parseCmd(i,r),n||(n=this.parseMidrow(i,r)),n||(n=this.parsePAC(i,r)),n||(n=this.parseBackgroundAttributes(i,r))}else es(null,null,d);if(!n&&(o=this.parseChars(i,r),o)){const c=this.currentChannel;c&&c>0?this.channels[c].insertChars(o):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!n&&!o&&this.logger.log(2,()=>"Couldn't parse cleaned data "+rt([i,r])+" orig: "+rt([t[s],t[s+1]]))}}parseCmd(e,t){const s=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47,i=(e===23||e===31)&&t>=33&&t<=35;if(!(s||i))return!1;const r=e===20||e===21||e===23?1:2,n=this.channels[r];return e===20||e===21||e===28||e===29?t===32?n.ccRCL():t===33?n.ccBS():t===34?n.ccAOF():t===35?n.ccAON():t===36?n.ccDER():t===37?n.ccRU(2):t===38?n.ccRU(3):t===39?n.ccRU(4):t===40?n.ccFON():t===41?n.ccRDC():t===42?n.ccTR():t===43?n.ccRTD():t===44?n.ccEDM():t===45?n.ccCR():t===46?n.ccENM():t===47&&n.ccEOC():n.ccTO(t-32),this.currentChannel=r,!0}parseMidrow(e,t){let s=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===17?s=1:s=2,s!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const i=this.channels[s];return i?(i.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+rt([e,t])+")"),!0):!1}return!1}parsePAC(e,t){let s;const i=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,r=(e===16||e===24)&&t>=64&&t<=95;if(!(i||r))return!1;const n=e<=23?1:2;t>=64&&t<=95?s=n===1?lu[e]:cu[e]:s=n===1?du[e]:uu[e];const o=this.channels[n];return o?(o.setPAC(this.interpretPAC(s,t)),this.currentChannel=n,!0):!1}interpretPAC(e,t){let s;const i={color:null,italics:!1,indent:null,underline:!1,row:e};return t>95?s=t-96:s=t-64,i.underline=(s&1)===1,s<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(s/2)]:s<=15?(i.italics=!0,i.color="white"):i.indent=Math.floor((s-16)/2)*4,i}parseChars(e,t){let s,i=null,r=null;if(e>=25?(s=2,r=e-8):(s=1,r=e),r>=17&&r<=19){let n;r===17?n=t+80:r===18?n=t+112:n=t+144,this.logger.log(2,()=>"Special char '"+wa(n)+"' in channel "+s),i=[n]}else e>=32&&e<=127&&(i=t===0?[e]:[e,t]);return i&&this.logger.log(3,()=>"Char codes = "+rt(i).join(",")),i}parseBackgroundAttributes(e,t){const s=(e===16||e===24)&&t>=32&&t<=47,i=(e===23||e===31)&&t>=45&&t<=47;if(!(s||i))return!1;let r;const n={};e===16||e===24?(r=Math.floor((t-32)/2),n.background=hu[r],t%2===1&&(n.background=n.background+"_semi")):t===45?n.background="transparent":(n.foreground="black",t===47&&(n.underline=!0));const o=e<=23?1:2;return this.channels[o].setBkgData(n),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}es(null,null,this.cmdHistory)}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){const s=this.channels[t];s&&s.cueSplitAtTime(e)}}}function es(a,e,t){t.a=a,t.b=e}function pu(a,e,t){return t.a===a&&t.b===e}function yu(){return{a:null,b:null}}var Gi=(function(){if(Ts!=null&&Ts.VTTCue)return self.VTTCue;const a=["","lr","rl"],e=["start","middle","end","left","right"];function t(o,d){if(typeof d!="string"||!Array.isArray(o))return!1;const l=d.toLowerCase();return~o.indexOf(l)?l:!1}function s(o){return t(a,o)}function i(o){return t(e,o)}function r(o,...d){let l=1;for(;l<arguments.length;l++){const c=arguments[l];for(const u in c)o[u]=c[u]}return o}function n(o,d,l){const c=this,u={enumerable:!0};c.hasBeenReset=!1;let h="",f=!1,g=o,m=d,p=l,v=null,E="",T=!0,S="auto",x="start",b=50,A="middle",I=50,R="middle";Object.defineProperty(c,"id",r({},u,{get:function(){return h},set:function(L){h=""+L}})),Object.defineProperty(c,"pauseOnExit",r({},u,{get:function(){return f},set:function(L){f=!!L}})),Object.defineProperty(c,"startTime",r({},u,{get:function(){return g},set:function(L){if(typeof L!="number")throw new TypeError("Start time must be set to a number.");g=L,this.hasBeenReset=!0}})),Object.defineProperty(c,"endTime",r({},u,{get:function(){return m},set:function(L){if(typeof L!="number")throw new TypeError("End time must be set to a number.");m=L,this.hasBeenReset=!0}})),Object.defineProperty(c,"text",r({},u,{get:function(){return p},set:function(L){p=""+L,this.hasBeenReset=!0}})),Object.defineProperty(c,"region",r({},u,{get:function(){return v},set:function(L){v=L,this.hasBeenReset=!0}})),Object.defineProperty(c,"vertical",r({},u,{get:function(){return E},set:function(L){const w=s(L);if(w===!1)throw new SyntaxError("An invalid or illegal string was specified.");E=w,this.hasBeenReset=!0}})),Object.defineProperty(c,"snapToLines",r({},u,{get:function(){return T},set:function(L){T=!!L,this.hasBeenReset=!0}})),Object.defineProperty(c,"line",r({},u,{get:function(){return S},set:function(L){if(typeof L!="number"&&L!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");S=L,this.hasBeenReset=!0}})),Object.defineProperty(c,"lineAlign",r({},u,{get:function(){return x},set:function(L){const w=i(L);if(!w)throw new SyntaxError("An invalid or illegal string was specified.");x=w,this.hasBeenReset=!0}})),Object.defineProperty(c,"position",r({},u,{get:function(){return b},set:function(L){if(L<0||L>100)throw new Error("Position must be between 0 and 100.");b=L,this.hasBeenReset=!0}})),Object.defineProperty(c,"positionAlign",r({},u,{get:function(){return A},set:function(L){const w=i(L);if(!w)throw new SyntaxError("An invalid or illegal string was specified.");A=w,this.hasBeenReset=!0}})),Object.defineProperty(c,"size",r({},u,{get:function(){return I},set:function(L){if(L<0||L>100)throw new Error("Size must be between 0 and 100.");I=L,this.hasBeenReset=!0}})),Object.defineProperty(c,"align",r({},u,{get:function(){return R},set:function(L){const w=i(L);if(!w)throw new SyntaxError("An invalid or illegal string was specified.");R=w,this.hasBeenReset=!0}})),c.displayState=void 0}return n.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},n})();class vu{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function Ma(a){function e(s,i,r,n){return(s|0)*3600+(i|0)*60+(r|0)+parseFloat(n||0)}const t=a.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return t?parseFloat(t[2])>59?e(t[2],t[3],0,t[4]):e(t[1],t[2],t[3],t[4]):null}class Eu{constructor(){this.values=Object.create(null)}set(e,t){!this.get(e)&&t!==""&&(this.values[e]=t)}get(e,t,s){return s?this.has(e)?this.values[e]:t[s]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,s){for(let i=0;i<s.length;++i)if(t===s[i]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){const s=parseFloat(t);if(s>=0&&s<=100)return this.set(e,s),!0}return!1}}function Fa(a,e,t,s){const i=s?a.split(s):[a];for(const r in i){if(typeof i[r]!="string")continue;const n=i[r].split(t);if(n.length!==2)continue;const o=n[0],d=n[1];e(o,d)}}const mi=new Gi(0,0,""),ts=mi.align==="middle"?"middle":"center";function Tu(a,e,t){const s=a;function i(){const o=Ma(a);if(o===null)throw new Error("Malformed timestamp: "+s);return a=a.replace(/^[^\sa-zA-Z-]+/,""),o}function r(o,d){const l=new Eu;Fa(o,function(h,f){let g;switch(h){case"region":for(let m=t.length-1;m>=0;m--)if(t[m].id===f){l.set(h,t[m].region);break}break;case"vertical":l.alt(h,f,["rl","lr"]);break;case"line":g=f.split(","),l.integer(h,g[0]),l.percent(h,g[0])&&l.set("snapToLines",!1),l.alt(h,g[0],["auto"]),g.length===2&&l.alt("lineAlign",g[1],["start",ts,"end"]);break;case"position":g=f.split(","),l.percent(h,g[0]),g.length===2&&l.alt("positionAlign",g[1],["start",ts,"end","line-left","line-right","auto"]);break;case"size":l.percent(h,f);break;case"align":l.alt(h,f,["start",ts,"end","left","right"]);break}},/:/,/\s/),d.region=l.get("region",null),d.vertical=l.get("vertical","");let c=l.get("line","auto");c==="auto"&&mi.line===-1&&(c=-1),d.line=c,d.lineAlign=l.get("lineAlign","start"),d.snapToLines=l.get("snapToLines",!0),d.size=l.get("size",100),d.align=l.get("align",ts);let u=l.get("position","auto");u==="auto"&&mi.position===50&&(u=d.align==="start"||d.align==="left"?0:d.align==="end"||d.align==="right"?100:50),d.position=u}function n(){a=a.replace(/^\s+/,"")}if(n(),e.startTime=i(),n(),a.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+s);a=a.slice(3),n(),e.endTime=i(),n(),r(a,e)}function $a(a){return a.replace(/<br(?: \/)?>/gi,"\n")}class Su{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new vu,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){const t=this;e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));function s(){let r=t.buffer,n=0;for(r=$a(r);n<r.length&&r[n]!=="\r"&&r[n]!=="\n";)++n;const o=r.slice(0,n);return r[n]==="\r"&&++n,r[n]==="\n"&&++n,t.buffer=r.slice(n),o}function i(r){Fa(r,function(n,o){},/:/)}try{let r="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;r=s();const o=r.match(/^()?WEBVTT([ \t].*)?$/);if(!(o!=null&&o[0]))throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let n=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(n?n=!1:r=s(),t.state){case"HEADER":/:/.test(r)?i(r):r||(t.state="ID");continue;case"NOTE":r||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(r)){t.state="NOTE";break}if(!r)continue;if(t.cue=new Gi(0,0,""),t.state="CUE",r.indexOf("-->")===-1){t.cue.id=r;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{Tu(r,t.cue,t.regionList)}catch(o){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{const o=r.indexOf("-->")!==-1;if(!r||o&&(n=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(t.cue===null)continue;t.cue.text&&(t.cue.text+="\n"),t.cue.text+=r}continue;case"BADCUE":r||(t.state="ID")}}}catch(r){t.state==="CUETEXT"&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state=t.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this}flush(){const e=this;try{if((e.cue||e.state==="HEADER")&&(e.buffer+="\n\n",e.parse()),e.state==="INITIAL"||e.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}const xu=/\r\n|\n\r|\n|\r/g,Ws=function(e,t,s=0){return e.slice(s,s+t.length)===t},Au=function(e){let t=parseInt(e.slice(-3));const s=parseInt(e.slice(-6,-4)),i=parseInt(e.slice(-9,-7)),r=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!K(t)||!K(s)||!K(i)||!K(r))throw Error("Malformed X-TIMESTAMP-MAP: Local:".concat(e));return t+=1e3*s,t+=60*1e3*i,t+=3600*1e3*r,t};function Ki(a,e,t){return Pt(a.toString())+Pt(e.toString())+Pt(t)}const Lu=function(e,t,s){let i=e[t],r=e[i.prevCC];if(!r||!r.new&&i.new){e.ccOffset=e.presentationOffset=i.start,i.new=!1;return}for(;(n=r)!=null&&n.new;){var n;e.ccOffset+=i.start-r.start,i.new=!1,i=r,r=e[i.prevCC]}e.presentationOffset=s};function Iu(a,e,t,s,i,r,n){const o=new Su,d=De(new Uint8Array(a)).trim().replace(xu,"\n").split("\n"),l=[],c=e?Cd(e.baseTime,e.timescale):0;let u="00:00.000",h=0,f=0,g,m=!0;o.oncue=function(p){const v=t[s];let E=t.ccOffset;const T=(h-c)/9e4;if(v!=null&&v.new&&(f!==void 0?E=t.ccOffset=v.start:Lu(t,s,T)),T){if(!e){g=new Error("Missing initPTS for VTT MPEGTS");return}E=T-t.presentationOffset}const S=p.endTime-p.startTime,x=ke((p.startTime+E-f)*9e4,i*9e4)/9e4;p.startTime=Math.max(x,0),p.endTime=Math.max(x+S,0);const b=p.text.trim();p.text=decodeURIComponent(encodeURIComponent(b)),p.id||(p.id=Ki(p.startTime,p.endTime,b)),p.endTime>0&&l.push(p)},o.onparsingerror=function(p){g=p},o.onflush=function(){if(g){n(g);return}r(l)},d.forEach(p=>{if(m)if(Ws(p,"X-TIMESTAMP-MAP=")){m=!1,p.slice(16).split(",").forEach(v=>{Ws(v,"LOCAL:")?u=v.slice(6):Ws(v,"MPEGTS:")&&(h=parseInt(v.slice(7)))});try{f=Au(u)/1e3}catch(v){g=v}return}else p===""&&(m=!1);o.parse(p+"\n")}),o.flush()}const Ys="stpp.ttml.im1t",Na=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Ba=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,bu={left:"start",center:"center",right:"end",start:"start",end:"end"};function rn(a,e,t,s){const i=Q(new Uint8Array(a),["mdat"]);if(i.length===0){s(new Error("Could not parse IMSC1 mdat"));return}const r=i.map(o=>De(o)),n=kd(e.baseTime,1,e.timescale);try{r.forEach(o=>t(Ru(o,n)))}catch(o){s(o)}}function Ru(a,e){const i=new DOMParser().parseFromString(a,"text/xml").getElementsByTagName("tt")[0];if(!i)throw new Error("Invalid ttml");const r={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},n=Object.keys(r).reduce((u,h)=>(u[h]=i.getAttribute("ttp:".concat(h))||r[h],u),{}),o=i.getAttribute("xml:space")!=="preserve",d=nn(qs(i,"styling","style")),l=nn(qs(i,"layout","region")),c=qs(i,"body","[begin]");return[].map.call(c,u=>{const h=Ua(u,o);if(!h||!u.hasAttribute("begin"))return null;const f=zs(u.getAttribute("begin"),n),g=zs(u.getAttribute("dur"),n);let m=zs(u.getAttribute("end"),n);if(f===null)throw an(u);if(m===null){if(g===null)throw an(u);m=f+g}const p=new Gi(f-e,m-e,h);p.id=Ki(p.startTime,p.endTime,p.text);const v=l[u.getAttribute("region")],E=d[u.getAttribute("style")],T=Du(v,E,d),{textAlign:S}=T;if(S){const x=bu[S];x&&(p.lineAlign=x),p.align=S}return ie(p,T),p}).filter(u=>u!==null)}function qs(a,e,t){const s=a.getElementsByTagName(e)[0];return s?[].slice.call(s.querySelectorAll(t)):[]}function nn(a){return a.reduce((e,t)=>{const s=t.getAttribute("xml:id");return s&&(e[s]=t),e},{})}function Ua(a,e){return[].slice.call(a.childNodes).reduce((t,s,i)=>{var r;return s.nodeName==="br"&&i?t+"\n":(r=s.childNodes)!=null&&r.length?Ua(s,e):e?t+s.textContent.trim().replace(/\s+/g," "):t+s.textContent},"")}function Du(a,e,t){const s="http://www.w3.org/ns/ttml#styling";let i=null;const r=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],n=a!=null&&a.hasAttribute("style")?a.getAttribute("style"):null;return n&&t.hasOwnProperty(n)&&(i=t[n]),r.reduce((o,d)=>{const l=js(e,s,d)||js(a,s,d)||js(i,s,d);return l&&(o[d]=l),o},{})}function js(a,e,t){return a&&a.hasAttributeNS(e,t)?a.getAttributeNS(e,t):null}function an(a){return new Error("Could not parse ttml timestamp ".concat(a))}function zs(a,e){if(!a)return null;let t=Ma(a);return t===null&&(Na.test(a)?t=_u(a,e):Ba.test(a)&&(t=ku(a,e))),t}function _u(a,e){const t=Na.exec(a),s=(t[4]|0)+(t[5]|0)/e.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+s/e.frameRate}function ku(a,e){const t=Ba.exec(a),s=Number(t[1]);switch(t[2]){case"h":return s*3600;case"m":return s*60;case"ms":return s*1e3;case"f":return s/e.frameRate;case"t":return s/e.tickRate}return s}class ss{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,s){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=s,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}class Cu{constructor(e){this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=ln(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},e.on(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(y.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(y.FRAG_LOADING,this.onFragLoading,this),e.on(y.FRAG_LOADED,this.onFragLoaded,this),e.on(y.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(y.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(y.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(y.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(y.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(y.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(y.FRAG_LOADING,this.onFragLoading,this),e.off(y.FRAG_LOADED,this.onFragLoaded,this),e.off(y.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(y.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(y.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(y.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(y.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){const e=new ss(this,"textTrack1"),t=new ss(this,"textTrack2"),s=new ss(this,"textTrack3"),i=new ss(this,"textTrack4");this.cea608Parser1=new sn(1,e,t),this.cea608Parser2=new sn(3,s,i)}addCues(e,t,s,i,r){let n=!1;for(let o=r.length;o--;){const d=r[o],l=Pu(d[0],d[1],t,s);if(l>=0&&(d[0]=Math.min(d[0],t),d[1]=Math.max(d[1],s),n=!0,l/(s-t)>.5))return}if(n||r.push([t,s]),this.config.renderTextTracksNatively){const o=this.captionsTracks[e];this.Cues.newCue(o,t,s,i)}else{const o=this.Cues.newCue(null,t,s,i);this.hls.trigger(y.CUES_PARSED,{type:"captions",cues:o,track:e})}}onInitPtsFound(e,{frag:t,id:s,initPTS:i,timescale:r,trackId:n}){const{unparsedVttFrags:o}=this;s===H.MAIN&&(this.initPTS[t.cc]={baseTime:i,timescale:r,trackId:n}),o.length&&(this.unparsedVttFrags=[],o.forEach(d=>{this.initPTS[d.frag.cc]?this.onFragLoaded(y.FRAG_LOADED,d):this.hls.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:d.frag,error:new Error("Subtitle discontinuity domain does not match main")})}))}getExistingTrack(e,t){const{media:s}=this;if(s)for(let i=0;i<s.textTracks.length;i++){const r=s.textTracks[i];if(on(r,{name:e,lang:t,characteristics:"transcribes-spoken-dialog,describes-music-and-sound"}))return r}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;const{captionsProperties:t,captionsTracks:s,media:i}=this,{label:r,languageCode:n}=t[e],o=this.getExistingTrack(r,n);if(o)s[e]=o,pt(s[e]),ka(s[e],i);else{const d=this.createTextTrack("captions",r,n);d&&(d[e]=!0,s[e]=d)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const t=this.captionsProperties[e];if(!t)return;const s=t.label,i={_id:e,label:s,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=i,this.hls.trigger(y.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[i]})}createTextTrack(e,t,s){const i=this.media;if(i)return i.addTextTrack(e,t,s)}onMediaAttaching(e,t){this.media=t.media,t.mediaSource||this._cleanTracks()}onMediaDetaching(e,t){const s=!!t.transferMedia;if(this.media=null,s)return;const{captionsTracks:i}=this;Object.keys(i).forEach(r=>{pt(i[r]),delete i[r]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=ln(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){const{media:e}=this;if(!e)return;const t=e.textTracks;if(t)for(let s=0;s<t.length;s++)pt(t[s])}onSubtitleTracksUpdated(e,t){const s=t.subtitleTracks||[],i=s.some(r=>r.textCodec===Ys);if(this.config.enableWebVTT||i&&this.config.enableIMSC1){if(ya(this.tracks,s)){this.tracks=s;return}if(this.textTracks=[],this.tracks=s,this.config.renderTextTracksNatively){const n=this.media,o=n?us(n.textTracks):null;if(this.tracks.forEach((d,l)=>{let c;if(o){let u=null;for(let h=0;h<o.length;h++)if(o[h]&&on(o[h],d)){u=o[h],o[h]=null;break}u&&(c=u)}if(c)pt(c);else{const u=Ga(d);c=this.createTextTrack(u,d.name,d.lang),c&&(c.mode="disabled")}c&&this.textTracks.push(c)}),o!=null&&o.length){const d=o.filter(l=>l!==null).map(l=>l.label);d.length&&this.hls.logger.warn("Media element contains unused subtitle tracks: ".concat(d.join(", "),". Replace media element for each source to clear TextTracks and captions menu."))}}else if(this.tracks.length){const n=this.tracks.map(o=>({label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}));this.hls.trigger(y.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:n})}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(s=>{const i=/(?:CC|SERVICE)([1-4])/.exec(s.instreamId);if(!i)return;const r="textTrack".concat(i[1]),n=this.captionsProperties[r];n&&(n.label=s.name,s.lang&&(n.languageCode=s.lang),n.media=s)})}closedCaptionsForLevel(e){const t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){if(this.enabled&&t.frag.type===H.MAIN){var s,i;const{cea608Parser1:r,cea608Parser2:n,lastSn:o}=this,{cc:d,sn:l}=t.frag,c=(s=(i=t.part)==null?void 0:i.index)!=null?s:-1;r&&n&&(l!==o+1||l===o&&c!==this.lastPartIndex+1||d!==this.lastCc)&&(r.reset(),n.reset()),this.lastCc=d,this.lastSn=l,this.lastPartIndex=c}}onFragLoaded(e,t){const{frag:s,payload:i}=t;if(s.type===H.SUBTITLE)if(i.byteLength){const r=s.decryptdata,n="stats"in t;if(r==null||!r.encrypted||n){const o=this.tracks[s.level],d=this.vttCCs;d[s.cc]||(d[s.cc]={start:s.start,prevCC:this.prevCC,new:!0},this.prevCC=s.cc),o&&o.textCodec===Ys?this._parseIMSC1(s,i):this._parseVTTs(t)}}else this.hls.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:s,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const s=this.hls;rn(t,this.initPTS[e.cc],i=>{this._appendCues(i,e.level),s.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},i=>{s.logger.log("Failed to parse IMSC1: ".concat(i)),s.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:i})})}_parseVTTs(e){var t;const{frag:s,payload:i}=e,{initPTS:r,unparsedVttFrags:n}=this,o=r.length-1;if(!r[s.cc]&&o===-1){n.push(e);return}const d=this.hls,l=(t=s.initSegment)!=null&&t.data?Ce(s.initSegment.data,new Uint8Array(i)).buffer:i;Iu(l,this.initPTS[s.cc],this.vttCCs,s.cc,s.start,c=>{this._appendCues(c,s.level),d.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:s})},c=>{const u=c.message==="Missing initPTS for VTT MPEGTS";u?n.push(e):this._fallbackToIMSC1(s,i),d.logger.log("Failed to parse VTT cue: ".concat(c)),!(u&&o>s.cc)&&d.trigger(y.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:s,error:c})})}_fallbackToIMSC1(e,t){const s=this.tracks[e.level];s.textCodec||rn(t,this.initPTS[e.cc],()=>{s.textCodec=Ys,this._parseIMSC1(e,t)},()=>{s.textCodec="wvtt"})}_appendCues(e,t){const s=this.hls;if(this.config.renderTextTracksNatively){const i=this.textTracks[t];if(!i||i.mode==="disabled")return;e.forEach(r=>Ca(i,r))}else{const i=this.tracks[t];if(!i)return;const r=i.default?"default":"subtitles"+t;s.trigger(y.CUES_PARSED,{type:"subtitles",cues:e,track:r})}}onFragDecrypted(e,t){const{frag:s}=t;s.type===H.SUBTITLE&&this.onFragLoaded(y.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){if(!this.enabled||!this.config.enableCEA708Captions)return;const{frag:s,samples:i}=t;if(!(s.type===H.MAIN&&this.closedCaptionsForLevel(s)==="NONE"))for(let r=0;r<i.length;r++){const n=i[r].bytes;if(n){this.cea608Parser1||this.initCea608Parsers();const o=this.extractCea608Data(n);this.cea608Parser1.addData(i[r].pts,o[0]),this.cea608Parser2.addData(i[r].pts,o[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:s,endOffsetSubtitles:i,type:r}){const{media:n}=this;if(!(!n||n.currentTime<s)){if(!r||r==="video"){const{captionsTracks:o}=this;Object.keys(o).forEach(d=>gi(o[d],t,s))}if(this.config.renderTextTracksNatively&&t===0&&i!==void 0){const{textTracks:o}=this;Object.keys(o).forEach(d=>gi(o[d],t,i))}}}extractCea608Data(e){const t=[[],[]],s=e[0]&31;let i=2;for(let r=0;r<s;r++){const n=e[i++],o=127&e[i++],d=127&e[i++];if(o===0&&d===0)continue;if((4&n)!==0){const c=3&n;(c===0||c===1)&&(t[c].push(o),t[c].push(d))}}return t}}function Ga(a){return a.characteristics&&/transcribes-spoken-dialog/gi.test(a.characteristics)&&/describes-music-and-sound/gi.test(a.characteristics)?"captions":"subtitles"}function on(a,e){return!!a&&a.kind===Ga(e)&&ci(e,a)}function Pu(a,e,t,s){return Math.min(e,s)-Math.max(a,t)}function ln(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}const wu=/\s/,Ou={newCue(a,e,t,s){const i=[];let r,n,o,d,l;const c=self.VTTCue||self.TextTrackCue;for(let h=0;h<s.rows.length;h++)if(r=s.rows[h],o=!0,d=0,l="",!r.isEmpty()){var u;for(let m=0;m<r.chars.length;m++)wu.test(r.chars[m].uchar)&&o?d++:(l+=r.chars[m].uchar,o=!1);r.cueStartTime=e,e===t&&(t+=1e-4),d>=16?d--:d++;const f=$a(l.trim()),g=Ki(e,t,f);a!=null&&(u=a.cues)!=null&&u.getCueById(g)||(n=new c(e,t,f),n.id=g,n.line=h+1,n.align="left",n.position=10+Math.min(80,Math.floor(d*8/32)*10),i.push(n))}return a&&i.length&&(i.sort((h,f)=>h.line==="auto"||f.line==="auto"?0:h.line>8&&f.line>8?f.line-h.line:h.line-f.line),i.forEach(h=>Ca(a,h))),i}};function Mu(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(a){}return!1}const Fu=/(\d+)-(\d+)\/(\d+)/;class dn{constructor(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||Uu,this.controller=new self.AbortController,this.stats=new Ei}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}abortInternal(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,s){const i=this.stats;if(i.loading.start)throw new Error("Loader can only be used once.");i.loading.start=self.performance.now();const r=$u(e,this.controller.signal),n=e.responseType==="arraybuffer",o=n?"byteLength":"length",{maxTimeToFirstByteMs:d,maxLoadTimeMs:l}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=s,this.request=this.fetchSetup(e,r),self.clearTimeout(this.requestTimeout),t.timeout=d&&K(d)?d:l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(i,e,this.response))},t.timeout),(Bt(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(u=>{var h;this.response=this.loader=u;const f=Math.max(self.performance.now(),i.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(i,e,this.response))},l-(f-i.loading.start)),!u.ok){const{status:m,statusText:p}=u;throw new Gu(p||"fetch, bad network response",m,u)}i.loading.first=f,i.total=Bu(u.headers)||i.total;const g=(h=this.callbacks)==null?void 0:h.onProgress;return g&&K(t.highWaterMark)?this.loadProgressively(u,i,e,t.highWaterMark,g):n?u.arrayBuffer():e.responseType==="json"?u.json():u.text()}).then(u=>{var h,f;const g=this.response;if(!g)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),i.loading.end=Math.max(self.performance.now(),i.loading.first);const m=u[o];m&&(i.loaded=i.total=m);const p={url:g.url,data:u,code:g.status},v=(h=this.callbacks)==null?void 0:h.onProgress;v&&!K(t.highWaterMark)&&v(i,e,u,g),(f=this.callbacks)==null||f.onSuccess(p,i,e,g)}).catch(u=>{var h;if(self.clearTimeout(this.requestTimeout),i.aborted)return;const f=u&&u.code||0,g=u?u.message:null;(h=this.callbacks)==null||h.onError({code:f,text:g},e,u?u.details:null,i)})}getCacheAge(){let e=null;if(this.response){const t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,s,i=0,r){const n=new Qn,o=e.body.getReader(),d=()=>o.read().then(l=>{if(l.done)return n.dataLength&&r(t,s,n.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));const c=l.value,u=c.length;return t.loaded+=u,u<i||n.dataLength?(n.push(c),n.dataLength>=i&&r(t,s,n.flush().buffer,e)):r(t,s,c.buffer,e),d()}).catch(()=>Promise.reject());return d()}}function $u(a,e){const t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(ie({},a.headers))};return a.rangeEnd&&t.headers.set("Range","bytes="+a.rangeStart+"-"+String(a.rangeEnd-1)),t}function Nu(a){const e=Fu.exec(a);if(e)return parseInt(e[2])-parseInt(e[1])+1}function Bu(a){const e=a.get("Content-Range");if(e){const s=Nu(e);if(K(s))return s}const t=a.get("Content-Length");if(t)return parseInt(t)}function Uu(a,e){return new self.Request(a.url,e)}class Gu extends Error{constructor(e,t,s){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=s}}const Ku=/^age:\s*[\d.]+\s*$/im;class Ka{constructor(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new Ei,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}abortInternal(){const e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,s){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=s,this.loadInternal()}loadInternal(){const{config:e,context:t}=this;if(!e||!t)return;const s=this.loader=new self.XMLHttpRequest,i=this.stats;i.loading.first=0,i.loaded=0,i.aborted=!1;const r=this.xhrSetup;r?Promise.resolve().then(()=>{if(!(this.loader!==s||this.stats.aborted))return r(s,t.url)}).catch(n=>{if(!(this.loader!==s||this.stats.aborted))return s.open("GET",t.url,!0),r(s,t.url)}).then(()=>{this.loader!==s||this.stats.aborted||this.openAndSendXhr(s,t,e)}).catch(n=>{var o;(o=this.callbacks)==null||o.onError({code:s.status,text:n.message},t,s,i)}):this.openAndSendXhr(s,t,e)}openAndSendXhr(e,t,s){e.readyState||e.open("GET",t.url,!0);const i=t.headers,{maxTimeToFirstByteMs:r,maxLoadTimeMs:n}=s.loadPolicy;if(i)for(const o in i)e.setRequestHeader(o,i[o]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),s.timeout=r&&K(r)?r:n,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.timeout),e.send()}readystatechange(){const{context:e,loader:t,stats:s}=this;if(!e||!t)return;const i=t.readyState,r=this.config;if(!s.aborted&&i>=2&&(s.loading.first===0&&(s.loading.first=Math.max(self.performance.now(),s.loading.start),r.timeout!==r.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),r.timeout=r.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.loadPolicy.maxLoadTimeMs-(s.loading.first-s.loading.start)))),i===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const l=t.status,c=t.responseType==="text"?t.responseText:null;if(l>=200&&l<300){const g=c!=null?c:t.response;if(g!=null){var n,o;s.loading.end=Math.max(self.performance.now(),s.loading.first);const m=t.responseType==="arraybuffer"?g.byteLength:g.length;s.loaded=s.total=m,s.bwEstimate=s.total*8e3/(s.loading.end-s.loading.first);const p=(n=this.callbacks)==null?void 0:n.onProgress;p&&p(s,e,g,t);const v={url:t.responseURL,data:g,code:l};(o=this.callbacks)==null||o.onSuccess(v,s,e,t);return}}const u=r.loadPolicy.errorRetry,h=s.retry,f={url:e.url,data:void 0,code:l};if(Es(u,h,!1,f))this.retry(u);else{var d;se.error("".concat(l," while loading ").concat(e.url)),(d=this.callbacks)==null||d.onError({code:l,text:t.statusText},e,t,s)}}}loadtimeout(){if(!this.config)return;const e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(Es(e,t,!0))this.retry(e);else{var s;se.warn("timeout while loading ".concat((s=this.context)==null?void 0:s.url));const i=this.callbacks;i&&(this.abortInternal(),i.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:t,stats:s}=this;this.retryDelay=Ai(e,s.retry),s.retry++,se.warn("".concat(status?"HTTP Status "+status:"Timeout"," while loading ").concat(t==null?void 0:t.url,", retrying ").concat(s.retry,"/").concat(e.maxNumRetry," in ").concat(this.retryDelay,"ms")),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(e){const t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&Ku.test(this.loader.getAllResponseHeaders())){const t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp("^".concat(e,":\\s*[\\d.]+\\s*$"),"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}const Vu={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},Hu=te(te({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,startOnSegmentBoundary:!1,maxBufferSize:60*1e3*1e3,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,liveSyncMode:"edge",liveSyncDurationCount:3,liveSyncOnStallIncrease:1,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,ignorePlaylistParsingErrors:!1,loader:Ka,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:tl,bufferController:Yd,capLevelController:Ni,errorController:al,fpsController:qc,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:Gn,requireKeySystemAccessOnStart:!1,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!0,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!0,preserveManualLevelOnError:!1,certLoadPolicy:{default:Vu},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},Wu()),{},{subtitleStreamController:nu,subtitleTrackController:Xc,timelineController:Cu,audioStreamController:Kd,audioTrackController:Vd,emeController:Et,cmcdController:Vc,contentSteeringController:Wc,interstitialsController:ru});function Wu(){return{cueHandler:Ou,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function Yu(a,e,t){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const s=pi(a),i=["manifest","level","frag"],r=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return i.forEach(n=>{const o="".concat(n==="level"?"playlist":n,"LoadPolicy"),d=e[o]===void 0,l=[];r.forEach(c=>{const u="".concat(n,"Loading").concat(c),h=e[u];if(h!==void 0&&d){l.push(u);const f=s[o].default;switch(e[o]={default:f},c){case"TimeOut":f.maxLoadTimeMs=h,f.maxTimeToFirstByteMs=h;break;case"MaxRetry":f.errorRetry.maxNumRetry=h,f.timeoutRetry.maxNumRetry=h;break;case"RetryDelay":f.errorRetry.retryDelayMs=h,f.timeoutRetry.retryDelayMs=h;break;case"MaxRetryTimeout":f.errorRetry.maxRetryDelayMs=h,f.timeoutRetry.maxRetryDelayMs=h;break}}}),l.length&&t.warn('hls.js config: "'.concat(l.join('", "'),'" setting(s) are deprecated, use "').concat(o,'": ').concat(ne(e[o])))}),te(te({},s),e)}function pi(a){return a&&typeof a=="object"?Array.isArray(a)?a.map(pi):Object.keys(a).reduce((e,t)=>(e[t]=pi(a[t]),e),{}):a}function qu(a,e){const t=a.loader;t!==dn&&t!==Ka?(e.log("[config]: Custom loader detected, cannot enable progressive streaming"),a.progressive=!1):Mu()&&(a.loader=dn,a.progressive=!0,a.enableSoftwareAES=!0,e.log("[config]: Progressive streaming enabled, using FetchLoader"))}const hs=2,ju=.1,zu=.05,Xu=100;class Qu extends $n{constructor(e,t){super("gap-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.media=null,this.mediaSource=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.buffered={},this.lastCurrentTime=0,this.ended=0,this.waiting=0,this.onMediaPlaying=()=>{this.ended=0,this.waiting=0},this.onMediaWaiting=()=>{var s;(s=this.media)!=null&&s.seeking||(this.waiting=self.performance.now(),this.tick())},this.onMediaEnded=()=>{if(this.hls){var s;this.ended=((s=this.media)==null?void 0:s.currentTime)||1,this.hls.trigger(y.MEDIA_ENDED,{stalled:!1})}},this.hls=e,this.fragmentTracker=t,this.registerListeners()}registerListeners(){const{hls:e}=this;e&&(e.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.BUFFER_APPENDED,this.onBufferAppended,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.BUFFER_APPENDED,this.onBufferAppended,this))}destroy(){super.destroy(),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0}onMediaAttached(e,t){this.setInterval(Xu),this.mediaSource=t.mediaSource;const s=this.media=t.media;Te(s,"playing",this.onMediaPlaying),Te(s,"waiting",this.onMediaWaiting),Te(s,"ended",this.onMediaEnded)}onMediaDetaching(e,t){this.clearInterval();const{media:s}=this;s&&(Le(s,"playing",this.onMediaPlaying),Le(s,"waiting",this.onMediaWaiting),Le(s,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0}onBufferAppended(e,t){this.buffered=t.timeRanges}get hasBuffered(){return Object.keys(this.buffered).length>0}tick(){var e;if(!((e=this.media)!=null&&e.readyState)||!this.hasBuffered)return;const t=this.media.currentTime;this.poll(t,this.lastCurrentTime),this.lastCurrentTime=t}poll(e,t){var s,i;const r=(s=this.hls)==null?void 0:s.config;if(!r)return;const n=this.media;if(!n)return;const{seeking:o}=n,d=this.seeking&&!o,l=!this.seeking&&o,c=n.paused&&!o||n.ended||n.playbackRate===0;if(this.seeking=o,e!==t){t&&(this.ended=0),this.moved=!0,o||(this.nudgeRetry=0,r.nudgeOnVideoHole&&!c&&e>t&&this.nudgeOnVideoHole(e,t)),this.waiting===0&&this.stallResolved(e);return}if(l||d){d&&this.stallResolved(e);return}if(c){this.nudgeRetry=0,this.stallResolved(e),!this.ended&&n.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(y.MEDIA_ENDED,{stalled:!1}));return}if(!X.getBuffered(n).length){this.nudgeRetry=0;return}const u=X.bufferInfo(n,e,0),h=u.nextStart||0,f=this.fragmentTracker;if(o&&f&&this.hls){const b=cn(this.hls.inFlightFragments,e),A=u.len>hs,I=!h||b||h-e>hs&&!f.getPartialFragment(e);if(A||I)return;this.moved=!1}const g=(i=this.hls)==null?void 0:i.latestLevelDetails;if(!this.moved&&this.stalled!==null&&f){if(!(u.len>0)&&!h)return;const A=Math.max(h,u.start||0)-e,R=!!(g!=null&&g.live)?g.targetduration*2:hs,L=is(e,f);if(A>0&&(A<=R||L)){n.paused||this._trySkipBufferHole(L);return}}const m=r.detectStallWithCurrentTimeMs,p=self.performance.now(),v=this.waiting;let E=this.stalled;if(E===null)if(v>0&&p-v<m)E=this.stalled=v;else{this.stalled=p;return}const T=p-E;if(!o&&(T>=m||v)&&this.hls){var S;if(((S=this.mediaSource)==null?void 0:S.readyState)==="ended"&&!(g!=null&&g.live)&&Math.abs(e-((g==null?void 0:g.edge)||0))<1){if(this.ended)return;this.ended=e||1,this.hls.trigger(y.MEDIA_ENDED,{stalled:!0});return}if(this._reportStall(u),!this.media||!this.hls)return}const x=X.bufferInfo(n,e,r.maxBufferHole);this._tryFixBufferStall(x,T,e)}stallResolved(e){const t=this.stalled;if(t&&this.hls&&(this.stalled=null,this.stallReported)){const s=self.performance.now()-t;this.log("playback not stuck anymore @".concat(e,", after ").concat(Math.round(s),"ms")),this.stallReported=!1,this.waiting=0,this.hls.trigger(y.STALL_RESOLVED,{})}}nudgeOnVideoHole(e,t){var s;const i=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&(s=this.buffered.audio)!=null&&s.length&&i&&i.length>1&&e>i.end(0)){const r=X.bufferedInfo(X.timeRangesToArray(this.buffered.audio),e,0);if(r.len>1&&t>=r.start){const n=X.timeRangesToArray(i),o=X.bufferedInfo(n,t,0).bufferedIndex;if(o>-1&&o<n.length-1){const d=X.bufferedInfo(n,e,0).bufferedIndex,l=n[o].end,c=n[o+1].start;if((d===-1||d>o)&&c-l<1&&e-l<2){const u=new Error("nudging playhead to flush pipeline after video hole. currentTime: ".concat(e," hole: ").concat(l," -> ").concat(c," buffered index: ").concat(d));this.warn(u.message),this.media.currentTime+=1e-6;let h=is(e,this.fragmentTracker);h&&"fragment"in h?h=h.fragment:h||(h=void 0);const f=X.bufferInfo(this.media,e,0);this.hls.trigger(y.ERROR,{type:W.MEDIA_ERROR,details:_.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:u,reason:u.message,frag:h,buffer:f.len,bufferInfo:f})}}}}}_tryFixBufferStall(e,t,s){var i,r;const{fragmentTracker:n,media:o}=this,d=(i=this.hls)==null?void 0:i.config;if(!o||!n||!d)return;const l=(r=this.hls)==null?void 0:r.latestLevelDetails,c=is(s,n);if((c||l!=null&&l.live&&s<l.fragmentStart)&&(this._trySkipBufferHole(c)||!this.media))return;const u=e.buffered,h=this.adjacentTraversal(e,s);(u&&u.length>1&&e.len>d.maxBufferHole||e.nextStart&&(e.nextStart-s<d.maxBufferHole||h))&&(t>d.highBufferWatchdogPeriod*1e3||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}adjacentTraversal(e,t){const s=this.fragmentTracker,i=e.nextStart;if(s&&i){const r=s.getFragAtPos(t,H.MAIN),n=s.getFragAtPos(i,H.MAIN);if(r&&n)return n.sn-r.sn<2}return!1}_reportStall(e){const{hls:t,media:s,stallReported:i,stalled:r}=this;if(!i&&r!==null&&s&&t){this.stallReported=!0;const n=new Error("Playback stalling at @".concat(s.currentTime," due to low buffer (").concat(ne(e),")"));this.warn(n.message),t.trigger(y.ERROR,{type:W.MEDIA_ERROR,details:_.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:e.len,bufferInfo:e,stalled:{start:r}})}}_trySkipBufferHole(e){var t;const{fragmentTracker:s,media:i}=this,r=(t=this.hls)==null?void 0:t.config;if(!i||!s||!r)return 0;const n=i.currentTime,o=X.bufferInfo(i,n,0),d=n<o.start?o.start:o.nextStart;if(d&&this.hls){const c=o.len<=r.maxBufferHole,u=o.len>0&&o.len<1&&i.readyState<3,h=d-n;if(h>0&&(c||u)){if(h>r.maxBufferHole){let g=!1;if(n===0){const m=s.getAppendedFrag(0,H.MAIN);m&&d<m.end&&(g=!0)}if(!g&&e){var l;if(!((l=this.hls.loadLevelObj)!=null&&l.details)||cn(this.hls.inFlightFragments,d))return 0;let p=!1,v=e.end;for(;v<d;){const E=is(v,s);if(E)v+=E.duration;else{p=!0;break}}if(p)return 0}}const f=Math.max(d+zu,n+ju);if(this.warn("skipping hole, adjusting currentTime from ".concat(n," to ").concat(f)),this.moved=!0,i.currentTime=f,!(e!=null&&e.gap)){const g=new Error("fragment loaded with buffer holes, seeking from ".concat(n," to ").concat(f)),m={type:W.MEDIA_ERROR,details:_.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:g,reason:g.message,buffer:o.len,bufferInfo:o};e&&("fragment"in e?m.part=e:m.frag=e),this.hls.trigger(y.ERROR,m)}return f}}return 0}_tryNudgeBuffer(e){const{hls:t,media:s,nudgeRetry:i}=this,r=t==null?void 0:t.config;if(!s||!r)return 0;const n=s.currentTime;if(this.nudgeRetry++,i<r.nudgeMaxRetry){const o=n+(i+1)*r.nudgeOffset,d=new Error("Nudging 'currentTime' from ".concat(n," to ").concat(o));this.warn(d.message),s.currentTime=o,t.trigger(y.ERROR,{type:W.MEDIA_ERROR,details:_.BUFFER_NUDGE_ON_STALL,error:d,fatal:!1,buffer:e.len,bufferInfo:e})}else{const o=new Error("Playhead still not moving while enough data buffered @".concat(n," after ").concat(r.nudgeMaxRetry," nudges"));this.error(o.message),t.trigger(y.ERROR,{type:W.MEDIA_ERROR,details:_.BUFFER_STALLED_ERROR,error:o,fatal:!0,buffer:e.len,bufferInfo:e})}}}function cn(a,e){const t=un(a.main);if(t&&t.start<=e)return t;const s=un(a.audio);return s&&s.start<=e?s:null}function un(a){if(!a)return null;switch(a.state){case P.IDLE:case P.STOPPED:case P.ENDED:case P.ERROR:return null}return a.frag}function is(a,e){return e.getAppendedFrag(a,H.MAIN)||e.getPartialFragment(a)}const Zu=.25;function yi(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function Xs(a,e,t,s,i){let r=new a(e,t,"");try{r.value=s,i&&(r.type=i)}catch(n){r=new a(e,t,ne(i?te({type:i},s):s))}return r}const rs=(()=>{const a=yi();try{a&&new a(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();class Ju{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.assetCue=void 0,this.onEventCueEnter=()=>{this.hls&&this.hls.trigger(y.EVENT_CUE_ENTER,{})},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null}_registerListeners(){const{hls:e}=this;e&&(e.on(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(y.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(y.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(y.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(y.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(y.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(y.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}onMediaAttaching(e,t){var s;this.media=t.media,((s=t.overrides)==null?void 0:s.cueRemoval)===!1&&(this.removeCues=!1)}onMediaAttached(){var e;const t=(e=this.hls)==null?void 0:e.latestLevelDetails;t&&this.updateDateRangeCues(t)}onMediaDetaching(e,t){this.media=null,!t.transferMedia&&(this.id3Track&&(this.removeCues&&pt(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){const t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){const s=e[t];if(s.kind==="metadata"&&s.label==="id3")return ka(s,this.media),s}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media||!this.hls)return;const{enableEmsgMetadataCues:s,enableID3MetadataCues:i}=this.hls.config;if(!s&&!i)return;const{samples:r}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const n=yi();if(n)for(let o=0;o<r.length;o++){const d=r[o].type;if(d===Re.emsg&&!s||!i)continue;const l=ra(r[o].data),c=r[o].pts;let u=c+r[o].duration;u>rs&&(u=rs),u-c<=0&&(u=c+Zu);for(let f=0;f<l.length;f++){const g=l[f];if(!na(g)){this.updateId3CueEnds(c,d);const m=Xs(n,c,u,g,d);m&&this.id3Track.addCue(m)}}}}updateId3CueEnds(e,t){var s;const i=(s=this.id3Track)==null?void 0:s.cues;if(i)for(let r=i.length;r--;){const n=i[r];n.type===t&&n.startTime<e&&n.endTime===rs&&(n.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:s,type:i}){const{id3Track:r,hls:n}=this;if(!n)return;const{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:d}}=n;if(r&&(o||d)){let l;i==="audio"?l=c=>c.type===Re.audioId3&&d:i==="video"?l=c=>c.type===Re.emsg&&o:l=c=>c.type===Re.audioId3&&d||c.type===Re.emsg&&o,gi(r,t,s,l)}}onLevelUpdated(e,{details:t}){this.updateDateRangeCues(t,!0)}onLevelPtsUpdated(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details)}updateDateRangeCues(e,t){if(!this.hls||!this.media)return;const{assetPlayerId:s,timelineOffset:i,enableDateRangeMetadataCues:r,interstitialsController:n}=this.hls.config;if(!r)return;const o=yi();if(s&&i&&!n){const{fragmentStart:m,fragmentEnd:p}=e;let v=this.assetCue;v?(v.startTime=m,v.endTime=p):o&&(v=this.assetCue=Xs(o,m,p,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"),v&&(v.id=s,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.addCue(v),v.addEventListener("enter",this.onEventCueEnter)))}if(!e.hasProgramDateTime)return;const{id3Track:d}=this,{dateRanges:l}=e,c=Object.keys(l);let u=this.dateRangeCuesAppended;if(d&&t){var h;if((h=d.cues)!=null&&h.length){const m=Object.keys(u).filter(p=>!c.includes(p));for(let p=m.length;p--;){var f;const v=m[p],E=(f=u[v])==null?void 0:f.cues;delete u[v],E&&Object.keys(E).forEach(T=>{const S=E[T];if(S){S.removeEventListener("enter",this.onEventCueEnter);try{d.removeCue(S)}catch(x){}}})}}else u=this.dateRangeCuesAppended={}}const g=e.fragments[e.fragments.length-1];if(!(c.length===0||!K(g==null?void 0:g.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let m=0;m<c.length;m++){const p=c[m],v=l[p],E=v.startTime,T=u[p],S=(T==null?void 0:T.cues)||{};let x=(T==null?void 0:T.durationKnown)||!1,b=rs;const{duration:A,endDate:I}=v;if(I&&A!==null)b=E+A,x=!0;else if(v.endOnNext&&!x){const L=c.reduce((w,U)=>{if(U!==v.id){const V=l[U];if(V.class===v.class&&V.startDate>v.startDate&&(!w||v.startDate<w.startDate))return V}return w},null);L&&(b=L.startTime,x=!0)}const R=Object.keys(v.attr);for(let L=0;L<R.length;L++){const w=R[L];if(!El(w))continue;const U=S[w];if(U)x&&!(T!=null&&T.durationKnown)?U.endTime=b:Math.abs(U.startTime-E)>.01&&(U.startTime=E,U.endTime=b);else if(o){let V=v.attr[w];Tl(w)&&(V=vn(V));const N=Xs(o,E,b,{key:w,data:V},Re.dateRange);N&&(N.id=p,this.id3Track.addCue(N),S[w]=N,n&&(w==="X-ASSET-LIST"||w==="X-ASSET-URL")&&N.addEventListener("enter",this.onEventCueEnter))}}u[p]={cues:S,dateRange:v,durationKnown:x}}}}}class eh{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=()=>{const{media:t}=this,s=this.levelDetails;if(!t||!s)return;this.currentTime=t.currentTime;const i=this.computeLatency();if(i===null)return;this._latency=i;const{lowLatencyMode:r,maxLiveSyncPlaybackRate:n}=this.config;if(!r||n===1||!s.live)return;const o=this.targetLatency;if(o===null)return;const d=i-o,l=Math.min(this.maxLatency,o+s.targetduration);if(d<l&&d>.05&&this.forwardBufferLength>1){const u=Math.min(2,Math.max(1,n)),h=Math.round(2/(1+Math.exp(-.75*d-this.edgeStalled))*20)/20,f=Math.min(u,Math.max(1,h));this.changeMediaPlaybackRate(t,f)}else t.playbackRate!==1&&t.playbackRate!==0&&this.changeMediaPlaybackRate(t,1)},this.hls=e,this.config=e.config,this.registerListeners()}get levelDetails(){var e;return((e=this.hls)==null?void 0:e.latestLevelDetails)||null}get latency(){return this._latency||0}get maxLatency(){const{config:e}=this;if(e.liveMaxLatencyDuration!==void 0)return e.liveMaxLatencyDuration;const t=this.levelDetails;return t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){const e=this.levelDetails;if(e===null||this.hls===null)return null;const{holdBack:t,partHoldBack:s,targetduration:i}=e,{liveSyncDuration:r,liveSyncDurationCount:n,lowLatencyMode:o}=this.config,d=this.hls.userConfig;let l=o&&s||t;(this._targetLatencyUpdated||d.liveSyncDuration||d.liveSyncDurationCount||l===0)&&(l=r!==void 0?r:n*i);const c=i;return l+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,c)}set targetLatency(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=!0}get liveSyncPosition(){const e=this.estimateLiveEdge(),t=this.targetLatency;if(e===null||t===null)return null;const s=this.levelDetails;if(s===null)return null;const i=s.edge,r=e-t-this.edgeStalled,n=i-s.totalduration,o=i-(this.config.lowLatencyMode&&s.partTarget||s.targetduration);return Math.min(Math.max(n,r),o)}get drift(){const e=this.levelDetails;return e===null?1:e.drift}get edgeStalled(){const e=this.levelDetails;if(e===null)return 0;const t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){const{media:e}=this,t=this.levelDetails;if(!e||!t)return 0;const s=e.buffered.length;return(s?e.buffered.end(s-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null}registerListeners(){const{hls:e}=this;e&&(e.on(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(y.ERROR,this.onError,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(y.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(y.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(y.ERROR,this.onError,this))}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)}onManifestLoading(){this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){t.advanced&&this.onTimeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)}onError(e,t){var s;t.details===_.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&(s=this.levelDetails)!=null&&s.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))}changeMediaPlaybackRate(e,t){var s,i;e.playbackRate!==t&&((s=this.hls)==null||s.logger.debug("[latency-controller]: latency=".concat(this.latency.toFixed(3),", targetLatency=").concat((i=this.targetLatency)==null?void 0:i.toFixed(3),", forwardBufferLength=").concat(this.forwardBufferLength.toFixed(3),": adjusting playback rate from ").concat(e.playbackRate," to ").concat(t)),e.playbackRate=t)}estimateLiveEdge(){const e=this.levelDetails;return e===null?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}}class th extends $i{constructor(e,t){super(e,"level-controller"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this),e.on(y.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this),e.off(y.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.stopLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){const s=this.hls.config.preferManagedMediaSource,i=[],r={},n={};let o=!1,d=!1,l=!1;t.levels.forEach(c=>{const u=c.attrs;let{audioCodec:h,videoCodec:f}=c;h&&(c.audioCodec=h=ms(h,s)||void 0),f&&(f=c.videoCodec=Fo(f));const{width:g,height:m,unknownCodecs:p}=c,v=(p==null?void 0:p.length)||0;if(o||(o=!!(g&&m)),d||(d=!!f),l||(l=!!h),v||h&&!this.isAudioSupported(h)||f&&!this.isVideoSupported(f)){this.log('Some or all CODECS not supported "'.concat(u.CODECS,'"'));return}const{CODECS:E,"FRAME-RATE":T,"HDCP-LEVEL":S,"PATHWAY-ID":x,RESOLUTION:b,"VIDEO-RANGE":A}=u,I="".concat(x||".","-"),R="".concat(I).concat(c.bitrate,"-").concat(b,"-").concat(T,"-").concat(E,"-").concat(A,"-").concat(S);if(r[R])if(r[R].uri!==c.url&&!c.attrs["PATHWAY-ID"]){const L=n[R]+=1;c.attrs["PATHWAY-ID"]=new Array(L+1).join(".");const w=this.createLevel(c);r[R]=w,i.push(w)}else r[R].addGroupId("audio",u.AUDIO),r[R].addGroupId("text",u.SUBTITLES);else{const L=this.createLevel(c);r[R]=L,n[R]=1,i.push(L)}}),this.filterAndSortMediaOptions(i,t,o,d,l)}createLevel(e){const t=new Mt(e),s=e.supplemental;if(s!=null&&s.videoCodec&&!this.isVideoSupported(s.videoCodec)){const i=new Error('SUPPLEMENTAL-CODECS not supported "'.concat(s.videoCodec,'"'));this.log(i.message),t.supportedResult=_n(i,[])}return t}isAudioSupported(e){return wt(e,"audio",this.hls.config.preferManagedMediaSource)}isVideoSupported(e){return wt(e,"video",this.hls.config.preferManagedMediaSource)}filterAndSortMediaOptions(e,t,s,i,r){var n;let o=[],d=[],l=e;const c=((n=t.stats)==null?void 0:n.parsing)||{};if((s||i)&&r&&(l=l.filter(({videoCodec:E,videoRange:T,width:S,height:x})=>(!!E||!!(S&&x))&&Yo(T))),l.length===0){Promise.resolve().then(()=>{if(this.hls){let E="no level with compatible codecs found in manifest",T=E;t.levels.length&&(T="one or more CODECS in variant not supported: ".concat(ne(t.levels.map(x=>x.attrs.CODECS).filter((x,b,A)=>A.indexOf(x)===b))),this.warn(T),E+=" (".concat(T,")"));const S=new Error(E);this.hls.trigger(y.ERROR,{type:W.MEDIA_ERROR,details:_.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:S,reason:T})}}),c.end=performance.now();return}t.audioTracks&&(o=t.audioTracks.filter(E=>!E.audioCodec||this.isAudioSupported(E.audioCodec)),hn(o)),t.subtitles&&(d=t.subtitles,hn(d));const u=l.slice(0);l.sort((E,T)=>{if(E.attrs["HDCP-LEVEL"]!==T.attrs["HDCP-LEVEL"])return(E.attrs["HDCP-LEVEL"]||"")>(T.attrs["HDCP-LEVEL"]||"")?1:-1;if(s&&E.height!==T.height)return E.height-T.height;if(E.frameRate!==T.frameRate)return E.frameRate-T.frameRate;if(E.videoRange!==T.videoRange)return ps.indexOf(E.videoRange)-ps.indexOf(T.videoRange);if(E.videoCodec!==T.videoCodec){const S=rr(E.videoCodec),x=rr(T.videoCodec);if(S!==x)return x-S}if(E.uri===T.uri&&E.codecSet!==T.codecSet){const S=gs(E.codecSet),x=gs(T.codecSet);if(S!==x)return x-S}return E.averageBitrate!==T.averageBitrate?E.averageBitrate-T.averageBitrate:0});let h=u[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==u.length)){for(let E=0;E<u.length;E++)if(u[E].pathwayId===l[0].pathwayId){h=u[E];break}}this._levels=l;for(let E=0;E<l.length;E++)if(l[E]===h){var f;this._firstLevel=E;const T=h.bitrate,S=this.hls.bandwidthEstimate;if(this.log("manifest loaded, ".concat(l.length," level(s) found, first bitrate: ").concat(T)),((f=this.hls.userConfig)==null?void 0:f.abrEwmaDefaultEstimate)===void 0){const x=Math.min(T,this.hls.config.abrEwmaDefaultEstimateMax);x>S&&S===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=x)}break}const g=r&&!i,m=this.hls.config,p=!!(m.audioStreamController&&m.audioTrackController),v={levels:l,audioTracks:o,subtitleTracks:d,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:r,video:i,altAudio:p&&!g&&o.some(E=>!!E.url)};c.end=performance.now(),this.hls.trigger(y.MANIFEST_PARSED,v)}get levels(){return this._levels.length===0?null:this._levels}get loadLevelObj(){return this.currentLevel}get level(){return this.currentLevelIndex}set level(e){const t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){const c=new Error("invalid level idx"),u=e<0;if(this.hls.trigger(y.ERROR,{type:W.OTHER_ERROR,details:_.LEVEL_SWITCH_ERROR,level:e,fatal:u,error:c,reason:c.message}),u)return;e=Math.min(e,t.length-1)}const s=this.currentLevelIndex,i=this.currentLevel,r=i?i.attrs["PATHWAY-ID"]:void 0,n=t[e],o=n.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=n,s===e&&i&&r===o)return;this.log("Switching to level ".concat(e," (").concat(n.height?n.height+"p ":"").concat(n.videoRange?n.videoRange+" ":"").concat(n.codecSet?n.codecSet+" ":"","@").concat(n.bitrate,")").concat(o?" with Pathway "+o:""," from level ").concat(s).concat(r?" with Pathway "+r:""));const d={level:e,attrs:n.attrs,details:n.details,bitrate:n.bitrate,averageBitrate:n.averageBitrate,maxBitrate:n.maxBitrate,realBitrate:n.realBitrate,width:n.width,height:n.height,codecSet:n.codecSet,audioCodec:n.audioCodec,videoCodec:n.videoCodec,audioGroups:n.audioGroups,subtitleGroups:n.subtitleGroups,loaded:n.loaded,loadError:n.loadError,fragmentError:n.fragmentError,name:n.name,id:n.id,uri:n.uri,url:n.url,urlId:0,audioGroupIds:n.audioGroupIds,textGroupIds:n.textGroupIds};this.hls.trigger(y.LEVEL_SWITCHING,d);const l=n.details;if(!l||l.live){const c=this.switchParams(n.uri,i==null?void 0:i.details,l);this.loadPlaylist(c)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(this._startLevel===void 0){const e=this.hls.config.startLevel;return e!==void 0?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}get pathways(){return this.steering?this.steering.pathways():[]}get pathwayPriority(){return this.steering?this.steering.pathwayPriority:null}set pathwayPriority(e){if(this.steering){const t=this.steering.pathways(),s=e.filter(i=>t.indexOf(i)!==-1);if(e.length<1){this.warn("pathwayPriority ".concat(e," should contain at least one pathway from list: ").concat(t));return}this.steering.pathwayPriority=s}}onError(e,t){t.fatal||!t.context||t.context.type===J.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===H.MAIN){const s=t.elementaryStreams;if(!Object.keys(s).some(r=>!!s[r]))return;const i=this._levels[t.level];i!=null&&i.loadError&&(this.log("Resetting level error count of ".concat(i.loadError," on frag buffered")),i.loadError=0)}}onLevelLoaded(e,t){var s;const{level:i,details:r}=t,n=t.levelInfo;if(!n){var o;this.warn("Invalid level index ".concat(i)),(o=t.deliveryDirectives)!=null&&o.skip&&(r.deltaUpdateFailed=!0);return}if(n===this.currentLevel||t.withoutMultiVariant){n.fragmentError===0&&(n.loadError=0);let d=n.details;d===t.details&&d.advanced&&(d=void 0),this.playlistLoaded(i,t,d)}else(s=t.deliveryDirectives)!=null&&s.skip&&(r.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const s=this.getUrlWithDirectives(e.uri,t),i=this.currentLevelIndex,r=e.attrs["PATHWAY-ID"],n=e.details,o=n==null?void 0:n.age;this.log("Loading level index ".concat(i).concat((t==null?void 0:t.msn)!==void 0?" at sn "+t.msn+" part "+t.part:"").concat(r?" Pathway "+r:"").concat(o&&n.live?" age "+o.toFixed(1)+(n.type&&" "+n.type||""):""," ").concat(s)),this.hls.trigger(y.LEVEL_LOADING,{url:s,level:i,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;if(this._levels.length===1)return;const s=this._levels.filter((r,n)=>n!==e?!0:(this.steering&&this.steering.removeLevel(r),r===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,r.details&&r.details.fragments.forEach(o=>o.level=-1)),!1));jn(s),this._levels=s,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);const i=s.length-1;this._firstLevel=Math.min(this._firstLevel,i),this._startLevel&&(this._startLevel=Math.min(this._startLevel,i)),this.hls.trigger(y.LEVELS_UPDATED,{levels:s})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){const{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:s}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(y.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:s}))}}function hn(a){const e={};a.forEach(t=>{const s=t.groupId||"";t.id=e[s]=e[s]||0,e[s]++})}function Va(){return self.SourceBuffer||self.WebKitSourceBuffer}function Ha(){if(!Je())return!1;const e=Va();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function sh(){if(!Ha())return!1;const a=Je();return typeof(a==null?void 0:a.isTypeSupported)=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>a.isTypeSupported(Ot(e,"video")))||["mp4a.40.2","fLaC"].some(e=>a.isTypeSupported(Ot(e,"audio"))))}function ih(){var a;const e=Va();return typeof(e==null||(a=e.prototype)==null?void 0:a.changeType)=="function"}const rh=100;class nh extends _i{constructor(e,t,s){super(e,t,s,"stream-controller",H.MAIN),this.audioCodecSwap=!1,this.level=-1,this._forceStartLoad=!1,this._hasEnoughToStart=!1,this.altAudio=0,this.audioOnly=!1,this.fragPlaying=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this.onMediaPlaying=()=>{this.tick()},this.onMediaSeeked=()=>{const i=this.media,r=i?i.currentTime:null;if(r===null||!K(r)||(this.log("Media seeked to ".concat(r.toFixed(3))),!this.getBufferedFrag(r)))return;const n=this.getFwdBufferInfoAtPos(i,r,H.MAIN,0);if(n===null||n.len===0){this.warn("Main forward buffer length at ".concat(r,' on "seeked" event ').concat(n?n.len:"empty",")"));return}this.tick()},this.registerListeners()}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(y.MANIFEST_PARSED,this.onManifestParsed,this),e.on(y.LEVEL_LOADING,this.onLevelLoading,this),e.on(y.LEVEL_LOADED,this.onLevelLoaded,this),e.on(y.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(y.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(y.BUFFER_CREATED,this.onBufferCreated,this),e.on(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(y.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(y.MANIFEST_PARSED,this.onManifestParsed,this),e.off(y.LEVEL_LOADED,this.onLevelLoaded,this),e.off(y.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(y.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(y.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(y.BUFFER_CREATED,this.onBufferCreated,this),e.off(y.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(y.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(y.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),super.onHandlerDestroying()}startLoad(e,t){if(this.levels){const{lastCurrentTime:s,hls:i}=this;if(this.stopLoad(),this.setInterval(rh),this.level=-1,!this.startFragRequested){let r=i.startLevel;r===-1&&(i.config.testBandwidth&&this.levels.length>1?(r=0,this.bitrateTest=!0):r=i.firstAutoLevel),i.nextLoadLevel=r,this.level=i.loadLevel,this._hasEnoughToStart=!!t}s>0&&e===-1&&!t&&(this.log("Override startPosition with lastCurrentTime @".concat(s.toFixed(3))),e=s),this.state=P.IDLE,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=P.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case P.WAITING_LEVEL:{const{levels:e,level:t}=this,s=e==null?void 0:e[t],i=s==null?void 0:s.details;if(i&&(!i.live||this.levelLastLoaded===s&&!this.waitForLive(s))){if(this.waitForCdnTuneIn(i))break;this.state=P.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=P.IDLE;break}break}case P.FRAG_LOADING_WAITING_RETRY:this.checkRetryDate();break}this.state===P.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){var e;super.onTickEnd(),(e=this.media)!=null&&e.readyState&&this.media.seeking===!1&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:s,media:i}=this;if(t===null||!i&&!this.primaryPrefetch&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;const r=this.buffering?e.nextLoadLevel:e.loadLevel;if(!(s!=null&&s[r]))return;const n=s[r],o=this.getMainFwdBufferInfo();if(o===null)return;const d=this.getLevelDetails();if(d&&this._streamEnded(o,d)){const m={};this.altAudio===2&&(m.type="video"),this.hls.trigger(y.BUFFER_EOS,m),this.state=P.ENDED;return}if(!this.buffering)return;e.loadLevel!==r&&e.manualLevel===-1&&this.log("Adapting to level ".concat(r," from level ").concat(this.level)),this.level=e.nextLoadLevel=r;const l=n.details;if(!l||this.state===P.WAITING_LEVEL||this.waitForLive(n)){this.level=r,this.state=P.WAITING_LEVEL,this.startFragRequested=!1;return}const c=o.len,u=this.getMaxBufferLength(n.maxBitrate);if(c>=u)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);const h=this.backtrackFragment?this.backtrackFragment.start:o.end;let f=this.getNextFragment(h,l);if(this.couldBacktrack&&!this.fragPrevious&&f&&he(f)&&this.fragmentTracker.getState(f)!==ge.OK){var g;const p=((g=this.backtrackFragment)!=null?g:f).sn-l.startSN,v=l.fragments[p-1];v&&f.cc===v.cc&&(f=v,this.fragmentTracker.removeFragment(v))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(f&&this.isLoopLoading(f,h)){if(!f.gap){const p=this.audioOnly&&!this.altAudio?re.AUDIO:re.VIDEO,v=(p===re.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;v&&this.afterBufferFlushed(v,p,H.MAIN)}f=this.getNextFragmentLoopLoading(f,l,o,H.MAIN,u)}f&&(f.initSegment&&!f.initSegment.data&&!this.bitrateTest&&(f=f.initSegment),this.loadFragment(f,n,h))}loadFragment(e,t,s){const i=this.fragmentTracker.getState(e);i===ge.NOT_LOADED||i===ge.PARTIAL?he(e)?this.bitrateTest?(this.log("Fragment ".concat(e.sn," of level ").concat(e.level," is being downloaded to test bitrate and will not be buffered")),this._loadBitrateTestFrag(e,t)):super.loadFragment(e,t,s):this._loadInitSegment(e,t):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,H.MAIN)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:e,media:t}=this;if(t!=null&&t.readyState){let s;const i=this.getAppendedFrag(t.currentTime);i&&i.start>1&&this.flushMainBuffer(0,i.start-1);const r=this.getLevelDetails();if(r!=null&&r.live){const o=this.getMainFwdBufferInfo();if(!o||o.len<r.targetduration*2)return}if(!t.paused&&e){const o=this.hls.nextLoadLevel,d=e[o],l=this.fragLastKbps;l&&this.fragCurrent?s=this.fragCurrent.duration*d.maxBitrate/(1e3*l)+1:s=0}else s=0;const n=this.getBufferedFrag(t.currentTime+s);if(n){const o=this.followingBufferedFrag(n);if(o){this.abortCurrentFrag();const d=o.maxStartPTS?o.maxStartPTS:o.start,l=o.duration,c=Math.max(n.end,d+Math.min(Math.max(l-this.config.maxFragLookUpTolerance,l*(this.couldBacktrack?.5:.125)),l*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(c,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case P.KEY_LOADING:case P.FRAG_LOADING:case P.FRAG_LOADING_WAITING_RETRY:case P.PARSING:case P.PARSED:this.state=P.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio===2?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);const s=t.media;Te(s,"playing",this.onMediaPlaying),Te(s,"seeked",this.onMediaSeeked)}onMediaDetaching(e,t){const{media:s}=this;s&&(Le(s,"playing",this.onMediaPlaying),Le(s,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,super.onMediaDetaching(e,t),!t.transferMedia&&(this._hasEnoughToStart=!1)}onManifestLoading(){super.onManifestLoading(),this.log("Trigger BUFFER_RESET"),this.hls.trigger(y.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1}onManifestParsed(e,t){let s=!1,i=!1;for(let r=0;r<t.levels.length;r++){const n=t.levels[r].audioCodec;n&&(s=s||n.indexOf("mp4a.40.2")!==-1,i=i||n.indexOf("mp4a.40.5")!==-1)}this.audioCodecSwitch=s&&i&&!ih(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){const{levels:s}=this;if(!s||this.state!==P.IDLE)return;const i=t.levelInfo;(!i.details||i.details.live&&(this.levelLastLoaded!==i||i.details.expired)||this.waitForCdnTuneIn(i.details))&&(this.state=P.WAITING_LEVEL)}onLevelLoaded(e,t){var s;const{levels:i,startFragRequested:r}=this,n=t.level,o=t.details,d=o.totalduration;if(!i){this.warn("Levels were reset while loading level ".concat(n));return}this.log("Level ".concat(n," loaded [").concat(o.startSN,",").concat(o.endSN,"]").concat(o.lastPartSn?"[part-".concat(o.lastPartSn,"-").concat(o.lastPartIndex,"]"):"",", cc [").concat(o.startCC,", ").concat(o.endCC,"] duration:").concat(d));const l=t.levelInfo,c=this.fragCurrent;c&&(this.state===P.FRAG_LOADING||this.state===P.FRAG_LOADING_WAITING_RETRY)&&c.level!==t.level&&c.loader&&this.abortCurrentFrag();let u=0;if(o.live||(s=l.details)!=null&&s.live){var h;if(this.checkLiveUpdate(o),o.deltaUpdateFailed)return;u=this.alignPlaylists(o,l.details,(h=this.levelLastLoaded)==null?void 0:h.details)}if(l.details=o,this.levelLastLoaded=l,r||this.setStartPosition(o,u),this.hls.trigger(y.LEVEL_UPDATED,{details:o,level:n}),this.state===P.WAITING_LEVEL){if(this.waitForCdnTuneIn(o))return;this.state=P.IDLE}r&&o.live&&this.synchronizeToLiveEdge(o),this.tick()}synchronizeToLiveEdge(e){const{config:t,media:s}=this;if(!s)return;const i=this.hls.liveSyncPosition,r=this.getLoadPosition(),n=e.fragmentStart,o=e.edge,d=r>=n-t.maxFragLookUpTolerance&&r<=o;if(i!==null&&s.duration>i&&(r<i||!d)){const c=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!d&&s.readyState<4||r<o-c)&&(this._hasEnoughToStart||(this.nextLoadPosition=i),s.readyState))if(this.warn("Playback: ".concat(r.toFixed(3)," is located too far from the end of live sliding playlist: ").concat(o,", reset currentTime to : ").concat(i.toFixed(3))),this.config.liveSyncMode==="buffered"){var l;const u=X.bufferInfo(s,i,0);if(!((l=u.buffered)!=null&&l.length)){s.currentTime=i;return}if(u.start<=r){s.currentTime=i;return}const{nextStart:f}=X.bufferedInfo(u.buffered,r,0);f&&(s.currentTime=f)}else s.currentTime=i}}_handleFragmentLoadProgress(e){var t;const s=e.frag,{part:i,payload:r}=e,{levels:n}=this;if(!n){this.warn("Levels were reset while fragment load was in progress. Fragment ".concat(s.sn," of level ").concat(s.level," will not be buffered"));return}const o=n[s.level];if(!o){this.warn("Level ".concat(s.level," not found on progress"));return}const d=o.details;if(!d){this.warn("Dropping fragment ".concat(s.sn," of level ").concat(s.level," after level details were reset")),this.fragmentTracker.removeFragment(s);return}const l=o.videoCodec,c=d.PTSKnown||!d.live,u=(t=s.initSegment)==null?void 0:t.data,h=this._getAudioCodec(o),f=this.transmuxer=this.transmuxer||new pa(this.hls,H.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),g=i?i.index:-1,m=g!==-1,p=new Ii(s.level,s.sn,s.stats.chunkCount,r.byteLength,g,m),v=this.initPTS[s.cc];f.push(r,u,h,l,s,i,d.totalduration,c,p,v)}onAudioTrackSwitching(e,t){const s=this.hls,i=this.altAudio===2;if(ys(t.url,s))this.altAudio=1;else{if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const n=this.fragCurrent;n&&(this.log("Switching to main audio track, cancel main fragment load"),n.abortRequests(),this.fragmentTracker.removeFragment(n)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(i){this.fragmentTracker.removeAllFragments(),s.once(y.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(y.AUDIO_TRACK_SWITCHED,t)}),s.trigger(y.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});return}s.trigger(y.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const s=ys(t.url,this.hls);if(s){const i=this.videoBuffer;i&&this.mediaBuffer!==i&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=i)}this.altAudio=s?2:0,this.tick()}onBufferCreated(e,t){const s=t.tracks;let i,r,n=!1;for(const o in s){const d=s[o];if(d.id==="main"){if(r=o,i=d,o==="video"){const l=s[o];l&&(this.videoBuffer=l.buffer)}}else n=!0}n&&i?(this.log("Alternate track found, use ".concat(r,".buffered to schedule main fragment loading")),this.mediaBuffer=i.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:s,part:i}=t,r=s.type===H.MAIN;if(r){if(this.fragContextChanged(s)){this.warn("Fragment ".concat(s.sn).concat(i?" p: "+i.index:""," of level ").concat(s.level," finished buffering, but was aborted. state: ").concat(this.state)),this.state===P.PARSED&&(this.state=P.IDLE);return}const o=i?i.stats:s.stats;this.fragLastKbps=Math.round(8*o.total/(o.buffering.end-o.loading.first)),he(s)&&(this.fragPrevious=s),this.fragBufferedComplete(s,i)}const n=this.media;n&&(!this._hasEnoughToStart&&X.getBuffered(n).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),r&&this.tick())}get hasEnoughToStart(){return this._hasEnoughToStart}onError(e,t){var s;if(t.fatal){this.state=P.ERROR;return}switch(t.details){case _.FRAG_GAP:case _.FRAG_PARSING_ERROR:case _.FRAG_DECRYPT_ERROR:case _.FRAG_LOAD_ERROR:case _.FRAG_LOAD_TIMEOUT:case _.KEY_LOAD_ERROR:case _.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(H.MAIN,t);break;case _.LEVEL_LOAD_ERROR:case _.LEVEL_LOAD_TIMEOUT:case _.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===P.WAITING_LEVEL&&((s=t.context)==null?void 0:s.type)===J.LEVEL&&(this.state=P.IDLE);break;case _.BUFFER_ADD_CODEC_ERROR:case _.BUFFER_APPEND_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case _.BUFFER_FULL_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&(!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=!0:this.flushMainBuffer(0,Number.POSITIVE_INFINITY));break;case _.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onFragLoadEmergencyAborted(){this.state=P.IDLE,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==re.AUDIO||!this.altAudio){const s=(t===re.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;s&&(this.afterBufferFlushed(s,t,H.MAIN),this.tick())}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,this.level===-1&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const t=e.currentTime;let s=this.startPosition;if(s>=0&&t<s){if(e.seeking){this.log("could not seek to ".concat(s,", already seeking at ").concat(t));return}const i=this.timelineOffset;i&&s&&(s+=i);const r=this.getLevelDetails(),n=X.getBuffered(e),o=n.length?n.start(0):0,d=o-s,l=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||d>0&&(d<l||this.loadingParts&&d<2*((r==null?void 0:r.partTarget)||0)))&&(this.log("adjusting start position by ".concat(d," to match buffer start")),s+=d,this.startPosition=s),t<s&&(this.log("seek to target start position ".concat(s," from current time ").concat(t," buffer start ").concat(o)),e.currentTime=s)}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(s=>{const{hls:i}=this,r=s==null?void 0:s.frag;if(!r||this.fragContextChanged(r))return;t.fragmentError=0,this.state=P.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const n=r.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),i.trigger(y.FRAG_LOADED,s),r.bitrateTest=!1}).catch(s=>{this.state===P.STOPPED||this.state===P.ERROR||(this.warn(s),this.resetFragmentLoading(e))})}_handleTransmuxComplete(e){const t=this.playlistType,{hls:s}=this,{remuxResult:i,chunkMeta:r}=e,n=this.getCurrentContext(r);if(!n){this.resetWhenMissingContext(r);return}const{frag:o,part:d,level:l}=n,{video:c,text:u,id3:h,initSegment:f}=i,{details:g}=l,m=this.altAudio?void 0:i.audio;if(this.fragContextChanged(o)){this.fragmentTracker.removeFragment(o);return}if(this.state=P.PARSING,f){const p=f.tracks;if(p){const S=o.initSegment||o;if(this.unhandledEncryptionError(f,o))return;this._bufferInitSegment(l,p,S,r),s.trigger(y.FRAG_PARSING_INIT_SEGMENT,{frag:S,id:t,tracks:p})}const v=f.initPTS,E=f.timescale,T=this.initPTS[o.cc];if(K(v)&&(!T||T.baseTime!==v||T.timescale!==E)){const S=f.trackId;this.initPTS[o.cc]={baseTime:v,timescale:E,trackId:S},s.trigger(y.INIT_PTS_FOUND,{frag:o,id:t,initPTS:v,timescale:E,trackId:S})}}if(c&&g){m&&c.type==="audiovideo"&&this.logMuxedErr(o);const p=g.fragments[o.sn-1-g.startSN],v=o.sn===g.startSN,E=!p||o.cc>p.cc;if(i.independent!==!1){const{startPTS:T,endPTS:S,startDTS:x,endDTS:b}=c;if(d)d.elementaryStreams[c.type]={startPTS:T,endPTS:S,startDTS:x,endDTS:b};else if(c.firstKeyFrame&&c.independent&&r.id===1&&!E&&(this.couldBacktrack=!0),c.dropped&&c.independent){const A=this.getMainFwdBufferInfo(),I=(A?A.end:this.getLoadPosition())+this.config.maxBufferHole,R=c.firstKeyFramePTS?c.firstKeyFramePTS:T;if(!v&&I<R-this.config.maxBufferHole&&!E){this.backtrack(o);return}else E&&(o.gap=!0);o.setElementaryStreamInfo(c.type,o.start,S,o.start,b,!0)}else v&&T-(g.appliedTimelineOffset||0)>hs&&(o.gap=!0);o.setElementaryStreamInfo(c.type,T,S,x,b),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(c,o,d,r,v||E)}else if(v||E)o.gap=!0;else{this.backtrack(o);return}}if(m){const{startPTS:p,endPTS:v,startDTS:E,endDTS:T}=m;d&&(d.elementaryStreams[re.AUDIO]={startPTS:p,endPTS:v,startDTS:E,endDTS:T}),o.setElementaryStreamInfo(re.AUDIO,p,v,E,T),this.bufferFragmentData(m,o,d,r)}if(g&&h!=null&&h.samples.length){const p={id:t,frag:o,details:g,samples:h.samples};s.trigger(y.FRAG_PARSING_METADATA,p)}if(g&&u){const p={id:t,frag:o,details:g,samples:u.samples};s.trigger(y.FRAG_PARSING_USERDATA,p)}}logMuxedErr(e){this.warn("".concat(he(e)?"Media":"Init"," segment with muxed audiovideo where only video expected: ").concat(e.url))}_bufferInitSegment(e,t,s,i){if(this.state!==P.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(s));const{audio:r,video:n,audiovideo:o}=t;if(r){const l=e.audioCodec;let c=ns(r.codec,l);c==="mp4a"&&(c="mp4a.40.5");const u=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){c&&(c.indexOf("mp4a.40.5")!==-1?c="mp4a.40.2":c="mp4a.40.5");const h=r.metadata;h&&"channelCount"in h&&(h.channelCount||1)!==1&&u.indexOf("firefox")===-1&&(c="mp4a.40.5")}c&&c.indexOf("mp4a.40.5")!==-1&&u.indexOf("android")!==-1&&r.container!=="audio/mpeg"&&(c="mp4a.40.2",this.log("Android: force audio codec to ".concat(c))),l&&l!==c&&this.log('Swapping manifest audio codec "'.concat(l,'" for "').concat(c,'"')),r.levelCodec=c,r.id=H.MAIN,this.log("Init audio buffer, container:".concat(r.container,", codecs[selected/level/parsed]=[").concat(c||"","/").concat(l||"","/").concat(r.codec,"]")),delete t.audiovideo}if(n){n.levelCodec=e.videoCodec,n.id=H.MAIN;const l=n.codec;if((l==null?void 0:l.length)===4)switch(l){case"hvc1":case"hev1":n.codec="hvc1.1.6.L120.90";break;case"av01":n.codec="av01.0.04M.08";break;case"avc1":n.codec="avc1.42e01e";break}this.log("Init video buffer, container:".concat(n.container,", codecs[level/parsed]=[").concat(e.videoCodec||"","/").concat(l,"]").concat(n.codec!==l?" parsed-corrected="+n.codec:"").concat(n.supplemental?" supplemental="+n.supplemental:"")),delete t.audiovideo}o&&(this.log("Init audiovideo buffer, container:".concat(o.container,", codecs[level/parsed]=[").concat(e.codecs,"/").concat(o.codec,"]")),delete t.video,delete t.audio);const d=Object.keys(t);if(d.length){if(this.hls.trigger(y.BUFFER_CODECS,t),!this.hls)return;d.forEach(l=>{const u=t[l].initSegment;u!=null&&u.byteLength&&this.hls.trigger(y.BUFFER_APPENDING,{type:l,data:u,frag:s,part:null,chunkMeta:i,parent:s.type})})}this.tickImmediate()}getMainFwdBufferInfo(){const e=this.mediaBuffer&&this.altAudio===2?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,H.MAIN)}get maxBufferLength(){const{levels:e,level:t}=this,s=e==null?void 0:e[t];return s?this.getMaxBufferLength(s.maxBitrate):this.config.maxBufferLength}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=P.IDLE}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&e.seeking===!1){const s=e.currentTime;if(X.isBuffered(e,s)?t=this.getAppendedFrag(s):X.isBuffered(e,s+.1)&&(t=this.getAppendedFrag(s+.1)),t){this.backtrackFragment=null;const i=this.fragPlaying,r=t.level;(!i||t.sn!==i.sn||i.level!==r)&&(this.fragPlaying=t,this.hls.trigger(y.FRAG_CHANGED,{frag:t}),(!i||i.level!==r)&&this.hls.trigger(y.LEVEL_SWITCHED,{level:r}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){var e;if(this.fragPlaying)return this.fragPlaying;const t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;return K(t)?this.getAppendedFrag(t):null}get currentProgramDateTime(){var e;const t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;if(K(t)){const s=this.getLevelDetails(),i=this.currentFrag||(s?lt(null,s.fragments,t):null);if(i){const r=i.programDateTime;if(r!==null){const n=r+(t-i.start)*1e3;return new Date(n)}}}return null}get currentLevel(){const e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){const e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}}class ah extends Pe{constructor(e,t){super("key-loader",t),this.config=void 0,this.keyIdToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const s in this.keyIdToKeyInfo){const i=this.keyIdToKeyInfo[s].loader;if(i){var t;if(e&&e!==((t=i.context)==null?void 0:t.frag.type))return;i.abort()}}}detach(){for(const e in this.keyIdToKeyInfo){const t=this.keyIdToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyIdToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyIdToKeyInfo){const t=this.keyIdToKeyInfo[e].loader;t&&t.destroy()}this.keyIdToKeyInfo={}}createKeyLoadError(e,t=_.KEY_LOAD_ERROR,s,i,r){return new qe({type:W.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:r,error:s,networkDetails:i})}loadClear(e,t,s){if(this.emeController&&this.config.emeEnabled&&!this.emeController.getSelectedKeySystemFormats().length){if(t.length)for(let i=0,r=t.length;i<r;i++){const n=t[i];if(e.cc<=n.cc&&(!he(e)||!he(n)||e.sn<n.sn)||!s&&i==r-1)return this.emeController.selectKeySystemFormat(n).then(o=>{if(!this.emeController)return;n.setKeyFormat(o);const d=os(o);if(d)return this.emeController.getKeySystemAccess([d])})}if(this.config.requireKeySystemAccessOnStart){const i=_t(this.config);if(i.length)return this.emeController.getKeySystemAccess(i)}}return null}load(e){return!e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var s,i;t&&e.setKeyFormat(t);const r=e.decryptdata;if(!r){const l=new Error(t?"Expected frag.decryptdata to be defined after setting format ".concat(t):"Missing decryption data on fragment in onKeyLoading (emeEnabled with controller: ".concat(this.emeController&&this.config.emeEnabled,")"));return Promise.reject(this.createKeyLoadError(e,_.KEY_LOAD_ERROR,l))}const n=r.uri;if(!n)return Promise.reject(this.createKeyLoadError(e,_.KEY_LOAD_ERROR,new Error('Invalid key URI: "'.concat(n,'"'))));const o=Qs(r);let d=this.keyIdToKeyInfo[o];if((s=d)!=null&&s.decryptdata.key)return r.key=d.decryptdata.key,Promise.resolve({frag:e,keyInfo:d});if(this.emeController&&(i=d)!=null&&i.keyLoadPromise)switch(this.emeController.getKeyStatus(d.decryptdata)){case"usable":case"usable-in-future":return d.keyLoadPromise.then(c=>{const{keyInfo:u}=c;return r.key=u.decryptdata.key,{frag:e,keyInfo:u}})}switch(this.log("".concat(this.keyIdToKeyInfo[o]?"Rel":"L","oading").concat(r.keyId?" keyId: "+Ae(r.keyId):""," URI: ").concat(r.uri," from ").concat(e.type," ").concat(e.level)),d=this.keyIdToKeyInfo[o]={decryptdata:r,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},r.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return r.keyFormat==="identity"?this.loadKeyHTTP(d,e):this.loadKeyEME(d,e);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(d,e);default:return Promise.reject(this.createKeyLoadError(e,_.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'.concat(r.method,'"'))))}}loadKeyEME(e,t){const s={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){const i=this.emeController.loadKey(s);return(e.keyLoadPromise=i.then(r=>(e.mediaKeySessionContext=r,s))).catch(r=>{throw e.keyLoadPromise=null,"data"in r&&(r.data.frag=t),r})}return Promise.resolve(s)}loadKeyHTTP(e,t){const s=this.config,i=s.loader,r=new i(s);return t.keyLoader=e.loader=r,e.keyLoadPromise=new Promise((n,o)=>{const d={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},l=s.keyLoadPolicy.default,c={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(h,f,g,m)=>{const{frag:p,keyInfo:v}=g,E=Qs(v.decryptdata);if(!p.decryptdata||v!==this.keyIdToKeyInfo[E])return o(this.createKeyLoadError(p,_.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),m));v.decryptdata.key=p.decryptdata.key=new Uint8Array(h.data),p.keyLoader=null,v.loader=null,n({frag:p,keyInfo:v})},onError:(h,f,g,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,_.KEY_LOAD_ERROR,new Error("HTTP Error ".concat(h.code," loading key ").concat(h.text)),g,te({url:d.url,data:void 0},h)))},onTimeout:(h,f,g)=>{this.resetLoader(f),o(this.createKeyLoadError(t,_.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),g))},onAbort:(h,f,g)=>{this.resetLoader(f),o(this.createKeyLoadError(t,_.INTERNAL_ABORTED,new Error("key loading aborted"),g))}};r.load(d,c,u)})}resetLoader(e){const{frag:t,keyInfo:s,url:i}=e,r=s.loader;t.keyLoader===r&&(t.keyLoader=null,s.loader=null);const n=Qs(s.decryptdata)||i;delete this.keyIdToKeyInfo[n],r&&r.destroy()}}function Qs(a){if(a.keyFormat!==Ee.FAIRPLAY){const e=a.keyId;if(e)return Ae(e)}return a.uri}function fn(a){const{type:e}=a;switch(e){case J.AUDIO_TRACK:return H.AUDIO;case J.SUBTITLE_TRACK:return H.SUBTITLE;default:return H.MAIN}}function Zs(a,e){let t=a.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}class oh{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(y.MANIFEST_LOADING,this.onManifestLoading,this),e.on(y.LEVEL_LOADING,this.onLevelLoading,this),e.on(y.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(y.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(y.LEVELS_UPDATED,this.onLevelsUpdated,this)}unregisterListeners(){const{hls:e}=this;e.off(y.MANIFEST_LOADING,this.onManifestLoading,this),e.off(y.LEVEL_LOADING,this.onLevelLoading,this),e.off(y.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(y.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(y.LEVELS_UPDATED,this.onLevelsUpdated,this)}createInternalLoader(e){const t=this.hls.config,s=t.pLoader,i=t.loader,r=s||i,n=new r(t);return this.loaders[e.type]=n,n}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const e in this.loaders){const t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){const{url:s}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:J.MANIFEST,url:s,deliveryDirectives:null,levelOrTrack:null})}onLevelLoading(e,t){const{id:s,level:i,pathwayId:r,url:n,deliveryDirectives:o,levelInfo:d}=t;this.load({id:s,level:i,pathwayId:r,responseType:"text",type:J.LEVEL,url:n,deliveryDirectives:o,levelOrTrack:d})}onAudioTrackLoading(e,t){const{id:s,groupId:i,url:r,deliveryDirectives:n,track:o}=t;this.load({id:s,groupId:i,level:null,responseType:"text",type:J.AUDIO_TRACK,url:r,deliveryDirectives:n,levelOrTrack:o})}onSubtitleTrackLoading(e,t){const{id:s,groupId:i,url:r,deliveryDirectives:n,track:o}=t;this.load({id:s,groupId:i,level:null,responseType:"text",type:J.SUBTITLE_TRACK,url:r,deliveryDirectives:n,levelOrTrack:o})}onLevelsUpdated(e,t){const s=this.loaders[J.LEVEL];if(s){const i=s.context;i&&!t.levels.some(r=>r===i.levelOrTrack)&&(s.abort(),delete this.loaders[J.LEVEL])}}load(e){var t;const s=this.hls.config;let i=this.getInternalLoader(e);if(i){const l=this.hls.logger,c=i.context;if(c&&c.levelOrTrack===e.levelOrTrack&&(c.url===e.url||c.deliveryDirectives&&!e.deliveryDirectives)){c.url===e.url?l.log("[playlist-loader]: ignore ".concat(e.url," ongoing request")):l.log("[playlist-loader]: ignore ".concat(e.url," in favor of ").concat(c.url));return}l.log("[playlist-loader]: aborting previous loader for type: ".concat(e.type)),i.abort()}let r;if(e.type===J.MANIFEST?r=s.manifestLoadPolicy.default:r=ie({},s.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),i=this.createInternalLoader(e),K((t=e.deliveryDirectives)==null?void 0:t.part)){let l;if(e.type===J.LEVEL&&e.level!==null?l=this.hls.levels[e.level].details:e.type===J.AUDIO_TRACK&&e.id!==null?l=this.hls.audioTracks[e.id].details:e.type===J.SUBTITLE_TRACK&&e.id!==null&&(l=this.hls.subtitleTracks[e.id].details),l){const c=l.partTarget,u=l.targetduration;if(c&&u){const h=Math.max(c*3,u*.8)*1e3;r=ie({},r,{maxTimeToFirstByteMs:Math.min(h,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,r.maxTimeToFirstByteMs)})}}}const n=r.errorRetry||r.timeoutRetry||{},o={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:n.maxNumRetry||0,retryDelay:n.retryDelayMs||0,maxRetryDelay:n.maxRetryDelayMs||0},d={onSuccess:(l,c,u,h)=>{const f=this.getInternalLoader(u);this.resetInternalLoader(u.type);const g=l.data;c.parsing.start=performance.now(),Ke.isMediaPlaylist(g)||u.type!==J.MANIFEST?this.handleTrackOrLevelPlaylist(l,c,u,h||null,f):this.handleMasterPlaylist(l,c,u,h)},onError:(l,c,u,h)=>{this.handleNetworkError(c,u,!1,l,h)},onTimeout:(l,c,u)=>{this.handleNetworkError(c,u,!0,void 0,l)}};i.load(e,o,d)}checkAutostartLoad(){if(!this.hls)return;const{config:{autoStartLoad:e,startPosition:t},forceStartLoad:s}=this.hls;(e||s)&&(this.hls.logger.log("".concat(e?"auto":"force"," startLoad with configured startPosition ").concat(t)),this.hls.startLoad(t))}handleMasterPlaylist(e,t,s,i){const r=this.hls,n=e.data,o=Zs(e,s),d=Ke.parseMasterPlaylist(n,o);if(d.playlistParsingError){t.parsing.end=performance.now(),this.handleManifestParsingError(e,s,d.playlistParsingError,i,t);return}const{contentSteering:l,levels:c,sessionData:u,sessionKeys:h,startTimeOffset:f,variableList:g}=d;this.variableList=g,c.forEach(E=>{const{unknownCodecs:T}=E;if(T){const{preferManagedMediaSource:S}=this.hls.config;let{audioCodec:x,videoCodec:b}=E;for(let A=T.length;A--;){const I=T[A];wt(I,"audio",S)?(E.audioCodec=x=x?"".concat(x,",").concat(I):I,St.audio[x.substring(0,4)]=2,T.splice(A,1)):wt(I,"video",S)&&(E.videoCodec=b=b?"".concat(b,",").concat(I):I,St.video[b.substring(0,4)]=2,T.splice(A,1))}}});const{AUDIO:m=[],SUBTITLES:p,"CLOSED-CAPTIONS":v}=Ke.parseMasterPlaylistMedia(n,o,d);m.length&&!m.some(T=>!T.url)&&c[0].audioCodec&&!c[0].attrs.AUDIO&&(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),m.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new de({}),bitrate:0,url:""})),r.trigger(y.MANIFEST_LOADED,{levels:c,audioTracks:m,subtitles:p,captions:v,contentSteering:l,url:o,stats:t,networkDetails:i,sessionData:u,sessionKeys:h,startTimeOffset:f,variableList:g})}handleTrackOrLevelPlaylist(e,t,s,i,r){const n=this.hls,{id:o,level:d,type:l}=s,c=Zs(e,s),u=K(d)?d:K(o)?o:0,h=fn(s),f=Ke.parseLevelPlaylist(e.data,c,u,h,0,this.variableList);if(l===J.MANIFEST){const g={attrs:new de({}),bitrate:0,details:f,name:"",url:c};f.requestScheduled=t.loading.start+Wn(f,0),n.trigger(y.MANIFEST_LOADED,{levels:[g],audioTracks:[],url:c,stats:t,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),s.levelDetails=f,this.handlePlaylistLoaded(f,e,t,s,i,r)}handleManifestParsingError(e,t,s,i,r){this.hls.trigger(y.ERROR,{type:W.NETWORK_ERROR,details:_.MANIFEST_PARSING_ERROR,fatal:t.type===J.MANIFEST,url:e.url,err:s,error:s,reason:s.message,response:e,context:t,networkDetails:i,stats:r})}handleNetworkError(e,t,s=!1,i,r){let n="A network ".concat(s?"timeout":"error"+(i?" (status "+i.code+")":"")," occurred while loading ").concat(e.type);e.type===J.LEVEL?n+=": ".concat(e.level," id: ").concat(e.id):(e.type===J.AUDIO_TRACK||e.type===J.SUBTITLE_TRACK)&&(n+=" id: ".concat(e.id,' group-id: "').concat(e.groupId,'"'));const o=new Error(n);this.hls.logger.warn("[playlist-loader]: ".concat(n));let d=_.UNKNOWN,l=!1;const c=this.getInternalLoader(e);switch(e.type){case J.MANIFEST:d=s?_.MANIFEST_LOAD_TIMEOUT:_.MANIFEST_LOAD_ERROR,l=!0;break;case J.LEVEL:d=s?_.LEVEL_LOAD_TIMEOUT:_.LEVEL_LOAD_ERROR,l=!1;break;case J.AUDIO_TRACK:d=s?_.AUDIO_TRACK_LOAD_TIMEOUT:_.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case J.SUBTITLE_TRACK:d=s?_.SUBTITLE_TRACK_LOAD_TIMEOUT:_.SUBTITLE_LOAD_ERROR,l=!1;break}c&&this.resetInternalLoader(e.type);const u={type:W.NETWORK_ERROR,details:d,fatal:l,url:e.url,loader:c,context:e,error:o,networkDetails:t,stats:r};if(i){const h=(t==null?void 0:t.url)||e.url;u.response=te({url:h,data:void 0},i)}this.hls.trigger(y.ERROR,u)}handlePlaylistLoaded(e,t,s,i,r,n){const o=this.hls,{type:d,level:l,levelOrTrack:c,id:u,groupId:h,deliveryDirectives:f}=i,g=Zs(t,i),m=fn(i);let p=typeof i.level=="number"&&m===H.MAIN?l:void 0;const v=e.playlistParsingError;if(v){if(this.hls.logger.warn("".concat(v," ").concat(e.url)),!o.config.ignorePlaylistParsingErrors){o.trigger(y.ERROR,{type:W.NETWORK_ERROR,details:_.LEVEL_PARSING_ERROR,fatal:!1,url:g,error:v,reason:v.message,response:t,context:i,level:p,parent:m,networkDetails:r,stats:s});return}e.playlistParsingError=null}if(!e.fragments.length){const E=e.playlistParsingError=new Error("No Segments found in Playlist");o.trigger(y.ERROR,{type:W.NETWORK_ERROR,details:_.LEVEL_EMPTY_ERROR,fatal:!1,url:g,error:E,reason:E.message,response:t,context:i,level:p,parent:m,networkDetails:r,stats:s});return}switch(e.live&&n&&(n.getCacheAge&&(e.ageHeader=n.getCacheAge()||0),(!n.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),d){case J.MANIFEST:case J.LEVEL:if(p){if(!c)p=0;else if(c!==o.levels[p]){const E=o.levels.indexOf(c);E>-1&&(p=E)}}o.trigger(y.LEVEL_LOADED,{details:e,levelInfo:c||o.levels[0],level:p||0,id:u||0,stats:s,networkDetails:r,deliveryDirectives:f,withoutMultiVariant:d===J.MANIFEST});break;case J.AUDIO_TRACK:o.trigger(y.AUDIO_TRACK_LOADED,{details:e,track:c,id:u||0,groupId:h||"",stats:s,networkDetails:r,deliveryDirectives:f});break;case J.SUBTITLE_TRACK:o.trigger(y.SUBTITLE_TRACK_LOADED,{details:e,track:c,id:u||0,groupId:h||"",stats:s,networkDetails:r,deliveryDirectives:f});break}}}class at{static get version(){return $t}static isMSESupported(){return Ha()}static isSupported(){return sh()}static getMediaSource(){return Je()}static get Events(){return y}static get MetadataSchema(){return Re}static get ErrorTypes(){return W}static get ErrorDetails(){return _}static get DefaultConfig(){return at.defaultConfig?at.defaultConfig:Hu}static set DefaultConfig(e){at.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new ki,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;const t=this.logger=fo(e.debug||!1,"Hls instance",e.assetPlayerId),s=this.config=Yu(at.DefaultConfig,e,t);this.userConfig=e,s.progressive&&qu(s,t);const{abrController:i,bufferController:r,capLevelController:n,errorController:o,fpsController:d}=s,l=new o(this),c=this.abrController=new i(this),u=new ol(this),h=s.interstitialsController,f=h?this.interstitialsController=new h(this,at):null,g=this.bufferController=new r(this,u),m=this.capLevelController=new n(this),p=new d(this),v=new oh(this),E=s.contentSteeringController,T=E?new E(this):null,S=this.levelController=new th(this,T),x=new Ju(this),b=new ah(this.config,this.logger),A=this.streamController=new nh(this,u,b),I=this.gapController=new Qu(this,u);m.setStreamController(A),p.setStreamController(A);const R=[v,S,A];f&&R.splice(1,0,f),T&&R.splice(1,0,T),this.networkControllers=R;const L=[c,g,I,m,p,x,u];this.audioTrackController=this.createController(s.audioTrackController,R);const w=s.audioStreamController;w&&R.push(this.audioStreamController=new w(this,u,b)),this.subtitleTrackController=this.createController(s.subtitleTrackController,R);const U=s.subtitleStreamController;U&&R.push(this.subtititleStreamController=new U(this,u,b)),this.createController(s.timelineController,L),b.emeController=this.emeController=this.createController(s.emeController,L),this.cmcdController=this.createController(s.cmcdController,L),this.latencyController=this.createController(eh,L),this.coreComponents=L,R.push(l);const V=l.onErrorOut;typeof V=="function"&&this.on(y.ERROR,V,l),this.on(y.MANIFEST_LOADED,v.onManifestLoaded,v)}createController(e,t){if(e){const s=new e(this);return t&&t.push(s),s}return null}on(e,t,s=this){this._emitter.on(e,t,s)}once(e,t,s=this){this._emitter.once(e,t,s)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,s=this,i){this._emitter.off(e,t,s,i)}listeners(e){return this._emitter.listeners(e)}emit(e,t,s){return this._emitter.emit(e,t,s)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(s){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+s.message+'". Here is a stacktrace:',s),!this.triggeringException){this.triggeringException=!0;const i=e===y.ERROR;this.trigger(y.ERROR,{type:W.OTHER_ERROR,details:_.INTERNAL_EXCEPTION,fatal:i,event:e,error:s}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){this.logger.log("destroy"),this.trigger(y.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,this.networkControllers.forEach(t=>t.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(t=>t.destroy()),this.coreComponents.length=0;const e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){if(!e||"media"in e&&!e.media){const r=new Error("attachMedia failed: invalid argument (".concat(e,")"));this.trigger(y.ERROR,{type:W.OTHER_ERROR,details:_.ATTACH_MEDIA_ERROR,fatal:!0,error:r});return}this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());const t="media"in e,s=t?e.media:e,i=t?e:{media:s};this._media=s,this.trigger(y.MEDIA_ATTACHING,i)}detachMedia(){this.logger.log("detachMedia"),this.trigger(y.MEDIA_DETACHING,{}),this._media=null}transferMedia(){this._media=null;const e=this.bufferController.transferMedia();return this.trigger(y.MEDIA_DETACHING,{transferMedia:e}),e}loadSource(e){this.stopLoad();const t=this.media,s=this._url,i=this._url=vi.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log("loadSource:".concat(i)),t&&s&&(s!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(y.MANIFEST_LOADING,{url:e})}get url(){return this._url}get hasEnoughToStart(){return this.streamController.hasEnoughToStart}get startPosition(){return this.streamController.startPositionValue}startLoad(e=-1,t){this.logger.log("startLoad(".concat(e+(t?", <skip seek to start>":""),")")),this.started=!0,this.resumeBuffering();for(let s=0;s<this.networkControllers.length&&(this.networkControllers[s].startLoad(e,t),!(!this.started||!this.networkControllers));s++);}stopLoad(){this.logger.log("stopLoad"),this.started=!1;for(let e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!(this.started||!this.networkControllers));e++);}get loadingEnabled(){return this.started}get bufferingEnabled(){return this.streamController.bufferingEnabled}resumeBuffering(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering()}))}pauseBuffering(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering()}))}get inFlightFragments(){const e={[H.MAIN]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[H.AUDIO]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[H.SUBTITLE]=this.subtititleStreamController.inFlightFrag),e}swapAudioCodec(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){this.logger.log("recoverMediaError");const e=this._media,t=e==null?void 0:e.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&this.startLoad(t))}removeLevel(e){this.levelController.removeLevel(e)}get sessionId(){let e=this._sessionId;return e||(e=this._sessionId=Qc()),e}get levels(){const e=this.levelController.levels;return e||[]}get latestLevelDetails(){return this.streamController.getLevelDetails()||null}get loadLevelObj(){return this.levelController.loadLevelObj}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){this.logger.log("set currentLevel:".concat(e)),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){this.logger.log("set nextLevel:".concat(e)),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){this.logger.log("set loadLevel:".concat(e)),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){this.logger.log("set firstLevel:".concat(e)),this.levelController.firstLevel=e}get startLevel(){const e=this.levelController.startLevel;return e===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){this.logger.log("set startLevel:".concat(e)),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){const t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e)}get abrEwmaDefaultEstimate(){const{bwEstimator:e}=this.abrController;return e?e.defaultEstimate:NaN}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(this.logger.log("set autoLevelCapping:".concat(e)),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){Wo(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;const s=e.length;for(let i=0;i<s;i++)if(e[i].maxBitrate>=t)return i;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:s}=this;let i;if(t===-1&&e!=null&&e.length?i=e.length-1:i=t,s)for(let r=i;r--;){const n=e[r].attrs["HDCP-LEVEL"];if(n&&n<=s)return r}return i}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get maxBufferLength(){return this.streamController.maxBufferLength}setAudioOption(e){var t;return((t=this.audioTrackController)==null?void 0:t.setAudioOption(e))||null}setSubtitleOption(e){var t;return((t=this.subtitleTrackController)==null?void 0:t.setSubtitleOption(e))||null}get allAudioTracks(){const e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){const e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){const e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){const t=this.audioTrackController;t&&(t.audioTrack=e)}get allSubtitleTracks(){const e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){const e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){const e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){const t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){const e=this.subtitleTrackController;return e?e.subtitleDisplay:!1}set subtitleDisplay(e){const t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}set targetLatency(e){this.latencyController.targetLatency=e}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}get pathways(){return this.levelController.pathways}get pathwayPriority(){return this.levelController.pathwayPriority}set pathwayPriority(e){this.levelController.pathwayPriority=e}get bufferedToEnd(){var e;return!!((e=this.bufferController)!=null&&e.bufferedToEnd)}get interstitialsManager(){var e;return((e=this.interstitialsController)==null?void 0:e.interstitialsManager)||null}getMediaDecodingInfo(e,t=this.allAudioTracks){const s=Pn(t);return kn(e,s,navigator.mediaCapabilities)}}at.defaultConfig=void 0;export{at as H,uh as a,ch as b};
|